1 /* arch/arm/mach-rk29/board-rk29.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>
48 #include <mach/rk29_smc.h>
50 #include <linux/regulator/rk29-pwm-regulator.h>
51 #include <linux/regulator/machine.h>
53 #include <linux/regulator/act8891.h>
55 #include <linux/mtd/nand.h>
56 #include <linux/mtd/partitions.h>
57 #include <linux/i2c-gpio.h>
60 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
62 #ifdef CONFIG_BU92747GUW_CIR
63 #include "../../../drivers/cir/bu92747guw_cir.h"
65 #ifdef CONFIG_VIDEO_RK29
66 /*---------------- Camera Sensor Macro Define Begin ------------------------*/
67 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
68 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642 /* back camera sensor */
69 #define CONFIG_SENSOR_IIC_ADDR_0 0x78
70 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0 1
71 #define CONFIG_SENSOR_POWER_PIN_0 INVALID_GPIO
72 #define CONFIG_SENSOR_RESET_PIN_0 INVALID_GPIO
73 #define CONFIG_SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
74 #define CONFIG_SENSOR_FALSH_PIN_0 INVALID_GPIO
75 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
76 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
77 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
78 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
80 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659 /* front camera sensor */
81 #define CONFIG_SENSOR_IIC_ADDR_1 0x60
82 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1 1
83 #define CONFIG_SENSOR_POWER_PIN_1 INVALID_GPIO
84 #define CONFIG_SENSOR_RESET_PIN_1 INVALID_GPIO
85 #define CONFIG_SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
86 #define CONFIG_SENSOR_FALSH_PIN_1 INVALID_GPIO
87 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
88 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
89 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
90 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
91 #endif //#ifdef CONFIG_VIDEO_RK29
92 /*---------------- Camera Sensor Configuration Macro End------------------------*/
93 #include "../../../drivers/media/video/rk29_camera.c"
94 /*---------------- Camera Sensor Macro Define End ------------------------*/
97 /* Set memory size of pmem */
98 #ifdef CONFIG_RK29_MEM_SIZE_M
99 #define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
101 #define SDRAM_SIZE SZ_512M
103 #define PMEM_GPU_SIZE SZ_16M
104 #define PMEM_UI_SIZE (48 * SZ_1M) /* 1280x800: 64M 1024x768: 48M ... */
105 #define PMEM_VPU_SIZE SZ_64M
106 #define PMEM_SKYPE_SIZE 0
107 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
108 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
109 #define MEM_CAMIPP_SIZE SZ_4M
111 #define MEM_CAMIPP_SIZE 0
113 #define MEM_FB_SIZE (9*SZ_1M)
114 #ifdef CONFIG_FB_WORK_IPP
115 #define MEM_FBIPP_SIZE SZ_8M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4
117 #define MEM_FBIPP_SIZE 0
119 #if SDRAM_SIZE > SZ_512M
120 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
122 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
124 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
125 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
126 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
127 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
128 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
129 #define MEM_FBIPP_BASE (MEM_FB_BASE - MEM_FBIPP_SIZE)
130 #define PMEM_SKYPE_BASE (MEM_FBIPP_BASE - PMEM_SKYPE_SIZE)
131 #define LINUX_SIZE (PMEM_SKYPE_BASE - RK29_SDRAM_PHYS)
133 #define PREALLOC_WLAN_SEC_NUM 4
134 #define PREALLOC_WLAN_BUF_NUM 160
135 #define PREALLOC_WLAN_SECTION_HEADER 24
137 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
138 #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
139 #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
140 #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
142 #define WLAN_SKB_BUF_NUM 16
144 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
146 struct wifi_mem_prealloc {
151 extern struct sys_timer rk29_timer;
153 static int rk29_nand_io_init(void)
158 struct rk29_nand_platform_data rk29_nand_data = {
159 .width = 1, /* data bus width in bytes */
160 .hw_ecc = 1, /* hw ecc 0: soft ecc */
162 .io_init = rk29_nand_io_init,
165 #define TOUCH_SCREEN_STANDBY_PIN RK29_PIN6_PD1
166 #define TOUCH_SCREEN_STANDBY_VALUE GPIO_HIGH
167 #define TOUCH_SCREEN_DISPLAY_PIN INVALID_GPIO
168 #define TOUCH_SCREEN_DISPLAY_VALUE GPIO_HIGH
170 #ifdef CONFIG_FB_RK29
171 /*****************************************************************************************
173 * author: zyw@rock-chips.com
174 *****************************************************************************************/
175 //#ifdef CONFIG_LCD_TD043MGEA1
176 #define LCD_TXD_PIN INVALID_GPIO
177 #define LCD_CLK_PIN INVALID_GPIO
178 #define LCD_CS_PIN INVALID_GPIO
179 /*****************************************************************************************
180 * frame buffe devices
181 * author: zyw@rock-chips.com
182 *****************************************************************************************/
184 #define FB_DISPLAY_ON_PIN INVALID_GPIO// RK29_PIN6_PD0
185 #define FB_LCD_STANDBY_PIN INVALID_GPIO
186 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
187 #define FB_MCU_FMK_PIN INVALID_GPIO
189 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
190 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
192 static int rk29_lcd_io_init(void)
198 static int rk29_lcd_io_deinit(void)
204 static struct rk29lcd_info rk29_lcd_info = {
205 .txd_pin = LCD_TXD_PIN,
206 .clk_pin = LCD_CLK_PIN,
207 .cs_pin = LCD_CS_PIN,
208 .io_init = rk29_lcd_io_init,
209 .io_deinit = rk29_lcd_io_deinit,
212 int rk29_fb_io_enable(void)
214 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
216 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
217 gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);
219 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
221 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
222 gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);
227 int rk29_fb_io_disable(void)
229 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
231 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
232 gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);
234 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
236 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
237 gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);
242 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
245 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
247 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
250 gpio_free(FB_MCU_FMK_PIN);
251 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
253 gpio_direction_input(FB_MCU_FMK_PIN);
255 if(fb_setting->disp_on_en)
257 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
259 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
262 gpio_free(FB_DISPLAY_ON_PIN);
263 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
266 else if (TOUCH_SCREEN_DISPLAY_PIN != INVALID_GPIO)
268 ret = gpio_request(TOUCH_SCREEN_DISPLAY_PIN, NULL);
271 gpio_free(TOUCH_SCREEN_DISPLAY_PIN);
272 printk(">>>>>> TOUCH_SCREEN_DISPLAY_PIN gpio_request err \n ");
274 gpio_direction_output(TOUCH_SCREEN_DISPLAY_PIN, 0);
275 gpio_set_value(TOUCH_SCREEN_DISPLAY_PIN, TOUCH_SCREEN_DISPLAY_VALUE);
279 if(fb_setting->disp_on_en)
281 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
283 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
286 gpio_free(FB_LCD_STANDBY_PIN);
287 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
290 else if (TOUCH_SCREEN_STANDBY_PIN != INVALID_GPIO)
292 ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL);
295 gpio_free(TOUCH_SCREEN_STANDBY_PIN);
296 printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n ");
298 gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0);
299 gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE);
303 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
305 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
308 gpio_free(FB_LCD_CABC_EN_PIN);
309 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
311 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
312 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
315 rk29_fb_io_enable(); //enable it
321 static struct rk29fb_info rk29_fb_info = {
323 .mcu_fmk_pin = FB_MCU_FMK_PIN,
324 .lcd_info = &rk29_lcd_info,
325 .io_init = rk29_fb_io_init,
326 .io_enable = rk29_fb_io_enable,
327 .io_disable = rk29_fb_io_disable,
330 /* rk29 fb resource */
331 static struct resource rk29_fb_resource[] = {
334 .start = RK29_LCDC_PHYS,
335 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
336 .flags = IORESOURCE_MEM,
342 .flags = IORESOURCE_IRQ,
346 .start = MEM_FB_BASE,
347 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
348 .flags = IORESOURCE_MEM,
350 #ifdef CONFIG_FB_WORK_IPP
352 .name = "win1 ipp buf",
353 .start = MEM_FBIPP_BASE,
354 .end = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
355 .flags = IORESOURCE_MEM,
361 struct platform_device rk29_device_fb = {
364 .num_resources = ARRAY_SIZE(rk29_fb_resource),
365 .resource = rk29_fb_resource,
367 .platform_data = &rk29_fb_info,
371 struct platform_device rk29_device_dma_cpy = {
372 .name = "dma_memcpy",
379 #if defined(CONFIG_RK29_GPIO_SUSPEND)
380 void key_gpio_pullupdown_enable(void)
381 { gpio_pull_updown(RK29_PIN6_PA0, 0);
382 gpio_pull_updown(RK29_PIN6_PA1, 0);
383 gpio_pull_updown(RK29_PIN6_PA2, 0);
384 gpio_pull_updown(RK29_PIN6_PA3, 0);
385 gpio_pull_updown(RK29_PIN6_PA4, 0);
386 gpio_pull_updown(RK29_PIN6_PA5, 0);
387 gpio_pull_updown(RK29_PIN6_PA6, 0);
390 void key_gpio_pullupdown_disable(void)
392 gpio_pull_updown(RK29_PIN6_PA0, 1);
393 gpio_pull_updown(RK29_PIN6_PA1, 1);
394 gpio_pull_updown(RK29_PIN6_PA2, 1);
395 gpio_pull_updown(RK29_PIN6_PA3, 1);
396 gpio_pull_updown(RK29_PIN6_PA4, 1);
397 gpio_pull_updown(RK29_PIN6_PA5, 1);
398 gpio_pull_updown(RK29_PIN6_PA6, 1);
400 void rk29_setgpio_suspend_board(void)
403 key_gpio_pullupdown_enable();
407 void rk29_setgpio_resume_board(void)
410 key_gpio_pullupdown_disable();
414 void rk29_setgpio_suspend_board(void)
416 void rk29_setgpio_resume_board(void)
420 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
421 #define BU92747GUW_RESET_PIN RK29_PIN3_PD4// INVALID_GPIO //
422 #define BU92747GUW_RESET_MUX_NAME GPIO3D4_HOSTWRN_NAME//NULL //
423 #define BU92747GUW_RESET_MUX_MODE GPIO3H_GPIO3D4//NULL //
425 #define BU92747GUW_PWDN_PIN RK29_PIN3_PD3//RK29_PIN5_PA7 //
426 #define BU92747GUW_PWDN_MUX_NAME GPIO3D3_HOSTRDN_NAME//GPIO5A7_HSADCDATA2_NAME //
427 #define BU92747GUW_PWDN_MUX_MODE GPIO3H_GPIO3D3//GPIO5L_GPIO5A7 //
429 static int bu92747guw_io_init(void)
434 if(BU92747GUW_RESET_MUX_NAME != NULL)
436 rk29_mux_api_set(BU92747GUW_RESET_MUX_NAME, BU92747GUW_RESET_MUX_MODE);
438 ret = gpio_request(BU92747GUW_RESET_PIN, NULL);
441 gpio_free(BU92747GUW_RESET_PIN);
442 printk(">>>>>> BU92747GUW_RESET_PIN gpio_request err \n ");
444 gpio_direction_output(BU92747GUW_RESET_PIN, GPIO_HIGH);
447 if(BU92747GUW_PWDN_MUX_NAME != NULL)
449 rk29_mux_api_set(BU92747GUW_PWDN_MUX_NAME, BU92747GUW_PWDN_MUX_MODE);
451 ret = gpio_request(BU92747GUW_PWDN_PIN, NULL);
454 gpio_free(BU92747GUW_PWDN_PIN);
455 printk(">>>>>> BU92747GUW_PWDN_PIN gpio_request err \n ");
458 //power down as default
459 gpio_direction_output(BU92747GUW_PWDN_PIN, GPIO_LOW);
465 static int bu92747guw_io_deinit(void)
467 gpio_free(BU92747GUW_PWDN_PIN);
468 gpio_free(BU92747GUW_RESET_PIN);
472 //power ctl func is share with irda and remote
473 static int nPowerOnCount = 0;
474 static DEFINE_MUTEX(bu92747_power_mutex);
476 //1---power on; 0---power off
477 static int bu92747guw_power_ctl(int enable)
479 printk("%s \n",__FUNCTION__);
481 mutex_lock(&bu92747_power_mutex);
484 if (nPowerOnCount == 1) {//power on first
486 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_HIGH);
487 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_LOW);
489 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_HIGH);
495 if (nPowerOnCount <= 0) {//power down final
498 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_LOW);
501 mutex_unlock(&bu92747_power_mutex);
506 #ifdef CONFIG_RK_IRDA
507 #define IRDA_IRQ_PIN RK29_PIN5_PB2
508 #define IRDA_IRQ_MUX_NAME GPIO5B2_HSADCDATA5_NAME
509 #define IRDA_IRQ_MUX_MODE GPIO5L_GPIO5B2
511 int irda_iomux_init(void)
516 if(IRDA_IRQ_MUX_NAME != NULL)
518 rk29_mux_api_set(IRDA_IRQ_MUX_NAME, IRDA_IRQ_MUX_MODE);
520 ret = gpio_request(IRDA_IRQ_PIN, NULL);
523 gpio_free(IRDA_IRQ_PIN);
524 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
526 gpio_pull_updown(IRDA_IRQ_PIN, GPIO_HIGH);
527 gpio_direction_input(IRDA_IRQ_PIN);
532 int irda_iomux_deinit(void)
534 gpio_free(IRDA_IRQ_PIN);
538 static struct irda_info rk29_irda_info = {
539 .intr_pin = IRDA_IRQ_PIN,
540 .iomux_init = irda_iomux_init,
541 .iomux_deinit = irda_iomux_deinit,
542 .irda_pwr_ctl = bu92747guw_power_ctl,
545 static struct platform_device irda_device = {
546 #ifdef CONFIG_RK_IRDA_NET
549 .name = "bu92747_irda",
553 .platform_data = &rk29_irda_info,
558 #ifdef CONFIG_BU92747GUW_CIR
559 #define BU92747_CIR_IRQ_PIN RK29_PIN5_PB0
560 #define CIR_IRQ_PIN_IOMUX_NAME GPIO5B0_HSADCDATA3_NAME
561 #define CIR_IRQ_PIN_IOMUX_VALUE GPIO5L_GPIO5B0
562 static int cir_iomux_init(void)
564 if (CIR_IRQ_PIN_IOMUX_NAME)
565 rk29_mux_api_set(CIR_IRQ_PIN_IOMUX_NAME, CIR_IRQ_PIN_IOMUX_VALUE);
566 rk29_mux_api_set(GPIO5A7_HSADCDATA2_NAME, GPIO5L_GPIO5A7);
570 static struct bu92747guw_platform_data bu92747guw_pdata = {
571 .intr_pin = BU92747_CIR_IRQ_PIN,
572 .iomux_init = cir_iomux_init,
573 .iomux_deinit = NULL,
574 .cir_pwr_ctl = bu92747guw_power_ctl,
577 #ifdef CONFIG_RK29_NEWTON
578 struct rk29_newton_data rk29_newton_info = {
580 struct platform_device rk29_device_newton = {
581 .name = "rk29_newton",
584 .platform_data = &rk29_newton_info,
588 #if defined (CONFIG_TOUCHSCREEN_FT5406)
589 #define TOUCH_RESET_PIN RK29_PIN6_PC3
590 #define TOUCH_INT_PIN RK29_PIN0_PA2
591 int ft5406_init_platform_hw(void)
593 printk("ft5406_init_platform_hw\n");
594 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
595 gpio_free(TOUCH_RESET_PIN);
596 printk("ft5406_init_platform_hw gpio_request error\n");
600 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
601 gpio_free(TOUCH_INT_PIN);
602 printk("ift5406_init_platform_hw gpio_request error\n");
606 gpio_direction_output(TOUCH_RESET_PIN, 0);
607 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
609 gpio_direction_input(TOUCH_INT_PIN);
611 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
616 void ft5406_exit_platform_hw(void)
618 printk("ft5406_exit_platform_hw\n");
619 gpio_free(TOUCH_RESET_PIN);
620 gpio_free(TOUCH_INT_PIN);
623 int ft5406_platform_sleep(void)
625 printk("ft5406_platform_sleep\n");
626 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
630 int ft5406_platform_wakeup(void)
632 printk("ft5406_platform_wakeup\n");
633 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
638 struct ft5406_platform_data ft5406_info = {
640 .init_platform_hw= ft5406_init_platform_hw,
641 .exit_platform_hw= ft5406_exit_platform_hw,
642 .platform_sleep = ft5406_platform_sleep,
643 .platform_wakeup = ft5406_platform_wakeup,
648 #if defined(CONFIG_TOUCHSCREEN_GT819)
649 #define TOUCH_RESET_PIN RK29_PIN6_PC3
650 #define TOUCH_INT_PIN RK29_PIN0_PA2
651 int gt819_init_platform_hw(void)
653 printk("gt819_init_platform_hw\n");
654 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
655 gpio_free(TOUCH_RESET_PIN);
656 printk("gt819_init_platform_hw gpio_request error\n");
660 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
661 gpio_free(TOUCH_INT_PIN);
662 printk("gt819_init_platform_hw gpio_request error\n");
665 gpio_direction_output(TOUCH_RESET_PIN, 0);
666 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
668 // gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
670 // gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
671 gpio_direction_input(TOUCH_INT_PIN);
673 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
679 void gt819_exit_platform_hw(void)
681 printk("gt819_exit_platform_hw\n");
682 gpio_free(TOUCH_RESET_PIN);
683 gpio_free(TOUCH_INT_PIN);
686 int gt819_platform_sleep(void)
688 printk("gt819_platform_sleep\n");
689 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
693 int gt819_platform_wakeup(void)
695 printk("gt819_platform_wakeup\n");
696 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
698 //gpio_set_value(TOUCH_INT_PIN, GPIO_LOW);
700 //gpio_set_value(TOUCH_INT_PIN, GPIO_HIGH);
703 struct goodix_platform_data goodix_info = {
705 .init_platform_hw= gt819_init_platform_hw,
706 .exit_platform_hw= gt819_exit_platform_hw,
707 .platform_sleep = gt819_platform_sleep,
708 .platform_wakeup = gt819_platform_wakeup,
714 #if defined (CONFIG_SND_SOC_CS42L52)
716 int cs42l52_init_platform_hw()
718 printk("cs42l52_init_platform_hw\n");
719 if(gpio_request(RK29_PIN6_PB6,NULL) != 0){
720 gpio_free(RK29_PIN6_PB6);
721 printk("cs42l52_init_platform_hw gpio_request error\n");
724 gpio_direction_output(RK29_PIN6_PB6, 0);
725 gpio_set_value(RK29_PIN6_PB6,GPIO_HIGH);
728 struct cs42l52_platform_data cs42l52_info = {
730 .init_platform_hw= cs42l52_init_platform_hw,
734 #if defined (CONFIG_BATTERY_BQ27541)
735 #define DC_CHECK_PIN RK29_PIN4_PA1
736 #define LI_LION_BAT_NUM 1
737 #define CHG_OK RK29_PIN4_PA3
738 #define BAT_LOW RK29_PIN4_PA2
740 static int bq27541_init_dc_check_pin(void){
741 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
742 gpio_free(DC_CHECK_PIN);
743 printk("bq27541 init dc check pin request error\n");
746 gpio_direction_input(DC_CHECK_PIN);
750 struct bq27541_platform_data bq27541_info = {
751 .init_dc_check_pin = bq27541_init_dc_check_pin,
752 .dc_check_pin = DC_CHECK_PIN,
753 .bat_num = LI_LION_BAT_NUM,
754 .chgok_check_pin = CHG_OK,
755 .bat_check_pin = BAT_LOW,
758 static struct android_pmem_platform_data android_pmem_pdata = {
760 .start = PMEM_UI_BASE,
761 .size = PMEM_UI_SIZE,
766 static struct platform_device android_pmem_device = {
767 .name = "android_pmem",
770 .platform_data = &android_pmem_pdata,
775 static struct vpu_mem_platform_data vpu_mem_pdata = {
777 .start = PMEM_VPU_BASE,
778 .size = PMEM_VPU_SIZE,
782 static struct platform_device rk29_vpu_mem_device = {
786 .platform_data = &vpu_mem_pdata,
790 #if PMEM_SKYPE_SIZE > 0
791 static struct android_pmem_platform_data android_pmem_skype_pdata = {
792 .name = "pmem_skype",
793 .start = PMEM_SKYPE_BASE,
794 .size = PMEM_SKYPE_SIZE,
799 static struct platform_device android_pmem_skype_device = {
800 .name = "android_pmem",
803 .platform_data = &android_pmem_skype_pdata,
808 #ifdef CONFIG_VIDEO_RK29XX_VOUT
809 static struct platform_device rk29_v4l2_output_devce = {
813 /*HANNSTAR_P1003 touch*/
814 #if defined (CONFIG_HANNSTAR_P1003)
815 #define TOUCH_RESET_PIN RK29_PIN6_PC3
816 #define TOUCH_INT_PIN RK29_PIN0_PA2
818 int p1003_init_platform_hw(void)
820 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
821 gpio_free(TOUCH_RESET_PIN);
822 printk("p1003_init_platform_hw gpio_request error\n");
826 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
827 gpio_free(TOUCH_INT_PIN);
828 printk("p1003_init_platform_hw gpio_request error\n");
831 gpio_pull_updown(TOUCH_INT_PIN, 1);
832 gpio_direction_output(TOUCH_RESET_PIN, 0);
834 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
836 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
842 struct p1003_platform_data p1003_info = {
844 .init_platform_hw= p1003_init_platform_hw,
848 #if defined (CONFIG_EETI_EGALAX)
849 #define TOUCH_RESET_PIN RK29_PIN6_PC3
850 #define TOUCH_INT_PIN RK29_PIN0_PA2
852 static int EETI_EGALAX_init_platform_hw(void)
854 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
855 gpio_free(TOUCH_RESET_PIN);
856 printk("p1003_init_platform_hw gpio_request error\n");
860 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
861 gpio_free(TOUCH_INT_PIN);
862 printk("p1003_init_platform_hw gpio_request error\n");
865 gpio_pull_updown(TOUCH_INT_PIN, 1);
866 gpio_direction_output(TOUCH_RESET_PIN, 0);
868 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
870 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
876 static struct eeti_egalax_platform_data eeti_egalax_info = {
878 .init_platform_hw= EETI_EGALAX_init_platform_hw,
879 .standby_pin = TOUCH_SCREEN_STANDBY_PIN,
880 .standby_value = TOUCH_SCREEN_STANDBY_VALUE,
881 .disp_on_pin = TOUCH_SCREEN_DISPLAY_PIN,
882 .disp_on_value = TOUCH_SCREEN_DISPLAY_VALUE,
886 #ifdef CONFIG_GS_KXTF9
887 #include <linux/kxtf9.h>
888 #define KXTF9_DEVICE_MAP 1
889 #define KXTF9_MAP_X (KXTF9_DEVICE_MAP-1)%2
890 #define KXTF9_MAP_Y KXTF9_DEVICE_MAP%2
891 #define KXTF9_NEG_X (KXTF9_DEVICE_MAP/2)%2
892 #define KXTF9_NEG_Y (KXTF9_DEVICE_MAP+1)/4
893 #define KXTF9_NEG_Z (KXTF9_DEVICE_MAP-1)/4
894 struct kxtf9_platform_data kxtf9_pdata = {
897 .g_range = KXTF9_G_2G,
898 .axis_map_x = KXTF9_MAP_X,
899 .axis_map_y = KXTF9_MAP_Y,
901 .negate_x = KXTF9_NEG_X,
902 .negate_y = KXTF9_NEG_Y,
903 .negate_z = KXTF9_NEG_Z,
904 //.ctrl_regc_init = KXTF9_G_2G | ODR50F,
905 //.ctrl_regb_init = ENABLE,
907 #endif /* CONFIG_GS_KXTF9 */
911 #if defined (CONFIG_GS_MMA8452)
912 #define MMA8452_INT_PIN RK29_PIN0_PA3
914 static int mma8452_init_platform_hw(void)
917 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
918 gpio_free(MMA8452_INT_PIN);
919 printk("mma8452_init_platform_hw gpio_request error\n");
922 gpio_pull_updown(MMA8452_INT_PIN, 1);
927 static struct mma8452_platform_data mma8452_info = {
930 .init_platform_hw= mma8452_init_platform_hw,
934 #if defined (CONFIG_MPU_SENSORS_MPU3050)
936 static struct mpu3050_platform_data mpu3050_data = {
938 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
939 //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
940 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
941 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
943 #if defined (CONFIG_MPU_SENSORS_KXTF9)
945 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
946 .get_slave_descr = NULL ,
948 .get_slave_descr = get_accel_slave_descr ,
950 .adapt_num = 0, // The i2c bus to which the mpu device is
952 //.irq = RK29_PIN0_PA3,
953 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
955 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
956 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
957 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
958 .orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
961 #if defined (CONFIG_MPU_SENSORS_AK8975)
963 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
964 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
966 .get_slave_descr = get_compass_slave_descr,
968 .adapt_num = 0, // The i2c bus to which the compass device is.
969 // It can be difference with mpu
971 //.irq = RK29_PIN0_PA4,
972 .bus = EXT_SLAVE_BUS_PRIMARY,
974 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
975 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
976 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
977 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
978 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
983 #if defined (CONFIG_BATTERY_BQ27510)
984 #define DC_CHECK_PIN RK29_PIN4_PA1
985 #define LI_LION_BAT_NUM 2
986 static int bq27510_init_dc_check_pin(void){
987 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
988 gpio_free(DC_CHECK_PIN);
989 printk("bq27510 init dc check pin request error\n");
992 gpio_direction_input(DC_CHECK_PIN);
996 struct bq27510_platform_data bq27510_info = {
997 .init_dc_check_pin = bq27510_init_dc_check_pin,
998 .dc_check_pin = DC_CHECK_PIN,
999 .bat_num = LI_LION_BAT_NUM,
1003 /*************************************PMU ACT8891****************************************/
1005 #if defined (CONFIG_REGULATOR_ACT8891)
1007 /*act8891 in REGULATOR_MODE_STANDBY mode is said DCDC is in PMF mode is can save power,when in REGULATOR_MODE_NORMAL
1008 mode is said DCDC is in PWM mode , General default is in REGULATOR_MODE_STANDBY mode*/
1010 /*act8891 in REGULATOR_MODE_STANDBY mode is said LDO is in low power mode is can save power,when in REGULATOR_MODE_NORMAL
1011 mode is said DCDC is in nomal mode , General default is in REGULATOR_MODE_STANDBY mode*/
1012 /*set dcdc and ldo voltage by regulator_set_voltage()*/
1013 static struct act8891 *act8891;
1014 int act8891_set_init(struct act8891 *act8891)
1017 struct regulator *act_ldo1,*act_ldo2,*act_ldo3,*act_ldo4;
1018 struct regulator *act_dcdc1,*act_dcdc2,*act_dcdc3;
1021 act_ldo1 = regulator_get(NULL, "act_ldo1");
1022 regulator_enable(act_ldo1);
1023 regulator_set_voltage(act_ldo1,1800000,1800000);
1024 tmp = regulator_get_voltage(act_ldo1);
1025 regulator_set_mode(act_ldo1,REGULATOR_MODE_STANDBY);
1026 //regulator_set_mode(act_ldo1,REGULATOR_MODE_NORMAL);
1027 printk("***regulator_set_init: ldo1 vcc =%d\n",tmp);
1028 regulator_put(act_ldo1);
1031 act_ldo2 = regulator_get(NULL, "act_ldo2");
1032 regulator_enable(act_ldo2);
1033 regulator_set_voltage(act_ldo2,1200000,1200000);
1034 tmp = regulator_get_voltage(act_ldo2);
1035 regulator_set_mode(act_ldo2,REGULATOR_MODE_STANDBY);
1036 //regulator_set_mode(act_ldo2,REGULATOR_MODE_NORMAL);
1037 printk("***regulator_set_init: ldo2 vcc =%d\n",tmp);
1038 regulator_put(act_ldo2);
1041 act_ldo3 = regulator_get(NULL, "act_ldo3");
1042 regulator_enable(act_ldo3);
1043 regulator_set_voltage(act_ldo3,3300000,3300000);
1044 tmp = regulator_get_voltage(act_ldo3);
1045 regulator_set_mode(act_ldo3,REGULATOR_MODE_STANDBY);
1046 //regulator_set_mode(act_ldo3,REGULATOR_MODE_NORMAL);
1047 printk("***regulator_set_init: ldo3 vcc =%d\n",tmp);
1048 regulator_put(act_ldo3);
1051 act_ldo4 = regulator_get(NULL, "act_ldo4");
1052 regulator_enable(act_ldo4);
1053 regulator_set_voltage(act_ldo4,2500000,2500000);
1054 tmp = regulator_get_voltage(act_ldo4);
1055 regulator_set_mode(act_ldo4,REGULATOR_MODE_STANDBY);
1056 //regulator_set_mode(act_ldo4,REGULATOR_MODE_NORMAL);
1057 printk("***regulator_set_init: ldo4 vcc =%d\n",tmp);
1058 regulator_put(act_ldo4);
1061 act_dcdc1 = regulator_get(NULL, "act_dcdc1");
1062 regulator_enable(act_dcdc1);
1063 regulator_set_voltage(act_dcdc1,3000000,3000000);
1064 tmp = regulator_get_voltage(act_dcdc1);
1065 regulator_set_mode(act_dcdc1,REGULATOR_MODE_STANDBY);
1066 //regulator_set_mode(act_dcdc1,REGULATOR_MODE_NORMAL);
1067 printk("***regulator_set_init: dcdc1 vcc =%d\n",tmp);
1068 regulator_put(act_dcdc1);
1071 act_dcdc2 = regulator_get(NULL, "act_dcdc2");
1072 regulator_enable(act_dcdc2);
1073 regulator_set_voltage(act_dcdc2,1500000,1500000);
1074 tmp = regulator_get_voltage(act_dcdc2);
1075 regulator_set_mode(act_dcdc2,REGULATOR_MODE_STANDBY);
1076 //regulator_set_mode(act_dcdc2,REGULATOR_MODE_NORMAL);
1077 printk("***regulator_set_init: dcdc2 vcc =%d\n",tmp);
1078 regulator_put(act_dcdc2);
1081 act_dcdc3 = regulator_get(NULL, "act_dcdc3");
1082 regulator_enable(act_dcdc3);
1083 regulator_set_voltage(act_dcdc3,1200000,1200000);
1084 tmp = regulator_get_voltage(act_dcdc3);
1085 regulator_set_mode(act_dcdc3,REGULATOR_MODE_STANDBY);
1086 //regulator_set_mode(act_dcdc3,REGULATOR_MODE_NORMAL);
1087 printk("***regulator_set_init: dcdc3 vcc =%d\n",tmp);
1088 regulator_put(act_dcdc3);
1093 static struct regulator_consumer_supply act8891_ldo1_consumers[] = {
1095 .supply = "act_ldo1",
1099 static struct regulator_init_data act8891_ldo1_data = {
1105 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1106 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1108 .num_consumer_supplies = ARRAY_SIZE(act8891_ldo1_consumers),
1109 .consumer_supplies = act8891_ldo1_consumers,
1113 static struct regulator_consumer_supply act8891_ldo2_consumers[] = {
1115 .supply = "act_ldo2",
1119 static struct regulator_init_data act8891_ldo2_data = {
1125 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1126 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1128 .num_consumer_supplies = ARRAY_SIZE(act8891_ldo2_consumers),
1129 .consumer_supplies = act8891_ldo2_consumers,
1132 /*ldo3 VCC_NAND WIFI/BT/FM_BCM4325*/
1133 static struct regulator_consumer_supply act8891_ldo3_consumers[] = {
1135 .supply = "act_ldo3",
1139 static struct regulator_init_data act8891_ldo3_data = {
1145 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1146 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1148 .num_consumer_supplies = ARRAY_SIZE(act8891_ldo3_consumers),
1149 .consumer_supplies = act8891_ldo3_consumers,
1152 /*ldo4 VCCA CODEC_WM8994*/
1153 static struct regulator_consumer_supply act8891_ldo4_consumers[] = {
1155 .supply = "act_ldo4",
1159 static struct regulator_init_data act8891_ldo4_data = {
1165 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1166 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1168 .num_consumer_supplies = ARRAY_SIZE(act8891_ldo4_consumers),
1169 .consumer_supplies = act8891_ldo4_consumers,
1172 static struct regulator_consumer_supply act8891_dcdc1_consumers[] = {
1174 .supply = "act_dcdc1",
1178 static struct regulator_init_data act8891_dcdc1_data = {
1180 .name = "ACT_DCDC1",
1185 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1186 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1188 .num_consumer_supplies = ARRAY_SIZE(act8891_dcdc1_consumers),
1189 .consumer_supplies = act8891_dcdc1_consumers
1192 /*buck2 VDDDR MobileDDR VCC*/
1193 static struct regulator_consumer_supply act8891_dcdc2_consumers[] = {
1195 .supply = "act_dcdc2",
1199 static struct regulator_init_data act8891_dcdc2_data = {
1201 .name = "ACT_DCDC2",
1206 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1207 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1209 .num_consumer_supplies = ARRAY_SIZE(act8891_dcdc2_consumers),
1210 .consumer_supplies = act8891_dcdc2_consumers
1214 static struct regulator_consumer_supply act8891_dcdc3_consumers[] = {
1216 .supply = "act_dcdc3",
1220 static struct regulator_init_data act8891_dcdc3_data = {
1222 .name = "ACT_DCDC3",
1227 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1228 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1230 .num_consumer_supplies = ARRAY_SIZE(act8891_dcdc3_consumers),
1231 .consumer_supplies = act8891_dcdc3_consumers
1234 struct act8891_regulator_subdev act8891_regulator_subdev_id[] = {
1237 .initdata=&act8891_ldo1_data,
1242 .initdata=&act8891_ldo2_data,
1247 .initdata=&act8891_ldo3_data,
1252 .initdata=&act8891_ldo4_data,
1257 .initdata=&act8891_dcdc1_data,
1262 .initdata=&act8891_dcdc2_data,
1266 .initdata=&act8891_dcdc3_data,
1271 struct act8891_platform_data act8891_data={
1272 .set_init=act8891_set_init,
1274 .regulators=act8891_regulator_subdev_id,
1279 /*****************************************************************************************
1281 * author: kfx@rock-chips.com
1282 *****************************************************************************************/
1283 static int rk29_i2c0_io_init(void)
1285 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1286 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
1287 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
1289 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
1290 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
1295 static int rk29_i2c1_io_init(void)
1297 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1298 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
1299 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
1301 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
1302 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
1306 static int rk29_i2c2_io_init(void)
1308 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1309 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
1310 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
1312 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
1313 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
1318 static int rk29_i2c3_io_init(void)
1320 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1321 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
1322 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1324 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
1325 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
1329 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1330 struct rk29_i2c_platform_data default_i2c0_data = {
1334 .scl_rate = 400*1000,
1335 .mode = I2C_MODE_IRQ,
1336 .io_init = rk29_i2c0_io_init,
1339 struct i2c_gpio_platform_data default_i2c0_data = {
1340 .sda_pin = RK29_PIN2_PB6,
1341 .scl_pin = RK29_PIN2_PB7,
1342 .udelay = 5, // clk = 500/udelay = 100Khz
1343 .timeout = 100,//msecs_to_jiffies(200),
1345 .io_init = rk29_i2c0_io_init,
1348 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1349 struct rk29_i2c_platform_data default_i2c1_data = {
1353 .scl_rate = 400*1000,
1354 .mode = I2C_MODE_IRQ,
1355 .io_init = rk29_i2c1_io_init,
1358 struct i2c_gpio_platform_data default_i2c1_data = {
1359 .sda_pin = RK29_PIN1_PA6,
1360 .scl_pin = RK29_PIN1_PA7,
1361 .udelay = 5, // clk = 500/udelay = 100Khz
1362 .timeout = 100,//msecs_to_jiffies(200),
1364 .io_init = rk29_i2c1_io_init,
1367 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1368 struct rk29_i2c_platform_data default_i2c2_data = {
1372 .scl_rate = 400*1000,
1373 .mode = I2C_MODE_IRQ,
1374 .io_init = rk29_i2c2_io_init,
1377 struct i2c_gpio_platform_data default_i2c2_data = {
1378 .sda_pin = RK29_PIN5_PD3,
1379 .scl_pin = RK29_PIN5_PD4,
1380 .udelay = 5, // clk = 500/udelay = 100Khz
1381 .timeout = 100,//msecs_to_jiffies(200),
1383 .io_init = rk29_i2c2_io_init,
1386 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1387 struct rk29_i2c_platform_data default_i2c3_data = {
1391 .scl_rate = 400*1000,
1392 .mode = I2C_MODE_IRQ,
1393 .io_init = rk29_i2c3_io_init,
1396 struct i2c_gpio_platform_data default_i2c3_data = {
1397 .sda_pin = RK29_PIN5_PB5,
1398 .scl_pin = RK29_PIN5_PB4,
1399 .udelay = 5, // clk = 500/udelay = 100Khz
1400 .timeout = 100,//msecs_to_jiffies(200),
1402 .io_init = rk29_i2c3_io_init,
1405 #ifdef CONFIG_I2C0_RK29
1406 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1407 #if defined (CONFIG_RK1000_CONTROL)
1409 .type = "rk1000_control",
1414 #if defined (CONFIG_SND_SOC_alc5621)
1421 #if defined (CONFIG_SND_SOC_alc5631)
1428 #if defined (CONFIG_SND_SOC_RK1000)
1430 .type = "rk1000_i2c_codec",
1435 #if defined (CONFIG_SND_SOC_WM8900)
1442 #if defined (CONFIG_BATTERY_STC3100)
1449 #if defined (CONFIG_BATTERY_BQ27510)
1454 .platform_data = &bq27510_info,
1457 #if defined (CONFIG_RTC_HYM8563)
1459 .type = "rtc_hym8563",
1462 .irq = RK29_PIN0_PA1,
1465 #if defined (CONFIG_GS_MMA8452)
1467 .type = "gs_mma8452",
1470 .irq = MMA8452_INT_PIN,
1471 .platform_data = &mma8452_info,
1474 #if defined (CONFIG_COMPASS_AK8973)
1479 .irq = RK29_PIN0_PA4,
1482 #if defined (CONFIG_COMPASS_AK8975)
1487 .irq = RK29_PIN0_PA4,
1491 #if defined (CONFIG_MPU_SENSORS_MPU3050)
1496 .irq = RK29_PIN5_PA3,
1497 .platform_data = &mpu3050_data,
1500 #if defined (CONFIG_SND_SOC_CS42L52)
1505 .platform_data = &cs42l52_info,
1508 #if defined (CONFIG_RTC_M41T66)
1510 .type = "rtc-M41T66",
1513 .irq = RK29_PIN0_PA1,
1518 #if defined (CONFIG_ANX7150)
1519 struct hdmi_platform_data anx7150_data = {
1520 //.io_init = anx7150_io_init,
1523 #ifdef CONFIG_I2C1_RK29
1524 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1525 #if defined (CONFIG_RK1000_CONTROL1)
1527 .type = "rk1000_control",
1532 #if defined (CONFIG_ANX7150)
1535 .addr = 0x39, //0x39, 0x3d
1537 .irq = RK29_PIN1_PD7,
1538 .platform_data = &anx7150_data,
1541 #ifdef CONFIG_BU92747GUW_CIR
1543 .type ="bu92747_cir",
1546 .irq = BU92747_CIR_IRQ_PIN,
1547 .platform_data = &bu92747guw_pdata,
1554 #ifdef CONFIG_I2C2_RK29
1555 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1556 #if defined (CONFIG_HANNSTAR_P1003)
1558 .type = "p1003_touch",
1560 .flags = 0, //I2C_M_NEED_DELAY
1561 .irq = RK29_PIN0_PA2,
1562 .platform_data = &p1003_info,
1566 #if defined (CONFIG_EETI_EGALAX)
1568 .type = "egalax_i2c",
1571 .irq = RK29_PIN0_PA2,
1572 .platform_data = &eeti_egalax_info,
1575 #if defined (CONFIG_TOUCHSCREEN_GT819)
1577 .type = "Goodix-TS",
1580 .irq =RK29_PIN0_PA2,
1581 .platform_data = &goodix_info,
1584 #if defined (CONFIG_TOUCHSCREEN_FT5406)
1587 .addr = 0x38, //0x70,
1589 .irq =RK29_PIN0_PA2, // support goodix tp detect, 20110706
1590 .platform_data = &ft5406_info,
1596 #ifdef CONFIG_I2C3_RK29
1597 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1598 #if defined (CONFIG_BATTERY_BQ27541)
1603 .platform_data = &bq27541_info,
1606 #if defined (CONFIG_REGULATOR_ACT8891)
1611 .platform_data=&act8891_data,
1618 /*****************************************************************************************
1620 * author: ddl@rock-chips.com
1621 *****************************************************************************************/
1622 #ifdef CONFIG_VIDEO_RK29
1623 #define CONFIG_SENSOR_POWER_IOCTL_USR 0
1624 #define CONFIG_SENSOR_RESET_IOCTL_USR 0
1625 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0
1626 #define CONFIG_SENSOR_FLASH_IOCTL_USR 0
1628 #if CONFIG_SENSOR_POWER_IOCTL_USR
1629 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
1631 #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
1635 #if CONFIG_SENSOR_RESET_IOCTL_USR
1636 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
1638 #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
1642 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1643 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
1645 #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
1649 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1650 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
1652 #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
1656 static struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
1657 #if CONFIG_SENSOR_POWER_IOCTL_USR
1658 .sensor_power_cb = sensor_power_usr_cb,
1660 .sensor_power_cb = NULL,
1663 #if CONFIG_SENSOR_RESET_IOCTL_USR
1664 .sensor_reset_cb = sensor_reset_usr_cb,
1666 .sensor_reset_cb = NULL,
1669 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1670 .sensor_powerdown_cb = sensor_powerdown_usr_cb,
1672 .sensor_powerdown_cb = NULL,
1675 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1676 .sensor_flash_cb = sensor_flash_usr_cb,
1678 .sensor_flash_cb = NULL,
1681 #include "../../../drivers/media/video/rk29_camera.c"
1683 /*****************************************************************************************
1685 * author: nzy@rock-chips.com
1686 *****************************************************************************************/
1687 #ifdef CONFIG_BACKLIGHT_RK29_BL
1689 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
1690 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
1691 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
1692 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
1696 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
1697 #define PWM_MUX_MODE GPIO1L_PWM0
1698 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1699 #define PWM_GPIO RK29_PIN1_PB5
1700 #define PWM_EFFECT_VALUE 1
1702 #define LCD_DISP_ON_PIN
1704 #ifdef LCD_DISP_ON_PIN
1705 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
1706 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
1708 #define BL_EN_PIN RK29_PIN6_PD0
1709 #define BL_EN_VALUE GPIO_HIGH
1711 static int rk29_backlight_io_init(void)
1715 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1716 #ifdef LCD_DISP_ON_PIN
1717 // rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
1719 ret = gpio_request(BL_EN_PIN, NULL);
1722 gpio_free(BL_EN_PIN);
1725 gpio_direction_output(BL_EN_PIN, 0);
1726 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1731 static int rk29_backlight_io_deinit(void)
1734 #ifdef LCD_DISP_ON_PIN
1735 gpio_free(BL_EN_PIN);
1737 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1742 static int rk29_backlight_pwm_suspend(void)
1745 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1746 if (gpio_request(PWM_GPIO, NULL)) {
1747 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
1750 gpio_direction_output(PWM_GPIO, GPIO_LOW);
1751 #ifdef LCD_DISP_ON_PIN
1752 gpio_direction_output(BL_EN_PIN, 0);
1753 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
1758 static int rk29_backlight_pwm_resume(void)
1760 gpio_free(PWM_GPIO);
1761 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1763 #ifdef LCD_DISP_ON_PIN
1765 gpio_direction_output(BL_EN_PIN, 1);
1766 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1771 struct rk29_bl_info rk29_bl_info = {
1773 .bl_ref = PWM_EFFECT_VALUE,
1774 .io_init = rk29_backlight_io_init,
1775 .io_deinit = rk29_backlight_io_deinit,
1776 .pwm_suspend = rk29_backlight_pwm_suspend,
1777 .pwm_resume = rk29_backlight_pwm_resume,
1780 /*****************************************************************************************
1781 * pwm voltage regulator devices
1782 ******************************************************************************************/
1783 #if defined (CONFIG_RK29_PWM_REGULATOR)
1785 #define REGULATOR_PWM_ID 2
1786 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1787 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1788 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1789 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1791 static struct regulator_consumer_supply pwm_consumers[] = {
1797 static struct regulator_init_data rk29_pwm_regulator_data = {
1803 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1805 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1806 .consumer_supplies = pwm_consumers,
1809 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1810 .pwm_id = REGULATOR_PWM_ID,
1811 .pwm_gpio = REGULATOR_PWM_GPIO,
1812 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1813 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1814 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1815 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1816 .init_data = &rk29_pwm_regulator_data,
1819 static struct platform_device rk29_device_pwm_regulator = {
1820 .name = "pwm-voltage-regulator",
1823 .platform_data = &rk29_regulator_pwm_platform_data,
1829 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1830 #define SDMMC0_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin.
1834 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1835 #define SDMMC1_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin.
1838 /*****************************************************************************************
1840 *****************************************************************************************/
1841 #ifdef CONFIG_SDMMC0_RK29
1842 static int rk29_sdmmc0_cfg_gpio(void)
1844 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1845 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1846 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1847 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1848 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1849 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1851 #ifdef CONFIG_SDMMC_RK29_OLD
1852 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
1854 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
1857 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1858 gpio_request(RK29_PIN5_PD5,"sdmmc");
1860 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1862 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1864 gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
1867 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1868 gpio_request(SDMMC0_WRITE_PROTECT_PIN,"sdmmc-wp");
1869 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1875 #define CONFIG_SDMMC0_USE_DMA
1876 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1877 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1878 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1879 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1880 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1881 .io_init = rk29_sdmmc0_cfg_gpio,
1882 .dma_name = "sd_mmc",
1883 #ifdef CONFIG_SDMMC0_USE_DMA
1888 .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
1889 .enable_sd_wakeup = 0,
1891 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1892 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1894 .write_prt = INVALID_GPIO,
1898 #ifdef CONFIG_SDMMC1_RK29
1899 #define CONFIG_SDMMC1_USE_DMA
1900 static int rk29_sdmmc1_cfg_gpio(void)
1902 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1903 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1904 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1905 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1906 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1907 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1908 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1910 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1911 gpio_request(SDMMC1_WRITE_PROTECT_PIN,"sdio-wp");
1912 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1917 #ifdef CONFIG_WIFI_CONTROL_FUNC
1918 static int rk29sdk_wifi_status(struct device *dev);
1919 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1922 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1924 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1925 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1926 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1927 MMC_VDD_32_33|MMC_VDD_33_34),
1928 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1929 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1930 .io_init = rk29_sdmmc1_cfg_gpio,
1932 #ifdef CONFIG_SDMMC1_USE_DMA
1937 #ifdef CONFIG_WIFI_CONTROL_FUNC
1938 .status = rk29sdk_wifi_status,
1939 .register_status_notify = rk29sdk_wifi_status_register,
1942 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1945 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1946 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1948 .write_prt = INVALID_GPIO,
1954 #ifdef CONFIG_WIFI_CONTROL_FUNC
1955 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1956 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1957 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1959 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1960 static void (*wifi_status_cb)(int card_present, void *dev_id);
1961 static void *wifi_status_cb_devid;
1962 int rk29sdk_wifi_power_state = 0;
1963 int rk29sdk_bt_power_state = 0;
1965 static int rk29sdk_wifi_status(struct device *dev)
1967 return rk29sdk_wifi_cd;
1970 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1974 wifi_status_cb = callback;
1975 wifi_status_cb_devid = dev_id;
1979 static int rk29sdk_wifi_bt_gpio_control_init(void)
1981 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1982 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1986 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1987 pr_info("%s: request wifi reset gpio failed\n", __func__);
1988 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1992 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1993 pr_info("%s: request bt reset gpio failed\n", __func__);
1994 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1998 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1999 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2000 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
2002 pr_info("%s: init finished\n",__func__);
2007 static int rk29sdk_wifi_power(int on)
2009 pr_info("%s: %d\n", __func__, on);
2011 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
2012 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
2014 pr_info("wifi turn on power\n");
2016 if (!rk29sdk_bt_power_state){
2017 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2019 pr_info("wifi shut off power\n");
2022 pr_info("wifi shouldn't shut off power, bt is using it!\n");
2024 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2028 rk29sdk_wifi_power_state = on;
2032 static int rk29sdk_wifi_reset_state;
2033 static int rk29sdk_wifi_reset(int on)
2035 pr_info("%s: %d\n", __func__, on);
2036 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
2038 rk29sdk_wifi_reset_state = on;
2042 int rk29sdk_wifi_set_carddetect(int val)
2044 pr_info("%s:%d\n", __func__, val);
2045 rk29sdk_wifi_cd = val;
2046 if (wifi_status_cb){
2047 wifi_status_cb(val, wifi_status_cb_devid);
2049 pr_warning("%s, nobody to notify\n", __func__);
2053 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
2055 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
2056 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
2057 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
2058 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
2059 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
2062 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
2064 if (section == PREALLOC_WLAN_SEC_NUM)
2065 return wlan_static_skb;
2067 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
2070 if (wifi_mem_array[section].size < size)
2073 return wifi_mem_array[section].mem_ptr;
2076 int __init rk29sdk_init_wifi_mem(void)
2081 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
2082 wlan_static_skb[i] = dev_alloc_skb(
2083 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
2085 if (!wlan_static_skb[i])
2089 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
2090 wifi_mem_array[i].mem_ptr =
2091 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
2093 if (!wifi_mem_array[i].mem_ptr)
2099 pr_err("Failed to mem_alloc for WLAN\n");
2100 for (j = 0 ; j < i ; j++)
2101 kfree(wifi_mem_array[j].mem_ptr);
2103 i = WLAN_SKB_BUF_NUM;
2106 pr_err("Failed to skb_alloc for WLAN\n");
2107 for (j = 0 ; j < i ; j++)
2108 dev_kfree_skb(wlan_static_skb[j]);
2113 static struct wifi_platform_data rk29sdk_wifi_control = {
2114 .set_power = rk29sdk_wifi_power,
2115 .set_reset = rk29sdk_wifi_reset,
2116 .set_carddetect = rk29sdk_wifi_set_carddetect,
2117 .mem_prealloc = rk29sdk_mem_prealloc,
2119 static struct platform_device rk29sdk_wifi_device = {
2120 .name = "bcm4329_wlan",
2123 .platform_data = &rk29sdk_wifi_control,
2129 /* bluetooth rfkill device */
2130 static struct platform_device rk29sdk_rfkill = {
2131 .name = "rk29sdk_rfkill",
2136 #ifdef CONFIG_VIVANTE
2137 #define GPU_HIGH_CLOCK 552
2138 #define GPU_LOW_CLOCK (periph_pll_default / 1000000) /* same as general pll clock rate below */
2139 static struct resource resources_gpu[] = {
2144 .flags = IORESOURCE_IRQ,
2148 .start = RK29_GPU_PHYS,
2149 .end = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
2150 .flags = IORESOURCE_MEM,
2154 .start = PMEM_GPU_BASE,
2155 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
2156 .flags = IORESOURCE_MEM,
2160 .start = GPU_LOW_CLOCK,
2161 .end = GPU_HIGH_CLOCK,
2162 .flags = IORESOURCE_IO,
2165 static struct platform_device rk29_device_gpu = {
2168 .num_resources = ARRAY_SIZE(resources_gpu),
2169 .resource = resources_gpu,
2173 #ifdef CONFIG_KEYS_RK29
2174 extern struct rk29_keys_platform_data rk29_keys_pdata;
2175 static struct platform_device rk29_device_keys = {
2176 .name = "rk29-keypad",
2179 .platform_data = &rk29_keys_pdata,
2184 #ifdef CONFIG_LEDS_GPIO_PLATFORM
2185 struct gpio_led rk29_leds[] = {
2187 .name = "rk29_red_led",
2188 .gpio = RK29_PIN4_PB2,
2189 .default_trigger = "timer",
2191 .retain_state_suspended = 1,
2192 .default_state = LEDS_GPIO_DEFSTATE_OFF,
2195 .name = "rk29_green_led",
2196 .gpio = RK29_PIN4_PB1,
2197 .default_trigger = "timer",
2199 .retain_state_suspended = 1,
2200 .default_state = LEDS_GPIO_DEFSTATE_OFF,
2203 .name = "rk29_blue_led",
2204 .gpio = RK29_PIN4_PB0,
2205 .default_trigger = "timer",
2207 .retain_state_suspended = 1,
2208 .default_state = LEDS_GPIO_DEFSTATE_OFF,
2212 struct gpio_led_platform_data rk29_leds_pdata = {
2214 .num_leds = ARRAY_SIZE(rk29_leds),
2217 struct platform_device rk29_device_gpio_leds = {
2218 .name = "leds-gpio",
2221 .platform_data = &rk29_leds_pdata,
2226 #ifdef CONFIG_LEDS_NEWTON_PWM
2227 static struct led_newton_pwm rk29_pwm_leds[] = {
2229 .name = "power_led",
2231 .pwm_gpio = RK29_PIN5_PD2,
2232 .pwm_iomux_name = GPIO5D2_PWM1_UART1SIRIN_NAME,
2233 .pwm_iomux_pwm = GPIO5H_PWM1,
2234 .pwm_iomux_gpio = GPIO5H_GPIO5D2,
2240 static struct led_newton_pwm_platform_data rk29_pwm_leds_pdata = {
2241 .leds = &rk29_pwm_leds,
2242 .num_leds = ARRAY_SIZE(rk29_pwm_leds),
2245 static struct platform_device rk29_device_pwm_leds = {
2246 .name = "leds_newton_pwm",
2249 .platform_data = &rk29_pwm_leds_pdata,
2254 static void __init rk29_board_iomux_init(void)
2256 #ifdef CONFIG_RK29_PWM_REGULATOR
2257 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
2261 static struct platform_device *devices[] __initdata = {
2263 #ifdef CONFIG_RK29_WATCHDOG
2267 #ifdef CONFIG_UART1_RK29
2270 #ifdef CONFIG_UART0_RK29
2273 #ifdef CONFIG_UART2_RK29
2276 #ifdef CONFIG_UART3_RK29
2280 #ifdef CONFIG_RK29_PWM_REGULATOR
2281 &rk29_device_pwm_regulator,
2283 #ifdef CONFIG_SPIM0_RK29
2284 &rk29xx_device_spi0m,
2286 #ifdef CONFIG_SPIM1_RK29
2287 &rk29xx_device_spi1m,
2289 #ifdef CONFIG_ADC_RK29
2292 #ifdef CONFIG_I2C0_RK29
2295 #ifdef CONFIG_I2C1_RK29
2298 #ifdef CONFIG_I2C2_RK29
2301 #ifdef CONFIG_I2C3_RK29
2305 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
2306 &rk29_device_iis_2ch,
2308 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
2309 &rk29_device_iis_8ch,
2312 #ifdef CONFIG_KEYS_RK29
2315 #ifdef CONFIG_KEYS_RK29_NEWTON
2318 #ifdef CONFIG_SDMMC0_RK29
2319 &rk29_device_sdmmc0,
2321 #ifdef CONFIG_SDMMC1_RK29
2322 &rk29_device_sdmmc1,
2325 #ifdef CONFIG_MTD_NAND_RK29XX
2326 &rk29xx_device_nand,
2329 #ifdef CONFIG_WIFI_CONTROL_FUNC
2330 &rk29sdk_wifi_device,
2337 #ifdef CONFIG_MTD_NAND_RK29
2341 #ifdef CONFIG_FB_RK29
2343 &rk29_device_dma_cpy,
2345 #ifdef CONFIG_BACKLIGHT_RK29_BL
2346 &rk29_device_backlight,
2348 #ifdef CONFIG_BACKLIGHT_RK29_NEWTON_BL
2349 &rk29_device_backlight,
2351 #ifdef CONFIG_RK29_VMAC
2354 #ifdef CONFIG_VIVANTE
2357 #ifdef CONFIG_VIDEO_RK29
2358 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
2359 #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
2360 &rk29_soc_camera_pdrv_0,
2362 &rk29_soc_camera_pdrv_1,
2363 &android_pmem_cam_device,
2365 #if PMEM_SKYPE_SIZE > 0
2366 &android_pmem_skype_device,
2368 &android_pmem_device,
2369 &rk29_vpu_mem_device,
2370 #ifdef CONFIG_USB20_OTG
2371 &rk29_device_usb20_otg,
2373 #ifdef CONFIG_USB20_HOST
2374 &rk29_device_usb20_host,
2376 #ifdef CONFIG_USB11_HOST
2377 &rk29_device_usb11_host,
2379 #ifdef CONFIG_USB_ANDROID
2380 &android_usb_device,
2381 &usb_mass_storage_device,
2383 #ifdef CONFIG_USB_ANDROID_RNDIS
2386 #ifdef CONFIG_RK29_IPP
2389 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2390 &rk29_v4l2_output_devce,
2392 #ifdef CONFIG_RK29_NEWTON
2393 &rk29_device_newton,
2395 #ifdef CONFIG_RK_IRDA
2398 #ifdef CONFIG_LEDS_GPIO_PLATFORM
2399 &rk29_device_gpio_leds,
2401 #ifdef CONFIG_LEDS_NEWTON_PWM
2402 &rk29_device_pwm_leds,
2404 #ifdef CONFIG_SND_RK29_SOC_CS42L52
2405 &rk29_cs42l52_device,
2409 /*****************************************************************************************
2411 * author: cmc@rock-chips.com
2412 *****************************************************************************************/
2413 static int rk29_vmac_register_set(void)
2415 //config rk29 vmac as rmii, 100MHz
2416 u32 value= readl(RK29_GRF_BASE + 0xbc);
2417 value = (value & 0xfff7ff) | (0x400);
2418 writel(value, RK29_GRF_BASE + 0xbc);
2422 static int rk29_rmii_io_init(void)
2427 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2429 gpio_free(RK29_PIN6_PB0);
2430 printk("-------request RK29_PIN6_PB0 fail--------\n");
2434 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2435 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2440 static int rk29_rmii_io_deinit(void)
2443 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2444 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2446 gpio_free(RK29_PIN6_PB0);
2450 static int rk29_rmii_power_control(int enable)
2454 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2455 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2458 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2459 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2464 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2465 .vmac_register_set = rk29_vmac_register_set,
2466 .rmii_io_init = rk29_rmii_io_init,
2467 .rmii_io_deinit = rk29_rmii_io_deinit,
2468 .rmii_power_control = rk29_rmii_power_control,
2471 /*****************************************************************************************
2473 * author: cmc@rock-chips.com
2474 *****************************************************************************************/
2475 #define SPI_CHIPSELECT_NUM 2
2476 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2479 .cs_gpio = RK29_PIN2_PC1,
2480 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2481 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2485 .cs_gpio = RK29_PIN1_PA4,
2486 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2487 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2491 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2494 .cs_gpio = RK29_PIN2_PC5,
2495 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2496 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2500 .cs_gpio = RK29_PIN1_PA3,
2501 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2502 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2506 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2511 for (i=0; i<cs_num; i++) {
2512 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2519 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2524 static int spi_io_fix_leakage_bug(void)
2527 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2532 static int spi_io_resume_leakage_bug(void)
2535 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2540 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2541 .num_chipselect = SPI_CHIPSELECT_NUM,
2542 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2543 .io_init = spi_io_init,
2544 .io_deinit = spi_io_deinit,
2545 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2546 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2549 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2550 .num_chipselect = SPI_CHIPSELECT_NUM,
2551 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2552 .io_init = spi_io_init,
2553 .io_deinit = spi_io_deinit,
2554 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2555 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2558 /*****************************************************************************************
2559 * xpt2046 touch panel
2560 * author: cmc@rock-chips.com
2561 *****************************************************************************************/
2562 #define XPT2046_GPIO_INT RK29_PIN0_PA3
2563 #define DEBOUNCE_REPTIME 3
2565 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
2566 static struct xpt2046_platform_data xpt2046_info = {
2575 .debounce_rep = DEBOUNCE_REPTIME,
2577 .gpio_pendown = XPT2046_GPIO_INT,
2578 .penirq_recheck_delay_usecs = 1,
2580 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
2581 static struct xpt2046_platform_data xpt2046_info = {
2590 .debounce_rep = DEBOUNCE_REPTIME,
2592 .gpio_pendown = XPT2046_GPIO_INT,
2593 .penirq_recheck_delay_usecs = 1,
2595 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2596 static struct xpt2046_platform_data xpt2046_info = {
2605 .debounce_rep = DEBOUNCE_REPTIME,
2607 .gpio_pendown = XPT2046_GPIO_INT,
2609 .penirq_recheck_delay_usecs = 1,
2611 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2612 static struct xpt2046_platform_data xpt2046_info = {
2621 .debounce_rep = DEBOUNCE_REPTIME,
2623 .gpio_pendown = XPT2046_GPIO_INT,
2625 .penirq_recheck_delay_usecs = 1,
2629 static struct spi_board_info board_spi_devices[] = {
2630 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
2631 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2633 .modalias = "xpt2046_ts",
2635 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2637 .irq = XPT2046_GPIO_INT,
2638 .platform_data = &xpt2046_info,
2644 static void __init rk29_gic_init_irq(void)
2646 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2647 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2650 static void __init machine_rk29_init_irq(void)
2652 rk29_gic_init_irq();
2656 static struct cpufreq_frequency_table freq_table[] = {
2657 { .index = 1200000, .frequency = 408000 },
2658 { .index = 1200000, .frequency = 816000 },
2659 { .index = 1300000, .frequency = 1008000 },
2660 { .frequency = CPUFREQ_TABLE_END },
2663 static void __init machine_rk29_board_init(void)
2665 rk29_board_iomux_init();
2668 board_update_cpufreq_table(freq_table);
2670 platform_add_devices(devices, ARRAY_SIZE(devices));
2671 #ifdef CONFIG_I2C0_RK29
2672 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2673 ARRAY_SIZE(board_i2c0_devices));
2675 #ifdef CONFIG_I2C1_RK29
2676 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2677 ARRAY_SIZE(board_i2c1_devices));
2679 #ifdef CONFIG_I2C2_RK29
2680 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2681 ARRAY_SIZE(board_i2c2_devices));
2683 #ifdef CONFIG_I2C3_RK29
2684 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2685 ARRAY_SIZE(board_i2c3_devices));
2688 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2690 #ifdef CONFIG_WIFI_CONTROL_FUNC
2691 rk29sdk_wifi_bt_gpio_control_init();
2692 rk29sdk_init_wifi_mem();
2695 board_usb_detect_init(RK29_PIN0_PA0);
2696 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
2698 bu92747guw_io_init();
2703 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2704 char **cmdline, struct meminfo *mi)
2707 mi->bank[0].start = RK29_SDRAM_PHYS;
2708 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
2709 mi->bank[0].size = LINUX_SIZE;
2710 #if SDRAM_SIZE > SZ_512M
2712 mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
2713 mi->bank[1].size = SDRAM_SIZE - SZ_512M;
2717 static void __init machine_rk29_mapio(void)
2719 rk29_map_common_io();
2720 rk29_setup_early_printk();
2722 rk29_clock_init(periph_pll_default);
2724 ddr_init(DDR_TYPE, DDR_FREQ);
2727 MACHINE_START(RK29, "RK29board")
2728 /* UART for LL DEBUG */
2729 .phys_io = RK29_UART1_PHYS & 0xfff00000,
2730 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2731 .boot_params = RK29_SDRAM_PHYS + 0x88000,
2732 .fixup = machine_rk29_fixup,
2733 .map_io = machine_rk29_mapio,
2734 .init_irq = machine_rk29_init_irq,
2735 .init_machine = machine_rk29_board_init,
2736 .timer = &rk29_timer,