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
171 void key_gpio_pullupdown_enable(void)
172 { gpio_pull_updown(RK29_PIN6_PA0, 0);
173 gpio_pull_updown(RK29_PIN6_PA1, 0);
174 gpio_pull_updown(RK29_PIN6_PA2, 0);
175 gpio_pull_updown(RK29_PIN6_PA3, 0);
176 gpio_pull_updown(RK29_PIN6_PA4, 0);
177 gpio_pull_updown(RK29_PIN6_PA5, 0);
178 gpio_pull_updown(RK29_PIN6_PA6, 0);
181 void key_gpio_pullupdown_disable(void)
183 gpio_pull_updown(RK29_PIN6_PA0, 1);
184 gpio_pull_updown(RK29_PIN6_PA1, 1);
185 gpio_pull_updown(RK29_PIN6_PA2, 1);
186 gpio_pull_updown(RK29_PIN6_PA3, 1);
187 gpio_pull_updown(RK29_PIN6_PA4, 1);
188 gpio_pull_updown(RK29_PIN6_PA5, 1);
189 gpio_pull_updown(RK29_PIN6_PA6, 1);
191 void rk29_setgpio_suspend_board(void)
194 key_gpio_pullupdown_enable();
198 void rk29_setgpio_resume_board(void)
201 key_gpio_pullupdown_disable();
208 #ifdef CONFIG_FB_RK29
209 /*****************************************************************************************
211 * author: zyw@rock-chips.com
212 *****************************************************************************************/
213 //#ifdef CONFIG_LCD_TD043MGEA1
214 #define LCD_TXD_PIN INVALID_GPIO
215 #define LCD_CLK_PIN INVALID_GPIO
216 #define LCD_CS_PIN INVALID_GPIO
217 /*****************************************************************************************
218 * frame buffe devices
219 * author: zyw@rock-chips.com
220 *****************************************************************************************/
222 #define FB_DISPLAY_ON_PIN INVALID_GPIO// RK29_PIN6_PD0
223 #define FB_LCD_STANDBY_PIN INVALID_GPIO
224 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
225 #define FB_MCU_FMK_PIN INVALID_GPIO
227 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
228 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
230 static int rk29_lcd_io_init(void)
236 static int rk29_lcd_io_deinit(void)
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)
295 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
297 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
300 gpio_free(FB_DISPLAY_ON_PIN);
301 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
304 else if (TOUCH_SCREEN_DISPLAY_PIN != INVALID_GPIO)
306 ret = gpio_request(TOUCH_SCREEN_DISPLAY_PIN, NULL);
309 gpio_free(TOUCH_SCREEN_DISPLAY_PIN);
310 printk(">>>>>> TOUCH_SCREEN_DISPLAY_PIN gpio_request err \n ");
312 gpio_direction_output(TOUCH_SCREEN_DISPLAY_PIN, 0);
313 gpio_set_value(TOUCH_SCREEN_DISPLAY_PIN, TOUCH_SCREEN_DISPLAY_VALUE);
317 if(fb_setting->disp_on_en)
319 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
321 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
324 gpio_free(FB_LCD_STANDBY_PIN);
325 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
328 else if (TOUCH_SCREEN_STANDBY_PIN != INVALID_GPIO)
330 ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL);
333 gpio_free(TOUCH_SCREEN_STANDBY_PIN);
334 printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n ");
336 gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0);
337 gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE);
341 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
343 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
346 gpio_free(FB_LCD_CABC_EN_PIN);
347 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
349 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
350 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
353 rk29_fb_io_enable(); //enable it
359 static struct rk29fb_info rk29_fb_info = {
361 .mcu_fmk_pin = FB_MCU_FMK_PIN,
362 .lcd_info = &rk29_lcd_info,
363 .io_init = rk29_fb_io_init,
364 .io_enable = rk29_fb_io_enable,
365 .io_disable = rk29_fb_io_disable,
368 /* rk29 fb resource */
369 static struct resource rk29_fb_resource[] = {
372 .start = RK29_LCDC_PHYS,
373 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
374 .flags = IORESOURCE_MEM,
380 .flags = IORESOURCE_IRQ,
384 .start = MEM_FB_BASE,
385 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
386 .flags = IORESOURCE_MEM,
388 #ifdef CONFIG_FB_WORK_IPP
390 .name = "win1 ipp buf",
391 .start = MEM_FBIPP_BASE,
392 .end = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
393 .flags = IORESOURCE_MEM,
399 struct platform_device rk29_device_fb = {
402 .num_resources = ARRAY_SIZE(rk29_fb_resource),
403 .resource = rk29_fb_resource,
405 .platform_data = &rk29_fb_info,
409 struct platform_device rk29_device_dma_cpy = {
410 .name = "dma_memcpy",
417 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
418 #define BU92747GUW_RESET_PIN RK29_PIN3_PD4// INVALID_GPIO //
419 #define BU92747GUW_RESET_MUX_NAME GPIO3D4_HOSTWRN_NAME//NULL //
420 #define BU92747GUW_RESET_MUX_MODE GPIO3H_GPIO3D4//NULL //
422 #define BU92747GUW_PWDN_PIN RK29_PIN3_PD3//RK29_PIN5_PA7 //
423 #define BU92747GUW_PWDN_MUX_NAME GPIO3D3_HOSTRDN_NAME//GPIO5A7_HSADCDATA2_NAME //
424 #define BU92747GUW_PWDN_MUX_MODE GPIO3H_GPIO3D3//GPIO5L_GPIO5A7 //
426 static int bu92747guw_io_init(void)
431 if(BU92747GUW_RESET_MUX_NAME != NULL)
433 rk29_mux_api_set(BU92747GUW_RESET_MUX_NAME, BU92747GUW_RESET_MUX_MODE);
435 ret = gpio_request(BU92747GUW_RESET_PIN, NULL);
438 gpio_free(BU92747GUW_RESET_PIN);
439 printk(">>>>>> BU92747GUW_RESET_PIN gpio_request err \n ");
441 gpio_direction_output(BU92747GUW_RESET_PIN, GPIO_HIGH);
444 if(BU92747GUW_PWDN_MUX_NAME != NULL)
446 rk29_mux_api_set(BU92747GUW_PWDN_MUX_NAME, BU92747GUW_PWDN_MUX_MODE);
448 ret = gpio_request(BU92747GUW_PWDN_PIN, NULL);
451 gpio_free(BU92747GUW_PWDN_PIN);
452 printk(">>>>>> BU92747GUW_PWDN_PIN gpio_request err \n ");
455 //power down as default
456 gpio_direction_output(BU92747GUW_PWDN_PIN, GPIO_LOW);
462 static int bu92747guw_io_deinit(void)
464 gpio_free(BU92747GUW_PWDN_PIN);
465 gpio_free(BU92747GUW_RESET_PIN);
469 //power ctl func is share with irda and remote
470 static int nPowerOnCount = 0;
471 static DEFINE_MUTEX(bu92747_power_mutex);
473 //1---power on; 0---power off
474 static int bu92747guw_power_ctl(int enable)
476 printk("%s \n",__FUNCTION__);
478 mutex_lock(&bu92747_power_mutex);
481 if (nPowerOnCount == 1) {//power on first
483 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_HIGH);
484 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_LOW);
486 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_HIGH);
492 if (nPowerOnCount <= 0) {//power down final
495 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_LOW);
498 mutex_unlock(&bu92747_power_mutex);
503 #ifdef CONFIG_RK_IRDA
504 #define IRDA_IRQ_PIN RK29_PIN5_PB2
505 #define IRDA_IRQ_MUX_NAME GPIO5B2_HSADCDATA5_NAME
506 #define IRDA_IRQ_MUX_MODE GPIO5L_GPIO5B2
508 int irda_iomux_init(void)
513 if(IRDA_IRQ_MUX_NAME != NULL)
515 rk29_mux_api_set(IRDA_IRQ_MUX_NAME, IRDA_IRQ_MUX_MODE);
517 ret = gpio_request(IRDA_IRQ_PIN, NULL);
520 gpio_free(IRDA_IRQ_PIN);
521 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
523 gpio_pull_updown(IRDA_IRQ_PIN, GPIO_HIGH);
524 gpio_direction_input(IRDA_IRQ_PIN);
529 int irda_iomux_deinit(void)
531 gpio_free(IRDA_IRQ_PIN);
535 static struct irda_info rk29_irda_info = {
536 .intr_pin = IRDA_IRQ_PIN,
537 .iomux_init = irda_iomux_init,
538 .iomux_deinit = irda_iomux_deinit,
539 .irda_pwr_ctl = bu92747guw_power_ctl,
542 static struct platform_device irda_device = {
543 #ifdef CONFIG_RK_IRDA_NET
546 .name = "bu92747_irda",
550 .platform_data = &rk29_irda_info,
555 #ifdef CONFIG_BU92747GUW_CIR
556 #define BU92747_CIR_IRQ_PIN RK29_PIN5_PB0
557 #define CIR_IRQ_PIN_IOMUX_NAME GPIO5B0_HSADCDATA3_NAME
558 #define CIR_IRQ_PIN_IOMUX_VALUE GPIO5L_GPIO5B0
559 static int cir_iomux_init(void)
561 if (CIR_IRQ_PIN_IOMUX_NAME)
562 rk29_mux_api_set(CIR_IRQ_PIN_IOMUX_NAME, CIR_IRQ_PIN_IOMUX_VALUE);
563 rk29_mux_api_set(GPIO5A7_HSADCDATA2_NAME, GPIO5L_GPIO5A7);
567 static struct bu92747guw_platform_data bu92747guw_pdata = {
568 .intr_pin = BU92747_CIR_IRQ_PIN,
569 .iomux_init = cir_iomux_init,
570 .iomux_deinit = NULL,
571 .cir_pwr_ctl = bu92747guw_power_ctl,
574 #ifdef CONFIG_RK29_NEWTON
575 struct rk29_newton_data rk29_newton_info = {
577 struct platform_device rk29_device_newton = {
578 .name = "rk29_newton",
581 .platform_data = &rk29_newton_info,
585 #if defined (CONFIG_TOUCHSCREEN_FT5406)
586 #define TOUCH_RESET_PIN RK29_PIN6_PC3
587 #define TOUCH_INT_PIN RK29_PIN0_PA2
588 int ft5406_init_platform_hw(void)
590 printk("ft5406_init_platform_hw\n");
591 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
592 gpio_free(TOUCH_RESET_PIN);
593 printk("ft5406_init_platform_hw gpio_request error\n");
597 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
598 gpio_free(TOUCH_INT_PIN);
599 printk("ift5406_init_platform_hw gpio_request error\n");
603 gpio_direction_output(TOUCH_RESET_PIN, 0);
604 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
606 gpio_direction_input(TOUCH_INT_PIN);
608 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
613 void ft5406_exit_platform_hw(void)
615 printk("ft5406_exit_platform_hw\n");
616 gpio_free(TOUCH_RESET_PIN);
617 gpio_free(TOUCH_INT_PIN);
620 int ft5406_platform_sleep(void)
622 printk("ft5406_platform_sleep\n");
623 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
627 int ft5406_platform_wakeup(void)
629 printk("ft5406_platform_wakeup\n");
630 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
635 struct ft5406_platform_data ft5406_info = {
637 .init_platform_hw= ft5406_init_platform_hw,
638 .exit_platform_hw= ft5406_exit_platform_hw,
639 .platform_sleep = ft5406_platform_sleep,
640 .platform_wakeup = ft5406_platform_wakeup,
645 #if defined(CONFIG_TOUCHSCREEN_GT819)
646 #define TOUCH_RESET_PIN RK29_PIN6_PC3
647 #define TOUCH_INT_PIN RK29_PIN0_PA2
648 int gt819_init_platform_hw(void)
650 printk("gt819_init_platform_hw\n");
651 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
652 gpio_free(TOUCH_RESET_PIN);
653 printk("gt819_init_platform_hw gpio_request error\n");
657 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
658 gpio_free(TOUCH_INT_PIN);
659 printk("gt819_init_platform_hw gpio_request error\n");
662 gpio_direction_output(TOUCH_RESET_PIN, 0);
663 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
665 // gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
667 // gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
668 gpio_direction_input(TOUCH_INT_PIN);
670 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
676 void gt819_exit_platform_hw(void)
678 printk("gt819_exit_platform_hw\n");
679 gpio_free(TOUCH_RESET_PIN);
680 gpio_free(TOUCH_INT_PIN);
683 int gt819_platform_sleep(void)
685 printk("gt819_platform_sleep\n");
686 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
690 int gt819_platform_wakeup(void)
692 printk("gt819_platform_wakeup\n");
693 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
695 //gpio_set_value(TOUCH_INT_PIN, GPIO_LOW);
697 //gpio_set_value(TOUCH_INT_PIN, GPIO_HIGH);
700 struct goodix_platform_data goodix_info = {
702 .init_platform_hw= gt819_init_platform_hw,
703 .exit_platform_hw= gt819_exit_platform_hw,
704 .platform_sleep = gt819_platform_sleep,
705 .platform_wakeup = gt819_platform_wakeup,
711 #if defined (CONFIG_SND_SOC_CS42L52)
713 int cs42l52_init_platform_hw()
715 printk("cs42l52_init_platform_hw\n");
716 if(gpio_request(RK29_PIN6_PB6,NULL) != 0){
717 gpio_free(RK29_PIN6_PB6);
718 printk("cs42l52_init_platform_hw gpio_request error\n");
721 gpio_direction_output(RK29_PIN6_PB6, 0);
722 gpio_set_value(RK29_PIN6_PB6,GPIO_HIGH);
725 struct cs42l52_platform_data cs42l52_info = {
727 .init_platform_hw= cs42l52_init_platform_hw,
731 #if defined (CONFIG_BATTERY_BQ27541)
732 #define DC_CHECK_PIN RK29_PIN4_PA1
733 #define LI_LION_BAT_NUM 1
734 #define CHG_OK RK29_PIN4_PA3
735 #define BAT_LOW RK29_PIN4_PA2
737 static int bq27541_init_dc_check_pin(void){
738 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
739 gpio_free(DC_CHECK_PIN);
740 printk("bq27541 init dc check pin request error\n");
743 gpio_direction_input(DC_CHECK_PIN);
747 struct bq27541_platform_data bq27541_info = {
748 .init_dc_check_pin = bq27541_init_dc_check_pin,
749 .dc_check_pin = DC_CHECK_PIN,
750 .bat_num = LI_LION_BAT_NUM,
751 .chgok_check_pin = CHG_OK,
752 .bat_check_pin = BAT_LOW,
755 static struct android_pmem_platform_data android_pmem_pdata = {
757 .start = PMEM_UI_BASE,
758 .size = PMEM_UI_SIZE,
763 static struct platform_device android_pmem_device = {
764 .name = "android_pmem",
767 .platform_data = &android_pmem_pdata,
772 static struct vpu_mem_platform_data vpu_mem_pdata = {
774 .start = PMEM_VPU_BASE,
775 .size = PMEM_VPU_SIZE,
779 static struct platform_device rk29_vpu_mem_device = {
783 .platform_data = &vpu_mem_pdata,
787 #if PMEM_SKYPE_SIZE > 0
788 static struct android_pmem_platform_data android_pmem_skype_pdata = {
789 .name = "pmem_skype",
790 .start = PMEM_SKYPE_BASE,
791 .size = PMEM_SKYPE_SIZE,
796 static struct platform_device android_pmem_skype_device = {
797 .name = "android_pmem",
800 .platform_data = &android_pmem_skype_pdata,
805 #ifdef CONFIG_VIDEO_RK29XX_VOUT
806 static struct platform_device rk29_v4l2_output_devce = {
810 /*HANNSTAR_P1003 touch*/
811 #if defined (CONFIG_HANNSTAR_P1003)
812 #define TOUCH_RESET_PIN RK29_PIN6_PC3
813 #define TOUCH_INT_PIN RK29_PIN0_PA2
815 int p1003_init_platform_hw(void)
817 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
818 gpio_free(TOUCH_RESET_PIN);
819 printk("p1003_init_platform_hw gpio_request error\n");
823 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
824 gpio_free(TOUCH_INT_PIN);
825 printk("p1003_init_platform_hw gpio_request error\n");
828 gpio_pull_updown(TOUCH_INT_PIN, 1);
829 gpio_direction_output(TOUCH_RESET_PIN, 0);
831 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
833 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
839 struct p1003_platform_data p1003_info = {
841 .init_platform_hw= p1003_init_platform_hw,
845 #if defined (CONFIG_EETI_EGALAX)
846 #define TOUCH_RESET_PIN RK29_PIN6_PC3
847 #define TOUCH_INT_PIN RK29_PIN0_PA2
849 static int EETI_EGALAX_init_platform_hw(void)
851 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
852 gpio_free(TOUCH_RESET_PIN);
853 printk("p1003_init_platform_hw gpio_request error\n");
857 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
858 gpio_free(TOUCH_INT_PIN);
859 printk("p1003_init_platform_hw gpio_request error\n");
862 gpio_pull_updown(TOUCH_INT_PIN, 1);
863 gpio_direction_output(TOUCH_RESET_PIN, 0);
865 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
867 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
873 static struct eeti_egalax_platform_data eeti_egalax_info = {
875 .init_platform_hw= EETI_EGALAX_init_platform_hw,
876 .standby_pin = TOUCH_SCREEN_STANDBY_PIN,
877 .standby_value = TOUCH_SCREEN_STANDBY_VALUE,
878 .disp_on_pin = TOUCH_SCREEN_DISPLAY_PIN,
879 .disp_on_value = TOUCH_SCREEN_DISPLAY_VALUE,
883 #ifdef CONFIG_GS_KXTF9
884 #include <linux/kxtf9.h>
885 #define KXTF9_DEVICE_MAP 1
886 #define KXTF9_MAP_X (KXTF9_DEVICE_MAP-1)%2
887 #define KXTF9_MAP_Y KXTF9_DEVICE_MAP%2
888 #define KXTF9_NEG_X (KXTF9_DEVICE_MAP/2)%2
889 #define KXTF9_NEG_Y (KXTF9_DEVICE_MAP+1)/4
890 #define KXTF9_NEG_Z (KXTF9_DEVICE_MAP-1)/4
891 struct kxtf9_platform_data kxtf9_pdata = {
894 .g_range = KXTF9_G_2G,
895 .axis_map_x = KXTF9_MAP_X,
896 .axis_map_y = KXTF9_MAP_Y,
898 .negate_x = KXTF9_NEG_X,
899 .negate_y = KXTF9_NEG_Y,
900 .negate_z = KXTF9_NEG_Z,
901 //.ctrl_regc_init = KXTF9_G_2G | ODR50F,
902 //.ctrl_regb_init = ENABLE,
904 #endif /* CONFIG_GS_KXTF9 */
908 #if defined (CONFIG_GS_MMA8452)
909 #define MMA8452_INT_PIN RK29_PIN0_PA3
911 static int mma8452_init_platform_hw(void)
914 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
915 gpio_free(MMA8452_INT_PIN);
916 printk("mma8452_init_platform_hw gpio_request error\n");
919 gpio_pull_updown(MMA8452_INT_PIN, 1);
924 static struct mma8452_platform_data mma8452_info = {
927 .init_platform_hw= mma8452_init_platform_hw,
931 #if defined (CONFIG_MPU_SENSORS_MPU3050)
933 static struct mpu3050_platform_data mpu3050_data = {
935 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
936 //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
937 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
938 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
940 #if defined (CONFIG_MPU_SENSORS_KXTF9)
942 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
943 .get_slave_descr = NULL ,
945 .get_slave_descr = get_accel_slave_descr ,
947 .adapt_num = 0, // The i2c bus to which the mpu device is
949 //.irq = RK29_PIN0_PA3,
950 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
952 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
953 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
954 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
955 .orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
958 #if defined (CONFIG_MPU_SENSORS_AK8975)
960 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
961 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
963 .get_slave_descr = get_compass_slave_descr,
965 .adapt_num = 0, // The i2c bus to which the compass device is.
966 // It can be difference with mpu
968 //.irq = RK29_PIN0_PA4,
969 .bus = EXT_SLAVE_BUS_PRIMARY,
971 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
972 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
973 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
974 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
975 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
980 #if defined (CONFIG_BATTERY_BQ27510)
981 #define DC_CHECK_PIN RK29_PIN4_PA1
982 #define LI_LION_BAT_NUM 2
983 static int bq27510_init_dc_check_pin(void){
984 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
985 gpio_free(DC_CHECK_PIN);
986 printk("bq27510 init dc check pin request error\n");
989 gpio_direction_input(DC_CHECK_PIN);
993 struct bq27510_platform_data bq27510_info = {
994 .init_dc_check_pin = bq27510_init_dc_check_pin,
995 .dc_check_pin = DC_CHECK_PIN,
996 .bat_num = LI_LION_BAT_NUM,
1000 /*************************************PMU ACT8891****************************************/
1002 #if defined (CONFIG_REGULATOR_ACT8891)
1004 /*act8891 in REGULATOR_MODE_STANDBY mode is said DCDC is in PMF mode is can save power,when in REGULATOR_MODE_NORMAL
1005 mode is said DCDC is in PWM mode , General default is in REGULATOR_MODE_STANDBY mode*/
1007 /*act8891 in REGULATOR_MODE_STANDBY mode is said LDO is in low power mode is can save power,when in REGULATOR_MODE_NORMAL
1008 mode is said DCDC is in nomal mode , General default is in REGULATOR_MODE_STANDBY mode*/
1009 /*set dcdc and ldo voltage by regulator_set_voltage()*/
1010 static struct act8891 *act8891;
1011 int act8891_set_init(struct act8891 *act8891)
1014 struct regulator *act_ldo1,*act_ldo2,*act_ldo3,*act_ldo4;
1015 struct regulator *act_dcdc1,*act_dcdc2,*act_dcdc3;
1018 act_ldo1 = regulator_get(NULL, "act_ldo1");
1019 regulator_enable(act_ldo1);
1020 regulator_set_voltage(act_ldo1,1800000,1800000);
1021 tmp = regulator_get_voltage(act_ldo1);
1022 regulator_set_mode(act_ldo1,REGULATOR_MODE_STANDBY);
1023 //regulator_set_mode(act_ldo1,REGULATOR_MODE_NORMAL);
1024 printk("***regulator_set_init: ldo1 vcc =%d\n",tmp);
1025 regulator_put(act_ldo1);
1028 act_ldo2 = regulator_get(NULL, "act_ldo2");
1029 regulator_enable(act_ldo2);
1030 regulator_set_voltage(act_ldo2,1200000,1200000);
1031 tmp = regulator_get_voltage(act_ldo2);
1032 regulator_set_mode(act_ldo2,REGULATOR_MODE_STANDBY);
1033 //regulator_set_mode(act_ldo2,REGULATOR_MODE_NORMAL);
1034 printk("***regulator_set_init: ldo2 vcc =%d\n",tmp);
1035 regulator_put(act_ldo2);
1038 act_ldo3 = regulator_get(NULL, "act_ldo3");
1039 regulator_enable(act_ldo3);
1040 regulator_set_voltage(act_ldo3,3300000,3300000);
1041 tmp = regulator_get_voltage(act_ldo3);
1042 regulator_set_mode(act_ldo3,REGULATOR_MODE_STANDBY);
1043 //regulator_set_mode(act_ldo3,REGULATOR_MODE_NORMAL);
1044 printk("***regulator_set_init: ldo3 vcc =%d\n",tmp);
1045 regulator_put(act_ldo3);
1048 act_ldo4 = regulator_get(NULL, "act_ldo4");
1049 regulator_enable(act_ldo4);
1050 regulator_set_voltage(act_ldo4,2500000,2500000);
1051 tmp = regulator_get_voltage(act_ldo4);
1052 regulator_set_mode(act_ldo4,REGULATOR_MODE_STANDBY);
1053 //regulator_set_mode(act_ldo4,REGULATOR_MODE_NORMAL);
1054 printk("***regulator_set_init: ldo4 vcc =%d\n",tmp);
1055 regulator_put(act_ldo4);
1058 act_dcdc1 = regulator_get(NULL, "act_dcdc1");
1059 regulator_enable(act_dcdc1);
1060 regulator_set_voltage(act_dcdc1,3000000,3000000);
1061 tmp = regulator_get_voltage(act_dcdc1);
1062 regulator_set_mode(act_dcdc1,REGULATOR_MODE_STANDBY);
1063 //regulator_set_mode(act_dcdc1,REGULATOR_MODE_NORMAL);
1064 printk("***regulator_set_init: dcdc1 vcc =%d\n",tmp);
1065 regulator_put(act_dcdc1);
1068 act_dcdc2 = regulator_get(NULL, "act_dcdc2");
1069 regulator_enable(act_dcdc2);
1070 regulator_set_voltage(act_dcdc2,1500000,1500000);
1071 tmp = regulator_get_voltage(act_dcdc2);
1072 regulator_set_mode(act_dcdc2,REGULATOR_MODE_STANDBY);
1073 //regulator_set_mode(act_dcdc2,REGULATOR_MODE_NORMAL);
1074 printk("***regulator_set_init: dcdc2 vcc =%d\n",tmp);
1075 regulator_put(act_dcdc2);
1078 act_dcdc3 = regulator_get(NULL, "act_dcdc3");
1079 regulator_enable(act_dcdc3);
1080 regulator_set_voltage(act_dcdc3,1200000,1200000);
1081 tmp = regulator_get_voltage(act_dcdc3);
1082 regulator_set_mode(act_dcdc3,REGULATOR_MODE_STANDBY);
1083 //regulator_set_mode(act_dcdc3,REGULATOR_MODE_NORMAL);
1084 printk("***regulator_set_init: dcdc3 vcc =%d\n",tmp);
1085 regulator_put(act_dcdc3);
1090 static struct regulator_consumer_supply act8891_ldo1_consumers[] = {
1092 .supply = "act_ldo1",
1096 static struct regulator_init_data act8891_ldo1_data = {
1102 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1103 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1105 .num_consumer_supplies = ARRAY_SIZE(act8891_ldo1_consumers),
1106 .consumer_supplies = act8891_ldo1_consumers,
1110 static struct regulator_consumer_supply act8891_ldo2_consumers[] = {
1112 .supply = "act_ldo2",
1116 static struct regulator_init_data act8891_ldo2_data = {
1122 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1123 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1125 .num_consumer_supplies = ARRAY_SIZE(act8891_ldo2_consumers),
1126 .consumer_supplies = act8891_ldo2_consumers,
1129 /*ldo3 VCC_NAND WIFI/BT/FM_BCM4325*/
1130 static struct regulator_consumer_supply act8891_ldo3_consumers[] = {
1132 .supply = "act_ldo3",
1136 static struct regulator_init_data act8891_ldo3_data = {
1142 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1143 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1145 .num_consumer_supplies = ARRAY_SIZE(act8891_ldo3_consumers),
1146 .consumer_supplies = act8891_ldo3_consumers,
1149 /*ldo4 VCCA CODEC_WM8994*/
1150 static struct regulator_consumer_supply act8891_ldo4_consumers[] = {
1152 .supply = "act_ldo4",
1156 static struct regulator_init_data act8891_ldo4_data = {
1162 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1163 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1165 .num_consumer_supplies = ARRAY_SIZE(act8891_ldo4_consumers),
1166 .consumer_supplies = act8891_ldo4_consumers,
1169 static struct regulator_consumer_supply act8891_dcdc1_consumers[] = {
1171 .supply = "act_dcdc1",
1175 static struct regulator_init_data act8891_dcdc1_data = {
1177 .name = "ACT_DCDC1",
1182 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1183 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1185 .num_consumer_supplies = ARRAY_SIZE(act8891_dcdc1_consumers),
1186 .consumer_supplies = act8891_dcdc1_consumers
1189 /*buck2 VDDDR MobileDDR VCC*/
1190 static struct regulator_consumer_supply act8891_dcdc2_consumers[] = {
1192 .supply = "act_dcdc2",
1196 static struct regulator_init_data act8891_dcdc2_data = {
1198 .name = "ACT_DCDC2",
1203 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1204 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1206 .num_consumer_supplies = ARRAY_SIZE(act8891_dcdc2_consumers),
1207 .consumer_supplies = act8891_dcdc2_consumers
1211 static struct regulator_consumer_supply act8891_dcdc3_consumers[] = {
1213 .supply = "act_dcdc3",
1217 static struct regulator_init_data act8891_dcdc3_data = {
1219 .name = "ACT_DCDC3",
1224 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
1225 .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,
1227 .num_consumer_supplies = ARRAY_SIZE(act8891_dcdc3_consumers),
1228 .consumer_supplies = act8891_dcdc3_consumers
1231 struct act8891_regulator_subdev act8891_regulator_subdev_id[] = {
1234 .initdata=&act8891_ldo1_data,
1239 .initdata=&act8891_ldo2_data,
1244 .initdata=&act8891_ldo3_data,
1249 .initdata=&act8891_ldo4_data,
1254 .initdata=&act8891_dcdc1_data,
1259 .initdata=&act8891_dcdc2_data,
1263 .initdata=&act8891_dcdc3_data,
1268 struct act8891_platform_data act8891_data={
1269 .set_init=act8891_set_init,
1271 .regulators=act8891_regulator_subdev_id,
1276 /*****************************************************************************************
1278 * author: kfx@rock-chips.com
1279 *****************************************************************************************/
1280 static int rk29_i2c0_io_init(void)
1282 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1283 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
1284 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
1286 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
1287 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
1292 static int rk29_i2c1_io_init(void)
1294 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1295 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
1296 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
1298 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
1299 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
1303 static int rk29_i2c2_io_init(void)
1305 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1306 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
1307 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
1309 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
1310 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
1315 static int rk29_i2c3_io_init(void)
1317 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1318 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
1319 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1321 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
1322 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
1326 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1327 struct rk29_i2c_platform_data default_i2c0_data = {
1331 .scl_rate = 400*1000,
1332 .mode = I2C_MODE_IRQ,
1333 .io_init = rk29_i2c0_io_init,
1336 struct i2c_gpio_platform_data default_i2c0_data = {
1337 .sda_pin = RK29_PIN2_PB6,
1338 .scl_pin = RK29_PIN2_PB7,
1339 .udelay = 5, // clk = 500/udelay = 100Khz
1340 .timeout = 100,//msecs_to_jiffies(200),
1342 .io_init = rk29_i2c0_io_init,
1345 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1346 struct rk29_i2c_platform_data default_i2c1_data = {
1350 .scl_rate = 400*1000,
1351 .mode = I2C_MODE_IRQ,
1352 .io_init = rk29_i2c1_io_init,
1355 struct i2c_gpio_platform_data default_i2c1_data = {
1356 .sda_pin = RK29_PIN1_PA6,
1357 .scl_pin = RK29_PIN1_PA7,
1358 .udelay = 5, // clk = 500/udelay = 100Khz
1359 .timeout = 100,//msecs_to_jiffies(200),
1361 .io_init = rk29_i2c1_io_init,
1364 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1365 struct rk29_i2c_platform_data default_i2c2_data = {
1369 .scl_rate = 400*1000,
1370 .mode = I2C_MODE_IRQ,
1371 .io_init = rk29_i2c2_io_init,
1374 struct i2c_gpio_platform_data default_i2c2_data = {
1375 .sda_pin = RK29_PIN5_PD3,
1376 .scl_pin = RK29_PIN5_PD4,
1377 .udelay = 5, // clk = 500/udelay = 100Khz
1378 .timeout = 100,//msecs_to_jiffies(200),
1380 .io_init = rk29_i2c2_io_init,
1383 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1384 struct rk29_i2c_platform_data default_i2c3_data = {
1388 .scl_rate = 400*1000,
1389 .mode = I2C_MODE_IRQ,
1390 .io_init = rk29_i2c3_io_init,
1393 struct i2c_gpio_platform_data default_i2c3_data = {
1394 .sda_pin = RK29_PIN5_PB5,
1395 .scl_pin = RK29_PIN5_PB4,
1396 .udelay = 5, // clk = 500/udelay = 100Khz
1397 .timeout = 100,//msecs_to_jiffies(200),
1399 .io_init = rk29_i2c3_io_init,
1402 #ifdef CONFIG_I2C0_RK29
1403 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1404 #if defined (CONFIG_RK1000_CONTROL)
1406 .type = "rk1000_control",
1411 #if defined (CONFIG_SND_SOC_alc5621)
1418 #if defined (CONFIG_SND_SOC_alc5631)
1425 #if defined (CONFIG_SND_SOC_RK1000)
1427 .type = "rk1000_i2c_codec",
1432 #if defined (CONFIG_SND_SOC_WM8900)
1439 #if defined (CONFIG_BATTERY_STC3100)
1446 #if defined (CONFIG_BATTERY_BQ27510)
1451 .platform_data = &bq27510_info,
1454 #if defined (CONFIG_RTC_HYM8563)
1456 .type = "rtc_hym8563",
1459 .irq = RK29_PIN0_PA1,
1462 #if defined (CONFIG_GS_MMA8452)
1464 .type = "gs_mma8452",
1467 .irq = MMA8452_INT_PIN,
1468 .platform_data = &mma8452_info,
1471 #if defined (CONFIG_COMPASS_AK8973)
1476 .irq = RK29_PIN0_PA4,
1479 #if defined (CONFIG_COMPASS_AK8975)
1484 .irq = RK29_PIN0_PA4,
1488 #if defined (CONFIG_MPU_SENSORS_MPU3050)
1493 .irq = RK29_PIN5_PA3,
1494 .platform_data = &mpu3050_data,
1497 #if defined (CONFIG_SND_SOC_CS42L52)
1502 .platform_data = &cs42l52_info,
1505 #if defined (CONFIG_RTC_M41T66)
1507 .type = "rtc-M41T66",
1510 .irq = RK29_PIN0_PA1,
1515 #if defined (CONFIG_ANX7150)
1516 struct hdmi_platform_data anx7150_data = {
1517 //.io_init = anx7150_io_init,
1520 #ifdef CONFIG_I2C1_RK29
1521 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1522 #if defined (CONFIG_RK1000_CONTROL1)
1524 .type = "rk1000_control",
1529 #if defined (CONFIG_ANX7150)
1532 .addr = 0x39, //0x39, 0x3d
1534 .irq = RK29_PIN1_PD7,
1535 .platform_data = &anx7150_data,
1538 #ifdef CONFIG_BU92747GUW_CIR
1540 .type ="bu92747_cir",
1543 .irq = BU92747_CIR_IRQ_PIN,
1544 .platform_data = &bu92747guw_pdata,
1551 #ifdef CONFIG_I2C2_RK29
1552 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1553 #if defined (CONFIG_HANNSTAR_P1003)
1555 .type = "p1003_touch",
1557 .flags = 0, //I2C_M_NEED_DELAY
1558 .irq = RK29_PIN0_PA2,
1559 .platform_data = &p1003_info,
1563 #if defined (CONFIG_EETI_EGALAX)
1565 .type = "egalax_i2c",
1568 .irq = RK29_PIN0_PA2,
1569 .platform_data = &eeti_egalax_info,
1572 #if defined (CONFIG_TOUCHSCREEN_GT819)
1574 .type = "Goodix-TS",
1577 .irq =RK29_PIN0_PA2,
1578 .platform_data = &goodix_info,
1581 #if defined (CONFIG_TOUCHSCREEN_FT5406)
1584 .addr = 0x38, //0x70,
1586 .irq =RK29_PIN0_PA2, // support goodix tp detect, 20110706
1587 .platform_data = &ft5406_info,
1593 #ifdef CONFIG_I2C3_RK29
1594 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1595 #if defined (CONFIG_BATTERY_BQ27541)
1600 .platform_data = &bq27541_info,
1603 #if defined (CONFIG_REGULATOR_ACT8891)
1608 .platform_data=&act8891_data,
1615 /*****************************************************************************************
1617 * author: ddl@rock-chips.com
1618 *****************************************************************************************/
1619 #ifdef CONFIG_VIDEO_RK29
1620 #define CONFIG_SENSOR_POWER_IOCTL_USR 0
1621 #define CONFIG_SENSOR_RESET_IOCTL_USR 0
1622 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0
1623 #define CONFIG_SENSOR_FLASH_IOCTL_USR 0
1625 #if CONFIG_SENSOR_POWER_IOCTL_USR
1626 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
1628 #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
1632 #if CONFIG_SENSOR_RESET_IOCTL_USR
1633 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
1635 #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
1639 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1640 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
1642 #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
1646 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1647 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
1649 #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
1653 static struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
1654 #if CONFIG_SENSOR_POWER_IOCTL_USR
1655 .sensor_power_cb = sensor_power_usr_cb,
1657 .sensor_power_cb = NULL,
1660 #if CONFIG_SENSOR_RESET_IOCTL_USR
1661 .sensor_reset_cb = sensor_reset_usr_cb,
1663 .sensor_reset_cb = NULL,
1666 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1667 .sensor_powerdown_cb = sensor_powerdown_usr_cb,
1669 .sensor_powerdown_cb = NULL,
1672 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1673 .sensor_flash_cb = sensor_flash_usr_cb,
1675 .sensor_flash_cb = NULL,
1678 #include "../../../drivers/media/video/rk29_camera.c"
1680 /*****************************************************************************************
1682 * author: nzy@rock-chips.com
1683 *****************************************************************************************/
1684 #ifdef CONFIG_BACKLIGHT_RK29_BL
1686 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
1687 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
1688 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
1689 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
1693 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
1694 #define PWM_MUX_MODE GPIO1L_PWM0
1695 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1696 #define PWM_GPIO RK29_PIN1_PB5
1697 #define PWM_EFFECT_VALUE 1
1699 #define LCD_DISP_ON_PIN
1701 #ifdef LCD_DISP_ON_PIN
1702 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
1703 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
1705 #define BL_EN_PIN RK29_PIN6_PD0
1706 #define BL_EN_VALUE GPIO_HIGH
1708 static int rk29_backlight_io_init(void)
1712 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1713 #ifdef LCD_DISP_ON_PIN
1714 // rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
1716 ret = gpio_request(BL_EN_PIN, NULL);
1719 gpio_free(BL_EN_PIN);
1722 gpio_direction_output(BL_EN_PIN, 0);
1723 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1728 static int rk29_backlight_io_deinit(void)
1731 #ifdef LCD_DISP_ON_PIN
1732 gpio_free(BL_EN_PIN);
1734 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1739 static int rk29_backlight_pwm_suspend(void)
1742 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1743 if (gpio_request(PWM_GPIO, NULL)) {
1744 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
1747 gpio_direction_output(PWM_GPIO, GPIO_LOW);
1748 #ifdef LCD_DISP_ON_PIN
1749 gpio_direction_output(BL_EN_PIN, 0);
1750 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
1755 static int rk29_backlight_pwm_resume(void)
1757 gpio_free(PWM_GPIO);
1758 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1760 #ifdef LCD_DISP_ON_PIN
1762 gpio_direction_output(BL_EN_PIN, 1);
1763 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1768 struct rk29_bl_info rk29_bl_info = {
1770 .bl_ref = PWM_EFFECT_VALUE,
1771 .io_init = rk29_backlight_io_init,
1772 .io_deinit = rk29_backlight_io_deinit,
1773 .pwm_suspend = rk29_backlight_pwm_suspend,
1774 .pwm_resume = rk29_backlight_pwm_resume,
1777 /*****************************************************************************************
1778 * pwm voltage regulator devices
1779 ******************************************************************************************/
1780 #if defined (CONFIG_RK29_PWM_REGULATOR)
1782 #define REGULATOR_PWM_ID 2
1783 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1784 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1785 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1786 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1788 static struct regulator_consumer_supply pwm_consumers[] = {
1794 static struct regulator_init_data rk29_pwm_regulator_data = {
1800 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1802 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1803 .consumer_supplies = pwm_consumers,
1806 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1807 .pwm_id = REGULATOR_PWM_ID,
1808 .pwm_gpio = REGULATOR_PWM_GPIO,
1809 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1810 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1811 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1812 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1813 .init_data = &rk29_pwm_regulator_data,
1816 static struct platform_device rk29_device_pwm_regulator = {
1817 .name = "pwm-voltage-regulator",
1820 .platform_data = &rk29_regulator_pwm_platform_data,
1826 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1827 #define SDMMC0_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin.
1831 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1832 #define SDMMC1_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin.
1835 /*****************************************************************************************
1837 *****************************************************************************************/
1838 #ifdef CONFIG_SDMMC0_RK29
1839 static int rk29_sdmmc0_cfg_gpio(void)
1841 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1842 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1843 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1844 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1845 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1846 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1848 #ifdef CONFIG_SDMMC_RK29_OLD
1849 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
1851 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
1854 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1855 gpio_request(RK29_PIN5_PD5,"sdmmc");
1857 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1859 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1861 gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
1864 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1865 gpio_request(SDMMC0_WRITE_PROTECT_PIN,"sdmmc-wp");
1866 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1872 #define CONFIG_SDMMC0_USE_DMA
1873 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1874 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1875 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1876 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1877 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1878 .io_init = rk29_sdmmc0_cfg_gpio,
1879 .dma_name = "sd_mmc",
1880 #ifdef CONFIG_SDMMC0_USE_DMA
1885 .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
1886 .enable_sd_wakeup = 0,
1888 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1889 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1891 .write_prt = INVALID_GPIO,
1895 #ifdef CONFIG_SDMMC1_RK29
1896 #define CONFIG_SDMMC1_USE_DMA
1897 static int rk29_sdmmc1_cfg_gpio(void)
1899 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1900 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1901 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1902 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1903 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1904 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1905 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1907 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1908 gpio_request(SDMMC1_WRITE_PROTECT_PIN,"sdio-wp");
1909 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1914 #ifdef CONFIG_WIFI_CONTROL_FUNC
1915 static int rk29sdk_wifi_status(struct device *dev);
1916 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1919 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1921 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1922 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1923 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1924 MMC_VDD_32_33|MMC_VDD_33_34),
1925 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1926 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1927 .io_init = rk29_sdmmc1_cfg_gpio,
1929 #ifdef CONFIG_SDMMC1_USE_DMA
1934 #ifdef CONFIG_WIFI_CONTROL_FUNC
1935 .status = rk29sdk_wifi_status,
1936 .register_status_notify = rk29sdk_wifi_status_register,
1939 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1942 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1943 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1945 .write_prt = INVALID_GPIO,
1951 #ifdef CONFIG_WIFI_CONTROL_FUNC
1952 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1953 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1954 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1956 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1957 static void (*wifi_status_cb)(int card_present, void *dev_id);
1958 static void *wifi_status_cb_devid;
1959 int rk29sdk_wifi_power_state = 0;
1960 int rk29sdk_bt_power_state = 0;
1962 static int rk29sdk_wifi_status(struct device *dev)
1964 return rk29sdk_wifi_cd;
1967 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1971 wifi_status_cb = callback;
1972 wifi_status_cb_devid = dev_id;
1976 static int rk29sdk_wifi_bt_gpio_control_init(void)
1978 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1979 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1983 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1984 pr_info("%s: request wifi reset gpio failed\n", __func__);
1985 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1989 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1990 pr_info("%s: request bt reset gpio failed\n", __func__);
1991 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1995 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1996 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1997 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1999 pr_info("%s: init finished\n",__func__);
2004 static int rk29sdk_wifi_power(int on)
2006 pr_info("%s: %d\n", __func__, on);
2008 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
2009 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
2011 pr_info("wifi turn on power\n");
2013 if (!rk29sdk_bt_power_state){
2014 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2016 pr_info("wifi shut off power\n");
2019 pr_info("wifi shouldn't shut off power, bt is using it!\n");
2021 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2025 rk29sdk_wifi_power_state = on;
2029 static int rk29sdk_wifi_reset_state;
2030 static int rk29sdk_wifi_reset(int on)
2032 pr_info("%s: %d\n", __func__, on);
2033 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
2035 rk29sdk_wifi_reset_state = on;
2039 int rk29sdk_wifi_set_carddetect(int val)
2041 pr_info("%s:%d\n", __func__, val);
2042 rk29sdk_wifi_cd = val;
2043 if (wifi_status_cb){
2044 wifi_status_cb(val, wifi_status_cb_devid);
2046 pr_warning("%s, nobody to notify\n", __func__);
2050 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
2052 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
2053 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
2054 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
2055 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
2056 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
2059 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
2061 if (section == PREALLOC_WLAN_SEC_NUM)
2062 return wlan_static_skb;
2064 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
2067 if (wifi_mem_array[section].size < size)
2070 return wifi_mem_array[section].mem_ptr;
2073 int __init rk29sdk_init_wifi_mem(void)
2078 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
2079 wlan_static_skb[i] = dev_alloc_skb(
2080 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
2082 if (!wlan_static_skb[i])
2086 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
2087 wifi_mem_array[i].mem_ptr =
2088 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
2090 if (!wifi_mem_array[i].mem_ptr)
2096 pr_err("Failed to mem_alloc for WLAN\n");
2097 for (j = 0 ; j < i ; j++)
2098 kfree(wifi_mem_array[j].mem_ptr);
2100 i = WLAN_SKB_BUF_NUM;
2103 pr_err("Failed to skb_alloc for WLAN\n");
2104 for (j = 0 ; j < i ; j++)
2105 dev_kfree_skb(wlan_static_skb[j]);
2110 static struct wifi_platform_data rk29sdk_wifi_control = {
2111 .set_power = rk29sdk_wifi_power,
2112 .set_reset = rk29sdk_wifi_reset,
2113 .set_carddetect = rk29sdk_wifi_set_carddetect,
2114 .mem_prealloc = rk29sdk_mem_prealloc,
2116 static struct platform_device rk29sdk_wifi_device = {
2117 .name = "bcm4329_wlan",
2120 .platform_data = &rk29sdk_wifi_control,
2126 /* bluetooth rfkill device */
2127 static struct platform_device rk29sdk_rfkill = {
2128 .name = "rk29sdk_rfkill",
2133 #ifdef CONFIG_VIVANTE
2134 #define GPU_HIGH_CLOCK 552
2135 #define GPU_LOW_CLOCK (periph_pll_default / 1000000) /* same as general pll clock rate below */
2136 static struct resource resources_gpu[] = {
2141 .flags = IORESOURCE_IRQ,
2145 .start = RK29_GPU_PHYS,
2146 .end = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
2147 .flags = IORESOURCE_MEM,
2151 .start = PMEM_GPU_BASE,
2152 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
2153 .flags = IORESOURCE_MEM,
2157 .start = GPU_LOW_CLOCK,
2158 .end = GPU_HIGH_CLOCK,
2159 .flags = IORESOURCE_IO,
2162 static struct platform_device rk29_device_gpu = {
2165 .num_resources = ARRAY_SIZE(resources_gpu),
2166 .resource = resources_gpu,
2170 #ifdef CONFIG_KEYS_RK29
2171 extern struct rk29_keys_platform_data rk29_keys_pdata;
2172 static struct platform_device rk29_device_keys = {
2173 .name = "rk29-keypad",
2176 .platform_data = &rk29_keys_pdata,
2181 #ifdef CONFIG_LEDS_GPIO_PLATFORM
2182 struct gpio_led rk29_leds[] = {
2184 .name = "rk29_red_led",
2185 .gpio = RK29_PIN4_PB2,
2186 .default_trigger = "timer",
2188 .retain_state_suspended = 1,
2189 .default_state = LEDS_GPIO_DEFSTATE_OFF,
2192 .name = "rk29_green_led",
2193 .gpio = RK29_PIN4_PB1,
2194 .default_trigger = "timer",
2196 .retain_state_suspended = 1,
2197 .default_state = LEDS_GPIO_DEFSTATE_OFF,
2200 .name = "rk29_blue_led",
2201 .gpio = RK29_PIN4_PB0,
2202 .default_trigger = "timer",
2204 .retain_state_suspended = 1,
2205 .default_state = LEDS_GPIO_DEFSTATE_OFF,
2209 struct gpio_led_platform_data rk29_leds_pdata = {
2211 .num_leds = ARRAY_SIZE(rk29_leds),
2214 struct platform_device rk29_device_gpio_leds = {
2215 .name = "leds-gpio",
2218 .platform_data = &rk29_leds_pdata,
2223 #ifdef CONFIG_LEDS_NEWTON_PWM
2224 static struct led_newton_pwm rk29_pwm_leds[] = {
2226 .name = "power_led",
2228 .pwm_gpio = RK29_PIN5_PD2,
2229 .pwm_iomux_name = GPIO5D2_PWM1_UART1SIRIN_NAME,
2230 .pwm_iomux_pwm = GPIO5H_PWM1,
2231 .pwm_iomux_gpio = GPIO5H_GPIO5D2,
2237 static struct led_newton_pwm_platform_data rk29_pwm_leds_pdata = {
2238 .leds = &rk29_pwm_leds,
2239 .num_leds = ARRAY_SIZE(rk29_pwm_leds),
2242 static struct platform_device rk29_device_pwm_leds = {
2243 .name = "leds_newton_pwm",
2246 .platform_data = &rk29_pwm_leds_pdata,
2251 static void __init rk29_board_iomux_init(void)
2253 #ifdef CONFIG_RK29_PWM_REGULATOR
2254 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
2258 static struct platform_device *devices[] __initdata = {
2260 #ifdef CONFIG_RK29_WATCHDOG
2264 #ifdef CONFIG_UART1_RK29
2267 #ifdef CONFIG_UART0_RK29
2270 #ifdef CONFIG_UART2_RK29
2273 #ifdef CONFIG_UART3_RK29
2277 #ifdef CONFIG_RK29_PWM_REGULATOR
2278 &rk29_device_pwm_regulator,
2280 #ifdef CONFIG_SPIM0_RK29
2281 &rk29xx_device_spi0m,
2283 #ifdef CONFIG_SPIM1_RK29
2284 &rk29xx_device_spi1m,
2286 #ifdef CONFIG_ADC_RK29
2289 #ifdef CONFIG_I2C0_RK29
2292 #ifdef CONFIG_I2C1_RK29
2295 #ifdef CONFIG_I2C2_RK29
2298 #ifdef CONFIG_I2C3_RK29
2302 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
2303 &rk29_device_iis_2ch,
2305 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
2306 &rk29_device_iis_8ch,
2309 #ifdef CONFIG_KEYS_RK29
2312 #ifdef CONFIG_KEYS_RK29_NEWTON
2315 #ifdef CONFIG_SDMMC0_RK29
2316 &rk29_device_sdmmc0,
2318 #ifdef CONFIG_SDMMC1_RK29
2319 &rk29_device_sdmmc1,
2322 #ifdef CONFIG_MTD_NAND_RK29XX
2323 &rk29xx_device_nand,
2326 #ifdef CONFIG_WIFI_CONTROL_FUNC
2327 &rk29sdk_wifi_device,
2334 #ifdef CONFIG_MTD_NAND_RK29
2338 #ifdef CONFIG_FB_RK29
2340 &rk29_device_dma_cpy,
2342 #ifdef CONFIG_BACKLIGHT_RK29_BL
2343 &rk29_device_backlight,
2345 #ifdef CONFIG_BACKLIGHT_RK29_NEWTON_BL
2346 &rk29_device_backlight,
2348 #ifdef CONFIG_RK29_VMAC
2351 #ifdef CONFIG_VIVANTE
2354 #ifdef CONFIG_VIDEO_RK29
2355 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
2356 #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
2357 &rk29_soc_camera_pdrv_0,
2359 &rk29_soc_camera_pdrv_1,
2360 &android_pmem_cam_device,
2362 #if PMEM_SKYPE_SIZE > 0
2363 &android_pmem_skype_device,
2365 &android_pmem_device,
2366 &rk29_vpu_mem_device,
2367 #ifdef CONFIG_USB20_OTG
2368 &rk29_device_usb20_otg,
2370 #ifdef CONFIG_USB20_HOST
2371 &rk29_device_usb20_host,
2373 #ifdef CONFIG_USB11_HOST
2374 &rk29_device_usb11_host,
2376 #ifdef CONFIG_USB_ANDROID
2377 &android_usb_device,
2378 &usb_mass_storage_device,
2380 #ifdef CONFIG_USB_ANDROID_RNDIS
2383 #ifdef CONFIG_RK29_IPP
2386 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2387 &rk29_v4l2_output_devce,
2389 #ifdef CONFIG_RK29_NEWTON
2390 &rk29_device_newton,
2392 #ifdef CONFIG_RK_IRDA
2395 #ifdef CONFIG_LEDS_GPIO_PLATFORM
2396 &rk29_device_gpio_leds,
2398 #ifdef CONFIG_LEDS_NEWTON_PWM
2399 &rk29_device_pwm_leds,
2401 #ifdef CONFIG_SND_RK29_SOC_CS42L52
2402 &rk29_cs42l52_device,
2406 /*****************************************************************************************
2408 * author: cmc@rock-chips.com
2409 *****************************************************************************************/
2410 static int rk29_vmac_register_set(void)
2412 //config rk29 vmac as rmii, 100MHz
2413 u32 value= readl(RK29_GRF_BASE + 0xbc);
2414 value = (value & 0xfff7ff) | (0x400);
2415 writel(value, RK29_GRF_BASE + 0xbc);
2419 static int rk29_rmii_io_init(void)
2424 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2426 gpio_free(RK29_PIN6_PB0);
2427 printk("-------request RK29_PIN6_PB0 fail--------\n");
2431 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2432 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2437 static int rk29_rmii_io_deinit(void)
2440 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2441 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2443 gpio_free(RK29_PIN6_PB0);
2447 static int rk29_rmii_power_control(int enable)
2451 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2452 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2455 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2456 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2461 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2462 .vmac_register_set = rk29_vmac_register_set,
2463 .rmii_io_init = rk29_rmii_io_init,
2464 .rmii_io_deinit = rk29_rmii_io_deinit,
2465 .rmii_power_control = rk29_rmii_power_control,
2468 /*****************************************************************************************
2470 * author: cmc@rock-chips.com
2471 *****************************************************************************************/
2472 #define SPI_CHIPSELECT_NUM 2
2473 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2476 .cs_gpio = RK29_PIN2_PC1,
2477 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2478 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2482 .cs_gpio = RK29_PIN1_PA4,
2483 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2484 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2488 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2491 .cs_gpio = RK29_PIN2_PC5,
2492 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2493 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2497 .cs_gpio = RK29_PIN1_PA3,
2498 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2499 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2503 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2508 for (i=0; i<cs_num; i++) {
2509 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2516 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2521 static int spi_io_fix_leakage_bug(void)
2524 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2529 static int spi_io_resume_leakage_bug(void)
2532 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2537 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2538 .num_chipselect = SPI_CHIPSELECT_NUM,
2539 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2540 .io_init = spi_io_init,
2541 .io_deinit = spi_io_deinit,
2542 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2543 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2546 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2547 .num_chipselect = SPI_CHIPSELECT_NUM,
2548 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2549 .io_init = spi_io_init,
2550 .io_deinit = spi_io_deinit,
2551 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2552 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2555 /*****************************************************************************************
2556 * xpt2046 touch panel
2557 * author: cmc@rock-chips.com
2558 *****************************************************************************************/
2559 #define XPT2046_GPIO_INT RK29_PIN0_PA3
2560 #define DEBOUNCE_REPTIME 3
2562 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
2563 static struct xpt2046_platform_data xpt2046_info = {
2572 .debounce_rep = DEBOUNCE_REPTIME,
2574 .gpio_pendown = XPT2046_GPIO_INT,
2575 .penirq_recheck_delay_usecs = 1,
2577 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
2578 static struct xpt2046_platform_data xpt2046_info = {
2587 .debounce_rep = DEBOUNCE_REPTIME,
2589 .gpio_pendown = XPT2046_GPIO_INT,
2590 .penirq_recheck_delay_usecs = 1,
2592 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2593 static struct xpt2046_platform_data xpt2046_info = {
2602 .debounce_rep = DEBOUNCE_REPTIME,
2604 .gpio_pendown = XPT2046_GPIO_INT,
2606 .penirq_recheck_delay_usecs = 1,
2608 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2609 static struct xpt2046_platform_data xpt2046_info = {
2618 .debounce_rep = DEBOUNCE_REPTIME,
2620 .gpio_pendown = XPT2046_GPIO_INT,
2622 .penirq_recheck_delay_usecs = 1,
2626 static struct spi_board_info board_spi_devices[] = {
2627 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
2628 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2630 .modalias = "xpt2046_ts",
2632 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2634 .irq = XPT2046_GPIO_INT,
2635 .platform_data = &xpt2046_info,
2641 static void __init rk29_gic_init_irq(void)
2643 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2644 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2647 static void __init machine_rk29_init_irq(void)
2649 rk29_gic_init_irq();
2653 static struct cpufreq_frequency_table freq_table[] = {
2654 { .index = 1200000, .frequency = 408000 },
2655 { .index = 1200000, .frequency = 816000 },
2656 { .index = 1300000, .frequency = 1008000 },
2657 { .frequency = CPUFREQ_TABLE_END },
2660 static void __init machine_rk29_board_init(void)
2662 rk29_board_iomux_init();
2665 board_update_cpufreq_table(freq_table);
2667 platform_add_devices(devices, ARRAY_SIZE(devices));
2668 #ifdef CONFIG_I2C0_RK29
2669 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2670 ARRAY_SIZE(board_i2c0_devices));
2672 #ifdef CONFIG_I2C1_RK29
2673 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2674 ARRAY_SIZE(board_i2c1_devices));
2676 #ifdef CONFIG_I2C2_RK29
2677 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2678 ARRAY_SIZE(board_i2c2_devices));
2680 #ifdef CONFIG_I2C3_RK29
2681 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2682 ARRAY_SIZE(board_i2c3_devices));
2685 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2687 #ifdef CONFIG_WIFI_CONTROL_FUNC
2688 rk29sdk_wifi_bt_gpio_control_init();
2689 rk29sdk_init_wifi_mem();
2692 board_usb_detect_init(RK29_PIN0_PA0);
2693 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
2695 bu92747guw_io_init();
2700 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2701 char **cmdline, struct meminfo *mi)
2704 mi->bank[0].start = RK29_SDRAM_PHYS;
2705 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
2706 mi->bank[0].size = LINUX_SIZE;
2707 #if SDRAM_SIZE > SZ_512M
2709 mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
2710 mi->bank[1].size = SDRAM_SIZE - SZ_512M;
2714 static void __init machine_rk29_mapio(void)
2716 rk29_map_common_io();
2717 rk29_setup_early_printk();
2719 rk29_clock_init(periph_pll_default);
2721 ddr_init(DDR_TYPE, DDR_FREQ);
2724 MACHINE_START(RK29, "RK29board")
2725 /* UART for LL DEBUG */
2726 .phys_io = RK29_UART1_PHYS & 0xfff00000,
2727 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2728 .boot_params = RK29_SDRAM_PHYS + 0x88000,
2729 .fixup = machine_rk29_fixup,
2730 .map_io = machine_rk29_mapio,
2731 .init_irq = machine_rk29_init_irq,
2732 .init_machine = machine_rk29_board_init,
2733 .timer = &rk29_timer,