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/mtd/nand.h>
54 #include <linux/mtd/partitions.h>
55 #include <linux/i2c-gpio.h>
58 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
60 #ifdef CONFIG_BU92747GUW_CIR
61 #include "../../../drivers/cir/bu92747guw_cir.h"
63 #ifdef CONFIG_VIDEO_RK29
64 /*---------------- Camera Sensor Macro Define Begin ------------------------*/
65 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
66 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642 /* back camera sensor */
67 #define CONFIG_SENSOR_IIC_ADDR_0 0x78
68 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0 1
69 #define CONFIG_SENSOR_POWER_PIN_0 INVALID_GPIO
70 #define CONFIG_SENSOR_RESET_PIN_0 INVALID_GPIO
71 #define CONFIG_SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
72 #define CONFIG_SENSOR_FALSH_PIN_0 INVALID_GPIO
73 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
74 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
75 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
76 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
78 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659 /* front camera sensor */
79 #define CONFIG_SENSOR_IIC_ADDR_1 0x60
80 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1 1
81 #define CONFIG_SENSOR_POWER_PIN_1 INVALID_GPIO
82 #define CONFIG_SENSOR_RESET_PIN_1 INVALID_GPIO
83 #define CONFIG_SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
84 #define CONFIG_SENSOR_FALSH_PIN_1 INVALID_GPIO
85 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
86 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
87 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
88 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
89 #endif //#ifdef CONFIG_VIDEO_RK29
90 /*---------------- Camera Sensor Configuration Macro End------------------------*/
91 #include "../../../drivers/media/video/rk29_camera.c"
92 /*---------------- Camera Sensor Macro Define End ------------------------*/
95 /* Set memory size of pmem */
96 #ifdef CONFIG_RK29_MEM_SIZE_M
97 #define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
99 #define SDRAM_SIZE SZ_512M
101 #define PMEM_GPU_SIZE SZ_16M
102 #define PMEM_UI_SIZE (48 * SZ_1M) /* 1280x800: 64M 1024x768: 48M ... */
103 #define PMEM_VPU_SIZE SZ_64M
104 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
105 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
106 #define MEM_CAMIPP_SIZE SZ_4M
108 #define MEM_CAMIPP_SIZE 0
110 #define MEM_FB_SIZE (3*SZ_2M)
111 #ifdef CONFIG_FB_WORK_IPP
112 #ifdef CONFIG_FB_SCALING_OSD_1080P
113 #define MEM_FBIPP_SIZE SZ_16M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4
115 #define MEM_FBIPP_SIZE SZ_8M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4
118 #define MEM_FBIPP_SIZE 0
120 #if SDRAM_SIZE > SZ_512M
121 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
123 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
125 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
126 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
127 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
128 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
129 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
130 #define MEM_FBIPP_BASE (MEM_FB_BASE - MEM_FBIPP_SIZE)
131 #define LINUX_SIZE (MEM_FBIPP_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 INVALID_GPIO
166 #define TOUCH_SCREEN_STANDBY_VALUE GPIO_HIGH
167 #define TOUCH_SCREEN_DISPLAY_PIN INVALID_GPIO
168 #define TOUCH_SCREEN_DISPLAY_VALUE GPIO_HIGH
169 #ifdef CONFIG_FB_RK29
170 /*****************************************************************************************
172 * author: zyw@rock-chips.com
173 *****************************************************************************************/
174 #define LCD_TXD_PIN INVALID_GPIO
175 #define LCD_CLK_PIN INVALID_GPIO
176 #define LCD_CS_PIN INVALID_GPIO
177 /*****************************************************************************************
178 * frame buffer devices pin define
179 * author: zyw@rock-chips.com
180 *****************************************************************************************/
182 #define FB_DISPLAY_ON_PIN INVALID_GPIO// RK29_PIN6_PD0
183 #define FB_LCD_STANDBY_PIN RK29_PIN6_PD1
184 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
185 #define FB_MCU_FMK_PIN INVALID_GPIO
187 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
188 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
190 static int rk29_lcd_io_init(void)
196 static int rk29_lcd_io_deinit(void)
202 static struct rk29lcd_info rk29_lcd_info = {
203 .txd_pin = LCD_TXD_PIN,
204 .clk_pin = LCD_CLK_PIN,
205 .cs_pin = LCD_CS_PIN,
206 .io_init = rk29_lcd_io_init,
207 .io_deinit = rk29_lcd_io_deinit,
210 int rk29_fb_io_enable(void)
212 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
214 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
215 gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);
217 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
219 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
220 gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);
225 int rk29_fb_io_disable(void)
227 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
229 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
230 gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);
232 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
234 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
235 gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);
240 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
243 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
245 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
248 gpio_free(FB_MCU_FMK_PIN);
249 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
251 gpio_direction_input(FB_MCU_FMK_PIN);
253 if(fb_setting->disp_on_en)
255 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
257 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
260 gpio_free(FB_DISPLAY_ON_PIN);
261 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
266 ret = gpio_request(TOUCH_SCREEN_DISPLAY_PIN, NULL);
269 gpio_free(TOUCH_SCREEN_DISPLAY_PIN);
270 printk(">>>>>> TOUCH_SCREEN_DISPLAY_PIN gpio_request err \n ");
272 gpio_direction_output(TOUCH_SCREEN_DISPLAY_PIN, 0);
273 gpio_set_value(TOUCH_SCREEN_DISPLAY_PIN, TOUCH_SCREEN_DISPLAY_VALUE);
277 if(fb_setting->disp_on_en)
279 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
281 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
284 gpio_free(FB_LCD_STANDBY_PIN);
285 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
290 ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL);
293 gpio_free(TOUCH_SCREEN_STANDBY_PIN);
294 printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n ");
296 gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0);
297 gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE);
301 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
303 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
306 gpio_free(FB_LCD_CABC_EN_PIN);
307 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
309 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
310 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
313 rk29_fb_io_enable(); //enable it
319 static struct rk29fb_info rk29_fb_info = {
321 .mcu_fmk_pin = FB_MCU_FMK_PIN,
322 .lcd_info = &rk29_lcd_info,
323 .io_init = rk29_fb_io_init,
324 .io_enable = rk29_fb_io_enable,
325 .io_disable = rk29_fb_io_disable,
328 /* rk29 fb resource */
329 static struct resource rk29_fb_resource[] = {
332 .start = RK29_LCDC_PHYS,
333 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
334 .flags = IORESOURCE_MEM,
340 .flags = IORESOURCE_IRQ,
344 .start = MEM_FB_BASE,
345 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
346 .flags = IORESOURCE_MEM,
348 #ifdef CONFIG_FB_WORK_IPP
350 .name = "win1 ipp buf",
351 .start = MEM_FBIPP_BASE,
352 .end = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
353 .flags = IORESOURCE_MEM,
359 struct platform_device rk29_device_fb = {
362 .num_resources = ARRAY_SIZE(rk29_fb_resource),
363 .resource = rk29_fb_resource,
365 .platform_data = &rk29_fb_info,
369 struct platform_device rk29_device_dma_cpy = {
370 .name = "dma_memcpy",
377 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
378 #define BU92747GUW_RESET_PIN RK29_PIN3_PD4// INVALID_GPIO //
379 #define BU92747GUW_RESET_MUX_NAME GPIO3D4_HOSTWRN_NAME//NULL //
380 #define BU92747GUW_RESET_MUX_MODE GPIO3H_GPIO3D4//NULL //
382 #define BU92747GUW_PWDN_PIN RK29_PIN3_PD3//RK29_PIN5_PA7 //
383 #define BU92747GUW_PWDN_MUX_NAME GPIO3D3_HOSTRDN_NAME//GPIO5A7_HSADCDATA2_NAME //
384 #define BU92747GUW_PWDN_MUX_MODE GPIO3H_GPIO3D3//GPIO5L_GPIO5A7 //
386 static int bu92747guw_io_init(void)
391 if(BU92747GUW_RESET_MUX_NAME != NULL)
393 rk29_mux_api_set(BU92747GUW_RESET_MUX_NAME, BU92747GUW_RESET_MUX_MODE);
395 ret = gpio_request(BU92747GUW_RESET_PIN, NULL);
398 gpio_free(BU92747GUW_RESET_PIN);
399 printk(">>>>>> BU92747GUW_RESET_PIN gpio_request err \n ");
401 gpio_direction_output(BU92747GUW_RESET_PIN, GPIO_HIGH);
404 if(BU92747GUW_PWDN_MUX_NAME != NULL)
406 rk29_mux_api_set(BU92747GUW_PWDN_MUX_NAME, BU92747GUW_PWDN_MUX_MODE);
408 ret = gpio_request(BU92747GUW_PWDN_PIN, NULL);
411 gpio_free(BU92747GUW_PWDN_PIN);
412 printk(">>>>>> BU92747GUW_PWDN_PIN gpio_request err \n ");
415 //power down as default
416 gpio_direction_output(BU92747GUW_PWDN_PIN, GPIO_LOW);
422 static int bu92747guw_io_deinit(void)
424 gpio_free(BU92747GUW_PWDN_PIN);
425 gpio_free(BU92747GUW_RESET_PIN);
429 //power ctl func is share with irda and remote
430 static int nPowerOnCount = 0;
431 static DEFINE_MUTEX(bu92747_power_mutex);
433 //1---power on; 0---power off
434 static int bu92747guw_power_ctl(int enable)
436 printk("%s \n",__FUNCTION__);
438 mutex_lock(&bu92747_power_mutex);
441 if (nPowerOnCount == 1) {//power on first
443 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_HIGH);
444 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_LOW);
446 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_HIGH);
452 if (nPowerOnCount <= 0) {//power down final
455 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_LOW);
458 mutex_unlock(&bu92747_power_mutex);
463 #ifdef CONFIG_RK_IRDA
464 #define IRDA_IRQ_PIN RK29_PIN5_PB2
465 #define IRDA_IRQ_MUX_NAME GPIO5B2_HSADCDATA5_NAME
466 #define IRDA_IRQ_MUX_MODE GPIO5L_GPIO5B2
468 int irda_iomux_init(void)
473 if(IRDA_IRQ_MUX_NAME != NULL)
475 rk29_mux_api_set(IRDA_IRQ_MUX_NAME, IRDA_IRQ_MUX_MODE);
477 ret = gpio_request(IRDA_IRQ_PIN, NULL);
480 gpio_free(IRDA_IRQ_PIN);
481 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
483 gpio_pull_updown(IRDA_IRQ_PIN, GPIO_HIGH);
484 gpio_direction_input(IRDA_IRQ_PIN);
489 int irda_iomux_deinit(void)
491 gpio_free(IRDA_IRQ_PIN);
495 static struct irda_info rk29_irda_info = {
496 .intr_pin = IRDA_IRQ_PIN,
497 .iomux_init = irda_iomux_init,
498 .iomux_deinit = irda_iomux_deinit,
499 .irda_pwr_ctl = bu92747guw_power_ctl,
502 static struct platform_device irda_device = {
503 #ifdef CONFIG_RK_IRDA_NET
506 .name = "bu92747_irda",
510 .platform_data = &rk29_irda_info,
515 #ifdef CONFIG_BU92747GUW_CIR
516 #define BU92747_CIR_IRQ_PIN RK29_PIN5_PB0
517 #define CIR_IRQ_PIN_IOMUX_NAME GPIO5B0_HSADCDATA3_NAME
518 #define CIR_IRQ_PIN_IOMUX_VALUE GPIO5L_GPIO5B0
519 static int cir_iomux_init(void)
521 if (CIR_IRQ_PIN_IOMUX_NAME)
522 rk29_mux_api_set(CIR_IRQ_PIN_IOMUX_NAME, CIR_IRQ_PIN_IOMUX_VALUE);
523 rk29_mux_api_set(GPIO5A7_HSADCDATA2_NAME, GPIO5L_GPIO5A7);
527 static struct bu92747guw_platform_data bu92747guw_pdata = {
528 .intr_pin = BU92747_CIR_IRQ_PIN,
529 .iomux_init = cir_iomux_init,
530 .iomux_deinit = NULL,
531 .cir_pwr_ctl = bu92747guw_power_ctl,
534 #ifdef CONFIG_RK29_NEWTON
535 struct rk29_newton_data rk29_newton_info = {
537 struct platform_device rk29_device_newton = {
538 .name = "rk29_newton",
541 .platform_data = &rk29_newton_info,
545 #if defined (CONFIG_TOUCHSCREEN_FT5406)
546 #define TOUCH_RESET_PIN RK29_PIN6_PC3
547 #define TOUCH_INT_PIN RK29_PIN0_PA2
548 int ft5406_init_platform_hw(void)
550 printk("ft5406_init_platform_hw\n");
551 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
552 gpio_free(TOUCH_RESET_PIN);
553 printk("ft5406_init_platform_hw gpio_request error\n");
557 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
558 gpio_free(TOUCH_INT_PIN);
559 printk("ift5406_init_platform_hw gpio_request error\n");
563 gpio_direction_output(TOUCH_RESET_PIN, 0);
564 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
566 gpio_direction_input(TOUCH_INT_PIN);
568 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
573 void ft5406_exit_platform_hw(void)
575 printk("ft5406_exit_platform_hw\n");
576 gpio_free(TOUCH_RESET_PIN);
577 gpio_free(TOUCH_INT_PIN);
580 int ft5406_platform_sleep(void)
582 printk("ft5406_platform_sleep\n");
583 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
587 int ft5406_platform_wakeup(void)
589 printk("ft5406_platform_wakeup\n");
590 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
595 struct ft5406_platform_data ft5406_info = {
597 .init_platform_hw= ft5406_init_platform_hw,
598 .exit_platform_hw= ft5406_exit_platform_hw,
599 .platform_sleep = ft5406_platform_sleep,
600 .platform_wakeup = ft5406_platform_wakeup,
605 #if defined(CONFIG_TOUCHSCREEN_GT819)
606 #define TOUCH_RESET_PIN RK29_PIN6_PC3
607 #define TOUCH_INT_PIN RK29_PIN0_PA2
608 int gt819_init_platform_hw(void)
610 printk("gt819_init_platform_hw\n");
611 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
612 gpio_free(TOUCH_RESET_PIN);
613 printk("gt819_init_platform_hw gpio_request error\n");
617 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
618 gpio_free(TOUCH_INT_PIN);
619 printk("gt819_init_platform_hw gpio_request error\n");
622 gpio_direction_output(TOUCH_RESET_PIN, 0);
623 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
625 // gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
627 // gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
628 gpio_direction_input(TOUCH_INT_PIN);
630 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
636 void gt819_exit_platform_hw(void)
638 printk("gt819_exit_platform_hw\n");
639 gpio_free(TOUCH_RESET_PIN);
640 gpio_free(TOUCH_INT_PIN);
643 int gt819_platform_sleep(void)
645 printk("gt819_platform_sleep\n");
646 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
650 int gt819_platform_wakeup(void)
652 printk("gt819_platform_wakeup\n");
653 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
655 //gpio_set_value(TOUCH_INT_PIN, GPIO_LOW);
657 //gpio_set_value(TOUCH_INT_PIN, GPIO_HIGH);
660 struct goodix_platform_data goodix_info = {
662 .init_platform_hw= gt819_init_platform_hw,
663 .exit_platform_hw= gt819_exit_platform_hw,
664 .platform_sleep = gt819_platform_sleep,
665 .platform_wakeup = gt819_platform_wakeup,
671 #if defined (CONFIG_SND_SOC_CS42L52)
673 int cs42l52_init_platform_hw()
675 printk("cs42l52_init_platform_hw\n");
676 if(gpio_request(RK29_PIN6_PB6,NULL) != 0){
677 gpio_free(RK29_PIN6_PB6);
678 printk("cs42l52_init_platform_hw gpio_request error\n");
681 gpio_direction_output(RK29_PIN6_PB6, 0);
682 gpio_set_value(RK29_PIN6_PB6,GPIO_HIGH);
685 struct cs42l52_platform_data cs42l52_info = {
687 .init_platform_hw= cs42l52_init_platform_hw,
691 #if defined (CONFIG_BATTERY_BQ27541)
692 #define DC_CHECK_PIN RK29_PIN4_PA1
693 #define LI_LION_BAT_NUM 1
694 #define CHG_OK RK29_PIN4_PA3
695 #define BAT_LOW RK29_PIN4_PA2
697 static int bq27541_init_dc_check_pin(void){
698 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
699 gpio_free(DC_CHECK_PIN);
700 printk("bq27541 init dc check pin request error\n");
703 gpio_direction_input(DC_CHECK_PIN);
707 struct bq27541_platform_data bq27541_info = {
708 .init_dc_check_pin = bq27541_init_dc_check_pin,
709 .dc_check_pin = DC_CHECK_PIN,
710 .bat_num = LI_LION_BAT_NUM,
711 .chgok_check_pin = CHG_OK,
712 .bat_check_pin = BAT_LOW,
715 static struct android_pmem_platform_data android_pmem_pdata = {
717 .start = PMEM_UI_BASE,
718 .size = PMEM_UI_SIZE,
723 static struct platform_device android_pmem_device = {
724 .name = "android_pmem",
727 .platform_data = &android_pmem_pdata,
732 static struct vpu_mem_platform_data vpu_mem_pdata = {
734 .start = PMEM_VPU_BASE,
735 .size = PMEM_VPU_SIZE,
739 static struct platform_device rk29_vpu_mem_device = {
743 .platform_data = &vpu_mem_pdata,
746 #ifdef CONFIG_VIDEO_RK29XX_VOUT
747 static struct platform_device rk29_v4l2_output_devce = {
751 /*HANNSTAR_P1003 touch*/
752 #if defined (CONFIG_HANNSTAR_P1003)
753 #define TOUCH_RESET_PIN RK29_PIN6_PC3
754 #define TOUCH_INT_PIN RK29_PIN0_PA2
756 int p1003_init_platform_hw(void)
758 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
759 gpio_free(TOUCH_RESET_PIN);
760 printk("p1003_init_platform_hw gpio_request error\n");
764 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
765 gpio_free(TOUCH_INT_PIN);
766 printk("p1003_init_platform_hw gpio_request error\n");
769 gpio_pull_updown(TOUCH_INT_PIN, 1);
770 gpio_direction_output(TOUCH_RESET_PIN, 0);
772 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
774 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
780 struct p1003_platform_data p1003_info = {
782 .init_platform_hw= p1003_init_platform_hw,
786 #if defined (CONFIG_EETI_EGALAX)
787 #define TOUCH_RESET_PIN RK29_PIN6_PC3
788 #define TOUCH_INT_PIN RK29_PIN0_PA2
790 static int EETI_EGALAX_init_platform_hw(void)
792 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
793 gpio_free(TOUCH_RESET_PIN);
794 printk("p1003_init_platform_hw gpio_request error\n");
798 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
799 gpio_free(TOUCH_INT_PIN);
800 printk("p1003_init_platform_hw gpio_request error\n");
803 gpio_pull_updown(TOUCH_INT_PIN, 1);
804 gpio_direction_output(TOUCH_RESET_PIN, 0);
806 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
808 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
814 static struct eeti_egalax_platform_data eeti_egalax_info = {
816 .init_platform_hw= EETI_EGALAX_init_platform_hw,
817 .standby_pin = TOUCH_SCREEN_STANDBY_PIN,
818 .standby_value = TOUCH_SCREEN_STANDBY_VALUE,
819 .disp_on_pin = TOUCH_SCREEN_DISPLAY_PIN,
820 .disp_on_value = TOUCH_SCREEN_DISPLAY_VALUE,
824 #ifdef CONFIG_GS_KXTF9
825 #include <linux/kxtf9.h>
826 #define KXTF9_DEVICE_MAP 1
827 #define KXTF9_MAP_X (KXTF9_DEVICE_MAP-1)%2
828 #define KXTF9_MAP_Y KXTF9_DEVICE_MAP%2
829 #define KXTF9_NEG_X (KXTF9_DEVICE_MAP/2)%2
830 #define KXTF9_NEG_Y (KXTF9_DEVICE_MAP+1)/4
831 #define KXTF9_NEG_Z (KXTF9_DEVICE_MAP-1)/4
832 struct kxtf9_platform_data kxtf9_pdata = {
835 .g_range = KXTF9_G_2G,
836 .axis_map_x = KXTF9_MAP_X,
837 .axis_map_y = KXTF9_MAP_Y,
839 .negate_x = KXTF9_NEG_X,
840 .negate_y = KXTF9_NEG_Y,
841 .negate_z = KXTF9_NEG_Z,
842 //.ctrl_regc_init = KXTF9_G_2G | ODR50F,
843 //.ctrl_regb_init = ENABLE,
845 #endif /* CONFIG_GS_KXTF9 */
849 #if defined (CONFIG_GS_MMA8452)
850 #define MMA8452_INT_PIN RK29_PIN0_PA3
852 static int mma8452_init_platform_hw(void)
855 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
856 gpio_free(MMA8452_INT_PIN);
857 printk("mma8452_init_platform_hw gpio_request error\n");
860 gpio_pull_updown(MMA8452_INT_PIN, 1);
865 static struct mma8452_platform_data mma8452_info = {
868 .init_platform_hw= mma8452_init_platform_hw,
872 #if defined (CONFIG_MPU_SENSORS_MPU3050)
874 static struct mpu3050_platform_data mpu3050_data = {
876 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
877 //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
878 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
879 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
881 #if defined (CONFIG_MPU_SENSORS_KXTF9)
883 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
884 .get_slave_descr = NULL ,
886 .get_slave_descr = get_accel_slave_descr ,
888 .adapt_num = 0, // The i2c bus to which the mpu device is
890 //.irq = RK29_PIN0_PA3,
891 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
893 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
894 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
895 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
896 .orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
899 #if defined (CONFIG_MPU_SENSORS_AK8975)
901 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
902 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
904 .get_slave_descr = get_compass_slave_descr,
906 .adapt_num = 0, // The i2c bus to which the compass device is.
907 // It can be difference with mpu
909 //.irq = RK29_PIN0_PA4,
910 .bus = EXT_SLAVE_BUS_PRIMARY,
912 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
913 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
914 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
915 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
916 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
921 #if defined (CONFIG_BATTERY_BQ27510)
922 #define DC_CHECK_PIN RK29_PIN4_PA1
923 #define LI_LION_BAT_NUM 2
924 static int bq27510_init_dc_check_pin(void){
925 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
926 gpio_free(DC_CHECK_PIN);
927 printk("bq27510 init dc check pin request error\n");
930 gpio_direction_input(DC_CHECK_PIN);
934 struct bq27510_platform_data bq27510_info = {
935 .init_dc_check_pin = bq27510_init_dc_check_pin,
936 .dc_check_pin = DC_CHECK_PIN,
937 .bat_num = LI_LION_BAT_NUM,
942 /*****************************************************************************************
944 * author: kfx@rock-chips.com
945 *****************************************************************************************/
946 static int rk29_i2c0_io_init(void)
948 #ifdef CONFIG_RK29_I2C0_CONTROLLER
949 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
950 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
952 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
953 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
958 static int rk29_i2c1_io_init(void)
960 #ifdef CONFIG_RK29_I2C1_CONTROLLER
961 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
962 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
964 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
965 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
969 static int rk29_i2c2_io_init(void)
971 #ifdef CONFIG_RK29_I2C2_CONTROLLER
972 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
973 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
975 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
976 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
981 static int rk29_i2c3_io_init(void)
983 #ifdef CONFIG_RK29_I2C3_CONTROLLER
984 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
985 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
987 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
988 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
992 #ifdef CONFIG_RK29_I2C0_CONTROLLER
993 struct rk29_i2c_platform_data default_i2c0_data = {
997 .scl_rate = 400*1000,
998 .mode = I2C_MODE_IRQ,
999 .io_init = rk29_i2c0_io_init,
1002 struct i2c_gpio_platform_data default_i2c0_data = {
1003 .sda_pin = RK29_PIN2_PB6,
1004 .scl_pin = RK29_PIN2_PB7,
1005 .udelay = 5, // clk = 500/udelay = 100Khz
1006 .timeout = 100,//msecs_to_jiffies(200),
1008 .io_init = rk29_i2c0_io_init,
1011 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1012 struct rk29_i2c_platform_data default_i2c1_data = {
1016 .scl_rate = 400*1000,
1017 .mode = I2C_MODE_IRQ,
1018 .io_init = rk29_i2c1_io_init,
1021 struct i2c_gpio_platform_data default_i2c1_data = {
1022 .sda_pin = RK29_PIN1_PA6,
1023 .scl_pin = RK29_PIN1_PA7,
1024 .udelay = 5, // clk = 500/udelay = 100Khz
1025 .timeout = 100,//msecs_to_jiffies(200),
1027 .io_init = rk29_i2c1_io_init,
1030 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1031 struct rk29_i2c_platform_data default_i2c2_data = {
1035 .scl_rate = 400*1000,
1036 .mode = I2C_MODE_IRQ,
1037 .io_init = rk29_i2c2_io_init,
1040 struct i2c_gpio_platform_data default_i2c2_data = {
1041 .sda_pin = RK29_PIN5_PD3,
1042 .scl_pin = RK29_PIN5_PD4,
1043 .udelay = 5, // clk = 500/udelay = 100Khz
1044 .timeout = 100,//msecs_to_jiffies(200),
1046 .io_init = rk29_i2c2_io_init,
1049 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1050 struct rk29_i2c_platform_data default_i2c3_data = {
1054 .scl_rate = 400*1000,
1055 .mode = I2C_MODE_IRQ,
1056 .io_init = rk29_i2c3_io_init,
1059 struct i2c_gpio_platform_data default_i2c3_data = {
1060 .sda_pin = RK29_PIN5_PB5,
1061 .scl_pin = RK29_PIN5_PB4,
1062 .udelay = 5, // clk = 500/udelay = 100Khz
1063 .timeout = 100,//msecs_to_jiffies(200),
1065 .io_init = rk29_i2c3_io_init,
1068 #ifdef CONFIG_I2C0_RK29
1069 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1070 #if defined (CONFIG_RK1000_CONTROL)
1072 .type = "rk1000_control",
1077 #if defined (CONFIG_SND_SOC_alc5621)
1084 #if defined (CONFIG_SND_SOC_alc5631)
1091 #if defined (CONFIG_SND_SOC_RK1000)
1093 .type = "rk1000_i2c_codec",
1098 #if defined (CONFIG_SND_SOC_WM8900)
1105 #if defined (CONFIG_BATTERY_STC3100)
1112 #if defined (CONFIG_BATTERY_BQ27510)
1117 .platform_data = &bq27510_info,
1120 #if defined (CONFIG_RTC_HYM8563)
1122 .type = "rtc_hym8563",
1125 .irq = RK29_PIN0_PA1,
1128 #if defined (CONFIG_GS_MMA8452)
1130 .type = "gs_mma8452",
1133 .irq = MMA8452_INT_PIN,
1134 .platform_data = &mma8452_info,
1137 #if defined (CONFIG_COMPASS_AK8973)
1142 .irq = RK29_PIN0_PA4,
1145 #if defined (CONFIG_COMPASS_AK8975)
1150 .irq = RK29_PIN0_PA4,
1154 #if defined (CONFIG_MPU_SENSORS_MPU3050)
1159 .irq = RK29_PIN5_PA3,
1160 .platform_data = &mpu3050_data,
1163 #if defined (CONFIG_SND_SOC_CS42L52)
1168 .platform_data = &cs42l52_info,
1171 #if defined (CONFIG_RTC_M41T66)
1173 .type = "rtc-M41T66",
1176 .irq = RK29_PIN0_PA1,
1181 #if defined (CONFIG_ANX7150)
1182 struct hdmi_platform_data anx7150_data = {
1183 //.io_init = anx7150_io_init,
1186 #ifdef CONFIG_I2C1_RK29
1187 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1188 #if defined (CONFIG_RK1000_CONTROL1)
1190 .type = "rk1000_control",
1195 #if defined (CONFIG_ANX7150)
1198 .addr = 0x39, //0x39, 0x3d
1200 .irq = RK29_PIN1_PD7,
1201 .platform_data = &anx7150_data,
1204 #ifdef CONFIG_BU92747GUW_CIR
1206 .type ="bu92747_cir",
1209 .irq = BU92747_CIR_IRQ_PIN,
1210 .platform_data = &bu92747guw_pdata,
1217 #ifdef CONFIG_I2C2_RK29
1218 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1219 #if defined (CONFIG_HANNSTAR_P1003)
1221 .type = "p1003_touch",
1223 .flags = 0, //I2C_M_NEED_DELAY
1224 .irq = RK29_PIN0_PA2,
1225 .platform_data = &p1003_info,
1229 #if defined (CONFIG_EETI_EGALAX)
1231 .type = "egalax_i2c",
1234 .irq = RK29_PIN0_PA2,
1235 .platform_data = &eeti_egalax_info,
1238 #if defined (CONFIG_TOUCHSCREEN_GT819)
1240 .type = "Goodix-TS",
1243 .irq =RK29_PIN0_PA2,
1244 .platform_data = &goodix_info,
1247 #if defined (CONFIG_TOUCHSCREEN_FT5406)
1250 .addr = 0x38, //0x70,
1252 .irq =RK29_PIN0_PA2, // support goodix tp detect, 20110706
1253 .platform_data = &ft5406_info,
1259 #ifdef CONFIG_I2C3_RK29
1260 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1261 #if defined (CONFIG_BATTERY_BQ27541)
1266 .platform_data = &bq27541_info,
1272 /*****************************************************************************************
1274 * author: ddl@rock-chips.com
1275 *****************************************************************************************/
1276 #ifdef CONFIG_VIDEO_RK29
1277 #define CONFIG_SENSOR_POWER_IOCTL_USR 0
1278 #define CONFIG_SENSOR_RESET_IOCTL_USR 0
1279 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0
1280 #define CONFIG_SENSOR_FLASH_IOCTL_USR 0
1282 #if CONFIG_SENSOR_POWER_IOCTL_USR
1283 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
1285 #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
1289 #if CONFIG_SENSOR_RESET_IOCTL_USR
1290 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
1292 #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
1296 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1297 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
1299 #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
1303 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1304 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
1306 #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
1310 static struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
1311 #if CONFIG_SENSOR_POWER_IOCTL_USR
1312 .sensor_power_cb = sensor_power_usr_cb,
1314 .sensor_power_cb = NULL,
1317 #if CONFIG_SENSOR_RESET_IOCTL_USR
1318 .sensor_reset_cb = sensor_reset_usr_cb,
1320 .sensor_reset_cb = NULL,
1323 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1324 .sensor_powerdown_cb = sensor_powerdown_usr_cb,
1326 .sensor_powerdown_cb = NULL,
1329 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1330 .sensor_flash_cb = sensor_flash_usr_cb,
1332 .sensor_flash_cb = NULL,
1335 #include "../../../drivers/media/video/rk29_camera.c"
1337 /*****************************************************************************************
1339 * author: nzy@rock-chips.com
1340 *****************************************************************************************/
1341 #ifdef CONFIG_BACKLIGHT_RK29_BL
1343 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
1344 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
1345 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
1346 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
1350 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
1351 #define PWM_MUX_MODE GPIO1L_PWM0
1352 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1353 #define PWM_GPIO RK29_PIN1_PB5
1354 #define PWM_EFFECT_VALUE 1
1356 #define LCD_DISP_ON_PIN
1358 #ifdef LCD_DISP_ON_PIN
1359 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
1360 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
1362 #define BL_EN_PIN RK29_PIN6_PD0
1363 #define BL_EN_VALUE GPIO_HIGH
1365 static int rk29_backlight_io_init(void)
1369 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1370 #ifdef LCD_DISP_ON_PIN
1371 // rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
1373 ret = gpio_request(BL_EN_PIN, NULL);
1376 gpio_free(BL_EN_PIN);
1379 gpio_direction_output(BL_EN_PIN, 0);
1380 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1385 static int rk29_backlight_io_deinit(void)
1388 #ifdef LCD_DISP_ON_PIN
1389 gpio_free(BL_EN_PIN);
1391 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1396 static int rk29_backlight_pwm_suspend(void)
1399 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1400 if (gpio_request(PWM_GPIO, NULL)) {
1401 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
1404 gpio_direction_output(PWM_GPIO, GPIO_LOW);
1405 #ifdef LCD_DISP_ON_PIN
1406 gpio_direction_output(BL_EN_PIN, 0);
1407 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
1412 static int rk29_backlight_pwm_resume(void)
1414 gpio_free(PWM_GPIO);
1415 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1417 #ifdef LCD_DISP_ON_PIN
1419 gpio_direction_output(BL_EN_PIN, 1);
1420 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1425 struct rk29_bl_info rk29_bl_info = {
1427 .bl_ref = PWM_EFFECT_VALUE,
1428 .io_init = rk29_backlight_io_init,
1429 .io_deinit = rk29_backlight_io_deinit,
1430 .pwm_suspend = rk29_backlight_pwm_suspend,
1431 .pwm_resume = rk29_backlight_pwm_resume,
1434 /*****************************************************************************************
1435 * pwm voltage regulator devices
1436 ******************************************************************************************/
1437 #if defined (CONFIG_RK29_PWM_REGULATOR)
1439 #define REGULATOR_PWM_ID 2
1440 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1441 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1442 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1443 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1445 static struct regulator_consumer_supply pwm_consumers[] = {
1451 static struct regulator_init_data rk29_pwm_regulator_data = {
1457 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1459 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1460 .consumer_supplies = pwm_consumers,
1463 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1464 .pwm_id = REGULATOR_PWM_ID,
1465 .pwm_gpio = REGULATOR_PWM_GPIO,
1466 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1467 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1468 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1469 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1470 .init_data = &rk29_pwm_regulator_data,
1473 static struct platform_device rk29_device_pwm_regulator = {
1474 .name = "pwm-voltage-regulator",
1477 .platform_data = &rk29_regulator_pwm_platform_data,
1483 /*****************************************************************************************
1485 *****************************************************************************************/
1486 #ifdef CONFIG_SDMMC0_RK29
1487 static int rk29_sdmmc0_cfg_gpio(void)
1489 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1490 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1491 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1492 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1493 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1494 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1496 #ifdef CONFIG_SDMMC_RK29_OLD
1497 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
1499 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
1502 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1503 gpio_request(RK29_PIN5_PD5,"sdmmc");
1505 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1507 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1509 gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
1514 #define CONFIG_SDMMC0_USE_DMA
1515 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1516 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1517 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1518 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1519 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1520 .io_init = rk29_sdmmc0_cfg_gpio,
1521 .dma_name = "sd_mmc",
1522 #ifdef CONFIG_SDMMC0_USE_DMA
1527 .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
1528 .enable_sd_wakeup = 0,
1531 #ifdef CONFIG_SDMMC1_RK29
1532 #define CONFIG_SDMMC1_USE_DMA
1533 static int rk29_sdmmc1_cfg_gpio(void)
1535 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1536 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1537 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1538 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1539 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1540 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1541 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1545 #ifdef CONFIG_WIFI_CONTROL_FUNC
1546 static int rk29sdk_wifi_status(struct device *dev);
1547 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1550 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1552 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1553 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1554 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1555 MMC_VDD_32_33|MMC_VDD_33_34),
1556 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1557 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1558 .io_init = rk29_sdmmc1_cfg_gpio,
1560 #ifdef CONFIG_SDMMC1_USE_DMA
1565 #ifdef CONFIG_WIFI_CONTROL_FUNC
1566 .status = rk29sdk_wifi_status,
1567 .register_status_notify = rk29sdk_wifi_status_register,
1570 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1575 #ifdef CONFIG_WIFI_CONTROL_FUNC
1576 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1577 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1578 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1580 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1581 static void (*wifi_status_cb)(int card_present, void *dev_id);
1582 static void *wifi_status_cb_devid;
1583 int rk29sdk_wifi_power_state = 0;
1584 int rk29sdk_bt_power_state = 0;
1586 static int rk29sdk_wifi_status(struct device *dev)
1588 return rk29sdk_wifi_cd;
1591 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1595 wifi_status_cb = callback;
1596 wifi_status_cb_devid = dev_id;
1600 static int rk29sdk_wifi_bt_gpio_control_init(void)
1602 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1603 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1607 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1608 pr_info("%s: request wifi reset gpio failed\n", __func__);
1609 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1613 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1614 pr_info("%s: request bt reset gpio failed\n", __func__);
1615 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1619 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1620 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1621 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1623 pr_info("%s: init finished\n",__func__);
1628 static int rk29sdk_wifi_power(int on)
1630 pr_info("%s: %d\n", __func__, on);
1632 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
1633 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
1635 pr_info("wifi turn on power\n");
1637 if (!rk29sdk_bt_power_state){
1638 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1640 pr_info("wifi shut off power\n");
1643 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1645 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1649 rk29sdk_wifi_power_state = on;
1653 static int rk29sdk_wifi_reset_state;
1654 static int rk29sdk_wifi_reset(int on)
1656 pr_info("%s: %d\n", __func__, on);
1657 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1659 rk29sdk_wifi_reset_state = on;
1663 int rk29sdk_wifi_set_carddetect(int val)
1665 pr_info("%s:%d\n", __func__, val);
1666 rk29sdk_wifi_cd = val;
1667 if (wifi_status_cb){
1668 wifi_status_cb(val, wifi_status_cb_devid);
1670 pr_warning("%s, nobody to notify\n", __func__);
1674 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
1676 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
1677 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
1678 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
1679 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
1680 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
1683 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
1685 if (section == PREALLOC_WLAN_SEC_NUM)
1686 return wlan_static_skb;
1688 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
1691 if (wifi_mem_array[section].size < size)
1694 return wifi_mem_array[section].mem_ptr;
1697 int __init rk29sdk_init_wifi_mem(void)
1702 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
1703 wlan_static_skb[i] = dev_alloc_skb(
1704 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
1706 if (!wlan_static_skb[i])
1710 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
1711 wifi_mem_array[i].mem_ptr =
1712 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
1714 if (!wifi_mem_array[i].mem_ptr)
1720 pr_err("Failed to mem_alloc for WLAN\n");
1721 for (j = 0 ; j < i ; j++)
1722 kfree(wifi_mem_array[j].mem_ptr);
1724 i = WLAN_SKB_BUF_NUM;
1727 pr_err("Failed to skb_alloc for WLAN\n");
1728 for (j = 0 ; j < i ; j++)
1729 dev_kfree_skb(wlan_static_skb[j]);
1734 static struct wifi_platform_data rk29sdk_wifi_control = {
1735 .set_power = rk29sdk_wifi_power,
1736 .set_reset = rk29sdk_wifi_reset,
1737 .set_carddetect = rk29sdk_wifi_set_carddetect,
1738 .mem_prealloc = rk29sdk_mem_prealloc,
1740 static struct platform_device rk29sdk_wifi_device = {
1741 .name = "bcm4329_wlan",
1744 .platform_data = &rk29sdk_wifi_control,
1750 /* bluetooth rfkill device */
1751 static struct platform_device rk29sdk_rfkill = {
1752 .name = "rk29sdk_rfkill",
1757 #ifdef CONFIG_VIVANTE
1758 #define GPU_HIGH_CLOCK 552
1759 #define GPU_LOW_CLOCK (periph_pll_default / 1000000) /* same as general pll clock rate below */
1760 static struct resource resources_gpu[] = {
1765 .flags = IORESOURCE_IRQ,
1769 .start = RK29_GPU_PHYS,
1770 .end = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
1771 .flags = IORESOURCE_MEM,
1775 .start = PMEM_GPU_BASE,
1776 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
1777 .flags = IORESOURCE_MEM,
1781 .start = GPU_LOW_CLOCK,
1782 .end = GPU_HIGH_CLOCK,
1783 .flags = IORESOURCE_IO,
1786 static struct platform_device rk29_device_gpu = {
1789 .num_resources = ARRAY_SIZE(resources_gpu),
1790 .resource = resources_gpu,
1794 #ifdef CONFIG_KEYS_RK29
1795 extern struct rk29_keys_platform_data rk29_keys_pdata;
1796 static struct platform_device rk29_device_keys = {
1797 .name = "rk29-keypad",
1800 .platform_data = &rk29_keys_pdata,
1805 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1806 struct gpio_led rk29_leds[] = {
1808 .name = "rk29_red_led",
1809 .gpio = RK29_PIN4_PB2,
1810 .default_trigger = "timer",
1812 .retain_state_suspended = 1,
1813 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1816 .name = "rk29_green_led",
1817 .gpio = RK29_PIN4_PB1,
1818 .default_trigger = "timer",
1820 .retain_state_suspended = 1,
1821 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1824 .name = "rk29_blue_led",
1825 .gpio = RK29_PIN4_PB0,
1826 .default_trigger = "timer",
1828 .retain_state_suspended = 1,
1829 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1833 struct gpio_led_platform_data rk29_leds_pdata = {
1835 .num_leds = ARRAY_SIZE(rk29_leds),
1838 struct platform_device rk29_device_gpio_leds = {
1839 .name = "leds-gpio",
1842 .platform_data = &rk29_leds_pdata,
1847 #ifdef CONFIG_LEDS_NEWTON_PWM
1848 static struct led_newton_pwm rk29_pwm_leds[] = {
1850 .name = "power_led",
1852 .pwm_gpio = RK29_PIN5_PD2,
1853 .pwm_iomux_name = GPIO5D2_PWM1_UART1SIRIN_NAME,
1854 .pwm_iomux_pwm = GPIO5H_PWM1,
1855 .pwm_iomux_gpio = GPIO5H_GPIO5D2,
1861 static struct led_newton_pwm_platform_data rk29_pwm_leds_pdata = {
1862 .leds = &rk29_pwm_leds,
1863 .num_leds = ARRAY_SIZE(rk29_pwm_leds),
1866 static struct platform_device rk29_device_pwm_leds = {
1867 .name = "leds_newton_pwm",
1870 .platform_data = &rk29_pwm_leds_pdata,
1875 static void __init rk29_board_iomux_init(void)
1877 #ifdef CONFIG_RK29_PWM_REGULATOR
1878 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1882 static struct platform_device *devices[] __initdata = {
1884 #ifdef CONFIG_RK29_WATCHDOG
1888 #ifdef CONFIG_UART1_RK29
1891 #ifdef CONFIG_UART0_RK29
1894 #ifdef CONFIG_UART2_RK29
1897 #ifdef CONFIG_UART3_RK29
1901 #ifdef CONFIG_RK29_PWM_REGULATOR
1902 &rk29_device_pwm_regulator,
1904 #ifdef CONFIG_SPIM0_RK29
1905 &rk29xx_device_spi0m,
1907 #ifdef CONFIG_SPIM1_RK29
1908 &rk29xx_device_spi1m,
1910 #ifdef CONFIG_ADC_RK29
1913 #ifdef CONFIG_I2C0_RK29
1916 #ifdef CONFIG_I2C1_RK29
1919 #ifdef CONFIG_I2C2_RK29
1922 #ifdef CONFIG_I2C3_RK29
1926 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1927 &rk29_device_iis_2ch,
1929 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1930 &rk29_device_iis_8ch,
1933 #ifdef CONFIG_KEYS_RK29
1936 #ifdef CONFIG_KEYS_RK29_NEWTON
1939 #ifdef CONFIG_SDMMC0_RK29
1940 &rk29_device_sdmmc0,
1942 #ifdef CONFIG_SDMMC1_RK29
1943 &rk29_device_sdmmc1,
1946 #ifdef CONFIG_MTD_NAND_RK29XX
1947 &rk29xx_device_nand,
1950 #ifdef CONFIG_WIFI_CONTROL_FUNC
1951 &rk29sdk_wifi_device,
1958 #ifdef CONFIG_MTD_NAND_RK29
1962 #ifdef CONFIG_FB_RK29
1964 &rk29_device_dma_cpy,
1966 #ifdef CONFIG_BACKLIGHT_RK29_BL
1967 &rk29_device_backlight,
1969 #ifdef CONFIG_BACKLIGHT_RK29_NEWTON_BL
1970 &rk29_device_backlight,
1972 #ifdef CONFIG_RK29_VMAC
1975 #ifdef CONFIG_VIVANTE
1978 #ifdef CONFIG_VIDEO_RK29
1979 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1980 #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
1981 &rk29_soc_camera_pdrv_0,
1983 &rk29_soc_camera_pdrv_1,
1984 &android_pmem_cam_device,
1986 &android_pmem_device,
1987 &rk29_vpu_mem_device,
1988 #ifdef CONFIG_USB20_OTG
1989 &rk29_device_usb20_otg,
1991 #ifdef CONFIG_USB20_HOST
1992 &rk29_device_usb20_host,
1994 #ifdef CONFIG_USB11_HOST
1995 &rk29_device_usb11_host,
1997 #ifdef CONFIG_USB_ANDROID
1998 &android_usb_device,
1999 &usb_mass_storage_device,
2001 #ifdef CONFIG_USB_ANDROID_RNDIS
2004 #ifdef CONFIG_RK29_IPP
2007 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2008 &rk29_v4l2_output_devce,
2010 #ifdef CONFIG_RK29_NEWTON
2011 &rk29_device_newton,
2013 #ifdef CONFIG_RK_IRDA
2016 #ifdef CONFIG_LEDS_GPIO_PLATFORM
2017 &rk29_device_gpio_leds,
2019 #ifdef CONFIG_LEDS_NEWTON_PWM
2020 &rk29_device_pwm_leds,
2022 #ifdef CONFIG_SND_RK29_SOC_CS42L52
2023 &rk29_cs42l52_device,
2027 /*****************************************************************************************
2029 * author: cmc@rock-chips.com
2030 *****************************************************************************************/
2031 static int rk29_vmac_register_set(void)
2033 //config rk29 vmac as rmii, 100MHz
2034 u32 value= readl(RK29_GRF_BASE + 0xbc);
2035 value = (value & 0xfff7ff) | (0x400);
2036 writel(value, RK29_GRF_BASE + 0xbc);
2040 static int rk29_rmii_io_init(void)
2045 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2047 gpio_free(RK29_PIN6_PB0);
2048 printk("-------request RK29_PIN6_PB0 fail--------\n");
2052 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2053 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2058 static int rk29_rmii_io_deinit(void)
2061 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2062 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2064 gpio_free(RK29_PIN6_PB0);
2068 static int rk29_rmii_power_control(int enable)
2072 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2073 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2076 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2077 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2082 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2083 .vmac_register_set = rk29_vmac_register_set,
2084 .rmii_io_init = rk29_rmii_io_init,
2085 .rmii_io_deinit = rk29_rmii_io_deinit,
2086 .rmii_power_control = rk29_rmii_power_control,
2089 /*****************************************************************************************
2091 * author: cmc@rock-chips.com
2092 *****************************************************************************************/
2093 #define SPI_CHIPSELECT_NUM 2
2094 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2097 .cs_gpio = RK29_PIN2_PC1,
2098 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2099 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2103 .cs_gpio = RK29_PIN1_PA4,
2104 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2105 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2109 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2112 .cs_gpio = RK29_PIN2_PC5,
2113 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2114 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2118 .cs_gpio = RK29_PIN1_PA3,
2119 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2120 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2124 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2129 for (i=0; i<cs_num; i++) {
2130 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2137 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2142 static int spi_io_fix_leakage_bug(void)
2145 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2150 static int spi_io_resume_leakage_bug(void)
2153 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2158 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2159 .num_chipselect = SPI_CHIPSELECT_NUM,
2160 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2161 .io_init = spi_io_init,
2162 .io_deinit = spi_io_deinit,
2163 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2164 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2167 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2168 .num_chipselect = SPI_CHIPSELECT_NUM,
2169 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2170 .io_init = spi_io_init,
2171 .io_deinit = spi_io_deinit,
2172 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2173 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2176 /*****************************************************************************************
2177 * xpt2046 touch panel
2178 * author: cmc@rock-chips.com
2179 *****************************************************************************************/
2180 #define XPT2046_GPIO_INT RK29_PIN0_PA3
2181 #define DEBOUNCE_REPTIME 3
2183 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
2184 static struct xpt2046_platform_data xpt2046_info = {
2193 .debounce_rep = DEBOUNCE_REPTIME,
2195 .gpio_pendown = XPT2046_GPIO_INT,
2196 .penirq_recheck_delay_usecs = 1,
2198 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
2199 static struct xpt2046_platform_data xpt2046_info = {
2208 .debounce_rep = DEBOUNCE_REPTIME,
2210 .gpio_pendown = XPT2046_GPIO_INT,
2211 .penirq_recheck_delay_usecs = 1,
2213 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2214 static struct xpt2046_platform_data xpt2046_info = {
2223 .debounce_rep = DEBOUNCE_REPTIME,
2225 .gpio_pendown = XPT2046_GPIO_INT,
2227 .penirq_recheck_delay_usecs = 1,
2229 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2230 static struct xpt2046_platform_data xpt2046_info = {
2239 .debounce_rep = DEBOUNCE_REPTIME,
2241 .gpio_pendown = XPT2046_GPIO_INT,
2243 .penirq_recheck_delay_usecs = 1,
2247 static struct spi_board_info board_spi_devices[] = {
2248 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
2249 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2251 .modalias = "xpt2046_ts",
2253 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2255 .irq = XPT2046_GPIO_INT,
2256 .platform_data = &xpt2046_info,
2262 static void __init rk29_gic_init_irq(void)
2264 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2265 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2268 static void __init machine_rk29_init_irq(void)
2270 rk29_gic_init_irq();
2274 static void __init machine_rk29_board_init(void)
2276 rk29_board_iomux_init();
2280 platform_add_devices(devices, ARRAY_SIZE(devices));
2281 #ifdef CONFIG_I2C0_RK29
2282 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2283 ARRAY_SIZE(board_i2c0_devices));
2285 #ifdef CONFIG_I2C1_RK29
2286 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2287 ARRAY_SIZE(board_i2c1_devices));
2289 #ifdef CONFIG_I2C2_RK29
2290 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2291 ARRAY_SIZE(board_i2c2_devices));
2293 #ifdef CONFIG_I2C3_RK29
2294 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2295 ARRAY_SIZE(board_i2c3_devices));
2298 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2300 #ifdef CONFIG_WIFI_CONTROL_FUNC
2301 rk29sdk_wifi_bt_gpio_control_init();
2302 rk29sdk_init_wifi_mem();
2305 board_usb_detect_init(RK29_PIN0_PA0);
2306 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
2308 bu92747guw_io_init();
2313 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2314 char **cmdline, struct meminfo *mi)
2317 mi->bank[0].start = RK29_SDRAM_PHYS;
2318 mi->bank[0].size = LINUX_SIZE;
2319 #if SDRAM_SIZE > SZ_512M
2321 mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
2322 mi->bank[1].size = SDRAM_SIZE - SZ_512M;
2326 static void __init machine_rk29_mapio(void)
2328 rk29_map_common_io();
2329 rk29_setup_early_printk();
2331 rk29_clock_init(periph_pll_default);
2333 ddr_init(DDR_TYPE,DDR_FREQ); // DDR3_1333H, 400
2336 MACHINE_START(RK29, "RK29board")
2337 /* UART for LL DEBUG */
2338 .phys_io = RK29_UART1_PHYS & 0xfff00000,
2339 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2340 .boot_params = RK29_SDRAM_PHYS + 0x88000,
2341 .fixup = machine_rk29_fixup,
2342 .map_io = machine_rk29_mapio,
2343 .init_irq = machine_rk29_init_irq,
2344 .init_machine = machine_rk29_board_init,
2345 .timer = &rk29_timer,