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_VIDEO_RK29
61 /*---------------- Camera Sensor Macro Define Begin ------------------------*/
62 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
63 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642 /* back camera sensor */
64 #define CONFIG_SENSOR_IIC_ADDR_0 0x78
65 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0 1
66 #define CONFIG_SENSOR_POWER_PIN_0 INVALID_GPIO
67 #define CONFIG_SENSOR_RESET_PIN_0 INVALID_GPIO
68 #define CONFIG_SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
69 #define CONFIG_SENSOR_FALSH_PIN_0 INVALID_GPIO
70 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
71 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
72 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
73 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
75 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659 /* front camera sensor */
76 #define CONFIG_SENSOR_IIC_ADDR_1 0x60
77 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1 1
78 #define CONFIG_SENSOR_POWER_PIN_1 INVALID_GPIO
79 #define CONFIG_SENSOR_RESET_PIN_1 INVALID_GPIO
80 #define CONFIG_SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
81 #define CONFIG_SENSOR_FALSH_PIN_1 INVALID_GPIO
82 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
83 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
84 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
85 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
86 #endif //#ifdef CONFIG_VIDEO_RK29
87 /*---------------- Camera Sensor Configuration Macro End------------------------*/
88 #include "../../../drivers/media/video/rk29_camera.c"
89 /*---------------- Camera Sensor Macro Define End ------------------------*/
91 /* Set memory size of pmem */
92 #ifdef CONFIG_RK29_MEM_SIZE_M
93 #define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
95 #define SDRAM_SIZE SZ_512M
97 #define PMEM_GPU_SIZE SZ_64M
98 #define PMEM_UI_SIZE SZ_32M
99 #define PMEM_VPU_SIZE SZ_64M
100 #define PMEM_SKYPE_SIZE 0
101 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
102 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
103 #define MEM_CAMIPP_SIZE SZ_4M
105 #define MEM_CAMIPP_SIZE 0
107 #define MEM_FB_SIZE (9*SZ_1M)
108 #ifdef CONFIG_FB_WORK_IPP
109 #define MEM_FBIPP_SIZE SZ_8M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4
111 #define MEM_FBIPP_SIZE 0
113 #if SDRAM_SIZE > SZ_512M
114 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
116 #define PMEM_GPU_BASE (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
118 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
119 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
120 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
121 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
122 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
123 #define MEM_FBIPP_BASE (MEM_FB_BASE - MEM_FBIPP_SIZE)
124 #define PMEM_SKYPE_BASE (MEM_FBIPP_BASE - PMEM_SKYPE_SIZE)
125 #define LINUX_SIZE (PMEM_SKYPE_BASE - RK29_SDRAM_PHYS)
127 #define PREALLOC_WLAN_SEC_NUM 4
128 #define PREALLOC_WLAN_BUF_NUM 160
129 #define PREALLOC_WLAN_SECTION_HEADER 24
131 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
132 #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
133 #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
134 #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
136 #define WLAN_SKB_BUF_NUM 16
138 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
140 struct wifi_mem_prealloc {
145 extern struct sys_timer rk29_timer;
147 static int rk29_nand_io_init(void)
152 struct rk29_nand_platform_data rk29_nand_data = {
153 .width = 1, /* data bus width in bytes */
154 .hw_ecc = 1, /* hw ecc 0: soft ecc */
156 .io_init = rk29_nand_io_init,
159 #define TOUCH_SCREEN_STANDBY_PIN RK29_PIN6_PD1
160 #define TOUCH_SCREEN_STANDBY_VALUE GPIO_HIGH
161 #define TOUCH_SCREEN_DISPLAY_PIN INVALID_GPIO
162 #define TOUCH_SCREEN_DISPLAY_VALUE GPIO_HIGH
163 #ifdef CONFIG_FB_RK29
164 /*****************************************************************************************
166 * author: zyw@rock-chips.com
167 *****************************************************************************************/
168 //#ifdef CONFIG_LCD_TD043MGEA1
169 #define LCD_TXD_PIN INVALID_GPIO
170 #define LCD_CLK_PIN INVALID_GPIO
171 #define LCD_CS_PIN INVALID_GPIO
172 /*****************************************************************************************
173 * frame buffe devices
174 * author: zyw@rock-chips.com
175 *****************************************************************************************/
177 #define FB_DISPLAY_ON_PIN INVALID_GPIO// RK29_PIN6_PD0
178 #define FB_LCD_STANDBY_PIN INVALID_GPIO
179 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
180 #define FB_MCU_FMK_PIN INVALID_GPIO
182 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
183 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
185 static int rk29_lcd_io_init(void)
191 static int rk29_lcd_io_deinit(void)
197 static struct rk29lcd_info rk29_lcd_info = {
198 .txd_pin = LCD_TXD_PIN,
199 .clk_pin = LCD_CLK_PIN,
200 .cs_pin = LCD_CS_PIN,
201 .io_init = rk29_lcd_io_init,
202 .io_deinit = rk29_lcd_io_deinit,
205 int rk29_fb_io_enable(void)
207 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
209 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
210 gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);
212 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
214 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
215 gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);
220 int rk29_fb_io_disable(void)
222 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
224 gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
225 gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);
227 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
229 gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
230 gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);
235 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
238 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
240 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
243 gpio_free(FB_MCU_FMK_PIN);
244 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
246 gpio_direction_input(FB_MCU_FMK_PIN);
248 if(fb_setting->disp_on_en)
250 if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
252 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
255 gpio_free(FB_DISPLAY_ON_PIN);
256 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
261 ret = gpio_request(TOUCH_SCREEN_DISPLAY_PIN, NULL);
264 gpio_free(TOUCH_SCREEN_DISPLAY_PIN);
265 printk(">>>>>> TOUCH_SCREEN_DISPLAY_PIN gpio_request err \n ");
267 gpio_direction_output(TOUCH_SCREEN_DISPLAY_PIN, 0);
268 gpio_set_value(TOUCH_SCREEN_DISPLAY_PIN, TOUCH_SCREEN_DISPLAY_VALUE);
272 if(fb_setting->disp_on_en)
274 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
276 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
279 gpio_free(FB_LCD_STANDBY_PIN);
280 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
285 ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL);
288 gpio_free(TOUCH_SCREEN_STANDBY_PIN);
289 printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n ");
291 gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0);
292 gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE);
296 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
298 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
301 gpio_free(FB_LCD_CABC_EN_PIN);
302 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
304 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
305 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
308 rk29_fb_io_enable(); //enable it
313 static struct rk29fb_info rk29_fb_info = {
315 .mcu_fmk_pin = FB_MCU_FMK_PIN,
316 .lcd_info = &rk29_lcd_info,
317 .io_init = rk29_fb_io_init,
318 .io_enable = rk29_fb_io_enable,
319 .io_disable = rk29_fb_io_disable,
322 /* rk29 fb resource */
323 static struct resource rk29_fb_resource[] = {
326 .start = RK29_LCDC_PHYS,
327 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
328 .flags = IORESOURCE_MEM,
334 .flags = IORESOURCE_IRQ,
338 .start = MEM_FB_BASE,
339 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
340 .flags = IORESOURCE_MEM,
342 #ifdef CONFIG_FB_WORK_IPP
344 .name = "win1 ipp buf",
345 .start = MEM_FBIPP_BASE,
346 .end = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
347 .flags = IORESOURCE_MEM,
353 struct platform_device rk29_device_fb = {
356 .num_resources = ARRAY_SIZE(rk29_fb_resource),
357 .resource = rk29_fb_resource,
359 .platform_data = &rk29_fb_info,
363 struct platform_device rk29_device_dma_cpy = {
364 .name = "dma_memcpy",
371 static struct android_pmem_platform_data android_pmem_pdata = {
373 .start = PMEM_UI_BASE,
374 .size = PMEM_UI_SIZE,
379 static struct platform_device android_pmem_device = {
380 .name = "android_pmem",
383 .platform_data = &android_pmem_pdata,
388 static struct vpu_mem_platform_data vpu_mem_pdata = {
390 .start = PMEM_VPU_BASE,
391 .size = PMEM_VPU_SIZE,
395 static struct platform_device rk29_vpu_mem_device = {
399 .platform_data = &vpu_mem_pdata,
402 static struct android_pmem_platform_data android_pmem_skype_pdata = {
403 .name = "pmem_skype",
404 .start = PMEM_SKYPE_BASE,
405 .size = PMEM_SKYPE_SIZE,
410 static struct platform_device android_pmem_skype_device = {
411 .name = "android_pmem",
414 .platform_data = &android_pmem_skype_pdata,
417 #ifdef CONFIG_VIDEO_RK29XX_VOUT
418 static struct platform_device rk29_v4l2_output_devce = {
422 /*HANNSTAR_P1003 touch*/
423 #if defined (CONFIG_HANNSTAR_P1003)
424 #define TOUCH_RESET_PIN RK29_PIN6_PC3
425 #define TOUCH_INT_PIN RK29_PIN0_PA2
427 int p1003_init_platform_hw(void)
429 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
430 gpio_free(TOUCH_RESET_PIN);
431 printk("p1003_init_platform_hw gpio_request error\n");
435 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
436 gpio_free(TOUCH_INT_PIN);
437 printk("p1003_init_platform_hw gpio_request error\n");
440 gpio_pull_updown(TOUCH_INT_PIN, 1);
441 gpio_direction_output(TOUCH_RESET_PIN, 0);
443 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
445 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
451 struct p1003_platform_data p1003_info = {
453 .init_platform_hw= p1003_init_platform_hw,
457 #if defined (CONFIG_EETI_EGALAX)
458 #define TOUCH_RESET_PIN RK29_PIN6_PC3
459 #define TOUCH_INT_PIN RK29_PIN0_PA2
461 static int EETI_EGALAX_init_platform_hw(void)
463 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
464 gpio_free(TOUCH_RESET_PIN);
465 printk("p1003_init_platform_hw gpio_request error\n");
469 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
470 gpio_free(TOUCH_INT_PIN);
471 printk("p1003_init_platform_hw gpio_request error\n");
474 gpio_pull_updown(TOUCH_INT_PIN, 1);
475 gpio_direction_output(TOUCH_RESET_PIN, 0);
477 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
479 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
485 static struct eeti_egalax_platform_data eeti_egalax_info = {
487 .init_platform_hw= EETI_EGALAX_init_platform_hw,
488 .standby_pin = TOUCH_SCREEN_STANDBY_PIN,
489 .standby_value = TOUCH_SCREEN_STANDBY_VALUE,
490 .disp_on_pin = TOUCH_SCREEN_DISPLAY_PIN,
491 .disp_on_value = TOUCH_SCREEN_DISPLAY_VALUE,
495 #ifdef CONFIG_GS_KXTF9
496 #include <linux/kxtf9.h>
497 #define KXTF9_DEVICE_MAP 1
498 #define KXTF9_MAP_X (KXTF9_DEVICE_MAP-1)%2
499 #define KXTF9_MAP_Y KXTF9_DEVICE_MAP%2
500 #define KXTF9_NEG_X (KXTF9_DEVICE_MAP/2)%2
501 #define KXTF9_NEG_Y (KXTF9_DEVICE_MAP+1)/4
502 #define KXTF9_NEG_Z (KXTF9_DEVICE_MAP-1)/4
503 struct kxtf9_platform_data kxtf9_pdata = {
506 .g_range = KXTF9_G_2G,
507 .axis_map_x = KXTF9_MAP_X,
508 .axis_map_y = KXTF9_MAP_Y,
510 .negate_x = KXTF9_NEG_X,
511 .negate_y = KXTF9_NEG_Y,
512 .negate_z = KXTF9_NEG_Z,
513 //.ctrl_regc_init = KXTF9_G_2G | ODR50F,
514 //.ctrl_regb_init = ENABLE,
516 #endif /* CONFIG_GS_KXTF9 */
520 #if defined (CONFIG_GS_MMA8452)
521 #define MMA8452_INT_PIN RK29_PIN0_PA3
523 static int mma8452_init_platform_hw(void)
526 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
527 gpio_free(MMA8452_INT_PIN);
528 printk("mma8452_init_platform_hw gpio_request error\n");
531 gpio_pull_updown(MMA8452_INT_PIN, 1);
536 static struct mma8452_platform_data mma8452_info = {
539 .init_platform_hw= mma8452_init_platform_hw,
543 #if defined (CONFIG_MPU_SENSORS_MPU3050)
545 static struct mpu3050_platform_data mpu3050_data = {
547 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
548 //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
549 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
550 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
552 #if defined (CONFIG_MPU_SENSORS_KXTF9)
554 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
555 .get_slave_descr = NULL ,
557 .get_slave_descr = get_accel_slave_descr ,
559 .adapt_num = 0, // The i2c bus to which the mpu device is
561 //.irq = RK29_PIN0_PA3,
562 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
564 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
565 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
566 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
567 .orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
570 #if defined (CONFIG_MPU_SENSORS_AK8975)
572 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
573 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
575 .get_slave_descr = get_compass_slave_descr,
577 .adapt_num = 0, // The i2c bus to which the compass device is.
578 // It can be difference with mpu
580 //.irq = RK29_PIN0_PA4,
581 .bus = EXT_SLAVE_BUS_PRIMARY,
583 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
584 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
585 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
586 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
587 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
592 #if defined (CONFIG_BATTERY_BQ27510)
593 #define DC_CHECK_PIN RK29_PIN4_PA1
594 #define LI_LION_BAT_NUM 2
595 static int bq27510_init_dc_check_pin(void){
596 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
597 gpio_free(DC_CHECK_PIN);
598 printk("bq27510 init dc check pin request error\n");
601 gpio_direction_input(DC_CHECK_PIN);
605 struct bq27510_platform_data bq27510_info = {
606 .init_dc_check_pin = bq27510_init_dc_check_pin,
607 .dc_check_pin = DC_CHECK_PIN,
608 .bat_num = LI_LION_BAT_NUM,
613 /*****************************************************************************************
615 * author: kfx@rock-chips.com
616 *****************************************************************************************/
617 static int rk29_i2c0_io_init(void)
619 #ifdef CONFIG_RK29_I2C0_CONTROLLER
620 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
621 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
623 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
624 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
629 static int rk29_i2c1_io_init(void)
631 #ifdef CONFIG_RK29_I2C1_CONTROLLER
632 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
633 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
635 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
636 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
640 static int rk29_i2c2_io_init(void)
642 #ifdef CONFIG_RK29_I2C2_CONTROLLER
643 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
644 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
646 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
647 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
652 static int rk29_i2c3_io_init(void)
654 #ifdef CONFIG_RK29_I2C3_CONTROLLER
655 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
656 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
658 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
659 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
663 #ifdef CONFIG_RK29_I2C0_CONTROLLER
664 struct rk29_i2c_platform_data default_i2c0_data = {
668 .scl_rate = 400*1000,
669 .mode = I2C_MODE_IRQ,
670 .io_init = rk29_i2c0_io_init,
673 struct i2c_gpio_platform_data default_i2c0_data = {
674 .sda_pin = RK29_PIN2_PB6,
675 .scl_pin = RK29_PIN2_PB7,
676 .udelay = 5, // clk = 500/udelay = 100Khz
677 .timeout = 100,//msecs_to_jiffies(200),
679 .io_init = rk29_i2c0_io_init,
682 #ifdef CONFIG_RK29_I2C1_CONTROLLER
683 struct rk29_i2c_platform_data default_i2c1_data = {
687 .scl_rate = 400*1000,
688 .mode = I2C_MODE_IRQ,
689 .io_init = rk29_i2c1_io_init,
692 struct i2c_gpio_platform_data default_i2c1_data = {
693 .sda_pin = RK29_PIN1_PA6,
694 .scl_pin = RK29_PIN1_PA7,
695 .udelay = 5, // clk = 500/udelay = 100Khz
696 .timeout = 100,//msecs_to_jiffies(200),
698 .io_init = rk29_i2c1_io_init,
701 #ifdef CONFIG_RK29_I2C2_CONTROLLER
702 struct rk29_i2c_platform_data default_i2c2_data = {
706 .scl_rate = 400*1000,
707 .mode = I2C_MODE_IRQ,
708 .io_init = rk29_i2c2_io_init,
711 struct i2c_gpio_platform_data default_i2c2_data = {
712 .sda_pin = RK29_PIN5_PD3,
713 .scl_pin = RK29_PIN5_PD4,
714 .udelay = 5, // clk = 500/udelay = 100Khz
715 .timeout = 100,//msecs_to_jiffies(200),
717 .io_init = rk29_i2c2_io_init,
720 #ifdef CONFIG_RK29_I2C3_CONTROLLER
721 struct rk29_i2c_platform_data default_i2c3_data = {
725 .scl_rate = 400*1000,
726 .mode = I2C_MODE_IRQ,
727 .io_init = rk29_i2c3_io_init,
730 struct i2c_gpio_platform_data default_i2c3_data = {
731 .sda_pin = RK29_PIN5_PB5,
732 .scl_pin = RK29_PIN5_PB4,
733 .udelay = 5, // clk = 500/udelay = 100Khz
734 .timeout = 100,//msecs_to_jiffies(200),
736 .io_init = rk29_i2c3_io_init,
739 #ifdef CONFIG_I2C0_RK29
740 static struct i2c_board_info __initdata board_i2c0_devices[] = {
741 #if defined (CONFIG_RK1000_CONTROL)
743 .type = "rk1000_control",
748 #if defined (CONFIG_SND_SOC_alc5621)
755 #if defined (CONFIG_SND_SOC_alc5631)
762 #if defined (CONFIG_SND_SOC_RK1000)
764 .type = "rk1000_i2c_codec",
769 #if defined (CONFIG_SND_SOC_WM8900)
776 #if defined (CONFIG_BATTERY_STC3100)
783 #if defined (CONFIG_BATTERY_BQ27510)
788 .platform_data = &bq27510_info,
791 #if defined (CONFIG_RTC_HYM8563)
793 .type = "rtc_hym8563",
796 .irq = RK29_PIN0_PA1,
799 #if defined (CONFIG_GS_MMA8452)
801 .type = "gs_mma8452",
804 .irq = MMA8452_INT_PIN,
805 .platform_data = &mma8452_info,
808 #if defined (CONFIG_COMPASS_AK8973)
813 .irq = RK29_PIN0_PA4,
816 #if defined (CONFIG_COMPASS_AK8975)
821 .irq = RK29_PIN0_PA4,
824 #if defined (CONFIG_MPU_SENSORS_MPU3050)
829 .irq = RK29_PIN5_PA3,
830 .platform_data = &mpu3050_data,
835 #if defined (CONFIG_ANX7150)
836 struct hdmi_platform_data anx7150_data = {
837 //.io_init = anx7150_io_init,
841 #ifdef CONFIG_I2C1_RK29
842 static struct i2c_board_info __initdata board_i2c1_devices[] = {
843 #if defined (CONFIG_RK1000_CONTROL1)
845 .type = "rk1000_control",
850 #if defined (CONFIG_ANX7150)
853 .addr = 0x39, //0x39, 0x3d
855 .irq = RK29_PIN1_PD7,
856 .platform_data = &anx7150_data,
863 #ifdef CONFIG_I2C2_RK29
864 static struct i2c_board_info __initdata board_i2c2_devices[] = {
865 #if defined (CONFIG_HANNSTAR_P1003)
867 .type = "p1003_touch",
869 .flags = 0, //I2C_M_NEED_DELAY
870 .irq = RK29_PIN0_PA2,
871 .platform_data = &p1003_info,
875 #if defined (CONFIG_EETI_EGALAX)
877 .type = "egalax_i2c",
880 .irq = RK29_PIN0_PA2,
881 .platform_data = &eeti_egalax_info,
887 #ifdef CONFIG_I2C3_RK29
888 static struct i2c_board_info __initdata board_i2c3_devices[] = {
892 /*****************************************************************************************
894 * author: ddl@rock-chips.com
895 *****************************************************************************************/
896 #ifdef CONFIG_VIDEO_RK29
897 #define CONFIG_SENSOR_POWER_IOCTL_USR 0
898 #define CONFIG_SENSOR_RESET_IOCTL_USR 0
899 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0
900 #define CONFIG_SENSOR_FLASH_IOCTL_USR 0
902 #if CONFIG_SENSOR_POWER_IOCTL_USR
903 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
905 #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
909 #if CONFIG_SENSOR_RESET_IOCTL_USR
910 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
912 #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
916 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
917 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
919 #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
923 #if CONFIG_SENSOR_FLASH_IOCTL_USR
924 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
926 #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
930 static struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
931 #if CONFIG_SENSOR_POWER_IOCTL_USR
932 .sensor_power_cb = sensor_power_usr_cb,
934 .sensor_power_cb = NULL,
937 #if CONFIG_SENSOR_RESET_IOCTL_USR
938 .sensor_reset_cb = sensor_reset_usr_cb,
940 .sensor_reset_cb = NULL,
943 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
944 .sensor_powerdown_cb = sensor_powerdown_usr_cb,
946 .sensor_powerdown_cb = NULL,
949 #if CONFIG_SENSOR_FLASH_IOCTL_USR
950 .sensor_flash_cb = sensor_flash_usr_cb,
952 .sensor_flash_cb = NULL,
956 #include "../../../drivers/media/video/rk29_camera.c"
958 /*****************************************************************************************
960 * author: nzy@rock-chips.com
961 *****************************************************************************************/
962 #ifdef CONFIG_BACKLIGHT_RK29_BL
964 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
965 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
966 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
967 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
971 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
972 #define PWM_MUX_MODE GPIO1L_PWM0
973 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
974 #define PWM_GPIO RK29_PIN1_PB5
975 #define PWM_EFFECT_VALUE 1
977 #define LCD_DISP_ON_PIN
979 #ifdef LCD_DISP_ON_PIN
980 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
981 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
983 #define BL_EN_PIN RK29_PIN6_PD0
984 #define BL_EN_VALUE GPIO_HIGH
986 static int rk29_backlight_io_init(void)
990 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
991 #ifdef LCD_DISP_ON_PIN
992 // rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
994 ret = gpio_request(BL_EN_PIN, NULL);
997 gpio_free(BL_EN_PIN);
1000 gpio_direction_output(BL_EN_PIN, 0);
1001 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1006 static int rk29_backlight_io_deinit(void)
1009 #ifdef LCD_DISP_ON_PIN
1010 gpio_free(BL_EN_PIN);
1012 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1016 static int rk29_backlight_pwm_suspend(void)
1019 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1020 if (gpio_request(PWM_GPIO, NULL)) {
1021 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
1024 gpio_direction_output(PWM_GPIO, GPIO_LOW);
1025 #ifdef LCD_DISP_ON_PIN
1026 gpio_direction_output(BL_EN_PIN, 0);
1027 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
1032 static int rk29_backlight_pwm_resume(void)
1034 gpio_free(PWM_GPIO);
1035 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1037 #ifdef LCD_DISP_ON_PIN
1039 gpio_direction_output(BL_EN_PIN, 1);
1040 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1045 struct rk29_bl_info rk29_bl_info = {
1047 .bl_ref = PWM_EFFECT_VALUE,
1048 .io_init = rk29_backlight_io_init,
1049 .io_deinit = rk29_backlight_io_deinit,
1050 .pwm_suspend = rk29_backlight_pwm_suspend,
1051 .pwm_resume = rk29_backlight_pwm_resume,
1054 /*****************************************************************************************
1055 * pwm voltage regulator devices
1056 ******************************************************************************************/
1057 #if defined (CONFIG_RK29_PWM_REGULATOR)
1059 #define REGULATOR_PWM_ID 2
1060 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1061 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1062 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1063 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1065 static struct regulator_consumer_supply pwm_consumers[] = {
1071 static struct regulator_init_data rk29_pwm_regulator_data = {
1077 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1079 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1080 .consumer_supplies = pwm_consumers,
1083 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1084 .pwm_id = REGULATOR_PWM_ID,
1085 .pwm_gpio = REGULATOR_PWM_GPIO,
1086 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1087 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1088 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1089 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1090 .init_data = &rk29_pwm_regulator_data,
1093 static struct platform_device rk29_device_pwm_regulator = {
1094 .name = "pwm-voltage-regulator",
1097 .platform_data = &rk29_regulator_pwm_platform_data,
1103 /*****************************************************************************************
1105 *****************************************************************************************/
1106 #ifdef CONFIG_SDMMC0_RK29
1107 static int rk29_sdmmc0_cfg_gpio(void)
1109 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1110 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1111 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1112 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1113 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1114 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1116 #ifdef CONFIG_SDMMC_RK29_OLD
1117 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
1119 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
1122 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1123 gpio_request(RK29_PIN5_PD5,"sdmmc");
1125 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1127 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1129 gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
1134 #define CONFIG_SDMMC0_USE_DMA
1135 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1136 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1137 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1138 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1139 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1140 .io_init = rk29_sdmmc0_cfg_gpio,
1141 .dma_name = "sd_mmc",
1142 #ifdef CONFIG_SDMMC0_USE_DMA
1147 .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
1148 .enable_sd_wakeup = 0,
1151 #ifdef CONFIG_SDMMC1_RK29
1152 #define CONFIG_SDMMC1_USE_DMA
1153 static int rk29_sdmmc1_cfg_gpio(void)
1155 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1156 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1157 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1158 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1159 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1160 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1161 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1165 #ifdef CONFIG_WIFI_CONTROL_FUNC
1166 static int rk29sdk_wifi_status(struct device *dev);
1167 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1170 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1172 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1173 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1174 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1175 MMC_VDD_32_33|MMC_VDD_33_34),
1176 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1177 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1178 .io_init = rk29_sdmmc1_cfg_gpio,
1180 #ifdef CONFIG_SDMMC1_USE_DMA
1185 #ifdef CONFIG_WIFI_CONTROL_FUNC
1186 .status = rk29sdk_wifi_status,
1187 .register_status_notify = rk29sdk_wifi_status_register,
1190 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1195 #ifdef CONFIG_WIFI_CONTROL_FUNC
1196 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1197 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1198 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1200 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1201 static void (*wifi_status_cb)(int card_present, void *dev_id);
1202 static void *wifi_status_cb_devid;
1203 int rk29sdk_wifi_power_state = 0;
1204 int rk29sdk_bt_power_state = 0;
1206 static int rk29sdk_wifi_status(struct device *dev)
1208 return rk29sdk_wifi_cd;
1211 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1215 wifi_status_cb = callback;
1216 wifi_status_cb_devid = dev_id;
1220 static int rk29sdk_wifi_bt_gpio_control_init(void)
1222 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1223 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1227 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1228 pr_info("%s: request wifi reset gpio failed\n", __func__);
1229 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1233 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1234 pr_info("%s: request bt reset gpio failed\n", __func__);
1235 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1239 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1240 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1241 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1243 pr_info("%s: init finished\n",__func__);
1248 static int rk29sdk_wifi_power(int on)
1250 pr_info("%s: %d\n", __func__, on);
1252 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
1253 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
1255 pr_info("wifi turn on power\n");
1257 if (!rk29sdk_bt_power_state){
1258 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1260 pr_info("wifi shut off power\n");
1263 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1265 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1269 rk29sdk_wifi_power_state = on;
1273 static int rk29sdk_wifi_reset_state;
1274 static int rk29sdk_wifi_reset(int on)
1276 pr_info("%s: %d\n", __func__, on);
1277 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1279 rk29sdk_wifi_reset_state = on;
1283 int rk29sdk_wifi_set_carddetect(int val)
1285 pr_info("%s:%d\n", __func__, val);
1286 rk29sdk_wifi_cd = val;
1287 if (wifi_status_cb){
1288 wifi_status_cb(val, wifi_status_cb_devid);
1290 pr_warning("%s, nobody to notify\n", __func__);
1294 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
1296 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
1297 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
1298 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
1299 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
1300 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
1303 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
1305 if (section == PREALLOC_WLAN_SEC_NUM)
1306 return wlan_static_skb;
1308 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
1311 if (wifi_mem_array[section].size < size)
1314 return wifi_mem_array[section].mem_ptr;
1317 int __init rk29sdk_init_wifi_mem(void)
1322 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
1323 wlan_static_skb[i] = dev_alloc_skb(
1324 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
1326 if (!wlan_static_skb[i])
1330 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
1331 wifi_mem_array[i].mem_ptr =
1332 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
1334 if (!wifi_mem_array[i].mem_ptr)
1340 pr_err("Failed to mem_alloc for WLAN\n");
1341 for (j = 0 ; j < i ; j++)
1342 kfree(wifi_mem_array[j].mem_ptr);
1344 i = WLAN_SKB_BUF_NUM;
1347 pr_err("Failed to skb_alloc for WLAN\n");
1348 for (j = 0 ; j < i ; j++)
1349 dev_kfree_skb(wlan_static_skb[j]);
1354 static struct wifi_platform_data rk29sdk_wifi_control = {
1355 .set_power = rk29sdk_wifi_power,
1356 .set_reset = rk29sdk_wifi_reset,
1357 .set_carddetect = rk29sdk_wifi_set_carddetect,
1358 .mem_prealloc = rk29sdk_mem_prealloc,
1360 static struct platform_device rk29sdk_wifi_device = {
1361 .name = "bcm4329_wlan",
1364 .platform_data = &rk29sdk_wifi_control,
1370 /* bluetooth rfkill device */
1371 static struct platform_device rk29sdk_rfkill = {
1372 .name = "rk29sdk_rfkill",
1377 #ifdef CONFIG_VIVANTE
1378 #define GPU_HIGH_CLOCK 552
1379 #define GPU_LOW_CLOCK (periph_pll_default / 1000000) /* same as general pll clock rate below */
1380 static struct resource resources_gpu[] = {
1385 .flags = IORESOURCE_IRQ,
1389 .start = RK29_GPU_PHYS,
1390 .end = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
1391 .flags = IORESOURCE_MEM,
1395 .start = PMEM_GPU_BASE,
1396 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
1397 .flags = IORESOURCE_MEM,
1401 .start = GPU_LOW_CLOCK,
1402 .end = GPU_HIGH_CLOCK,
1403 .flags = IORESOURCE_IO,
1406 static struct platform_device rk29_device_gpu = {
1409 .num_resources = ARRAY_SIZE(resources_gpu),
1410 .resource = resources_gpu,
1414 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
1415 #define BU92747GUW_RESET_PIN RK29_PIN3_PD4// INVALID_GPIO //
1416 #define BU92747GUW_RESET_MUX_NAME GPIO3D4_HOSTWRN_NAME//NULL //
1417 #define BU92747GUW_RESET_MUX_MODE GPIO3H_GPIO3D4//NULL //
1419 #define BU92747GUW_PWDN_PIN RK29_PIN3_PD3//RK29_PIN5_PA7 //
1420 #define BU92747GUW_PWDN_MUX_NAME GPIO3D3_HOSTRDN_NAME//GPIO5A7_HSADCDATA2_NAME //
1421 #define BU92747GUW_PWDN_MUX_MODE GPIO3H_GPIO3D3//GPIO5L_GPIO5A7 //
1423 static int bu92747guw_io_init(void)
1428 if(BU92747GUW_RESET_MUX_NAME != NULL)
1430 rk29_mux_api_set(BU92747GUW_RESET_MUX_NAME, BU92747GUW_RESET_MUX_MODE);
1432 ret = gpio_request(BU92747GUW_RESET_PIN, NULL);
1435 gpio_free(BU92747GUW_RESET_PIN);
1436 printk(">>>>>> BU92747GUW_RESET_PIN gpio_request err \n ");
1438 gpio_direction_output(BU92747GUW_RESET_PIN, GPIO_HIGH);
1441 if(BU92747GUW_PWDN_MUX_NAME != NULL)
1443 rk29_mux_api_set(BU92747GUW_PWDN_MUX_NAME, BU92747GUW_PWDN_MUX_MODE);
1445 ret = gpio_request(BU92747GUW_PWDN_PIN, NULL);
1448 gpio_free(BU92747GUW_PWDN_PIN);
1449 printk(">>>>>> BU92747GUW_PWDN_PIN gpio_request err \n ");
1452 //power down as default
1453 gpio_direction_output(BU92747GUW_PWDN_PIN, GPIO_LOW);
1459 static int bu92747guw_io_deinit(void)
1461 gpio_free(BU92747GUW_PWDN_PIN);
1462 gpio_free(BU92747GUW_RESET_PIN);
1466 //power ctl func is share with irda and remote
1467 static int nPowerOnCount = 0;
1468 static DEFINE_MUTEX(bu92747_power_mutex);
1470 //1---power on; 0---power off
1471 static int bu92747guw_power_ctl(int enable)
1473 printk("%s \n",__FUNCTION__);
1475 mutex_lock(&bu92747_power_mutex);
1478 if (nPowerOnCount == 1) {//power on first
1480 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_HIGH);
1481 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_LOW);
1483 gpio_set_value(BU92747GUW_RESET_PIN, GPIO_HIGH);
1489 if (nPowerOnCount <= 0) {//power down final
1492 gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_LOW);
1495 mutex_unlock(&bu92747_power_mutex);
1500 #ifdef CONFIG_RK_IRDA
1501 #define IRDA_IRQ_PIN RK29_PIN5_PB2
1502 #define IRDA_IRQ_MUX_NAME GPIO5B2_HSADCDATA5_NAME
1503 #define IRDA_IRQ_MUX_MODE GPIO5L_GPIO5B2
1505 int irda_iomux_init(void)
1510 if(IRDA_IRQ_MUX_NAME != NULL)
1512 rk29_mux_api_set(IRDA_IRQ_MUX_NAME, IRDA_IRQ_MUX_MODE);
1514 ret = gpio_request(IRDA_IRQ_PIN, NULL);
1517 gpio_free(IRDA_IRQ_PIN);
1518 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1520 gpio_pull_updown(IRDA_IRQ_PIN, GPIO_HIGH);
1521 gpio_direction_input(IRDA_IRQ_PIN);
1526 int irda_iomux_deinit(void)
1528 gpio_free(IRDA_IRQ_PIN);
1532 static struct irda_info rk29_irda_info = {
1533 .intr_pin = IRDA_IRQ_PIN,
1534 .iomux_init = irda_iomux_init,
1535 .iomux_deinit = irda_iomux_deinit,
1536 .irda_pwr_ctl = bu92747guw_power_ctl,
1539 static struct platform_device irda_device = {
1540 #ifdef CONFIG_RK_IRDA_NET
1543 .name = "bu92747_irda",
1547 .platform_data = &rk29_irda_info,
1553 #ifdef CONFIG_KEYS_RK29
1554 extern struct rk29_keys_platform_data rk29_keys_pdata;
1555 static struct platform_device rk29_device_keys = {
1556 .name = "rk29-keypad",
1559 .platform_data = &rk29_keys_pdata,
1564 static void __init rk29_board_iomux_init(void)
1566 #ifdef CONFIG_RK29_PWM_REGULATOR
1567 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1571 static struct platform_device *devices[] __initdata = {
1573 #ifdef CONFIG_RK29_WATCHDOG
1577 #ifdef CONFIG_UART1_RK29
1580 #ifdef CONFIG_UART0_RK29
1583 #ifdef CONFIG_UART2_RK29
1586 #ifdef CONFIG_UART3_RK29
1590 #ifdef CONFIG_RK29_PWM_REGULATOR
1591 &rk29_device_pwm_regulator,
1593 #ifdef CONFIG_SPIM0_RK29
1594 &rk29xx_device_spi0m,
1596 #ifdef CONFIG_SPIM1_RK29
1597 &rk29xx_device_spi1m,
1599 #ifdef CONFIG_ADC_RK29
1602 #ifdef CONFIG_I2C0_RK29
1605 #ifdef CONFIG_I2C1_RK29
1608 #ifdef CONFIG_I2C2_RK29
1611 #ifdef CONFIG_I2C3_RK29
1615 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1616 &rk29_device_iis_2ch,
1618 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1619 &rk29_device_iis_8ch,
1622 #ifdef CONFIG_KEYS_RK29
1625 #ifdef CONFIG_SDMMC0_RK29
1626 &rk29_device_sdmmc0,
1628 #ifdef CONFIG_SDMMC1_RK29
1629 &rk29_device_sdmmc1,
1632 #ifdef CONFIG_MTD_NAND_RK29XX
1633 &rk29xx_device_nand,
1636 #ifdef CONFIG_WIFI_CONTROL_FUNC
1637 &rk29sdk_wifi_device,
1644 #ifdef CONFIG_MTD_NAND_RK29
1648 #ifdef CONFIG_FB_RK29
1650 &rk29_device_dma_cpy,
1652 #ifdef CONFIG_BACKLIGHT_RK29_BL
1653 &rk29_device_backlight,
1655 #ifdef CONFIG_RK29_VMAC
1658 #ifdef CONFIG_VIVANTE
1661 #ifdef CONFIG_VIDEO_RK29
1662 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1663 #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
1664 &rk29_soc_camera_pdrv_0,
1666 &rk29_soc_camera_pdrv_1,
1667 &android_pmem_cam_device,
1669 &android_pmem_skype_device,
1670 &android_pmem_device,
1671 &rk29_vpu_mem_device,
1672 #ifdef CONFIG_USB20_OTG
1673 &rk29_device_usb20_otg,
1675 #ifdef CONFIG_USB20_HOST
1676 &rk29_device_usb20_host,
1678 #ifdef CONFIG_USB11_HOST
1679 &rk29_device_usb11_host,
1681 #ifdef CONFIG_USB_ANDROID
1682 &android_usb_device,
1683 &usb_mass_storage_device,
1685 #ifdef CONFIG_RK29_IPP
1688 #ifdef CONFIG_VIDEO_RK29XX_VOUT
1689 &rk29_v4l2_output_devce,
1691 #ifdef CONFIG_RK_IRDA
1696 /*****************************************************************************************
1698 * author: cmc@rock-chips.com
1699 *****************************************************************************************/
1700 static int rk29_vmac_register_set(void)
1702 //config rk29 vmac as rmii, 100MHz
1703 u32 value= readl(RK29_GRF_BASE + 0xbc);
1704 value = (value & 0xfff7ff) | (0x400);
1705 writel(value, RK29_GRF_BASE + 0xbc);
1709 static int rk29_rmii_io_init(void)
1714 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
1716 gpio_free(RK29_PIN6_PB0);
1717 printk("-------request RK29_PIN6_PB0 fail--------\n");
1721 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1722 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1727 static int rk29_rmii_io_deinit(void)
1730 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1731 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1733 gpio_free(RK29_PIN6_PB0);
1737 static int rk29_rmii_power_control(int enable)
1741 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
1742 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
1745 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1746 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1751 struct rk29_vmac_platform_data rk29_vmac_pdata = {
1752 .vmac_register_set = rk29_vmac_register_set,
1753 .rmii_io_init = rk29_rmii_io_init,
1754 .rmii_io_deinit = rk29_rmii_io_deinit,
1755 .rmii_power_control = rk29_rmii_power_control,
1758 /*****************************************************************************************
1760 * author: cmc@rock-chips.com
1761 *****************************************************************************************/
1762 #define SPI_CHIPSELECT_NUM 2
1763 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
1766 .cs_gpio = RK29_PIN2_PC1,
1767 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
1768 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
1772 .cs_gpio = RK29_PIN1_PA4,
1773 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
1774 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
1778 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
1781 .cs_gpio = RK29_PIN2_PC5,
1782 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
1783 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
1787 .cs_gpio = RK29_PIN1_PA3,
1788 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
1789 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
1793 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
1798 for (i=0; i<cs_num; i++) {
1799 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
1806 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
1811 static int spi_io_fix_leakage_bug(void)
1814 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
1819 static int spi_io_resume_leakage_bug(void)
1822 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
1827 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
1828 .num_chipselect = SPI_CHIPSELECT_NUM,
1829 .chipselect_gpios = rk29xx_spi0_cs_gpios,
1830 .io_init = spi_io_init,
1831 .io_deinit = spi_io_deinit,
1832 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1833 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1836 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
1837 .num_chipselect = SPI_CHIPSELECT_NUM,
1838 .chipselect_gpios = rk29xx_spi1_cs_gpios,
1839 .io_init = spi_io_init,
1840 .io_deinit = spi_io_deinit,
1841 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1842 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1845 /*****************************************************************************************
1846 * xpt2046 touch panel
1847 * author: cmc@rock-chips.com
1848 *****************************************************************************************/
1849 #define XPT2046_GPIO_INT RK29_PIN0_PA3
1850 #define DEBOUNCE_REPTIME 3
1852 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
1853 static struct xpt2046_platform_data xpt2046_info = {
1862 .debounce_rep = DEBOUNCE_REPTIME,
1864 .gpio_pendown = XPT2046_GPIO_INT,
1865 .penirq_recheck_delay_usecs = 1,
1867 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
1868 static struct xpt2046_platform_data xpt2046_info = {
1877 .debounce_rep = DEBOUNCE_REPTIME,
1879 .gpio_pendown = XPT2046_GPIO_INT,
1880 .penirq_recheck_delay_usecs = 1,
1882 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
1883 static struct xpt2046_platform_data xpt2046_info = {
1892 .debounce_rep = DEBOUNCE_REPTIME,
1894 .gpio_pendown = XPT2046_GPIO_INT,
1896 .penirq_recheck_delay_usecs = 1,
1898 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1899 static struct xpt2046_platform_data xpt2046_info = {
1908 .debounce_rep = DEBOUNCE_REPTIME,
1910 .gpio_pendown = XPT2046_GPIO_INT,
1912 .penirq_recheck_delay_usecs = 1,
1916 static struct spi_board_info board_spi_devices[] = {
1917 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
1918 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1920 .modalias = "xpt2046_ts",
1922 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
1924 .irq = XPT2046_GPIO_INT,
1925 .platform_data = &xpt2046_info,
1931 static void __init rk29_gic_init_irq(void)
1933 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
1934 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
1937 static void __init machine_rk29_init_irq(void)
1939 rk29_gic_init_irq();
1943 static struct cpufreq_frequency_table freq_table[] = {
1944 { .index = 1200000, .frequency = 408000 },
1945 { .index = 1200000, .frequency = 816000 },
1946 { .index = 1300000, .frequency = 1008000 },
1947 { .frequency = CPUFREQ_TABLE_END },
1950 static void __init machine_rk29_board_init(void)
1952 rk29_board_iomux_init();
1955 board_update_cpufreq_table(freq_table);
1957 platform_add_devices(devices, ARRAY_SIZE(devices));
1958 #ifdef CONFIG_I2C0_RK29
1959 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
1960 ARRAY_SIZE(board_i2c0_devices));
1962 #ifdef CONFIG_I2C1_RK29
1963 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
1964 ARRAY_SIZE(board_i2c1_devices));
1966 #ifdef CONFIG_I2C2_RK29
1967 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
1968 ARRAY_SIZE(board_i2c2_devices));
1970 #ifdef CONFIG_I2C3_RK29
1971 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
1972 ARRAY_SIZE(board_i2c3_devices));
1975 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1977 #ifdef CONFIG_WIFI_CONTROL_FUNC
1978 rk29sdk_wifi_bt_gpio_control_init();
1979 rk29sdk_init_wifi_mem();
1982 board_usb_detect_init(RK29_PIN0_PA0);
1983 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
1985 bu92747guw_io_init();
1990 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
1991 char **cmdline, struct meminfo *mi)
1994 mi->bank[0].start = RK29_SDRAM_PHYS;
1995 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
1996 mi->bank[0].size = LINUX_SIZE;
1997 #if SDRAM_SIZE > SZ_512M
1999 mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
2000 mi->bank[1].size = SDRAM_SIZE - SZ_512M;
2004 static void __init machine_rk29_mapio(void)
2006 rk29_map_common_io();
2007 rk29_setup_early_printk();
2009 rk29_clock_init(periph_pll_default);
2011 ddr_init(DDR_TYPE, DDR_FREQ);
2014 MACHINE_START(RK29, "RK29board")
2015 /* UART for LL DEBUG */
2016 .phys_io = RK29_UART1_PHYS & 0xfff00000,
2017 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2018 .boot_params = RK29_SDRAM_PHYS + 0x88000,
2019 .fixup = machine_rk29_fixup,
2020 .map_io = machine_rk29_mapio,
2021 .init_irq = machine_rk29_init_irq,
2022 .init_machine = machine_rk29_board_init,
2023 .timer = &rk29_timer,