1 /* arch/arm/mach-rk29/board-rk29.c
3 * Copyright (C) 2010 ROCKCHIP, Inc.
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
21 #include <linux/delay.h>
22 #include <linux/i2c.h>
23 #include <linux/spi/spi.h>
24 #include <linux/mmc/host.h>
25 #include <linux/android_pmem.h>
26 #include <linux/usb/android_composite.h>
28 #include <mach/hardware.h>
29 #include <asm/setup.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/flash.h>
34 #include <asm/hardware/gic.h>
36 #include <mach/iomux.h>
37 #include <mach/gpio.h>
38 #include <mach/irqs.h>
39 #include <mach/rk29_iomap.h>
40 #include <mach/board.h>
41 #include <mach/rk29_nand.h>
42 #include <mach/rk29_camera.h> /* ddl@rock-chips.com : camera support */
43 #include <media/soc_camera.h> /* ddl@rock-chips.com : camera support */
44 #include <mach/vpu_mem.h>
46 #include <linux/regulator/rk29-pwm-regulator.h>
47 #include <linux/regulator/machine.h>
49 #include <linux/mtd/nand.h>
50 #include <linux/mtd/partitions.h>
53 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
56 /* Set memory size of pmem */
57 #ifdef CONFIG_RK29_MEM_SIZE_M
58 #define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
60 #define SDRAM_SIZE SZ_512M
62 #define PMEM_GPU_SIZE SZ_64M
63 #define PMEM_UI_SIZE SZ_32M
64 #define PMEM_VPU_SIZE SZ_32M
65 #define PMEM_CAM_SIZE 0x00c00000
66 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
67 #define MEM_CAMIPP_SIZE SZ_4M
69 #define MEM_CAMIPP_SIZE 0
71 #define MEM_FB_SIZE (3*SZ_2M)
73 #define PMEM_GPU_BASE ((u32)RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
74 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
75 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
76 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
77 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
78 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
79 #define LINUX_SIZE (MEM_FB_BASE - RK29_SDRAM_PHYS)
81 extern struct sys_timer rk29_timer;
83 int rk29_nand_io_init(void)
88 struct rk29_nand_platform_data rk29_nand_data = {
89 .width = 1, /* data bus width in bytes */
90 .hw_ecc = 1, /* hw ecc 0: soft ecc */
92 .io_init = rk29_nand_io_init,
95 static struct rk29_gpio_bank rk29_gpiobankinit[] = {
98 .offset = RK29_GPIO0_BASE,
102 .offset = RK29_GPIO1_BASE,
106 .offset = RK29_GPIO2_BASE,
110 .offset = RK29_GPIO3_BASE,
114 .offset = RK29_GPIO4_BASE,
118 .offset = RK29_GPIO5_BASE,
122 .offset = RK29_GPIO6_BASE,
126 #ifdef CONFIG_FB_RK29
127 /*****************************************************************************************
129 * author: zyw@rock-chips.com
130 *****************************************************************************************/
131 //#ifdef CONFIG_LCD_TD043MGEA1
132 #define LCD_TXD_PIN INVALID_GPIO
133 #define LCD_CLK_PIN INVALID_GPIO
134 #define LCD_CS_PIN INVALID_GPIO
135 /*****************************************************************************************
136 * frame buffe devices
137 * author: zyw@rock-chips.com
138 *****************************************************************************************/
140 #define FB_DISPLAY_ON_PIN RK29_PIN6_PD0
141 #define FB_LCD_STANDBY_PIN RK29_PIN6_PD1
142 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
143 #define FB_MCU_FMK_PIN INVALID_GPIO
145 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
146 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
149 static int rk29_lcd_io_init(void)
155 static int rk29_lcd_io_deinit(void)
161 struct rk29lcd_info rk29_lcd_info = {
162 .txd_pin = LCD_TXD_PIN,
163 .clk_pin = LCD_CLK_PIN,
164 .cs_pin = LCD_CS_PIN,
165 .io_init = rk29_lcd_io_init,
166 .io_deinit = rk29_lcd_io_deinit,
170 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
173 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
175 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
178 gpio_free(FB_MCU_FMK_PIN);
179 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
181 gpio_direction_input(FB_MCU_FMK_PIN);
183 if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
185 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
188 gpio_free(FB_DISPLAY_ON_PIN);
189 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
193 if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
195 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
198 gpio_free(FB_LCD_STANDBY_PIN);
199 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
203 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
205 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
208 gpio_free(FB_LCD_CABC_EN_PIN);
209 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
211 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
212 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
218 struct rk29fb_info rk29_fb_info = {
220 .disp_on_pin = FB_DISPLAY_ON_PIN,
221 .disp_on_value = FB_DISPLAY_ON_VALUE,
222 .standby_pin = FB_LCD_STANDBY_PIN,
223 .standby_value = FB_LCD_STANDBY_VALUE,
224 .mcu_fmk_pin = FB_MCU_FMK_PIN,
225 .lcd_info = &rk29_lcd_info,
226 .io_init = rk29_fb_io_init,
229 /* rk29 fb resource */
230 struct resource rk29_fb_resource[] = {
233 .start = RK29_LCDC_PHYS,
234 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
235 .flags = IORESOURCE_MEM,
241 .flags = IORESOURCE_IRQ,
245 .start = MEM_FB_BASE,
246 .end = MEM_FB_BASE + MEM_FB_SIZE,
247 .flags = IORESOURCE_MEM,
252 struct platform_device rk29_device_fb = {
255 .num_resources = ARRAY_SIZE(rk29_fb_resource),
256 .resource = rk29_fb_resource,
258 .platform_data = &rk29_fb_info,
263 static struct android_pmem_platform_data android_pmem_pdata = {
265 .start = PMEM_UI_BASE,
266 .size = PMEM_UI_SIZE,
271 static struct platform_device android_pmem_device = {
272 .name = "android_pmem",
275 .platform_data = &android_pmem_pdata,
280 static struct android_pmem_platform_data android_pmem_cam_pdata = {
282 .start = PMEM_CAM_BASE,
283 .size = PMEM_CAM_SIZE,
288 static struct platform_device android_pmem_cam_device = {
289 .name = "android_pmem",
292 .platform_data = &android_pmem_cam_pdata,
297 static struct vpu_mem_platform_data vpu_mem_pdata = {
299 .start = PMEM_VPU_BASE,
300 .size = PMEM_VPU_SIZE,
304 static struct platform_device rk29_vpu_mem_device = {
308 .platform_data = &vpu_mem_pdata,
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,
350 #if defined (CONFIG_GS_MMA8452)
351 #define MMA8452_INT_PIN RK29_PIN0_PA3
353 int mma8452_init_platform_hw(void)
356 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
357 gpio_free(MMA8452_INT_PIN);
358 printk("mma8452_init_platform_hw gpio_request error\n");
361 gpio_pull_updown(MMA8452_INT_PIN, 1);
366 struct mma8452_platform_data mma8452_info = {
369 .init_platform_hw= mma8452_init_platform_hw,
376 /*****************************************************************************************
378 * author: kfx@rock-chips.com
379 *****************************************************************************************/
380 static int rk29_i2c0_io_init(void)
382 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
383 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
387 static int rk29_i2c1_io_init(void)
389 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
390 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
393 static int rk29_i2c2_io_init(void)
395 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
396 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
400 static int rk29_i2c3_io_init(void)
402 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
403 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
407 struct rk29_i2c_platform_data default_i2c0_data = {
411 .scl_rate = 400*1000,
412 .mode = I2C_MODE_IRQ,
413 .io_init = rk29_i2c0_io_init,
416 struct rk29_i2c_platform_data default_i2c1_data = {
420 .scl_rate = 400*1000,
421 .mode = I2C_MODE_POLL,
422 .io_init = rk29_i2c1_io_init,
425 struct rk29_i2c_platform_data default_i2c2_data = {
429 .scl_rate = 400*1000,
430 .mode = I2C_MODE_IRQ,
431 .io_init = rk29_i2c2_io_init,
434 struct rk29_i2c_platform_data default_i2c3_data = {
438 .scl_rate = 400*1000,
439 .mode = I2C_MODE_POLL,
440 .io_init = rk29_i2c3_io_init,
443 #ifdef CONFIG_I2C0_RK29
444 static struct i2c_board_info __initdata board_i2c0_devices[] = {
445 #if defined (CONFIG_RK1000_CONTROL)
447 .type = "rk1000_control",
452 #if defined (CONFIG_SND_SOC_RK1000)
454 .type = "rk1000_i2c_codec",
459 #if defined (CONFIG_SND_SOC_WM8900)
466 #if defined (CONFIG_BATTERY_STC3100)
473 #if defined (CONFIG_BATTERY_BQ27510)
480 #if defined (CONFIG_RTC_HYM8563)
482 .type = "rtc_hym8563",
485 ///.irq = RK2818_PIN_PA4,
488 #if defined (CONFIG_GS_MMA8452)
490 .type = "gs_mma8452",
493 .irq = MMA8452_INT_PIN,
494 .platform_data = &mma8452_info,
497 #if defined (CONFIG_SENSORS_AK8973)
502 .irq = RK29_PIN0_PA4,
505 #if defined (CONFIG_SENSORS_AK8975)
510 .irq = RK29_PIN0_PA4,
516 #ifdef CONFIG_I2C1_RK29
517 static struct i2c_board_info __initdata board_i2c1_devices[] = {
518 #if defined (CONFIG_RK1000_CONTROL1)
520 .type = "rk1000_control",
525 #if defined (CONFIG_ANX7150)
528 .addr = 0x39, //0x39, 0x3d
530 .irq = RK29_PIN1_PD7,
537 #ifdef CONFIG_I2C2_RK29
538 static struct i2c_board_info __initdata board_i2c2_devices[] = {
539 #if defined (CONFIG_HANNSTAR_P1003)
541 .type = "p1003_touch",
544 .irq = RK29_PIN0_PA2,
545 .platform_data = &p1003_info,
551 #ifdef CONFIG_I2C3_RK29
552 static struct i2c_board_info __initdata board_i2c3_devices[] = {
556 /*****************************************************************************************
558 * author: ddl@rock-chips.com
559 *****************************************************************************************/
560 #ifdef CONFIG_VIDEO_RK29
561 #define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_OV5642 /* back camera sensor */
562 #define SENSOR_IIC_ADDR_0 0x78
563 #define SENSOR_IIC_ADAPTER_ID_0 1
564 #define SENSOR_POWER_PIN_0 RK29_PIN6_PB7
565 #define SENSOR_RESET_PIN_0 INVALID_GPIO
566 #define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
567 #define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
570 #define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_OV2659 /* front camera sensor */
571 #define SENSOR_IIC_ADDR_1 0x60
572 #define SENSOR_IIC_ADAPTER_ID_1 1
573 #define SENSOR_POWER_PIN_1 RK29_PIN5_PD7
574 #define SENSOR_RESET_PIN_1 INVALID_GPIO
575 #define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
576 #define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
578 static int rk29_sensor_io_init(void);
579 static int rk29_sensor_io_deinit(void);
581 struct rk29camera_platform_data rk29_camera_platform_data = {
582 .io_init = rk29_sensor_io_init,
583 .io_deinit = rk29_sensor_io_deinit,
586 .gpio_reset = SENSOR_RESET_PIN_0,
587 .gpio_power = SENSOR_POWER_PIN_0,
588 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0),
589 .dev_name = SENSOR_NAME_0,
591 .gpio_reset = SENSOR_RESET_PIN_1,
592 .gpio_power = SENSOR_POWER_PIN_1,
593 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1),
594 .dev_name = SENSOR_NAME_1,
597 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
599 .name = "camera_ipp_mem",
600 .start = MEM_CAMIPP_BASE,
601 .size = MEM_CAMIPP_SIZE,
606 static int rk29_sensor_io_init(void)
609 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
610 unsigned int camera_ioflag;
612 for (i=0; i<2; i++) {
613 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
614 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
615 camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
617 if (camera_power != INVALID_GPIO) {
618 ret = gpio_request(camera_power, "camera power");
622 gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
623 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
625 //printk("\n%s....%d %x \n",__FUNCTION__,__LINE__,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
629 if (camera_reset != INVALID_GPIO) {
630 ret = gpio_request(camera_reset, "camera reset");
632 if (camera_power != INVALID_GPIO)
633 gpio_free(camera_power);
638 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
639 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
641 //printk("\n%s....%d %x \n",__FUNCTION__,__LINE__,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
649 static int rk29_sensor_io_deinit(void)
652 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
654 //printk("\n%s....%d ******** ddl *********\n",__FUNCTION__,__LINE__);
656 for (i=0; i<2; i++) {
657 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
658 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
660 if (camera_power != INVALID_GPIO){
661 gpio_direction_input(camera_power);
662 gpio_free(camera_power);
665 if (camera_reset != INVALID_GPIO) {
666 gpio_direction_input(camera_reset);
667 gpio_free(camera_reset);
675 static int rk29_sensor_power(struct device *dev, int on)
677 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
678 unsigned int camera_ioflag;
680 if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
681 camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
682 camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
683 camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
684 } 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)) {
685 camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
686 camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
687 camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
690 if (camera_reset != INVALID_GPIO) {
691 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
692 //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));
694 if (camera_power != INVALID_GPIO) {
696 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
697 //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));
699 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
700 //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));
704 if (camera_reset != INVALID_GPIO) {
706 msleep(3); /* delay 3 ms */
707 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
708 //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));
713 #if (SENSOR_IIC_ADDR_0 != 0x00)
714 static struct i2c_board_info rk29_i2c_cam_info_0[] = {
716 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
720 struct soc_camera_link rk29_iclink_0 = {
721 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
722 .power = rk29_sensor_power,
723 .board_info = &rk29_i2c_cam_info_0[0],
724 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
725 .module_name = SENSOR_NAME_0,
728 /*platform_device : soc-camera need */
729 struct platform_device rk29_soc_camera_pdrv_0 = {
730 .name = "soc-camera-pdrv",
733 .init_name = SENSOR_NAME_0,
734 .platform_data = &rk29_iclink_0,
738 static struct i2c_board_info rk29_i2c_cam_info_1[] = {
740 I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
744 struct soc_camera_link rk29_iclink_1 = {
745 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
746 .power = rk29_sensor_power,
747 .board_info = &rk29_i2c_cam_info_1[0],
748 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
749 .module_name = SENSOR_NAME_1,
752 /*platform_device : soc-camera need */
753 struct platform_device rk29_soc_camera_pdrv_1 = {
754 .name = "soc-camera-pdrv",
757 .init_name = SENSOR_NAME_1,
758 .platform_data = &rk29_iclink_1,
763 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
764 struct resource rk29_camera_resource[] = {
766 .start = RK29_VIP_PHYS,
767 .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
768 .flags = IORESOURCE_MEM,
773 .flags = IORESOURCE_IRQ,
777 /*platform_device : */
778 struct platform_device rk29_device_camera = {
779 .name = RK29_CAM_DRV_NAME,
780 .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
781 .num_resources = ARRAY_SIZE(rk29_camera_resource),
782 .resource = rk29_camera_resource,
784 .dma_mask = &rockchip_device_camera_dmamask,
785 .coherent_dma_mask = 0xffffffffUL,
786 .platform_data = &rk29_camera_platform_data,
790 /*****************************************************************************************
792 * author: nzy@rock-chips.com
793 *****************************************************************************************/
794 #ifdef CONFIG_BACKLIGHT_RK29_BL
796 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
797 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
798 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
799 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
803 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
804 #define PWM_MUX_MODE GPIO1L_PWM0
805 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
806 #define PWM_EFFECT_VALUE 1
808 //#define LCD_DISP_ON_PIN
810 #ifdef LCD_DISP_ON_PIN
811 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
812 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
814 #define BL_EN_PIN GPIO0L_GPIO0A5
815 #define BL_EN_VALUE GPIO_HIGH
817 static int rk29_backlight_io_init(void)
821 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
822 #ifdef LCD_DISP_ON_PIN
823 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
825 ret = gpio_request(BL_EN_PIN, NULL);
828 gpio_free(BL_EN_PIN);
831 gpio_direction_output(BL_EN_PIN, 0);
832 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
837 static int rk29_backlight_io_deinit(void)
840 #ifdef LCD_DISP_ON_PIN
841 gpio_free(BL_EN_PIN);
843 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
846 struct rk29_bl_info rk29_bl_info = {
848 .bl_ref = PWM_EFFECT_VALUE,
849 .io_init = rk29_backlight_io_init,
850 .io_deinit = rk29_backlight_io_deinit,
853 /*****************************************************************************************
854 * pwm voltage regulator devices
855 ******************************************************************************************/
856 #if defined (CONFIG_RK29_PWM_REGULATOR)
858 #define REGULATOR_PWM_ID 2
859 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
860 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
861 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
862 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
864 static struct regulator_consumer_supply pwm_consumers[] = {
870 static struct regulator_init_data rk29_pwm_regulator_data = {
876 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
878 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
879 .consumer_supplies = pwm_consumers,
882 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
883 .pwm_id = REGULATOR_PWM_ID,
884 .pwm_gpio = REGULATOR_PWM_GPIO,
885 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
886 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
887 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
888 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
889 .init_data = &rk29_pwm_regulator_data,
892 static struct platform_device rk29_device_pwm_regulator = {
893 .name = "pwm-voltage-regulator",
896 .platform_data = &rk29_regulator_pwm_platform_data,
902 /*****************************************************************************************
904 *****************************************************************************************/
905 #ifdef CONFIG_SDMMC0_RK29
906 static int rk29_sdmmc0_cfg_gpio(void)
908 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
909 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
910 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
911 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
912 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
913 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
914 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
915 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
916 gpio_request(RK29_PIN5_PD5,"sdmmc");
917 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
919 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
923 #define CONFIG_SDMMC0_USE_DMA
924 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
925 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
926 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
927 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
928 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
929 .io_init = rk29_sdmmc0_cfg_gpio,
930 .dma_name = "sd_mmc",
931 #ifdef CONFIG_SDMMC0_USE_DMA
938 #ifdef CONFIG_SDMMC1_RK29
939 #define CONFIG_SDMMC1_USE_DMA
940 static int rk29_sdmmc1_cfg_gpio(void)
942 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
943 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
944 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
945 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
946 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
947 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
948 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
952 #ifdef CONFIG_WIFI_CONTROL_FUNC
953 static int rk29sdk_wifi_status(struct device *dev);
954 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
957 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
959 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
960 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
961 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
962 MMC_VDD_32_33|MMC_VDD_33_34),
963 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
964 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
965 .io_init = rk29_sdmmc1_cfg_gpio,
967 #ifdef CONFIG_SDMMC1_USE_DMA
972 #ifdef CONFIG_WIFI_CONTROL_FUNC
973 .status = rk29sdk_wifi_status,
974 .register_status_notify = rk29sdk_wifi_status_register,
977 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
982 #ifdef CONFIG_WIFI_CONTROL_FUNC
983 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
984 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
985 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
987 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
988 static void (*wifi_status_cb)(int card_present, void *dev_id);
989 static void *wifi_status_cb_devid;
990 int rk29sdk_wifi_power_state = 0;
991 int rk29sdk_bt_power_state = 0;
993 static int rk29sdk_wifi_status(struct device *dev)
995 return rk29sdk_wifi_cd;
998 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1002 wifi_status_cb = callback;
1003 wifi_status_cb_devid = dev_id;
1007 static int rk29sdk_wifi_bt_gpio_control_init(void)
1009 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1010 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1014 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1015 pr_info("%s: request wifi reset gpio failed\n", __func__);
1016 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1020 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1021 pr_info("%s: request bt reset gpio failed\n", __func__);
1022 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1026 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1027 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1028 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1030 pr_info("%s: init finished\n",__func__);
1035 static int rk29sdk_wifi_power(int on)
1037 pr_info("%s: %d\n", __func__, on);
1039 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
1041 pr_info("wifi turn on power\n");
1043 if (!rk29sdk_bt_power_state){
1044 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
1046 pr_info("wifi shut off power\n");
1049 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1054 rk29sdk_wifi_power_state = on;
1058 static int rk29sdk_wifi_reset_state;
1059 static int rk29sdk_wifi_reset(int on)
1061 pr_info("%s: %d\n", __func__, on);
1062 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1064 rk29sdk_wifi_reset_state = on;
1068 static int rk29sdk_wifi_set_carddetect(int val)
1070 pr_info("%s:%d\n", __func__, val);
1071 rk29sdk_wifi_cd = val;
1072 if (wifi_status_cb){
1073 wifi_status_cb(val, wifi_status_cb_devid);
1075 pr_warning("%s, nobody to notify\n", __func__);
1080 static struct wifi_platform_data rk29sdk_wifi_control = {
1081 .set_power = rk29sdk_wifi_power,
1082 .set_reset = rk29sdk_wifi_reset,
1083 .set_carddetect = rk29sdk_wifi_set_carddetect,
1085 static struct platform_device rk29sdk_wifi_device = {
1086 .name = "bcm4329_wlan",
1089 .platform_data = &rk29sdk_wifi_control,
1095 /* bluetooth rfkill device */
1096 static struct platform_device rk29sdk_rfkill = {
1097 .name = "rk29sdk_rfkill",
1102 #ifdef CONFIG_VIVANTE
1103 static struct resource resources_gpu[] = {
1108 .flags = IORESOURCE_IRQ,
1112 .start = RK29_GPU_PHYS,
1113 .end = RK29_GPU_PHYS + RK29_GPU_PHYS_SIZE,
1114 .flags = IORESOURCE_MEM,
1118 .start = PMEM_GPU_BASE,
1119 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE,
1120 .flags = IORESOURCE_MEM,
1123 struct platform_device rk29_device_gpu = {
1126 .num_resources = ARRAY_SIZE(resources_gpu),
1127 .resource = resources_gpu,
1130 #ifdef CONFIG_KEYS_RK29
1131 extern struct rk29_keys_platform_data rk29_keys_pdata;
1132 static struct platform_device rk29_device_keys = {
1133 .name = "rk29-keypad",
1136 .platform_data = &rk29_keys_pdata,
1141 static void __init rk29_board_iomux_init(void)
1143 #ifdef CONFIG_UART0_RK29
1144 rk29_mux_api_set(GPIO1B7_UART0SOUT_NAME, GPIO1L_UART0_SOUT);
1145 rk29_mux_api_set(GPIO1B6_UART0SIN_NAME, GPIO1L_UART0_SIN);
1146 #ifdef CONFIG_UART0_CTS_RTS_RK29
1147 rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N);
1148 rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_UART0_CTS_N);
1151 #ifdef CONFIG_UART1_RK29
1152 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
1153 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
1155 #ifdef CONFIG_UART2_RK29
1156 rk29_mux_api_set(GPIO2B1_UART2SOUT_NAME, GPIO2L_UART2_SOUT);
1157 rk29_mux_api_set(GPIO2B0_UART2SIN_NAME, GPIO2L_UART2_SIN);
1158 #ifdef CONFIG_UART2_CTS_RTS_RK29
1159 rk29_mux_api_set(GPIO2A7_UART2RTSN_NAME, GPIO2L_UART2_RTS_N);
1160 rk29_mux_api_set(GPIO2A6_UART2CTSN_NAME, GPIO2L_UART2_CTS_N);
1163 #ifdef CONFIG_UART3_RK29
1164 rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
1165 rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
1166 #ifdef CONFIG_UART3_CTS_RTS_RK29
1167 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_UART3_RTS_N);
1168 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_UART3_CTS_N);
1171 #ifdef CONFIG_SPIM0_RK29
1172 rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME, GPIO2H_SPI0_CLK);
1173 rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME, GPIO2H_SPI0_CSN0);
1174 rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME, GPIO2H_SPI0_TXD);
1175 rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME, GPIO2H_SPI0_RXD);
1177 #ifdef CONFIG_SPIM1_RK29
1178 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK);
1179 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME, GPIO2H_SPI1_CSN0);
1180 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME, GPIO2H_SPI1_TXD);
1181 rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME, GPIO2H_SPI1_RXD);
1183 #ifdef CONFIG_RK29_VMAC
1184 rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME, GPIO4H_RMII_CLKOUT);
1185 rk29_mux_api_set(GPIO4C1_RMIITXEN_MIITXEN_NAME, GPIO4H_RMII_TX_EN);
1186 rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME, GPIO4H_RMII_TXD1);
1187 rk29_mux_api_set(GPIO4C3_RMIITXD0_MIITXD0_NAME, GPIO4H_RMII_TXD0);
1188 rk29_mux_api_set(GPIO4C4_RMIIRXERR_MIIRXERR_NAME, GPIO4H_RMII_RX_ERR);
1189 rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME, GPIO4H_RMII_CSR_DVALID);
1190 rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME, GPIO4H_RMII_RXD1);
1191 rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME, GPIO4H_RMII_RXD0);
1193 rk29_mux_api_set(GPIO0A7_MIIMDCLK_NAME, GPIO0L_MII_MDCLK);
1194 rk29_mux_api_set(GPIO0A6_MIIMD_NAME, GPIO0L_MII_MD);
1196 #ifdef CONFIG_RK29_PWM_REGULATOR
1197 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1201 static struct platform_device *devices[] __initdata = {
1202 #ifdef CONFIG_UART1_RK29
1205 #ifdef CONFIG_UART0_RK29
1208 #ifdef CONFIG_UART2_RK29
1212 #ifdef CONFIG_RK29_PWM_REGULATOR
1213 &rk29_device_pwm_regulator,
1215 #ifdef CONFIG_SPIM0_RK29
1216 &rk29xx_device_spi0m,
1218 #ifdef CONFIG_SPIM1_RK29
1219 &rk29xx_device_spi1m,
1221 #ifdef CONFIG_ADC_RK29
1224 #ifdef CONFIG_I2C0_RK29
1227 #ifdef CONFIG_I2C1_RK29
1230 #ifdef CONFIG_I2C2_RK29
1233 #ifdef CONFIG_I2C3_RK29
1237 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1238 &rk29_device_iis_2ch,
1240 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1241 &rk29_device_iis_8ch,
1244 #ifdef CONFIG_KEYS_RK29
1247 #ifdef CONFIG_SDMMC0_RK29
1248 &rk29_device_sdmmc0,
1250 #ifdef CONFIG_SDMMC1_RK29
1251 &rk29_device_sdmmc1,
1254 #ifdef CONFIG_MTD_NAND_RK29XX
1255 &rk29xx_device_nand,
1258 #ifdef CONFIG_WIFI_CONTROL_FUNC
1259 &rk29sdk_wifi_device,
1266 #ifdef CONFIG_MTD_NAND_RK29
1270 #ifdef CONFIG_FB_RK29
1273 #ifdef CONFIG_BACKLIGHT_RK29_BL
1274 &rk29_device_backlight,
1276 #ifdef CONFIG_RK29_VMAC
1279 #ifdef CONFIG_VIVANTE
1282 #ifdef CONFIG_VIDEO_RK29
1283 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1284 #if (SENSOR_IIC_ADDR_0 != 0x00)
1285 &rk29_soc_camera_pdrv_0,
1287 &rk29_soc_camera_pdrv_1,
1288 &android_pmem_cam_device,
1290 &android_pmem_device,
1291 &rk29_vpu_mem_device,
1292 #ifdef CONFIG_USB20_OTG
1293 &rk29_device_usb20_otg,
1295 #ifdef CONFIG_USB20_HOST
1296 &rk29_device_usb20_host,
1298 #ifdef CONFIG_USB11_HOST
1299 &rk29_device_usb11_host,
1301 #ifdef CONFIG_USB_ANDROID
1302 &android_usb_device,
1303 &usb_mass_storage_device,
1305 #ifdef CONFIG_RK29_IPP
1310 /*****************************************************************************************
1312 * author: cmc@rock-chips.com
1313 *****************************************************************************************/
1314 static int rk29_vmac_register_set(void)
1316 //config rk29 vmac as rmii, 100MHz
1317 u32 value= readl(RK29_GRF_BASE + 0xbc);
1318 value = (value & 0xfff7ff) | (0x400);
1319 writel(value, RK29_GRF_BASE + 0xbc);
1323 static int rk29_rmii_io_init(void)
1328 rk29_mux_api_set(GPIO2D3_I2S0SDI_MIICOL_NAME, GPIO2H_GPIO2D3);
1329 err = gpio_request(RK29_PIN2_PD3, "rmii");
1331 gpio_free(RK29_PIN2_PD3);
1332 printk("-------request RK29_PIN2_PD3 fail--------\n");
1335 gpio_direction_output(RK29_PIN2_PD3, GPIO_HIGH);
1336 gpio_set_value(RK29_PIN2_PD3, GPIO_HIGH);
1339 err = gpio_request(RK29_PIN6_PB0, "rmii_power_en");
1341 gpio_free(RK29_PIN6_PB0);
1342 gpio_free(RK29_PIN2_PD3);
1343 printk("-------request RK29_PIN6_PB0 fail--------\n");
1346 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
1347 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
1352 static int rk29_rmii_power_control(int enable)
1355 //set dm9161 as rmii
1356 gpio_direction_output(RK29_PIN2_PD3, GPIO_HIGH);
1357 gpio_set_value(RK29_PIN2_PD3, GPIO_HIGH);
1360 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
1361 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
1365 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1366 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1372 struct rk29_vmac_platform_data rk29_vmac_pdata = {
1373 .vmac_register_set = rk29_vmac_register_set,
1374 .rmii_io_init = rk29_rmii_io_init,
1375 .rmii_power_control = rk29_rmii_power_control,
1378 /*****************************************************************************************
1380 * author: cmc@rock-chips.com
1381 *****************************************************************************************/
1382 #define SPI_CHIPSELECT_NUM 2
1383 struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
1386 .cs_gpio = RK29_PIN2_PC1,
1387 .cs_iomux_name = NULL,
1391 .cs_gpio = RK29_PIN1_PA4,
1392 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
1393 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
1397 struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
1400 .cs_gpio = RK29_PIN2_PC5,
1401 .cs_iomux_name = NULL,
1405 .cs_gpio = RK29_PIN1_PA3,
1406 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
1407 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
1411 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
1418 for (i=0; i<cs_num; i++) {
1419 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
1420 ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
1423 gpio_free(cs_gpios[j].cs_gpio);
1424 //rk29_mux_api_mode_resume(cs_gpios[j].cs_iomux_name);
1426 printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
1429 gpio_direction_output(cs_gpios[i].cs_gpio, GPIO_HIGH);
1436 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
1442 for (i=0; i<cs_num; i++) {
1443 gpio_free(cs_gpios[i].cs_gpio);
1444 //rk29_mux_api_mode_resume(cs_gpios[i].cs_iomux_name);
1451 static int spi_io_fix_leakage_bug(void)
1454 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
1459 static int spi_io_resume_leakage_bug(void)
1462 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
1467 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
1468 .num_chipselect = SPI_CHIPSELECT_NUM,
1469 .chipselect_gpios = rk29xx_spi0_cs_gpios,
1470 .io_init = spi_io_init,
1471 .io_deinit = spi_io_deinit,
1472 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1473 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1476 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
1477 .num_chipselect = SPI_CHIPSELECT_NUM,
1478 .chipselect_gpios = rk29xx_spi1_cs_gpios,
1479 .io_init = spi_io_init,
1480 .io_deinit = spi_io_deinit,
1481 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1482 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1485 /*****************************************************************************************
1486 * xpt2046 touch panel
1487 * author: cmc@rock-chips.com
1488 *****************************************************************************************/
1489 #define XPT2046_GPIO_INT RK29_PIN0_PA3
1490 #define DEBOUNCE_REPTIME 3
1492 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
1493 static struct xpt2046_platform_data xpt2046_info = {
1502 .debounce_rep = DEBOUNCE_REPTIME,
1504 .gpio_pendown = XPT2046_GPIO_INT,
1505 .penirq_recheck_delay_usecs = 1,
1507 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
1508 static struct xpt2046_platform_data xpt2046_info = {
1517 .debounce_rep = DEBOUNCE_REPTIME,
1519 .gpio_pendown = XPT2046_GPIO_INT,
1520 .penirq_recheck_delay_usecs = 1,
1522 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
1523 static struct xpt2046_platform_data xpt2046_info = {
1532 .debounce_rep = DEBOUNCE_REPTIME,
1534 .gpio_pendown = XPT2046_GPIO_INT,
1536 .penirq_recheck_delay_usecs = 1,
1538 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1539 static struct xpt2046_platform_data xpt2046_info = {
1548 .debounce_rep = DEBOUNCE_REPTIME,
1550 .gpio_pendown = XPT2046_GPIO_INT,
1552 .penirq_recheck_delay_usecs = 1,
1556 static struct spi_board_info board_spi_devices[] = {
1557 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
1558 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1560 .modalias = "xpt2046_ts",
1562 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
1564 .irq = XPT2046_GPIO_INT,
1565 .platform_data = &xpt2046_info,
1571 static void __init rk29_gic_init_irq(void)
1573 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
1574 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
1577 static void __init machine_rk29_init_irq(void)
1579 rk29_gic_init_irq();
1580 rk29_gpio_init(rk29_gpiobankinit, MAX_BANK);
1581 rk29_gpio_irq_setup();
1583 #define POWER_ON_PIN RK29_PIN4_PA4
1584 static void __init machine_rk29_board_init(void)
1586 rk29_board_iomux_init();
1587 gpio_request(POWER_ON_PIN,"poweronpin");
1588 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
1589 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1591 #ifdef CONFIG_WIFI_CONTROL_FUNC
1592 rk29sdk_wifi_bt_gpio_control_init();
1595 platform_add_devices(devices, ARRAY_SIZE(devices));
1596 #ifdef CONFIG_I2C0_RK29
1597 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
1598 ARRAY_SIZE(board_i2c0_devices));
1600 #ifdef CONFIG_I2C1_RK29
1601 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
1602 ARRAY_SIZE(board_i2c1_devices));
1604 #ifdef CONFIG_I2C2_RK29
1605 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
1606 ARRAY_SIZE(board_i2c2_devices));
1608 #ifdef CONFIG_I2C3_RK29
1609 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
1610 ARRAY_SIZE(board_i2c3_devices));
1613 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1616 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
1617 char **cmdline, struct meminfo *mi)
1620 mi->bank[0].start = RK29_SDRAM_PHYS;
1621 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
1622 mi->bank[0].size = LINUX_SIZE;
1625 static void __init machine_rk29_mapio(void)
1627 rk29_map_common_io();
1632 MACHINE_START(RK29, "RK29board")
1633 /* UART for LL DEBUG */
1634 .phys_io = RK29_UART1_PHYS,
1635 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
1636 .boot_params = RK29_SDRAM_PHYS + 0x88000,
1637 .fixup = machine_rk29_fixup,
1638 .map_io = machine_rk29_mapio,
1639 .init_irq = machine_rk29_init_irq,
1640 .init_machine = machine_rk29_board_init,
1641 .timer = &rk29_timer,