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_64M
102 #define PMEM_UI_SIZE SZ_32M
103 #define PMEM_VPU_SIZE SZ_64M
104 #define PMEM_SKYPE_SIZE 0
105 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
106 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
107 #define MEM_CAMIPP_SIZE SZ_4M
109 #define MEM_CAMIPP_SIZE 0
111 #define MEM_FB_SIZE (9*SZ_1M)
112 #ifdef CONFIG_FB_WORK_IPP
113 #define MEM_FBIPP_SIZE SZ_8M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4
115 #define MEM_FBIPP_SIZE 0
117 #if SDRAM_SIZE > SZ_512M
118 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
120 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
122 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
123 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
124 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
125 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
126 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
127 #define MEM_FBIPP_BASE (MEM_FB_BASE - MEM_FBIPP_SIZE)
128 #define PMEM_SKYPE_BASE (MEM_FBIPP_BASE - PMEM_SKYPE_SIZE)
129 #define LINUX_SIZE (PMEM_SKYPE_BASE - RK29_SDRAM_PHYS)
131 #define PREALLOC_WLAN_SEC_NUM 4
132 #define PREALLOC_WLAN_BUF_NUM 160
133 #define PREALLOC_WLAN_SECTION_HEADER 24
135 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
136 #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
137 #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
138 #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
140 #define WLAN_SKB_BUF_NUM 16
142 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
144 struct wifi_mem_prealloc {
149 extern struct sys_timer rk29_timer;
151 static int rk29_nand_io_init(void)
156 struct rk29_nand_platform_data rk29_nand_data = {
157 .width = 1, /* data bus width in bytes */
158 .hw_ecc = 1, /* hw ecc 0: soft ecc */
160 .io_init = rk29_nand_io_init,
163 #define TOUCH_SCREEN_STANDBY_PIN RK29_PIN6_PD1
164 #define TOUCH_SCREEN_STANDBY_VALUE GPIO_HIGH
165 #define TOUCH_SCREEN_DISPLAY_PIN INVALID_GPIO
166 #define TOUCH_SCREEN_DISPLAY_VALUE GPIO_HIGH
167 #ifdef CONFIG_FB_RK29
168 /*****************************************************************************************
170 * author: zyw@rock-chips.com
171 *****************************************************************************************/
172 //#ifdef CONFIG_LCD_TD043MGEA1
173 #define LCD_TXD_PIN INVALID_GPIO
174 #define LCD_CLK_PIN INVALID_GPIO
175 #define LCD_CS_PIN INVALID_GPIO
176 /*****************************************************************************************
177 * frame buffe devices
178 * author: zyw@rock-chips.com
179 *****************************************************************************************/
181 #define FB_DISPLAY_ON_PIN INVALID_GPIO// RK29_PIN6_PD0
182 #define FB_LCD_STANDBY_PIN INVALID_GPIO
183 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
184 #define FB_MCU_FMK_PIN INVALID_GPIO
186 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
187 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
189 static int rk29_lcd_io_init(void)
195 static int rk29_lcd_io_deinit(void)
201 static struct rk29lcd_info rk29_lcd_info = {
202 .txd_pin = LCD_TXD_PIN,
203 .clk_pin = LCD_CLK_PIN,
204 .cs_pin = LCD_CS_PIN,
205 .io_init = rk29_lcd_io_init,
206 .io_deinit = rk29_lcd_io_deinit,
209 int rk29_fb_io_enable(void)
211 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
213 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
214 gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);
216 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
218 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
219 gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);
224 int rk29_fb_io_disable(void)
226 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
228 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
229 gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);
231 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
233 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
234 gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);
239 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
242 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
244 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
247 gpio_free(FB_MCU_FMK_PIN);
248 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
250 gpio_direction_input(FB_MCU_FMK_PIN);
252 if(fb_setting->disp_on_en)
254 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
256 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
259 gpio_free(FB_DISPLAY_ON_PIN);
260 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
263 else if (TOUCH_SCREEN_DISPLAY_PIN != INVALID_GPIO)
265 ret = gpio_request(TOUCH_SCREEN_DISPLAY_PIN, NULL);
268 gpio_free(TOUCH_SCREEN_DISPLAY_PIN);
269 printk(">>>>>> TOUCH_SCREEN_DISPLAY_PIN gpio_request err \n ");
271 gpio_direction_output(TOUCH_SCREEN_DISPLAY_PIN, 0);
272 gpio_set_value(TOUCH_SCREEN_DISPLAY_PIN, TOUCH_SCREEN_DISPLAY_VALUE);
276 if(fb_setting->disp_on_en)
278 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
280 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
283 gpio_free(FB_LCD_STANDBY_PIN);
284 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
287 else if (TOUCH_SCREEN_STANDBY_PIN != INVALID_GPIO)
289 ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL);
292 gpio_free(TOUCH_SCREEN_STANDBY_PIN);
293 printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n ");
295 gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0);
296 gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE);
300 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
302 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
305 gpio_free(FB_LCD_CABC_EN_PIN);
306 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
308 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
309 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
312 rk29_fb_io_enable(); //enable it
318 static struct rk29fb_info rk29_fb_info = {
320 .mcu_fmk_pin = FB_MCU_FMK_PIN,
321 .lcd_info = &rk29_lcd_info,
322 .io_init = rk29_fb_io_init,
323 .io_enable = rk29_fb_io_enable,
324 .io_disable = rk29_fb_io_disable,
327 /* rk29 fb resource */
328 static struct resource rk29_fb_resource[] = {
331 .start = RK29_LCDC_PHYS,
332 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
333 .flags = IORESOURCE_MEM,
339 .flags = IORESOURCE_IRQ,
343 .start = MEM_FB_BASE,
344 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
345 .flags = IORESOURCE_MEM,
347 #ifdef CONFIG_FB_WORK_IPP
349 .name = "win1 ipp buf",
350 .start = MEM_FBIPP_BASE,
351 .end = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
352 .flags = IORESOURCE_MEM,
358 struct platform_device rk29_device_fb = {
361 .num_resources = ARRAY_SIZE(rk29_fb_resource),
362 .resource = rk29_fb_resource,
364 .platform_data = &rk29_fb_info,
368 struct platform_device rk29_device_dma_cpy = {
369 .name = "dma_memcpy",
376 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
377 #define BU92747GUW_RESET_PIN RK29_PIN3_PD4// INVALID_GPIO //
378 #define BU92747GUW_RESET_MUX_NAME GPIO3D4_HOSTWRN_NAME//NULL //
379 #define BU92747GUW_RESET_MUX_MODE GPIO3H_GPIO3D4//NULL //
381 #define BU92747GUW_PWDN_PIN RK29_PIN3_PD3//RK29_PIN5_PA7 //
382 #define BU92747GUW_PWDN_MUX_NAME GPIO3D3_HOSTRDN_NAME//GPIO5A7_HSADCDATA2_NAME //
383 #define BU92747GUW_PWDN_MUX_MODE GPIO3H_GPIO3D3//GPIO5L_GPIO5A7 //
385 static int bu92747guw_io_init(void)
390 if(BU92747GUW_RESET_MUX_NAME != NULL)
392 rk29_mux_api_set(BU92747GUW_RESET_MUX_NAME, BU92747GUW_RESET_MUX_MODE);
394 ret = gpio_request(BU92747GUW_RESET_PIN, NULL);
397 gpio_free(BU92747GUW_RESET_PIN);
398 printk(">>>>>> BU92747GUW_RESET_PIN gpio_request err \n ");
400 gpio_direction_output(BU92747GUW_RESET_PIN, GPIO_HIGH);
403 if(BU92747GUW_PWDN_MUX_NAME != NULL)
405 rk29_mux_api_set(BU92747GUW_PWDN_MUX_NAME, BU92747GUW_PWDN_MUX_MODE);
407 ret = gpio_request(BU92747GUW_PWDN_PIN, NULL);
410 gpio_free(BU92747GUW_PWDN_PIN);
411 printk(">>>>>> BU92747GUW_PWDN_PIN gpio_request err \n ");
414 //power down as default
415 gpio_direction_output(BU92747GUW_PWDN_PIN, GPIO_LOW);
421 static int bu92747guw_io_deinit(void)
423 gpio_free(BU92747GUW_PWDN_PIN);
424 gpio_free(BU92747GUW_RESET_PIN);
428 //power ctl func is share with irda and remote
429 static int nPowerOnCount = 0;
430 static DEFINE_MUTEX(bu92747_power_mutex);
432 //1---power on; 0---power off
433 static int bu92747guw_power_ctl(int enable)
435 printk("%s \n",__FUNCTION__);
437 mutex_lock(&bu92747_power_mutex);
440 if (nPowerOnCount == 1) {//power on first
442 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_HIGH);
443 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_LOW);
445 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_HIGH);
451 if (nPowerOnCount <= 0) {//power down final
454 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_LOW);
457 mutex_unlock(&bu92747_power_mutex);
462 #ifdef CONFIG_RK_IRDA
463 #define IRDA_IRQ_PIN RK29_PIN5_PB2
464 #define IRDA_IRQ_MUX_NAME GPIO5B2_HSADCDATA5_NAME
465 #define IRDA_IRQ_MUX_MODE GPIO5L_GPIO5B2
467 int irda_iomux_init(void)
472 if(IRDA_IRQ_MUX_NAME != NULL)
474 rk29_mux_api_set(IRDA_IRQ_MUX_NAME, IRDA_IRQ_MUX_MODE);
476 ret = gpio_request(IRDA_IRQ_PIN, NULL);
479 gpio_free(IRDA_IRQ_PIN);
480 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
482 gpio_pull_updown(IRDA_IRQ_PIN, GPIO_HIGH);
483 gpio_direction_input(IRDA_IRQ_PIN);
488 int irda_iomux_deinit(void)
490 gpio_free(IRDA_IRQ_PIN);
494 static struct irda_info rk29_irda_info = {
495 .intr_pin = IRDA_IRQ_PIN,
496 .iomux_init = irda_iomux_init,
497 .iomux_deinit = irda_iomux_deinit,
498 .irda_pwr_ctl = bu92747guw_power_ctl,
501 static struct platform_device irda_device = {
502 #ifdef CONFIG_RK_IRDA_NET
505 .name = "bu92747_irda",
509 .platform_data = &rk29_irda_info,
514 #ifdef CONFIG_BU92747GUW_CIR
515 #define BU92747_CIR_IRQ_PIN RK29_PIN5_PB0
516 #define CIR_IRQ_PIN_IOMUX_NAME GPIO5B0_HSADCDATA3_NAME
517 #define CIR_IRQ_PIN_IOMUX_VALUE GPIO5L_GPIO5B0
518 static int cir_iomux_init(void)
520 if (CIR_IRQ_PIN_IOMUX_NAME)
521 rk29_mux_api_set(CIR_IRQ_PIN_IOMUX_NAME, CIR_IRQ_PIN_IOMUX_VALUE);
522 rk29_mux_api_set(GPIO5A7_HSADCDATA2_NAME, GPIO5L_GPIO5A7);
526 static struct bu92747guw_platform_data bu92747guw_pdata = {
527 .intr_pin = BU92747_CIR_IRQ_PIN,
528 .iomux_init = cir_iomux_init,
529 .iomux_deinit = NULL,
530 .cir_pwr_ctl = bu92747guw_power_ctl,
533 #ifdef CONFIG_RK29_NEWTON
534 struct rk29_newton_data rk29_newton_info = {
536 struct platform_device rk29_device_newton = {
537 .name = "rk29_newton",
540 .platform_data = &rk29_newton_info,
544 #if defined (CONFIG_TOUCHSCREEN_FT5406)
545 #define TOUCH_RESET_PIN RK29_PIN6_PC3
546 #define TOUCH_INT_PIN RK29_PIN0_PA2
547 int ft5406_init_platform_hw(void)
549 printk("ft5406_init_platform_hw\n");
550 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
551 gpio_free(TOUCH_RESET_PIN);
552 printk("ft5406_init_platform_hw gpio_request error\n");
556 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
557 gpio_free(TOUCH_INT_PIN);
558 printk("ift5406_init_platform_hw gpio_request error\n");
562 gpio_direction_output(TOUCH_RESET_PIN, 0);
563 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
565 gpio_direction_input(TOUCH_INT_PIN);
567 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
572 void ft5406_exit_platform_hw(void)
574 printk("ft5406_exit_platform_hw\n");
575 gpio_free(TOUCH_RESET_PIN);
576 gpio_free(TOUCH_INT_PIN);
579 int ft5406_platform_sleep(void)
581 printk("ft5406_platform_sleep\n");
582 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
586 int ft5406_platform_wakeup(void)
588 printk("ft5406_platform_wakeup\n");
589 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
594 struct ft5406_platform_data ft5406_info = {
596 .init_platform_hw= ft5406_init_platform_hw,
597 .exit_platform_hw= ft5406_exit_platform_hw,
598 .platform_sleep = ft5406_platform_sleep,
599 .platform_wakeup = ft5406_platform_wakeup,
604 #if defined(CONFIG_TOUCHSCREEN_GT819)
605 #define TOUCH_RESET_PIN RK29_PIN6_PC3
606 #define TOUCH_INT_PIN RK29_PIN0_PA2
607 int gt819_init_platform_hw(void)
609 printk("gt819_init_platform_hw\n");
610 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
611 gpio_free(TOUCH_RESET_PIN);
612 printk("gt819_init_platform_hw gpio_request error\n");
616 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
617 gpio_free(TOUCH_INT_PIN);
618 printk("gt819_init_platform_hw gpio_request error\n");
621 gpio_direction_output(TOUCH_RESET_PIN, 0);
622 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
624 // gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
626 // gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
627 gpio_direction_input(TOUCH_INT_PIN);
629 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
635 void gt819_exit_platform_hw(void)
637 printk("gt819_exit_platform_hw\n");
638 gpio_free(TOUCH_RESET_PIN);
639 gpio_free(TOUCH_INT_PIN);
642 int gt819_platform_sleep(void)
644 printk("gt819_platform_sleep\n");
645 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
649 int gt819_platform_wakeup(void)
651 printk("gt819_platform_wakeup\n");
652 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
654 //gpio_set_value(TOUCH_INT_PIN, GPIO_LOW);
656 //gpio_set_value(TOUCH_INT_PIN, GPIO_HIGH);
659 struct goodix_platform_data goodix_info = {
661 .init_platform_hw= gt819_init_platform_hw,
662 .exit_platform_hw= gt819_exit_platform_hw,
663 .platform_sleep = gt819_platform_sleep,
664 .platform_wakeup = gt819_platform_wakeup,
670 #if defined (CONFIG_SND_SOC_CS42L52)
672 int cs42l52_init_platform_hw()
674 printk("cs42l52_init_platform_hw\n");
675 if(gpio_request(RK29_PIN6_PB6,NULL) != 0){
676 gpio_free(RK29_PIN6_PB6);
677 printk("cs42l52_init_platform_hw gpio_request error\n");
680 gpio_direction_output(RK29_PIN6_PB6, 0);
681 gpio_set_value(RK29_PIN6_PB6,GPIO_HIGH);
684 struct cs42l52_platform_data cs42l52_info = {
686 .init_platform_hw= cs42l52_init_platform_hw,
690 #if defined (CONFIG_BATTERY_BQ27541)
691 #define DC_CHECK_PIN RK29_PIN4_PA1
692 #define LI_LION_BAT_NUM 1
693 #define CHG_OK RK29_PIN4_PA3
694 #define BAT_LOW RK29_PIN4_PA2
696 static int bq27541_init_dc_check_pin(void){
697 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
698 gpio_free(DC_CHECK_PIN);
699 printk("bq27541 init dc check pin request error\n");
702 gpio_direction_input(DC_CHECK_PIN);
706 struct bq27541_platform_data bq27541_info = {
707 .init_dc_check_pin = bq27541_init_dc_check_pin,
708 .dc_check_pin = DC_CHECK_PIN,
709 .bat_num = LI_LION_BAT_NUM,
710 .chgok_check_pin = CHG_OK,
711 .bat_check_pin = BAT_LOW,
714 static struct android_pmem_platform_data android_pmem_pdata = {
716 .start = PMEM_UI_BASE,
717 .size = PMEM_UI_SIZE,
722 static struct platform_device android_pmem_device = {
723 .name = "android_pmem",
726 .platform_data = &android_pmem_pdata,
731 static struct vpu_mem_platform_data vpu_mem_pdata = {
733 .start = PMEM_VPU_BASE,
734 .size = PMEM_VPU_SIZE,
738 static struct platform_device rk29_vpu_mem_device = {
742 .platform_data = &vpu_mem_pdata,
745 static struct android_pmem_platform_data android_pmem_skype_pdata = {
746 .name = "pmem_skype",
747 .start = PMEM_SKYPE_BASE,
748 .size = PMEM_SKYPE_SIZE,
753 static struct platform_device android_pmem_skype_device = {
754 .name = "android_pmem",
757 .platform_data = &android_pmem_skype_pdata,
760 #ifdef CONFIG_VIDEO_RK29XX_VOUT
761 static struct platform_device rk29_v4l2_output_devce = {
765 /*HANNSTAR_P1003 touch*/
766 #if defined (CONFIG_HANNSTAR_P1003)
767 #define TOUCH_RESET_PIN RK29_PIN6_PC3
768 #define TOUCH_INT_PIN RK29_PIN0_PA2
770 int p1003_init_platform_hw(void)
772 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
773 gpio_free(TOUCH_RESET_PIN);
774 printk("p1003_init_platform_hw gpio_request error\n");
778 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
779 gpio_free(TOUCH_INT_PIN);
780 printk("p1003_init_platform_hw gpio_request error\n");
783 gpio_pull_updown(TOUCH_INT_PIN, 1);
784 gpio_direction_output(TOUCH_RESET_PIN, 0);
786 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
788 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
794 struct p1003_platform_data p1003_info = {
796 .init_platform_hw= p1003_init_platform_hw,
800 #if defined (CONFIG_EETI_EGALAX)
801 #define TOUCH_RESET_PIN RK29_PIN6_PC3
802 #define TOUCH_INT_PIN RK29_PIN0_PA2
804 static int EETI_EGALAX_init_platform_hw(void)
806 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
807 gpio_free(TOUCH_RESET_PIN);
808 printk("p1003_init_platform_hw gpio_request error\n");
812 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
813 gpio_free(TOUCH_INT_PIN);
814 printk("p1003_init_platform_hw gpio_request error\n");
817 gpio_pull_updown(TOUCH_INT_PIN, 1);
818 gpio_direction_output(TOUCH_RESET_PIN, 0);
820 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
822 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
828 static struct eeti_egalax_platform_data eeti_egalax_info = {
830 .init_platform_hw= EETI_EGALAX_init_platform_hw,
831 .standby_pin = TOUCH_SCREEN_STANDBY_PIN,
832 .standby_value = TOUCH_SCREEN_STANDBY_VALUE,
833 .disp_on_pin = TOUCH_SCREEN_DISPLAY_PIN,
834 .disp_on_value = TOUCH_SCREEN_DISPLAY_VALUE,
838 #ifdef CONFIG_GS_KXTF9
839 #include <linux/kxtf9.h>
840 #define KXTF9_DEVICE_MAP 1
841 #define KXTF9_MAP_X (KXTF9_DEVICE_MAP-1)%2
842 #define KXTF9_MAP_Y KXTF9_DEVICE_MAP%2
843 #define KXTF9_NEG_X (KXTF9_DEVICE_MAP/2)%2
844 #define KXTF9_NEG_Y (KXTF9_DEVICE_MAP+1)/4
845 #define KXTF9_NEG_Z (KXTF9_DEVICE_MAP-1)/4
846 struct kxtf9_platform_data kxtf9_pdata = {
849 .g_range = KXTF9_G_2G,
850 .axis_map_x = KXTF9_MAP_X,
851 .axis_map_y = KXTF9_MAP_Y,
853 .negate_x = KXTF9_NEG_X,
854 .negate_y = KXTF9_NEG_Y,
855 .negate_z = KXTF9_NEG_Z,
856 //.ctrl_regc_init = KXTF9_G_2G | ODR50F,
857 //.ctrl_regb_init = ENABLE,
859 #endif /* CONFIG_GS_KXTF9 */
863 #if defined (CONFIG_GS_MMA8452)
864 #define MMA8452_INT_PIN RK29_PIN0_PA3
866 static int mma8452_init_platform_hw(void)
869 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
870 gpio_free(MMA8452_INT_PIN);
871 printk("mma8452_init_platform_hw gpio_request error\n");
874 gpio_pull_updown(MMA8452_INT_PIN, 1);
879 static struct mma8452_platform_data mma8452_info = {
882 .init_platform_hw= mma8452_init_platform_hw,
886 #if defined (CONFIG_MPU_SENSORS_MPU3050)
888 static struct mpu3050_platform_data mpu3050_data = {
890 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
891 //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
892 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
893 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
895 #if defined (CONFIG_MPU_SENSORS_KXTF9)
897 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
898 .get_slave_descr = NULL ,
900 .get_slave_descr = get_accel_slave_descr ,
902 .adapt_num = 0, // The i2c bus to which the mpu device is
904 //.irq = RK29_PIN0_PA3,
905 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
907 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
908 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
909 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
910 .orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
913 #if defined (CONFIG_MPU_SENSORS_AK8975)
915 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
916 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
918 .get_slave_descr = get_compass_slave_descr,
920 .adapt_num = 0, // The i2c bus to which the compass device is.
921 // It can be difference with mpu
923 //.irq = RK29_PIN0_PA4,
924 .bus = EXT_SLAVE_BUS_PRIMARY,
926 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
927 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
928 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
929 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
930 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
935 #if defined (CONFIG_BATTERY_BQ27510)
936 #define DC_CHECK_PIN RK29_PIN4_PA1
937 #define LI_LION_BAT_NUM 2
938 static int bq27510_init_dc_check_pin(void){
939 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
940 gpio_free(DC_CHECK_PIN);
941 printk("bq27510 init dc check pin request error\n");
944 gpio_direction_input(DC_CHECK_PIN);
948 struct bq27510_platform_data bq27510_info = {
949 .init_dc_check_pin = bq27510_init_dc_check_pin,
950 .dc_check_pin = DC_CHECK_PIN,
951 .bat_num = LI_LION_BAT_NUM,
956 /*****************************************************************************************
958 * author: kfx@rock-chips.com
959 *****************************************************************************************/
960 static int rk29_i2c0_io_init(void)
962 #ifdef CONFIG_RK29_I2C0_CONTROLLER
963 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
964 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
966 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
967 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
972 static int rk29_i2c1_io_init(void)
974 #ifdef CONFIG_RK29_I2C1_CONTROLLER
975 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
976 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
978 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
979 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
983 static int rk29_i2c2_io_init(void)
985 #ifdef CONFIG_RK29_I2C2_CONTROLLER
986 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
987 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
989 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
990 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
995 static int rk29_i2c3_io_init(void)
997 #ifdef CONFIG_RK29_I2C3_CONTROLLER
998 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
999 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1001 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
1002 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
1006 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1007 struct rk29_i2c_platform_data default_i2c0_data = {
1011 .scl_rate = 400*1000,
1012 .mode = I2C_MODE_IRQ,
1013 .io_init = rk29_i2c0_io_init,
1016 struct i2c_gpio_platform_data default_i2c0_data = {
1017 .sda_pin = RK29_PIN2_PB6,
1018 .scl_pin = RK29_PIN2_PB7,
1019 .udelay = 5, // clk = 500/udelay = 100Khz
1020 .timeout = 100,//msecs_to_jiffies(200),
1022 .io_init = rk29_i2c0_io_init,
1025 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1026 struct rk29_i2c_platform_data default_i2c1_data = {
1030 .scl_rate = 400*1000,
1031 .mode = I2C_MODE_IRQ,
1032 .io_init = rk29_i2c1_io_init,
1035 struct i2c_gpio_platform_data default_i2c1_data = {
1036 .sda_pin = RK29_PIN1_PA6,
1037 .scl_pin = RK29_PIN1_PA7,
1038 .udelay = 5, // clk = 500/udelay = 100Khz
1039 .timeout = 100,//msecs_to_jiffies(200),
1041 .io_init = rk29_i2c1_io_init,
1044 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1045 struct rk29_i2c_platform_data default_i2c2_data = {
1049 .scl_rate = 400*1000,
1050 .mode = I2C_MODE_IRQ,
1051 .io_init = rk29_i2c2_io_init,
1054 struct i2c_gpio_platform_data default_i2c2_data = {
1055 .sda_pin = RK29_PIN5_PD3,
1056 .scl_pin = RK29_PIN5_PD4,
1057 .udelay = 5, // clk = 500/udelay = 100Khz
1058 .timeout = 100,//msecs_to_jiffies(200),
1060 .io_init = rk29_i2c2_io_init,
1063 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1064 struct rk29_i2c_platform_data default_i2c3_data = {
1068 .scl_rate = 400*1000,
1069 .mode = I2C_MODE_IRQ,
1070 .io_init = rk29_i2c3_io_init,
1073 struct i2c_gpio_platform_data default_i2c3_data = {
1074 .sda_pin = RK29_PIN5_PB5,
1075 .scl_pin = RK29_PIN5_PB4,
1076 .udelay = 5, // clk = 500/udelay = 100Khz
1077 .timeout = 100,//msecs_to_jiffies(200),
1079 .io_init = rk29_i2c3_io_init,
1082 #ifdef CONFIG_I2C0_RK29
1083 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1084 #if defined (CONFIG_RK1000_CONTROL)
1086 .type = "rk1000_control",
1091 #if defined (CONFIG_SND_SOC_alc5621)
1098 #if defined (CONFIG_SND_SOC_alc5631)
1105 #if defined (CONFIG_SND_SOC_RK1000)
1107 .type = "rk1000_i2c_codec",
1112 #if defined (CONFIG_SND_SOC_WM8900)
1119 #if defined (CONFIG_BATTERY_STC3100)
1126 #if defined (CONFIG_BATTERY_BQ27510)
1131 .platform_data = &bq27510_info,
1134 #if defined (CONFIG_RTC_HYM8563)
1136 .type = "rtc_hym8563",
1139 .irq = RK29_PIN0_PA1,
1142 #if defined (CONFIG_GS_MMA8452)
1144 .type = "gs_mma8452",
1147 .irq = MMA8452_INT_PIN,
1148 .platform_data = &mma8452_info,
1151 #if defined (CONFIG_COMPASS_AK8973)
1156 .irq = RK29_PIN0_PA4,
1159 #if defined (CONFIG_COMPASS_AK8975)
1164 .irq = RK29_PIN0_PA4,
1168 #if defined (CONFIG_MPU_SENSORS_MPU3050)
1173 .irq = RK29_PIN5_PA3,
1174 .platform_data = &mpu3050_data,
1177 #if defined (CONFIG_SND_SOC_CS42L52)
1182 .platform_data = &cs42l52_info,
1185 #if defined (CONFIG_RTC_M41T66)
1187 .type = "rtc-M41T66",
1190 .irq = RK29_PIN0_PA1,
1195 #if defined (CONFIG_ANX7150)
1196 struct hdmi_platform_data anx7150_data = {
1197 //.io_init = anx7150_io_init,
1200 #ifdef CONFIG_I2C1_RK29
1201 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1202 #if defined (CONFIG_RK1000_CONTROL1)
1204 .type = "rk1000_control",
1209 #if defined (CONFIG_ANX7150)
1212 .addr = 0x39, //0x39, 0x3d
1214 .irq = RK29_PIN1_PD7,
1215 .platform_data = &anx7150_data,
1218 #ifdef CONFIG_BU92747GUW_CIR
1220 .type ="bu92747_cir",
1223 .irq = BU92747_CIR_IRQ_PIN,
1224 .platform_data = &bu92747guw_pdata,
1231 #ifdef CONFIG_I2C2_RK29
1232 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1233 #if defined (CONFIG_HANNSTAR_P1003)
1235 .type = "p1003_touch",
1237 .flags = 0, //I2C_M_NEED_DELAY
1238 .irq = RK29_PIN0_PA2,
1239 .platform_data = &p1003_info,
1243 #if defined (CONFIG_EETI_EGALAX)
1245 .type = "egalax_i2c",
1248 .irq = RK29_PIN0_PA2,
1249 .platform_data = &eeti_egalax_info,
1252 #if defined (CONFIG_TOUCHSCREEN_GT819)
1254 .type = "Goodix-TS",
1257 .irq =RK29_PIN0_PA2,
1258 .platform_data = &goodix_info,
1261 #if defined (CONFIG_TOUCHSCREEN_FT5406)
1264 .addr = 0x38, //0x70,
1266 .irq =RK29_PIN0_PA2, // support goodix tp detect, 20110706
1267 .platform_data = &ft5406_info,
1273 #ifdef CONFIG_I2C3_RK29
1274 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1275 #if defined (CONFIG_BATTERY_BQ27541)
1280 .platform_data = &bq27541_info,
1286 /*****************************************************************************************
1288 * author: ddl@rock-chips.com
1289 *****************************************************************************************/
1290 #ifdef CONFIG_VIDEO_RK29
1291 #define CONFIG_SENSOR_POWER_IOCTL_USR 0
1292 #define CONFIG_SENSOR_RESET_IOCTL_USR 0
1293 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0
1294 #define CONFIG_SENSOR_FLASH_IOCTL_USR 0
1296 #if CONFIG_SENSOR_POWER_IOCTL_USR
1297 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
1299 #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
1303 #if CONFIG_SENSOR_RESET_IOCTL_USR
1304 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
1306 #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
1310 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1311 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
1313 #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
1317 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1318 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
1320 #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
1324 static struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
1325 #if CONFIG_SENSOR_POWER_IOCTL_USR
1326 .sensor_power_cb = sensor_power_usr_cb,
1328 .sensor_power_cb = NULL,
1331 #if CONFIG_SENSOR_RESET_IOCTL_USR
1332 .sensor_reset_cb = sensor_reset_usr_cb,
1334 .sensor_reset_cb = NULL,
1337 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1338 .sensor_powerdown_cb = sensor_powerdown_usr_cb,
1340 .sensor_powerdown_cb = NULL,
1343 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1344 .sensor_flash_cb = sensor_flash_usr_cb,
1346 .sensor_flash_cb = NULL,
1349 #include "../../../drivers/media/video/rk29_camera.c"
1351 /*****************************************************************************************
1353 * author: nzy@rock-chips.com
1354 *****************************************************************************************/
1355 #ifdef CONFIG_BACKLIGHT_RK29_BL
1357 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
1358 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
1359 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
1360 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
1364 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
1365 #define PWM_MUX_MODE GPIO1L_PWM0
1366 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1367 #define PWM_GPIO RK29_PIN1_PB5
1368 #define PWM_EFFECT_VALUE 1
1370 #define LCD_DISP_ON_PIN
1372 #ifdef LCD_DISP_ON_PIN
1373 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
1374 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
1376 #define BL_EN_PIN RK29_PIN6_PD0
1377 #define BL_EN_VALUE GPIO_HIGH
1379 static int rk29_backlight_io_init(void)
1383 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1384 #ifdef LCD_DISP_ON_PIN
1385 // rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
1387 ret = gpio_request(BL_EN_PIN, NULL);
1390 gpio_free(BL_EN_PIN);
1393 gpio_direction_output(BL_EN_PIN, 0);
1394 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1399 static int rk29_backlight_io_deinit(void)
1402 #ifdef LCD_DISP_ON_PIN
1403 gpio_free(BL_EN_PIN);
1405 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1410 static int rk29_backlight_pwm_suspend(void)
1413 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1414 if (gpio_request(PWM_GPIO, NULL)) {
1415 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
1418 gpio_direction_output(PWM_GPIO, GPIO_LOW);
1419 #ifdef LCD_DISP_ON_PIN
1420 gpio_direction_output(BL_EN_PIN, 0);
1421 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
1426 static int rk29_backlight_pwm_resume(void)
1428 gpio_free(PWM_GPIO);
1429 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1431 #ifdef LCD_DISP_ON_PIN
1433 gpio_direction_output(BL_EN_PIN, 1);
1434 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1439 struct rk29_bl_info rk29_bl_info = {
1441 .bl_ref = PWM_EFFECT_VALUE,
1442 .io_init = rk29_backlight_io_init,
1443 .io_deinit = rk29_backlight_io_deinit,
1444 .pwm_suspend = rk29_backlight_pwm_suspend,
1445 .pwm_resume = rk29_backlight_pwm_resume,
1448 /*****************************************************************************************
1449 * pwm voltage regulator devices
1450 ******************************************************************************************/
1451 #if defined (CONFIG_RK29_PWM_REGULATOR)
1453 #define REGULATOR_PWM_ID 2
1454 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1455 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1456 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1457 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1459 static struct regulator_consumer_supply pwm_consumers[] = {
1465 static struct regulator_init_data rk29_pwm_regulator_data = {
1471 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1473 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1474 .consumer_supplies = pwm_consumers,
1477 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1478 .pwm_id = REGULATOR_PWM_ID,
1479 .pwm_gpio = REGULATOR_PWM_GPIO,
1480 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1481 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1482 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1483 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1484 .init_data = &rk29_pwm_regulator_data,
1487 static struct platform_device rk29_device_pwm_regulator = {
1488 .name = "pwm-voltage-regulator",
1491 .platform_data = &rk29_regulator_pwm_platform_data,
1497 /*****************************************************************************************
1499 *****************************************************************************************/
1500 #ifdef CONFIG_SDMMC0_RK29
1501 static int rk29_sdmmc0_cfg_gpio(void)
1503 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1504 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1505 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1506 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1507 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1508 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1510 #ifdef CONFIG_SDMMC_RK29_OLD
1511 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
1513 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
1516 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1517 gpio_request(RK29_PIN5_PD5,"sdmmc");
1519 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1521 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1523 gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
1528 #define CONFIG_SDMMC0_USE_DMA
1529 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1530 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1531 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1532 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1533 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1534 .io_init = rk29_sdmmc0_cfg_gpio,
1535 .dma_name = "sd_mmc",
1536 #ifdef CONFIG_SDMMC0_USE_DMA
1541 .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
1542 .enable_sd_wakeup = 0,
1545 #ifdef CONFIG_SDMMC1_RK29
1546 #define CONFIG_SDMMC1_USE_DMA
1547 static int rk29_sdmmc1_cfg_gpio(void)
1549 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1550 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1551 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1552 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1553 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1554 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1555 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1559 #ifdef CONFIG_WIFI_CONTROL_FUNC
1560 static int rk29sdk_wifi_status(struct device *dev);
1561 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1564 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1566 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1567 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1568 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1569 MMC_VDD_32_33|MMC_VDD_33_34),
1570 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1571 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1572 .io_init = rk29_sdmmc1_cfg_gpio,
1574 #ifdef CONFIG_SDMMC1_USE_DMA
1579 #ifdef CONFIG_WIFI_CONTROL_FUNC
1580 .status = rk29sdk_wifi_status,
1581 .register_status_notify = rk29sdk_wifi_status_register,
1584 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1589 #ifdef CONFIG_WIFI_CONTROL_FUNC
1590 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1591 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1592 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1594 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1595 static void (*wifi_status_cb)(int card_present, void *dev_id);
1596 static void *wifi_status_cb_devid;
1597 int rk29sdk_wifi_power_state = 0;
1598 int rk29sdk_bt_power_state = 0;
1600 static int rk29sdk_wifi_status(struct device *dev)
1602 return rk29sdk_wifi_cd;
1605 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1609 wifi_status_cb = callback;
1610 wifi_status_cb_devid = dev_id;
1614 static int rk29sdk_wifi_bt_gpio_control_init(void)
1616 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1617 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1621 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1622 pr_info("%s: request wifi reset gpio failed\n", __func__);
1623 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1627 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1628 pr_info("%s: request bt reset gpio failed\n", __func__);
1629 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1633 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1634 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1635 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1637 pr_info("%s: init finished\n",__func__);
1642 static int rk29sdk_wifi_power(int on)
1644 pr_info("%s: %d\n", __func__, on);
1646 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
1647 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
1649 pr_info("wifi turn on power\n");
1651 if (!rk29sdk_bt_power_state){
1652 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1654 pr_info("wifi shut off power\n");
1657 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1659 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1663 rk29sdk_wifi_power_state = on;
1667 static int rk29sdk_wifi_reset_state;
1668 static int rk29sdk_wifi_reset(int on)
1670 pr_info("%s: %d\n", __func__, on);
1671 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1673 rk29sdk_wifi_reset_state = on;
1677 int rk29sdk_wifi_set_carddetect(int val)
1679 pr_info("%s:%d\n", __func__, val);
1680 rk29sdk_wifi_cd = val;
1681 if (wifi_status_cb){
1682 wifi_status_cb(val, wifi_status_cb_devid);
1684 pr_warning("%s, nobody to notify\n", __func__);
1688 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
1690 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
1691 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
1692 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
1693 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
1694 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
1697 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
1699 if (section == PREALLOC_WLAN_SEC_NUM)
1700 return wlan_static_skb;
1702 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
1705 if (wifi_mem_array[section].size < size)
1708 return wifi_mem_array[section].mem_ptr;
1711 int __init rk29sdk_init_wifi_mem(void)
1716 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
1717 wlan_static_skb[i] = dev_alloc_skb(
1718 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
1720 if (!wlan_static_skb[i])
1724 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
1725 wifi_mem_array[i].mem_ptr =
1726 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
1728 if (!wifi_mem_array[i].mem_ptr)
1734 pr_err("Failed to mem_alloc for WLAN\n");
1735 for (j = 0 ; j < i ; j++)
1736 kfree(wifi_mem_array[j].mem_ptr);
1738 i = WLAN_SKB_BUF_NUM;
1741 pr_err("Failed to skb_alloc for WLAN\n");
1742 for (j = 0 ; j < i ; j++)
1743 dev_kfree_skb(wlan_static_skb[j]);
1748 static struct wifi_platform_data rk29sdk_wifi_control = {
1749 .set_power = rk29sdk_wifi_power,
1750 .set_reset = rk29sdk_wifi_reset,
1751 .set_carddetect = rk29sdk_wifi_set_carddetect,
1752 .mem_prealloc = rk29sdk_mem_prealloc,
1754 static struct platform_device rk29sdk_wifi_device = {
1755 .name = "bcm4329_wlan",
1758 .platform_data = &rk29sdk_wifi_control,
1764 /* bluetooth rfkill device */
1765 static struct platform_device rk29sdk_rfkill = {
1766 .name = "rk29sdk_rfkill",
1771 #ifdef CONFIG_VIVANTE
1772 #define GPU_HIGH_CLOCK 552
1773 #define GPU_LOW_CLOCK (periph_pll_default / 1000000) /* same as general pll clock rate below */
1774 static struct resource resources_gpu[] = {
1779 .flags = IORESOURCE_IRQ,
1783 .start = RK29_GPU_PHYS,
1784 .end = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
1785 .flags = IORESOURCE_MEM,
1789 .start = PMEM_GPU_BASE,
1790 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
1791 .flags = IORESOURCE_MEM,
1795 .start = GPU_LOW_CLOCK,
1796 .end = GPU_HIGH_CLOCK,
1797 .flags = IORESOURCE_IO,
1800 static struct platform_device rk29_device_gpu = {
1803 .num_resources = ARRAY_SIZE(resources_gpu),
1804 .resource = resources_gpu,
1808 #ifdef CONFIG_KEYS_RK29
1809 extern struct rk29_keys_platform_data rk29_keys_pdata;
1810 static struct platform_device rk29_device_keys = {
1811 .name = "rk29-keypad",
1814 .platform_data = &rk29_keys_pdata,
1819 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1820 struct gpio_led rk29_leds[] = {
1822 .name = "rk29_red_led",
1823 .gpio = RK29_PIN4_PB2,
1824 .default_trigger = "timer",
1826 .retain_state_suspended = 1,
1827 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1830 .name = "rk29_green_led",
1831 .gpio = RK29_PIN4_PB1,
1832 .default_trigger = "timer",
1834 .retain_state_suspended = 1,
1835 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1838 .name = "rk29_blue_led",
1839 .gpio = RK29_PIN4_PB0,
1840 .default_trigger = "timer",
1842 .retain_state_suspended = 1,
1843 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1847 struct gpio_led_platform_data rk29_leds_pdata = {
1849 .num_leds = ARRAY_SIZE(rk29_leds),
1852 struct platform_device rk29_device_gpio_leds = {
1853 .name = "leds-gpio",
1856 .platform_data = &rk29_leds_pdata,
1861 #ifdef CONFIG_LEDS_NEWTON_PWM
1862 static struct led_newton_pwm rk29_pwm_leds[] = {
1864 .name = "power_led",
1866 .pwm_gpio = RK29_PIN5_PD2,
1867 .pwm_iomux_name = GPIO5D2_PWM1_UART1SIRIN_NAME,
1868 .pwm_iomux_pwm = GPIO5H_PWM1,
1869 .pwm_iomux_gpio = GPIO5H_GPIO5D2,
1875 static struct led_newton_pwm_platform_data rk29_pwm_leds_pdata = {
1876 .leds = &rk29_pwm_leds,
1877 .num_leds = ARRAY_SIZE(rk29_pwm_leds),
1880 static struct platform_device rk29_device_pwm_leds = {
1881 .name = "leds_newton_pwm",
1884 .platform_data = &rk29_pwm_leds_pdata,
1889 static void __init rk29_board_iomux_init(void)
1891 #ifdef CONFIG_RK29_PWM_REGULATOR
1892 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1896 static struct platform_device *devices[] __initdata = {
1898 #ifdef CONFIG_RK29_WATCHDOG
1902 #ifdef CONFIG_UART1_RK29
1905 #ifdef CONFIG_UART0_RK29
1908 #ifdef CONFIG_UART2_RK29
1911 #ifdef CONFIG_UART3_RK29
1915 #ifdef CONFIG_RK29_PWM_REGULATOR
1916 &rk29_device_pwm_regulator,
1918 #ifdef CONFIG_SPIM0_RK29
1919 &rk29xx_device_spi0m,
1921 #ifdef CONFIG_SPIM1_RK29
1922 &rk29xx_device_spi1m,
1924 #ifdef CONFIG_ADC_RK29
1927 #ifdef CONFIG_I2C0_RK29
1930 #ifdef CONFIG_I2C1_RK29
1933 #ifdef CONFIG_I2C2_RK29
1936 #ifdef CONFIG_I2C3_RK29
1940 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1941 &rk29_device_iis_2ch,
1943 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1944 &rk29_device_iis_8ch,
1947 #ifdef CONFIG_KEYS_RK29
1950 #ifdef CONFIG_KEYS_RK29_NEWTON
1953 #ifdef CONFIG_SDMMC0_RK29
1954 &rk29_device_sdmmc0,
1956 #ifdef CONFIG_SDMMC1_RK29
1957 &rk29_device_sdmmc1,
1960 #ifdef CONFIG_MTD_NAND_RK29XX
1961 &rk29xx_device_nand,
1964 #ifdef CONFIG_WIFI_CONTROL_FUNC
1965 &rk29sdk_wifi_device,
1972 #ifdef CONFIG_MTD_NAND_RK29
1976 #ifdef CONFIG_FB_RK29
1978 &rk29_device_dma_cpy,
1980 #ifdef CONFIG_BACKLIGHT_RK29_BL
1981 &rk29_device_backlight,
1983 #ifdef CONFIG_BACKLIGHT_RK29_NEWTON_BL
1984 &rk29_device_backlight,
1986 #ifdef CONFIG_RK29_VMAC
1989 #ifdef CONFIG_VIVANTE
1992 #ifdef CONFIG_VIDEO_RK29
1993 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1994 #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
1995 &rk29_soc_camera_pdrv_0,
1997 &rk29_soc_camera_pdrv_1,
1998 &android_pmem_cam_device,
2000 &android_pmem_skype_device,
2001 &android_pmem_device,
2002 &rk29_vpu_mem_device,
2003 #ifdef CONFIG_USB20_OTG
2004 &rk29_device_usb20_otg,
2006 #ifdef CONFIG_USB20_HOST
2007 &rk29_device_usb20_host,
2009 #ifdef CONFIG_USB11_HOST
2010 &rk29_device_usb11_host,
2012 #ifdef CONFIG_USB_ANDROID
2013 &android_usb_device,
2014 &usb_mass_storage_device,
2016 #ifdef CONFIG_USB_ANDROID_RNDIS
2019 #ifdef CONFIG_RK29_IPP
2022 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2023 &rk29_v4l2_output_devce,
2025 #ifdef CONFIG_RK29_NEWTON
2026 &rk29_device_newton,
2028 #ifdef CONFIG_RK_IRDA
2031 #ifdef CONFIG_LEDS_GPIO_PLATFORM
2032 &rk29_device_gpio_leds,
2034 #ifdef CONFIG_LEDS_NEWTON_PWM
2035 &rk29_device_pwm_leds,
2037 #ifdef CONFIG_SND_RK29_SOC_CS42L52
2038 &rk29_cs42l52_device,
2042 /*****************************************************************************************
2044 * author: cmc@rock-chips.com
2045 *****************************************************************************************/
2046 static int rk29_vmac_register_set(void)
2048 //config rk29 vmac as rmii, 100MHz
2049 u32 value= readl(RK29_GRF_BASE + 0xbc);
2050 value = (value & 0xfff7ff) | (0x400);
2051 writel(value, RK29_GRF_BASE + 0xbc);
2055 static int rk29_rmii_io_init(void)
2060 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2062 gpio_free(RK29_PIN6_PB0);
2063 printk("-------request RK29_PIN6_PB0 fail--------\n");
2067 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2068 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2073 static int rk29_rmii_io_deinit(void)
2076 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2077 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2079 gpio_free(RK29_PIN6_PB0);
2083 static int rk29_rmii_power_control(int enable)
2087 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2088 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2091 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2092 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2097 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2098 .vmac_register_set = rk29_vmac_register_set,
2099 .rmii_io_init = rk29_rmii_io_init,
2100 .rmii_io_deinit = rk29_rmii_io_deinit,
2101 .rmii_power_control = rk29_rmii_power_control,
2104 /*****************************************************************************************
2106 * author: cmc@rock-chips.com
2107 *****************************************************************************************/
2108 #define SPI_CHIPSELECT_NUM 2
2109 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2112 .cs_gpio = RK29_PIN2_PC1,
2113 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2114 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2118 .cs_gpio = RK29_PIN1_PA4,
2119 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2120 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2124 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2127 .cs_gpio = RK29_PIN2_PC5,
2128 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2129 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2133 .cs_gpio = RK29_PIN1_PA3,
2134 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2135 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2139 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2144 for (i=0; i<cs_num; i++) {
2145 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2152 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2157 static int spi_io_fix_leakage_bug(void)
2160 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2165 static int spi_io_resume_leakage_bug(void)
2168 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2173 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2174 .num_chipselect = SPI_CHIPSELECT_NUM,
2175 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2176 .io_init = spi_io_init,
2177 .io_deinit = spi_io_deinit,
2178 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2179 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2182 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2183 .num_chipselect = SPI_CHIPSELECT_NUM,
2184 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2185 .io_init = spi_io_init,
2186 .io_deinit = spi_io_deinit,
2187 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2188 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2191 /*****************************************************************************************
2192 * xpt2046 touch panel
2193 * author: cmc@rock-chips.com
2194 *****************************************************************************************/
2195 #define XPT2046_GPIO_INT RK29_PIN0_PA3
2196 #define DEBOUNCE_REPTIME 3
2198 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_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_320X480_CBN_SPI)
2214 static struct xpt2046_platform_data xpt2046_info = {
2223 .debounce_rep = DEBOUNCE_REPTIME,
2225 .gpio_pendown = XPT2046_GPIO_INT,
2226 .penirq_recheck_delay_usecs = 1,
2228 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2229 static struct xpt2046_platform_data xpt2046_info = {
2238 .debounce_rep = DEBOUNCE_REPTIME,
2240 .gpio_pendown = XPT2046_GPIO_INT,
2242 .penirq_recheck_delay_usecs = 1,
2244 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2245 static struct xpt2046_platform_data xpt2046_info = {
2254 .debounce_rep = DEBOUNCE_REPTIME,
2256 .gpio_pendown = XPT2046_GPIO_INT,
2258 .penirq_recheck_delay_usecs = 1,
2262 static struct spi_board_info board_spi_devices[] = {
2263 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
2264 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2266 .modalias = "xpt2046_ts",
2268 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2270 .irq = XPT2046_GPIO_INT,
2271 .platform_data = &xpt2046_info,
2277 static void __init rk29_gic_init_irq(void)
2279 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2280 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2283 static void __init machine_rk29_init_irq(void)
2285 rk29_gic_init_irq();
2289 static struct cpufreq_frequency_table freq_table[] = {
2290 { .index = 1200000, .frequency = 408000 },
2291 { .index = 1200000, .frequency = 816000 },
2292 { .index = 1300000, .frequency = 1008000 },
2293 { .frequency = CPUFREQ_TABLE_END },
2296 static void __init machine_rk29_board_init(void)
2298 rk29_board_iomux_init();
2301 board_update_cpufreq_table(freq_table);
2303 platform_add_devices(devices, ARRAY_SIZE(devices));
2304 #ifdef CONFIG_I2C0_RK29
2305 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2306 ARRAY_SIZE(board_i2c0_devices));
2308 #ifdef CONFIG_I2C1_RK29
2309 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2310 ARRAY_SIZE(board_i2c1_devices));
2312 #ifdef CONFIG_I2C2_RK29
2313 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2314 ARRAY_SIZE(board_i2c2_devices));
2316 #ifdef CONFIG_I2C3_RK29
2317 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2318 ARRAY_SIZE(board_i2c3_devices));
2321 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2323 #ifdef CONFIG_WIFI_CONTROL_FUNC
2324 rk29sdk_wifi_bt_gpio_control_init();
2325 rk29sdk_init_wifi_mem();
2328 board_usb_detect_init(RK29_PIN0_PA0);
2329 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
2331 bu92747guw_io_init();
2336 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2337 char **cmdline, struct meminfo *mi)
2340 mi->bank[0].start = RK29_SDRAM_PHYS;
2341 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
2342 mi->bank[0].size = LINUX_SIZE;
2343 #if SDRAM_SIZE > SZ_512M
2345 mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
2346 mi->bank[1].size = SDRAM_SIZE - SZ_512M;
2350 static void __init machine_rk29_mapio(void)
2352 rk29_map_common_io();
2353 rk29_setup_early_printk();
2355 rk29_clock_init(periph_pll_default);
2357 ddr_init(DDR_TYPE, DDR_FREQ);
2360 MACHINE_START(RK29, "RK29board")
2361 /* UART for LL DEBUG */
2362 .phys_io = RK29_UART1_PHYS & 0xfff00000,
2363 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2364 .boot_params = RK29_SDRAM_PHYS + 0x88000,
2365 .fixup = machine_rk29_fixup,
2366 .map_io = machine_rk29_mapio,
2367 .init_irq = machine_rk29_init_irq,
2368 .init_machine = machine_rk29_board_init,
2369 .timer = &rk29_timer,