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>
49 #include <linux/regulator/rk29-pwm-regulator.h>
50 #include <linux/regulator/machine.h>
52 #include <linux/mtd/nand.h>
53 #include <linux/mtd/partitions.h>
54 #include <linux/i2c-gpio.h>
57 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
59 #ifdef CONFIG_VIDEO_RK29
60 /*---------------- Camera Sensor Macro Define Begin ------------------------*/
61 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
62 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642 /* back camera sensor */
63 #define CONFIG_SENSOR_IIC_ADDR_0 0x78
64 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0 1
65 #define CONFIG_SENSOR_POWER_PIN_0 INVALID_GPIO
66 #define CONFIG_SENSOR_RESET_PIN_0 INVALID_GPIO
67 #define CONFIG_SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
68 #define CONFIG_SENSOR_FALSH_PIN_0 INVALID_GPIO
69 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
70 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
71 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
72 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
74 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659 /* front camera sensor */
75 #define CONFIG_SENSOR_IIC_ADDR_1 0x60
76 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1 1
77 #define CONFIG_SENSOR_POWER_PIN_1 INVALID_GPIO
78 #define CONFIG_SENSOR_RESET_PIN_1 INVALID_GPIO
79 #define CONFIG_SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
80 #define CONFIG_SENSOR_FALSH_PIN_1 INVALID_GPIO
81 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
82 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
83 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
84 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
85 #endif //#ifdef CONFIG_VIDEO_RK29
86 /*---------------- Camera Sensor Configuration Macro End------------------------*/
87 #include "../../../drivers/media/video/rk29_camera.c"
88 /*---------------- Camera Sensor Macro Define End ------------------------*/
90 /* Set memory size of pmem */
91 #ifdef CONFIG_RK29_MEM_SIZE_M
92 #define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
94 #define SDRAM_SIZE SZ_512M
96 #define PMEM_GPU_SIZE SZ_64M
97 #define PMEM_UI_SIZE SZ_32M
98 #define PMEM_VPU_SIZE SZ_64M
99 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
100 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
101 #define MEM_CAMIPP_SIZE SZ_4M
103 #define MEM_CAMIPP_SIZE 0
105 #define MEM_FB_SIZE (3*SZ_2M)
106 #ifdef CONFIG_FB_WORK_IPP
107 #define MEM_FBIPP_SIZE SZ_8M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4
109 #define MEM_FBIPP_SIZE 0
111 #if SDRAM_SIZE > SZ_512M
112 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
114 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
116 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
117 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
118 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
119 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
120 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
121 #define MEM_FBIPP_BASE (MEM_FB_BASE - MEM_FBIPP_SIZE)
122 #define LINUX_SIZE (MEM_FBIPP_BASE - RK29_SDRAM_PHYS)
124 #define PREALLOC_WLAN_SEC_NUM 4
125 #define PREALLOC_WLAN_BUF_NUM 160
126 #define PREALLOC_WLAN_SECTION_HEADER 24
128 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
129 #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
130 #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
131 #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
133 #define WLAN_SKB_BUF_NUM 16
135 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
137 struct wifi_mem_prealloc {
142 extern struct sys_timer rk29_timer;
144 static int rk29_nand_io_init(void)
149 struct rk29_nand_platform_data rk29_nand_data = {
150 .width = 1, /* data bus width in bytes */
151 .hw_ecc = 1, /* hw ecc 0: soft ecc */
153 .io_init = rk29_nand_io_init,
156 #define TOUCH_SCREEN_STANDBY_PIN RK29_PIN6_PD1
157 #define TOUCH_SCREEN_STANDBY_VALUE GPIO_HIGH
158 #define TOUCH_SCREEN_DISPLAY_PIN INVALID_GPIO
159 #define TOUCH_SCREEN_DISPLAY_VALUE GPIO_HIGH
160 #ifdef CONFIG_FB_RK29
161 /*****************************************************************************************
163 * author: zyw@rock-chips.com
164 *****************************************************************************************/
165 //#ifdef CONFIG_LCD_TD043MGEA1
166 #define LCD_TXD_PIN INVALID_GPIO
167 #define LCD_CLK_PIN INVALID_GPIO
168 #define LCD_CS_PIN INVALID_GPIO
169 /*****************************************************************************************
170 * frame buffe devices
171 * author: zyw@rock-chips.com
172 *****************************************************************************************/
174 #define FB_DISPLAY_ON_PIN INVALID_GPIO// RK29_PIN6_PD0
175 #define FB_LCD_STANDBY_PIN INVALID_GPIO
176 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
177 #define FB_MCU_FMK_PIN INVALID_GPIO
179 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
180 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
182 static int rk29_lcd_io_init(void)
188 static int rk29_lcd_io_deinit(void)
194 static struct rk29lcd_info rk29_lcd_info = {
195 .txd_pin = LCD_TXD_PIN,
196 .clk_pin = LCD_CLK_PIN,
197 .cs_pin = LCD_CS_PIN,
198 .io_init = rk29_lcd_io_init,
199 .io_deinit = rk29_lcd_io_deinit,
202 int rk29_fb_io_enable(void)
204 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
206 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
207 gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);
209 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
211 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
212 gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);
217 int rk29_fb_io_disable(void)
219 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
221 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
222 gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);
224 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
226 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
227 gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);
232 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
235 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
237 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
240 gpio_free(FB_MCU_FMK_PIN);
241 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
243 gpio_direction_input(FB_MCU_FMK_PIN);
245 if(fb_setting->disp_on_en)
247 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
249 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
252 gpio_free(FB_DISPLAY_ON_PIN);
253 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
258 ret = gpio_request(TOUCH_SCREEN_DISPLAY_PIN, NULL);
261 gpio_free(TOUCH_SCREEN_DISPLAY_PIN);
262 printk(">>>>>> TOUCH_SCREEN_DISPLAY_PIN gpio_request err \n ");
264 gpio_direction_output(TOUCH_SCREEN_DISPLAY_PIN, 0);
265 gpio_set_value(TOUCH_SCREEN_DISPLAY_PIN, TOUCH_SCREEN_DISPLAY_VALUE);
269 if(fb_setting->disp_on_en)
271 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
273 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
276 gpio_free(FB_LCD_STANDBY_PIN);
277 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
282 ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL);
285 gpio_free(TOUCH_SCREEN_STANDBY_PIN);
286 printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n ");
288 gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0);
289 gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE);
293 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
295 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
298 gpio_free(FB_LCD_CABC_EN_PIN);
299 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
301 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
302 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
305 rk29_fb_io_enable(); //enable it
310 static struct rk29fb_info rk29_fb_info = {
312 .mcu_fmk_pin = FB_MCU_FMK_PIN,
313 .lcd_info = &rk29_lcd_info,
314 .io_init = rk29_fb_io_init,
315 .io_enable = rk29_fb_io_enable,
316 .io_disable = rk29_fb_io_disable,
319 /* rk29 fb resource */
320 static struct resource rk29_fb_resource[] = {
323 .start = RK29_LCDC_PHYS,
324 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
325 .flags = IORESOURCE_MEM,
331 .flags = IORESOURCE_IRQ,
335 .start = MEM_FB_BASE,
336 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
337 .flags = IORESOURCE_MEM,
339 #ifdef CONFIG_FB_WORK_IPP
341 .name = "win1 ipp buf",
342 .start = MEM_FBIPP_BASE,
343 .end = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
344 .flags = IORESOURCE_MEM,
350 struct platform_device rk29_device_fb = {
353 .num_resources = ARRAY_SIZE(rk29_fb_resource),
354 .resource = rk29_fb_resource,
356 .platform_data = &rk29_fb_info,
360 struct platform_device rk29_device_dma_cpy = {
361 .name = "dma_memcpy",
368 static struct android_pmem_platform_data android_pmem_pdata = {
370 .start = PMEM_UI_BASE,
371 .size = PMEM_UI_SIZE,
376 static struct platform_device android_pmem_device = {
377 .name = "android_pmem",
380 .platform_data = &android_pmem_pdata,
385 static struct vpu_mem_platform_data vpu_mem_pdata = {
387 .start = PMEM_VPU_BASE,
388 .size = PMEM_VPU_SIZE,
392 static struct platform_device rk29_vpu_mem_device = {
396 .platform_data = &vpu_mem_pdata,
399 #ifdef CONFIG_VIDEO_RK29XX_VOUT
400 static struct platform_device rk29_v4l2_output_devce = {
404 /*HANNSTAR_P1003 touch*/
405 #if defined (CONFIG_HANNSTAR_P1003)
406 #define TOUCH_RESET_PIN RK29_PIN6_PC3
407 #define TOUCH_INT_PIN RK29_PIN0_PA2
409 int p1003_init_platform_hw(void)
411 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
412 gpio_free(TOUCH_RESET_PIN);
413 printk("p1003_init_platform_hw gpio_request error\n");
417 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
418 gpio_free(TOUCH_INT_PIN);
419 printk("p1003_init_platform_hw gpio_request error\n");
422 gpio_pull_updown(TOUCH_INT_PIN, 1);
423 gpio_direction_output(TOUCH_RESET_PIN, 0);
425 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
427 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
433 struct p1003_platform_data p1003_info = {
435 .init_platform_hw= p1003_init_platform_hw,
439 #if defined (CONFIG_EETI_EGALAX)
440 #define TOUCH_RESET_PIN RK29_PIN6_PC3
441 #define TOUCH_INT_PIN RK29_PIN0_PA2
443 static int EETI_EGALAX_init_platform_hw(void)
445 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
446 gpio_free(TOUCH_RESET_PIN);
447 printk("p1003_init_platform_hw gpio_request error\n");
451 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
452 gpio_free(TOUCH_INT_PIN);
453 printk("p1003_init_platform_hw gpio_request error\n");
456 gpio_pull_updown(TOUCH_INT_PIN, 1);
457 gpio_direction_output(TOUCH_RESET_PIN, 0);
459 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
461 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
467 static struct eeti_egalax_platform_data eeti_egalax_info = {
469 .init_platform_hw= EETI_EGALAX_init_platform_hw,
470 .standby_pin = TOUCH_SCREEN_STANDBY_PIN,
471 .standby_value = TOUCH_SCREEN_STANDBY_VALUE,
472 .disp_on_pin = TOUCH_SCREEN_DISPLAY_PIN,
473 .disp_on_value = TOUCH_SCREEN_DISPLAY_VALUE,
477 #if defined (CONFIG_GS_MMA8452)
478 #define MMA8452_INT_PIN RK29_PIN0_PA3
480 static int mma8452_init_platform_hw(void)
483 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
484 gpio_free(MMA8452_INT_PIN);
485 printk("mma8452_init_platform_hw gpio_request error\n");
488 gpio_pull_updown(MMA8452_INT_PIN, 1);
493 static struct mma8452_platform_data mma8452_info = {
496 .init_platform_hw= mma8452_init_platform_hw,
500 #if defined (CONFIG_MPU_SENSORS_MPU3050)
502 static struct mpu3050_platform_data mpu3050_data = {
504 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
505 //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
506 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
507 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
509 #if defined (CONFIG_MPU_SENSORS_KXTF9)
511 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
512 .get_slave_descr = NULL ,
514 .get_slave_descr = get_accel_slave_descr ,
516 .adapt_num = 0, // The i2c bus to which the mpu device is
518 //.irq = RK29_PIN0_PA3,
519 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
521 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
522 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
523 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
524 .orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
527 #if defined (CONFIG_MPU_SENSORS_AK8975)
529 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
530 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
532 .get_slave_descr = get_compass_slave_descr,
534 .adapt_num = 0, // The i2c bus to which the compass device is.
535 // It can be difference with mpu
537 //.irq = RK29_PIN0_PA4,
538 .bus = EXT_SLAVE_BUS_PRIMARY,
540 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
541 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
542 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
543 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
544 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
549 #if defined (CONFIG_BATTERY_BQ27510)
550 #define DC_CHECK_PIN RK29_PIN4_PA1
551 #define LI_LION_BAT_NUM 2
552 static int bq27510_init_dc_check_pin(void){
553 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
554 gpio_free(DC_CHECK_PIN);
555 printk("bq27510 init dc check pin request error\n");
558 gpio_direction_input(DC_CHECK_PIN);
562 struct bq27510_platform_data bq27510_info = {
563 .init_dc_check_pin = bq27510_init_dc_check_pin,
564 .dc_check_pin = DC_CHECK_PIN,
565 .bat_num = LI_LION_BAT_NUM,
570 /*****************************************************************************************
572 * author: kfx@rock-chips.com
573 *****************************************************************************************/
574 static int rk29_i2c0_io_init(void)
576 #ifdef CONFIG_RK29_I2C0_CONTROLLER
577 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
578 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
580 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
581 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
586 static int rk29_i2c1_io_init(void)
588 #ifdef CONFIG_RK29_I2C1_CONTROLLER
589 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
590 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
592 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
593 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
597 static int rk29_i2c2_io_init(void)
599 #ifdef CONFIG_RK29_I2C2_CONTROLLER
600 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
601 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
603 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
604 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
609 static int rk29_i2c3_io_init(void)
611 #ifdef CONFIG_RK29_I2C3_CONTROLLER
612 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
613 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
615 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
616 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
620 #ifdef CONFIG_RK29_I2C0_CONTROLLER
621 struct rk29_i2c_platform_data default_i2c0_data = {
625 .scl_rate = 400*1000,
626 .mode = I2C_MODE_IRQ,
627 .io_init = rk29_i2c0_io_init,
630 struct i2c_gpio_platform_data default_i2c0_data = {
631 .sda_pin = RK29_PIN2_PB6,
632 .scl_pin = RK29_PIN2_PB7,
633 .udelay = 5, // clk = 500/udelay = 100Khz
634 .timeout = 100,//msecs_to_jiffies(200),
636 .io_init = rk29_i2c0_io_init,
639 #ifdef CONFIG_RK29_I2C1_CONTROLLER
640 struct rk29_i2c_platform_data default_i2c1_data = {
644 .scl_rate = 400*1000,
645 .mode = I2C_MODE_IRQ,
646 .io_init = rk29_i2c1_io_init,
649 struct i2c_gpio_platform_data default_i2c1_data = {
650 .sda_pin = RK29_PIN1_PA6,
651 .scl_pin = RK29_PIN1_PA7,
652 .udelay = 5, // clk = 500/udelay = 100Khz
653 .timeout = 100,//msecs_to_jiffies(200),
655 .io_init = rk29_i2c1_io_init,
658 #ifdef CONFIG_RK29_I2C2_CONTROLLER
659 struct rk29_i2c_platform_data default_i2c2_data = {
663 .scl_rate = 400*1000,
664 .mode = I2C_MODE_IRQ,
665 .io_init = rk29_i2c2_io_init,
668 struct i2c_gpio_platform_data default_i2c2_data = {
669 .sda_pin = RK29_PIN5_PD3,
670 .scl_pin = RK29_PIN5_PD4,
671 .udelay = 5, // clk = 500/udelay = 100Khz
672 .timeout = 100,//msecs_to_jiffies(200),
674 .io_init = rk29_i2c2_io_init,
677 #ifdef CONFIG_RK29_I2C3_CONTROLLER
678 struct rk29_i2c_platform_data default_i2c3_data = {
682 .scl_rate = 400*1000,
683 .mode = I2C_MODE_IRQ,
684 .io_init = rk29_i2c3_io_init,
687 struct i2c_gpio_platform_data default_i2c3_data = {
688 .sda_pin = RK29_PIN5_PB5,
689 .scl_pin = RK29_PIN5_PB4,
690 .udelay = 5, // clk = 500/udelay = 100Khz
691 .timeout = 100,//msecs_to_jiffies(200),
693 .io_init = rk29_i2c3_io_init,
696 #ifdef CONFIG_I2C0_RK29
697 static struct i2c_board_info __initdata board_i2c0_devices[] = {
698 #if defined (CONFIG_RK1000_CONTROL)
700 .type = "rk1000_control",
705 #if defined (CONFIG_SND_SOC_alc5621)
712 #if defined (CONFIG_SND_SOC_alc5631)
719 #if defined (CONFIG_SND_SOC_RK1000)
721 .type = "rk1000_i2c_codec",
726 #if defined (CONFIG_SND_SOC_WM8900)
733 #if defined (CONFIG_BATTERY_STC3100)
740 #if defined (CONFIG_BATTERY_BQ27510)
745 .platform_data = &bq27510_info,
748 #if defined (CONFIG_RTC_HYM8563)
750 .type = "rtc_hym8563",
753 .irq = RK29_PIN0_PA1,
756 #if defined (CONFIG_GS_MMA8452)
758 .type = "gs_mma8452",
761 .irq = MMA8452_INT_PIN,
762 .platform_data = &mma8452_info,
765 #if defined (CONFIG_COMPASS_AK8973)
770 .irq = RK29_PIN0_PA4,
773 #if defined (CONFIG_COMPASS_AK8975)
778 .irq = RK29_PIN0_PA4,
781 #if defined (CONFIG_MPU_SENSORS_MPU3050)
786 .irq = RK29_PIN5_PA3,
787 .platform_data = &mpu3050_data,
793 #ifdef CONFIG_I2C1_RK29
794 static struct i2c_board_info __initdata board_i2c1_devices[] = {
795 #if defined (CONFIG_RK1000_CONTROL1)
797 .type = "rk1000_control",
802 #if defined (CONFIG_ANX7150) || defined (CONFIG_ANX7150_NEW)
805 .addr = 0x39, //0x39, 0x3d
807 .irq = RK29_PIN1_PD7,
814 #ifdef CONFIG_I2C2_RK29
815 static struct i2c_board_info __initdata board_i2c2_devices[] = {
816 #if defined (CONFIG_HANNSTAR_P1003)
818 .type = "p1003_touch",
820 .flags = 0, //I2C_M_NEED_DELAY
821 .irq = RK29_PIN0_PA2,
822 .platform_data = &p1003_info,
826 #if defined (CONFIG_EETI_EGALAX)
828 .type = "egalax_i2c",
831 .irq = RK29_PIN0_PA2,
832 .platform_data = &eeti_egalax_info,
838 #ifdef CONFIG_I2C3_RK29
839 static struct i2c_board_info __initdata board_i2c3_devices[] = {
843 /*****************************************************************************************
845 * author: ddl@rock-chips.com
846 *****************************************************************************************/
847 #ifdef CONFIG_VIDEO_RK29
848 #define CONFIG_SENSOR_POWER_IOCTL_USR 0
849 #define CONFIG_SENSOR_RESET_IOCTL_USR 0
850 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0
851 #define CONFIG_SENSOR_FLASH_IOCTL_USR 0
853 #if CONFIG_SENSOR_POWER_IOCTL_USR
854 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
856 #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
860 #if CONFIG_SENSOR_RESET_IOCTL_USR
861 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
863 #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
867 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
868 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
870 #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
874 #if CONFIG_SENSOR_FLASH_IOCTL_USR
875 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
877 #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
881 static struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
882 #if CONFIG_SENSOR_POWER_IOCTL_USR
883 .sensor_power_cb = sensor_power_usr_cb,
885 .sensor_power_cb = NULL,
888 #if CONFIG_SENSOR_RESET_IOCTL_USR
889 .sensor_reset_cb = sensor_reset_usr_cb,
891 .sensor_reset_cb = NULL,
894 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
895 .sensor_powerdown_cb = sensor_powerdown_usr_cb,
897 .sensor_powerdown_cb = NULL,
900 #if CONFIG_SENSOR_FLASH_IOCTL_USR
901 .sensor_flash_cb = sensor_flash_usr_cb,
903 .sensor_flash_cb = NULL,
907 #include "../../../drivers/media/video/rk29_camera.c"
909 /*****************************************************************************************
911 * author: nzy@rock-chips.com
912 *****************************************************************************************/
913 #ifdef CONFIG_BACKLIGHT_RK29_BL
915 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
916 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
917 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
918 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
922 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
923 #define PWM_MUX_MODE GPIO1L_PWM0
924 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
925 #define PWM_GPIO RK29_PIN1_PB5
926 #define PWM_EFFECT_VALUE 1
928 #define LCD_DISP_ON_PIN
930 #ifdef LCD_DISP_ON_PIN
931 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
932 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
934 #define BL_EN_PIN RK29_PIN6_PD0
935 #define BL_EN_VALUE GPIO_HIGH
937 static int rk29_backlight_io_init(void)
941 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
942 #ifdef LCD_DISP_ON_PIN
943 // rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
945 ret = gpio_request(BL_EN_PIN, NULL);
948 gpio_free(BL_EN_PIN);
951 gpio_direction_output(BL_EN_PIN, 0);
952 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
957 static int rk29_backlight_io_deinit(void)
960 #ifdef LCD_DISP_ON_PIN
961 gpio_free(BL_EN_PIN);
963 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
967 static int rk29_backlight_pwm_suspend(void)
970 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
971 if (gpio_request(PWM_GPIO, NULL)) {
972 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
975 gpio_direction_output(PWM_GPIO, GPIO_LOW);
976 #ifdef LCD_DISP_ON_PIN
977 gpio_direction_output(BL_EN_PIN, 0);
978 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
983 static int rk29_backlight_pwm_resume(void)
986 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
988 #ifdef LCD_DISP_ON_PIN
990 gpio_direction_output(BL_EN_PIN, 1);
991 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
996 struct rk29_bl_info rk29_bl_info = {
998 .bl_ref = PWM_EFFECT_VALUE,
999 .io_init = rk29_backlight_io_init,
1000 .io_deinit = rk29_backlight_io_deinit,
1001 .pwm_suspend = rk29_backlight_pwm_suspend,
1002 .pwm_resume = rk29_backlight_pwm_resume,
1005 /*****************************************************************************************
1006 * pwm voltage regulator devices
1007 ******************************************************************************************/
1008 #if defined (CONFIG_RK29_PWM_REGULATOR)
1010 #define REGULATOR_PWM_ID 2
1011 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1012 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1013 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1014 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1016 static struct regulator_consumer_supply pwm_consumers[] = {
1022 static struct regulator_init_data rk29_pwm_regulator_data = {
1028 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1030 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1031 .consumer_supplies = pwm_consumers,
1034 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1035 .pwm_id = REGULATOR_PWM_ID,
1036 .pwm_gpio = REGULATOR_PWM_GPIO,
1037 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1038 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1039 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1040 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1041 .init_data = &rk29_pwm_regulator_data,
1044 static struct platform_device rk29_device_pwm_regulator = {
1045 .name = "pwm-voltage-regulator",
1048 .platform_data = &rk29_regulator_pwm_platform_data,
1054 /*****************************************************************************************
1056 *****************************************************************************************/
1057 #ifdef CONFIG_SDMMC0_RK29
1058 static int rk29_sdmmc0_cfg_gpio(void)
1060 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1061 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1062 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1063 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1064 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1065 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1067 #ifdef CONFIG_SDMMC_RK29_OLD
1068 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
1070 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
1073 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1074 gpio_request(RK29_PIN5_PD5,"sdmmc");
1076 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1078 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1080 gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
1085 #define CONFIG_SDMMC0_USE_DMA
1086 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1087 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1088 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1089 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1090 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1091 .io_init = rk29_sdmmc0_cfg_gpio,
1092 .dma_name = "sd_mmc",
1093 #ifdef CONFIG_SDMMC0_USE_DMA
1098 .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
1099 .enable_sd_wakeup = 0,
1102 #ifdef CONFIG_SDMMC1_RK29
1103 #define CONFIG_SDMMC1_USE_DMA
1104 static int rk29_sdmmc1_cfg_gpio(void)
1106 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1107 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1108 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1109 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1110 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1111 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1112 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1116 #ifdef CONFIG_WIFI_CONTROL_FUNC
1117 static int rk29sdk_wifi_status(struct device *dev);
1118 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1121 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1123 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1124 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1125 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1126 MMC_VDD_32_33|MMC_VDD_33_34),
1127 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1128 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1129 .io_init = rk29_sdmmc1_cfg_gpio,
1131 #ifdef CONFIG_SDMMC1_USE_DMA
1136 #ifdef CONFIG_WIFI_CONTROL_FUNC
1137 .status = rk29sdk_wifi_status,
1138 .register_status_notify = rk29sdk_wifi_status_register,
1141 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1146 #ifdef CONFIG_WIFI_CONTROL_FUNC
1147 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1148 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1149 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1151 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1152 static void (*wifi_status_cb)(int card_present, void *dev_id);
1153 static void *wifi_status_cb_devid;
1154 int rk29sdk_wifi_power_state = 0;
1155 int rk29sdk_bt_power_state = 0;
1157 static int rk29sdk_wifi_status(struct device *dev)
1159 return rk29sdk_wifi_cd;
1162 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1166 wifi_status_cb = callback;
1167 wifi_status_cb_devid = dev_id;
1171 static int rk29sdk_wifi_bt_gpio_control_init(void)
1173 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1174 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1178 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1179 pr_info("%s: request wifi reset gpio failed\n", __func__);
1180 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1184 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1185 pr_info("%s: request bt reset gpio failed\n", __func__);
1186 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1190 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1191 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1192 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1194 pr_info("%s: init finished\n",__func__);
1199 static int rk29sdk_wifi_power(int on)
1201 pr_info("%s: %d\n", __func__, on);
1203 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
1204 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
1206 pr_info("wifi turn on power\n");
1208 if (!rk29sdk_bt_power_state){
1209 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1211 pr_info("wifi shut off power\n");
1214 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1216 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1220 rk29sdk_wifi_power_state = on;
1224 static int rk29sdk_wifi_reset_state;
1225 static int rk29sdk_wifi_reset(int on)
1227 pr_info("%s: %d\n", __func__, on);
1228 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1230 rk29sdk_wifi_reset_state = on;
1234 int rk29sdk_wifi_set_carddetect(int val)
1236 pr_info("%s:%d\n", __func__, val);
1237 rk29sdk_wifi_cd = val;
1238 if (wifi_status_cb){
1239 wifi_status_cb(val, wifi_status_cb_devid);
1241 pr_warning("%s, nobody to notify\n", __func__);
1245 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
1247 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
1248 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
1249 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
1250 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
1251 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
1254 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
1256 if (section == PREALLOC_WLAN_SEC_NUM)
1257 return wlan_static_skb;
1259 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
1262 if (wifi_mem_array[section].size < size)
1265 return wifi_mem_array[section].mem_ptr;
1268 int __init rk29sdk_init_wifi_mem(void)
1273 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
1274 wlan_static_skb[i] = dev_alloc_skb(
1275 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
1277 if (!wlan_static_skb[i])
1281 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
1282 wifi_mem_array[i].mem_ptr =
1283 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
1285 if (!wifi_mem_array[i].mem_ptr)
1291 pr_err("Failed to mem_alloc for WLAN\n");
1292 for (j = 0 ; j < i ; j++)
1293 kfree(wifi_mem_array[j].mem_ptr);
1295 i = WLAN_SKB_BUF_NUM;
1298 pr_err("Failed to skb_alloc for WLAN\n");
1299 for (j = 0 ; j < i ; j++)
1300 dev_kfree_skb(wlan_static_skb[j]);
1305 static struct wifi_platform_data rk29sdk_wifi_control = {
1306 .set_power = rk29sdk_wifi_power,
1307 .set_reset = rk29sdk_wifi_reset,
1308 .set_carddetect = rk29sdk_wifi_set_carddetect,
1309 .mem_prealloc = rk29sdk_mem_prealloc,
1311 static struct platform_device rk29sdk_wifi_device = {
1312 .name = "bcm4329_wlan",
1315 .platform_data = &rk29sdk_wifi_control,
1321 /* bluetooth rfkill device */
1322 static struct platform_device rk29sdk_rfkill = {
1323 .name = "rk29sdk_rfkill",
1328 #ifdef CONFIG_VIVANTE
1329 #define GPU_HIGH_CLOCK 552
1330 #define GPU_LOW_CLOCK (periph_pll_default / 1000000) /* same as general pll clock rate below */
1331 static struct resource resources_gpu[] = {
1336 .flags = IORESOURCE_IRQ,
1340 .start = RK29_GPU_PHYS,
1341 .end = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
1342 .flags = IORESOURCE_MEM,
1346 .start = PMEM_GPU_BASE,
1347 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
1348 .flags = IORESOURCE_MEM,
1352 .start = GPU_LOW_CLOCK,
1353 .end = GPU_HIGH_CLOCK,
1354 .flags = IORESOURCE_IO,
1357 static struct platform_device rk29_device_gpu = {
1360 .num_resources = ARRAY_SIZE(resources_gpu),
1361 .resource = resources_gpu,
1365 #ifdef CONFIG_KEYS_RK29
1366 extern struct rk29_keys_platform_data rk29_keys_pdata;
1367 static struct platform_device rk29_device_keys = {
1368 .name = "rk29-keypad",
1371 .platform_data = &rk29_keys_pdata,
1376 static void __init rk29_board_iomux_init(void)
1378 #ifdef CONFIG_RK29_PWM_REGULATOR
1379 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1383 static struct platform_device *devices[] __initdata = {
1385 #ifdef CONFIG_RK29_WATCHDOG
1389 #ifdef CONFIG_UART1_RK29
1392 #ifdef CONFIG_UART0_RK29
1395 #ifdef CONFIG_UART2_RK29
1398 #ifdef CONFIG_UART3_RK29
1402 #ifdef CONFIG_RK29_PWM_REGULATOR
1403 &rk29_device_pwm_regulator,
1405 #ifdef CONFIG_SPIM0_RK29
1406 &rk29xx_device_spi0m,
1408 #ifdef CONFIG_SPIM1_RK29
1409 &rk29xx_device_spi1m,
1411 #ifdef CONFIG_ADC_RK29
1414 #ifdef CONFIG_I2C0_RK29
1417 #ifdef CONFIG_I2C1_RK29
1420 #ifdef CONFIG_I2C2_RK29
1423 #ifdef CONFIG_I2C3_RK29
1427 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1428 &rk29_device_iis_2ch,
1430 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1431 &rk29_device_iis_8ch,
1434 #ifdef CONFIG_KEYS_RK29
1437 #ifdef CONFIG_SDMMC0_RK29
1438 &rk29_device_sdmmc0,
1440 #ifdef CONFIG_SDMMC1_RK29
1441 &rk29_device_sdmmc1,
1444 #ifdef CONFIG_MTD_NAND_RK29XX
1445 &rk29xx_device_nand,
1448 #ifdef CONFIG_WIFI_CONTROL_FUNC
1449 &rk29sdk_wifi_device,
1456 #ifdef CONFIG_MTD_NAND_RK29
1460 #ifdef CONFIG_FB_RK29
1462 &rk29_device_dma_cpy,
1464 #ifdef CONFIG_BACKLIGHT_RK29_BL
1465 &rk29_device_backlight,
1467 #ifdef CONFIG_RK29_VMAC
1470 #ifdef CONFIG_VIVANTE
1473 #ifdef CONFIG_VIDEO_RK29
1474 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1475 #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
1476 &rk29_soc_camera_pdrv_0,
1478 &rk29_soc_camera_pdrv_1,
1479 &android_pmem_cam_device,
1481 &android_pmem_device,
1482 &rk29_vpu_mem_device,
1483 #ifdef CONFIG_USB20_OTG
1484 &rk29_device_usb20_otg,
1486 #ifdef CONFIG_USB20_HOST
1487 &rk29_device_usb20_host,
1489 #ifdef CONFIG_USB11_HOST
1490 &rk29_device_usb11_host,
1492 #ifdef CONFIG_USB_ANDROID
1493 &android_usb_device,
1494 &usb_mass_storage_device,
1496 #ifdef CONFIG_RK29_IPP
1499 #ifdef CONFIG_VIDEO_RK29XX_VOUT
1500 &rk29_v4l2_output_devce,
1504 /*****************************************************************************************
1506 * author: cmc@rock-chips.com
1507 *****************************************************************************************/
1508 static int rk29_vmac_register_set(void)
1510 //config rk29 vmac as rmii, 100MHz
1511 u32 value= readl(RK29_GRF_BASE + 0xbc);
1512 value = (value & 0xfff7ff) | (0x400);
1513 writel(value, RK29_GRF_BASE + 0xbc);
1517 static int rk29_rmii_io_init(void)
1522 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
1524 gpio_free(RK29_PIN6_PB0);
1525 printk("-------request RK29_PIN6_PB0 fail--------\n");
1529 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1530 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1535 static int rk29_rmii_io_deinit(void)
1538 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1539 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1541 gpio_free(RK29_PIN6_PB0);
1545 static int rk29_rmii_power_control(int enable)
1549 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
1550 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
1553 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1554 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1559 struct rk29_vmac_platform_data rk29_vmac_pdata = {
1560 .vmac_register_set = rk29_vmac_register_set,
1561 .rmii_io_init = rk29_rmii_io_init,
1562 .rmii_io_deinit = rk29_rmii_io_deinit,
1563 .rmii_power_control = rk29_rmii_power_control,
1566 /*****************************************************************************************
1568 * author: cmc@rock-chips.com
1569 *****************************************************************************************/
1570 #define SPI_CHIPSELECT_NUM 2
1571 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
1574 .cs_gpio = RK29_PIN2_PC1,
1575 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
1576 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
1580 .cs_gpio = RK29_PIN1_PA4,
1581 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
1582 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
1586 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
1589 .cs_gpio = RK29_PIN2_PC5,
1590 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
1591 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
1595 .cs_gpio = RK29_PIN1_PA3,
1596 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
1597 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
1601 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
1606 for (i=0; i<cs_num; i++) {
1607 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
1614 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
1619 static int spi_io_fix_leakage_bug(void)
1622 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
1627 static int spi_io_resume_leakage_bug(void)
1630 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
1635 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
1636 .num_chipselect = SPI_CHIPSELECT_NUM,
1637 .chipselect_gpios = rk29xx_spi0_cs_gpios,
1638 .io_init = spi_io_init,
1639 .io_deinit = spi_io_deinit,
1640 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1641 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1644 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
1645 .num_chipselect = SPI_CHIPSELECT_NUM,
1646 .chipselect_gpios = rk29xx_spi1_cs_gpios,
1647 .io_init = spi_io_init,
1648 .io_deinit = spi_io_deinit,
1649 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1650 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1653 /*****************************************************************************************
1654 * xpt2046 touch panel
1655 * author: cmc@rock-chips.com
1656 *****************************************************************************************/
1657 #define XPT2046_GPIO_INT RK29_PIN0_PA3
1658 #define DEBOUNCE_REPTIME 3
1660 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
1661 static struct xpt2046_platform_data xpt2046_info = {
1670 .debounce_rep = DEBOUNCE_REPTIME,
1672 .gpio_pendown = XPT2046_GPIO_INT,
1673 .penirq_recheck_delay_usecs = 1,
1675 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
1676 static struct xpt2046_platform_data xpt2046_info = {
1685 .debounce_rep = DEBOUNCE_REPTIME,
1687 .gpio_pendown = XPT2046_GPIO_INT,
1688 .penirq_recheck_delay_usecs = 1,
1690 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
1691 static struct xpt2046_platform_data xpt2046_info = {
1700 .debounce_rep = DEBOUNCE_REPTIME,
1702 .gpio_pendown = XPT2046_GPIO_INT,
1704 .penirq_recheck_delay_usecs = 1,
1706 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1707 static struct xpt2046_platform_data xpt2046_info = {
1716 .debounce_rep = DEBOUNCE_REPTIME,
1718 .gpio_pendown = XPT2046_GPIO_INT,
1720 .penirq_recheck_delay_usecs = 1,
1724 static struct spi_board_info board_spi_devices[] = {
1725 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
1726 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1728 .modalias = "xpt2046_ts",
1730 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
1732 .irq = XPT2046_GPIO_INT,
1733 .platform_data = &xpt2046_info,
1739 static void __init rk29_gic_init_irq(void)
1741 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
1742 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
1745 static void __init machine_rk29_init_irq(void)
1747 rk29_gic_init_irq();
1751 static struct cpufreq_frequency_table freq_table[] = {
1752 { .index = 1200000, .frequency = 408000 },
1753 { .index = 1200000, .frequency = 816000 },
1754 { .index = 1300000, .frequency = 1008000 },
1755 { .frequency = CPUFREQ_TABLE_END },
1758 static void __init machine_rk29_board_init(void)
1760 rk29_board_iomux_init();
1763 board_update_cpufreq_table(freq_table);
1765 platform_add_devices(devices, ARRAY_SIZE(devices));
1766 #ifdef CONFIG_I2C0_RK29
1767 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
1768 ARRAY_SIZE(board_i2c0_devices));
1770 #ifdef CONFIG_I2C1_RK29
1771 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
1772 ARRAY_SIZE(board_i2c1_devices));
1774 #ifdef CONFIG_I2C2_RK29
1775 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
1776 ARRAY_SIZE(board_i2c2_devices));
1778 #ifdef CONFIG_I2C3_RK29
1779 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
1780 ARRAY_SIZE(board_i2c3_devices));
1783 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1785 #ifdef CONFIG_WIFI_CONTROL_FUNC
1786 rk29sdk_wifi_bt_gpio_control_init();
1787 rk29sdk_init_wifi_mem();
1790 board_usb_detect_init(RK29_PIN0_PA0);
1793 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
1794 char **cmdline, struct meminfo *mi)
1797 mi->bank[0].start = RK29_SDRAM_PHYS;
1798 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
1799 mi->bank[0].size = LINUX_SIZE;
1800 #if SDRAM_SIZE > SZ_512M
1802 mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
1803 mi->bank[1].size = SDRAM_SIZE - SZ_512M;
1807 static void __init machine_rk29_mapio(void)
1809 rk29_map_common_io();
1810 rk29_setup_early_printk();
1812 rk29_clock_init(periph_pll_default);
1814 ddr_init(DDR_TYPE, DDR_FREQ);
1817 MACHINE_START(RK29, "RK29board")
1818 /* UART for LL DEBUG */
1819 .phys_io = RK29_UART1_PHYS & 0xfff00000,
1820 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
1821 .boot_params = RK29_SDRAM_PHYS + 0x88000,
1822 .fixup = machine_rk29_fixup,
1823 .map_io = machine_rk29_mapio,
1824 .init_irq = machine_rk29_init_irq,
1825 .init_machine = machine_rk29_board_init,
1826 .timer = &rk29_timer,