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"
64 #ifdef CONFIG_VIDEO_RK29
65 /*---------------- Camera Sensor Macro Define Begin ------------------------*/
66 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
67 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV2655 /* back camera sensor */
68 #define CONFIG_SENSOR_IIC_ADDR_0 0//0x60
69 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0 1
70 #define CONFIG_SENSOR_POWER_PIN_0 INVALID_GPIO
71 #define CONFIG_SENSOR_RESET_PIN_0 INVALID_GPIO
72 #define CONFIG_SENSOR_POWERDN_PIN_0 INVALID_GPIO
73 #define CONFIG_SENSOR_FALSH_PIN_0 INVALID_GPIO
74 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
75 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
76 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
77 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
79 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV3640 /* front camera sensor */
80 #define CONFIG_SENSOR_IIC_ADDR_1 0x78
81 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1 1
82 #define CONFIG_SENSOR_POWER_PIN_1 INVALID_GPIO
83 #define CONFIG_SENSOR_RESET_PIN_1 INVALID_GPIO
84 #define CONFIG_SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
85 #define CONFIG_SENSOR_FALSH_PIN_1 INVALID_GPIO
86 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
87 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
88 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
89 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
90 #endif //#ifdef CONFIG_VIDEO_RK29
91 /*---------------- Camera Sensor Configuration Macro End------------------------*/
92 #include "../../../drivers/media/video/rk29_camera.c"
93 /*---------------- 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_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 #define MEM_FBIPP_SIZE SZ_8M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4
114 #define MEM_FBIPP_SIZE 0
116 #if SDRAM_SIZE > SZ_512M
117 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
119 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
121 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
122 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
123 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
124 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
125 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
126 #define MEM_FBIPP_BASE (MEM_FB_BASE - MEM_FBIPP_SIZE)
127 #define LINUX_SIZE (MEM_FBIPP_BASE - RK29_SDRAM_PHYS)
129 #define PREALLOC_WLAN_SEC_NUM 4
130 #define PREALLOC_WLAN_BUF_NUM 160
131 #define PREALLOC_WLAN_SECTION_HEADER 24
133 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
134 #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
135 #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
136 #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
138 #define WLAN_SKB_BUF_NUM 16
140 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
142 struct wifi_mem_prealloc {
147 extern struct sys_timer rk29_timer;
149 static int rk29_nand_io_init(void)
154 struct rk29_nand_platform_data rk29_nand_data = {
155 .width = 1, /* data bus width in bytes */
156 .hw_ecc = 1, /* hw ecc 0: soft ecc */
158 .io_init = rk29_nand_io_init,
161 #define TOUCH_SCREEN_STANDBY_PIN RK29_PIN6_PD1
162 #define TOUCH_SCREEN_STANDBY_VALUE GPIO_HIGH
163 #define TOUCH_SCREEN_DISPLAY_PIN INVALID_GPIO
164 #define TOUCH_SCREEN_DISPLAY_VALUE GPIO_HIGH
165 #ifdef CONFIG_FB_RK29
166 /*****************************************************************************************
168 * author: zyw@rock-chips.com
169 *****************************************************************************************/
170 //#ifdef CONFIG_LCD_TD043MGEA1
171 #define LCD_TXD_PIN INVALID_GPIO
172 #define LCD_CLK_PIN INVALID_GPIO
173 #define LCD_CS_PIN INVALID_GPIO
174 /*****************************************************************************************
175 * frame buffe devices
176 * author: zyw@rock-chips.com
177 *****************************************************************************************/
179 #define FB_DISPLAY_ON_PIN RK29_PIN6_PD1
180 #define FB_LCD_STANDBY_PIN RK29_PIN1_PD6
181 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
182 #define FB_MCU_FMK_PIN INVALID_GPIO
184 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
185 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
186 //#define FB_LCD_STANDBY_VALUE GPIO_LOW
189 #define NEWTON_LCD_DISP RK29_PIN1_PD6
190 #define NEWTON_LCD_EN RK29_PIN6_PD1
191 static int rk29_lcd_io_init(void)
197 static int rk29_lcd_io_deinit(void)
203 static struct rk29lcd_info rk29_lcd_info = {
204 .txd_pin = LCD_TXD_PIN,
205 .clk_pin = LCD_CLK_PIN,
206 .cs_pin = LCD_CS_PIN,
207 .io_init = rk29_lcd_io_init,
208 .io_deinit = rk29_lcd_io_deinit,
211 int rk29_fb_io_enable(void)
213 gpio_direction_output(NEWTON_LCD_DISP, 0);
214 gpio_set_value(NEWTON_LCD_DISP,GPIO_HIGH);
215 gpio_direction_output(NEWTON_LCD_EN, 0);
216 gpio_set_value(NEWTON_LCD_EN,GPIO_LOW);
220 int rk29_fb_io_disable(void)
222 gpio_direction_output(NEWTON_LCD_DISP, 0);
223 gpio_set_value(NEWTON_LCD_DISP,GPIO_LOW);
224 gpio_direction_output(NEWTON_LCD_EN, 0);
225 gpio_set_value(NEWTON_LCD_EN,GPIO_HIGH);
229 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
231 if(gpio_request(NEWTON_LCD_DISP,NULL) != 0){
232 gpio_free(NEWTON_LCD_DISP);
233 printk("NEWTON_LCD_DISP gpio_request error\n");
236 if(gpio_request(NEWTON_LCD_EN,NULL) != 0){
237 gpio_free(NEWTON_LCD_EN);
238 printk("NEWTON_LCD_EN gpio_request error\n");
241 rk29_fb_io_enable(); //enable it
246 static struct rk29fb_info rk29_fb_info = {
248 .mcu_fmk_pin = FB_MCU_FMK_PIN,
249 .lcd_info = &rk29_lcd_info,
250 .io_init = rk29_fb_io_init,
251 .io_enable = rk29_fb_io_enable,
252 .io_disable = rk29_fb_io_disable,
255 /* rk29 fb resource */
256 static struct resource rk29_fb_resource[] = {
259 .start = RK29_LCDC_PHYS,
260 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
261 .flags = IORESOURCE_MEM,
267 .flags = IORESOURCE_IRQ,
271 .start = MEM_FB_BASE,
272 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
273 .flags = IORESOURCE_MEM,
275 #ifdef CONFIG_FB_WORK_IPP
277 .name = "win1 ipp buf",
278 .start = MEM_FBIPP_BASE,
279 .end = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
280 .flags = IORESOURCE_MEM,
286 struct platform_device rk29_device_fb = {
289 .num_resources = ARRAY_SIZE(rk29_fb_resource),
290 .resource = rk29_fb_resource,
292 .platform_data = &rk29_fb_info,
296 struct platform_device rk29_device_dma_cpy = {
297 .name = "dma_memcpy",
304 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
305 #define BU92747GUW_RESET_PIN RK29_PIN3_PD4// INVALID_GPIO //
306 #define BU92747GUW_RESET_MUX_NAME GPIO3D4_HOSTWRN_NAME//NULL //
307 #define BU92747GUW_RESET_MUX_MODE GPIO3H_GPIO3D4//NULL //
309 #define BU92747GUW_PWDN_PIN RK29_PIN3_PD3//RK29_PIN5_PA7 //
310 #define BU92747GUW_PWDN_MUX_NAME GPIO3D3_HOSTRDN_NAME//GPIO5A7_HSADCDATA2_NAME //
311 #define BU92747GUW_PWDN_MUX_MODE GPIO3H_GPIO3D3//GPIO5L_GPIO5A7 //
313 static int bu92747guw_io_init(void)
318 if(BU92747GUW_RESET_MUX_NAME != NULL)
320 rk29_mux_api_set(BU92747GUW_RESET_MUX_NAME, BU92747GUW_RESET_MUX_MODE);
322 ret = gpio_request(BU92747GUW_RESET_PIN, NULL);
325 gpio_free(BU92747GUW_RESET_PIN);
326 printk(">>>>>> BU92747GUW_RESET_PIN gpio_request err \n ");
328 gpio_direction_output(BU92747GUW_RESET_PIN, GPIO_HIGH);
331 if(BU92747GUW_PWDN_MUX_NAME != NULL)
333 rk29_mux_api_set(BU92747GUW_PWDN_MUX_NAME, BU92747GUW_PWDN_MUX_MODE);
335 ret = gpio_request(BU92747GUW_PWDN_PIN, NULL);
338 gpio_free(BU92747GUW_PWDN_PIN);
339 printk(">>>>>> BU92747GUW_PWDN_PIN gpio_request err \n ");
342 //power down as default
343 gpio_direction_output(BU92747GUW_PWDN_PIN, GPIO_LOW);
349 static int bu92747guw_io_deinit(void)
351 gpio_free(BU92747GUW_PWDN_PIN);
352 gpio_free(BU92747GUW_RESET_PIN);
356 //power ctl func is share with irda and remote
357 static int nPowerOnCount = 0;
358 static DEFINE_MUTEX(bu92747_power_mutex);
360 //1---power on; 0---power off
361 static int bu92747guw_power_ctl(int enable)
363 printk("%s \n",__FUNCTION__);
365 mutex_lock(&bu92747_power_mutex);
368 if (nPowerOnCount == 1) {//power on first
370 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_HIGH);
371 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_LOW);
373 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_HIGH);
379 if (nPowerOnCount <= 0) {//power down final
382 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_LOW);
385 mutex_unlock(&bu92747_power_mutex);
390 #ifdef CONFIG_RK_IRDA
391 #define IRDA_IRQ_PIN RK29_PIN5_PB2
392 #define IRDA_IRQ_MUX_NAME GPIO5B2_HSADCDATA5_NAME
393 #define IRDA_IRQ_MUX_MODE GPIO5L_GPIO5B2
395 int irda_iomux_init(void)
400 if(IRDA_IRQ_MUX_NAME != NULL)
402 rk29_mux_api_set(IRDA_IRQ_MUX_NAME, IRDA_IRQ_MUX_MODE);
404 ret = gpio_request(IRDA_IRQ_PIN, NULL);
407 gpio_free(IRDA_IRQ_PIN);
408 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
410 gpio_pull_updown(IRDA_IRQ_PIN, GPIO_HIGH);
411 gpio_direction_input(IRDA_IRQ_PIN);
416 int irda_iomux_deinit(void)
418 gpio_free(IRDA_IRQ_PIN);
422 static struct irda_info rk29_irda_info = {
423 .intr_pin = IRDA_IRQ_PIN,
424 .iomux_init = irda_iomux_init,
425 .iomux_deinit = irda_iomux_deinit,
426 .irda_pwr_ctl = bu92747guw_power_ctl,
429 static struct platform_device irda_device = {
430 #ifdef CONFIG_RK_IRDA_NET
433 .name = "bu92747_irda",
437 .platform_data = &rk29_irda_info,
442 #ifdef CONFIG_BU92747GUW_CIR
443 #define BU92747_CIR_IRQ_PIN RK29_PIN5_PB0
444 #define CIR_IRQ_PIN_IOMUX_NAME GPIO5B0_HSADCDATA3_NAME
445 #define CIR_IRQ_PIN_IOMUX_VALUE GPIO5L_GPIO5B0
446 static int cir_iomux_init(void)
448 if (CIR_IRQ_PIN_IOMUX_NAME)
449 rk29_mux_api_set(CIR_IRQ_PIN_IOMUX_NAME, CIR_IRQ_PIN_IOMUX_VALUE);
450 rk29_mux_api_set(GPIO5A7_HSADCDATA2_NAME, GPIO5L_GPIO5A7);
454 static struct bu92747guw_platform_data bu92747guw_pdata = {
455 .intr_pin = BU92747_CIR_IRQ_PIN,
456 .iomux_init = cir_iomux_init,
457 .iomux_deinit = NULL,
458 .cir_pwr_ctl = bu92747guw_power_ctl,
461 #ifdef CONFIG_RK29_NEWTON
462 struct rk29_newton_data rk29_newton_info = {
464 struct platform_device rk29_device_newton = {
465 .name = "rk29_newton",
468 .platform_data = &rk29_newton_info,
472 #if defined (CONFIG_TOUCHSCREEN_FT5406)
473 #define TOUCH_RESET_PIN RK29_PIN6_PC3
474 #define TOUCH_INT_PIN RK29_PIN0_PA2
475 int ft5406_init_platform_hw(void)
477 printk("ft5406_init_platform_hw\n");
478 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
479 gpio_free(TOUCH_RESET_PIN);
480 printk("ft5406_init_platform_hw gpio_request error\n");
484 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
485 gpio_free(TOUCH_INT_PIN);
486 printk("ift5406_init_platform_hw gpio_request error\n");
490 gpio_direction_output(TOUCH_RESET_PIN, 0);
491 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
493 gpio_direction_input(TOUCH_INT_PIN);
495 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
500 void ft5406_exit_platform_hw(void)
502 printk("ft5406_exit_platform_hw\n");
503 gpio_free(TOUCH_RESET_PIN);
504 gpio_free(TOUCH_INT_PIN);
507 int ft5406_platform_sleep(void)
509 printk("ft5406_platform_sleep\n");
510 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
514 int ft5406_platform_wakeup(void)
516 printk("ft5406_platform_wakeup\n");
517 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
521 struct ft5406_platform_data ft5406_info = {
523 .init_platform_hw= ft5406_init_platform_hw,
524 .exit_platform_hw= ft5406_exit_platform_hw,
525 .platform_sleep = ft5406_platform_sleep,
526 .platform_wakeup = ft5406_platform_wakeup,
531 #if defined(CONFIG_TOUCHSCREEN_GT819)
532 #define TOUCH_RESET_PIN RK29_PIN6_PC3
533 #define TOUCH_INT_PIN RK29_PIN0_PA2
534 int gt819_init_platform_hw(void)
536 printk("gt819_init_platform_hw\n");
537 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
538 gpio_free(TOUCH_RESET_PIN);
539 printk("gt819_init_platform_hw gpio_request error\n");
543 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
544 gpio_free(TOUCH_INT_PIN);
545 printk("gt819_init_platform_hw gpio_request error\n");
548 gpio_direction_output(TOUCH_RESET_PIN, 0);
549 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
551 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
553 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
554 gpio_direction_input(TOUCH_INT_PIN);
556 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
562 void gt819_exit_platform_hw(void)
564 printk("gt819_exit_platform_hw\n");
565 gpio_free(TOUCH_RESET_PIN);
566 gpio_free(TOUCH_INT_PIN);
569 int gt819_platform_sleep(void)
571 printk("gt819_platform_sleep\n");
572 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
576 int gt819_platform_wakeup(void)
578 printk("gt819_platform_wakeup\n");
579 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
581 //gpio_set_value(TOUCH_INT_PIN, GPIO_LOW);
583 //gpio_set_value(TOUCH_INT_PIN, GPIO_HIGH);
586 struct goodix_platform_data goodix_info = {
588 .init_platform_hw= gt819_init_platform_hw,
589 .exit_platform_hw= gt819_exit_platform_hw,
590 .platform_sleep = gt819_platform_sleep,
591 .platform_wakeup = gt819_platform_wakeup,
597 #if defined (CONFIG_SND_SOC_CS42L52)
599 int cs42l52_init_platform_hw()
601 printk("cs42l52_init_platform_hw\n");
602 if(gpio_request(RK29_PIN6_PB6,NULL) != 0){
603 gpio_free(RK29_PIN6_PB6);
604 printk("cs42l52_init_platform_hw gpio_request error\n");
607 gpio_direction_output(RK29_PIN6_PB6, 0);
608 gpio_set_value(RK29_PIN6_PB6,GPIO_HIGH);
611 struct cs42l52_platform_data cs42l52_info = {
613 .init_platform_hw= cs42l52_init_platform_hw,
617 #if defined (CONFIG_BATTERY_BQ27541)
618 #define DC_CHECK_PIN RK29_PIN4_PA1
619 #define LI_LION_BAT_NUM 1
620 static int bq27541_init_dc_check_pin(void){
621 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
622 gpio_free(DC_CHECK_PIN);
623 printk("bq27541 init dc check pin request error\n");
626 gpio_direction_input(DC_CHECK_PIN);
630 struct bq27541_platform_data bq27541_info = {
631 .init_dc_check_pin = bq27541_init_dc_check_pin,
632 .dc_check_pin = DC_CHECK_PIN,
633 .bat_num = LI_LION_BAT_NUM,
636 static struct android_pmem_platform_data android_pmem_pdata = {
638 .start = PMEM_UI_BASE,
639 .size = PMEM_UI_SIZE,
644 static struct platform_device android_pmem_device = {
645 .name = "android_pmem",
648 .platform_data = &android_pmem_pdata,
653 static struct vpu_mem_platform_data vpu_mem_pdata = {
655 .start = PMEM_VPU_BASE,
656 .size = PMEM_VPU_SIZE,
660 static struct platform_device rk29_vpu_mem_device = {
664 .platform_data = &vpu_mem_pdata,
667 #ifdef CONFIG_VIDEO_RK29XX_VOUT
668 static struct platform_device rk29_v4l2_output_devce = {
672 /*HANNSTAR_P1003 touch*/
673 #if defined (CONFIG_HANNSTAR_P1003)
674 #define TOUCH_RESET_PIN RK29_PIN6_PC3
675 #define TOUCH_INT_PIN RK29_PIN0_PA2
677 int p1003_init_platform_hw(void)
679 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
680 gpio_free(TOUCH_RESET_PIN);
681 printk("p1003_init_platform_hw gpio_request error\n");
685 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
686 gpio_free(TOUCH_INT_PIN);
687 printk("p1003_init_platform_hw gpio_request error\n");
690 gpio_pull_updown(TOUCH_INT_PIN, 1);
691 gpio_direction_output(TOUCH_RESET_PIN, 0);
693 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
695 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
701 struct p1003_platform_data p1003_info = {
703 .init_platform_hw= p1003_init_platform_hw,
707 #if defined (CONFIG_EETI_EGALAX)
708 #define TOUCH_RESET_PIN RK29_PIN6_PC3
709 #define TOUCH_INT_PIN RK29_PIN0_PA2
711 static int EETI_EGALAX_init_platform_hw(void)
713 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
714 gpio_free(TOUCH_RESET_PIN);
715 printk("p1003_init_platform_hw gpio_request error\n");
719 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
720 gpio_free(TOUCH_INT_PIN);
721 printk("p1003_init_platform_hw gpio_request error\n");
724 gpio_pull_updown(TOUCH_INT_PIN, 1);
725 gpio_direction_output(TOUCH_RESET_PIN, 0);
727 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
729 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
735 static struct eeti_egalax_platform_data eeti_egalax_info = {
737 .init_platform_hw= EETI_EGALAX_init_platform_hw,
738 .standby_pin = TOUCH_SCREEN_STANDBY_PIN,
739 .standby_value = TOUCH_SCREEN_STANDBY_VALUE,
740 .disp_on_pin = TOUCH_SCREEN_DISPLAY_PIN,
741 .disp_on_value = TOUCH_SCREEN_DISPLAY_VALUE,
745 #if defined (CONFIG_GS_MMA8452)
746 #define MMA8452_INT_PIN RK29_PIN0_PA3
748 static int mma8452_init_platform_hw(void)
751 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
752 gpio_free(MMA8452_INT_PIN);
753 printk("mma8452_init_platform_hw gpio_request error\n");
756 gpio_pull_updown(MMA8452_INT_PIN, 1);
761 static struct mma8452_platform_data mma8452_info = {
764 .init_platform_hw= mma8452_init_platform_hw,
768 #if defined (CONFIG_MPU_SENSORS_MPU3050)
770 static struct mpu3050_platform_data mpu3050_data = {
772 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
773 //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
774 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
775 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
777 #if defined (CONFIG_MPU_SENSORS_KXTF9)
779 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
780 .get_slave_descr = NULL ,
782 .get_slave_descr = get_accel_slave_descr ,
784 .adapt_num = 0, // The i2c bus to which the mpu device is
786 //.irq = RK29_PIN0_PA3,
787 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
789 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
790 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
791 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
792 .orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
795 #if defined (CONFIG_MPU_SENSORS_AK8975)
797 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
798 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
800 .get_slave_descr = get_compass_slave_descr,
802 .adapt_num = 0, // The i2c bus to which the compass device is.
803 // It can be difference with mpu
805 //.irq = RK29_PIN0_PA4,
806 .bus = EXT_SLAVE_BUS_PRIMARY,
808 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
809 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
810 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
811 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
812 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
817 #if defined (CONFIG_BATTERY_BQ27510)
818 #define DC_CHECK_PIN RK29_PIN4_PA1
819 #define LI_LION_BAT_NUM 2
820 static int bq27510_init_dc_check_pin(void){
821 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
822 gpio_free(DC_CHECK_PIN);
823 printk("bq27510 init dc check pin request error\n");
826 gpio_direction_input(DC_CHECK_PIN);
830 struct bq27510_platform_data bq27510_info = {
831 .init_dc_check_pin = bq27510_init_dc_check_pin,
832 .dc_check_pin = DC_CHECK_PIN,
833 .bat_num = LI_LION_BAT_NUM,
838 /*****************************************************************************************
840 * author: kfx@rock-chips.com
841 *****************************************************************************************/
842 static int rk29_i2c0_io_init(void)
844 #ifdef CONFIG_RK29_I2C0_CONTROLLER
845 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
846 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
848 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
849 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
854 static int rk29_i2c1_io_init(void)
856 #ifdef CONFIG_RK29_I2C1_CONTROLLER
857 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
858 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
860 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
861 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
865 static int rk29_i2c2_io_init(void)
867 #ifdef CONFIG_RK29_I2C2_CONTROLLER
868 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
869 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
871 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
872 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
877 static int rk29_i2c3_io_init(void)
879 #ifdef CONFIG_RK29_I2C3_CONTROLLER
880 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
881 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
883 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
884 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
888 #ifdef CONFIG_RK29_I2C0_CONTROLLER
889 struct rk29_i2c_platform_data default_i2c0_data = {
893 .scl_rate = 400*1000,
894 .mode = I2C_MODE_IRQ,
895 .io_init = rk29_i2c0_io_init,
898 struct i2c_gpio_platform_data default_i2c0_data = {
899 .sda_pin = RK29_PIN2_PB6,
900 .scl_pin = RK29_PIN2_PB7,
901 .udelay = 5, // clk = 500/udelay = 100Khz
902 .timeout = 100,//msecs_to_jiffies(200),
904 .io_init = rk29_i2c0_io_init,
907 #ifdef CONFIG_RK29_I2C1_CONTROLLER
908 struct rk29_i2c_platform_data default_i2c1_data = {
912 .scl_rate = 400*1000,
913 .mode = I2C_MODE_IRQ,
914 .io_init = rk29_i2c1_io_init,
917 struct i2c_gpio_platform_data default_i2c1_data = {
918 .sda_pin = RK29_PIN1_PA6,
919 .scl_pin = RK29_PIN1_PA7,
920 .udelay = 5, // clk = 500/udelay = 100Khz
921 .timeout = 100,//msecs_to_jiffies(200),
923 .io_init = rk29_i2c1_io_init,
926 #ifdef CONFIG_RK29_I2C2_CONTROLLER
927 struct rk29_i2c_platform_data default_i2c2_data = {
931 .scl_rate = 400*1000,
932 .mode = I2C_MODE_IRQ,
933 .io_init = rk29_i2c2_io_init,
936 struct i2c_gpio_platform_data default_i2c2_data = {
937 .sda_pin = RK29_PIN5_PD3,
938 .scl_pin = RK29_PIN5_PD4,
939 .udelay = 5, // clk = 500/udelay = 100Khz
940 .timeout = 100,//msecs_to_jiffies(200),
942 .io_init = rk29_i2c2_io_init,
945 #ifdef CONFIG_RK29_I2C3_CONTROLLER
946 struct rk29_i2c_platform_data default_i2c3_data = {
950 .scl_rate = 400*1000,
951 .mode = I2C_MODE_IRQ,
952 .io_init = rk29_i2c3_io_init,
955 struct i2c_gpio_platform_data default_i2c3_data = {
956 .sda_pin = RK29_PIN5_PB5,
957 .scl_pin = RK29_PIN5_PB4,
958 .udelay = 5, // clk = 500/udelay = 100Khz
959 .timeout = 100,//msecs_to_jiffies(200),
961 .io_init = rk29_i2c3_io_init,
964 #ifdef CONFIG_I2C0_RK29
965 static struct i2c_board_info __initdata board_i2c0_devices[] = {
966 #if defined (CONFIG_RK1000_CONTROL)
968 .type = "rk1000_control",
973 #if defined (CONFIG_SND_SOC_alc5621)
980 #if defined (CONFIG_SND_SOC_alc5631)
987 #if defined (CONFIG_SND_SOC_RK1000)
989 .type = "rk1000_i2c_codec",
994 #if defined (CONFIG_SND_SOC_WM8900)
1001 #if defined (CONFIG_BATTERY_STC3100)
1008 #if defined (CONFIG_BATTERY_BQ27510)
1013 .platform_data = &bq27510_info,
1016 #if defined (CONFIG_RTC_HYM8563)
1018 .type = "rtc_hym8563",
1021 .irq = RK29_PIN0_PA1,
1024 #if defined (CONFIG_GS_MMA8452)
1026 .type = "gs_mma8452",
1029 .irq = MMA8452_INT_PIN,
1030 .platform_data = &mma8452_info,
1033 #if defined (CONFIG_COMPASS_AK8973)
1038 .irq = RK29_PIN0_PA4,
1041 #if defined (CONFIG_COMPASS_AK8975)
1046 .irq = RK29_PIN0_PA4,
1050 #if defined (CONFIG_MPU_SENSORS_MPU3050)
1055 .irq = RK29_PIN5_PA3,
1056 .platform_data = &mpu3050_data,
1060 #if defined (CONFIG_SND_SOC_CS42L52)
1065 .platform_data = &cs42l52_info,
1068 #if defined (CONFIG_RTC_M41T66)
1070 .type = "rtc-M41T66",
1073 .irq = RK29_PIN0_PA1,
1079 #ifdef CONFIG_I2C1_RK29
1080 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1081 #if defined (CONFIG_RK1000_CONTROL1)
1083 .type = "rk1000_control",
1088 #if defined (CONFIG_ANX7150) || defined (CONFIG_ANX7150_NEW)
1091 .addr = 0x39, //0x39, 0x3d
1093 .irq = RK29_PIN1_PD7,
1096 #ifdef CONFIG_BU92747GUW_CIR
1098 .type ="bu92747_cir",
1101 .irq = BU92747_CIR_IRQ_PIN,
1102 .platform_data = &bu92747guw_pdata,
1109 #ifdef CONFIG_I2C2_RK29
1110 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1111 #if defined (CONFIG_HANNSTAR_P1003)
1113 .type = "p1003_touch",
1115 .flags = 0, //I2C_M_NEED_DELAY
1116 .irq = RK29_PIN0_PA2,
1117 .platform_data = &p1003_info,
1121 #if defined (CONFIG_EETI_EGALAX)
1123 .type = "egalax_i2c",
1126 .irq = RK29_PIN0_PA2,
1127 .platform_data = &eeti_egalax_info,
1130 #if defined (CONFIG_TOUCHSCREEN_GT819)
1132 .type = "Goodix-TS",
1135 .irq =RK29_PIN0_PA2,
1136 .platform_data = &goodix_info,
1139 #if defined (CONFIG_TOUCHSCREEN_FT5406)
1142 .addr = 0x38, //0x70,
1144 .irq =RK29_PIN0_PA2, // support goodix tp detect, 20110706
1145 .platform_data = &ft5406_info,
1151 #ifdef CONFIG_I2C3_RK29
1152 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1153 #if defined (CONFIG_BATTERY_BQ27541)
1158 .platform_data = &bq27541_info,
1164 /*****************************************************************************************
1166 * author: ddl@rock-chips.com
1167 *****************************************************************************************/
1168 #ifdef CONFIG_VIDEO_RK29
1169 #define CONFIG_SENSOR_POWER_IOCTL_USR 0
1170 #define CONFIG_SENSOR_RESET_IOCTL_USR 0
1171 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0
1172 #define CONFIG_SENSOR_FLASH_IOCTL_USR 0
1174 #if CONFIG_SENSOR_POWER_IOCTL_USR
1175 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
1177 #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
1181 #if CONFIG_SENSOR_RESET_IOCTL_USR
1182 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
1184 #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
1188 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1189 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
1191 #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
1195 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1196 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
1198 #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
1202 static struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
1203 #if CONFIG_SENSOR_POWER_IOCTL_USR
1204 .sensor_power_cb = sensor_power_usr_cb,
1206 .sensor_power_cb = NULL,
1209 #if CONFIG_SENSOR_RESET_IOCTL_USR
1210 .sensor_reset_cb = sensor_reset_usr_cb,
1212 .sensor_reset_cb = NULL,
1215 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1216 .sensor_powerdown_cb = sensor_powerdown_usr_cb,
1218 .sensor_powerdown_cb = NULL,
1221 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1222 .sensor_flash_cb = sensor_flash_usr_cb,
1224 .sensor_flash_cb = NULL,
1227 #include "../../../drivers/media/video/rk29_camera.c"
1229 /*****************************************************************************************
1231 * author: nzy@rock-chips.com
1232 *****************************************************************************************/
1233 #ifdef CONFIG_BACKLIGHT_RK29_NEWTON_BL
1235 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
1236 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
1237 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
1238 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
1242 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
1243 #define PWM_MUX_MODE GPIO1L_PWM0
1244 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1245 #define PWM_GPIO RK29_PIN1_PB5
1246 #define PWM_EFFECT_VALUE 0
1247 #define BACKLIGHT_MINVALUE 52
1248 #define LCD_DISP_ON_PIN
1250 #ifdef LCD_DISP_ON_PIN
1251 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
1252 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
1254 #define BL_EN_PIN RK29_PIN6_PD0
1255 #define BL_EN_VALUE GPIO_HIGH
1257 static int rk29_backlight_io_init(void)
1261 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1262 #ifdef LCD_DISP_ON_PIN
1263 // rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
1265 ret = gpio_request(BL_EN_PIN, NULL);
1268 gpio_free(BL_EN_PIN);
1271 gpio_direction_output(BL_EN_PIN, 0);
1272 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
1277 static int rk29_backlight_io_deinit(void)
1280 #ifdef LCD_DISP_ON_PIN
1281 gpio_free(BL_EN_PIN);
1283 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1288 static int rk29_backlight_pwm_suspend(void)
1291 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1292 if (gpio_request(PWM_GPIO, NULL)) {
1293 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
1296 gpio_direction_output(PWM_GPIO, GPIO_HIGH);
1297 //gpio_direction_output(PWM_GPIO, GPIO_LOW);
1298 #ifdef LCD_DISP_ON_PIN
1299 gpio_direction_output(BL_EN_PIN, 0);
1300 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
1305 static int rk29_backlight_pwm_resume(void)
1307 gpio_free(PWM_GPIO);
1308 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1310 #ifdef LCD_DISP_ON_PIN
1312 gpio_direction_output(BL_EN_PIN, 1);
1313 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1318 struct rk29_bl_info rk29_bl_info = {
1320 .bl_ref = PWM_EFFECT_VALUE,
1321 .io_init = rk29_backlight_io_init,
1322 .io_deinit = rk29_backlight_io_deinit,
1323 .pwm_suspend = rk29_backlight_pwm_suspend,
1324 .pwm_resume = rk29_backlight_pwm_resume,
1325 .min_brightness = BACKLIGHT_MINVALUE,
1327 struct platform_device rk29_device_backlight = {
1328 .name = "rk29_backlight",
1331 .platform_data = &rk29_bl_info,
1335 /*****************************************************************************************
1336 * pwm voltage regulator devices
1337 ******************************************************************************************/
1338 #if defined (CONFIG_RK29_PWM_REGULATOR)
1340 #define REGULATOR_PWM_ID 2
1341 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1342 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1343 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1344 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1346 static struct regulator_consumer_supply pwm_consumers[] = {
1352 static struct regulator_init_data rk29_pwm_regulator_data = {
1358 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1360 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1361 .consumer_supplies = pwm_consumers,
1364 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1365 .pwm_id = REGULATOR_PWM_ID,
1366 .pwm_gpio = REGULATOR_PWM_GPIO,
1367 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1368 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1369 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1370 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1371 .init_data = &rk29_pwm_regulator_data,
1374 static struct platform_device rk29_device_pwm_regulator = {
1375 .name = "pwm-voltage-regulator",
1378 .platform_data = &rk29_regulator_pwm_platform_data,
1384 /*****************************************************************************************
1386 *****************************************************************************************/
1387 #ifdef CONFIG_SDMMC0_RK29
1388 static int rk29_sdmmc0_cfg_gpio(void)
1390 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1391 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1392 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1393 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1394 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1395 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1397 #ifdef CONFIG_SDMMC_RK29_OLD
1398 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
1400 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
1403 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1404 gpio_request(RK29_PIN5_PD5,"sdmmc");
1406 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1408 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1410 gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
1415 #define CONFIG_SDMMC0_USE_DMA
1416 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1417 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1418 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1419 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1420 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1421 .io_init = rk29_sdmmc0_cfg_gpio,
1422 .dma_name = "sd_mmc",
1423 #ifdef CONFIG_SDMMC0_USE_DMA
1428 .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
1429 .enable_sd_wakeup = 0,
1432 #ifdef CONFIG_SDMMC1_RK29
1433 #define CONFIG_SDMMC1_USE_DMA
1434 static int rk29_sdmmc1_cfg_gpio(void)
1436 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1437 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1438 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1439 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1440 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1441 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1442 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1446 #ifdef CONFIG_WIFI_CONTROL_FUNC
1447 static int rk29sdk_wifi_status(struct device *dev);
1448 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1451 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1453 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1454 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1455 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1456 MMC_VDD_32_33|MMC_VDD_33_34),
1457 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1458 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1459 .io_init = rk29_sdmmc1_cfg_gpio,
1461 #ifdef CONFIG_SDMMC1_USE_DMA
1466 #ifdef CONFIG_WIFI_CONTROL_FUNC
1467 .status = rk29sdk_wifi_status,
1468 .register_status_notify = rk29sdk_wifi_status_register,
1471 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1476 #ifdef CONFIG_WIFI_CONTROL_FUNC
1477 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1478 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1479 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1481 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1482 static void (*wifi_status_cb)(int card_present, void *dev_id);
1483 static void *wifi_status_cb_devid;
1484 int rk29sdk_wifi_power_state = 0;
1485 int rk29sdk_bt_power_state = 0;
1487 static int rk29sdk_wifi_status(struct device *dev)
1489 return rk29sdk_wifi_cd;
1492 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1496 wifi_status_cb = callback;
1497 wifi_status_cb_devid = dev_id;
1501 static int rk29sdk_wifi_bt_gpio_control_init(void)
1503 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1504 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1508 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1509 pr_info("%s: request wifi reset gpio failed\n", __func__);
1510 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1514 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1515 pr_info("%s: request bt reset gpio failed\n", __func__);
1516 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1520 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1521 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1522 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1524 pr_info("%s: init finished\n",__func__);
1529 static int rk29sdk_wifi_power(int on)
1531 pr_info("%s: %d\n", __func__, on);
1533 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
1534 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
1536 pr_info("wifi turn on power\n");
1538 if (!rk29sdk_bt_power_state){
1539 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1541 pr_info("wifi shut off power\n");
1544 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1546 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1550 rk29sdk_wifi_power_state = on;
1554 static int rk29sdk_wifi_reset_state;
1555 static int rk29sdk_wifi_reset(int on)
1557 pr_info("%s: %d\n", __func__, on);
1558 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1560 rk29sdk_wifi_reset_state = on;
1564 int rk29sdk_wifi_set_carddetect(int val)
1566 pr_info("%s:%d\n", __func__, val);
1567 rk29sdk_wifi_cd = val;
1568 if (wifi_status_cb){
1569 wifi_status_cb(val, wifi_status_cb_devid);
1571 pr_warning("%s, nobody to notify\n", __func__);
1575 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
1577 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
1578 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
1579 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
1580 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
1581 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
1584 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
1586 if (section == PREALLOC_WLAN_SEC_NUM)
1587 return wlan_static_skb;
1589 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
1592 if (wifi_mem_array[section].size < size)
1595 return wifi_mem_array[section].mem_ptr;
1598 int __init rk29sdk_init_wifi_mem(void)
1603 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
1604 wlan_static_skb[i] = dev_alloc_skb(
1605 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
1607 if (!wlan_static_skb[i])
1611 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
1612 wifi_mem_array[i].mem_ptr =
1613 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
1615 if (!wifi_mem_array[i].mem_ptr)
1621 pr_err("Failed to mem_alloc for WLAN\n");
1622 for (j = 0 ; j < i ; j++)
1623 kfree(wifi_mem_array[j].mem_ptr);
1625 i = WLAN_SKB_BUF_NUM;
1628 pr_err("Failed to skb_alloc for WLAN\n");
1629 for (j = 0 ; j < i ; j++)
1630 dev_kfree_skb(wlan_static_skb[j]);
1635 static struct wifi_platform_data rk29sdk_wifi_control = {
1636 .set_power = rk29sdk_wifi_power,
1637 .set_reset = rk29sdk_wifi_reset,
1638 .set_carddetect = rk29sdk_wifi_set_carddetect,
1639 .mem_prealloc = rk29sdk_mem_prealloc,
1641 static struct platform_device rk29sdk_wifi_device = {
1642 .name = "bcm4329_wlan",
1645 .platform_data = &rk29sdk_wifi_control,
1651 /* bluetooth rfkill device */
1652 static struct platform_device rk29sdk_rfkill = {
1653 .name = "rk29sdk_rfkill",
1658 #ifdef CONFIG_VIVANTE
1659 #define GPU_HIGH_CLOCK 552
1660 #define GPU_LOW_CLOCK (periph_pll_default / 1000000) /* same as general pll clock rate below */
1661 static struct resource resources_gpu[] = {
1666 .flags = IORESOURCE_IRQ,
1670 .start = RK29_GPU_PHYS,
1671 .end = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
1672 .flags = IORESOURCE_MEM,
1676 .start = PMEM_GPU_BASE,
1677 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
1678 .flags = IORESOURCE_MEM,
1682 .start = GPU_LOW_CLOCK,
1683 .end = GPU_HIGH_CLOCK,
1684 .flags = IORESOURCE_IO,
1687 static struct platform_device rk29_device_gpu = {
1690 .num_resources = ARRAY_SIZE(resources_gpu),
1691 .resource = resources_gpu,
1695 #ifdef CONFIG_KEYS_RK29_NEWTON
1696 extern struct rk29_keys_platform_data rk29_keys_pdata;
1697 static struct platform_device rk29_device_keys = {
1698 .name = "rk29-keypad",
1701 .platform_data = &rk29_keys_pdata,
1706 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1707 struct gpio_led rk29_leds[] = {
1709 .name = "rk29_red_led",
1710 .gpio = RK29_PIN4_PB2,
1711 .default_trigger = "timer",
1713 .retain_state_suspended = 1,
1714 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1717 .name = "rk29_green_led",
1718 .gpio = RK29_PIN4_PB1,
1719 .default_trigger = "timer",
1721 .retain_state_suspended = 1,
1722 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1725 .name = "rk29_blue_led",
1726 .gpio = RK29_PIN4_PB0,
1727 .default_trigger = "timer",
1729 .retain_state_suspended = 1,
1730 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1734 struct gpio_led_platform_data rk29_leds_pdata = {
1736 .num_leds = ARRAY_SIZE(rk29_leds),
1739 struct platform_device rk29_device_gpio_leds = {
1740 .name = "leds-gpio",
1743 .platform_data = &rk29_leds_pdata,
1748 #ifdef CONFIG_LEDS_NEWTON_PWM
1749 static struct led_newton_pwm rk29_pwm_leds[] = {
1751 .name = "power_led",
1753 .pwm_gpio = RK29_PIN5_PD2,
1754 .pwm_iomux_name = GPIO5D2_PWM1_UART1SIRIN_NAME,
1755 .pwm_iomux_pwm = GPIO5H_PWM1,
1756 .pwm_iomux_gpio = GPIO5H_GPIO5D2,
1762 static struct led_newton_pwm_platform_data rk29_pwm_leds_pdata = {
1763 .leds = &rk29_pwm_leds,
1764 .num_leds = ARRAY_SIZE(rk29_pwm_leds),
1767 static struct platform_device rk29_device_pwm_leds = {
1768 .name = "leds_newton_pwm",
1771 .platform_data = &rk29_pwm_leds_pdata,
1776 #ifdef CONFIG_USB_ANDROID
1777 struct usb_mass_storage_platform_data newton_mass_storage_pdata = {
1779 .vendor = "RockChip",
1780 .product = "rk29 sdk",
1785 struct platform_device newton_usb_mass_storage_device = {
1786 .name = "usb_mass_storage",
1789 .platform_data = &newton_mass_storage_pdata,
1793 static struct platform_device rk29_cs42l52_device = {
1794 .name = "rk29_cs42l52",
1798 static void __init rk29_board_iomux_init(void)
1800 #ifdef CONFIG_RK29_PWM_REGULATOR
1801 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1803 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1804 rk29_mux_api_set(GPIO4B0_FLASHDATA8_NAME,GPIO4L_GPIO4B0);
1805 rk29_mux_api_set(GPIO4B1_FLASHDATA9_NAME,GPIO4L_GPIO4B1);
1806 rk29_mux_api_set(GPIO4B2_FLASHDATA10_NAME,GPIO4L_GPIO4B2);
1808 #ifdef CONFIG_LEDS_NEWTON_PWM
1809 rk29_mux_api_set(GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_GPIO5D2);
1813 static struct platform_device *devices[] __initdata = {
1815 #ifdef CONFIG_RK29_WATCHDOG
1819 #ifdef CONFIG_UART1_RK29
1822 #ifdef CONFIG_UART0_RK29
1825 #ifdef CONFIG_UART2_RK29
1828 #ifdef CONFIG_UART3_RK29
1832 #ifdef CONFIG_RK29_PWM_REGULATOR
1833 &rk29_device_pwm_regulator,
1835 #ifdef CONFIG_SPIM0_RK29
1836 &rk29xx_device_spi0m,
1838 #ifdef CONFIG_SPIM1_RK29
1839 &rk29xx_device_spi1m,
1841 #ifdef CONFIG_ADC_RK29
1844 #ifdef CONFIG_I2C0_RK29
1847 #ifdef CONFIG_I2C1_RK29
1850 #ifdef CONFIG_I2C2_RK29
1853 #ifdef CONFIG_I2C3_RK29
1857 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1858 &rk29_device_iis_2ch,
1860 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1861 &rk29_device_iis_8ch,
1864 #ifdef CONFIG_KEYS_RK29_NEWTON
1867 #ifdef CONFIG_SDMMC0_RK29
1868 &rk29_device_sdmmc0,
1870 #ifdef CONFIG_SDMMC1_RK29
1871 &rk29_device_sdmmc1,
1874 #ifdef CONFIG_MTD_NAND_RK29XX
1875 &rk29xx_device_nand,
1878 #ifdef CONFIG_WIFI_CONTROL_FUNC
1879 &rk29sdk_wifi_device,
1886 #ifdef CONFIG_MTD_NAND_RK29
1890 #ifdef CONFIG_FB_RK29
1892 &rk29_device_dma_cpy,
1894 #ifdef CONFIG_BACKLIGHT_RK29_NEWTON_BL
1895 &rk29_device_backlight,
1897 #ifdef CONFIG_RK29_VMAC
1900 #ifdef CONFIG_VIVANTE
1903 #ifdef CONFIG_VIDEO_RK29
1904 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1905 #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
1906 &rk29_soc_camera_pdrv_0,
1908 &rk29_soc_camera_pdrv_1,
1909 &android_pmem_cam_device,
1911 &android_pmem_device,
1912 &rk29_vpu_mem_device,
1913 #ifdef CONFIG_USB20_OTG
1914 &rk29_device_usb20_otg,
1916 #ifdef CONFIG_USB20_HOST
1917 &rk29_device_usb20_host,
1919 #ifdef CONFIG_USB11_HOST
1920 &rk29_device_usb11_host,
1922 #ifdef CONFIG_USB_ANDROID
1923 &android_usb_device,
1924 &newton_usb_mass_storage_device,
1926 #ifdef CONFIG_USB_ANDROID_RNDIS
1929 #ifdef CONFIG_RK29_IPP
1932 #ifdef CONFIG_VIDEO_RK29XX_VOUT
1933 &rk29_v4l2_output_devce,
1935 #ifdef CONFIG_RK29_NEWTON
1936 &rk29_device_newton,
1938 #ifdef CONFIG_RK_IRDA
1941 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1942 &rk29_device_gpio_leds,
1944 #ifdef CONFIG_LEDS_NEWTON_PWM
1945 &rk29_device_pwm_leds,
1947 #ifdef CONFIG_SND_RK29_SOC_CS42L52
1948 &rk29_cs42l52_device,
1952 /*****************************************************************************************
1954 * author: cmc@rock-chips.com
1955 *****************************************************************************************/
1956 static int rk29_vmac_register_set(void)
1958 //config rk29 vmac as rmii, 100MHz
1959 u32 value= readl(RK29_GRF_BASE + 0xbc);
1960 value = (value & 0xfff7ff) | (0x400);
1961 writel(value, RK29_GRF_BASE + 0xbc);
1965 static int rk29_rmii_io_init(void)
1970 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
1972 gpio_free(RK29_PIN6_PB0);
1973 printk("-------request RK29_PIN6_PB0 fail--------\n");
1977 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1978 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1983 static int rk29_rmii_io_deinit(void)
1986 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1987 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1989 gpio_free(RK29_PIN6_PB0);
1993 static int rk29_rmii_power_control(int enable)
1997 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
1998 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2001 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2002 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2007 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2008 .vmac_register_set = rk29_vmac_register_set,
2009 .rmii_io_init = rk29_rmii_io_init,
2010 .rmii_io_deinit = rk29_rmii_io_deinit,
2011 .rmii_power_control = rk29_rmii_power_control,
2014 /*****************************************************************************************
2016 * author: cmc@rock-chips.com
2017 *****************************************************************************************/
2018 #define SPI_CHIPSELECT_NUM 2
2019 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2022 .cs_gpio = RK29_PIN2_PC1,
2023 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2024 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2028 .cs_gpio = RK29_PIN1_PA4,
2029 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2030 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2034 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2037 .cs_gpio = RK29_PIN2_PC5,
2038 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2039 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2043 .cs_gpio = RK29_PIN1_PA3,
2044 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2045 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2049 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2054 for (i=0; i<cs_num; i++) {
2055 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2062 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2067 static int spi_io_fix_leakage_bug(void)
2070 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2075 static int spi_io_resume_leakage_bug(void)
2078 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2083 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2084 .num_chipselect = SPI_CHIPSELECT_NUM,
2085 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2086 .io_init = spi_io_init,
2087 .io_deinit = spi_io_deinit,
2088 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2089 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2092 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2093 .num_chipselect = SPI_CHIPSELECT_NUM,
2094 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2095 .io_init = spi_io_init,
2096 .io_deinit = spi_io_deinit,
2097 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2098 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2101 /*****************************************************************************************
2102 * xpt2046 touch panel
2103 * author: cmc@rock-chips.com
2104 *****************************************************************************************/
2105 #define XPT2046_GPIO_INT RK29_PIN0_PA3
2106 #define DEBOUNCE_REPTIME 3
2108 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
2109 static struct xpt2046_platform_data xpt2046_info = {
2118 .debounce_rep = DEBOUNCE_REPTIME,
2120 .gpio_pendown = XPT2046_GPIO_INT,
2121 .penirq_recheck_delay_usecs = 1,
2123 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
2124 static struct xpt2046_platform_data xpt2046_info = {
2133 .debounce_rep = DEBOUNCE_REPTIME,
2135 .gpio_pendown = XPT2046_GPIO_INT,
2136 .penirq_recheck_delay_usecs = 1,
2138 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2139 static struct xpt2046_platform_data xpt2046_info = {
2148 .debounce_rep = DEBOUNCE_REPTIME,
2150 .gpio_pendown = XPT2046_GPIO_INT,
2152 .penirq_recheck_delay_usecs = 1,
2154 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2155 static struct xpt2046_platform_data xpt2046_info = {
2164 .debounce_rep = DEBOUNCE_REPTIME,
2166 .gpio_pendown = XPT2046_GPIO_INT,
2168 .penirq_recheck_delay_usecs = 1,
2172 static struct spi_board_info board_spi_devices[] = {
2173 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
2174 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2176 .modalias = "xpt2046_ts",
2178 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2180 .irq = XPT2046_GPIO_INT,
2181 .platform_data = &xpt2046_info,
2187 static void __init rk29_gic_init_irq(void)
2189 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2190 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2193 static void __init machine_rk29_init_irq(void)
2195 rk29_gic_init_irq();
2199 static struct cpufreq_frequency_table freq_table[] = {
2200 { .index = 1200000, .frequency = 408000 },
2201 { .index = 1200000, .frequency = 816000 },
2202 { .index = 1300000, .frequency = 1008000 },
2203 { .frequency = CPUFREQ_TABLE_END },
2206 #define BAT_LOW RK29_PIN4_PA2
2207 #define POWER_ON_PIN RK29_PIN4_PA4
2208 static void __init machine_rk29_board_init(void)
2211 gpio_request(BAT_LOW, NULL);
2212 gpio_direction_input(BAT_LOW);
2213 val = gpio_get_value(BAT_LOW);
2215 printk("no battery, no power up\n");
2216 gpio_request(POWER_ON_PIN, "poweronpin");
2217 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2219 gpio_set_value(POWER_ON_PIN, GPIO_LOW);
2224 rk29_board_iomux_init();
2227 board_update_cpufreq_table(freq_table);
2229 platform_add_devices(devices, ARRAY_SIZE(devices));
2230 #ifdef CONFIG_I2C0_RK29
2231 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2232 ARRAY_SIZE(board_i2c0_devices));
2234 #ifdef CONFIG_I2C1_RK29
2235 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2236 ARRAY_SIZE(board_i2c1_devices));
2238 #ifdef CONFIG_I2C2_RK29
2239 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2240 ARRAY_SIZE(board_i2c2_devices));
2242 #ifdef CONFIG_I2C3_RK29
2243 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2244 ARRAY_SIZE(board_i2c3_devices));
2247 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2249 #ifdef CONFIG_WIFI_CONTROL_FUNC
2250 rk29sdk_wifi_bt_gpio_control_init();
2251 rk29sdk_init_wifi_mem();
2254 board_usb_detect_init(RK29_PIN0_PA0);
2256 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
2258 bu92747guw_io_init();
2263 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2264 char **cmdline, struct meminfo *mi)
2267 mi->bank[0].start = RK29_SDRAM_PHYS;
2268 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
2269 mi->bank[0].size = LINUX_SIZE;
2270 #if SDRAM_SIZE > SZ_512M
2272 mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
2273 mi->bank[1].size = SDRAM_SIZE - SZ_512M;
2277 static void __init machine_rk29_mapio(void)
2279 rk29_map_common_io();
2280 rk29_setup_early_printk();
2282 rk29_clock_init(periph_pll_default);
2284 ddr_init(DDR_TYPE,DDR_FREQ); // DDR3_1333H, 400
2287 MACHINE_START(RK29, "RK29board")
2288 /* UART for LL DEBUG */
2289 .phys_io = RK29_UART1_PHYS & 0xfff00000,
2290 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2291 .boot_params = RK29_SDRAM_PHYS + 0x88000,
2292 .fixup = machine_rk29_fixup,
2293 .map_io = machine_rk29_mapio,
2294 .init_irq = machine_rk29_init_irq,
2295 .init_machine = machine_rk29_board_init,
2296 .timer = &rk29_timer,