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>
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
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,
408 static struct mpu3050_platform_data mpu3050_data = {
410 .orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
414 .get_slave_descr = bma150_get_slave_descr,
415 .adapt_num = 0, // The i2c bus to which the mpu device is
417 .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU
419 .orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
423 .get_slave_descr = ak8975_get_slave_descr,/*ak5883_get_slave_descr,*/
424 .adapt_num = 0, // The i2c bus to which the compass device is.
425 // It can be difference with mpu
427 .bus = EXT_SLAVE_BUS_PRIMARY,
429 .orientation = { 0, 1, 0,-1, 0, 0,0, 0, 1 },
434 #if defined (CONFIG_BATTERY_BQ27510)
436 #define DC_CHECK_PIN RK29_PIN4_PA1
437 #define LI_LION_BAT_NUM 2
438 static int bq27510_init_dc_check_pin(void)
440 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0)
442 gpio_free(DC_CHECK_PIN);
443 printk("bq27510 init dc check pin request error\n");
446 gpio_direction_input(DC_CHECK_PIN);
449 struct bq27510_platform_data bq27510_info =
451 .init_dc_check_pin = bq27510_init_dc_check_pin,
452 .dc_check_pin = DC_CHECK_PIN,
453 .bat_num = LI_LION_BAT_NUM,
459 /*****************************************************************************************
460 * TI TPS65910 voltage regulator devices
461 ******************************************************************************************/
462 #if defined (CONFIG_TPS65910_CORE)
464 static struct regulator_consumer_supply rk29_vdd1_supplies[] = {
466 .supply = "vcore", // set name vcore for all platform
471 static struct regulator_init_data rk29_regulator_vdd1 = {
475 .valid_modes_mask = REGULATOR_MODE_NORMAL,
476 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
480 .num_consumer_supplies = ARRAY_SIZE(rk29_vdd1_supplies),
481 .consumer_supplies = rk29_vdd1_supplies,
485 static struct regulator_consumer_supply rk29_vdd2_supplies[] = {
492 static struct regulator_init_data rk29_regulator_vdd2 = {
496 .valid_modes_mask = REGULATOR_MODE_NORMAL,
497 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
501 .num_consumer_supplies = ARRAY_SIZE(rk29_vdd2_supplies),
502 .consumer_supplies = rk29_vdd2_supplies,
506 static struct regulator_consumer_supply rk29_vio_supplies[] = {
513 static struct regulator_init_data rk29_regulator_vio = {
517 .valid_modes_mask = REGULATOR_MODE_NORMAL,
518 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
522 .num_consumer_supplies = ARRAY_SIZE(rk29_vio_supplies),
523 .consumer_supplies = rk29_vio_supplies,
527 static struct regulator_consumer_supply rk29_vaux1_supplies[] = {
534 static struct regulator_init_data rk29_regulator_vaux1 = {
538 .valid_modes_mask = REGULATOR_MODE_NORMAL,
539 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
542 .num_consumer_supplies = ARRAY_SIZE(rk29_vaux1_supplies),
543 .consumer_supplies = rk29_vaux1_supplies,
547 static struct regulator_consumer_supply rk29_vaux2_supplies[] = {
554 static struct regulator_init_data rk29_regulator_vaux2 = {
558 .valid_modes_mask = REGULATOR_MODE_NORMAL,
559 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
562 .num_consumer_supplies = ARRAY_SIZE(rk29_vaux2_supplies),
563 .consumer_supplies = rk29_vaux2_supplies,
567 static struct regulator_consumer_supply rk29_vdac_supplies[] = {
574 static struct regulator_init_data rk29_regulator_vdac = {
578 .valid_modes_mask = REGULATOR_MODE_NORMAL,
579 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
582 .num_consumer_supplies = ARRAY_SIZE(rk29_vdac_supplies),
583 .consumer_supplies = rk29_vdac_supplies,
587 static struct regulator_consumer_supply rk29_vaux33_supplies[] = {
594 static struct regulator_init_data rk29_regulator_vaux33 = {
598 .valid_modes_mask = REGULATOR_MODE_NORMAL,
599 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
602 .num_consumer_supplies = ARRAY_SIZE(rk29_vaux33_supplies),
603 .consumer_supplies = rk29_vaux33_supplies,
607 static struct regulator_consumer_supply rk29_vmmc_supplies[] = {
614 static struct regulator_init_data rk29_regulator_vmmc = {
618 .valid_modes_mask = REGULATOR_MODE_NORMAL,
619 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
622 .num_consumer_supplies = ARRAY_SIZE(rk29_vmmc_supplies),
623 .consumer_supplies = rk29_vmmc_supplies,
627 static struct regulator_consumer_supply rk29_vpll_supplies[] = {
634 static struct regulator_init_data rk29_regulator_vpll = {
638 .valid_modes_mask = REGULATOR_MODE_NORMAL,
639 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
643 .num_consumer_supplies = ARRAY_SIZE(rk29_vpll_supplies),
644 .consumer_supplies = rk29_vpll_supplies,
648 static struct regulator_consumer_supply rk29_vdig1_supplies[] = {
655 static struct regulator_init_data rk29_regulator_vdig1 = {
659 .valid_modes_mask = REGULATOR_MODE_NORMAL,
660 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
663 .num_consumer_supplies = ARRAY_SIZE(rk29_vdig1_supplies),
664 .consumer_supplies = rk29_vdig1_supplies,
668 static struct regulator_consumer_supply rk29_vdig2_supplies[] = {
675 static struct regulator_init_data rk29_regulator_vdig2 = {
679 .valid_modes_mask = REGULATOR_MODE_NORMAL,
680 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
684 .num_consumer_supplies = ARRAY_SIZE(rk29_vdig2_supplies),
685 .consumer_supplies = rk29_vdig2_supplies,
688 static int rk29_tps65910_config(struct tps65910_platform_data *pdata)
695 /* Configure TPS65910 for rk29 board needs */
696 printk("rk29_tps65910_config: tps65910 init config.\n");
698 err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_DEVCTRL2);
700 printk(KERN_ERR "Unable to read TPS65910_REG_DEVCTRL2 reg\n");
703 /* Set sleep state active high and allow device turn-off after PWRON long press */
704 val |= (TPS65910_DEV2_SLEEPSIG_POL | TPS65910_DEV2_PWON_LP_OFF);
706 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val,
707 TPS65910_REG_DEVCTRL2);
709 printk(KERN_ERR "Unable to write TPS65910_REG_DEVCTRL2 reg\n");
713 /* Set the maxinum load current */
715 err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD1);
717 printk(KERN_ERR "Unable to read TPS65910_REG_VDD1 reg\n");
722 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VDD1);
724 printk(KERN_ERR "Unable to write TPS65910_REG_VDD1 reg\n");
729 err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD2);
731 printk(KERN_ERR "Unable to read TPS65910_REG_VDD2 reg\n");
736 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VDD2);
738 printk(KERN_ERR "Unable to write TPS65910_REG_VDD2 reg\n");
743 err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VIO);
745 printk(KERN_ERR "Unable to read TPS65910_REG_VIO reg\n");
750 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VIO);
752 printk(KERN_ERR "Unable to write TPS65910_REG_VIO reg\n");
756 /* Mask ALL interrupts */
757 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, 0xFF,
758 TPS65910_REG_INT_MSK);
760 printk(KERN_ERR "Unable to write TPS65910_REG_INT_MSK reg\n");
763 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, 0x03,
764 TPS65910_REG_INT_MSK2);
766 printk(KERN_ERR "Unable to write TPS65910_REG_INT_MSK2 reg\n");
770 /* Set RTC Power, disable Smart Reflex in DEVCTRL_REG */
772 val |= (TPS65910_SR_CTL_I2C_SEL);
773 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val,
774 TPS65910_REG_DEVCTRL);
776 printk(KERN_ERR "Unable to write TPS65910_REG_DEVCTRL reg\n");
781 printk(KERN_INFO "TPS65910 Set default voltage.\n");
782 /* VDD1 Set the default voltage: 1150 mV(47)*/
784 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VDD1_OP);
786 printk(KERN_ERR "Unable to read TPS65910 Reg at offset 0x%x= \
787 \n", TPS65910_REG_VDD1_OP);
791 /* VDD2 Set the default voltage: 1087 * 1.25mV(41)*/
793 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val, TPS65910_REG_VDD2_OP);
795 printk(KERN_ERR "Unable to read TPS65910 Reg at offset 0x%x= \
796 \n", TPS65910_REG_VDD2_OP);
801 /* initilize all ISR work as NULL, specific driver will
802 * assign function(s) later.
804 for (i = 0; i < TPS65910_MAX_IRQS; i++)
805 pdata->handlers[i] = NULL;
810 struct tps65910_platform_data rk29_tps65910_data = {
811 .irq_num = (unsigned)TPS65910_HOST_IRQ,
813 .vio = &rk29_regulator_vio,
814 .vdd1 = &rk29_regulator_vdd1,
815 .vdd2 = &rk29_regulator_vdd2,
817 .vdig1 = &rk29_regulator_vdig1,
818 .vdig2 = &rk29_regulator_vdig2,
819 .vaux33 = &rk29_regulator_vaux33,
820 .vmmc = &rk29_regulator_vmmc,
821 .vaux1 = &rk29_regulator_vaux1,
822 .vaux2 = &rk29_regulator_vaux2,
823 .vdac = &rk29_regulator_vdac,
824 .vpll = &rk29_regulator_vpll,
825 .board_tps65910_config = rk29_tps65910_config,
827 #endif /* CONFIG_TPS65910_CORE */
830 /*****************************************************************************************
832 * author: kfx@rock-chips.com
833 *****************************************************************************************/
834 static int rk29_i2c0_io_init(void)
836 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
837 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
841 static int rk29_i2c1_io_init(void)
843 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
844 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
847 static int rk29_i2c2_io_init(void)
849 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
850 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
854 static int rk29_i2c3_io_init(void)
856 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
857 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
861 struct rk29_i2c_platform_data default_i2c0_data = {
865 .scl_rate = 400*1000,
866 .mode = I2C_MODE_IRQ,
867 .io_init = rk29_i2c0_io_init,
870 struct rk29_i2c_platform_data default_i2c1_data = {
874 .scl_rate = 400*1000,
875 .mode = I2C_MODE_POLL,
876 .io_init = rk29_i2c1_io_init,
879 struct rk29_i2c_platform_data default_i2c2_data = {
883 .scl_rate = 400*1000,
884 .mode = I2C_MODE_IRQ,
885 .io_init = rk29_i2c2_io_init,
888 struct rk29_i2c_platform_data default_i2c3_data = {
892 .scl_rate = 400*1000,
893 .mode = I2C_MODE_POLL,
894 .io_init = rk29_i2c3_io_init,
897 #ifdef CONFIG_I2C0_RK29
898 static struct i2c_board_info __initdata board_i2c0_devices[] = {
899 #if defined (CONFIG_RK1000_CONTROL)
901 .type = "rk1000_control",
906 #if defined (CONFIG_SND_SOC_RK1000)
908 .type = "rk1000_i2c_codec",
913 #if defined (CONFIG_SND_SOC_WM8900)
920 #if defined (CONFIG_BATTERY_STC3100)
927 #if defined (CONFIG_BATTERY_BQ27510)
932 .platform_data = &bq27510_info,
935 #if defined (CONFIG_RTC_HYM8563)
937 .type = "rtc_hym8563",
940 .irq = RK29_PIN0_PA1,
943 #if defined (CONFIG_GS_MMA8452)
945 .type = "gs_mma8452",
948 .irq = MMA8452_INT_PIN,
949 .platform_data = &mma8452_info,
952 #if defined (CONFIG_SENSORS_AK8973)
957 .irq = RK29_PIN0_PA4,
960 #if defined (CONFIG_SENSORS_AK8975)
965 .irq = RK29_PIN0_PA4,
974 .irq = RK29_PIN5_PA3,
975 .platform_data = &mpu3050_data,
981 #ifdef CONFIG_I2C1_RK29
982 static struct i2c_board_info __initdata board_i2c1_devices[] = {
983 #if defined (CONFIG_RK1000_CONTROL1)
985 .type = "rk1000_control",
990 #if defined (CONFIG_ANX7150)
993 .addr = 0x39, //0x39, 0x3d
995 .irq = RK29_PIN1_PD7,
998 #if defined (CONFIG_ATMEL_MXT224)
1000 .type = "mXT224_touch",
1003 .irq = RK29_PIN0_PA2,
1004 //.platform_data = &p1003_info,
1010 #ifdef CONFIG_I2C2_RK29
1011 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1012 #if defined (CONFIG_HANNSTAR_P1003)
1014 .type = "p1003_touch",
1017 .irq = RK29_PIN0_PA2,
1018 .platform_data = &p1003_info,
1021 #if defined (CONFIG_EETI_EGALAX)
1023 .type = "egalax_i2c",
1026 .irq = RK29_PIN0_PA2,
1027 .platform_data = &eeti_egalax_info,
1030 #if defined (CONFIG_TPS65910_CORE)
1032 .type = "tps659102",
1033 .addr = TPS65910_I2C_ID0,
1035 .irq = TPS65910_HOST_IRQ,
1036 .platform_data = &rk29_tps65910_data,
1042 #ifdef CONFIG_I2C3_RK29
1043 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1047 /*****************************************************************************************
1049 * author: ddl@rock-chips.com
1050 *****************************************************************************************/
1051 #ifdef CONFIG_VIDEO_RK29
1052 #define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_MT9P111 /* back camera sensor */
1053 #define SENSOR_IIC_ADDR_0 0x00
1054 #define SENSOR_IIC_ADAPTER_ID_0 1
1055 #define SENSOR_POWER_PIN_0 RK29_PIN5_PD7
1056 #define SENSOR_RESET_PIN_0 INVALID_GPIO
1057 #define SENSOR_POWERDN_PIN_0 RK29_PIN1_PB2
1058 #define SENSOR_FALSH_PIN_0 INVALID_GPIO
1059 #define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
1060 #define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
1061 #define SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
1062 #define SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
1064 #define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_S5K6AA /* front camera sensor */
1065 #define SENSOR_IIC_ADDR_1 0x78
1066 #define SENSOR_IIC_ADAPTER_ID_1 1
1067 #define SENSOR_POWER_PIN_1 INVALID_GPIO
1068 #define SENSOR_RESET_PIN_1 RK29_PIN1_PB3
1069 #define SENSOR_POWERDN_PIN_1 RK29_PIN6_PB7
1070 #define SENSOR_FALSH_PIN_1 INVALID_GPIO
1071 #define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
1072 #define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
1073 #define SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_L
1074 #define SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
1076 static int rk29_sensor_io_init(void);
1077 static int rk29_sensor_io_deinit(int sensor);
1078 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
1080 static struct rk29camera_platform_data rk29_camera_platform_data = {
1081 .io_init = rk29_sensor_io_init,
1082 .io_deinit = rk29_sensor_io_deinit,
1083 .sensor_ioctrl = rk29_sensor_ioctrl,
1086 .gpio_reset = SENSOR_RESET_PIN_0,
1087 .gpio_power = SENSOR_POWER_PIN_0,
1088 .gpio_powerdown = SENSOR_POWERDN_PIN_0,
1089 .gpio_flash = SENSOR_FALSH_PIN_0,
1090 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0|SENSOR_POWERDNACTIVE_LEVEL_0|SENSOR_FLASHACTIVE_LEVEL_0),
1092 .dev_name = SENSOR_NAME_0,
1094 .gpio_reset = SENSOR_RESET_PIN_1,
1095 .gpio_power = SENSOR_POWER_PIN_1,
1096 .gpio_powerdown = SENSOR_POWERDN_PIN_1,
1097 .gpio_flash = SENSOR_FALSH_PIN_1,
1098 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1|SENSOR_POWERDNACTIVE_LEVEL_1|SENSOR_FLASHACTIVE_LEVEL_1),
1100 .dev_name = SENSOR_NAME_1,
1103 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
1105 .name = "camera_ipp_mem",
1106 .start = MEM_CAMIPP_BASE,
1107 .size = MEM_CAMIPP_SIZE,
1112 static int rk29_sensor_io_init(void)
1115 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1116 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1117 unsigned int camera_ioflag;
1119 for (i=0; i<2; i++) {
1120 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
1121 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
1122 camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
1123 camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
1124 camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
1125 rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
1127 if (camera_power != INVALID_GPIO) {
1128 ret = gpio_request(camera_power, "camera power");
1130 goto sensor_io_int_loop_end;
1131 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
1132 gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1133 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1135 //printk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1139 if (camera_reset != INVALID_GPIO) {
1140 ret = gpio_request(camera_reset, "camera reset");
1142 goto sensor_io_int_loop_end;
1143 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
1144 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1145 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1147 //printk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1151 if (camera_powerdown != INVALID_GPIO) {
1152 ret = gpio_request(camera_powerdown, "camera powerdown");
1154 goto sensor_io_int_loop_end;
1155 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
1156 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1157 gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1159 //printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1163 if (camera_flash != INVALID_GPIO) {
1164 ret = gpio_request(camera_flash, "camera flash");
1166 goto sensor_io_int_loop_end;
1167 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
1168 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1169 gpio_direction_output(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1171 //printk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1175 sensor_io_int_loop_end:
1176 rk29_sensor_io_deinit(i);
1183 static int rk29_sensor_io_deinit(int sensor)
1185 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1186 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1188 camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
1189 camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
1190 camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
1191 camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
1193 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
1194 if (camera_power != INVALID_GPIO) {
1195 gpio_direction_input(camera_power);
1196 gpio_free(camera_power);
1200 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
1201 if (camera_reset != INVALID_GPIO) {
1202 gpio_direction_input(camera_reset);
1203 gpio_free(camera_reset);
1207 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
1208 if (camera_powerdown != INVALID_GPIO) {
1209 gpio_direction_input(camera_powerdown);
1210 gpio_free(camera_powerdown);
1214 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
1215 if (camera_flash != INVALID_GPIO) {
1216 gpio_direction_input(camera_flash);
1217 gpio_free(camera_flash);
1221 rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
1224 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
1226 unsigned int camera_power=INVALID_GPIO,camera_reset=INVALID_GPIO, camera_powerdown=INVALID_GPIO,camera_flash = INVALID_GPIO;
1227 unsigned int camera_ioflag,camera_io_init;
1228 int ret = RK29_CAM_IO_SUCCESS;
1230 if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
1231 camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
1232 camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
1233 camera_powerdown = rk29_camera_platform_data.gpio_res[0].gpio_powerdown;
1234 camera_flash = rk29_camera_platform_data.gpio_res[0].gpio_flash;
1235 camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
1236 camera_io_init = rk29_camera_platform_data.gpio_res[0].gpio_init;
1237 } 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)) {
1238 camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
1239 camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
1240 camera_powerdown = rk29_camera_platform_data.gpio_res[1].gpio_powerdown;
1241 camera_flash = rk29_camera_platform_data.gpio_res[1].gpio_flash;
1242 camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
1243 camera_io_init = rk29_camera_platform_data.gpio_res[1].gpio_init;
1250 if (camera_power != INVALID_GPIO) {
1251 if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
1253 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1254 //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));
1257 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1258 //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));
1261 ret = RK29_CAM_EIO_REQUESTFAIL;
1262 printk("\n%s..%s..PowerPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1265 ret = RK29_CAM_EIO_INVALID;
1271 if (camera_reset != INVALID_GPIO) {
1272 if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
1274 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1275 //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));
1277 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1278 //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));
1281 ret = RK29_CAM_EIO_REQUESTFAIL;
1282 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1285 ret = RK29_CAM_EIO_INVALID;
1292 if (camera_powerdown != INVALID_GPIO) {
1293 if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
1295 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1296 //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));
1298 gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1299 //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));
1302 ret = RK29_CAM_EIO_REQUESTFAIL;
1303 printk("\n%s..%s..PowerDownPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_powerdown);
1306 ret = RK29_CAM_EIO_INVALID;
1313 if (camera_flash != INVALID_GPIO) {
1314 if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
1316 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1317 //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));
1319 gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1320 //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));
1323 ret = RK29_CAM_EIO_REQUESTFAIL;
1324 printk("\n%s..%s..FlashPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_flash);
1327 ret = RK29_CAM_EIO_INVALID;
1334 printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
1340 static int rk29_sensor_power(struct device *dev, int on)
1342 rk29_sensor_ioctrl(dev,Cam_Power,on);
1345 static int rk29_sensor_reset(struct device *dev)
1347 rk29_sensor_ioctrl(dev,Cam_Reset,1);
1349 rk29_sensor_ioctrl(dev,Cam_Reset,0);
1352 static int rk29_sensor_powerdown(struct device *dev, int on)
1354 return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
1356 #if (SENSOR_IIC_ADDR_0 != 0x00)
1357 static struct i2c_board_info rk29_i2c_cam_info_0[] = {
1359 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
1363 static struct soc_camera_link rk29_iclink_0 = {
1364 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1365 .power = rk29_sensor_power,
1366 .powerdown = rk29_sensor_powerdown,
1367 .board_info = &rk29_i2c_cam_info_0[0],
1368 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
1369 .module_name = SENSOR_NAME_0,
1372 /*platform_device : soc-camera need */
1373 static struct platform_device rk29_soc_camera_pdrv_0 = {
1374 .name = "soc-camera-pdrv",
1377 .init_name = SENSOR_NAME_0,
1378 .platform_data = &rk29_iclink_0,
1382 #if (SENSOR_IIC_ADDR_1 != 0x00)
1383 static struct i2c_board_info rk29_i2c_cam_info_1[] = {
1385 I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
1389 static struct soc_camera_link rk29_iclink_1 = {
1390 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1391 .power = rk29_sensor_power,
1392 .powerdown = rk29_sensor_powerdown,
1393 .board_info = &rk29_i2c_cam_info_1[0],
1394 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
1395 .module_name = SENSOR_NAME_1,
1398 /*platform_device : soc-camera need */
1399 static struct platform_device rk29_soc_camera_pdrv_1 = {
1400 .name = "soc-camera-pdrv",
1403 .init_name = SENSOR_NAME_1,
1404 .platform_data = &rk29_iclink_1,
1409 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
1410 static struct resource rk29_camera_resource[] = {
1412 .start = RK29_VIP_PHYS,
1413 .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
1414 .flags = IORESOURCE_MEM,
1419 .flags = IORESOURCE_IRQ,
1423 /*platform_device : */
1424 static struct platform_device rk29_device_camera = {
1425 .name = RK29_CAM_DRV_NAME,
1426 .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
1427 .num_resources = ARRAY_SIZE(rk29_camera_resource),
1428 .resource = rk29_camera_resource,
1430 .dma_mask = &rockchip_device_camera_dmamask,
1431 .coherent_dma_mask = 0xffffffffUL,
1432 .platform_data = &rk29_camera_platform_data,
1436 /*****************************************************************************************
1438 * author: nzy@rock-chips.com
1439 *****************************************************************************************/
1440 #ifdef CONFIG_BACKLIGHT_RK29_BL
1442 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
1443 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
1444 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
1445 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
1449 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
1450 #define PWM_MUX_MODE GPIO1L_PWM0
1451 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1452 #define PWM_EFFECT_VALUE 1
1454 //#define LCD_DISP_ON_PIN
1456 #ifdef LCD_DISP_ON_PIN
1457 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
1458 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
1460 #define BL_EN_PIN GPIO0L_GPIO0A5
1461 #define BL_EN_VALUE GPIO_HIGH
1463 static int rk29_backlight_io_init(void)
1467 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1468 #ifdef LCD_DISP_ON_PIN
1469 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
1471 ret = gpio_request(BL_EN_PIN, NULL);
1474 gpio_free(BL_EN_PIN);
1477 gpio_direction_output(BL_EN_PIN, 0);
1478 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1483 static int rk29_backlight_io_deinit(void)
1486 #ifdef LCD_DISP_ON_PIN
1487 gpio_free(BL_EN_PIN);
1489 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1492 struct rk29_bl_info rk29_bl_info = {
1494 .bl_ref = PWM_EFFECT_VALUE,
1495 .io_init = rk29_backlight_io_init,
1496 .io_deinit = rk29_backlight_io_deinit,
1499 /*****************************************************************************************
1500 * pwm voltage regulator devices
1501 ******************************************************************************************/
1502 #if defined (CONFIG_RK29_PWM_REGULATOR)
1504 #define REGULATOR_PWM_ID 2
1505 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1506 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1507 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1508 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1510 static struct regulator_consumer_supply pwm_consumers[] = {
1516 static struct regulator_init_data rk29_pwm_regulator_data = {
1522 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1524 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1525 .consumer_supplies = pwm_consumers,
1528 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1529 .pwm_id = REGULATOR_PWM_ID,
1530 .pwm_gpio = REGULATOR_PWM_GPIO,
1531 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1532 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1533 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1534 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1535 .init_data = &rk29_pwm_regulator_data,
1538 static struct platform_device rk29_device_pwm_regulator = {
1539 .name = "pwm-voltage-regulator",
1542 .platform_data = &rk29_regulator_pwm_platform_data,
1549 /*****************************************************************************************
1551 *****************************************************************************************/
1552 #ifdef CONFIG_SDMMC0_RK29
1553 static int rk29_sdmmc0_cfg_gpio(void)
1555 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1556 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1557 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1558 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1559 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1560 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1561 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
1562 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1563 gpio_request(RK29_PIN5_PD5,"sdmmc");
1564 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1566 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1570 #define CONFIG_SDMMC0_USE_DMA
1571 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1572 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1573 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1574 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1575 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1576 .io_init = rk29_sdmmc0_cfg_gpio,
1577 .dma_name = "sd_mmc",
1578 #ifdef CONFIG_SDMMC0_USE_DMA
1585 #ifdef CONFIG_SDMMC1_RK29
1586 #define CONFIG_SDMMC1_USE_DMA
1587 static int rk29_sdmmc1_cfg_gpio(void)
1589 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1590 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1591 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1592 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1593 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1594 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1595 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1599 #ifdef CONFIG_WIFI_CONTROL_FUNC
1600 static int rk29sdk_wifi_status(struct device *dev);
1601 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1604 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1606 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1607 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1608 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1609 MMC_VDD_32_33|MMC_VDD_33_34),
1610 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1611 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1612 .io_init = rk29_sdmmc1_cfg_gpio,
1614 #ifdef CONFIG_SDMMC1_USE_DMA
1619 #ifdef CONFIG_WIFI_CONTROL_FUNC
1620 .status = rk29sdk_wifi_status,
1621 .register_status_notify = rk29sdk_wifi_status_register,
1624 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1629 #ifdef CONFIG_WIFI_CONTROL_FUNC
1630 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1631 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1632 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1634 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1635 static void (*wifi_status_cb)(int card_present, void *dev_id);
1636 static void *wifi_status_cb_devid;
1637 int rk29sdk_wifi_power_state = 0;
1638 int rk29sdk_bt_power_state = 0;
1640 static int rk29sdk_wifi_status(struct device *dev)
1642 return rk29sdk_wifi_cd;
1645 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1649 wifi_status_cb = callback;
1650 wifi_status_cb_devid = dev_id;
1654 static int rk29sdk_wifi_bt_gpio_control_init(void)
1656 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1657 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1661 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1662 pr_info("%s: request wifi reset gpio failed\n", __func__);
1663 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1667 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1668 pr_info("%s: request bt reset gpio failed\n", __func__);
1669 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1673 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1674 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1675 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1677 pr_info("%s: init finished\n",__func__);
1682 static int rk29sdk_wifi_power(int on)
1684 pr_info("%s: %d\n", __func__, on);
1686 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
1688 pr_info("wifi turn on power\n");
1690 if (!rk29sdk_bt_power_state){
1691 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
1693 pr_info("wifi shut off power\n");
1696 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1701 rk29sdk_wifi_power_state = on;
1705 static int rk29sdk_wifi_reset_state;
1706 static int rk29sdk_wifi_reset(int on)
1708 pr_info("%s: %d\n", __func__, on);
1709 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1711 rk29sdk_wifi_reset_state = on;
1715 int rk29sdk_wifi_set_carddetect(int val)
1717 pr_info("%s:%d\n", __func__, val);
1718 rk29sdk_wifi_cd = val;
1719 if (wifi_status_cb){
1720 wifi_status_cb(val, wifi_status_cb_devid);
1722 pr_warning("%s, nobody to notify\n", __func__);
1726 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
1728 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
1729 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
1730 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
1731 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
1732 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
1735 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
1737 if (section == PREALLOC_WLAN_SEC_NUM)
1738 return wlan_static_skb;
1740 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
1743 if (wifi_mem_array[section].size < size)
1746 return wifi_mem_array[section].mem_ptr;
1749 int __init rk29sdk_init_wifi_mem(void)
1754 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
1755 wlan_static_skb[i] = dev_alloc_skb(
1756 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
1758 if (!wlan_static_skb[i])
1762 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
1763 wifi_mem_array[i].mem_ptr =
1764 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
1766 if (!wifi_mem_array[i].mem_ptr)
1772 pr_err("Failed to mem_alloc for WLAN\n");
1773 for (j = 0 ; j < i ; j++)
1774 kfree(wifi_mem_array[j].mem_ptr);
1776 i = WLAN_SKB_BUF_NUM;
1779 pr_err("Failed to skb_alloc for WLAN\n");
1780 for (j = 0 ; j < i ; j++)
1781 dev_kfree_skb(wlan_static_skb[j]);
1786 static struct wifi_platform_data rk29sdk_wifi_control = {
1787 .set_power = rk29sdk_wifi_power,
1788 .set_reset = rk29sdk_wifi_reset,
1789 .set_carddetect = rk29sdk_wifi_set_carddetect,
1790 .mem_prealloc = rk29sdk_mem_prealloc,
1792 static struct platform_device rk29sdk_wifi_device = {
1793 .name = "bcm4329_wlan",
1796 .platform_data = &rk29sdk_wifi_control,
1802 /* bluetooth rfkill device */
1803 static struct platform_device rk29sdk_rfkill = {
1804 .name = "rk29sdk_rfkill",
1809 #ifdef CONFIG_VIVANTE
1810 static struct resource resources_gpu[] = {
1815 .flags = IORESOURCE_IRQ,
1819 .start = RK29_GPU_PHYS,
1820 .end = RK29_GPU_PHYS + RK29_GPU_PHYS_SIZE,
1821 .flags = IORESOURCE_MEM,
1825 .start = PMEM_GPU_BASE,
1826 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE,
1827 .flags = IORESOURCE_MEM,
1830 static struct platform_device rk29_device_gpu = {
1833 .num_resources = ARRAY_SIZE(resources_gpu),
1834 .resource = resources_gpu,
1837 #ifdef CONFIG_KEYS_RK29
1838 extern struct rk29_keys_platform_data rk29_keys_pdata;
1839 static struct platform_device rk29_device_keys = {
1840 .name = "rk29-keypad",
1843 .platform_data = &rk29_keys_pdata,
1848 static void __init rk29_board_iomux_init(void)
1850 #ifdef CONFIG_UART0_RK29
1851 rk29_mux_api_set(GPIO1B7_UART0SOUT_NAME, GPIO1L_UART0_SOUT);
1852 rk29_mux_api_set(GPIO1B6_UART0SIN_NAME, GPIO1L_UART0_SIN);
1853 #ifdef CONFIG_UART0_CTS_RTS_RK29
1854 rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N);
1855 rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_UART0_CTS_N);
1858 #ifdef CONFIG_UART1_RK29
1859 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
1860 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
1862 #ifdef CONFIG_UART2_RK29
1863 rk29_mux_api_set(GPIO2B1_UART2SOUT_NAME, GPIO2L_UART2_SOUT);
1864 rk29_mux_api_set(GPIO2B0_UART2SIN_NAME, GPIO2L_UART2_SIN);
1865 #ifdef CONFIG_UART2_CTS_RTS_RK29
1866 rk29_mux_api_set(GPIO2A7_UART2RTSN_NAME, GPIO2L_UART2_RTS_N);
1867 rk29_mux_api_set(GPIO2A6_UART2CTSN_NAME, GPIO2L_UART2_CTS_N);
1870 #ifdef CONFIG_UART3_RK29
1871 rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
1872 rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
1873 #ifdef CONFIG_UART3_CTS_RTS_RK29
1874 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_UART3_RTS_N);
1875 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_UART3_CTS_N);
1878 #ifdef CONFIG_SPIM0_RK29
1879 rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME, GPIO2H_SPI0_CLK);
1880 rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME, GPIO2H_SPI0_CSN0);
1881 rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME, GPIO2H_SPI0_TXD);
1882 rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME, GPIO2H_SPI0_RXD);
1884 #ifdef CONFIG_SPIM1_RK29
1885 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK);
1886 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME, GPIO2H_SPI1_CSN0);
1887 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME, GPIO2H_SPI1_TXD);
1888 rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME, GPIO2H_SPI1_RXD);
1890 #ifdef CONFIG_RK29_VMAC
1891 rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME, GPIO4H_RMII_CLKOUT);
1892 rk29_mux_api_set(GPIO4C1_RMIITXEN_MIITXEN_NAME, GPIO4H_RMII_TX_EN);
1893 rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME, GPIO4H_RMII_TXD1);
1894 rk29_mux_api_set(GPIO4C3_RMIITXD0_MIITXD0_NAME, GPIO4H_RMII_TXD0);
1895 rk29_mux_api_set(GPIO4C4_RMIIRXERR_MIIRXERR_NAME, GPIO4H_RMII_RX_ERR);
1896 rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME, GPIO4H_RMII_CSR_DVALID);
1897 rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME, GPIO4H_RMII_RXD1);
1898 rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME, GPIO4H_RMII_RXD0);
1900 rk29_mux_api_set(GPIO0A7_MIIMDCLK_NAME, GPIO0L_MII_MDCLK);
1901 rk29_mux_api_set(GPIO0A6_MIIMD_NAME, GPIO0L_MII_MD);
1903 #ifdef CONFIG_RK29_PWM_REGULATOR
1904 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1906 #if defined (CONFIG_TPS65910_CORE)
1907 rk29_mux_api_set(GPIO4D32_CPUTRACEDATA32_NAME, GPIO4H_GPIO4D32);
1911 static struct platform_device *devices[] __initdata = {
1912 #ifdef CONFIG_UART1_RK29
1915 #ifdef CONFIG_UART0_RK29
1918 #ifdef CONFIG_UART2_RK29
1922 #ifdef CONFIG_RK29_PWM_REGULATOR
1923 &rk29_device_pwm_regulator,
1925 #ifdef CONFIG_SPIM0_RK29
1926 &rk29xx_device_spi0m,
1928 #ifdef CONFIG_SPIM1_RK29
1929 &rk29xx_device_spi1m,
1931 #ifdef CONFIG_ADC_RK29
1934 #ifdef CONFIG_I2C0_RK29
1937 #ifdef CONFIG_I2C1_RK29
1940 #ifdef CONFIG_I2C2_RK29
1943 #ifdef CONFIG_I2C3_RK29
1947 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1948 &rk29_device_iis_2ch,
1950 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1951 &rk29_device_iis_8ch,
1954 #ifdef CONFIG_KEYS_RK29
1957 #ifdef CONFIG_SDMMC0_RK29
1958 &rk29_device_sdmmc0,
1960 #ifdef CONFIG_SDMMC1_RK29
1961 &rk29_device_sdmmc1,
1964 #ifdef CONFIG_MTD_NAND_RK29XX
1965 &rk29xx_device_nand,
1968 #ifdef CONFIG_WIFI_CONTROL_FUNC
1969 &rk29sdk_wifi_device,
1976 #ifdef CONFIG_MTD_NAND_RK29
1980 #ifdef CONFIG_FB_RK29
1982 &rk29_device_dma_cpy,
1984 #ifdef CONFIG_BACKLIGHT_RK29_BL
1985 &rk29_device_backlight,
1987 #ifdef CONFIG_RK29_VMAC
1990 #ifdef CONFIG_VIVANTE
1993 #ifdef CONFIG_VIDEO_RK29
1994 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1995 #if (SENSOR_IIC_ADDR_0 != 0x00)
1996 &rk29_soc_camera_pdrv_0,
1998 #if (SENSOR_IIC_ADDR_1 != 0x00)
1999 &rk29_soc_camera_pdrv_1,
2001 &android_pmem_cam_device,
2003 &android_pmem_device,
2004 &rk29_vpu_mem_device,
2005 #ifdef CONFIG_USB20_OTG
2006 &rk29_device_usb20_otg,
2008 #ifdef CONFIG_USB20_HOST
2009 &rk29_device_usb20_host,
2011 #ifdef CONFIG_USB11_HOST
2012 &rk29_device_usb11_host,
2014 #ifdef CONFIG_USB_ANDROID
2015 &android_usb_device,
2016 &usb_mass_storage_device,
2018 #ifdef CONFIG_RK29_IPP
2021 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2022 &rk29_v4l2_output_devce,
2026 /*****************************************************************************************
2028 * author: cmc@rock-chips.com
2029 *****************************************************************************************/
2030 static int rk29_vmac_register_set(void)
2032 //config rk29 vmac as rmii, 100MHz
2033 u32 value= readl(RK29_GRF_BASE + 0xbc);
2034 value = (value & 0xfff7ff) | (0x400);
2035 writel(value, RK29_GRF_BASE + 0xbc);
2039 static int rk29_rmii_io_init(void)
2044 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2046 gpio_free(RK29_PIN6_PB0);
2047 printk("-------request RK29_PIN6_PB0 fail--------\n");
2051 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2052 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2057 static int rk29_rmii_io_deinit(void)
2060 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2061 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2063 gpio_free(RK29_PIN6_PB0);
2067 static int rk29_rmii_power_control(int enable)
2071 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2072 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2075 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2076 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2081 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2082 .vmac_register_set = rk29_vmac_register_set,
2083 .rmii_io_init = rk29_rmii_io_init,
2084 .rmii_io_deinit = rk29_rmii_io_deinit,
2085 .rmii_power_control = rk29_rmii_power_control,
2088 /*****************************************************************************************
2090 * author: cmc@rock-chips.com
2091 *****************************************************************************************/
2092 #define SPI_CHIPSELECT_NUM 2
2093 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2096 .cs_gpio = RK29_PIN2_PC1,
2097 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2098 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2102 .cs_gpio = RK29_PIN1_PA4,
2103 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2104 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2108 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2111 .cs_gpio = RK29_PIN2_PC5,
2112 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2113 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2117 .cs_gpio = RK29_PIN1_PA3,
2118 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2119 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2123 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2128 for (i=0; i<cs_num; i++) {
2129 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2137 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2143 static int spi_io_fix_leakage_bug(void)
2146 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2151 static int spi_io_resume_leakage_bug(void)
2154 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2159 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2160 .num_chipselect = SPI_CHIPSELECT_NUM,
2161 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2162 .io_init = spi_io_init,
2163 .io_deinit = spi_io_deinit,
2164 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2165 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2168 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2169 .num_chipselect = SPI_CHIPSELECT_NUM,
2170 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2171 .io_init = spi_io_init,
2172 .io_deinit = spi_io_deinit,
2173 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2174 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2177 /*****************************************************************************************
2178 * xpt2046 touch panel
2179 * author: cmc@rock-chips.com
2180 *****************************************************************************************/
2181 #define XPT2046_GPIO_INT RK29_PIN0_PA3
2182 #define DEBOUNCE_REPTIME 3
2184 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
2185 static struct xpt2046_platform_data xpt2046_info = {
2194 .debounce_rep = DEBOUNCE_REPTIME,
2196 .gpio_pendown = XPT2046_GPIO_INT,
2197 .penirq_recheck_delay_usecs = 1,
2199 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
2200 static struct xpt2046_platform_data xpt2046_info = {
2209 .debounce_rep = DEBOUNCE_REPTIME,
2211 .gpio_pendown = XPT2046_GPIO_INT,
2212 .penirq_recheck_delay_usecs = 1,
2214 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2215 static struct xpt2046_platform_data xpt2046_info = {
2224 .debounce_rep = DEBOUNCE_REPTIME,
2226 .gpio_pendown = XPT2046_GPIO_INT,
2228 .penirq_recheck_delay_usecs = 1,
2230 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2231 static struct xpt2046_platform_data xpt2046_info = {
2240 .debounce_rep = DEBOUNCE_REPTIME,
2242 .gpio_pendown = XPT2046_GPIO_INT,
2244 .penirq_recheck_delay_usecs = 1,
2248 static struct spi_board_info board_spi_devices[] = {
2249 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
2250 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2252 .modalias = "xpt2046_ts",
2254 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2256 .irq = XPT2046_GPIO_INT,
2257 .platform_data = &xpt2046_info,
2263 static void __init rk29_gic_init_irq(void)
2265 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2266 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2269 static void __init machine_rk29_init_irq(void)
2271 rk29_gic_init_irq();
2275 #define POWER_ON_PIN RK29_PIN4_PA4
2276 static void rk29_pm_power_off(void)
2278 printk(KERN_ERR "rk29_pm_power_off start...\n");
2279 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2283 static void __init machine_rk29_board_init(void)
2285 rk29_board_iomux_init();
2287 gpio_request(POWER_ON_PIN,"poweronpin");
2288 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
2289 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2290 pm_power_off = rk29_pm_power_off;
2294 platform_add_devices(devices, ARRAY_SIZE(devices));
2295 #ifdef CONFIG_I2C0_RK29
2296 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2297 ARRAY_SIZE(board_i2c0_devices));
2299 #ifdef CONFIG_I2C1_RK29
2300 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2301 ARRAY_SIZE(board_i2c1_devices));
2303 #ifdef CONFIG_I2C2_RK29
2304 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2305 ARRAY_SIZE(board_i2c2_devices));
2307 #ifdef CONFIG_I2C3_RK29
2308 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2309 ARRAY_SIZE(board_i2c3_devices));
2312 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2314 #ifdef CONFIG_WIFI_CONTROL_FUNC
2315 rk29sdk_wifi_bt_gpio_control_init();
2316 rk29sdk_init_wifi_mem();
2320 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2321 char **cmdline, struct meminfo *mi)
2324 mi->bank[0].start = RK29_SDRAM_PHYS;
2325 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
2326 mi->bank[0].size = LINUX_SIZE;
2329 static void __init machine_rk29_mapio(void)
2331 rk29_map_common_io();
2332 rk29_setup_early_printk();
2338 MACHINE_START(RK29, "RK29board")
2339 /* UART for LL DEBUG */
2340 .phys_io = RK29_UART1_PHYS,
2341 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2342 .boot_params = RK29_SDRAM_PHYS + 0x88000,
2343 .fixup = machine_rk29_fixup,
2344 .map_io = machine_rk29_mapio,
2345 .init_irq = machine_rk29_init_irq,
2346 .init_machine = machine_rk29_board_init,
2347 .timer = &rk29_timer,