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>
27 #include <linux/i2c/tps65910.h>
28 #include <linux/mpu.h>
29 #include <linux/mpu3050.h>
30 #include <mach/hardware.h>
31 #include <asm/setup.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/flash.h>
36 #include <asm/hardware/gic.h>
38 #include <mach/iomux.h>
39 #include <mach/gpio.h>
40 #include <mach/irqs.h>
41 #include <mach/rk29_iomap.h>
42 #include <mach/board.h>
43 #include <mach/rk29_nand.h>
44 #include <mach/rk29_camera.h> /* ddl@rock-chips.com : camera support */
45 #include <media/soc_camera.h> /* ddl@rock-chips.com : camera support */
46 #include <mach/vpu_mem.h>
47 #include <mach/sram.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>
56 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
59 /* Set memory size of pmem */
60 #ifdef CONFIG_RK29_MEM_SIZE_M
61 #define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
63 #define SDRAM_SIZE SZ_512M
65 #define PMEM_GPU_SIZE ( SZ_64M *3)
66 #define PMEM_UI_SIZE SZ_32M
67 #define PMEM_VPU_SIZE SZ_64M
68 #define PMEM_CAM_SIZE 0x01300000
69 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
70 #define MEM_CAMIPP_SIZE SZ_4M
72 #define MEM_CAMIPP_SIZE 0
74 #define MEM_FB_SIZE (3*SZ_2M)
76 #define PMEM_GPU_BASE ((u32)RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
77 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
78 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
79 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
80 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
81 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
82 #define LINUX_SIZE (MEM_FB_BASE - RK29_SDRAM_PHYS)
84 #define PREALLOC_WLAN_SEC_NUM 4
85 #define PREALLOC_WLAN_BUF_NUM 160
86 #define PREALLOC_WLAN_SECTION_HEADER 24
88 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
89 #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
90 #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
91 #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
93 #define WLAN_SKB_BUF_NUM 16
95 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
97 struct wifi_mem_prealloc {
102 extern struct sys_timer rk29_timer;
104 static int rk29_nand_io_init(void)
109 struct rk29_nand_platform_data rk29_nand_data = {
110 .width = 1, /* data bus width in bytes */
111 .hw_ecc = 1, /* hw ecc 0: soft ecc */
113 .io_init = rk29_nand_io_init,
116 #ifdef CONFIG_FB_RK29
117 /*****************************************************************************************
119 * author: zyw@rock-chips.com
120 *****************************************************************************************/
121 //#ifdef CONFIG_LCD_TD043MGEA1
122 #define LCD_TXD_PIN INVALID_GPIO
123 #define LCD_CLK_PIN INVALID_GPIO
124 #define LCD_CS_PIN INVALID_GPIO
125 /*****************************************************************************************
126 * frame buffe devices
127 * author: zyw@rock-chips.com
128 *****************************************************************************************/
130 #define FB_DISPLAY_ON_PIN RK29_PIN6_PD0
131 #define FB_LCD_STANDBY_PIN RK29_PIN6_PD1
132 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
133 #define FB_MCU_FMK_PIN INVALID_GPIO
135 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
136 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
139 static int rk29_lcd_io_init(void)
145 static int rk29_lcd_io_deinit(void)
151 static struct rk29lcd_info rk29_lcd_info = {
152 .txd_pin = LCD_TXD_PIN,
153 .clk_pin = LCD_CLK_PIN,
154 .cs_pin = LCD_CS_PIN,
155 .io_init = rk29_lcd_io_init,
156 .io_deinit = rk29_lcd_io_deinit,
160 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
163 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
165 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
168 gpio_free(FB_MCU_FMK_PIN);
169 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
171 gpio_direction_input(FB_MCU_FMK_PIN);
173 if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
175 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
178 gpio_free(FB_DISPLAY_ON_PIN);
179 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
183 if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
185 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
188 gpio_free(FB_LCD_STANDBY_PIN);
189 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
193 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
195 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
198 gpio_free(FB_LCD_CABC_EN_PIN);
199 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
201 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
202 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
208 static struct rk29fb_info rk29_fb_info = {
210 .disp_on_pin = FB_DISPLAY_ON_PIN,
211 .disp_on_value = FB_DISPLAY_ON_VALUE,
212 .standby_pin = FB_LCD_STANDBY_PIN,
213 .standby_value = FB_LCD_STANDBY_VALUE,
214 .mcu_fmk_pin = FB_MCU_FMK_PIN,
215 .lcd_info = &rk29_lcd_info,
216 .io_init = rk29_fb_io_init,
219 /* rk29 fb resource */
220 static struct resource rk29_fb_resource[] = {
223 .start = RK29_LCDC_PHYS,
224 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
225 .flags = IORESOURCE_MEM,
231 .flags = IORESOURCE_IRQ,
235 .start = MEM_FB_BASE,
236 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
237 .flags = IORESOURCE_MEM,
242 struct platform_device rk29_device_fb = {
245 .num_resources = ARRAY_SIZE(rk29_fb_resource),
246 .resource = rk29_fb_resource,
248 .platform_data = &rk29_fb_info,
252 struct platform_device rk29_device_dma_cpy = {
253 .name = "dma_memcpy",
260 static struct android_pmem_platform_data android_pmem_pdata = {
262 .start = PMEM_UI_BASE,
263 .size = PMEM_UI_SIZE,
268 static struct platform_device android_pmem_device = {
269 .name = "android_pmem",
272 .platform_data = &android_pmem_pdata,
277 static struct android_pmem_platform_data android_pmem_cam_pdata = {
279 .start = PMEM_CAM_BASE,
280 .size = PMEM_CAM_SIZE,
285 static struct platform_device android_pmem_cam_device = {
286 .name = "android_pmem",
289 .platform_data = &android_pmem_cam_pdata,
294 static struct vpu_mem_platform_data vpu_mem_pdata = {
296 .start = PMEM_VPU_BASE,
297 .size = PMEM_VPU_SIZE,
301 static struct platform_device rk29_vpu_mem_device = {
305 .platform_data = &vpu_mem_pdata,
309 static struct platform_device rk29_v4l2_output_devce = {
313 /*HANNSTAR_P1003 touch*/
314 #if defined (CONFIG_HANNSTAR_P1003)
315 #define TOUCH_RESET_PIN RK29_PIN6_PC3
316 #define TOUCH_INT_PIN RK29_PIN0_PA2
318 int p1003_init_platform_hw(void)
320 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
321 gpio_free(TOUCH_RESET_PIN);
322 printk("p1003_init_platform_hw gpio_request error\n");
326 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
327 gpio_free(TOUCH_INT_PIN);
328 printk("p1003_init_platform_hw gpio_request error\n");
331 gpio_pull_updown(TOUCH_INT_PIN, 1);
332 gpio_direction_output(TOUCH_RESET_PIN, 0);
334 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
336 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
342 struct p1003_platform_data p1003_info = {
344 .init_platform_hw= p1003_init_platform_hw,
348 #if defined (CONFIG_EETI_EGALAX)
349 #define TOUCH_RESET_PIN RK29_PIN6_PC3
350 #define TOUCH_INT_PIN RK29_PIN0_PA2
352 static int EETI_EGALAX_init_platform_hw(void)
354 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
355 gpio_free(TOUCH_RESET_PIN);
356 printk("p1003_init_platform_hw gpio_request error\n");
360 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
361 gpio_free(TOUCH_INT_PIN);
362 printk("p1003_init_platform_hw gpio_request error\n");
365 gpio_pull_updown(TOUCH_INT_PIN, 1);
366 gpio_direction_output(TOUCH_RESET_PIN, 0);
368 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
370 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
376 static struct eeti_egalax_platform_data eeti_egalax_info = {
378 .init_platform_hw= EETI_EGALAX_init_platform_hw,
383 #if defined (CONFIG_GS_MMA8452)
384 #define MMA8452_INT_PIN RK29_PIN0_PA3
386 static int mma8452_init_platform_hw(void)
389 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
390 gpio_free(MMA8452_INT_PIN);
391 printk("mma8452_init_platform_hw gpio_request error\n");
394 gpio_pull_updown(MMA8452_INT_PIN, 1);
399 static struct mma8452_platform_data mma8452_info = {
402 .init_platform_hw= mma8452_init_platform_hw,
406 #if defined (CONFIG_SENSORS_MPU3050)
408 static struct mpu3050_platform_data mpu3050_data = {
410 .orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
411 //{ 0, -1, 0 ,-1 , 0, 0, 0, 0, 1 },
412 //{ 0, -1, 0 ,-1 , 0, 0, 0, 0, 1 },
413 //{ 1, 0, 0,0, -1, 0,0, 0, 1 },//{ 0, 1, 0,1, 0, 0,0, 0, -1 },
415 #if defined (CONFIG_SENSORS_KXTF9)
417 .get_slave_descr = kxtf9_get_slave_descr ,
418 .adapt_num = 0, // The i2c bus to which the mpu device is
420 .irq = RK29_PIN0_PA3,
421 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
423 .orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
424 //{ 0, -1, 0 ,1 , 0, 0, 0, 0, 1 },
425 //{ 0, -1, 0 ,1 , 0, 0, 0, 0, 1 },
426 //{ 1, 0, 0,0, 1, 0,0, 0, 1 },//{ 0, 1, 0,1, 0, 0,0, 0, -1 },
429 #if defined (CONFIG_SENSORS_AK8975)
431 .get_slave_descr = ak8975_get_slave_descr,/*ak5883_get_slave_descr,*/
432 .adapt_num = 0, // The i2c bus to which the compass device is.
433 // It can be difference with mpu
435 .irq = RK29_PIN0_PA4,
436 .bus = EXT_SLAVE_BUS_PRIMARY,
438 .orientation = /*{ 0, 1, 0,
441 { -1, 0, 0,0, -1, 0,0, 0, 1 },
442 //{ 0, 1, 0 , -1 , 0, 0, 0, 0, 1 },
443 //{ -1, 0, 0 ,0 , -1, 0, 0, 0, 1 },
444 //{ -1, 0, 0,0, -1, 0,0, 0, 1 },//{ 0, 1, 0,-1, 0, 0,0, 0, 1 },
449 #if defined (CONFIG_BATTERY_BQ27510)
451 #define DC_CHECK_PIN RK29_PIN4_PA1
452 #define LI_LION_BAT_NUM 2
453 static int bq27510_init_dc_check_pin(void)
455 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0)
457 gpio_free(DC_CHECK_PIN);
458 printk("bq27510 init dc check pin request error\n");
461 gpio_direction_input(DC_CHECK_PIN);
464 struct bq27510_platform_data bq27510_info =
466 .init_dc_check_pin = bq27510_init_dc_check_pin,
467 .dc_check_pin = DC_CHECK_PIN,
468 .bat_num = LI_LION_BAT_NUM,
474 /*****************************************************************************************
475 * TI TPS65910 voltage regulator devices
476 ******************************************************************************************/
477 #if defined (CONFIG_TPS65910_CORE)
479 static struct regulator_consumer_supply rk29_vdd1_supplies[] = {
481 .supply = "vcore", // set name vcore for all platform
486 static struct regulator_init_data rk29_regulator_vdd1 = {
490 .valid_modes_mask = REGULATOR_MODE_NORMAL,
491 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
495 .num_consumer_supplies = ARRAY_SIZE(rk29_vdd1_supplies),
496 .consumer_supplies = rk29_vdd1_supplies,
500 static struct regulator_consumer_supply rk29_vdd2_supplies[] = {
507 static struct regulator_init_data rk29_regulator_vdd2 = {
511 .valid_modes_mask = REGULATOR_MODE_NORMAL,
512 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
516 .num_consumer_supplies = ARRAY_SIZE(rk29_vdd2_supplies),
517 .consumer_supplies = rk29_vdd2_supplies,
521 static struct regulator_consumer_supply rk29_vio_supplies[] = {
528 static struct regulator_init_data rk29_regulator_vio = {
532 .valid_modes_mask = REGULATOR_MODE_NORMAL,
533 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
537 .num_consumer_supplies = ARRAY_SIZE(rk29_vio_supplies),
538 .consumer_supplies = rk29_vio_supplies,
542 static struct regulator_consumer_supply rk29_vaux1_supplies[] = {
549 static struct regulator_init_data rk29_regulator_vaux1 = {
553 .valid_modes_mask = REGULATOR_MODE_NORMAL,
554 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
557 .num_consumer_supplies = ARRAY_SIZE(rk29_vaux1_supplies),
558 .consumer_supplies = rk29_vaux1_supplies,
562 static struct regulator_consumer_supply rk29_vaux2_supplies[] = {
569 static struct regulator_init_data rk29_regulator_vaux2 = {
573 .valid_modes_mask = REGULATOR_MODE_NORMAL,
574 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
577 .num_consumer_supplies = ARRAY_SIZE(rk29_vaux2_supplies),
578 .consumer_supplies = rk29_vaux2_supplies,
582 static struct regulator_consumer_supply rk29_vdac_supplies[] = {
589 static struct regulator_init_data rk29_regulator_vdac = {
593 .valid_modes_mask = REGULATOR_MODE_NORMAL,
594 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
597 .num_consumer_supplies = ARRAY_SIZE(rk29_vdac_supplies),
598 .consumer_supplies = rk29_vdac_supplies,
602 static struct regulator_consumer_supply rk29_vaux33_supplies[] = {
609 static struct regulator_init_data rk29_regulator_vaux33 = {
613 .valid_modes_mask = REGULATOR_MODE_NORMAL,
614 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
617 .num_consumer_supplies = ARRAY_SIZE(rk29_vaux33_supplies),
618 .consumer_supplies = rk29_vaux33_supplies,
622 static struct regulator_consumer_supply rk29_vmmc_supplies[] = {
629 static struct regulator_init_data rk29_regulator_vmmc = {
633 .valid_modes_mask = REGULATOR_MODE_NORMAL,
634 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
637 .num_consumer_supplies = ARRAY_SIZE(rk29_vmmc_supplies),
638 .consumer_supplies = rk29_vmmc_supplies,
642 static struct regulator_consumer_supply rk29_vpll_supplies[] = {
649 static struct regulator_init_data rk29_regulator_vpll = {
653 .valid_modes_mask = REGULATOR_MODE_NORMAL,
654 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
658 .num_consumer_supplies = ARRAY_SIZE(rk29_vpll_supplies),
659 .consumer_supplies = rk29_vpll_supplies,
663 static struct regulator_consumer_supply rk29_vdig1_supplies[] = {
670 static struct regulator_init_data rk29_regulator_vdig1 = {
674 .valid_modes_mask = REGULATOR_MODE_NORMAL,
675 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
678 .num_consumer_supplies = ARRAY_SIZE(rk29_vdig1_supplies),
679 .consumer_supplies = rk29_vdig1_supplies,
683 static struct regulator_consumer_supply rk29_vdig2_supplies[] = {
690 static struct regulator_init_data rk29_regulator_vdig2 = {
694 .valid_modes_mask = REGULATOR_MODE_NORMAL,
695 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
699 .num_consumer_supplies = ARRAY_SIZE(rk29_vdig2_supplies),
700 .consumer_supplies = rk29_vdig2_supplies,
703 static int rk29_tps65910_config(struct tps65910_platform_data *pdata)
710 /* Configure TPS65910 for rk29 board needs */
711 printk("rk29_tps65910_config: tps65910 init config.\n");
713 err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_DEVCTRL2);
715 printk(KERN_ERR "Unable to read TPS65910_REG_DEVCTRL2 reg\n");
718 /* Set sleep state active high and allow device turn-off after PWRON long press */
719 val |= (TPS65910_DEV2_SLEEPSIG_POL | TPS65910_DEV2_PWON_LP_OFF);
721 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val,
722 TPS65910_REG_DEVCTRL2);
724 printk(KERN_ERR "Unable to write TPS65910_REG_DEVCTRL2 reg\n");
728 /* Set the maxinum load current */
730 err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD1);
732 printk(KERN_ERR "Unable to read TPS65910_REG_VDD1 reg\n");
737 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VDD1);
739 printk(KERN_ERR "Unable to write TPS65910_REG_VDD1 reg\n");
744 err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD2);
746 printk(KERN_ERR "Unable to read TPS65910_REG_VDD2 reg\n");
751 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VDD2);
753 printk(KERN_ERR "Unable to write TPS65910_REG_VDD2 reg\n");
758 err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VIO);
760 printk(KERN_ERR "Unable to read TPS65910_REG_VIO reg\n");
765 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VIO);
767 printk(KERN_ERR "Unable to write TPS65910_REG_VIO reg\n");
771 /* Mask ALL interrupts */
772 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, 0xFF,
773 TPS65910_REG_INT_MSK);
775 printk(KERN_ERR "Unable to write TPS65910_REG_INT_MSK reg\n");
778 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, 0x03,
779 TPS65910_REG_INT_MSK2);
781 printk(KERN_ERR "Unable to write TPS65910_REG_INT_MSK2 reg\n");
785 /* Set RTC Power, disable Smart Reflex in DEVCTRL_REG */
787 val |= (TPS65910_SR_CTL_I2C_SEL);
788 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val,
789 TPS65910_REG_DEVCTRL);
791 printk(KERN_ERR "Unable to write TPS65910_REG_DEVCTRL reg\n");
795 /* initilize all ISR work as NULL, specific driver will
796 * assign function(s) later.
798 for (i = 0; i < TPS65910_MAX_IRQS; i++)
799 pdata->handlers[i] = NULL;
804 struct tps65910_platform_data rk29_tps65910_data = {
805 .irq_num = (unsigned)TPS65910_HOST_IRQ,
807 .vio = &rk29_regulator_vio,
808 .vdd1 = &rk29_regulator_vdd1,
809 .vdd2 = &rk29_regulator_vdd2,
811 .vdig1 = &rk29_regulator_vdig1,
812 .vdig2 = &rk29_regulator_vdig2,
813 .vaux33 = &rk29_regulator_vaux33,
814 .vmmc = &rk29_regulator_vmmc,
815 .vaux1 = &rk29_regulator_vaux1,
816 .vaux2 = &rk29_regulator_vaux2,
817 .vdac = &rk29_regulator_vdac,
818 .vpll = &rk29_regulator_vpll,
819 .board_tps65910_config = rk29_tps65910_config,
821 #endif /* CONFIG_TPS65910_CORE */
824 /*****************************************************************************************
826 * author: kfx@rock-chips.com
827 *****************************************************************************************/
828 static int rk29_i2c0_io_init(void)
830 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
831 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
835 static int rk29_i2c1_io_init(void)
837 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
838 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
841 static int rk29_i2c2_io_init(void)
843 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
844 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
848 static int rk29_i2c3_io_init(void)
850 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
851 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
855 struct rk29_i2c_platform_data default_i2c0_data = {
859 .scl_rate = 400*1000,
860 .mode = I2C_MODE_IRQ,
861 .io_init = rk29_i2c0_io_init,
864 struct rk29_i2c_platform_data default_i2c1_data = {
868 .scl_rate = 400*1000,
869 .mode = I2C_MODE_POLL,
870 .io_init = rk29_i2c1_io_init,
873 struct rk29_i2c_platform_data default_i2c2_data = {
877 .scl_rate = 400*1000,
878 .mode = I2C_MODE_IRQ,
879 .io_init = rk29_i2c2_io_init,
882 struct rk29_i2c_platform_data default_i2c3_data = {
886 .scl_rate = 400*1000,
887 .mode = I2C_MODE_POLL,
888 .io_init = rk29_i2c3_io_init,
891 #ifdef CONFIG_I2C0_RK29
892 static struct i2c_board_info __initdata board_i2c0_devices[] = {
893 #if defined (CONFIG_RK1000_CONTROL)
895 .type = "rk1000_control",
900 #if defined (CONFIG_SND_SOC_RK1000)
902 .type = "rk1000_i2c_codec",
907 #if defined (CONFIG_SND_SOC_WM8900)
914 #if defined (CONFIG_BATTERY_STC3100)
921 #if defined (CONFIG_BATTERY_BQ27510)
926 .platform_data = &bq27510_info,
929 #if defined (CONFIG_RTC_HYM8563)
931 .type = "rtc_hym8563",
934 .irq = RK29_PIN0_PA1,
937 #if defined (CONFIG_GS_MMA8452)
939 .type = "gs_mma8452",
942 .irq = MMA8452_INT_PIN,
943 .platform_data = &mma8452_info,
946 #if defined (CONFIG_SENSORS_AK8973)
951 .irq = RK29_PIN0_PA4,
954 #if 0//defined (CONFIG_SENSORS_AK8975)
959 .irq = RK29_PIN0_PA4,
963 #if defined (CONFIG_SENSORS_MPU3050)
968 .irq = RK29_PIN5_PA3,
969 .platform_data = &mpu3050_data,
975 #ifdef CONFIG_I2C1_RK29
976 static struct i2c_board_info __initdata board_i2c1_devices[] = {
977 #if defined (CONFIG_RK1000_CONTROL1)
979 .type = "rk1000_control",
984 #if defined (CONFIG_ANX7150)
987 .addr = 0x39, //0x39, 0x3d
989 .irq = RK29_PIN1_PD7,
992 #if defined (CONFIG_ATMEL_MXT224)
994 .type = "mXT224_touch",
997 .irq = RK29_PIN0_PA2,
998 //.platform_data = &p1003_info,
1004 #ifdef CONFIG_I2C2_RK29
1005 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1006 #if defined (CONFIG_HANNSTAR_P1003)
1008 .type = "p1003_touch",
1011 .irq = RK29_PIN0_PA2,
1012 .platform_data = &p1003_info,
1015 #if defined (CONFIG_EETI_EGALAX)
1017 .type = "egalax_i2c",
1020 .irq = RK29_PIN0_PA2,
1021 .platform_data = &eeti_egalax_info,
1024 #if defined (CONFIG_TPS65910_CORE)
1026 .type = "tps659102",
1027 .addr = TPS65910_I2C_ID0,
1029 .irq = TPS65910_HOST_IRQ,
1030 .platform_data = &rk29_tps65910_data,
1036 #ifdef CONFIG_I2C3_RK29
1037 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1041 /*****************************************************************************************
1043 * author: ddl@rock-chips.com
1044 *****************************************************************************************/
1045 #ifdef CONFIG_VIDEO_RK29
1046 #define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_MT9P111 /* back camera sensor */
1047 #define SENSOR_IIC_ADDR_0 0x00
1048 #define SENSOR_IIC_ADAPTER_ID_0 1
1049 #define SENSOR_POWER_PIN_0 RK29_PIN5_PD7
1050 #define SENSOR_RESET_PIN_0 INVALID_GPIO
1051 #define SENSOR_POWERDN_PIN_0 RK29_PIN1_PB2
1052 #define SENSOR_FALSH_PIN_0 INVALID_GPIO
1053 #define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
1054 #define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
1055 #define SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
1056 #define SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
1058 #define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_S5K6AA /* front camera sensor */
1059 #define SENSOR_IIC_ADDR_1 0x78
1060 #define SENSOR_IIC_ADAPTER_ID_1 1
1061 #define SENSOR_POWER_PIN_1 INVALID_GPIO
1062 #define SENSOR_RESET_PIN_1 RK29_PIN1_PB3
1063 #define SENSOR_POWERDN_PIN_1 RK29_PIN6_PB7
1064 #define SENSOR_FALSH_PIN_1 INVALID_GPIO
1065 #define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
1066 #define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
1067 #define SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_L
1068 #define SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
1070 static int rk29_sensor_io_init(void);
1071 static int rk29_sensor_io_deinit(int sensor);
1072 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
1074 static struct rk29camera_platform_data rk29_camera_platform_data = {
1075 .io_init = rk29_sensor_io_init,
1076 .io_deinit = rk29_sensor_io_deinit,
1077 .sensor_ioctrl = rk29_sensor_ioctrl,
1080 .gpio_reset = SENSOR_RESET_PIN_0,
1081 .gpio_power = SENSOR_POWER_PIN_0,
1082 .gpio_powerdown = SENSOR_POWERDN_PIN_0,
1083 .gpio_flash = SENSOR_FALSH_PIN_0,
1084 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0|SENSOR_POWERDNACTIVE_LEVEL_0|SENSOR_FLASHACTIVE_LEVEL_0),
1086 .dev_name = SENSOR_NAME_0,
1088 .gpio_reset = SENSOR_RESET_PIN_1,
1089 .gpio_power = SENSOR_POWER_PIN_1,
1090 .gpio_powerdown = SENSOR_POWERDN_PIN_1,
1091 .gpio_flash = SENSOR_FALSH_PIN_1,
1092 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1|SENSOR_POWERDNACTIVE_LEVEL_1|SENSOR_FLASHACTIVE_LEVEL_1),
1094 .dev_name = SENSOR_NAME_1,
1097 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
1099 .name = "camera_ipp_mem",
1100 .start = MEM_CAMIPP_BASE,
1101 .size = MEM_CAMIPP_SIZE,
1106 static int rk29_sensor_io_init(void)
1109 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1110 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1111 unsigned int camera_ioflag;
1113 for (i=0; i<2; i++) {
1114 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
1115 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
1116 camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
1117 camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
1118 camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
1119 rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
1121 if (camera_power != INVALID_GPIO) {
1122 ret = gpio_request(camera_power, "camera power");
1124 goto sensor_io_int_loop_end;
1125 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
1126 gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1127 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1129 //printk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1133 if (camera_reset != INVALID_GPIO) {
1134 ret = gpio_request(camera_reset, "camera reset");
1136 goto sensor_io_int_loop_end;
1137 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
1138 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1139 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1141 //printk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1145 if (camera_powerdown != INVALID_GPIO) {
1146 ret = gpio_request(camera_powerdown, "camera powerdown");
1148 goto sensor_io_int_loop_end;
1149 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
1150 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1151 gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1153 //printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1157 if (camera_flash != INVALID_GPIO) {
1158 ret = gpio_request(camera_flash, "camera flash");
1160 goto sensor_io_int_loop_end;
1161 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
1162 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1163 gpio_direction_output(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1165 //printk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1169 sensor_io_int_loop_end:
1170 rk29_sensor_io_deinit(i);
1177 static int rk29_sensor_io_deinit(int sensor)
1179 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1180 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1182 camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
1183 camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
1184 camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
1185 camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
1187 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
1188 if (camera_power != INVALID_GPIO) {
1189 gpio_direction_input(camera_power);
1190 gpio_free(camera_power);
1194 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
1195 if (camera_reset != INVALID_GPIO) {
1196 gpio_direction_input(camera_reset);
1197 gpio_free(camera_reset);
1201 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
1202 if (camera_powerdown != INVALID_GPIO) {
1203 gpio_direction_input(camera_powerdown);
1204 gpio_free(camera_powerdown);
1208 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
1209 if (camera_flash != INVALID_GPIO) {
1210 gpio_direction_input(camera_flash);
1211 gpio_free(camera_flash);
1215 rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
1218 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
1220 unsigned int camera_power=INVALID_GPIO,camera_reset=INVALID_GPIO, camera_powerdown=INVALID_GPIO,camera_flash = INVALID_GPIO;
1221 unsigned int camera_ioflag,camera_io_init;
1222 int ret = RK29_CAM_IO_SUCCESS;
1224 if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
1225 camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
1226 camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
1227 camera_powerdown = rk29_camera_platform_data.gpio_res[0].gpio_powerdown;
1228 camera_flash = rk29_camera_platform_data.gpio_res[0].gpio_flash;
1229 camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
1230 camera_io_init = rk29_camera_platform_data.gpio_res[0].gpio_init;
1231 } else if (rk29_camera_platform_data.gpio_res[1].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[1].dev_name, dev_name(dev)) == 0)) {
1232 camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
1233 camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
1234 camera_powerdown = rk29_camera_platform_data.gpio_res[1].gpio_powerdown;
1235 camera_flash = rk29_camera_platform_data.gpio_res[1].gpio_flash;
1236 camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
1237 camera_io_init = rk29_camera_platform_data.gpio_res[1].gpio_init;
1244 if (camera_power != INVALID_GPIO) {
1245 if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
1247 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1248 //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1251 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1252 //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1255 ret = RK29_CAM_EIO_REQUESTFAIL;
1256 printk("\n%s..%s..PowerPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1259 ret = RK29_CAM_EIO_INVALID;
1265 if (camera_reset != INVALID_GPIO) {
1266 if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
1268 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1269 //printk("\n%s..%s..ResetPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1271 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1272 //printk("\n%s..%s..ResetPin= %d..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_reset, (((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1275 ret = RK29_CAM_EIO_REQUESTFAIL;
1276 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1279 ret = RK29_CAM_EIO_INVALID;
1286 if (camera_powerdown != INVALID_GPIO) {
1287 if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
1289 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1290 //printk("\n%s..%s..PowerDownPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1292 gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1293 //printk("\n%s..%s..PowerDownPin= %d..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_powerdown, (((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1296 ret = RK29_CAM_EIO_REQUESTFAIL;
1297 printk("\n%s..%s..PowerDownPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_powerdown);
1300 ret = RK29_CAM_EIO_INVALID;
1307 if (camera_flash != INVALID_GPIO) {
1308 if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
1310 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1311 //printk("\n%s..%s..FlashPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1313 gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1314 //printk("\n%s..%s..FlashPin= %d..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_flash, (((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1317 ret = RK29_CAM_EIO_REQUESTFAIL;
1318 printk("\n%s..%s..FlashPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_flash);
1321 ret = RK29_CAM_EIO_INVALID;
1328 printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
1334 static int rk29_sensor_power(struct device *dev, int on)
1336 rk29_sensor_ioctrl(dev,Cam_Power,on);
1339 static int rk29_sensor_reset(struct device *dev)
1341 rk29_sensor_ioctrl(dev,Cam_Reset,1);
1343 rk29_sensor_ioctrl(dev,Cam_Reset,0);
1346 static int rk29_sensor_powerdown(struct device *dev, int on)
1348 return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
1350 #if (SENSOR_IIC_ADDR_0 != 0x00)
1351 static struct i2c_board_info rk29_i2c_cam_info_0[] = {
1353 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
1357 static struct soc_camera_link rk29_iclink_0 = {
1358 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1359 .power = rk29_sensor_power,
1360 .powerdown = rk29_sensor_powerdown,
1361 .board_info = &rk29_i2c_cam_info_0[0],
1362 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
1363 .module_name = SENSOR_NAME_0,
1366 /*platform_device : soc-camera need */
1367 static struct platform_device rk29_soc_camera_pdrv_0 = {
1368 .name = "soc-camera-pdrv",
1371 .init_name = SENSOR_NAME_0,
1372 .platform_data = &rk29_iclink_0,
1376 #if (SENSOR_IIC_ADDR_1 != 0x00)
1377 static struct i2c_board_info rk29_i2c_cam_info_1[] = {
1379 I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
1383 static struct soc_camera_link rk29_iclink_1 = {
1384 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1385 .power = rk29_sensor_power,
1386 .powerdown = rk29_sensor_powerdown,
1387 .board_info = &rk29_i2c_cam_info_1[0],
1388 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
1389 .module_name = SENSOR_NAME_1,
1392 /*platform_device : soc-camera need */
1393 static struct platform_device rk29_soc_camera_pdrv_1 = {
1394 .name = "soc-camera-pdrv",
1397 .init_name = SENSOR_NAME_1,
1398 .platform_data = &rk29_iclink_1,
1403 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
1404 static struct resource rk29_camera_resource[] = {
1406 .start = RK29_VIP_PHYS,
1407 .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
1408 .flags = IORESOURCE_MEM,
1413 .flags = IORESOURCE_IRQ,
1417 /*platform_device : */
1418 static struct platform_device rk29_device_camera = {
1419 .name = RK29_CAM_DRV_NAME,
1420 .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
1421 .num_resources = ARRAY_SIZE(rk29_camera_resource),
1422 .resource = rk29_camera_resource,
1424 .dma_mask = &rockchip_device_camera_dmamask,
1425 .coherent_dma_mask = 0xffffffffUL,
1426 .platform_data = &rk29_camera_platform_data,
1430 /*****************************************************************************************
1432 * author: nzy@rock-chips.com
1433 *****************************************************************************************/
1434 #ifdef CONFIG_BACKLIGHT_RK29_BL
1436 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
1437 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
1438 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
1439 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
1443 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
1444 #define PWM_MUX_MODE GPIO1L_PWM0
1445 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1446 #define PWM_EFFECT_VALUE 1
1448 //#define LCD_DISP_ON_PIN
1450 #ifdef LCD_DISP_ON_PIN
1451 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
1452 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
1454 #define BL_EN_PIN GPIO0L_GPIO0A5
1455 #define BL_EN_VALUE GPIO_HIGH
1457 static int rk29_backlight_io_init(void)
1461 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1462 #ifdef LCD_DISP_ON_PIN
1463 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
1465 ret = gpio_request(BL_EN_PIN, NULL);
1468 gpio_free(BL_EN_PIN);
1471 gpio_direction_output(BL_EN_PIN, 0);
1472 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1477 static int rk29_backlight_io_deinit(void)
1480 #ifdef LCD_DISP_ON_PIN
1481 gpio_free(BL_EN_PIN);
1483 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1486 struct rk29_bl_info rk29_bl_info = {
1488 .bl_ref = PWM_EFFECT_VALUE,
1489 .io_init = rk29_backlight_io_init,
1490 .io_deinit = rk29_backlight_io_deinit,
1493 /*****************************************************************************************
1494 * pwm voltage regulator devices
1495 ******************************************************************************************/
1496 #if defined (CONFIG_RK29_PWM_REGULATOR)
1498 #define REGULATOR_PWM_ID 2
1499 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1500 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1501 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1502 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1504 static struct regulator_consumer_supply pwm_consumers[] = {
1510 static struct regulator_init_data rk29_pwm_regulator_data = {
1516 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1518 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1519 .consumer_supplies = pwm_consumers,
1522 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1523 .pwm_id = REGULATOR_PWM_ID,
1524 .pwm_gpio = REGULATOR_PWM_GPIO,
1525 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1526 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1527 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1528 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1529 .init_data = &rk29_pwm_regulator_data,
1532 static struct platform_device rk29_device_pwm_regulator = {
1533 .name = "pwm-voltage-regulator",
1536 .platform_data = &rk29_regulator_pwm_platform_data,
1543 /*****************************************************************************************
1545 *****************************************************************************************/
1546 #ifdef CONFIG_SDMMC0_RK29
1547 static int rk29_sdmmc0_cfg_gpio(void)
1549 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1550 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1551 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1552 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1553 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1554 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1555 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
1556 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1557 gpio_request(RK29_PIN5_PD5,"sdmmc");
1558 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1560 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1564 #define CONFIG_SDMMC0_USE_DMA
1565 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1566 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1567 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1568 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1569 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1570 .io_init = rk29_sdmmc0_cfg_gpio,
1571 .dma_name = "sd_mmc",
1572 #ifdef CONFIG_SDMMC0_USE_DMA
1579 #ifdef CONFIG_SDMMC1_RK29
1580 #define CONFIG_SDMMC1_USE_DMA
1581 static int rk29_sdmmc1_cfg_gpio(void)
1583 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1584 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1585 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1586 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1587 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1588 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1589 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1593 #ifdef CONFIG_WIFI_CONTROL_FUNC
1594 static int rk29sdk_wifi_status(struct device *dev);
1595 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1598 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1600 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1601 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1602 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1603 MMC_VDD_32_33|MMC_VDD_33_34),
1604 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1605 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1606 .io_init = rk29_sdmmc1_cfg_gpio,
1608 #ifdef CONFIG_SDMMC1_USE_DMA
1613 #ifdef CONFIG_WIFI_CONTROL_FUNC
1614 .status = rk29sdk_wifi_status,
1615 .register_status_notify = rk29sdk_wifi_status_register,
1618 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1623 #ifdef CONFIG_WIFI_CONTROL_FUNC
1624 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1625 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1626 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1628 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1629 static void (*wifi_status_cb)(int card_present, void *dev_id);
1630 static void *wifi_status_cb_devid;
1631 int rk29sdk_wifi_power_state = 0;
1632 int rk29sdk_bt_power_state = 0;
1634 static int rk29sdk_wifi_status(struct device *dev)
1636 return rk29sdk_wifi_cd;
1639 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1643 wifi_status_cb = callback;
1644 wifi_status_cb_devid = dev_id;
1648 static int rk29sdk_wifi_bt_gpio_control_init(void)
1650 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1651 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1655 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1656 pr_info("%s: request wifi reset gpio failed\n", __func__);
1657 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1661 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1662 pr_info("%s: request bt reset gpio failed\n", __func__);
1663 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1667 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1668 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1669 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1671 pr_info("%s: init finished\n",__func__);
1676 static int rk29sdk_wifi_power(int on)
1678 pr_info("%s: %d\n", __func__, on);
1680 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
1682 pr_info("wifi turn on power\n");
1684 if (!rk29sdk_bt_power_state){
1685 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
1687 pr_info("wifi shut off power\n");
1690 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1695 rk29sdk_wifi_power_state = on;
1699 static int rk29sdk_wifi_reset_state;
1700 static int rk29sdk_wifi_reset(int on)
1702 pr_info("%s: %d\n", __func__, on);
1703 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1705 rk29sdk_wifi_reset_state = on;
1709 int rk29sdk_wifi_set_carddetect(int val)
1711 pr_info("%s:%d\n", __func__, val);
1712 rk29sdk_wifi_cd = val;
1713 if (wifi_status_cb){
1714 wifi_status_cb(val, wifi_status_cb_devid);
1716 pr_warning("%s, nobody to notify\n", __func__);
1720 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
1722 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
1723 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
1724 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
1725 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
1726 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
1729 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
1731 if (section == PREALLOC_WLAN_SEC_NUM)
1732 return wlan_static_skb;
1734 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
1737 if (wifi_mem_array[section].size < size)
1740 return wifi_mem_array[section].mem_ptr;
1743 int __init rk29sdk_init_wifi_mem(void)
1748 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
1749 wlan_static_skb[i] = dev_alloc_skb(
1750 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
1752 if (!wlan_static_skb[i])
1756 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
1757 wifi_mem_array[i].mem_ptr =
1758 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
1760 if (!wifi_mem_array[i].mem_ptr)
1766 pr_err("Failed to mem_alloc for WLAN\n");
1767 for (j = 0 ; j < i ; j++)
1768 kfree(wifi_mem_array[j].mem_ptr);
1770 i = WLAN_SKB_BUF_NUM;
1773 pr_err("Failed to skb_alloc for WLAN\n");
1774 for (j = 0 ; j < i ; j++)
1775 dev_kfree_skb(wlan_static_skb[j]);
1780 static struct wifi_platform_data rk29sdk_wifi_control = {
1781 .set_power = rk29sdk_wifi_power,
1782 .set_reset = rk29sdk_wifi_reset,
1783 .set_carddetect = rk29sdk_wifi_set_carddetect,
1784 .mem_prealloc = rk29sdk_mem_prealloc,
1786 static struct platform_device rk29sdk_wifi_device = {
1787 .name = "bcm4329_wlan",
1790 .platform_data = &rk29sdk_wifi_control,
1796 /* bluetooth rfkill device */
1797 static struct platform_device rk29sdk_rfkill = {
1798 .name = "rk29sdk_rfkill",
1803 #ifdef CONFIG_VIVANTE
1804 static struct resource resources_gpu[] = {
1809 .flags = IORESOURCE_IRQ,
1813 .start = RK29_GPU_PHYS,
1814 .end = RK29_GPU_PHYS + RK29_GPU_SIZE,
1815 .flags = IORESOURCE_MEM,
1819 .start = PMEM_GPU_BASE,
1820 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE,
1821 .flags = IORESOURCE_MEM,
1824 static struct platform_device rk29_device_gpu = {
1827 .num_resources = ARRAY_SIZE(resources_gpu),
1828 .resource = resources_gpu,
1831 #ifdef CONFIG_KEYS_RK29
1832 extern struct rk29_keys_platform_data rk29_keys_pdata;
1833 static struct platform_device rk29_device_keys = {
1834 .name = "rk29-keypad",
1837 .platform_data = &rk29_keys_pdata,
1842 static void __init rk29_board_iomux_init(void)
1844 #ifdef CONFIG_UART0_RK29
1845 rk29_mux_api_set(GPIO1B7_UART0SOUT_NAME, GPIO1L_UART0_SOUT);
1846 rk29_mux_api_set(GPIO1B6_UART0SIN_NAME, GPIO1L_UART0_SIN);
1847 #ifdef CONFIG_UART0_CTS_RTS_RK29
1848 rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N);
1849 rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_UART0_CTS_N);
1852 #ifdef CONFIG_UART1_RK29
1853 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
1854 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
1856 #ifdef CONFIG_UART2_RK29
1857 rk29_mux_api_set(GPIO2B1_UART2SOUT_NAME, GPIO2L_UART2_SOUT);
1858 rk29_mux_api_set(GPIO2B0_UART2SIN_NAME, GPIO2L_UART2_SIN);
1859 #ifdef CONFIG_UART2_CTS_RTS_RK29
1860 rk29_mux_api_set(GPIO2A7_UART2RTSN_NAME, GPIO2L_UART2_RTS_N);
1861 rk29_mux_api_set(GPIO2A6_UART2CTSN_NAME, GPIO2L_UART2_CTS_N);
1864 #ifdef CONFIG_UART3_RK29
1865 rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
1866 rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
1867 #ifdef CONFIG_UART3_CTS_RTS_RK29
1868 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_UART3_RTS_N);
1869 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_UART3_CTS_N);
1872 #ifdef CONFIG_SPIM0_RK29
1873 rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME, GPIO2H_SPI0_CLK);
1874 rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME, GPIO2H_SPI0_CSN0);
1875 rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME, GPIO2H_SPI0_TXD);
1876 rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME, GPIO2H_SPI0_RXD);
1878 #ifdef CONFIG_SPIM1_RK29
1879 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK);
1880 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME, GPIO2H_SPI1_CSN0);
1881 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME, GPIO2H_SPI1_TXD);
1882 rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME, GPIO2H_SPI1_RXD);
1884 #ifdef CONFIG_RK29_VMAC
1885 rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME, GPIO4H_RMII_CLKOUT);
1886 rk29_mux_api_set(GPIO4C1_RMIITXEN_MIITXEN_NAME, GPIO4H_RMII_TX_EN);
1887 rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME, GPIO4H_RMII_TXD1);
1888 rk29_mux_api_set(GPIO4C3_RMIITXD0_MIITXD0_NAME, GPIO4H_RMII_TXD0);
1889 rk29_mux_api_set(GPIO4C4_RMIIRXERR_MIIRXERR_NAME, GPIO4H_RMII_RX_ERR);
1890 rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME, GPIO4H_RMII_CSR_DVALID);
1891 rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME, GPIO4H_RMII_RXD1);
1892 rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME, GPIO4H_RMII_RXD0);
1894 rk29_mux_api_set(GPIO0A7_MIIMDCLK_NAME, GPIO0L_MII_MDCLK);
1895 rk29_mux_api_set(GPIO0A6_MIIMD_NAME, GPIO0L_MII_MD);
1897 #ifdef CONFIG_RK29_PWM_REGULATOR
1898 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1900 #if defined (CONFIG_TPS65910_CORE)
1901 rk29_mux_api_set(GPIO4D32_CPUTRACEDATA32_NAME, GPIO4H_GPIO4D32);
1905 static struct platform_device *devices[] __initdata = {
1906 #ifdef CONFIG_UART1_RK29
1909 #ifdef CONFIG_UART0_RK29
1912 #ifdef CONFIG_UART2_RK29
1916 #ifdef CONFIG_RK29_PWM_REGULATOR
1917 &rk29_device_pwm_regulator,
1919 #ifdef CONFIG_SPIM0_RK29
1920 &rk29xx_device_spi0m,
1922 #ifdef CONFIG_SPIM1_RK29
1923 &rk29xx_device_spi1m,
1925 #ifdef CONFIG_ADC_RK29
1928 #ifdef CONFIG_I2C0_RK29
1931 #ifdef CONFIG_I2C1_RK29
1934 #ifdef CONFIG_I2C2_RK29
1937 #ifdef CONFIG_I2C3_RK29
1941 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1942 &rk29_device_iis_2ch,
1944 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1945 &rk29_device_iis_8ch,
1948 #ifdef CONFIG_KEYS_RK29
1951 #ifdef CONFIG_SDMMC0_RK29
1952 &rk29_device_sdmmc0,
1954 #ifdef CONFIG_SDMMC1_RK29
1955 &rk29_device_sdmmc1,
1958 #ifdef CONFIG_MTD_NAND_RK29XX
1959 &rk29xx_device_nand,
1962 #ifdef CONFIG_WIFI_CONTROL_FUNC
1963 &rk29sdk_wifi_device,
1970 #ifdef CONFIG_MTD_NAND_RK29
1974 #ifdef CONFIG_FB_RK29
1976 &rk29_device_dma_cpy,
1978 #ifdef CONFIG_BACKLIGHT_RK29_BL
1979 &rk29_device_backlight,
1981 #ifdef CONFIG_RK29_VMAC
1984 #ifdef CONFIG_VIVANTE
1987 #ifdef CONFIG_VIDEO_RK29
1988 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1989 #if (SENSOR_IIC_ADDR_0 != 0x00)
1990 &rk29_soc_camera_pdrv_0,
1992 #if (SENSOR_IIC_ADDR_1 != 0x00)
1993 &rk29_soc_camera_pdrv_1,
1995 &android_pmem_cam_device,
1997 &android_pmem_device,
1998 &rk29_vpu_mem_device,
1999 #ifdef CONFIG_USB20_OTG
2000 &rk29_device_usb20_otg,
2002 #ifdef CONFIG_USB20_HOST
2003 &rk29_device_usb20_host,
2005 #ifdef CONFIG_USB11_HOST
2006 &rk29_device_usb11_host,
2008 #ifdef CONFIG_USB_ANDROID
2009 &android_usb_device,
2010 &usb_mass_storage_device,
2012 #ifdef CONFIG_RK29_IPP
2015 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2016 &rk29_v4l2_output_devce,
2020 /*****************************************************************************************
2022 * author: cmc@rock-chips.com
2023 *****************************************************************************************/
2024 static int rk29_vmac_register_set(void)
2026 //config rk29 vmac as rmii, 100MHz
2027 u32 value= readl(RK29_GRF_BASE + 0xbc);
2028 value = (value & 0xfff7ff) | (0x400);
2029 writel(value, RK29_GRF_BASE + 0xbc);
2033 static int rk29_rmii_io_init(void)
2038 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2040 gpio_free(RK29_PIN6_PB0);
2041 printk("-------request RK29_PIN6_PB0 fail--------\n");
2045 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2046 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2051 static int rk29_rmii_io_deinit(void)
2054 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2055 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2057 gpio_free(RK29_PIN6_PB0);
2061 static int rk29_rmii_power_control(int enable)
2065 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2066 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2069 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2070 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2075 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2076 .vmac_register_set = rk29_vmac_register_set,
2077 .rmii_io_init = rk29_rmii_io_init,
2078 .rmii_io_deinit = rk29_rmii_io_deinit,
2079 .rmii_power_control = rk29_rmii_power_control,
2082 /*****************************************************************************************
2084 * author: cmc@rock-chips.com
2085 *****************************************************************************************/
2086 #define SPI_CHIPSELECT_NUM 2
2087 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2090 .cs_gpio = RK29_PIN2_PC1,
2091 .cs_iomux_name = NULL,
2095 .cs_gpio = RK29_PIN1_PA4,
2096 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2097 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2101 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2104 .cs_gpio = RK29_PIN2_PC5,
2105 .cs_iomux_name = NULL,
2109 .cs_gpio = RK29_PIN1_PA3,
2110 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2111 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2115 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2122 for (i=0; i<cs_num; i++) {
2123 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2124 ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
2127 gpio_free(cs_gpios[j].cs_gpio);
2128 //rk29_mux_api_mode_resume(cs_gpios[j].cs_iomux_name);
2130 printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
2133 gpio_direction_output(cs_gpios[i].cs_gpio, GPIO_HIGH);
2140 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2146 for (i=0; i<cs_num; i++) {
2147 gpio_free(cs_gpios[i].cs_gpio);
2148 //rk29_mux_api_mode_resume(cs_gpios[i].cs_iomux_name);
2155 static int spi_io_fix_leakage_bug(void)
2158 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2163 static int spi_io_resume_leakage_bug(void)
2166 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2171 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2172 .num_chipselect = SPI_CHIPSELECT_NUM,
2173 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2174 .io_init = spi_io_init,
2175 .io_deinit = spi_io_deinit,
2176 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2177 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2180 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2181 .num_chipselect = SPI_CHIPSELECT_NUM,
2182 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2183 .io_init = spi_io_init,
2184 .io_deinit = spi_io_deinit,
2185 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2186 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2189 /*****************************************************************************************
2190 * xpt2046 touch panel
2191 * author: cmc@rock-chips.com
2192 *****************************************************************************************/
2193 #define XPT2046_GPIO_INT RK29_PIN0_PA3
2194 #define DEBOUNCE_REPTIME 3
2196 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
2197 static struct xpt2046_platform_data xpt2046_info = {
2206 .debounce_rep = DEBOUNCE_REPTIME,
2208 .gpio_pendown = XPT2046_GPIO_INT,
2209 .penirq_recheck_delay_usecs = 1,
2211 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
2212 static struct xpt2046_platform_data xpt2046_info = {
2221 .debounce_rep = DEBOUNCE_REPTIME,
2223 .gpio_pendown = XPT2046_GPIO_INT,
2224 .penirq_recheck_delay_usecs = 1,
2226 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2227 static struct xpt2046_platform_data xpt2046_info = {
2236 .debounce_rep = DEBOUNCE_REPTIME,
2238 .gpio_pendown = XPT2046_GPIO_INT,
2240 .penirq_recheck_delay_usecs = 1,
2242 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2243 static struct xpt2046_platform_data xpt2046_info = {
2252 .debounce_rep = DEBOUNCE_REPTIME,
2254 .gpio_pendown = XPT2046_GPIO_INT,
2256 .penirq_recheck_delay_usecs = 1,
2260 static struct spi_board_info board_spi_devices[] = {
2261 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
2262 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2264 .modalias = "xpt2046_ts",
2266 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2268 .irq = XPT2046_GPIO_INT,
2269 .platform_data = &xpt2046_info,
2275 static void __init rk29_gic_init_irq(void)
2277 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2278 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2281 static void __init machine_rk29_init_irq(void)
2283 rk29_gic_init_irq();
2287 #define POWER_ON_PIN RK29_PIN4_PA4
2288 static void rk29_pm_power_off(void)
2290 printk(KERN_ERR "rk29_pm_power_off start...\n");
2291 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2295 static void __init machine_rk29_board_init(void)
2297 rk29_board_iomux_init();
2299 gpio_request(POWER_ON_PIN,"poweronpin");
2300 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
2301 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2302 pm_power_off = rk29_pm_power_off;
2304 #ifdef CONFIG_WIFI_CONTROL_FUNC
2305 rk29sdk_wifi_bt_gpio_control_init();
2308 platform_add_devices(devices, ARRAY_SIZE(devices));
2309 #ifdef CONFIG_I2C0_RK29
2310 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2311 ARRAY_SIZE(board_i2c0_devices));
2313 #ifdef CONFIG_I2C1_RK29
2314 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2315 ARRAY_SIZE(board_i2c1_devices));
2317 #ifdef CONFIG_I2C2_RK29
2318 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2319 ARRAY_SIZE(board_i2c2_devices));
2321 #ifdef CONFIG_I2C3_RK29
2322 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2323 ARRAY_SIZE(board_i2c3_devices));
2326 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2328 rk29sdk_init_wifi_mem();
2331 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2332 char **cmdline, struct meminfo *mi)
2335 mi->bank[0].start = RK29_SDRAM_PHYS;
2336 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
2337 mi->bank[0].size = LINUX_SIZE;
2340 static void __init machine_rk29_mapio(void)
2342 rk29_map_common_io();
2343 rk29_setup_early_printk();
2349 MACHINE_START(RK29, "RK29board")
2350 /* UART for LL DEBUG */
2351 .phys_io = RK29_UART1_PHYS,
2352 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2353 .boot_params = RK29_SDRAM_PHYS + 0x88000,
2354 .fixup = machine_rk29_fixup,
2355 .map_io = machine_rk29_mapio,
2356 .init_irq = machine_rk29_init_irq,
2357 .init_machine = machine_rk29_board_init,
2358 .timer = &rk29_timer,