1 /* arch/arm/mach-rk29/board-rk29-phonesdk.c
3 * Copyright (C) 2010 ROCKCHIP, Inc.
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
21 #include <linux/delay.h>
22 #include <linux/i2c.h>
23 #include <linux/spi/spi.h>
24 #include <linux/mmc/host.h>
25 #include <linux/android_pmem.h>
26 #include <linux/usb/android_composite.h>
28 #include <mach/hardware.h>
29 #include <asm/setup.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/flash.h>
34 #include <asm/hardware/gic.h>
36 #include <mach/iomux.h>
37 #include <mach/gpio.h>
38 #include <mach/irqs.h>
39 #include <mach/rk29_iomap.h>
40 #include <mach/board.h>
41 #include <mach/rk29_nand.h>
42 #include <mach/rk29_camera.h> /* ddl@rock-chips.com : camera support */
43 #include <media/soc_camera.h> /* ddl@rock-chips.com : camera support */
44 #include <mach/vpu_mem.h>
45 #include <mach/sram.h>
47 #include <mach/cpufreq.h>
49 #include <linux/regulator/rk29-pwm-regulator.h>
50 #include <linux/regulator/machine.h>
51 #include <linux/mfd/wm831x/pdata.h>
52 #include <linux/mfd/wm831x/core.h>
53 #include <linux/mfd/wm831x/gpio.h>
54 #include <linux/mfd/wm8994/pdata.h>
55 #include <linux/mfd/wm8994/registers.h>
57 #include <linux/mtd/nand.h>
58 #include <linux/mtd/partitions.h>
59 #include <linux/i2c-gpio.h>
60 #include <linux/mpu.h>
64 #if defined(CONFIG_MTK23D)
65 #include <linux/mtk23d.h>
68 #ifdef CONFIG_USE_GPIO_GENERATE_WAVE
69 #include "../../../drivers/testcode/gpio_wave.h"
72 #include "../../../drivers/headset_observe/rk_headset.h"
73 /*set touchscreen different type header*/
74 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI)
75 #include "../../../drivers/input/touchscreen/xpt2046_ts.h"
76 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
77 #include "../../../drivers/input/touchscreen/xpt2046_tslib_ts.h"
78 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
79 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
81 #include "../../../drivers/misc/gps/rk29_gps.h"
82 #include "../../../drivers/serial/sc8800.h"
83 #ifdef CONFIG_VIDEO_RK29
84 /*---------------- Camera Sensor Macro Define Begin ------------------------*/
85 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
86 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642 /* back camera sensor */
87 #define CONFIG_SENSOR_IIC_ADDR_0 0x78
88 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0 1
89 #define CONFIG_SENSOR_POWER_PIN_0 INVALID_GPIO
90 #define CONFIG_SENSOR_RESET_PIN_0 INVALID_GPIO
91 #define CONFIG_SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
92 #define CONFIG_SENSOR_FALSH_PIN_0 INVALID_GPIO
93 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
94 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
95 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
96 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
98 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659 /* front camera sensor */
99 #define CONFIG_SENSOR_IIC_ADDR_1 0x60
100 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1 1
101 #define CONFIG_SENSOR_POWER_PIN_1 INVALID_GPIO
102 #define CONFIG_SENSOR_RESET_PIN_1 INVALID_GPIO
103 #define CONFIG_SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
104 #define CONFIG_SENSOR_FALSH_PIN_1 INVALID_GPIO
105 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
106 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
107 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
108 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
109 #endif //#ifdef CONFIG_VIDEO_RK29
110 /*---------------- Camera Sensor Configuration Macro End------------------------*/
111 #include "../../../drivers/media/video/rk29_camera.c"
112 /*---------------- Camera Sensor Macro Define End ------------------------*/
115 /* Set memory size of pmem */
116 #ifdef CONFIG_RK29_MEM_SIZE_M
117 #define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
119 #define SDRAM_SIZE SZ_512M
121 #define PMEM_GPU_SIZE SZ_64M
122 #define PMEM_UI_SIZE SZ_32M
123 #define PMEM_VPU_SIZE SZ_64M
124 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
125 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
126 #define MEM_CAMIPP_SIZE SZ_4M
128 #define MEM_CAMIPP_SIZE 0
130 #define MEM_FB_SIZE (3*SZ_2M)
131 #ifdef CONFIG_FB_WORK_IPP
132 #define MEM_FBIPP_SIZE SZ_8M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4
134 #define MEM_FBIPP_SIZE 0
136 #if SDRAM_SIZE > SZ_512M
137 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
139 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
141 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
142 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
143 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
144 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
145 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
146 #define MEM_FBIPP_BASE (MEM_FB_BASE - MEM_FBIPP_SIZE)
147 #define LINUX_SIZE (MEM_FBIPP_BASE - RK29_SDRAM_PHYS)
149 #define PREALLOC_WLAN_SEC_NUM 4
150 #define PREALLOC_WLAN_BUF_NUM 160
151 #define PREALLOC_WLAN_SECTION_HEADER 24
153 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
154 #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
155 #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
156 #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
158 #define WLAN_SKB_BUF_NUM 16
160 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
162 struct wifi_mem_prealloc {
167 extern struct sys_timer rk29_timer;
169 static int rk29_nand_io_init(void)
174 struct rk29_nand_platform_data rk29_nand_data = {
175 .width = 1, /* data bus width in bytes */
176 .hw_ecc = 1, /* hw ecc 0: soft ecc */
178 .io_init = rk29_nand_io_init,
181 #ifdef CONFIG_FB_RK29
182 /*****************************************************************************************
184 * author: zyw@rock-chips.com
185 *****************************************************************************************/
186 //#ifdef CONFIG_LCD_TD043MGEA1
187 #define LCD_RXD_PIN RK29_PIN2_PC7
188 #define LCD_TXD_PIN RK29_PIN2_PC6
189 #define LCD_CLK_PIN RK29_PIN2_PC4
190 #define LCD_CS_PIN RK29_PIN2_PC5
191 /*****************************************************************************************
192 * frame buffer devices
193 * author: zyw@rock-chips.com
194 *****************************************************************************************/
196 #define FB_DISPLAY_ON_PIN INVALID_GPIO//RK29_PIN6_PD0
197 #define FB_LCD_STANDBY_PIN INVALID_GPIO//RK29_PIN6_PD1
198 #define FB_LCD_CABC_EN_PIN INVALID_GPIO//RK29_PIN6_PD2
199 #define FB_MCU_FMK_PIN INVALID_GPIO
201 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
202 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
205 static int rk29_lcd_io_init(void)
208 //printk("rk29_lcd_io_init\n");
209 //ret = gpio_request(LCD_RXD_PIN, NULL);
210 ret = gpio_request(LCD_TXD_PIN, NULL);
211 ret = gpio_request(LCD_CLK_PIN, NULL);
212 ret = gpio_request(LCD_CS_PIN, NULL);
213 //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_GPIO2C7);
214 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_GPIO2C6);
215 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_GPIO2C5);
216 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_GPIO2C4);
220 static int rk29_lcd_io_deinit(void)
223 //printk("rk29_lcd_io_deinit\n");
224 gpio_free(LCD_CS_PIN);
225 gpio_free(LCD_CLK_PIN);
226 gpio_free(LCD_TXD_PIN);
227 //gpio_free(LCD_RXD_PIN);
228 //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_SPI1_RXD);
229 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_SPI1_TXD);
230 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_SPI1_CSN0);
231 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_SPI1_CLK);
235 static struct rk29lcd_info rk29_lcd_info = {
236 .txd_pin = LCD_TXD_PIN,
237 .clk_pin = LCD_CLK_PIN,
238 .cs_pin = LCD_CS_PIN,
239 .io_init = rk29_lcd_io_init,
240 .io_deinit = rk29_lcd_io_deinit,
243 int rk29_fb_io_enable(void)
245 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
247 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
248 gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);
250 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
252 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
253 gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);
258 int rk29_fb_io_disable(void)
260 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
262 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
263 gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);
265 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
267 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
268 gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);
273 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
276 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
278 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
281 gpio_free(FB_MCU_FMK_PIN);
282 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
284 gpio_direction_input(FB_MCU_FMK_PIN);
286 if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
288 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
291 gpio_free(FB_DISPLAY_ON_PIN);
292 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
296 if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
298 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
301 gpio_free(FB_LCD_STANDBY_PIN);
302 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
306 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
308 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
311 gpio_free(FB_LCD_CABC_EN_PIN);
312 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
314 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
315 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
317 rk29_fb_io_enable(); //enable it
322 static struct rk29fb_info rk29_fb_info = {
324 .mcu_fmk_pin = FB_MCU_FMK_PIN,
325 .lcd_info = &rk29_lcd_info,
326 .io_init = rk29_fb_io_init,
327 .io_enable = rk29_fb_io_enable,
328 .io_disable = rk29_fb_io_disable,
331 /* rk29 fb resource */
332 static struct resource rk29_fb_resource[] = {
335 .start = RK29_LCDC_PHYS,
336 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
337 .flags = IORESOURCE_MEM,
343 .flags = IORESOURCE_IRQ,
347 .start = MEM_FB_BASE,
348 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
349 .flags = IORESOURCE_MEM,
351 #ifdef CONFIG_FB_WORK_IPP
353 .name = "win1 ipp buf",
354 .start = MEM_FBIPP_BASE,
355 .end = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
356 .flags = IORESOURCE_MEM,
362 struct platform_device rk29_device_fb = {
365 .num_resources = ARRAY_SIZE(rk29_fb_resource),
366 .resource = rk29_fb_resource,
368 .platform_data = &rk29_fb_info,
372 struct platform_device rk29_device_dma_cpy = {
373 .name = "dma_memcpy",
380 static struct android_pmem_platform_data android_pmem_pdata = {
382 .start = PMEM_UI_BASE,
383 .size = PMEM_UI_SIZE,
388 static struct platform_device android_pmem_device = {
389 .name = "android_pmem",
392 .platform_data = &android_pmem_pdata,
397 static struct vpu_mem_platform_data vpu_mem_pdata = {
399 .start = PMEM_VPU_BASE,
400 .size = PMEM_VPU_SIZE,
404 static struct platform_device rk29_vpu_mem_device = {
408 .platform_data = &vpu_mem_pdata,
412 static struct platform_device rk29_v4l2_output_devce = {
416 /* HANNSTAR_P1003 touch I2C */
417 #if defined (CONFIG_HANNSTAR_P1003)
418 #define TOUCH_RESET_PIN RK29_PIN6_PC3
419 #define TOUCH_INT_PIN RK29_PIN4_PD5
421 int p1003_init_platform_hw(void)
423 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
424 gpio_free(TOUCH_RESET_PIN);
425 printk("p1003_init_platform_hw gpio_request error\n");
429 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
430 gpio_free(TOUCH_INT_PIN);
431 printk("p1003_init_platform_hw gpio_request error\n");
434 gpio_pull_updown(TOUCH_INT_PIN, 1);
435 gpio_direction_output(TOUCH_RESET_PIN, 0);
437 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
439 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
445 struct p1003_platform_data p1003_info = {
447 .init_platform_hw= p1003_init_platform_hw,
453 #if defined(CONFIG_TOUCHSCREEN_GT801_IIC)
454 #include "../../../drivers/input/touchscreen/gt801_ts.h"
455 #define GT801_GPIO_INT RK29_PIN4_PD5
456 #define GT801_GPIO_RESET RK29_PIN6_PC3
457 static struct gt801_platform_data gt801_info = {
464 .gpio_reset = GT801_GPIO_RESET,
465 .gpio_reset_active_low = 0,
466 .gpio_pendown = GT801_GPIO_INT,
467 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
468 .resetpin_iomux_name = NULL,
469 .pendown_iomux_mode = GPIO4H_GPIO4D5,
470 .resetpin_iomux_mode = 0,
475 #if defined(CONFIG_TOUCHSCREEN_GT818_IIC)
476 #include "../../../drivers/input/touchscreen/gt818_ts.h"
477 #define GT818_GPIO_INT RK29_PIN4_PD5
478 #define GT818_GPIO_RESET RK29_PIN6_PC3
479 static struct gt818_platform_data gt818_info = {
486 .gpio_reset = GT818_GPIO_RESET,
487 .gpio_reset_active_low = 0,
488 .gpio_pendown = GT818_GPIO_INT,
489 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
490 .resetpin_iomux_name = NULL,
491 .pendown_iomux_mode = GPIO4H_GPIO4D5,
492 .resetpin_iomux_mode = 0,
496 #if defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
497 #include "../../../drivers/input/touchscreen/ili2102_ts.h"
498 #define GT801_GPIO_INT RK29_PIN4_PD5
499 #define GT801_GPIO_RESET RK29_PIN6_PC3
500 static struct ili2102_platform_data ili2102_info = {
507 .gpio_reset = GT801_GPIO_RESET,
508 .gpio_reset_active_low = 1,
509 .gpio_pendown = GT801_GPIO_INT,
510 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
511 .resetpin_iomux_name = NULL,
512 .pendown_iomux_mode = GPIO4H_GPIO4D5,
513 .resetpin_iomux_mode = 0,
517 /* EETI_EGALAX touch I2C */
518 #if defined (CONFIG_EETI_EGALAX)
519 #define TOUCH_RESET_PIN RK29_PIN6_PC3
520 #define TOUCH_INT_PIN RK29_PIN4_PD5
522 static int EETI_EGALAX_init_platform_hw(void)
524 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
525 gpio_free(TOUCH_RESET_PIN);
526 printk("p1003_init_platform_hw gpio_request error\n");
530 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
531 gpio_free(TOUCH_INT_PIN);
532 printk("p1003_init_platform_hw gpio_request error\n");
535 gpio_pull_updown(TOUCH_INT_PIN, 1);
536 gpio_direction_output(TOUCH_RESET_PIN, 0);
538 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
540 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
546 static struct eeti_egalax_platform_data eeti_egalax_info = {
548 .init_platform_hw= EETI_EGALAX_init_platform_hw,
554 #if defined (CONFIG_GS_MMA8452)
555 #define MMA8452_INT_PIN RK29_PIN6_PC4
557 static int mma8452_init_platform_hw(void)
560 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
561 gpio_free(MMA8452_INT_PIN);
562 printk("mma8452_init_platform_hw gpio_request error\n");
565 gpio_pull_updown(MMA8452_INT_PIN, 1);
570 static struct mma8452_platform_data mma8452_info = {
573 .init_platform_hw= mma8452_init_platform_hw,
578 #if defined (CONFIG_MPU_SENSORS_MPU3050)
580 static struct mpu3050_platform_data mpu3050_data = {
582 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
583 //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
584 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
585 //.orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
586 .orientation = { 1, 0, 0,0, 1, 0, 0, 0, 1 },
588 #if defined (CONFIG_MPU_SENSORS_KXTF9)
590 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
591 .get_slave_descr = NULL ,
593 .get_slave_descr = get_accel_slave_descr ,
595 .adapt_num = 0, // The i2c bus to which the mpu device is
597 //.irq = RK29_PIN6_PC4,
598 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
600 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
601 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
602 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
603 //.orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
604 .orientation = {1, 0, 0, 0, 1, 0, 0, 0, 1},
607 #if defined (CONFIG_MPU_SENSORS_AK8975)
609 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
610 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
612 .get_slave_descr = get_compass_slave_descr,
614 .adapt_num = 0, // The i2c bus to which the compass device is.
615 // It can be difference with mpu
617 //.irq = RK29_PIN6_PC5,
618 .bus = EXT_SLAVE_BUS_PRIMARY,
620 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
621 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
622 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
623 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
624 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
630 #if defined(CONFIG_GPIO_WM831X)
631 struct rk29_gpio_expander_info wm831x_gpio_settinginfo[] = {
633 .gpio_num =WM831X_P01,// tp3
634 .pin_type = GPIO_OUT,
635 .pin_value =GPIO_HIGH,
639 .gpio_num =WM831X_P02,//tp4
640 .pin_type = GPIO_OUT,
641 .pin_value =GPIO_HIGH,
644 .gpio_num =WM831X_P03,//tp2
645 .pin_type = GPIO_OUT,
646 .pin_value =GPIO_HIGH,
649 .gpio_num =WM831X_P04,//tp1
650 .pin_type = GPIO_OUT,
651 .pin_value =GPIO_HIGH,
654 .gpio_num =WM831X_P05,//tp1
655 .pin_type = GPIO_OUT,
656 .pin_value =GPIO_HIGH,
659 .gpio_num =WM831X_P06,//tp1
660 .pin_type = GPIO_OUT,
661 .pin_value =GPIO_HIGH,
664 .gpio_num =WM831X_P07,//tp1
665 .pin_type = GPIO_OUT,
666 .pin_value =GPIO_HIGH,
669 .gpio_num =WM831X_P08,//tp1
670 .pin_type = GPIO_OUT,
671 .pin_value =GPIO_HIGH,
674 .gpio_num =WM831X_P09,//tp1
675 .pin_type = GPIO_OUT,
676 .pin_value =GPIO_HIGH,
679 .gpio_num =WM831X_P10,//tp1
680 .pin_type = GPIO_OUT,
681 .pin_value =GPIO_HIGH,
684 .gpio_num =WM831X_P11,//tp1
685 .pin_type = GPIO_OUT,
686 .pin_value =GPIO_HIGH,
689 .gpio_num =WM831X_P12,
690 .pin_type = GPIO_OUT,
691 .pin_value =GPIO_HIGH,
699 #if defined(CONFIG_MFD_WM831X)
700 static struct wm831x *gWm831x;
701 int wm831x_pre_init(struct wm831x *parm)
704 printk("%s\n", __FUNCTION__);
707 ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
708 wm831x_reg_write(parm, WM831X_POWER_STATE, (ret&0xfff8) | 0x04);
711 wm831x_set_bits(parm, WM831X_RESET_CONTROL,0x1000,0x1000);
712 ret = wm831x_reg_read(parm, WM831X_RESET_CONTROL) & 0xffff;
713 printk("%s:WM831X_RESET_CONTROL=0x%x\n",__FUNCTION__,ret);
716 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 3), 0);
717 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 7), 0);
718 printk("%s:disable ldo4 and ldo8 because they are enabled in uboot\n",__FUNCTION__);
722 int wm831x_post_init(struct wm831x *parm)
724 struct regulator *dcdc;
725 struct regulator *ldo;
727 dcdc = regulator_get(NULL, "dcdc3"); // 1th IO
728 regulator_set_voltage(dcdc,3000000,3000000);
729 regulator_set_suspend_voltage(dcdc, 2800000);
730 regulator_enable(dcdc);
731 printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
735 ldo = regulator_get(NULL, "ldo10"); // 1th modem IO
736 regulator_set_voltage(ldo,3000000,3000000);
737 regulator_set_suspend_voltage(ldo,3000000);
738 regulator_enable(ldo);
739 printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
743 dcdc = regulator_get(NULL, "dcdc2"); // 2th CORE
744 regulator_set_voltage(dcdc,1300000,1300000);
745 regulator_set_suspend_voltage(dcdc,1000000);
746 regulator_enable(dcdc);
747 printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
751 dcdc = regulator_get(NULL, "dcdc1"); // 3th ddr
752 regulator_set_voltage(dcdc,1800000,1800000);
753 regulator_set_suspend_voltage(ldo, 1800000);
754 regulator_enable(dcdc);
755 printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
759 ldo = regulator_get(NULL, "ldo1"); // 3th nand
760 regulator_set_voltage(ldo,1800000,1800000);
761 regulator_set_suspend_voltage(ldo,1800000);
762 regulator_enable(ldo);
763 printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
767 ldo = regulator_get(NULL, "ldo4"); // 4th usb
768 regulator_set_voltage(ldo,2500000,2500000);
769 regulator_set_suspend_voltage(ldo,0000000);
770 regulator_enable(ldo);
771 printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
775 ldo = regulator_get(NULL, "ldo7"); // 5th usb
776 regulator_set_voltage(ldo,3300000,3300000);
777 regulator_set_suspend_voltage(ldo,3300000);
778 regulator_enable(ldo);
779 printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
783 dcdc = regulator_get(NULL, "dcdc4"); // backlight
784 regulator_set_voltage(dcdc,20000000,20000000);
785 regulator_set_suspend_voltage(dcdc, 20000000);
786 regulator_enable(dcdc);
787 printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
792 ldo = regulator_get(NULL, "ldo2"); //lcd
793 regulator_set_voltage(ldo,3000000,3000000);
794 regulator_set_suspend_voltage(ldo,3000000);
795 regulator_enable(ldo);
796 printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
800 ldo = regulator_get(NULL, "ldo5"); //tf
801 regulator_set_voltage(ldo,3000000,3000000);
802 regulator_set_suspend_voltage(ldo,3000000);
803 regulator_enable(ldo);
804 printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
807 ldo = regulator_get(NULL, "ldo6"); //camera
808 regulator_set_voltage(ldo,1800000,1800000);
809 regulator_set_suspend_voltage(ldo,1800000);
810 regulator_enable(ldo);
811 printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
817 ldo = regulator_get(NULL, "ldo3"); //sram
818 regulator_set_voltage(ldo,1800000,1800000);
819 regulator_set_suspend_voltage(ldo,1800000);
820 regulator_enable(ldo);
821 printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
825 ldo = regulator_get(NULL, "ldo8"); //cmmb
826 regulator_set_voltage(ldo,1200000,1200000);
827 regulator_set_suspend_voltage(ldo,1200000);
828 regulator_enable(ldo);
829 printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
832 ldo = regulator_get(NULL, "ldo9"); //cmmb
833 regulator_set_voltage(ldo,3000000,3000000);
834 regulator_set_suspend_voltage(ldo,3000000);
835 regulator_enable(ldo);
836 printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
842 ldo = regulator_get(NULL, "ldo11");
843 //regulator_enable(ldo);
844 printk("%s set ldo11=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
851 extern void wm831x_enter_sleep(void);
852 extern void wm831x_exit_sleep(void);
854 void pmu_wm831x_set_suspend_voltage(void)
858 EXPORT_SYMBOL_GPL(pmu_wm831x_set_suspend_voltage);
860 void pmu_wm831x_set_resume_voltage(void)
864 EXPORT_SYMBOL_GPL(pmu_wm831x_set_resume_voltage);
866 int wm831x_last_deinit(struct wm831x *parm)
868 struct regulator* ldo;
870 printk("%s\n", __FUNCTION__);
872 ldo = regulator_get(NULL, "ldo1");
873 regulator_disable(ldo);
876 ldo = regulator_get(NULL, "ldo2");
877 regulator_disable(ldo);
880 ldo = regulator_get(NULL, "ldo3");
881 regulator_disable(ldo);
884 ldo = regulator_get(NULL, "ldo4");
885 //regulator_disable(ldo);
888 ldo = regulator_get(NULL, "ldo5");
889 regulator_disable(ldo);
892 ldo = regulator_get(NULL, "ldo6");
893 regulator_disable(ldo);
896 ldo = regulator_get(NULL, "ldo7");
897 regulator_disable(ldo);
900 ldo = regulator_get(NULL, "ldo8");
901 //regulator_disable(ldo);
904 ldo = regulator_get(NULL, "ldo9");
905 regulator_disable(ldo);
908 ldo = regulator_get(NULL, "ldo10");
909 regulator_disable(ldo);
915 struct wm831x_backlight_pdata wm831x_backlight_platdata = {
916 .isink = 1, /** ISINK to use, 1 or 2 */
917 .max_uA = 19484, /** Maximum current to allow */
920 struct wm831x_backup_pdata wm831x_backup_platdata = {
922 .no_constant_voltage = 0, /** Disable constant voltage charging */
923 .vlim = 3100, /** Voltage limit in milivolts */
924 .ilim = 300, /** Current limit in microamps */
927 struct wm831x_battery_pdata wm831x_battery_platdata = {
928 .enable = 1, /** Enable charging */
929 .fast_enable = 1, /** Enable fast charging */
930 .off_mask = 1, /** Mask OFF while charging */
931 .trickle_ilim = 200, /** Trickle charge current limit, in mA */
932 .vsel = 4200, /** Target voltage, in mV */
933 .eoc_iterm = 50, /** End of trickle charge current, in mA */
934 .fast_ilim = 500, /** Fast charge current limit, in mA */
935 .timeout = 480, /** Charge cycle timeout, in minutes */
936 .syslo = 3300, /* syslo threshold, in mV*/
937 .sysok = 3500, /* sysko threshold, in mV*/
940 struct wm831x_status_pdata wm831x_status_platdata[WM831X_MAX_STATUS] = {
942 .default_src = WM831X_STATUS_OTP,
943 .name = "wm831x_status0",
944 .default_trigger = "wm831x_otp",
947 .default_src = WM831X_STATUS_POWER,
948 .name = "wm831x_status1",
949 .default_trigger = "wm831x_power",
954 static struct regulator_consumer_supply dcdc1_consumers[] = {
959 static struct regulator_consumer_supply dcdc2_consumers[] = {
967 static struct regulator_consumer_supply dcdc3_consumers[] = {
972 static struct regulator_consumer_supply dcdc4_consumers[] = {
977 static struct regulator_consumer_supply epe1_consumers[] = {
982 static struct regulator_consumer_supply epe2_consumers[] = {
987 static struct regulator_consumer_supply ldo1_consumers[] = {
992 static struct regulator_consumer_supply ldo2_consumers[] = {
997 static struct regulator_consumer_supply ldo3_consumers[] = {
1002 static struct regulator_consumer_supply ldo4_consumers[] = {
1007 static struct regulator_consumer_supply ldo5_consumers[] = {
1012 static struct regulator_consumer_supply ldo6_consumers[] = {
1017 static struct regulator_consumer_supply ldo7_consumers[] = {
1022 static struct regulator_consumer_supply ldo8_consumers[] = {
1027 static struct regulator_consumer_supply ldo9_consumers[] = {
1032 static struct regulator_consumer_supply ldo10_consumers[] = {
1037 static struct regulator_consumer_supply ldo11_consumers[] = {
1042 static struct regulator_consumer_supply isink1_consumers[] = {
1047 static struct regulator_consumer_supply isink2_consumers[] = {
1053 struct regulator_init_data wm831x_regulator_init_dcdc[WM831X_MAX_DCDC] = {
1058 .max_uV = 1800000,//0.6-1.8V
1060 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1062 .num_consumer_supplies = ARRAY_SIZE(dcdc1_consumers),
1063 .consumer_supplies = dcdc1_consumers,
1069 .max_uV = 1800000,//0.6-1.8V
1071 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1073 .num_consumer_supplies = ARRAY_SIZE(dcdc2_consumers),
1074 .consumer_supplies = dcdc2_consumers,
1080 .max_uV = 3400000,//0.85-3.4V
1082 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1084 .num_consumer_supplies = ARRAY_SIZE(dcdc3_consumers),
1085 .consumer_supplies = dcdc3_consumers,
1091 .max_uV = 30000000,//30V/40mA
1093 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1095 .num_consumer_supplies = ARRAY_SIZE(dcdc4_consumers),
1096 .consumer_supplies = dcdc4_consumers,
1100 struct regulator_init_data wm831x_regulator_init_epe[WM831X_MAX_EPE] = {
1107 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1109 .num_consumer_supplies = ARRAY_SIZE(epe1_consumers),
1110 .consumer_supplies = epe1_consumers,
1118 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1120 .num_consumer_supplies = ARRAY_SIZE(epe2_consumers),
1121 .consumer_supplies = epe2_consumers,
1125 struct regulator_init_data wm831x_regulator_init_ldo[WM831X_MAX_LDO] = {
1132 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1134 .num_consumer_supplies = ARRAY_SIZE(ldo1_consumers),
1135 .consumer_supplies = ldo1_consumers,
1143 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1145 .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
1146 .consumer_supplies = ldo2_consumers,
1154 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1156 .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
1157 .consumer_supplies = ldo3_consumers,
1165 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1167 .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
1168 .consumer_supplies = ldo4_consumers,
1176 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1178 .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
1179 .consumer_supplies = ldo5_consumers,
1187 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1189 .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers),
1190 .consumer_supplies = ldo6_consumers,
1198 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1200 .num_consumer_supplies = ARRAY_SIZE(ldo7_consumers),
1201 .consumer_supplies = ldo7_consumers,
1209 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1211 .num_consumer_supplies = ARRAY_SIZE(ldo8_consumers),
1212 .consumer_supplies = ldo8_consumers,
1220 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1222 .num_consumer_supplies = ARRAY_SIZE(ldo9_consumers),
1223 .consumer_supplies = ldo9_consumers,
1231 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1233 .num_consumer_supplies = ARRAY_SIZE(ldo10_consumers),
1234 .consumer_supplies = ldo10_consumers,
1242 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1244 .num_consumer_supplies = ARRAY_SIZE(ldo11_consumers),
1245 .consumer_supplies = ldo11_consumers,
1249 struct regulator_init_data wm831x_regulator_init_isink[WM831X_MAX_ISINK] = {
1257 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1259 .num_consumer_supplies = ARRAY_SIZE(isink1_consumers),
1260 .consumer_supplies = isink1_consumers,
1268 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1270 .num_consumer_supplies = ARRAY_SIZE(isink2_consumers),
1271 .consumer_supplies = isink2_consumers,
1275 static int wm831x_checkrange(int start,int num,int val)
1277 if((val<(start+num))&&(val>=start))
1283 static int wm831x_init_pin_type(struct wm831x *wm831x)
1286 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
1287 struct rk29_gpio_expander_info *wm831x_gpio_settinginfo;
1288 uint16_t offset = 0;
1289 uint16_t wm831x_settingpin_num = 0;
1295 wm831x_gpio_settinginfo=pdata->settinginfo;
1296 if(wm831x_gpio_settinginfo)
1298 wm831x_settingpin_num = pdata->settinginfolen;
1299 for(i=0;i<wm831x_settingpin_num;i++)
1301 if(!wm831x_checkrange(pdata->gpio_base,pdata->gpio_pin_num,wm831x_gpio_settinginfo[i].gpio_num))
1303 offset = wm831x_gpio_settinginfo[i].gpio_num - pdata->gpio_base;
1305 if(wm831x_gpio_settinginfo[i].pin_type==GPIO_IN)
1307 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_DIR_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
1311 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_TRI_SHIFT);
1312 if(wm831x_gpio_settinginfo[i].pin_value==GPIO_HIGH)
1314 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(1 << offset));
1318 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(0 << offset));
1327 for(i=0;i<pdata->gpio_pin_num;i++)
1329 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+i),
1330 WM831X_GPN_PULL_MASK|WM831X_GPN_POL_MASK|WM831X_GPN_OD_MASK|WM831X_GPN_TRI_MASK,
1331 1<<WM831X_GPN_POL_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
1332 ret = wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL+i);
1333 printk("Gpio%d Pin Configuration = %x\n",i,ret);
1342 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1343 static struct wm831x_gpio_keys_button wm831x_gpio_buttons[] = {
1346 .gpio = TCA6424_P21,
1350 .debounce_interval = 120,
1353 .code= KEY_VOLUMEUP,
1367 .code= KEY_VOLUMEDOWN,
1370 .desc= "volume_down",
1403 struct wm831x_gpio_keys_pdata wm831x_gpio_keys_platdata = {
1404 .buttons = wm831x_gpio_buttons,
1405 .nbuttons = ARRAY_SIZE(wm831x_gpio_buttons),
1409 struct wm831x_pdata wm831x_platdata = {
1410 /** Called before subdevices are set up */
1411 .pre_init= wm831x_pre_init,
1412 /** Called after subdevices are set up */
1413 .post_init = wm831x_post_init,
1414 /** Called before subdevices are power down */
1415 .last_deinit = wm831x_last_deinit,
1417 #if defined(CONFIG_GPIO_WM831X)
1418 .gpio_base=WM831X_GPIO_EXPANDER_BASE,
1419 .gpio_pin_num=WM831X_TOTOL_GPIO_NUM,
1420 .settinginfo=wm831x_gpio_settinginfo,
1421 .settinginfolen=ARRAY_SIZE(wm831x_gpio_settinginfo),
1422 .pin_type_init = wm831x_init_pin_type,
1423 .irq_base= NR_AIC_IRQS + 7*NUM_GROUP,
1426 .backlight = &wm831x_backlight_platdata,
1428 .backup = &wm831x_backup_platdata,
1430 .battery = &wm831x_battery_platdata,
1431 //.wm831x_touch_pdata = NULL,
1434 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1435 .gpio_keys = &wm831x_gpio_keys_platdata,
1438 /** LED1 = 0 and so on */
1439 .status = {&wm831x_status_platdata[0], &wm831x_status_platdata[1]},
1441 /** DCDC1 = 0 and so on */
1442 .dcdc = {&wm831x_regulator_init_dcdc[0], &wm831x_regulator_init_dcdc[1], &wm831x_regulator_init_dcdc[2], &wm831x_regulator_init_dcdc[3]},
1444 /** EPE1 = 0 and so on */
1445 .epe = {&wm831x_regulator_init_epe[0], &wm831x_regulator_init_epe[1]},
1447 /** LDO1 = 0 and so on */
1448 .ldo = {&wm831x_regulator_init_ldo[0], &wm831x_regulator_init_ldo[1], &wm831x_regulator_init_ldo[2], &wm831x_regulator_init_ldo[3],
1449 &wm831x_regulator_init_ldo[4], &wm831x_regulator_init_ldo[5], &wm831x_regulator_init_ldo[6], &wm831x_regulator_init_ldo[7],
1450 &wm831x_regulator_init_ldo[8], &wm831x_regulator_init_ldo[9], &wm831x_regulator_init_ldo[10]},
1452 /** ISINK1 = 0 and so on*/
1453 .isink = {&wm831x_regulator_init_isink[0], &wm831x_regulator_init_isink[1]},
1459 #if defined(CONFIG_RK29_GPS)
1461 #define RK29_GPS_POWER_PIN RK29_PIN6_PB2
1462 #define RK29_GPS_RESET_PIN RK29_PIN6_PC1
1464 int rk29_gps_power_up(void)
1466 printk("%s \n", __FUNCTION__);
1468 gpio_request(RK29_GPS_POWER_PIN, NULL);
1469 gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH);
1474 int rk29_gps_power_down(void)
1476 printk("%s \n", __FUNCTION__);
1478 gpio_request(RK29_GPS_POWER_PIN, NULL);
1479 gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW);
1484 int rk29_gps_reset_set(int level)
1486 gpio_request(RK29_GPS_RESET_PIN, NULL);
1488 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);
1490 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);
1495 struct rk29_gps_data rk29_gps_info = {
1496 .power_up = rk29_gps_power_up,
1497 .power_down = rk29_gps_power_down,
1498 .reset = rk29_gps_reset_set,
1502 struct platform_device rk29_device_gps = {
1506 .platform_data = &rk29_gps_info,
1511 /*****************************************************************************************
1513 * author: qjb@rock-chips.com
1514 *****************************************************************************************/
1515 struct wm8994_pdata wm8994_platdata = {
1519 .PA_control_pin = 0,
1520 .Power_EN_Pin = RK29_PIN5_PA1,
1522 .speaker_incall_vol = 0,
1523 .speaker_incall_mic_vol = -9,
1524 .speaker_normal_vol = 6,
1525 .earpiece_incall_vol = 0,
1526 .headset_incall_vol = 6,
1527 .headset_incall_mic_vol = -6,
1528 .headset_normal_vol = -6,
1530 .BT_incall_mic_vol = 0,
1536 #ifdef CONFIG_RK_HEADSET_DET
1537 #define HEADSET_GPIO RK29_PIN4_PD2
1538 struct rk_headset_pdata rk_headset_info = {
1539 .Headset_gpio = RK29_PIN4_PD2,
1540 .headset_in_type= HEADSET_IN_HIGH,
1541 .Hook_gpio = RK29_PIN4_PD1,//Detection Headset--Must be set
1542 .hook_key_code = KEY_MEDIA,
1545 struct platform_device rk_device_headset = {
1546 .name = "rk_headsetdet",
1549 .platform_data = &rk_headset_info,
1554 #if defined(CONFIG_GS_L3G4200D)
1556 #include <linux/l3g4200d.h>
1557 #define L3G4200D_INT_PIN RK29_PIN5_PA3
1559 static int l3g4200d_init_platform_hw(void)
1561 if (gpio_request(L3G4200D_INT_PIN, NULL) != 0) {
1562 gpio_free(L3G4200D_INT_PIN);
1563 printk("%s: request l3g4200d int pin error\n", __func__);
1566 gpio_pull_updown(L3G4200D_INT_PIN, 1);
1570 static struct l3g4200d_platform_data l3g4200d_info = {
1581 .init = l3g4200d_init_platform_hw,
1586 /*****************************************************************************************
1588 * author: kfx@rock-chips.com
1589 *****************************************************************************************/
1590 static int rk29_i2c0_io_init(void)
1592 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1593 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
1594 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
1596 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
1597 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
1602 static int rk29_i2c1_io_init(void)
1604 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1605 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
1606 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
1608 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
1609 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
1613 static int rk29_i2c2_io_init(void)
1615 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1616 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
1617 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
1619 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
1620 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
1625 static int rk29_i2c3_io_init(void)
1627 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1628 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
1629 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1631 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
1632 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
1636 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1637 struct rk29_i2c_platform_data default_i2c0_data = {
1641 .scl_rate = 400*1000,
1642 .mode = I2C_MODE_IRQ,
1643 .io_init = rk29_i2c0_io_init,
1646 struct i2c_gpio_platform_data default_i2c0_data = {
1647 .sda_pin = RK29_PIN2_PB6,
1648 .scl_pin = RK29_PIN2_PB7,
1649 .udelay = 5, // clk = 500/udelay = 100Khz
1650 .timeout = 100,//msecs_to_jiffies(200),
1652 .io_init = rk29_i2c0_io_init,
1655 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1656 struct rk29_i2c_platform_data default_i2c1_data = {
1660 .scl_rate = 400*1000,
1661 .mode = I2C_MODE_IRQ,
1662 .io_init = rk29_i2c1_io_init,
1665 struct i2c_gpio_platform_data default_i2c1_data = {
1666 .sda_pin = RK29_PIN1_PA6,
1667 .scl_pin = RK29_PIN1_PA7,
1668 .udelay = 5, // clk = 500/udelay = 100Khz
1669 .timeout = 100,//msecs_to_jiffies(200),
1671 .io_init = rk29_i2c1_io_init,
1674 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1675 struct rk29_i2c_platform_data default_i2c2_data = {
1679 .scl_rate = 400*1000,
1680 .mode = I2C_MODE_IRQ,
1681 .io_init = rk29_i2c2_io_init,
1684 struct i2c_gpio_platform_data default_i2c2_data = {
1685 .sda_pin = RK29_PIN5_PD3,
1686 .scl_pin = RK29_PIN5_PD4,
1687 .udelay = 5, // clk = 500/udelay = 100Khz
1688 .timeout = 100,//msecs_to_jiffies(200),
1690 .io_init = rk29_i2c2_io_init,
1693 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1694 struct rk29_i2c_platform_data default_i2c3_data = {
1698 .scl_rate = 400*1000,
1699 .mode = I2C_MODE_IRQ,
1700 .io_init = rk29_i2c3_io_init,
1703 struct i2c_gpio_platform_data default_i2c3_data = {
1704 .sda_pin = RK29_PIN5_PB5,
1705 .scl_pin = RK29_PIN5_PB4,
1706 .udelay = 5, // clk = 500/udelay = 100Khz
1707 .timeout = 100,//msecs_to_jiffies(200),
1709 .io_init = rk29_i2c3_io_init,
1713 #if defined (CONFIG_ANX7150)
1714 struct hdmi_platform_data anx7150_data = {
1715 //.io_init = anx7150_io_init,
1718 #ifdef CONFIG_I2C0_RK29
1719 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1720 #if defined (CONFIG_RK1000_CONTROL)
1722 .type = "rk1000_control",
1727 #if defined (CONFIG_SND_SOC_RK1000)
1729 .type = "rk1000_i2c_codec",
1734 #if defined (CONFIG_SND_SOC_WM8900)
1741 #if defined (CONFIG_SND_SOC_WM8994)
1746 // #if defined(CONFIG_MFD_WM8994)
1747 .platform_data = &wm8994_platdata,
1751 #if defined (CONFIG_BATTERY_STC3100)
1758 #if defined (CONFIG_BATTERY_BQ27510)
1765 #if defined (CONFIG_RTC_HYM8563)
1767 .type = "rtc_hym8563",
1770 .irq = RK29_PIN0_PA1,
1773 #if defined (CONFIG_GS_MMA8452)
1775 .type = "gs_mma8452",
1778 .irq = MMA8452_INT_PIN,
1779 .platform_data = &mma8452_info,
1782 #if defined (CONFIG_COMPASS_AK8973)
1787 .irq = RK29_PIN6_PC5,
1790 #if defined (CONFIG_COMPASS_AK8975)
1795 .irq = RK29_PIN6_PC5,
1798 #if defined (CONFIG_INPUT_LPSENSOR_ISL29028)
1803 .irq = RK29_PIN4_PD3,
1806 #if defined (CONFIG_ANX7150)
1809 .addr = 0x39, //0x39, 0x3d
1811 .irq = RK29_PIN2_PA3,
1812 .platform_data = &anx7150_data,
1815 #if defined (CONFIG_GS_L3G4200D)
1817 .type = "gs_l3g4200d",
1820 .irq = L3G4200D_INT_PIN,
1821 .platform_data = &l3g4200d_info,
1824 #if defined (CONFIG_MPU_SENSORS_MPU3050)
1829 .irq = RK29_PIN4_PC4,
1830 .platform_data = &mpu3050_data,
1836 #ifdef CONFIG_I2C1_RK29
1837 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1838 #if defined (CONFIG_RK1000_CONTROL1)
1840 .type = "rk1000_control",
1849 #ifdef CONFIG_I2C2_RK29
1850 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1851 #if defined (CONFIG_TOUCHSCREEN_GT801_IIC)
1856 .irq = RK29_PIN4_PD5,
1857 .platform_data = >801_info,
1861 #if defined (CONFIG_TOUCHSCREEN_GT818_IIC)
1866 .irq = RK29_PIN4_PD5,
1867 .platform_data = >818_info,
1871 #if defined (CONFIG_TOUCHSCREEN_ILI2102_IIC)
1873 .type = "ili2102_ts",
1875 .flags = I2C_M_NEED_DELAY,
1877 .irq = RK29_PIN4_PD5,
1878 .platform_data = &ili2102_info,
1882 #if defined (CONFIG_MFD_WM831X_I2C)
1887 .irq = RK29_PIN4_PD0,
1888 .platform_data = &wm831x_platdata,
1891 #if defined (CONFIG_HANNSTAR_P1003)
1893 .type = "p1003_touch",
1896 .irq = RK29_PIN0_PA2,
1897 .platform_data = &p1003_info,
1900 #if defined (CONFIG_EETI_EGALAX)
1902 .type = "egalax_i2c",
1905 .irq = RK29_PIN4_PD5,
1906 .platform_data = &eeti_egalax_info,
1912 #ifdef CONFIG_I2C3_RK29
1913 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1917 /*****************************************************************************************
1919 * author: ddl@rock-chips.com
1920 *****************************************************************************************/
1921 #ifdef CONFIG_VIDEO_RK29
1922 #define CONFIG_SENSOR_POWER_IOCTL_USR 0
1923 #define CONFIG_SENSOR_RESET_IOCTL_USR 0
1924 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0
1925 #define CONFIG_SENSOR_FLASH_IOCTL_USR 0
1927 #if CONFIG_SENSOR_POWER_IOCTL_USR
1928 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
1930 #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
1934 #if CONFIG_SENSOR_RESET_IOCTL_USR
1935 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
1937 #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
1941 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1942 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
1944 #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
1948 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1949 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
1951 #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
1955 static struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
1956 #if CONFIG_SENSOR_POWER_IOCTL_USR
1957 .sensor_power_cb = sensor_power_usr_cb,
1959 .sensor_power_cb = NULL,
1962 #if CONFIG_SENSOR_RESET_IOCTL_USR
1963 .sensor_reset_cb = sensor_reset_usr_cb,
1965 .sensor_reset_cb = NULL,
1968 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1969 .sensor_powerdown_cb = sensor_powerdown_usr_cb,
1971 .sensor_powerdown_cb = NULL,
1974 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1975 .sensor_flash_cb = sensor_flash_usr_cb,
1977 .sensor_flash_cb = NULL,
1980 #include "../../../drivers/media/video/rk29_camera.c"
1983 /*****************************************************************************************
1985 * author: nzy@rock-chips.com
1986 *****************************************************************************************/
1987 #ifdef CONFIG_BACKLIGHT_RK29_BL
1989 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
1990 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
1991 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
1992 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
1996 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
1997 #define PWM_MUX_MODE GPIO1L_PWM0
1998 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1999 #define PWM_EFFECT_VALUE 1
2001 //#define LCD_DISP_ON_PIN
2003 #ifdef LCD_DISP_ON_PIN
2004 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
2005 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
2007 #define BL_EN_PIN GPIO0L_GPIO0A5
2008 #define BL_EN_VALUE GPIO_HIGH
2010 static int rk29_backlight_io_init(void)
2014 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
2015 #ifdef LCD_DISP_ON_PIN
2016 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
2018 ret = gpio_request(BL_EN_PIN, NULL);
2021 gpio_free(BL_EN_PIN);
2024 gpio_direction_output(BL_EN_PIN, 0);
2025 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
2030 static int rk29_backlight_io_deinit(void)
2033 #ifdef LCD_DISP_ON_PIN
2034 gpio_free(BL_EN_PIN);
2036 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
2039 struct rk29_bl_info rk29_bl_info = {
2041 .bl_ref = PWM_EFFECT_VALUE,
2042 .io_init = rk29_backlight_io_init,
2043 .io_deinit = rk29_backlight_io_deinit,
2046 /*****************************************************************************************
2047 * pwm voltage regulator devices
2048 ******************************************************************************************/
2049 #if defined (CONFIG_RK29_PWM_REGULATOR)
2051 #define REGULATOR_PWM_ID 2
2052 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
2053 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
2054 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
2055 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
2057 static struct regulator_consumer_supply pwm_consumers[] = {
2063 static struct regulator_init_data rk29_pwm_regulator_data = {
2069 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
2071 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
2072 .consumer_supplies = pwm_consumers,
2075 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
2076 .pwm_id = REGULATOR_PWM_ID,
2077 .pwm_gpio = REGULATOR_PWM_GPIO,
2078 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
2079 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
2080 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
2081 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
2082 .init_data = &rk29_pwm_regulator_data,
2085 static struct platform_device rk29_device_pwm_regulator = {
2086 .name = "pwm-voltage-regulator",
2089 .platform_data = &rk29_regulator_pwm_platform_data,
2096 #if defined(CONFIG_MTK23D)
2097 static int mtk23d_io_init(void)
2103 static int mtk23d_io_deinit(void)
2109 struct rk2818_23d_data rk2818_23d_info = {
2110 .io_init = mtk23d_io_init,
2111 .io_deinit = mtk23d_io_deinit,
2112 .bp_power = RK29_PIN0_PA0,
2113 .bp_power_active_low = 0,
2114 .bp_reset = RK29_PIN0_PA1,
2115 .bp_reset_active_low = 1,
2116 .bp_statue = RK29_PIN0_PA2,//input high bp sleep;
2117 .ap_statue = RK29_PIN0_PA4,//output high ap sleep;
2118 .ap_bp_wakeup = RK29_PIN0_PA3, //output AP wake up BP used rising edge;
2119 .bp_ap_wakeup = 0,//input BP wake up AP
2121 struct platform_device rk2818_device_mtk23d = {
2125 .platform_data = &rk2818_23d_info,
2131 /*****************************************************************************************
2133 *****************************************************************************************/
2134 #ifdef CONFIG_SDMMC0_RK29
2135 static int rk29_sdmmc0_cfg_gpio(void)
2137 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
2138 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
2139 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
2140 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
2141 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
2142 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
2143 #ifdef CONFIG_SDMMC_RK29_OLD
2144 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
2146 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
2148 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
2149 gpio_request(RK29_PIN5_PD5,"sdmmc");
2150 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
2152 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
2156 #define CONFIG_SDMMC0_USE_DMA
2157 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
2158 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
2159 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
2160 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
2161 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2162 .io_init = rk29_sdmmc0_cfg_gpio,
2163 .dma_name = "sd_mmc",
2164 #ifdef CONFIG_SDMMC0_USE_DMA
2169 .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
2170 .enable_sd_wakeup = 0,
2173 #ifdef CONFIG_SDMMC1_RK29
2174 #define CONFIG_SDMMC1_USE_DMA
2175 static int rk29_sdmmc1_cfg_gpio(void)
2177 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2178 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2179 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2180 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2181 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2182 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2183 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
2187 #ifdef CONFIG_WIFI_CONTROL_FUNC
2188 static int rk29sdk_wifi_status(struct device *dev);
2189 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
2192 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
2194 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
2195 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
2196 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
2197 MMC_VDD_32_33|MMC_VDD_33_34),
2198 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
2199 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2200 .io_init = rk29_sdmmc1_cfg_gpio,
2202 #ifdef CONFIG_SDMMC1_USE_DMA
2207 #ifdef CONFIG_WIFI_CONTROL_FUNC
2208 .status = rk29sdk_wifi_status,
2209 .register_status_notify = rk29sdk_wifi_status_register,
2212 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
2217 #ifdef CONFIG_WIFI_CONTROL_FUNC
2218 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
2219 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
2220 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC7
2222 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
2223 static void (*wifi_status_cb)(int card_present, void *dev_id);
2224 static void *wifi_status_cb_devid;
2225 int rk29sdk_wifi_power_state = 0;
2226 int rk29sdk_bt_power_state = 0;
2228 static int rk29sdk_wifi_status(struct device *dev)
2230 return rk29sdk_wifi_cd;
2233 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
2237 wifi_status_cb = callback;
2238 wifi_status_cb_devid = dev_id;
2242 static int rk29sdk_wifi_bt_gpio_control_init(void)
2244 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
2245 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
2249 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
2250 pr_info("%s: request wifi reset gpio failed\n", __func__);
2251 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
2255 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
2256 pr_info("%s: request bt reset gpio failed\n", __func__);
2257 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
2261 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2262 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2263 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
2265 pr_info("%s: init finished\n",__func__);
2270 static int rk29sdk_wifi_power(int on)
2272 pr_info("%s: %d\n", __func__, on);
2274 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
2275 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
2277 pr_info("wifi turn on power\n");
2279 if (!rk29sdk_bt_power_state){
2280 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2282 pr_info("wifi shut off power\n");
2285 pr_info("wifi shouldn't shut off power, bt is using it!\n");
2287 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2291 rk29sdk_wifi_power_state = on;
2295 static int rk29sdk_wifi_reset_state;
2296 static int rk29sdk_wifi_reset(int on)
2298 pr_info("%s: %d\n", __func__, on);
2299 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
2301 rk29sdk_wifi_reset_state = on;
2305 int rk29sdk_wifi_set_carddetect(int val)
2307 pr_info("%s:%d\n", __func__, val);
2308 rk29sdk_wifi_cd = val;
2309 if (wifi_status_cb){
2310 wifi_status_cb(val, wifi_status_cb_devid);
2312 pr_warning("%s, nobody to notify\n", __func__);
2316 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
2318 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
2319 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
2320 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
2321 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
2322 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
2325 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
2327 if (section == PREALLOC_WLAN_SEC_NUM)
2328 return wlan_static_skb;
2330 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
2333 if (wifi_mem_array[section].size < size)
2336 return wifi_mem_array[section].mem_ptr;
2339 int __init rk29sdk_init_wifi_mem(void)
2344 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
2345 wlan_static_skb[i] = dev_alloc_skb(
2346 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
2348 if (!wlan_static_skb[i])
2352 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
2353 wifi_mem_array[i].mem_ptr =
2354 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
2356 if (!wifi_mem_array[i].mem_ptr)
2362 pr_err("Failed to mem_alloc for WLAN\n");
2363 for (j = 0 ; j < i ; j++)
2364 kfree(wifi_mem_array[j].mem_ptr);
2366 i = WLAN_SKB_BUF_NUM;
2369 pr_err("Failed to skb_alloc for WLAN\n");
2370 for (j = 0 ; j < i ; j++)
2371 dev_kfree_skb(wlan_static_skb[j]);
2376 static struct wifi_platform_data rk29sdk_wifi_control = {
2377 .set_power = rk29sdk_wifi_power,
2378 .set_reset = rk29sdk_wifi_reset,
2379 .set_carddetect = rk29sdk_wifi_set_carddetect,
2380 .mem_prealloc = rk29sdk_mem_prealloc,
2382 static struct platform_device rk29sdk_wifi_device = {
2383 .name = "bcm4329_wlan",
2386 .platform_data = &rk29sdk_wifi_control,
2392 /* bluetooth rfkill device */
2393 static struct platform_device rk29sdk_rfkill = {
2394 .name = "rk29sdk_rfkill",
2399 #ifdef CONFIG_VIVANTE
2400 static struct resource resources_gpu[] = {
2405 .flags = IORESOURCE_IRQ,
2409 .start = RK29_GPU_PHYS,
2410 .end = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
2411 .flags = IORESOURCE_MEM,
2415 .start = PMEM_GPU_BASE,
2416 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
2417 .flags = IORESOURCE_MEM,
2420 static struct platform_device rk29_device_gpu = {
2423 .num_resources = ARRAY_SIZE(resources_gpu),
2424 .resource = resources_gpu,
2427 #ifdef CONFIG_KEYS_RK29
2428 extern struct rk29_keys_platform_data rk29_keys_pdata;
2429 static struct platform_device rk29_device_keys = {
2430 .name = "rk29-keypad",
2433 .platform_data = &rk29_keys_pdata,
2438 #ifdef CONFIG_USE_GPIO_GENERATE_WAVE
2439 static struct gpio_wave_platform_data gpio_wave_pdata = {
2440 .gpio = RK29_PIN0_PA0,
2443 .Dvalue = GPIO_HIGH,
2445 static struct platform_device gpio_wave_device = {
2446 .name = "gpio_wave",
2449 .platform_data = &gpio_wave_pdata,
2454 static void __init rk29_board_iomux_init(void)
2458 #ifdef CONFIG_UART1_RK29
2459 //disable uart1 pull down
2460 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_GPIO2A5);
2461 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_GPIO2A4);
2463 gpio_request(RK29_PIN2_PA5, NULL);
2464 gpio_request(RK29_PIN2_PA4, NULL);
2466 gpio_pull_updown(RK29_PIN2_PA5, PullDisable);
2467 gpio_pull_updown(RK29_PIN2_PA4, PullDisable);
2469 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
2470 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
2472 gpio_free(RK29_PIN2_PA5);
2473 gpio_free(RK29_PIN2_PA4);
2475 #ifdef CONFIG_RK29_PWM_REGULATOR
2476 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
2478 rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME,GPIO4H_GPIO4C0);
2480 /****************************clock change********************************************/
2481 err = gpio_request(RK29_PIN4_PC0, "clk27M_control");
2483 gpio_free(RK29_PIN4_PC0);
2484 printk("-------request RK29_PIN4_PC0 fail--------\n");
2488 gpio_direction_output(RK29_PIN4_PC0, GPIO_LOW);// 27M 32K
2489 gpio_set_value(RK29_PIN4_PC0, GPIO_LOW);
2491 rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME,GPIO4H_GPIO4C5);
2493 err = gpio_request(RK29_PIN4_PC5, "clk24M_control");
2495 gpio_free(RK29_PIN4_PC5);
2496 printk("-------request RK29_PIN4_PC5 fail--------\n");
2500 gpio_direction_output(RK29_PIN4_PC5, GPIO_LOW);// control 24M
2501 gpio_set_value(RK29_PIN4_PC5, GPIO_LOW);
2502 /*******************************************************************/
2507 // For phone,just a disk only, add by phc,20110816
2508 #ifdef CONFIG_USB_ANDROID
2509 struct usb_mass_storage_platform_data phone_mass_storage_pdata = {
2511 .vendor = "RockChip",
2512 .product = "rk29 sdk",
2517 struct platform_device phone_usb_mass_storage_device = {
2518 .name = "usb_mass_storage",
2521 .platform_data = &phone_mass_storage_pdata,
2527 static struct platform_device *devices[] __initdata = {
2529 #ifdef CONFIG_RK29_WATCHDOG
2533 #ifdef CONFIG_UART1_RK29
2536 #ifdef CONFIG_UART0_RK29
2539 #ifdef CONFIG_UART2_RK29
2542 #ifdef CONFIG_UART3_RK29
2546 #ifdef CONFIG_RK29_PWM_REGULATOR
2547 &rk29_device_pwm_regulator,
2549 #ifdef CONFIG_SPIM0_RK29
2550 &rk29xx_device_spi0m,
2552 #ifdef CONFIG_SPIM1_RK29
2553 &rk29xx_device_spi1m,
2555 #ifdef CONFIG_ADC_RK29
2558 #ifdef CONFIG_I2C0_RK29
2561 #ifdef CONFIG_I2C1_RK29
2564 #ifdef CONFIG_I2C2_RK29
2567 #ifdef CONFIG_I2C3_RK29
2571 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
2572 &rk29_device_iis_2ch,
2574 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
2575 &rk29_device_iis_8ch,
2578 #ifdef CONFIG_KEYS_RK29
2581 #ifdef CONFIG_USE_GPIO_GENERATE_WAVE
2584 #ifdef CONFIG_SDMMC0_RK29
2585 &rk29_device_sdmmc0,
2587 #ifdef CONFIG_SDMMC1_RK29
2588 &rk29_device_sdmmc1,
2591 #ifdef CONFIG_MTD_NAND_RK29XX
2592 &rk29xx_device_nand,
2595 #ifdef CONFIG_WIFI_CONTROL_FUNC
2596 &rk29sdk_wifi_device,
2603 #if defined(CONFIG_MTK23D)
2604 &rk2818_device_mtk23d,
2607 #ifdef CONFIG_MTD_NAND_RK29
2611 #ifdef CONFIG_FB_RK29
2613 &rk29_device_dma_cpy,
2615 #ifdef CONFIG_BACKLIGHT_RK29_BL
2616 &rk29_device_backlight,
2618 #ifdef CONFIG_RK29_VMAC
2621 #ifdef CONFIG_VIVANTE
2624 #ifdef CONFIG_VIDEO_RK29
2625 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
2626 #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
2627 &rk29_soc_camera_pdrv_0,
2629 &rk29_soc_camera_pdrv_1,
2630 &android_pmem_cam_device,
2632 &android_pmem_device,
2633 &rk29_vpu_mem_device,
2634 #ifdef CONFIG_USB20_OTG
2635 &rk29_device_usb20_otg,
2637 #ifdef CONFIG_USB20_HOST
2638 &rk29_device_usb20_host,
2640 #ifdef CONFIG_USB11_HOST
2641 &rk29_device_usb11_host,
2643 #ifdef CONFIG_USB_ANDROID
2644 &android_usb_device,
2645 &phone_usb_mass_storage_device,
2647 #ifdef CONFIG_RK29_IPP
2650 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2651 &rk29_v4l2_output_devce,
2653 #ifdef CONFIG_RK_HEADSET_DET
2656 #ifdef CONFIG_RK29_GPS
2661 #ifdef CONFIG_RK29_VMAC
2662 /*****************************************************************************************
2664 * author: lyx@rock-chips.com
2665 *****************************************************************************************/
2666 static int rk29_vmac_register_set(void)
2668 //config rk29 vmac as rmii, 100MHz
2669 u32 value= readl(RK29_GRF_BASE + 0xbc);
2670 value = (value & 0xfff7ff) | (0x400);
2671 writel(value, RK29_GRF_BASE + 0xbc);
2675 static int rk29_rmii_io_init(void)
2680 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2682 gpio_free(RK29_PIN6_PB0);
2683 printk("-------request RK29_PIN6_PB0 fail--------\n");
2687 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2688 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2693 static int rk29_rmii_io_deinit(void)
2696 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2697 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2699 gpio_free(RK29_PIN6_PB0);
2703 static int rk29_rmii_power_control(int enable)
2707 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2708 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2711 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2712 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2717 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2718 .vmac_register_set = rk29_vmac_register_set,
2719 .rmii_io_init = rk29_rmii_io_init,
2720 .rmii_io_deinit = rk29_rmii_io_deinit,
2721 .rmii_power_control = rk29_rmii_power_control,
2725 /*****************************************************************************************
2727 * author: cmc@rock-chips.com
2728 *****************************************************************************************/
2729 #define SPI_CHIPSELECT_NUM 2
2730 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2733 .cs_gpio = RK29_PIN2_PC1,
2734 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2735 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2739 .cs_gpio = RK29_PIN1_PA4,
2740 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2741 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2745 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2748 .cs_gpio = RK29_PIN2_PC5,
2749 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2750 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2754 .cs_gpio = RK29_PIN1_PA3,
2755 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2756 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2760 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2765 for (i=0; i<cs_num; i++) {
2766 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2773 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2778 static int spi_io_fix_leakage_bug(void)
2781 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2786 static int spi_io_resume_leakage_bug(void)
2789 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2794 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2795 .num_chipselect = SPI_CHIPSELECT_NUM,
2796 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2797 .io_init = spi_io_init,
2798 .io_deinit = spi_io_deinit,
2799 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2800 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2803 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2804 .num_chipselect = SPI_CHIPSELECT_NUM,
2805 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2806 .io_init = spi_io_init,
2807 .io_deinit = spi_io_deinit,
2808 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2809 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2812 /*****************************************************************************************
2813 * xpt2046 touch panel
2814 * author: hhb@rock-chips.com
2815 *****************************************************************************************/
2816 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
2817 #define XPT2046_GPIO_INT RK29_PIN4_PD5 //ä¸æ–???#define DEBOUNCE_REPTIME 3
2819 static struct xpt2046_platform_data xpt2046_info = {
2824 .debounce_rep = DEBOUNCE_REPTIME,
2826 .gpio_pendown = XPT2046_GPIO_INT,
2827 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
2828 .pendown_iomux_mode = GPIO4H_GPIO4D5,
2829 .touch_virtualkey_length = 60,
2830 .penirq_recheck_delay_usecs = 1,
2831 #if defined(CONFIG_TOUCHSCREEN_480X800)
2836 .touch_ad_top = 3940,
2837 .touch_ad_bottom = 310,
2838 .touch_ad_left = 3772,
2839 .touch_ad_right = 340,
2840 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2845 .touch_ad_top = 2447,
2846 .touch_ad_bottom = 207,
2847 .touch_ad_left = 5938,
2848 .touch_ad_right = 153,
2849 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2854 .touch_ad_top = 3166,
2855 .touch_ad_bottom = 256,
2856 .touch_ad_left = 3658,
2857 .touch_ad_right = 380,
2860 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2861 static struct xpt2046_platform_data xpt2046_info = {
2866 .debounce_rep = DEBOUNCE_REPTIME,
2868 .gpio_pendown = XPT2046_GPIO_INT,
2869 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
2870 .pendown_iomux_mode = GPIO4H_GPIO4D5,
2871 .touch_virtualkey_length = 60,
2872 .penirq_recheck_delay_usecs = 1,
2874 #if defined(CONFIG_TOUCHSCREEN_480X800)
2879 .screen_x = { 70, 410, 70, 410, 240},
2880 .screen_y = { 50, 50, 740, 740, 400},
2881 .uncali_x_default = { 3267, 831, 3139, 715, 1845 },
2882 .uncali_y_default = { 3638, 3664, 564, 591, 2087 },
2883 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2888 .screen_x[5] = { 50, 750, 50, 750, 400};
2889 .screen_y[5] = { 40, 40, 440, 440, 240};
2890 .uncali_x_default[5] = { 438, 565, 3507, 3631, 2105 };
2891 .uncali_y_default[5] = { 3756, 489, 3792, 534, 2159 };
2892 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2897 .screen_x[5] = { 50, 270, 50, 270, 160};
2898 .screen_y[5] = { 40, 40, 440, 440, 240};
2899 .uncali_x_default[5] = { 812, 3341, 851, 3371, 2183 };
2900 .uncali_y_default[5] = { 442, 435, 3193, 3195, 2004 };
2905 #if defined(CONFIG_SERIAL_SC8800)
2906 static struct plat_sc8800 sc8800_plat_data = {
2907 .slav_rts_pin = RK29_PIN4_PD4,
2908 .slav_rdy_pin = RK29_PIN4_PD1,
2909 .master_rts_pin = RK29_PIN4_PD2,
2910 .master_rdy_pin = RK29_PIN4_PD3,
2915 static struct spi_board_info board_spi_devices[] = {
2916 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2918 .modalias = "xpt2046_ts",
2919 .chip_select = 0,// 2,
2920 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2922 .irq = XPT2046_GPIO_INT,
2923 .platform_data = &xpt2046_info,
2927 #if defined(CONFIG_MFD_WM831X_SPI)
2929 .modalias = "wm8310",
2931 .max_speed_hz = 1*1000*1000,
2933 .irq = RK29_PIN4_PD0,
2934 .platform_data = &wm831x_platdata,
2937 #if defined(CONFIG_SERIAL_SC8800)
2939 .modalias = "sc8800",
2941 .platform_data = &sc8800_plat_data,
2942 .max_speed_hz = 12*1000*1000,
2949 /**********************************************************************************************
2951 * The virtual keys for android "back", "home", "menu", "search", these four keys are touch key
2952 * on the touch screen panel. (added by hhb@rock-chips.com 2011.03.31)
2954 ***********************************************************************************************/
2955 static ssize_t rk29xx_virtual_keys_show(struct kobject *kobj,
2956 struct kobj_attribute *attr, char *buf)
2958 #if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
2959 || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC)
2960 /* center: x: home: 50, menu: 184, back: 315, search 435, y: 830*/
2961 /* centerx;centery;width;height; */
2963 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":315:815:120:50" //":50:830:98:50" //":210:796:98:50"
2964 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":85:815:88:50" // ":184:830:120:50" // ":435:796:120:50"
2965 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":184:815:100:50" //":315:830:100:50" //":320:796:100:50"
2966 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":435:815:88:50" //":50:815:98:50" // //":85:796:88:50"
2972 static struct kobj_attribute rk29xx_virtual_keys_attr = {
2974 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2975 .name = "virtualkeys.xpt2046-touchscreen",
2976 #elif defined(CONFIG_TOUCHSCREEN_HX8520_IIC)
2977 .name = "virtualkeys.hx8520-touchscreen",
2978 #elif defined(CONFIG_TOUCHSCREEN_GT801_IIC)
2979 .name = "virtualkeys.gt801-touchscreen",
2980 #elif defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
2981 .name = "virtualkeys.ili2102-touchscreen",
2983 .name = "virtualkeys",
2987 .show = &rk29xx_virtual_keys_show,
2990 static struct attribute *rk29xx_properties_attrs[] = {
2991 &rk29xx_virtual_keys_attr.attr,
2995 static struct attribute_group rk29xx_properties_attr_group = {
2996 .attrs = rk29xx_properties_attrs,
2998 static int rk29xx_virtual_keys_init(void)
3001 struct kobject *properties_kobj;
3002 printk("rk29xx_virtual_keys_init \n");
3003 properties_kobj = kobject_create_and_add("board_properties", NULL);
3004 if (properties_kobj)
3005 ret = sysfs_create_group(properties_kobj,
3006 &rk29xx_properties_attr_group);
3007 if (!properties_kobj || ret)
3009 pr_err("failed to create board_properties\n");
3015 static void __init rk29_gic_init_irq(void)
3017 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
3018 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
3021 static void __init machine_rk29_init_irq(void)
3023 rk29_gic_init_irq();
3027 #define POWER_ON_PIN RK29_PIN4_PA4
3029 static void rk29_pm_power_restart(void)
3031 printk("%s,line=%d\n",__FUNCTION__,__LINE__);
3033 #if defined(CONFIG_MFD_WM831X)
3034 wm831x_device_restart(gWm831x);
3039 static void rk29_pm_power_off(void)
3041 printk(KERN_ERR "rk29_pm_power_off start...\n");
3042 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
3043 #if defined(CONFIG_MFD_WM831X)
3044 if(wm831x_read_usb(gWm831x))
3045 rk29_pm_power_restart(); //if charging then restart
3047 wm831x_device_shutdown(gWm831x);//else shutdown
3052 static struct cpufreq_frequency_table freq_table[] =
3054 { .index = 1200000, .frequency = 408000 },
3055 { .index = 1200000, .frequency = 600000 },
3056 { .index = 1200000, .frequency = 816000 },
3057 { .index = 1350000, .frequency = 1008000 },
3058 { .frequency = CPUFREQ_TABLE_END },
3061 static void __init machine_rk29_board_init(void)
3063 rk29_board_iomux_init();
3065 gpio_request(POWER_ON_PIN,"poweronpin");
3066 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
3067 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
3068 pm_power_off = rk29_pm_power_off;
3069 //arm_pm_restart = rk29_pm_power_restart;
3071 board_update_cpufreq_table(freq_table);
3073 platform_add_devices(devices, ARRAY_SIZE(devices));
3074 #ifdef CONFIG_I2C0_RK29
3075 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
3076 ARRAY_SIZE(board_i2c0_devices));
3078 #ifdef CONFIG_I2C1_RK29
3079 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
3080 ARRAY_SIZE(board_i2c1_devices));
3082 #ifdef CONFIG_I2C2_RK29
3083 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
3084 ARRAY_SIZE(board_i2c2_devices));
3086 #ifdef CONFIG_I2C3_RK29
3087 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
3088 ARRAY_SIZE(board_i2c3_devices));
3091 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
3093 #ifdef CONFIG_WIFI_CONTROL_FUNC
3094 rk29sdk_wifi_bt_gpio_control_init();
3095 rk29sdk_init_wifi_mem();
3098 #if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
3099 || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC)
3100 rk29xx_virtual_keys_init();
3105 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
3106 char **cmdline, struct meminfo *mi)
3109 mi->bank[0].start = RK29_SDRAM_PHYS;
3110 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
3111 mi->bank[0].size = LINUX_SIZE;
3112 #if SDRAM_SIZE > SZ_512M
3114 mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
3115 mi->bank[1].size = SDRAM_SIZE - SZ_512M;
3119 static void __init machine_rk29_mapio(void)
3121 rk29_map_common_io();
3122 rk29_setup_early_printk();
3124 rk29_clock_init2(periph_pll_96mhz, codec_pll_300mhz, false);
3126 ddr_init(DDR_TYPE, DDR_FREQ);
3129 MACHINE_START(RK29, "RK29board")
3130 /* UART for LL DEBUG */
3131 .phys_io = RK29_UART1_PHYS & 0xfff00000,
3132 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
3133 .boot_params = RK29_SDRAM_PHYS + 0x88000,
3134 .fixup = machine_rk29_fixup,
3135 .map_io = machine_rk29_mapio,
3136 .init_irq = machine_rk29_init_irq,
3137 .init_machine = machine_rk29_board_init,
3138 .timer = &rk29_timer,