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>
27 #include <linux/mpu.h>
28 #include <linux/mpu3050.h>
30 #include <mach/hardware.h>
31 #include <asm/setup.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/flash.h>
36 #include <asm/hardware/gic.h>
38 #include <mach/iomux.h>
39 #include <mach/gpio.h>
40 #include <mach/irqs.h>
41 #include <mach/rk29_iomap.h>
42 #include <mach/board.h>
43 #include <mach/rk29_nand.h>
44 #include <mach/rk29_camera.h> /* ddl@rock-chips.com : camera support */
45 #include <media/soc_camera.h> /* ddl@rock-chips.com : camera support */
46 #include <mach/vpu_mem.h>
47 #include <mach/sram.h>
49 #include <mach/cpufreq.h>
51 #include <linux/regulator/rk29-pwm-regulator.h>
52 #include <linux/regulator/machine.h>
53 #include <linux/mfd/wm831x/pdata.h>
54 #include <linux/mfd/wm831x/core.h>
55 #include <linux/mfd/wm831x/gpio.h>
56 #include <linux/mfd/wm8994/pdata.h>
57 #include <linux/mfd/wm8994/registers.h>
59 #include <linux/mtd/nand.h>
60 #include <linux/mtd/partitions.h>
61 #include <linux/i2c-gpio.h>
65 #if defined(CONFIG_MTK23D)
66 #include <linux/mtk23d.h>
69 #include "../../../drivers/staging/android/timed_gpio.h"
70 #include "../../../drivers/headset_observe/rk_headset.h"
71 /*set touchscreen different type header*/
72 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI)
73 #include "../../../drivers/input/touchscreen/xpt2046_ts.h"
74 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
75 #include "../../../drivers/input/touchscreen/xpt2046_tslib_ts.h"
76 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
77 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
80 #include "../../../drivers/misc/gps/rk29_gps.h"
81 #ifdef CONFIG_VIDEO_RK29
82 /*---------------- Camera Sensor Macro Define Begin ------------------------*/
83 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
84 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5640 /* back camera sensor */
85 #define CONFIG_SENSOR_IIC_ADDR_0 0x78
86 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0 1
87 #define CONFIG_SENSOR_ORIENTATION_0 0
88 #define CONFIG_SENSOR_POWER_PIN_0 RK29_PIN5_PA0
89 #define CONFIG_SENSOR_RESET_PIN_0 INVALID_GPIO
90 #define CONFIG_SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
91 #define CONFIG_SENSOR_FALSH_PIN_0 RK29_PIN6_PB5
92 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_H
93 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
94 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
95 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_H
97 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV7690 /* front camera sensor */
98 #define CONFIG_SENSOR_IIC_ADDR_1 0x42
99 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1 1
100 #define CONFIG_SENSOR_ORIENTATION_1 0
101 #define CONFIG_SENSOR_POWER_PIN_1 RK29_PIN5_PA0
102 #define CONFIG_SENSOR_RESET_PIN_1 INVALID_GPIO
103 #define CONFIG_SENSOR_POWERDN_PIN_1 RK29_PIN6_PB6
104 #define CONFIG_SENSOR_FALSH_PIN_1 INVALID_GPIO
105 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_H
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_16M
122 #define PMEM_UI_SIZE SZ_32M /* 1280x800: 64M 1024x768: 48M ... */
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 PMEM_CAMIPP_NECESSARY
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_2M//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
159 #define UNLOCK_SECURITY_KEY ~(0x1<<5)
160 #define LOCK_SECURITY_KEY 0x00
162 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
164 struct wifi_mem_prealloc {
169 extern struct sys_timer rk29_timer;
171 static int rk29_nand_io_init(void)
176 struct rk29_nand_platform_data rk29_nand_data = {
177 .width = 1, /* data bus width in bytes */
178 .hw_ecc = 1, /* hw ecc 0: soft ecc */
180 .io_init = rk29_nand_io_init,
183 #ifdef CONFIG_FB_RK29
184 /*****************************************************************************************
186 * author: zyw@rock-chips.com
187 *****************************************************************************************/
188 //#ifdef CONFIG_LCD_TD043MGEA1
189 #define LCD_RXD_PIN RK29_PIN4_PC3
190 #define LCD_TXD_PIN RK29_PIN4_PC7
191 #define LCD_CLK_PIN RK29_PIN4_PC6
192 #define LCD_CS_PIN RK29_PIN4_PC2
193 /*****************************************************************************************
194 * frame buffer devices
195 * author: zyw@rock-chips.com
196 *****************************************************************************************/
198 #define FB_DISPLAY_ON_PIN INVALID_GPIO//RK29_PIN6_PD0
199 #define FB_LCD_STANDBY_PIN INVALID_GPIO//RK29_PIN6_PD1
200 #define FB_LCD_CABC_EN_PIN INVALID_GPIO//RK29_PIN6_PD2
201 #define FB_MCU_FMK_PIN INVALID_GPIO
203 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
204 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
207 static int rk29_lcd_io_init(void)
211 ret = gpio_request(LCD_TXD_PIN, NULL);
212 ret = gpio_request(LCD_CLK_PIN, NULL);
213 ret = gpio_request(LCD_CS_PIN, NULL);
214 ret = gpio_request(RK29_PIN6_PC6, NULL);
216 ret = gpio_request(RK29_PIN4_PC1, NULL);//RS
217 gpio_direction_output(RK29_PIN4_PC1, 0);
218 gpio_set_value(RK29_PIN4_PC1, GPIO_HIGH);
220 rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME,GPIO4H_GPIO4C7);
221 rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME,GPIO4H_GPIO4C6);
222 rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME,GPIO4H_GPIO4C2);
223 rk29_mux_api_set(GPIO4C1_RMIITXEN_MIITXEN_NAME,GPIO4H_GPIO4C1);
228 static int rk29_lcd_io_deinit(void)
231 gpio_free(LCD_CS_PIN);
232 gpio_free(LCD_CLK_PIN);
233 gpio_free(LCD_TXD_PIN);
234 gpio_free(RK29_PIN6_PC6);
235 gpio_free(RK29_PIN4_PC1);
236 rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME,GPIO4H_RMII_RXD0);
237 rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME,GPIO4H_RMII_RXD1);
238 rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME,GPIO4H_RMII_TXD1);
242 static struct rk29lcd_info rk29_lcd_info = {
243 .txd_pin = LCD_TXD_PIN,
244 .clk_pin = LCD_CLK_PIN,
245 .cs_pin = LCD_CS_PIN,
246 .io_init = rk29_lcd_io_init,
247 .io_deinit = rk29_lcd_io_deinit,
250 int rk29_fb_io_enable(void)
252 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
254 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
255 gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);
257 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
259 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
260 gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);
265 int rk29_fb_io_disable(void)
267 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
269 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
270 gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);
272 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
274 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
275 gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);
280 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
283 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
285 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
288 gpio_free(FB_MCU_FMK_PIN);
289 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
291 gpio_direction_input(FB_MCU_FMK_PIN);
293 if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
295 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
298 gpio_free(FB_DISPLAY_ON_PIN);
299 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
303 if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
305 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
308 gpio_free(FB_LCD_STANDBY_PIN);
309 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
313 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
315 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
318 gpio_free(FB_LCD_CABC_EN_PIN);
319 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
321 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
322 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
324 rk29_fb_io_enable(); //enable it
329 static struct rk29fb_info rk29_fb_info = {
331 .mcu_fmk_pin = FB_MCU_FMK_PIN,
332 .lcd_info = &rk29_lcd_info,
333 .io_init = rk29_fb_io_init,
334 .io_enable = rk29_fb_io_enable,
335 .io_disable = rk29_fb_io_disable,
338 /* rk29 fb resource */
339 static struct resource rk29_fb_resource[] = {
342 .start = RK29_LCDC_PHYS,
343 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
344 .flags = IORESOURCE_MEM,
350 .flags = IORESOURCE_IRQ,
354 .start = MEM_FB_BASE,
355 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
356 .flags = IORESOURCE_MEM,
358 #ifdef CONFIG_FB_WORK_IPP
360 .name = "win1 ipp buf",
361 .start = MEM_FBIPP_BASE,
362 .end = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
363 .flags = IORESOURCE_MEM,
369 struct platform_device rk29_device_fb = {
372 .num_resources = ARRAY_SIZE(rk29_fb_resource),
373 .resource = rk29_fb_resource,
375 .platform_data = &rk29_fb_info,
379 struct platform_device rk29_device_dma_cpy = {
380 .name = "dma_memcpy",
387 static struct android_pmem_platform_data android_pmem_pdata = {
389 .start = PMEM_UI_BASE,
390 .size = PMEM_UI_SIZE,
395 static struct platform_device android_pmem_device = {
396 .name = "android_pmem",
399 .platform_data = &android_pmem_pdata,
405 static struct vpu_mem_platform_data vpu_mem_pdata = {
407 .start = PMEM_VPU_BASE,
408 .size = PMEM_VPU_SIZE,
412 static struct platform_device rk29_vpu_mem_device = {
416 .platform_data = &vpu_mem_pdata,
420 static struct platform_device rk29_v4l2_output_devce = {
424 /*HANNSTAR_P1003 touch*/
425 #if defined (CONFIG_HANNSTAR_P1003)
426 #define TOUCH_RESET_PIN RK29_PIN6_PC3
427 #define TOUCH_INT_PIN RK29_PIN4_PD5
429 int p1003_init_platform_hw(void)
431 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
432 gpio_free(TOUCH_RESET_PIN);
433 printk("p1003_init_platform_hw gpio_request error\n");
437 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
438 gpio_free(TOUCH_INT_PIN);
439 printk("p1003_init_platform_hw gpio_request error\n");
442 gpio_pull_updown(TOUCH_INT_PIN, 1);
443 gpio_direction_output(TOUCH_RESET_PIN, 0);
445 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
447 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
453 struct p1003_platform_data p1003_info = {
455 .init_platform_hw= p1003_init_platform_hw,
460 #if defined (CONFIG_TOUCHSCREEN_GT801_IIC)
461 #include "../../../drivers/input/touchscreen/gt801_ts.h"
463 #define TOUCH_RESET_PIN RK29_PIN6_PC3
464 #define TOUCH_INT_PIN RK29_PIN4_PD5
466 int gt801_init_platform_hw(void)
468 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
469 gpio_free(TOUCH_RESET_PIN);
470 printk("gt801_init_platform_hw gpio_request error\n");
474 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
475 gpio_free(TOUCH_INT_PIN);
476 printk("gt801_init_platform_hw gpio_request error\n");
479 gpio_pull_updown(TOUCH_INT_PIN, 1);
480 gpio_direction_output(TOUCH_RESET_PIN, 0);
482 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
484 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
491 static struct gt801_platform_data gt801_info = {
493 .gpio_reset = TOUCH_RESET_PIN,
494 .init_platform_hw = gt801_init_platform_hw,
498 #if defined(CONFIG_TOUCHSCREEN_GT801_Z5)
499 #include "../../../drivers/input/touchscreen/gt801_z5_ts.h"
500 #define TOUCH_RESET_PIN RK29_PIN6_PC3
501 #define TOUCH_INT_PIN RK29_PIN4_PD5
503 int gt801_init_platform_hw(void)
505 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
506 gpio_free(TOUCH_RESET_PIN);
507 printk("gt801_init_platform_hw gpio_request error\n");
511 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
512 gpio_free(TOUCH_INT_PIN);
513 printk("gt801_init_platform_hw gpio_request error\n");
516 gpio_pull_updown(TOUCH_INT_PIN, 1);
517 gpio_direction_output(TOUCH_RESET_PIN, 0);
519 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
521 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
527 static struct gt801_platform_data gt801_info = {
529 .gpio_reset = TOUCH_RESET_PIN,
530 .init_platform_hw= gt801_init_platform_hw,
534 #if defined(CONFIG_TOUCHSCREEN_GT818_IIC)
535 #include "../../../drivers/input/touchscreen/gt818_ts.h"
536 #define GT818_GPIO_INT RK29_PIN4_PD5
537 #define GT818_GPIO_RESET RK29_PIN6_PC3
538 static struct gt818_platform_data gt818_info = {
545 .gpio_reset = GT818_GPIO_RESET,
546 .gpio_reset_active_low = 0,
547 .gpio_pendown = GT818_GPIO_INT,
548 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
549 .resetpin_iomux_name = NULL,
550 .pendown_iomux_mode = GPIO4H_GPIO4D5,
551 .resetpin_iomux_mode = 0,
555 #if defined(CONFIG_TOUCHSCREEN_FT5X0X_Z5) || defined (CONFIG_TOUCHSCREEN_FT5306)
557 #define TOUCH_RESET_PIN RK29_PIN6_PC3
558 #define TOUCH_INT_PIN RK29_PIN4_PD5
559 int ft5406_init_platform_hw(void)
561 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
562 gpio_free(TOUCH_RESET_PIN);
563 printk("ft5406_init_platform_hw gpio_request error\n");
567 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
568 gpio_free(TOUCH_INT_PIN);
569 printk("ift5406_init_platform_hw gpio_request error\n");
572 gpio_pull_updown(TOUCH_INT_PIN, 0);
573 gpio_direction_output(TOUCH_RESET_PIN, GPIO_HIGH);
575 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
577 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
581 void ft5406_exit_platform_hw(void)
583 printk("ft5406_exit_platform_hw\n");
584 gpio_free(TOUCH_RESET_PIN);
585 gpio_free(TOUCH_INT_PIN);
588 int ft5406_platform_sleep(void)
590 //printk("ft5406_platform_sleep\n");
591 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
595 int ft5406_platform_wakeup(void)
597 //printk("ft5406_platform_wakeup\n");
598 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
602 struct ft5406_platform_data ft5406_info = {
604 .init_platform_hw= ft5406_init_platform_hw,
605 .exit_platform_hw= ft5406_exit_platform_hw,
606 .platform_sleep = ft5406_platform_sleep,
607 .platform_wakeup = ft5406_platform_wakeup,
612 #if defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
613 #include "../../../drivers/input/touchscreen/ili2102_ts.h"
614 #define GT801_GPIO_INT RK29_PIN4_PD5
615 #define GT801_GPIO_RESET RK29_PIN6_PC3
616 static struct ili2102_platform_data ili2102_info = {
623 .gpio_reset = GT801_GPIO_RESET,
624 .gpio_reset_active_low = 1,
625 .gpio_pendown = GT801_GPIO_INT,
626 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
627 .resetpin_iomux_name = NULL,
628 .pendown_iomux_mode = GPIO4H_GPIO4D5,
629 .resetpin_iomux_mode = 0,
633 /* EETI_EGALAX touch I2C */
634 #if defined (CONFIG_EETI_EGALAX)
635 #define TOUCH_RESET_PIN RK29_PIN6_PC3
636 #define TOUCH_INT_PIN RK29_PIN4_PD5
638 static int EETI_EGALAX_init_platform_hw(void)
640 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
641 gpio_free(TOUCH_RESET_PIN);
642 printk("p1003_init_platform_hw gpio_request error\n");
646 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
647 gpio_free(TOUCH_INT_PIN);
648 printk("p1003_init_platform_hw gpio_request error\n");
651 gpio_pull_updown(TOUCH_INT_PIN, 1);
652 gpio_direction_output(TOUCH_RESET_PIN, 0);
654 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
656 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
662 static struct eeti_egalax_platform_data eeti_egalax_info = {
664 .init_platform_hw= EETI_EGALAX_init_platform_hw,
670 #if defined (CONFIG_GS_MMA8452)
671 #define MMA8452_INT_PIN RK29_PIN6_PC4
673 static int mma8452_init_platform_hw(void)
676 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
677 gpio_free(MMA8452_INT_PIN);
678 printk("mma8452_init_platform_hw gpio_request error\n");
681 gpio_pull_updown(MMA8452_INT_PIN, 1);
686 static struct mma8452_platform_data mma8452_info = {
689 .init_platform_hw= mma8452_init_platform_hw,
694 #if defined (CONFIG_MPU_SENSORS_MPU3050)
696 static struct mpu3050_platform_data mpu3050_data = {
698 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
699 .orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
700 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
701 //.orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
702 //.orientation = { 1, 0, 0,0, 1, 0, 0, 0, 1 },
704 #if defined (CONFIG_MPU_SENSORS_KXTF9)
706 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
707 .get_slave_descr = NULL ,
709 .get_slave_descr = get_accel_slave_descr ,
711 .adapt_num = 0, // The i2c bus to which the mpu device is
713 //.irq = RK29_PIN6_PC4,
714 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
716 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
717 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
718 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
719 //.orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
720 .orientation = {1, 0, 0, 0, 1, 0, 0, 0, 1},
724 #if defined (CONFIG_MPU_SENSORS_MMA845X)
726 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
727 .get_slave_descr = NULL ,
729 .get_slave_descr = get_accel_slave_descr ,
731 .adapt_num = 0, // The i2c bus to which the mpu device is
733 //.irq = RK29_PIN6_PC4,
734 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
736 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
737 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
738 .orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
739 //.orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
743 #if defined (CONFIG_MPU_SENSORS_AK8975)
745 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
746 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
748 .get_slave_descr = get_compass_slave_descr,
750 .adapt_num = 0, // The i2c bus to which the compass device is.
751 // It can be difference with mpu
753 //.irq = RK29_PIN6_PC5,
754 .bus = EXT_SLAVE_BUS_PRIMARY,
756 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
757 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
758 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
759 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
760 //.orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
761 .orientation = { 1, 0 ,0, 0 ,-1, 0, 0, 0, -1 },
767 #if defined(CONFIG_GPIO_WM831X)
768 struct rk29_gpio_expander_info wm831x_gpio_settinginfo[] = {
770 .gpio_num =WM831X_P01,// tp3
771 .pin_type = GPIO_OUT,
772 .pin_value =GPIO_HIGH,
776 .gpio_num =WM831X_P02,//tp4
777 .pin_type = GPIO_OUT,
778 .pin_value =GPIO_HIGH,
781 .gpio_num =WM831X_P03,//tp2
782 .pin_type = GPIO_OUT,
783 .pin_value =GPIO_HIGH,
786 .gpio_num =WM831X_P04,//tp1
787 .pin_type = GPIO_OUT,
788 .pin_value =GPIO_HIGH,
791 .gpio_num =WM831X_P05,//tp1
792 .pin_type = GPIO_OUT,
793 .pin_value =GPIO_HIGH,
796 .gpio_num =WM831X_P06,//tp1
797 .pin_type = GPIO_OUT,
798 .pin_value =GPIO_HIGH,
801 .gpio_num =WM831X_P07,//tp1
802 .pin_type = GPIO_OUT,
803 .pin_value =GPIO_HIGH,
806 .gpio_num =WM831X_P08,//tp1
807 .pin_type = GPIO_OUT,
808 .pin_value =GPIO_HIGH,
811 .gpio_num =WM831X_P09,//tp1
812 .pin_type = GPIO_OUT,
813 .pin_value =GPIO_HIGH,
816 .gpio_num =WM831X_P10,//tp1
817 .pin_type = GPIO_OUT,
818 .pin_value =GPIO_HIGH,
821 .gpio_num =WM831X_P11,//tp1
822 .pin_type = GPIO_OUT,
823 .pin_value =GPIO_HIGH,
826 .gpio_num =WM831X_P12,
827 .pin_type = GPIO_OUT,
828 .pin_value =GPIO_HIGH,
836 #if defined(CONFIG_MFD_WM831X)
837 static struct wm831x *gWm831x;
838 int wm831x_pre_init(struct wm831x *parm)
841 printk("%s\n", __FUNCTION__);
844 ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
845 wm831x_reg_write(parm, WM831X_POWER_STATE, (ret&0xfff8) | 0x04);
848 wm831x_reg_write(parm,WM831X_SECURITY_KEY,0x9716); // unlock security key
849 wm831x_set_bits(parm, WM831X_RESET_CONTROL,0x1000,0x1000);
850 ret = wm831x_reg_read(parm, WM831X_RESET_CONTROL) & 0xffff&UNLOCK_SECURITY_KEY;// enternal reset active in sleep
851 printk("%s:WM831X_RESET_CONTROL=0x%x\n",__FUNCTION__,ret);
852 wm831x_reg_write(parm, WM831X_RESET_CONTROL, ret);
855 wm831x_reg_write(parm,WM831X_SECURITY_KEY,LOCK_SECURITY_KEY); // lock security key
859 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 3), 0);
860 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 7), 0);
861 printk("%s:disable ldo4 and ldo8 because they are enabled in uboot\n",__FUNCTION__);
865 int wm831x_post_init(struct wm831x *parm)
867 struct regulator *dcdc;
868 struct regulator *ldo;
871 dcdc = regulator_get(NULL, "dcdc3"); // 1th IO
872 regulator_set_voltage(dcdc,3000000,3000000);
873 regulator_set_suspend_voltage(dcdc, 2800000);
874 regulator_enable(dcdc);
875 printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
879 ldo = regulator_get(NULL, "ldo10"); // 1th modem IO
880 regulator_set_voltage(ldo,3000000,3000000);
881 regulator_set_suspend_voltage(ldo,3000000);
882 regulator_enable(ldo);
883 printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
887 dcdc = regulator_get(NULL, "dcdc2"); // 2th CORE
888 regulator_set_voltage(dcdc,1300000,1300000);
889 regulator_set_suspend_voltage(dcdc,1000000);
890 regulator_enable(dcdc);
891 printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
895 dcdc = regulator_get(NULL, "dcdc1"); // 3th ddr
896 regulator_set_voltage(dcdc,1800000,1800000);
897 regulator_set_suspend_voltage(dcdc,1800000);
898 regulator_enable(dcdc);
899 printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
903 ldo = regulator_get(NULL, "ldo1"); // 3th nand
904 regulator_set_voltage(ldo,1800000,1800000);
905 regulator_set_suspend_voltage(ldo,1800000);
906 regulator_enable(ldo);
907 printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
911 ldo = regulator_get(NULL, "ldo4"); // 4th usb
912 regulator_set_voltage(ldo,2500000,2500000);
913 regulator_set_suspend_voltage(ldo,0000000);
914 regulator_enable(ldo);
915 printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
919 ldo = regulator_get(NULL, "ldo7"); // 5th usb
920 regulator_set_voltage(ldo,3300000,3300000);
921 regulator_set_suspend_voltage(ldo,3300000);
922 regulator_enable(ldo);
923 printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
927 dcdc = regulator_get(NULL, "dcdc4"); // backlight
928 regulator_set_voltage(dcdc,20000000,16000000);
929 regulator_set_suspend_voltage(dcdc, 16000000);
930 regulator_enable(dcdc);
931 printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
936 ldo = regulator_get(NULL, "ldo2"); //lcd
937 regulator_set_voltage(ldo,3000000,3000000);
938 regulator_set_suspend_voltage(ldo,3000000);
939 regulator_enable(ldo);
940 printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
944 ldo = regulator_get(NULL, "ldo5"); //tf
945 regulator_set_voltage(ldo,3000000,3000000);
946 regulator_set_suspend_voltage(ldo,3000000);
947 regulator_enable(ldo);
948 printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
951 ldo = regulator_get(NULL, "ldo6"); //camera
952 regulator_set_voltage(ldo,2800000,2800000);
953 regulator_set_suspend_voltage(ldo,2800000);
954 regulator_enable(ldo);
955 printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
962 ldo = regulator_get(NULL, "ldo3"); //sram
963 regulator_set_voltage(ldo,1800000,1800000);
964 regulator_set_suspend_voltage(ldo,1800000);
965 regulator_enable(ldo);
966 printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
970 ldo = regulator_get(NULL, "ldo8"); //cmmb
971 regulator_set_voltage(ldo,1200000,1200000);
972 regulator_set_suspend_voltage(ldo,1200000);
973 regulator_enable(ldo);
974 printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
977 ldo = regulator_get(NULL, "ldo9"); //cmmb
978 regulator_set_voltage(ldo,3000000,3000000);
979 regulator_set_suspend_voltage(ldo,3000000);
980 regulator_enable(ldo);
981 printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
987 ldo = regulator_get(NULL, "ldo11");
988 //regulator_enable(ldo);
989 printk("%s set ldo11=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
996 extern void wm831x_enter_sleep(void);
997 extern void wm831x_exit_sleep(void);
999 void pmu_wm831x_set_suspend_voltage(void)
1003 EXPORT_SYMBOL_GPL(pmu_wm831x_set_suspend_voltage);
1005 void pmu_wm831x_set_resume_voltage(void)
1009 EXPORT_SYMBOL_GPL(pmu_wm831x_set_resume_voltage);
1011 int wm831x_last_deinit(struct wm831x *parm)
1013 struct regulator* ldo;
1015 printk("%s\n", __FUNCTION__);
1017 ldo = regulator_get(NULL, "ldo1");
1018 regulator_disable(ldo);
1021 ldo = regulator_get(NULL, "ldo2");
1022 regulator_disable(ldo);
1025 ldo = regulator_get(NULL, "ldo3");
1026 regulator_disable(ldo);
1029 ldo = regulator_get(NULL, "ldo4");
1030 //regulator_disable(ldo);
1033 ldo = regulator_get(NULL, "ldo5");
1034 regulator_disable(ldo);
1037 ldo = regulator_get(NULL, "ldo6");
1038 regulator_disable(ldo);
1041 ldo = regulator_get(NULL, "ldo7");
1042 regulator_disable(ldo);
1045 ldo = regulator_get(NULL, "ldo8");
1046 //regulator_disable(ldo);
1049 ldo = regulator_get(NULL, "ldo9");
1050 regulator_disable(ldo);
1053 ldo = regulator_get(NULL, "ldo10");
1054 regulator_disable(ldo);
1060 struct wm831x_backlight_pdata wm831x_backlight_platdata = {
1061 .isink = 1, /** ISINK to use, 1 or 2 */
1062 .max_uA = 19484, /** Maximum current to allow */
1065 struct wm831x_backup_pdata wm831x_backup_platdata = {
1066 .charger_enable = 1,
1067 .no_constant_voltage = 0, /** Disable constant voltage charging */
1068 .vlim = 3100, /** Voltage limit in milivolts */
1069 .ilim = 300, /** Current limit in microamps */
1072 struct wm831x_battery_pdata wm831x_battery_platdata = {
1073 .enable = 1, /** Enable charging */
1074 .fast_enable = 1, /** Enable fast charging */
1075 .off_mask = 1, /** Mask OFF while charging */
1076 .trickle_ilim = 200, /** Trickle charge current limit, in mA */
1077 .vsel = 4200, /** Target voltage, in mV */
1078 .eoc_iterm = 50, /** End of trickle charge current, in mA */
1079 .fast_ilim = 600, /** Fast charge current limit, in mA */
1080 .timeout = 480, /** Charge cycle timeout, in minutes */
1081 .syslo = 3300, /* syslo threshold, in mV*/
1082 .sysok = 3500, /* sysko threshold, in mV*/
1085 struct wm831x_status_pdata wm831x_status_platdata[WM831X_MAX_STATUS] = {
1087 .default_src = WM831X_STATUS_OTP,
1088 .name = "wm831x_status0",
1089 .default_trigger = "wm831x_otp",
1092 .default_src = WM831X_STATUS_POWER,
1093 .name = "wm831x_status1",
1094 .default_trigger = "wm831x_power",
1099 static struct regulator_consumer_supply dcdc1_consumers[] = {
1104 static struct regulator_consumer_supply dcdc2_consumers[] = {
1112 static struct regulator_consumer_supply dcdc3_consumers[] = {
1117 static struct regulator_consumer_supply dcdc4_consumers[] = {
1122 static struct regulator_consumer_supply epe1_consumers[] = {
1127 static struct regulator_consumer_supply epe2_consumers[] = {
1132 static struct regulator_consumer_supply ldo1_consumers[] = {
1137 static struct regulator_consumer_supply ldo2_consumers[] = {
1142 static struct regulator_consumer_supply ldo3_consumers[] = {
1147 static struct regulator_consumer_supply ldo4_consumers[] = {
1152 static struct regulator_consumer_supply ldo5_consumers[] = {
1157 static struct regulator_consumer_supply ldo6_consumers[] = {
1162 static struct regulator_consumer_supply ldo7_consumers[] = {
1167 static struct regulator_consumer_supply ldo8_consumers[] = {
1172 static struct regulator_consumer_supply ldo9_consumers[] = {
1177 static struct regulator_consumer_supply ldo10_consumers[] = {
1182 static struct regulator_consumer_supply ldo11_consumers[] = {
1187 static struct regulator_consumer_supply isink1_consumers[] = {
1192 static struct regulator_consumer_supply isink2_consumers[] = {
1198 struct regulator_init_data wm831x_regulator_init_dcdc[WM831X_MAX_DCDC] = {
1203 .max_uV = 1800000,//0.6-1.8V
1205 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1207 .num_consumer_supplies = ARRAY_SIZE(dcdc1_consumers),
1208 .consumer_supplies = dcdc1_consumers,
1214 .max_uV = 1800000,//0.6-1.8V
1216 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1218 .num_consumer_supplies = ARRAY_SIZE(dcdc2_consumers),
1219 .consumer_supplies = dcdc2_consumers,
1225 .max_uV = 3400000,//0.85-3.4V
1227 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1229 .num_consumer_supplies = ARRAY_SIZE(dcdc3_consumers),
1230 .consumer_supplies = dcdc3_consumers,
1236 .max_uV = 30000000,//30V/40mA
1238 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1240 .num_consumer_supplies = ARRAY_SIZE(dcdc4_consumers),
1241 .consumer_supplies = dcdc4_consumers,
1245 struct regulator_init_data wm831x_regulator_init_epe[WM831X_MAX_EPE] = {
1252 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1254 .num_consumer_supplies = ARRAY_SIZE(epe1_consumers),
1255 .consumer_supplies = epe1_consumers,
1263 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1265 .num_consumer_supplies = ARRAY_SIZE(epe2_consumers),
1266 .consumer_supplies = epe2_consumers,
1270 struct regulator_init_data wm831x_regulator_init_ldo[WM831X_MAX_LDO] = {
1277 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1279 .num_consumer_supplies = ARRAY_SIZE(ldo1_consumers),
1280 .consumer_supplies = ldo1_consumers,
1288 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1290 .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
1291 .consumer_supplies = ldo2_consumers,
1299 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1301 .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
1302 .consumer_supplies = ldo3_consumers,
1310 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1312 .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
1313 .consumer_supplies = ldo4_consumers,
1321 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1323 .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
1324 .consumer_supplies = ldo5_consumers,
1332 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1334 .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers),
1335 .consumer_supplies = ldo6_consumers,
1343 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1345 .num_consumer_supplies = ARRAY_SIZE(ldo7_consumers),
1346 .consumer_supplies = ldo7_consumers,
1354 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1356 .num_consumer_supplies = ARRAY_SIZE(ldo8_consumers),
1357 .consumer_supplies = ldo8_consumers,
1365 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1367 .num_consumer_supplies = ARRAY_SIZE(ldo9_consumers),
1368 .consumer_supplies = ldo9_consumers,
1376 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1378 .num_consumer_supplies = ARRAY_SIZE(ldo10_consumers),
1379 .consumer_supplies = ldo10_consumers,
1387 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1389 .num_consumer_supplies = ARRAY_SIZE(ldo11_consumers),
1390 .consumer_supplies = ldo11_consumers,
1394 struct regulator_init_data wm831x_regulator_init_isink[WM831X_MAX_ISINK] = {
1402 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1404 .num_consumer_supplies = ARRAY_SIZE(isink1_consumers),
1405 .consumer_supplies = isink1_consumers,
1413 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1415 .num_consumer_supplies = ARRAY_SIZE(isink2_consumers),
1416 .consumer_supplies = isink2_consumers,
1420 static int wm831x_checkrange(int start,int num,int val)
1422 if((val<(start+num))&&(val>=start))
1428 static int wm831x_init_pin_type(struct wm831x *wm831x)
1431 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
1432 struct rk29_gpio_expander_info *wm831x_gpio_settinginfo;
1433 uint16_t offset = 0;
1434 uint16_t wm831x_settingpin_num = 0;
1440 wm831x_gpio_settinginfo=pdata->settinginfo;
1441 if(wm831x_gpio_settinginfo)
1443 wm831x_settingpin_num = pdata->settinginfolen;
1444 for(i=0;i<wm831x_settingpin_num;i++)
1446 if(!wm831x_checkrange(pdata->gpio_base,pdata->gpio_pin_num,wm831x_gpio_settinginfo[i].gpio_num))
1448 offset = wm831x_gpio_settinginfo[i].gpio_num - pdata->gpio_base;
1450 if(wm831x_gpio_settinginfo[i].pin_type==GPIO_IN)
1452 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);
1456 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_TRI_SHIFT);
1457 if(wm831x_gpio_settinginfo[i].pin_value==GPIO_HIGH)
1459 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(1 << offset));
1463 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(0 << offset));
1472 for(i=0;i<pdata->gpio_pin_num;i++)
1474 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+i),
1475 WM831X_GPN_PULL_MASK|WM831X_GPN_POL_MASK|WM831X_GPN_OD_MASK|WM831X_GPN_TRI_MASK,
1476 1<<WM831X_GPN_POL_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
1477 ret = wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL+i);
1478 printk("Gpio%d Pin Configuration = %x\n",i,ret);
1487 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1488 static struct wm831x_gpio_keys_button wm831x_gpio_buttons[] = {
1491 .gpio = TCA6424_P21,
1495 .debounce_interval = 120,
1498 .code= KEY_VOLUMEUP,
1512 .code= KEY_VOLUMEDOWN,
1515 .desc= "volume_down",
1548 struct wm831x_gpio_keys_pdata wm831x_gpio_keys_platdata = {
1549 .buttons = wm831x_gpio_buttons,
1550 .nbuttons = ARRAY_SIZE(wm831x_gpio_buttons),
1554 struct wm831x_pdata wm831x_platdata = {
1555 /** Called before subdevices are set up */
1556 .pre_init= wm831x_pre_init,
1557 /** Called after subdevices are set up */
1558 .post_init = wm831x_post_init,
1559 /** Called before subdevices are power down */
1560 .last_deinit = wm831x_last_deinit,
1562 #if defined(CONFIG_GPIO_WM831X)
1563 .gpio_base=WM831X_GPIO_EXPANDER_BASE,
1564 .gpio_pin_num=WM831X_TOTOL_GPIO_NUM,
1565 .settinginfo=wm831x_gpio_settinginfo,
1566 .settinginfolen=ARRAY_SIZE(wm831x_gpio_settinginfo),
1567 .pin_type_init = wm831x_init_pin_type,
1568 .irq_base= NR_AIC_IRQS + 7*NUM_GROUP,
1571 .backlight = &wm831x_backlight_platdata,
1573 .backup = &wm831x_backup_platdata,
1575 .battery = &wm831x_battery_platdata,
1576 //.wm831x_touch_pdata = NULL,
1579 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1580 .gpio_keys = &wm831x_gpio_keys_platdata,
1583 /** LED1 = 0 and so on */
1584 .status = {&wm831x_status_platdata[0], &wm831x_status_platdata[1]},
1586 /** DCDC1 = 0 and so on */
1587 .dcdc = {&wm831x_regulator_init_dcdc[0], &wm831x_regulator_init_dcdc[1], &wm831x_regulator_init_dcdc[2], &wm831x_regulator_init_dcdc[3]},
1589 /** EPE1 = 0 and so on */
1590 .epe = {&wm831x_regulator_init_epe[0], &wm831x_regulator_init_epe[1]},
1592 /** LDO1 = 0 and so on */
1593 .ldo = {&wm831x_regulator_init_ldo[0], &wm831x_regulator_init_ldo[1], &wm831x_regulator_init_ldo[2], &wm831x_regulator_init_ldo[3],
1594 &wm831x_regulator_init_ldo[4], &wm831x_regulator_init_ldo[5], &wm831x_regulator_init_ldo[6], &wm831x_regulator_init_ldo[7],
1595 &wm831x_regulator_init_ldo[8], &wm831x_regulator_init_ldo[9], &wm831x_regulator_init_ldo[10]},
1597 /** ISINK1 = 0 and so on*/
1598 .isink = {&wm831x_regulator_init_isink[0], &wm831x_regulator_init_isink[1]},
1602 #if defined(CONFIG_RK29_GPIO_SUSPEND)
1603 static void gpio_set_request(void)
1605 gpio_request(RK29_PIN6_PA0, NULL);
1606 gpio_request(RK29_PIN6_PA1, NULL);
1607 gpio_request(RK29_PIN6_PA2, NULL);
1608 gpio_request(RK29_PIN6_PA3, NULL);
1609 gpio_request(RK29_PIN6_PA4, NULL);
1610 gpio_request(RK29_PIN6_PA5, NULL);
1611 gpio_request(RK29_PIN6_PA6, NULL);
1613 gpio_request(RK29_PIN2_PA5, NULL);
1614 gpio_request(RK29_PIN2_PA4, NULL);
1615 gpio_request(RK29_PIN2_PB0, NULL);
1616 gpio_request(RK29_PIN2_PB1, NULL);
1617 gpio_request(RK29_PIN2_PB2, NULL);
1618 gpio_request(RK29_PIN2_PB3, NULL);
1620 gpio_request(RK29_PIN1_PA4, NULL);
1621 gpio_request(RK29_PIN1_PA3, NULL);
1623 gpio_request(RK29_PIN2_PC7, NULL);
1624 gpio_request(RK29_PIN2_PC6, NULL);
1625 gpio_request(RK29_PIN2_PC5, NULL);
1626 gpio_request(RK29_PIN2_PC4, NULL);
1627 gpio_request(RK29_PIN2_PC3, NULL);
1628 gpio_request(RK29_PIN2_PC2, NULL);
1629 gpio_request(RK29_PIN2_PC1, NULL);
1630 gpio_request(RK29_PIN2_PC0, NULL);
1633 static void gpio_set_free(void)
1635 gpio_free(RK29_PIN6_PA0);
1636 gpio_free(RK29_PIN6_PA1);
1637 gpio_free(RK29_PIN6_PA2);
1638 gpio_free(RK29_PIN6_PA3);
1639 gpio_free(RK29_PIN6_PA4);
1640 gpio_free(RK29_PIN6_PA5);
1641 gpio_free(RK29_PIN6_PA6);
1643 gpio_free(RK29_PIN2_PA5);
1644 gpio_free(RK29_PIN2_PA4);
1645 gpio_free(RK29_PIN2_PB0);
1646 gpio_free(RK29_PIN2_PB1);
1647 gpio_free(RK29_PIN2_PB2);
1648 gpio_free(RK29_PIN2_PB3);
1650 gpio_free(RK29_PIN1_PA4);
1651 gpio_free(RK29_PIN1_PA3);
1653 gpio_free(RK29_PIN2_PC7);
1654 gpio_free(RK29_PIN2_PC6);
1655 gpio_free(RK29_PIN2_PC5);
1656 gpio_free(RK29_PIN2_PC4);
1657 gpio_free(RK29_PIN2_PC3);
1658 gpio_free(RK29_PIN2_PC2);
1659 gpio_free(RK29_PIN2_PC1);
1660 gpio_free(RK29_PIN2_PC0);
1663 static void rk29_keygpio_suspend(void)
1665 gpio_pull_updown(RK29_PIN6_PA0, 0);
1666 gpio_pull_updown(RK29_PIN6_PA1, 0);
1667 gpio_pull_updown(RK29_PIN6_PA2, 0);
1668 gpio_pull_updown(RK29_PIN6_PA3, 0);
1669 gpio_pull_updown(RK29_PIN6_PA4, 0);
1670 gpio_pull_updown(RK29_PIN6_PA5, 0);
1671 gpio_pull_updown(RK29_PIN6_PA6, 0);//key pullup/pulldown disable
1673 gpio_pull_updown(RK29_PIN2_PA4, 0);
1674 gpio_pull_updown(RK29_PIN2_PA5, 0);
1675 gpio_pull_updown(RK29_PIN2_PB0, 0);
1676 gpio_pull_updown(RK29_PIN2_PB1, 0);
1677 gpio_pull_updown(RK29_PIN2_PB2, 0);
1678 gpio_pull_updown(RK29_PIN2_PB3, 0);
1681 static void rk29_keygpio_resume(void)
1683 gpio_pull_updown(RK29_PIN6_PA0, 1);
1684 gpio_pull_updown(RK29_PIN6_PA1, 1);
1685 gpio_pull_updown(RK29_PIN6_PA2, 1);
1686 gpio_pull_updown(RK29_PIN6_PA3, 1);
1687 gpio_pull_updown(RK29_PIN6_PA4, 1);
1688 gpio_pull_updown(RK29_PIN6_PA5, 1);
1689 gpio_pull_updown(RK29_PIN6_PA6, 1);//key pullup/pulldown enable
1691 gpio_pull_updown(RK29_PIN2_PA4, 1);
1692 gpio_pull_updown(RK29_PIN2_PA5, 1);
1693 gpio_pull_updown(RK29_PIN2_PB0, 1);
1694 gpio_pull_updown(RK29_PIN2_PB1, 1);
1695 gpio_pull_updown(RK29_PIN2_PB2, 1);
1696 gpio_pull_updown(RK29_PIN2_PB3, 1);
1699 static void spi_gpio_suspend(void)
1701 rk29_mux_api_set(GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,GPIO1L_GPIO1A4); //set iomux is gpio mode
1702 rk29_mux_api_set(GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,GPIO1L_GPIO1A3);
1704 rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_GPIO2C7);
1705 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_GPIO2C6);
1706 //rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_GPIO2C5);
1707 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_GPIO2C4);
1708 rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME,GPIO2H_GPIO2C3);
1709 rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME,GPIO2H_GPIO2C2);
1710 rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME,GPIO2H_GPIO2C1);
1711 rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME,GPIO2H_GPIO2C0);
1713 gpio_direction_input(RK29_PIN1_PA4); //set gpio is input
1714 gpio_direction_input(RK29_PIN1_PA3);
1715 gpio_direction_input(RK29_PIN2_PC7);
1716 gpio_direction_input(RK29_PIN2_PC6);
1717 // gpio_direction_input(RK29_PIN2_PC5);
1718 gpio_direction_input(RK29_PIN2_PC4);
1719 gpio_direction_input(RK29_PIN2_PC3);
1720 gpio_direction_input(RK29_PIN2_PC2);
1721 gpio_direction_input(RK29_PIN2_PC1);
1722 gpio_direction_input(RK29_PIN2_PC0);
1724 gpio_pull_updown(RK29_PIN1_PA4, 0); //set gpio pullup/down disable
1725 gpio_pull_updown(RK29_PIN1_PA3, 0);
1727 gpio_pull_updown(RK29_PIN2_PC7, 0);
1728 gpio_pull_updown(RK29_PIN2_PC6, 0);
1729 //gpio_pull_updown(RK29_PIN2_PC5, 0);
1730 gpio_pull_updown(RK29_PIN2_PC4, 0);
1731 gpio_pull_updown(RK29_PIN2_PC3, 0);
1732 gpio_pull_updown(RK29_PIN2_PC2, 0);
1733 gpio_pull_updown(RK29_PIN2_PC1, 0);
1734 gpio_pull_updown(RK29_PIN2_PC0, 0);
1737 static void spi_gpio_resume(void)
1739 gpio_pull_updown(RK29_PIN1_PA4, 1); //set gpio pullup/down enable
1740 gpio_pull_updown(RK29_PIN1_PA3, 1);
1742 gpio_pull_updown(RK29_PIN2_PC7, 1);
1743 gpio_pull_updown(RK29_PIN2_PC6, 1);
1744 //gpio_pull_updown(RK29_PIN2_PC5, 1);
1745 gpio_pull_updown(RK29_PIN2_PC4, 1);
1746 gpio_pull_updown(RK29_PIN2_PC3, 1);
1747 gpio_pull_updown(RK29_PIN2_PC2, 1);
1748 gpio_pull_updown(RK29_PIN2_PC1, 1);
1749 gpio_pull_updown(RK29_PIN2_PC0, 1);
1751 rk29_mux_api_set(GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,GPIO1L_SPI0_CSN1); //set iomux is spi mode
1752 rk29_mux_api_set(GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,GPIO1L_SPI1_CSN1);
1754 rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_SPI1_RXD);
1755 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_SPI1_TXD);
1756 //rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_SPI1_CSN0);
1757 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK);
1758 rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME,GPIO2H_SPI0_RXD);
1759 rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME,GPIO2H_SPI0_TXD);
1760 rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME,GPIO2H_SPI0_CSN0);
1761 rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME,GPIO2H_SPI0_CLK);
1764 void rk29_setgpio_suspend_board(void)
1767 rk29_keygpio_suspend();
1772 void rk29_setgpio_resume_board(void)
1775 rk29_keygpio_resume();
1781 #if defined(CONFIG_RK29_GPS)
1783 #define RK29_GPS_POWER_PIN RK29_PIN6_PB2
1784 #define RK29_GPS_RESET_PIN RK29_PIN6_PA7//RK29_PIN6_PC1 //modif by zwx CONFIG_CSR_GPS_GSD4E
1786 int rk29_gps_power_up(void)
1788 printk("%s \n", __FUNCTION__);
1790 gpio_request(RK29_GPS_POWER_PIN, NULL);
1791 gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH);
1796 int rk29_gps_power_down(void)
1798 printk("%s \n", __FUNCTION__);
1800 gpio_request(RK29_GPS_POWER_PIN, NULL);
1801 gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW);
1806 int rk29_gps_reset_set(int level)
1808 gpio_request(RK29_GPS_RESET_PIN, NULL);
1810 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);
1812 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);
1815 #ifdef CONFIG_CSR_GPS_GSD4E
1816 struct gps_rfkill_platform_data gps_rfkill_data=
1818 .nshutdown_gpio=RK29_PIN6_PB2,
1819 .reset_gpio=RK29_PIN6_PA7,
1821 static struct platform_device rk_csrgps_device={
1826 .platform_data = &gps_rfkill_data,
1830 struct rk29_gps_data rk29_gps_info = {
1831 .power_up = rk29_gps_power_up,
1832 .power_down = rk29_gps_power_down,
1833 .reset = rk29_gps_reset_set,
1837 struct platform_device rk29_device_gps = {
1841 .platform_data = &rk29_gps_info,
1847 /*****************************************************************************************
1849 * author: qjb@rock-chips.com
1850 *****************************************************************************************/
1851 #if defined (CONFIG_SND_SOC_WM8994)
1852 struct wm8994_pdata wm8994_platdata = {
1854 .BB_class = NO_PCM_BB,
1857 .sp_hp_same_channel = 0,
1859 .PA_control_pin = 0,
1860 .Power_EN_Pin = RK29_PIN5_PA1,
1862 .speaker_incall_vol = 0,
1863 .speaker_incall_mic_vol = -9,
1864 .speaker_normal_vol = 6,
1865 .earpiece_incall_vol = 0,
1866 .headset_incall_vol = 6,
1867 .headset_incall_mic_vol = -6,
1868 .headset_normal_vol = -6,
1870 .BT_incall_mic_vol = 0,
1876 #ifdef CONFIG_RK_HEADSET_DET
1877 #define HEADSET_GPIO RK29_PIN4_PD2
1878 struct rk_headset_pdata rk_headset_info = {
1879 .Headset_gpio = RK29_PIN4_PD2,
1880 .headset_in_type= HEADSET_IN_HIGH,
1881 .Hook_gpio = RK29_PIN4_PD1,//Detection Headset--Must be set
1882 .hook_key_code = KEY_MEDIA,
1885 struct platform_device rk_device_headset = {
1886 .name = "rk_headsetdet",
1889 .platform_data = &rk_headset_info,
1894 #if defined(CONFIG_GS_L3G4200D)
1896 #include <linux/l3g4200d.h>
1897 #define L3G4200D_INT_PIN RK29_PIN5_PA3
1899 static int l3g4200d_init_platform_hw(void)
1901 if (gpio_request(L3G4200D_INT_PIN, NULL) != 0) {
1902 gpio_free(L3G4200D_INT_PIN);
1903 printk("%s: request l3g4200d int pin error\n", __func__);
1906 gpio_pull_updown(L3G4200D_INT_PIN, 1);
1910 static struct l3g4200d_platform_data l3g4200d_info = {
1921 .init = l3g4200d_init_platform_hw,
1926 /*****************************************************************************************
1928 * author: kfx@rock-chips.com
1929 *****************************************************************************************/
1930 static int rk29_i2c0_io_init(void)
1932 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1933 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
1934 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
1936 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
1937 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
1942 static int rk29_i2c1_io_init(void)
1944 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1945 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
1946 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
1948 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
1949 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
1953 static int rk29_i2c2_io_init(void)
1955 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1956 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
1957 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
1959 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
1960 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
1965 static int rk29_i2c3_io_init(void)
1967 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1968 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
1969 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1971 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
1972 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
1976 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1977 struct rk29_i2c_platform_data default_i2c0_data = {
1981 .scl_rate = 400*1000,
1982 .mode = I2C_MODE_IRQ,
1983 .io_init = rk29_i2c0_io_init,
1986 struct i2c_gpio_platform_data default_i2c0_data = {
1987 .sda_pin = RK29_PIN2_PB6,
1988 .scl_pin = RK29_PIN2_PB7,
1989 .udelay = 5, // clk = 500/udelay = 100Khz
1990 .timeout = 100,//msecs_to_jiffies(200),
1992 .io_init = rk29_i2c0_io_init,
1995 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1996 struct rk29_i2c_platform_data default_i2c1_data = {
2000 .scl_rate = 400*1000,
2001 .mode = I2C_MODE_IRQ,
2002 .io_init = rk29_i2c1_io_init,
2005 struct i2c_gpio_platform_data default_i2c1_data = {
2006 .sda_pin = RK29_PIN1_PA6,
2007 .scl_pin = RK29_PIN1_PA7,
2008 .udelay = 5, // clk = 500/udelay = 100Khz
2009 .timeout = 100,//msecs_to_jiffies(200),
2011 .io_init = rk29_i2c1_io_init,
2014 #ifdef CONFIG_RK29_I2C2_CONTROLLER
2015 struct rk29_i2c_platform_data default_i2c2_data = {
2019 .scl_rate = 400*1000,
2020 .mode = I2C_MODE_IRQ,
2021 .io_init = rk29_i2c2_io_init,
2024 struct i2c_gpio_platform_data default_i2c2_data = {
2025 .sda_pin = RK29_PIN5_PD3,
2026 .scl_pin = RK29_PIN5_PD4,
2027 .udelay = 5, // clk = 500/udelay = 100Khz
2028 .timeout = 100,//msecs_to_jiffies(200),
2030 .io_init = rk29_i2c2_io_init,
2033 #ifdef CONFIG_RK29_I2C3_CONTROLLER
2034 struct rk29_i2c_platform_data default_i2c3_data = {
2038 .scl_rate = 400*1000,
2039 .mode = I2C_MODE_IRQ,
2040 .io_init = rk29_i2c3_io_init,
2043 struct i2c_gpio_platform_data default_i2c3_data = {
2044 .sda_pin = RK29_PIN5_PB5,
2045 .scl_pin = RK29_PIN5_PB4,
2046 .udelay = 5, // clk = 500/udelay = 100Khz
2047 .timeout = 100,//msecs_to_jiffies(200),
2049 .io_init = rk29_i2c3_io_init,
2052 #ifdef CONFIG_I2C0_RK29
2053 static struct i2c_board_info __initdata board_i2c0_devices[] = {
2054 #if defined (CONFIG_RK1000_CONTROL)
2056 .type = "rk1000_control",
2061 #if defined (CONFIG_SND_SOC_RK1000)
2063 .type = "rk1000_i2c_codec",
2068 #if defined (CONFIG_SND_SOC_WM8900)
2075 #if defined (CONFIG_SND_SOC_WM8994)
2080 // #if defined(CONFIG_MFD_WM8994)
2081 .platform_data = &wm8994_platdata,
2085 #if defined (CONFIG_BATTERY_STC3100)
2092 #if defined (CONFIG_BATTERY_BQ27510)
2099 #if defined (CONFIG_RTC_HYM8563)
2101 .type = "rtc_hym8563",
2104 .irq = RK29_PIN0_PA1,
2107 #if defined (CONFIG_GS_MMA8452)
2109 .type = "gs_mma8452",
2112 .irq = MMA8452_INT_PIN,
2113 .platform_data = &mma8452_info,
2116 #if defined (CONFIG_COMPASS_AK8973)
2121 .irq = RK29_PIN6_PC5,
2124 #if defined (CONFIG_COMPASS_AK8975)
2129 .irq = RK29_PIN6_PC5,
2132 #if defined (CONFIG_INPUT_LPSENSOR_ISL29028)
2137 .irq = RK29_PIN4_PD3,
2140 #if defined (CONFIG_INPUT_LPSENSOR_APDS9900)
2145 .irq = RK29_PIN4_PD3,
2148 #if defined (CONFIG_ANX7150)
2151 .addr = 0x39, //0x39, 0x3d
2153 .irq = RK29_PIN2_PA3,
2156 #if defined (CONFIG_GS_L3G4200D)
2158 .type = "gs_l3g4200d",
2161 .irq = L3G4200D_INT_PIN,
2162 .platform_data = &l3g4200d_info,
2165 #if defined (CONFIG_MPU_SENSORS_MPU3050)
2170 .irq = RK29_PIN4_PC4,
2171 .platform_data = &mpu3050_data,
2177 #ifdef CONFIG_I2C1_RK29
2178 static struct i2c_board_info __initdata board_i2c1_devices[] = {
2179 #if defined (CONFIG_RK1000_CONTROL1)
2181 .type = "rk1000_control",
2190 #ifdef CONFIG_I2C2_RK29
2191 static struct i2c_board_info __initdata board_i2c2_devices[] = {
2192 #if defined (CONFIG_TOUCHSCREEN_GT801_IIC) || defined (CONFIG_TOUCHSCREEN_GT801_Z5)
2197 .irq = RK29_PIN4_PD5,
2198 .platform_data = >801_info,
2201 #if defined (CONFIG_TOUCHSCREEN_GT818_IIC)
2206 .irq = RK29_PIN4_PD5,
2207 .platform_data = >818_info,
2211 #if defined(CONFIG_TOUCHSCREEN_FT5X0X_Z5) || defined (CONFIG_TOUCHSCREEN_FT5306)
2213 .type = "ft5x0x_ts",
2216 .irq = RK29_PIN4_PD5,
2217 .platform_data = &ft5406_info,
2221 #if defined (CONFIG_TOUCHSCREEN_ILI2102_IIC)
2223 .type = "ili2102_ts",
2225 .flags = I2C_M_NEED_DELAY,
2227 .irq = RK29_PIN4_PD5,
2228 .platform_data = &ili2102_info,
2232 #if defined (CONFIG_MFD_WM831X_I2C)
2237 .irq = RK29_PIN4_PD0,
2238 .platform_data = &wm831x_platdata,
2241 #if defined (CONFIG_HANNSTAR_P1003)
2243 .type = "p1003_touch",
2246 .irq = RK29_PIN0_PA2,
2247 .platform_data = &p1003_info,
2250 #if defined (CONFIG_EETI_EGALAX)
2252 .type = "egalax_i2c",
2255 .irq = RK29_PIN4_PD5,
2256 .platform_data = &eeti_egalax_info,
2262 #ifdef CONFIG_I2C3_RK29
2263 static struct i2c_board_info __initdata board_i2c3_devices[] = {
2267 /*****************************************************************************************
2269 * author: ddl@rock-chips.com
2270 *****************************************************************************************/
2271 #ifdef CONFIG_VIDEO_RK29
2272 #define CONFIG_SENSOR_POWER_IOCTL_USR 0
2273 #define CONFIG_SENSOR_RESET_IOCTL_USR 0
2274 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0
2275 #define CONFIG_SENSOR_FLASH_IOCTL_USR 0
2277 #if CONFIG_SENSOR_POWER_IOCTL_USR
2278 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
2280 #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
2284 #if CONFIG_SENSOR_RESET_IOCTL_USR
2285 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
2287 #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
2291 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
2292 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
2294 #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
2298 #if CONFIG_SENSOR_FLASH_IOCTL_USR
2299 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
2301 #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
2305 static struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
2306 #if CONFIG_SENSOR_POWER_IOCTL_USR
2307 .sensor_power_cb = sensor_power_usr_cb,
2309 .sensor_power_cb = NULL,
2312 #if CONFIG_SENSOR_RESET_IOCTL_USR
2313 .sensor_reset_cb = sensor_reset_usr_cb,
2315 .sensor_reset_cb = NULL,
2318 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
2319 .sensor_powerdown_cb = sensor_powerdown_usr_cb,
2321 .sensor_powerdown_cb = NULL,
2324 #if CONFIG_SENSOR_FLASH_IOCTL_USR
2325 .sensor_flash_cb = sensor_flash_usr_cb,
2327 .sensor_flash_cb = NULL,
2330 #include "../../../drivers/media/video/rk29_camera.c"
2333 /*****************************************************************************************
2335 * author: nzy@rock-chips.com
2336 *****************************************************************************************/
2337 #ifdef CONFIG_BACKLIGHT_RK29_BL
2339 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
2340 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
2341 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
2342 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
2346 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
2347 #define PWM_MUX_MODE GPIO1L_PWM0
2348 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
2349 #define PWM_EFFECT_VALUE 1
2351 //#define LCD_DISP_ON_PIN
2353 #ifdef LCD_DISP_ON_PIN
2354 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
2355 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
2357 #define BL_EN_PIN GPIO0L_GPIO0A5
2358 #define BL_EN_VALUE GPIO_HIGH
2360 static int rk29_backlight_io_init(void)
2364 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
2365 #ifdef LCD_DISP_ON_PIN
2366 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
2368 ret = gpio_request(BL_EN_PIN, NULL);
2371 gpio_free(BL_EN_PIN);
2374 gpio_direction_output(BL_EN_PIN, 0);
2375 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
2380 static int rk29_backlight_io_deinit(void)
2383 #ifdef LCD_DISP_ON_PIN
2384 gpio_free(BL_EN_PIN);
2386 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
2389 struct rk29_bl_info rk29_bl_info = {
2391 .bl_ref = PWM_EFFECT_VALUE,
2392 .io_init = rk29_backlight_io_init,
2393 .io_deinit = rk29_backlight_io_deinit,
2396 /*****************************************************************************************
2397 * pwm voltage regulator devices
2398 ******************************************************************************************/
2399 #if defined (CONFIG_RK29_PWM_REGULATOR)
2401 #define REGULATOR_PWM_ID 2
2402 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
2403 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
2404 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
2405 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
2407 static struct regulator_consumer_supply pwm_consumers[] = {
2413 static struct regulator_init_data rk29_pwm_regulator_data = {
2419 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
2421 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
2422 .consumer_supplies = pwm_consumers,
2425 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
2426 .pwm_id = REGULATOR_PWM_ID,
2427 .pwm_gpio = REGULATOR_PWM_GPIO,
2428 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
2429 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
2430 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
2431 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
2432 .init_data = &rk29_pwm_regulator_data,
2435 static struct platform_device rk29_device_pwm_regulator = {
2436 .name = "pwm-voltage-regulator",
2439 .platform_data = &rk29_regulator_pwm_platform_data,
2446 #if defined(CONFIG_MTK23D)
2447 static int mtk23d_io_init(void)
2452 static int mtk23d_io_deinit(void)
2458 struct rk2818_23d_data rk2818_23d_info = {
2459 .io_init = mtk23d_io_init,
2460 .io_deinit = mtk23d_io_deinit,
2461 .bp_power = RK29_PIN6_PB0,
2462 .bp_power_active_low = 0,
2463 .bp_reset = RK29_PIN6_PB1,
2464 .bp_reset_active_low = 0,
2465 .bp_statue = RK29_PIN0_PA2,//input high bp sleep;
2466 .ap_statue = RK29_PIN0_PA3,//output high ap sleep;
2467 .ap_bp_wakeup = RK29_PIN0_PA0, //output AP wake up BP used rising edge;
2468 .bp_ap_wakeup = RK29_PIN0_PA4,//input BP wake up AP
2470 struct platform_device rk2818_device_mtk23d = {
2474 .platform_data = &rk2818_23d_info,
2479 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
2480 #define SDMMC0_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin.
2484 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
2485 #define SDMMC1_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin.
2488 /*****************************************************************************************
2490 *****************************************************************************************/
2491 #if !defined(CONFIG_SDMMC_RK29_OLD)
2492 static void rk29_sdmmc_gpio_open(int device_id, int on)
2498 #ifdef CONFIG_SDMMC0_RK29
2501 gpio_direction_output(RK29_PIN1_PD0,GPIO_HIGH);//set mmc0-clk to high
2502 gpio_direction_output(RK29_PIN1_PD1,GPIO_HIGH);//set mmc0-cmd to high.
2503 gpio_direction_output(RK29_PIN1_PD2,GPIO_HIGH);//set mmc0-data0 to high.
2504 gpio_direction_output(RK29_PIN1_PD3,GPIO_HIGH);//set mmc0-data1 to high.
2505 gpio_direction_output(RK29_PIN1_PD4,GPIO_HIGH);//set mmc0-data2 to high.
2506 gpio_direction_output(RK29_PIN1_PD5,GPIO_HIGH);//set mmc0-data3 to high.
2512 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_GPIO1_D0);
2513 gpio_request(RK29_PIN1_PD0, "mmc0-clk");
2514 gpio_direction_output(RK29_PIN1_PD0,GPIO_LOW);//set mmc0-clk to low.
2516 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_GPIO1_D1);
2517 gpio_request(RK29_PIN1_PD1, "mmc0-cmd");
2518 gpio_direction_output(RK29_PIN1_PD1,GPIO_LOW);//set mmc0-cmd to low.
2520 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_GPIO1D2);
2521 gpio_request(RK29_PIN1_PD2, "mmc0-data0");
2522 gpio_direction_output(RK29_PIN1_PD2,GPIO_LOW);//set mmc0-data0 to low.
2524 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_GPIO1D3);
2525 gpio_request(RK29_PIN1_PD3, "mmc0-data1");
2526 gpio_direction_output(RK29_PIN1_PD3,GPIO_LOW);//set mmc0-data1 to low.
2528 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_GPIO1D4);
2529 gpio_request(RK29_PIN1_PD4, "mmc0-data2");
2530 gpio_direction_output(RK29_PIN1_PD4,GPIO_LOW);//set mmc0-data2 to low.
2532 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_GPIO1D5);
2533 gpio_request(RK29_PIN1_PD5, "mmc0-data3");
2534 gpio_direction_output(RK29_PIN1_PD5,GPIO_LOW);//set mmc0-data3 to low.
2544 #ifdef CONFIG_SDMMC1_RK29
2547 gpio_direction_output(RK29_PIN1_PC7,GPIO_HIGH);//set mmc1-clk to high
2548 gpio_direction_output(RK29_PIN1_PC2,GPIO_HIGH);//set mmc1-cmd to high.
2549 gpio_direction_output(RK29_PIN1_PC3,GPIO_HIGH);//set mmc1-data0 to high.
2550 gpio_direction_output(RK29_PIN1_PC4,GPIO_HIGH);//set mmc1-data1 to high.
2551 gpio_direction_output(RK29_PIN1_PC5,GPIO_HIGH);//set mmc1-data2 to high.
2552 gpio_direction_output(RK29_PIN1_PC6,GPIO_HIGH);//set mmc1-data3 to high.
2557 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_GPIO1C7);
2558 gpio_request(RK29_PIN1_PC7, "mmc1-clk");
2559 gpio_direction_output(RK29_PIN1_PC7,GPIO_LOW);//set mmc1-clk to low.
2561 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_GPIO1C2);
2562 gpio_request(RK29_PIN1_PC2, "mmc1-cmd");
2563 gpio_direction_output(RK29_PIN1_PC2,GPIO_LOW);//set mmc1-cmd to low.
2565 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_GPIO1C3);
2566 gpio_request(RK29_PIN1_PC3, "mmc1-data0");
2567 gpio_direction_output(RK29_PIN1_PC3,GPIO_LOW);//set mmc1-data0 to low.
2584 static void rk29_sdmmc_set_iomux_mmc0(unsigned int bus_width)
2589 case 1://SDMMC_CTYPE_4BIT:
2591 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
2592 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
2593 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
2597 case 0x10000://SDMMC_CTYPE_8BIT:
2599 case 0xFFFF: //gpio_reset
2601 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5);
2602 gpio_request(RK29_PIN5_PD5,"sdmmc-power");
2603 gpio_direction_output(RK29_PIN5_PD5,GPIO_HIGH); //power-off
2605 rk29_sdmmc_gpio_open(0, 0);
2607 gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW); //power-on
2609 rk29_sdmmc_gpio_open(0, 1);
2613 default: //case 0://SDMMC_CTYPE_1BIT:
2615 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
2616 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
2617 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
2619 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_GPIO1D3);
2620 gpio_request(RK29_PIN1_PD3, "mmc0-data1");
2621 gpio_direction_output(RK29_PIN1_PD3,GPIO_HIGH);
2623 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_GPIO1D4);
2624 gpio_request(RK29_PIN1_PD4, "mmc0-data2");
2625 gpio_direction_output(RK29_PIN1_PD4,GPIO_HIGH);
2627 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_GPIO1D5);
2628 gpio_request(RK29_PIN1_PD5, "mmc0-data3");
2629 gpio_direction_output(RK29_PIN1_PD5,GPIO_HIGH);
2635 static void rk29_sdmmc_set_iomux_mmc1(unsigned int bus_width)
2641 case 1://SDMMC_CTYPE_4BIT:
2643 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2644 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2645 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2646 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2647 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2648 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2652 case 0x10000://SDMMC_CTYPE_8BIT:
2656 rk29_sdmmc_gpio_open(1, 0);
2657 rk29_sdmmc_gpio_open(1, 1);
2661 default: //case 0://SDMMC_CTYPE_1BIT:
2663 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2664 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2665 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2667 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_GPIO1C4);
2668 gpio_request(RK29_PIN1_PC4, "mmc1-data1");
2669 gpio_direction_output(RK29_PIN1_PC4,GPIO_HIGH);
2671 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_GPIO1C5);
2672 gpio_request(RK29_PIN1_PC5, "mmc1-data2");
2673 gpio_direction_output(RK29_PIN1_PC5,GPIO_HIGH);
2675 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_GPIO1C6);
2676 gpio_request(RK29_PIN1_PC6, "mmc1-data3");
2677 gpio_direction_output(RK29_PIN1_PC6,GPIO_HIGH);
2683 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2684 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2685 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2686 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2687 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2688 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2693 static void rk29_sdmmc_set_iomux_mmc2(unsigned int bus_width)
2698 static void rk29_sdmmc_set_iomux(int device_id, unsigned int bus_width)
2703 #ifdef CONFIG_SDMMC0_RK29
2704 rk29_sdmmc_set_iomux_mmc0(bus_width);
2708 #ifdef CONFIG_SDMMC1_RK29
2709 rk29_sdmmc_set_iomux_mmc1(bus_width);
2713 rk29_sdmmc_set_iomux_mmc2(bus_width);
2722 #ifdef CONFIG_WIFI_CONTROL_FUNC
2723 static int rk29sdk_wifi_status(struct device *dev);
2724 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
2727 #ifdef CONFIG_SDMMC0_RK29
2728 static int rk29_sdmmc0_cfg_gpio(void)
2730 #ifdef CONFIG_SDMMC_RK29_OLD
2731 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
2732 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
2733 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
2734 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
2735 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
2736 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
2738 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
2740 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
2741 gpio_request(RK29_PIN5_PD5,"sdmmc");
2743 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
2745 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
2747 gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
2751 rk29_sdmmc_set_iomux(0, 0xFFFF);
2753 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
2755 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
2756 gpio_request(SDMMC0_WRITE_PROTECT_PIN,"sdmmc-wp");
2757 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
2765 #define CONFIG_SDMMC0_USE_DMA
2766 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
2767 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
2768 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
2769 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
2770 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2771 .io_init = rk29_sdmmc0_cfg_gpio,
2773 #if !defined(CONFIG_SDMMC_RK29_OLD)
2774 .set_iomux = rk29_sdmmc_set_iomux,
2777 .dma_name = "sd_mmc",
2778 #ifdef CONFIG_SDMMC0_USE_DMA
2783 .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
2784 .enable_sd_wakeup = 0,
2786 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
2787 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
2789 .write_prt = INVALID_GPIO,
2793 #ifdef CONFIG_SDMMC1_RK29
2794 #define CONFIG_SDMMC1_USE_DMA
2795 static int rk29_sdmmc1_cfg_gpio(void)
2797 #if defined(CONFIG_SDMMC_RK29_OLD)
2798 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2799 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2800 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2801 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2802 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2803 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2804 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
2808 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
2809 gpio_request(SDMMC1_WRITE_PROTECT_PIN,"sdio-wp");
2810 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
2820 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
2822 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
2823 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
2824 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
2825 MMC_VDD_32_33|MMC_VDD_33_34),
2827 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
2828 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
2829 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2831 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2834 .io_init = rk29_sdmmc1_cfg_gpio,
2836 #if !defined(CONFIG_SDMMC_RK29_OLD)
2837 .set_iomux = rk29_sdmmc_set_iomux,
2841 #ifdef CONFIG_SDMMC1_USE_DMA
2847 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
2848 #ifdef CONFIG_WIFI_CONTROL_FUNC
2849 .status = rk29sdk_wifi_status,
2850 .register_status_notify = rk29sdk_wifi_status_register,
2853 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
2856 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
2857 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
2859 .write_prt = INVALID_GPIO,
2863 //for wifi develop board
2864 .detect_irq = INVALID_GPIO,
2865 .enable_sd_wakeup = 0,
2869 #endif ////endif--#ifdef CONFIG_SDMMC1_RK29
2872 int rk29sdk_wifi_power_state = 0;
2873 int rk29sdk_bt_power_state = 0;
2875 #ifdef CONFIG_WIFI_CONTROL_FUNC
2876 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
2877 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
2878 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC7
2880 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
2881 static void (*wifi_status_cb)(int card_present, void *dev_id);
2882 static void *wifi_status_cb_devid;
2884 static int rk29sdk_wifi_status(struct device *dev)
2886 return rk29sdk_wifi_cd;
2889 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
2893 wifi_status_cb = callback;
2894 wifi_status_cb_devid = dev_id;
2898 static int rk29sdk_wifi_bt_gpio_control_init(void)
2900 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
2901 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
2905 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
2906 pr_info("%s: request wifi reset gpio failed\n", __func__);
2907 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
2911 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
2912 pr_info("%s: request bt reset gpio failed\n", __func__);
2913 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
2917 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2918 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2919 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
2921 #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
2923 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_GPIO1C4);
2924 gpio_request(RK29_PIN1_PC4, "mmc1-data1");
2925 gpio_direction_output(RK29_PIN1_PC4,GPIO_LOW);//set mmc1-data1 to low.
2927 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_GPIO1C5);
2928 gpio_request(RK29_PIN1_PC5, "mmc1-data2");
2929 gpio_direction_output(RK29_PIN1_PC5,GPIO_LOW);//set mmc1-data2 to low.
2931 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_GPIO1C6);
2932 gpio_request(RK29_PIN1_PC6, "mmc1-data3");
2933 gpio_direction_output(RK29_PIN1_PC6,GPIO_LOW);//set mmc1-data3 to low.
2935 rk29_sdmmc_gpio_open(1, 0); //added by xbw at 2011-10-13
2937 pr_info("%s: init finished\n",__func__);
2942 static int rk29sdk_wifi_power(int on)
2944 pr_info("%s: %d\n", __func__, on);
2946 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
2948 #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
2949 rk29_sdmmc_gpio_open(1, 1); //added by xbw at 2011-10-13
2952 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
2954 pr_info("wifi turn on power\n");
2956 if (!rk29sdk_bt_power_state){
2957 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2959 #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
2960 rk29_sdmmc_gpio_open(1, 0); //added by xbw at 2011-10-13
2964 pr_info("wifi shut off power\n");
2967 pr_info("wifi shouldn't shut off power, bt is using it!\n");
2969 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2973 rk29sdk_wifi_power_state = on;
2977 static int rk29sdk_wifi_reset_state;
2978 static int rk29sdk_wifi_reset(int on)
2980 pr_info("%s: %d\n", __func__, on);
2981 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
2983 rk29sdk_wifi_reset_state = on;
2987 int rk29sdk_wifi_set_carddetect(int val)
2989 pr_info("%s:%d\n", __func__, val);
2990 rk29sdk_wifi_cd = val;
2991 if (wifi_status_cb){
2992 wifi_status_cb(val, wifi_status_cb_devid);
2994 pr_warning("%s, nobody to notify\n", __func__);
2998 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
3000 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
3001 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
3002 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
3003 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
3004 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
3007 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
3009 if (section == PREALLOC_WLAN_SEC_NUM)
3010 return wlan_static_skb;
3012 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
3015 if (wifi_mem_array[section].size < size)
3018 return wifi_mem_array[section].mem_ptr;
3021 int __init rk29sdk_init_wifi_mem(void)
3026 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
3027 wlan_static_skb[i] = dev_alloc_skb(
3028 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
3030 if (!wlan_static_skb[i])
3034 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
3035 wifi_mem_array[i].mem_ptr =
3036 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
3038 if (!wifi_mem_array[i].mem_ptr)
3044 pr_err("Failed to mem_alloc for WLAN\n");
3045 for (j = 0 ; j < i ; j++)
3046 kfree(wifi_mem_array[j].mem_ptr);
3048 i = WLAN_SKB_BUF_NUM;
3051 pr_err("Failed to skb_alloc for WLAN\n");
3052 for (j = 0 ; j < i ; j++)
3053 dev_kfree_skb(wlan_static_skb[j]);
3058 static struct wifi_platform_data rk29sdk_wifi_control = {
3059 .set_power = rk29sdk_wifi_power,
3060 .set_reset = rk29sdk_wifi_reset,
3061 .set_carddetect = rk29sdk_wifi_set_carddetect,
3062 .mem_prealloc = rk29sdk_mem_prealloc,
3064 static struct platform_device rk29sdk_wifi_device = {
3065 .name = "bcm4329_wlan",
3068 .platform_data = &rk29sdk_wifi_control,
3074 /* bluetooth rfkill device */
3075 static struct platform_device rk29sdk_rfkill = {
3076 .name = "rk29sdk_rfkill",
3081 #ifdef CONFIG_VIVANTE
3082 static struct resource resources_gpu[] = {
3087 .flags = IORESOURCE_IRQ,
3091 .start = RK29_GPU_PHYS,
3092 .end = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
3093 .flags = IORESOURCE_MEM,
3097 .start = PMEM_GPU_BASE,
3098 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
3099 .flags = IORESOURCE_MEM,
3102 static struct platform_device rk29_device_gpu = {
3105 .num_resources = ARRAY_SIZE(resources_gpu),
3106 .resource = resources_gpu,
3109 #ifdef CONFIG_KEYS_RK29
3110 extern struct rk29_keys_platform_data rk29_keys_pdata;
3111 static struct platform_device rk29_device_keys = {
3112 .name = "rk29-keypad",
3115 .platform_data = &rk29_keys_pdata,
3120 #if CONFIG_ANDROID_TIMED_GPIO
3121 static struct timed_gpio timed_gpios[] = {
3124 .gpio = RK29_PIN1_PB5,
3125 .max_timeout = 1000,
3127 .adjust_time =20, //adjust for diff product
3131 struct timed_gpio_platform_data rk29_vibrator_info = {
3133 .gpios = timed_gpios,
3136 struct platform_device rk29_device_vibrator ={
3137 .name = "timed-gpio",
3140 .platform_data = &rk29_vibrator_info,
3146 static void __init rk29_board_iomux_init(void)
3150 #ifdef CONFIG_UART1_RK29
3151 //disable uart1 pull down
3152 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_GPIO2A5);
3153 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_GPIO2A4);
3155 gpio_request(RK29_PIN2_PA5, NULL);
3156 gpio_request(RK29_PIN2_PA4, NULL);
3158 gpio_pull_updown(RK29_PIN2_PA5, PullDisable);
3159 gpio_pull_updown(RK29_PIN2_PA4, PullDisable);
3161 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
3162 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
3164 gpio_free(RK29_PIN2_PA5);
3165 gpio_free(RK29_PIN2_PA4);
3168 #if CONFIG_ANDROID_TIMED_GPIO
3169 rk29_mux_api_set(GPIO1B5_PWM0_NAME, GPIO1L_GPIO1B5);//for timed gpio
3171 #ifdef CONFIG_RK29_PWM_REGULATOR
3172 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
3174 #ifdef CONFIG_RK_HEADSET_DET
3175 rk29_mux_api_set(GPIO3A6_SMCADDR14_HOSTDATA14_NAME,GPIO3L_GPIO3A6);
3178 rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME,GPIO4H_GPIO4C0);
3180 err = gpio_request(RK29_PIN4_PC0, "clk27M_control");
3182 gpio_free(RK29_PIN4_PC0);
3183 printk("-------request RK29_PIN4_PC0 fail--------\n");
3188 #if defined (CONFIG_RK29_WORKING_POWER_MANAGEMENT)
3189 gpio_direction_output(RK29_PIN4_PC0, GPIO_HIGH);
3190 gpio_set_value(RK29_PIN4_PC0, GPIO_HIGH);
3192 gpio_direction_output(RK29_PIN4_PC0, GPIO_LOW);
3193 gpio_set_value(RK29_PIN4_PC0, GPIO_LOW);
3196 rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME,GPIO4H_GPIO4C5);
3198 err = gpio_request(RK29_PIN4_PC5, "clk24M_control");
3200 gpio_free(RK29_PIN4_PC5);
3201 printk("-------request RK29_PIN4_PC5 fail--------\n");
3205 gpio_direction_output(RK29_PIN4_PC5, GPIO_LOW);
3206 gpio_set_value(RK29_PIN4_PC5, GPIO_LOW);
3209 // For phone,just a disk only, add by phc,20110816
3210 #ifdef CONFIG_USB_ANDROID
3211 struct usb_mass_storage_platform_data phone_mass_storage_pdata = {
3213 .vendor = "RockChip",
3214 .product = "rk29 sdk",
3219 struct platform_device phone_usb_mass_storage_device = {
3220 .name = "usb_mass_storage",
3223 .platform_data = &phone_mass_storage_pdata,
3228 #ifdef CONFIG_RK29_CHARGE_EARLYSUSPEND
3230 struct platform_device charge_lowerpower_device = {
3231 .name = "charge_lowerpower",
3236 static struct platform_device *devices[] __initdata = {
3237 #ifdef CONFIG_UART1_RK29
3240 #ifdef CONFIG_UART0_RK29
3243 #ifdef CONFIG_UART2_RK29
3246 #ifdef CONFIG_UART3_RK29
3250 #ifdef CONFIG_RK29_PWM_REGULATOR
3251 &rk29_device_pwm_regulator,
3253 #ifdef CONFIG_SPIM0_RK29
3254 &rk29xx_device_spi0m,
3256 #ifdef CONFIG_SPIM1_RK29
3257 &rk29xx_device_spi1m,
3259 #ifdef CONFIG_ADC_RK29
3262 #ifdef CONFIG_I2C0_RK29
3265 #ifdef CONFIG_I2C1_RK29
3268 #ifdef CONFIG_I2C2_RK29
3271 #ifdef CONFIG_I2C3_RK29
3275 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
3276 &rk29_device_iis_2ch,
3278 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
3279 &rk29_device_iis_8ch,
3282 #ifdef CONFIG_KEYS_RK29
3285 #ifdef CONFIG_SDMMC0_RK29
3286 &rk29_device_sdmmc0,
3288 #ifdef CONFIG_SDMMC1_RK29
3289 &rk29_device_sdmmc1,
3292 #ifdef CONFIG_MTD_NAND_RK29XX
3293 &rk29xx_device_nand,
3296 #ifdef CONFIG_WIFI_CONTROL_FUNC
3297 &rk29sdk_wifi_device,
3304 #if defined(CONFIG_MTK23D)
3305 &rk2818_device_mtk23d,
3308 #ifdef CONFIG_MTD_NAND_RK29
3312 #ifdef CONFIG_FB_RK29
3314 &rk29_device_dma_cpy,
3316 #ifdef CONFIG_BACKLIGHT_RK29_BL
3317 &rk29_device_backlight,
3319 #ifdef CONFIG_RK29_VMAC
3322 #ifdef CONFIG_VIVANTE
3325 #ifdef CONFIG_VIDEO_RK29
3326 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
3327 #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
3328 &rk29_soc_camera_pdrv_0,
3330 &rk29_soc_camera_pdrv_1,
3331 &android_pmem_cam_device,
3333 &android_pmem_device,
3334 &rk29_vpu_mem_device,
3335 #ifdef CONFIG_USB20_OTG
3336 &rk29_device_usb20_otg,
3338 #ifdef CONFIG_USB20_HOST
3339 &rk29_device_usb20_host,
3341 #ifdef CONFIG_USB11_HOST
3342 &rk29_device_usb11_host,
3344 #ifdef CONFIG_USB_ANDROID
3345 &android_usb_device,
3346 &phone_usb_mass_storage_device,
3348 #ifdef CONFIG_RK29_IPP
3351 #ifdef CONFIG_VIDEO_RK29XX_VOUT
3352 &rk29_v4l2_output_devce,
3354 #ifdef CONFIG_RK_HEADSET_DET
3357 #ifdef CONFIG_RK29_GPS
3360 #ifdef CONFIG_ANDROID_TIMED_GPIO
3361 &rk29_device_vibrator,
3365 #ifdef CONFIG_RK29_VMAC
3366 /*****************************************************************************************
3368 * author: lyx@rock-chips.com
3369 *****************************************************************************************/
3370 static int rk29_vmac_register_set(void)
3372 //config rk29 vmac as rmii, 100MHz
3373 u32 value= readl(RK29_GRF_BASE + 0xbc);
3374 value = (value & 0xfff7ff) | (0x400);
3375 writel(value, RK29_GRF_BASE + 0xbc);
3379 static int rk29_rmii_io_init(void)
3384 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
3386 gpio_free(RK29_PIN6_PB0);
3387 printk("-------request RK29_PIN6_PB0 fail--------\n");
3391 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
3392 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
3397 static int rk29_rmii_io_deinit(void)
3400 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
3401 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
3403 gpio_free(RK29_PIN6_PB0);
3407 static int rk29_rmii_power_control(int enable)
3411 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
3412 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
3415 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
3416 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
3421 struct rk29_vmac_platform_data rk29_vmac_pdata = {
3422 .vmac_register_set = rk29_vmac_register_set,
3423 .rmii_io_init = rk29_rmii_io_init,
3424 .rmii_io_deinit = rk29_rmii_io_deinit,
3425 .rmii_power_control = rk29_rmii_power_control,
3429 /*****************************************************************************************
3431 * author: cmc@rock-chips.com
3432 *****************************************************************************************/
3433 #define SPI_CHIPSELECT_NUM 2
3434 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
3437 .cs_gpio = RK29_PIN2_PC1,
3438 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
3439 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
3443 .cs_gpio = RK29_PIN1_PA4,
3444 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
3445 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
3449 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
3452 .cs_gpio = RK29_PIN2_PC5,
3453 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
3454 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
3458 .cs_gpio = RK29_PIN1_PA3,
3459 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
3460 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
3464 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
3469 for (i=0; i<cs_num; i++) {
3470 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
3477 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
3482 static int spi_io_fix_leakage_bug(void)
3485 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
3490 static int spi_io_resume_leakage_bug(void)
3493 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
3498 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
3499 .num_chipselect = SPI_CHIPSELECT_NUM,
3500 .chipselect_gpios = rk29xx_spi0_cs_gpios,
3501 .io_init = spi_io_init,
3502 .io_deinit = spi_io_deinit,
3503 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
3504 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
3507 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
3508 .num_chipselect = SPI_CHIPSELECT_NUM,
3509 .chipselect_gpios = rk29xx_spi1_cs_gpios,
3510 .io_init = spi_io_init,
3511 .io_deinit = spi_io_deinit,
3512 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
3513 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
3517 /*****************************************************************************************
3518 * xpt2046 touch panel
3519 * author: hhb@rock-chips.com
3520 *****************************************************************************************/
3521 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
3522 #define XPT2046_GPIO_INT RK29_PIN4_PD5 //ä¸æ–???#define DEBOUNCE_REPTIME 3
3524 static struct xpt2046_platform_data xpt2046_info = {
3529 .debounce_rep = DEBOUNCE_REPTIME,
3531 .gpio_pendown = XPT2046_GPIO_INT,
3532 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
3533 .pendown_iomux_mode = GPIO4H_GPIO4D5,
3534 .touch_virtualkey_length = 60,
3535 .penirq_recheck_delay_usecs = 1,
3536 #if defined(CONFIG_TOUCHSCREEN_480X800)
3541 .touch_ad_top = 3940,
3542 .touch_ad_bottom = 310,
3543 .touch_ad_left = 3772,
3544 .touch_ad_right = 340,
3545 #elif defined(CONFIG_TOUCHSCREEN_800X480)
3550 .touch_ad_top = 2447,
3551 .touch_ad_bottom = 207,
3552 .touch_ad_left = 5938,
3553 .touch_ad_right = 153,
3554 #elif defined(CONFIG_TOUCHSCREEN_320X480)
3559 .touch_ad_top = 3166,
3560 .touch_ad_bottom = 256,
3561 .touch_ad_left = 3658,
3562 .touch_ad_right = 380,
3565 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
3566 static struct xpt2046_platform_data xpt2046_info = {
3571 .debounce_rep = DEBOUNCE_REPTIME,
3573 .gpio_pendown = XPT2046_GPIO_INT,
3574 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
3575 .pendown_iomux_mode = GPIO4H_GPIO4D5,
3576 .touch_virtualkey_length = 60,
3577 .penirq_recheck_delay_usecs = 1,
3579 #if defined(CONFIG_TOUCHSCREEN_480X800)
3584 .screen_x = { 70, 410, 70, 410, 240},
3585 .screen_y = { 50, 50, 740, 740, 400},
3586 .uncali_x_default = { 3267, 831, 3139, 715, 1845 },
3587 .uncali_y_default = { 3638, 3664, 564, 591, 2087 },
3588 #elif defined(CONFIG_TOUCHSCREEN_800X480)
3593 .screen_x[5] = { 50, 750, 50, 750, 400};
3594 .screen_y[5] = { 40, 40, 440, 440, 240};
3595 .uncali_x_default[5] = { 438, 565, 3507, 3631, 2105 };
3596 .uncali_y_default[5] = { 3756, 489, 3792, 534, 2159 };
3597 #elif defined(CONFIG_TOUCHSCREEN_320X480)
3602 .screen_x[5] = { 50, 270, 50, 270, 160};
3603 .screen_y[5] = { 40, 40, 440, 440, 240};
3604 .uncali_x_default[5] = { 812, 3341, 851, 3371, 2183 };
3605 .uncali_y_default[5] = { 442, 435, 3193, 3195, 2004 };
3610 static struct spi_board_info board_spi_devices[] = {
3611 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
3613 .modalias = "xpt2046_ts",
3614 .chip_select = 0,// 2,
3615 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
3617 .irq = XPT2046_GPIO_INT,
3618 .platform_data = &xpt2046_info,
3622 #if defined(CONFIG_MFD_WM831X_SPI)
3624 .modalias = "wm8310",
3626 .max_speed_hz = 2*1000*1000,
3628 .irq = RK29_PIN4_PD0,
3629 .platform_data = &wm831x_platdata,
3636 /**********************************************************************************************
3638 * The virtual keys for android "back", "home", "menu", "search", these four keys are touch key
3639 * on the touch screen panel. (added by hhb@rock-chips.com 2011.03.31)
3641 ***********************************************************************************************/
3642 static ssize_t rk29xx_virtual_keys_show(struct kobject *kobj,
3643 struct kobj_attribute *attr, char *buf)
3645 #if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
3646 || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC) \
3647 || defined (CONFIG_TOUCHSCREEN_GT801_Z5)
3648 /* center: x: home: 50, menu: 184, back: 315, search 435, y: 830*/
3649 /* centerx;centery;width;height; */
3651 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":300:860:120:60"//":315:815:120:50" //":50:830:98:50" //":210:796:98:50"
3652 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":60:860:120:60"//":85:815:88:50" // ":184:830:120:50" // ":435:796:120:50"
3653 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":180:860:120:60"//":184:815:100:50" //":315:830:100:50" //":320:796:100:50"
3654 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:860:120:60"//":435:815:88:50" //":50:815:98:50" // //":85:796:88:50"
3657 #elif defined (CONFIG_TOUCHSCREEN_FT5306)
3659 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":400:830:120:60"//":315:815:120:50" //":50:830:98:50" //":210:796:98:50"
3660 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":80:830:120:60"//":85:815:88:50" // ":184:830:120:50" // ":435:796:120:50"
3661 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":240:830:120:60"//":184:815:100:50" //":315:830:100:50" //":320:796:100:50"
3667 static struct kobj_attribute rk29xx_virtual_keys_attr = {
3669 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
3670 .name = "virtualkeys.xpt2046-touchscreen",
3671 #elif defined(CONFIG_TOUCHSCREEN_HX8520_IIC)
3672 .name = "virtualkeys.hx8520-touchscreen",
3673 #elif defined(CONFIG_TOUCHSCREEN_GT801_IIC) || defined (CONFIG_TOUCHSCREEN_GT801_Z5)
3674 .name = "virtualkeys.gt801-touchscreen",
3675 #elif defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
3676 .name = "virtualkeys.ili2102-touchscreen",
3677 #elif defined (CONFIG_TOUCHSCREEN_FT5306)
3678 .name = "virtualkeys.ft5x0x_ts-touchscreen",
3680 .name = "virtualkeys",
3684 .show = &rk29xx_virtual_keys_show,
3687 static struct attribute *rk29xx_properties_attrs[] = {
3688 &rk29xx_virtual_keys_attr.attr,
3692 static struct attribute_group rk29xx_properties_attr_group = {
3693 .attrs = rk29xx_properties_attrs,
3695 static int rk29xx_virtual_keys_init(void)
3698 struct kobject *properties_kobj;
3699 printk("rk29xx_virtual_keys_init \n");
3700 properties_kobj = kobject_create_and_add("board_properties", NULL);
3701 if (properties_kobj)
3702 ret = sysfs_create_group(properties_kobj,
3703 &rk29xx_properties_attr_group);
3704 if (!properties_kobj || ret)
3706 pr_err("failed to create board_properties\n");
3712 static void __init rk29_gic_init_irq(void)
3714 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38))
3715 gic_init(0, 32, (void __iomem *)RK29_GICPERI_BASE, (void __iomem *)RK29_GICCPU_BASE);
3717 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
3718 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
3722 static void __init machine_rk29_init_irq(void)
3724 rk29_gic_init_irq();
3728 #define POWER_ON_PIN RK29_PIN4_PA4
3730 static void rk29_pm_power_restart(void)
3732 printk("%s,line=%d\n",__FUNCTION__,__LINE__);
3734 #if defined(CONFIG_MFD_WM831X)
3735 wm831x_device_restart(gWm831x);
3740 static void rk29_pm_power_off(void)
3742 printk(KERN_ERR "rk29_pm_power_off start...\n");
3743 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
3744 #if defined(CONFIG_MFD_WM831X)
3745 if(wm831x_read_usb(gWm831x))
3746 rk29_pm_power_restart(); //if charging then restart
3748 wm831x_device_shutdown(gWm831x);//else shutdown
3754 static struct cpufreq_frequency_table freq_table[] =
3756 { .index = 1100000, .frequency = 408000 },
3757 { .index = 1150000, .frequency = 600000 },
3758 { .index = 1200000, .frequency = 816000 },
3759 { .index = 1300000, .frequency = 1008000 },
3760 { .frequency = CPUFREQ_TABLE_END },
3763 static void __init machine_rk29_board_init(void)
3765 rk29_board_iomux_init();
3767 gpio_request(POWER_ON_PIN,"poweronpin");
3768 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
3769 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
3770 pm_power_off = rk29_pm_power_off;
3771 //arm_pm_restart = rk29_pm_power_restart;
3773 board_update_cpufreq_table(freq_table);
3775 platform_add_devices(devices, ARRAY_SIZE(devices));
3776 #ifdef CONFIG_I2C0_RK29
3777 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
3778 ARRAY_SIZE(board_i2c0_devices));
3780 #ifdef CONFIG_I2C1_RK29
3781 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
3782 ARRAY_SIZE(board_i2c1_devices));
3784 #ifdef CONFIG_I2C2_RK29
3785 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
3786 ARRAY_SIZE(board_i2c2_devices));
3788 #ifdef CONFIG_I2C3_RK29
3789 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
3790 ARRAY_SIZE(board_i2c3_devices));
3793 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
3795 #ifdef CONFIG_WIFI_CONTROL_FUNC
3796 rk29sdk_wifi_bt_gpio_control_init();
3797 rk29sdk_init_wifi_mem();
3800 #if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
3801 || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC) \
3802 || defined (CONFIG_TOUCHSCREEN_GT801_Z5) || defined (CONFIG_TOUCHSCREEN_FT5306)
3803 rk29xx_virtual_keys_init();
3808 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
3809 char **cmdline, struct meminfo *mi)
3812 mi->bank[0].start = RK29_SDRAM_PHYS;
3813 mi->bank[0].size = LINUX_SIZE;
3814 #if SDRAM_SIZE > SZ_512M
3816 mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
3817 mi->bank[1].size = SDRAM_SIZE - SZ_512M;
3821 static void __init machine_rk29_mapio(void)
3823 rk29_map_common_io();
3824 rk29_setup_early_printk();
3826 rk29_clock_init2(periph_pll_96mhz, codec_pll_300mhz, false);
3828 ddr_init(DDR_TYPE, DDR_FREQ);
3831 MACHINE_START(RK29, "RK29board")
3832 /* UART for LL DEBUG */
3833 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37))
3834 /* UART for LL DEBUG */
3835 .phys_io = RK29_UART1_PHYS & 0xfff00000,
3836 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
3838 .boot_params = RK29_SDRAM_PHYS + 0x88000,
3839 .fixup = machine_rk29_fixup,
3840 .map_io = machine_rk29_mapio,
3841 .init_irq = machine_rk29_init_irq,
3842 .init_machine = machine_rk29_board_init,
3843 .timer = &rk29_timer,