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_64M
65 #define PMEM_CAM_SIZE 0x01300000
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, 0);
383 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, 0);
384 gpio_request(RK29_PIN2_PB6, "i2c0_sda");
385 gpio_set_value(RK29_PIN2_PB6, GPIO_HIGH);
386 gpio_pull_updown(RK29_PIN2_PB6, PullDisable);
388 gpio_request(RK29_PIN2_PB7, "i2c0_scl");
389 gpio_set_value(RK29_PIN2_PB7, GPIO_HIGH);
390 gpio_pull_updown(RK29_PIN2_PB7, PullDisable);
392 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
393 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
397 static int rk29_i2c1_io_init(void)
399 gpio_request(RK29_PIN1_PA6, "i2c1_sda");
400 gpio_set_value(RK29_PIN1_PA6, GPIO_HIGH);
401 gpio_pull_updown(RK29_PIN1_PA6, PullDisable);
403 gpio_request(RK29_PIN1_PA7, "i2c1_scl");
404 gpio_set_value(RK29_PIN1_PA7, GPIO_HIGH);
405 gpio_pull_updown(RK29_PIN1_PA7, PullDisable);
407 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
408 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
411 static int rk29_i2c2_io_init(void)
413 gpio_request(RK29_PIN5_PD3, "i2c2_sda");
414 gpio_set_value(RK29_PIN5_PD3, GPIO_HIGH);
415 gpio_pull_updown(RK29_PIN5_PD3, PullDisable);
417 gpio_request(RK29_PIN5_PD4, "i2c2_scl");
418 gpio_set_value(RK29_PIN5_PD4, GPIO_HIGH);
419 gpio_pull_updown(RK29_PIN5_PD4, PullDisable);
421 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
422 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
426 static int rk29_i2c3_io_init(void)
428 gpio_request(RK29_PIN2_PB4, "i2c3_sda");
429 gpio_set_value(RK29_PIN2_PB4, GPIO_HIGH);
430 gpio_pull_updown(RK29_PIN2_PB4, PullDisable);
432 gpio_request(RK29_PIN2_PB5, "i2c3_scl");
433 gpio_set_value(RK29_PIN2_PB5, GPIO_HIGH);
434 gpio_pull_updown(RK29_PIN2_PB5, PullDisable);
436 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
437 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
441 struct rk29_i2c_platform_data default_i2c0_data = {
445 .scl_rate = 400*1000,
446 .mode = I2C_MODE_IRQ,
447 .io_init = rk29_i2c0_io_init,
450 struct rk29_i2c_platform_data default_i2c1_data = {
454 .scl_rate = 400*1000,
455 .mode = I2C_MODE_POLL,
456 .io_init = rk29_i2c1_io_init,
459 struct rk29_i2c_platform_data default_i2c2_data = {
463 .scl_rate = 400*1000,
464 .mode = I2C_MODE_IRQ,
465 .io_init = rk29_i2c2_io_init,
468 struct rk29_i2c_platform_data default_i2c3_data = {
472 .scl_rate = 400*1000,
473 .mode = I2C_MODE_POLL,
474 .io_init = rk29_i2c3_io_init,
477 #ifdef CONFIG_I2C0_RK29
478 static struct i2c_board_info __initdata board_i2c0_devices[] = {
479 #if defined (CONFIG_RK1000_CONTROL)
481 .type = "rk1000_control",
486 #if defined (CONFIG_SND_SOC_RK1000)
488 .type = "rk1000_i2c_codec",
493 #if defined (CONFIG_SND_SOC_WM8900)
500 #if defined (CONFIG_BATTERY_STC3100)
507 #if defined (CONFIG_BATTERY_BQ27510)
514 #if defined (CONFIG_RTC_HYM8563)
516 .type = "rtc_hym8563",
519 ///.irq = RK2818_PIN_PA4,
522 #if defined (CONFIG_GS_MMA8452)
524 .type = "gs_mma8452",
527 .irq = MMA8452_INT_PIN,
528 .platform_data = &mma8452_info,
531 #if defined (CONFIG_SENSORS_AK8973)
536 .irq = RK29_PIN0_PA4,
539 #if defined (CONFIG_SENSORS_AK8975)
544 .irq = RK29_PIN0_PA4,
550 #ifdef CONFIG_I2C1_RK29
551 static struct i2c_board_info __initdata board_i2c1_devices[] = {
552 #if defined (CONFIG_RK1000_CONTROL1)
554 .type = "rk1000_control",
559 #if defined (CONFIG_ANX7150)
562 .addr = 0x39, //0x39, 0x3d
564 .irq = RK29_PIN1_PD7,
571 #ifdef CONFIG_I2C2_RK29
572 static struct i2c_board_info __initdata board_i2c2_devices[] = {
573 #if defined (CONFIG_HANNSTAR_P1003)
575 .type = "p1003_touch",
578 .irq = RK29_PIN0_PA2,
579 .platform_data = &p1003_info,
585 #ifdef CONFIG_I2C3_RK29
586 static struct i2c_board_info __initdata board_i2c3_devices[] = {
590 /*****************************************************************************************
592 * author: ddl@rock-chips.com
593 *****************************************************************************************/
594 #ifdef CONFIG_VIDEO_RK29
595 #define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_OV5642 /* back camera sensor */
596 #define SENSOR_IIC_ADDR_0 0x78
597 #define SENSOR_IIC_ADAPTER_ID_0 1
598 #define SENSOR_POWER_PIN_0 RK29_PIN6_PB7
599 #define SENSOR_RESET_PIN_0 INVALID_GPIO
600 #define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
601 #define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
604 #define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_OV2659 /* front camera sensor */
605 #define SENSOR_IIC_ADDR_1 0x60
606 #define SENSOR_IIC_ADAPTER_ID_1 1
607 #define SENSOR_POWER_PIN_1 RK29_PIN5_PD7
608 #define SENSOR_RESET_PIN_1 INVALID_GPIO
609 #define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
610 #define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
612 static int rk29_sensor_io_init(void);
613 static int rk29_sensor_io_deinit(void);
615 struct rk29camera_platform_data rk29_camera_platform_data = {
616 .io_init = rk29_sensor_io_init,
617 .io_deinit = rk29_sensor_io_deinit,
620 .gpio_reset = SENSOR_RESET_PIN_0,
621 .gpio_power = SENSOR_POWER_PIN_0,
622 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0),
623 .dev_name = SENSOR_NAME_0,
625 .gpio_reset = SENSOR_RESET_PIN_1,
626 .gpio_power = SENSOR_POWER_PIN_1,
627 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1),
628 .dev_name = SENSOR_NAME_1,
631 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
633 .name = "camera_ipp_mem",
634 .start = MEM_CAMIPP_BASE,
635 .size = MEM_CAMIPP_SIZE,
640 static int rk29_sensor_io_init(void)
643 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
644 unsigned int camera_ioflag;
646 for (i=0; i<2; i++) {
647 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
648 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
649 camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
651 if (camera_power != INVALID_GPIO) {
652 ret = gpio_request(camera_power, "camera power");
656 gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
657 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
659 //printk("\n%s....%d %x \n",__FUNCTION__,__LINE__,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
663 if (camera_reset != INVALID_GPIO) {
664 ret = gpio_request(camera_reset, "camera reset");
666 if (camera_power != INVALID_GPIO)
667 gpio_free(camera_power);
672 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
673 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
675 //printk("\n%s....%d %x \n",__FUNCTION__,__LINE__,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
683 static int rk29_sensor_io_deinit(void)
686 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
688 //printk("\n%s....%d ******** ddl *********\n",__FUNCTION__,__LINE__);
690 for (i=0; i<2; i++) {
691 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
692 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
694 if (camera_power != INVALID_GPIO){
695 gpio_direction_input(camera_power);
696 gpio_free(camera_power);
699 if (camera_reset != INVALID_GPIO) {
700 gpio_direction_input(camera_reset);
701 gpio_free(camera_reset);
709 static int rk29_sensor_power(struct device *dev, int on)
711 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
712 unsigned int camera_ioflag;
714 if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
715 camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
716 camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
717 camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
718 } 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)) {
719 camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
720 camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
721 camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
724 if (camera_reset != INVALID_GPIO) {
725 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
726 //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));
728 if (camera_power != INVALID_GPIO) {
730 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
731 //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));
733 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
734 //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));
738 if (camera_reset != INVALID_GPIO) {
740 msleep(3); /* delay 3 ms */
741 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
742 //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));
747 #if (SENSOR_IIC_ADDR_0 != 0x00)
748 static struct i2c_board_info rk29_i2c_cam_info_0[] = {
750 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
754 struct soc_camera_link rk29_iclink_0 = {
755 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
756 .power = rk29_sensor_power,
757 .board_info = &rk29_i2c_cam_info_0[0],
758 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
759 .module_name = SENSOR_NAME_0,
762 /*platform_device : soc-camera need */
763 struct platform_device rk29_soc_camera_pdrv_0 = {
764 .name = "soc-camera-pdrv",
767 .init_name = SENSOR_NAME_0,
768 .platform_data = &rk29_iclink_0,
772 static struct i2c_board_info rk29_i2c_cam_info_1[] = {
774 I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
778 struct soc_camera_link rk29_iclink_1 = {
779 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
780 .power = rk29_sensor_power,
781 .board_info = &rk29_i2c_cam_info_1[0],
782 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
783 .module_name = SENSOR_NAME_1,
786 /*platform_device : soc-camera need */
787 struct platform_device rk29_soc_camera_pdrv_1 = {
788 .name = "soc-camera-pdrv",
791 .init_name = SENSOR_NAME_1,
792 .platform_data = &rk29_iclink_1,
797 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
798 struct resource rk29_camera_resource[] = {
800 .start = RK29_VIP_PHYS,
801 .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
802 .flags = IORESOURCE_MEM,
807 .flags = IORESOURCE_IRQ,
811 /*platform_device : */
812 struct platform_device rk29_device_camera = {
813 .name = RK29_CAM_DRV_NAME,
814 .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
815 .num_resources = ARRAY_SIZE(rk29_camera_resource),
816 .resource = rk29_camera_resource,
818 .dma_mask = &rockchip_device_camera_dmamask,
819 .coherent_dma_mask = 0xffffffffUL,
820 .platform_data = &rk29_camera_platform_data,
824 /*****************************************************************************************
826 * author: nzy@rock-chips.com
827 *****************************************************************************************/
828 #ifdef CONFIG_BACKLIGHT_RK29_BL
830 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
831 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
832 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
833 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
837 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
838 #define PWM_MUX_MODE GPIO1L_PWM0
839 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
840 #define PWM_EFFECT_VALUE 1
842 //#define LCD_DISP_ON_PIN
844 #ifdef LCD_DISP_ON_PIN
845 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
846 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
848 #define BL_EN_PIN GPIO0L_GPIO0A5
849 #define BL_EN_VALUE GPIO_HIGH
851 static int rk29_backlight_io_init(void)
855 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
856 #ifdef LCD_DISP_ON_PIN
857 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
859 ret = gpio_request(BL_EN_PIN, NULL);
862 gpio_free(BL_EN_PIN);
865 gpio_direction_output(BL_EN_PIN, 0);
866 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
871 static int rk29_backlight_io_deinit(void)
874 #ifdef LCD_DISP_ON_PIN
875 gpio_free(BL_EN_PIN);
877 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
880 struct rk29_bl_info rk29_bl_info = {
882 .bl_ref = PWM_EFFECT_VALUE,
883 .io_init = rk29_backlight_io_init,
884 .io_deinit = rk29_backlight_io_deinit,
887 /*****************************************************************************************
888 * pwm voltage regulator devices
889 ******************************************************************************************/
890 #if defined (CONFIG_RK29_PWM_REGULATOR)
892 #define REGULATOR_PWM_ID 2
893 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
894 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
895 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
896 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
898 static struct regulator_consumer_supply pwm_consumers[] = {
904 static struct regulator_init_data rk29_pwm_regulator_data = {
910 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
912 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
913 .consumer_supplies = pwm_consumers,
916 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
917 .pwm_id = REGULATOR_PWM_ID,
918 .pwm_gpio = REGULATOR_PWM_GPIO,
919 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
920 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
921 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
922 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
923 .init_data = &rk29_pwm_regulator_data,
926 static struct platform_device rk29_device_pwm_regulator = {
927 .name = "pwm-voltage-regulator",
930 .platform_data = &rk29_regulator_pwm_platform_data,
936 /*****************************************************************************************
938 *****************************************************************************************/
939 #ifdef CONFIG_SDMMC0_RK29
940 static int rk29_sdmmc0_cfg_gpio(void)
942 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
943 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
944 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
945 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
946 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
947 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
948 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
949 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
950 gpio_request(RK29_PIN5_PD5,"sdmmc");
951 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
953 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
957 #define CONFIG_SDMMC0_USE_DMA
958 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
959 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
960 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
961 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
962 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
963 .io_init = rk29_sdmmc0_cfg_gpio,
964 .dma_name = "sd_mmc",
965 #ifdef CONFIG_SDMMC0_USE_DMA
972 #ifdef CONFIG_SDMMC1_RK29
973 #define CONFIG_SDMMC1_USE_DMA
974 static int rk29_sdmmc1_cfg_gpio(void)
976 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
977 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
978 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
979 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
980 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
981 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
982 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
986 #ifdef CONFIG_WIFI_CONTROL_FUNC
987 static int rk29sdk_wifi_status(struct device *dev);
988 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
991 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
993 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
994 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
995 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
996 MMC_VDD_32_33|MMC_VDD_33_34),
997 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
998 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
999 .io_init = rk29_sdmmc1_cfg_gpio,
1001 #ifdef CONFIG_SDMMC1_USE_DMA
1006 #ifdef CONFIG_WIFI_CONTROL_FUNC
1007 .status = rk29sdk_wifi_status,
1008 .register_status_notify = rk29sdk_wifi_status_register,
1011 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1016 #ifdef CONFIG_WIFI_CONTROL_FUNC
1017 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1018 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1019 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1021 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1022 static void (*wifi_status_cb)(int card_present, void *dev_id);
1023 static void *wifi_status_cb_devid;
1024 int rk29sdk_wifi_power_state = 0;
1025 int rk29sdk_bt_power_state = 0;
1027 static int rk29sdk_wifi_status(struct device *dev)
1029 return rk29sdk_wifi_cd;
1032 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1036 wifi_status_cb = callback;
1037 wifi_status_cb_devid = dev_id;
1041 static int rk29sdk_wifi_bt_gpio_control_init(void)
1043 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1044 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1048 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1049 pr_info("%s: request wifi reset gpio failed\n", __func__);
1050 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1054 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1055 pr_info("%s: request bt reset gpio failed\n", __func__);
1056 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1060 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1061 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1062 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1064 pr_info("%s: init finished\n",__func__);
1069 static int rk29sdk_wifi_power(int on)
1071 pr_info("%s: %d\n", __func__, on);
1073 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
1075 pr_info("wifi turn on power\n");
1077 if (!rk29sdk_bt_power_state){
1078 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
1080 pr_info("wifi shut off power\n");
1083 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1088 rk29sdk_wifi_power_state = on;
1092 static int rk29sdk_wifi_reset_state;
1093 static int rk29sdk_wifi_reset(int on)
1095 pr_info("%s: %d\n", __func__, on);
1096 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1098 rk29sdk_wifi_reset_state = on;
1102 static int rk29sdk_wifi_set_carddetect(int val)
1104 pr_info("%s:%d\n", __func__, val);
1105 rk29sdk_wifi_cd = val;
1106 if (wifi_status_cb){
1107 wifi_status_cb(val, wifi_status_cb_devid);
1109 pr_warning("%s, nobody to notify\n", __func__);
1114 static struct wifi_platform_data rk29sdk_wifi_control = {
1115 .set_power = rk29sdk_wifi_power,
1116 .set_reset = rk29sdk_wifi_reset,
1117 .set_carddetect = rk29sdk_wifi_set_carddetect,
1119 static struct platform_device rk29sdk_wifi_device = {
1120 .name = "bcm4329_wlan",
1123 .platform_data = &rk29sdk_wifi_control,
1129 /* bluetooth rfkill device */
1130 static struct platform_device rk29sdk_rfkill = {
1131 .name = "rk29sdk_rfkill",
1136 #ifdef CONFIG_VIVANTE
1137 static struct resource resources_gpu[] = {
1142 .flags = IORESOURCE_IRQ,
1146 .start = RK29_GPU_PHYS,
1147 .end = RK29_GPU_PHYS + RK29_GPU_PHYS_SIZE,
1148 .flags = IORESOURCE_MEM,
1152 .start = PMEM_GPU_BASE,
1153 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE,
1154 .flags = IORESOURCE_MEM,
1157 struct platform_device rk29_device_gpu = {
1160 .num_resources = ARRAY_SIZE(resources_gpu),
1161 .resource = resources_gpu,
1164 #ifdef CONFIG_KEYS_RK29
1165 extern struct rk29_keys_platform_data rk29_keys_pdata;
1166 static struct platform_device rk29_device_keys = {
1167 .name = "rk29-keypad",
1170 .platform_data = &rk29_keys_pdata,
1175 static void __init rk29_board_iomux_init(void)
1177 #ifdef CONFIG_UART0_RK29
1178 rk29_mux_api_set(GPIO1B7_UART0SOUT_NAME, GPIO1L_UART0_SOUT);
1179 rk29_mux_api_set(GPIO1B6_UART0SIN_NAME, GPIO1L_UART0_SIN);
1180 #ifdef CONFIG_UART0_CTS_RTS_RK29
1181 rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N);
1182 rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_UART0_CTS_N);
1185 #ifdef CONFIG_UART1_RK29
1186 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
1187 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
1189 #ifdef CONFIG_UART2_RK29
1190 rk29_mux_api_set(GPIO2B1_UART2SOUT_NAME, GPIO2L_UART2_SOUT);
1191 rk29_mux_api_set(GPIO2B0_UART2SIN_NAME, GPIO2L_UART2_SIN);
1192 #ifdef CONFIG_UART2_CTS_RTS_RK29
1193 rk29_mux_api_set(GPIO2A7_UART2RTSN_NAME, GPIO2L_UART2_RTS_N);
1194 rk29_mux_api_set(GPIO2A6_UART2CTSN_NAME, GPIO2L_UART2_CTS_N);
1197 #ifdef CONFIG_UART3_RK29
1198 rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
1199 rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
1200 #ifdef CONFIG_UART3_CTS_RTS_RK29
1201 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_UART3_RTS_N);
1202 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_UART3_CTS_N);
1205 #ifdef CONFIG_SPIM0_RK29
1206 rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME, GPIO2H_SPI0_CLK);
1207 rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME, GPIO2H_SPI0_CSN0);
1208 rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME, GPIO2H_SPI0_TXD);
1209 rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME, GPIO2H_SPI0_RXD);
1211 #ifdef CONFIG_SPIM1_RK29
1212 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK);
1213 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME, GPIO2H_SPI1_CSN0);
1214 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME, GPIO2H_SPI1_TXD);
1215 rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME, GPIO2H_SPI1_RXD);
1217 #ifdef CONFIG_RK29_VMAC
1218 rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME, GPIO4H_RMII_CLKOUT);
1219 rk29_mux_api_set(GPIO4C1_RMIITXEN_MIITXEN_NAME, GPIO4H_RMII_TX_EN);
1220 rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME, GPIO4H_RMII_TXD1);
1221 rk29_mux_api_set(GPIO4C3_RMIITXD0_MIITXD0_NAME, GPIO4H_RMII_TXD0);
1222 rk29_mux_api_set(GPIO4C4_RMIIRXERR_MIIRXERR_NAME, GPIO4H_RMII_RX_ERR);
1223 rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME, GPIO4H_RMII_CSR_DVALID);
1224 rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME, GPIO4H_RMII_RXD1);
1225 rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME, GPIO4H_RMII_RXD0);
1227 rk29_mux_api_set(GPIO0A7_MIIMDCLK_NAME, GPIO0L_MII_MDCLK);
1228 rk29_mux_api_set(GPIO0A6_MIIMD_NAME, GPIO0L_MII_MD);
1230 #ifdef CONFIG_RK29_PWM_REGULATOR
1231 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1235 static struct platform_device *devices[] __initdata = {
1236 #ifdef CONFIG_UART1_RK29
1239 #ifdef CONFIG_UART0_RK29
1242 #ifdef CONFIG_UART2_RK29
1246 #ifdef CONFIG_RK29_PWM_REGULATOR
1247 &rk29_device_pwm_regulator,
1249 #ifdef CONFIG_SPIM0_RK29
1250 &rk29xx_device_spi0m,
1252 #ifdef CONFIG_SPIM1_RK29
1253 &rk29xx_device_spi1m,
1255 #ifdef CONFIG_ADC_RK29
1258 #ifdef CONFIG_I2C0_RK29
1261 #ifdef CONFIG_I2C1_RK29
1264 #ifdef CONFIG_I2C2_RK29
1267 #ifdef CONFIG_I2C3_RK29
1271 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1272 &rk29_device_iis_2ch,
1274 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1275 &rk29_device_iis_8ch,
1278 #ifdef CONFIG_KEYS_RK29
1281 #ifdef CONFIG_SDMMC0_RK29
1282 &rk29_device_sdmmc0,
1284 #ifdef CONFIG_SDMMC1_RK29
1285 &rk29_device_sdmmc1,
1288 #ifdef CONFIG_MTD_NAND_RK29XX
1289 &rk29xx_device_nand,
1292 #ifdef CONFIG_WIFI_CONTROL_FUNC
1293 &rk29sdk_wifi_device,
1300 #ifdef CONFIG_MTD_NAND_RK29
1304 #ifdef CONFIG_FB_RK29
1307 #ifdef CONFIG_BACKLIGHT_RK29_BL
1308 &rk29_device_backlight,
1310 #ifdef CONFIG_RK29_VMAC
1313 #ifdef CONFIG_VIVANTE
1316 #ifdef CONFIG_VIDEO_RK29
1317 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1318 #if (SENSOR_IIC_ADDR_0 != 0x00)
1319 &rk29_soc_camera_pdrv_0,
1321 &rk29_soc_camera_pdrv_1,
1322 &android_pmem_cam_device,
1324 &android_pmem_device,
1325 &rk29_vpu_mem_device,
1326 #ifdef CONFIG_USB20_OTG
1327 &rk29_device_usb20_otg,
1329 #ifdef CONFIG_USB20_HOST
1330 &rk29_device_usb20_host,
1332 #ifdef CONFIG_USB11_HOST
1333 &rk29_device_usb11_host,
1335 #ifdef CONFIG_USB_ANDROID
1336 &android_usb_device,
1337 &usb_mass_storage_device,
1339 #ifdef CONFIG_RK29_IPP
1344 /*****************************************************************************************
1346 * author: cmc@rock-chips.com
1347 *****************************************************************************************/
1348 static int rk29_vmac_register_set(void)
1350 //config rk29 vmac as rmii, 100MHz
1351 u32 value= readl(RK29_GRF_BASE + 0xbc);
1352 value = (value & 0xfff7ff) | (0x400);
1353 writel(value, RK29_GRF_BASE + 0xbc);
1357 static int rk29_rmii_io_init(void)
1362 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
1364 gpio_free(RK29_PIN6_PB0);
1365 printk("-------request RK29_PIN6_PB0 fail--------\n");
1369 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1370 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1375 static int rk29_rmii_io_deinit(void)
1378 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1379 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1381 gpio_free(RK29_PIN6_PB0);
1385 static int rk29_rmii_power_control(int enable)
1389 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
1390 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
1393 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1394 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1399 struct rk29_vmac_platform_data rk29_vmac_pdata = {
1400 .vmac_register_set = rk29_vmac_register_set,
1401 .rmii_io_init = rk29_rmii_io_init,
1402 .rmii_io_deinit = rk29_rmii_io_deinit,
1403 .rmii_power_control = rk29_rmii_power_control,
1406 /*****************************************************************************************
1408 * author: cmc@rock-chips.com
1409 *****************************************************************************************/
1410 #define SPI_CHIPSELECT_NUM 2
1411 struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
1414 .cs_gpio = RK29_PIN2_PC1,
1415 .cs_iomux_name = NULL,
1419 .cs_gpio = RK29_PIN1_PA4,
1420 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
1421 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
1425 struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
1428 .cs_gpio = RK29_PIN2_PC5,
1429 .cs_iomux_name = NULL,
1433 .cs_gpio = RK29_PIN1_PA3,
1434 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
1435 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
1439 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
1446 for (i=0; i<cs_num; i++) {
1447 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
1448 ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
1451 gpio_free(cs_gpios[j].cs_gpio);
1452 //rk29_mux_api_mode_resume(cs_gpios[j].cs_iomux_name);
1454 printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
1457 gpio_direction_output(cs_gpios[i].cs_gpio, GPIO_HIGH);
1464 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
1470 for (i=0; i<cs_num; i++) {
1471 gpio_free(cs_gpios[i].cs_gpio);
1472 //rk29_mux_api_mode_resume(cs_gpios[i].cs_iomux_name);
1479 static int spi_io_fix_leakage_bug(void)
1482 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
1487 static int spi_io_resume_leakage_bug(void)
1490 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
1495 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
1496 .num_chipselect = SPI_CHIPSELECT_NUM,
1497 .chipselect_gpios = rk29xx_spi0_cs_gpios,
1498 .io_init = spi_io_init,
1499 .io_deinit = spi_io_deinit,
1500 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1501 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1504 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
1505 .num_chipselect = SPI_CHIPSELECT_NUM,
1506 .chipselect_gpios = rk29xx_spi1_cs_gpios,
1507 .io_init = spi_io_init,
1508 .io_deinit = spi_io_deinit,
1509 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1510 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1513 /*****************************************************************************************
1514 * xpt2046 touch panel
1515 * author: cmc@rock-chips.com
1516 *****************************************************************************************/
1517 #define XPT2046_GPIO_INT RK29_PIN0_PA3
1518 #define DEBOUNCE_REPTIME 3
1520 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
1521 static struct xpt2046_platform_data xpt2046_info = {
1530 .debounce_rep = DEBOUNCE_REPTIME,
1532 .gpio_pendown = XPT2046_GPIO_INT,
1533 .penirq_recheck_delay_usecs = 1,
1535 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
1536 static struct xpt2046_platform_data xpt2046_info = {
1545 .debounce_rep = DEBOUNCE_REPTIME,
1547 .gpio_pendown = XPT2046_GPIO_INT,
1548 .penirq_recheck_delay_usecs = 1,
1550 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
1551 static struct xpt2046_platform_data xpt2046_info = {
1560 .debounce_rep = DEBOUNCE_REPTIME,
1562 .gpio_pendown = XPT2046_GPIO_INT,
1564 .penirq_recheck_delay_usecs = 1,
1566 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1567 static struct xpt2046_platform_data xpt2046_info = {
1576 .debounce_rep = DEBOUNCE_REPTIME,
1578 .gpio_pendown = XPT2046_GPIO_INT,
1580 .penirq_recheck_delay_usecs = 1,
1584 static struct spi_board_info board_spi_devices[] = {
1585 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
1586 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1588 .modalias = "xpt2046_ts",
1590 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
1592 .irq = XPT2046_GPIO_INT,
1593 .platform_data = &xpt2046_info,
1599 static void __init rk29_gic_init_irq(void)
1601 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
1602 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
1605 static void __init machine_rk29_init_irq(void)
1607 rk29_gic_init_irq();
1608 rk29_gpio_init(rk29_gpiobankinit, MAX_BANK);
1609 rk29_gpio_irq_setup();
1612 #define POWER_ON_PIN RK29_PIN4_PA4
1613 static void rk29_pm_power_off(void)
1615 printk(KERN_ERR "rk29_pm_power_off start...\n");
1616 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1620 static void __init machine_rk29_board_init(void)
1622 rk29_board_iomux_init();
1624 gpio_request(POWER_ON_PIN,"poweronpin");
1625 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
1626 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1627 pm_power_off = rk29_pm_power_off;
1629 #ifdef CONFIG_WIFI_CONTROL_FUNC
1630 rk29sdk_wifi_bt_gpio_control_init();
1633 platform_add_devices(devices, ARRAY_SIZE(devices));
1634 #ifdef CONFIG_I2C0_RK29
1635 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
1636 ARRAY_SIZE(board_i2c0_devices));
1638 #ifdef CONFIG_I2C1_RK29
1639 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
1640 ARRAY_SIZE(board_i2c1_devices));
1642 #ifdef CONFIG_I2C2_RK29
1643 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
1644 ARRAY_SIZE(board_i2c2_devices));
1646 #ifdef CONFIG_I2C3_RK29
1647 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
1648 ARRAY_SIZE(board_i2c3_devices));
1651 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1654 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
1655 char **cmdline, struct meminfo *mi)
1658 mi->bank[0].start = RK29_SDRAM_PHYS;
1659 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
1660 mi->bank[0].size = LINUX_SIZE;
1663 static void __init machine_rk29_mapio(void)
1665 rk29_map_common_io();
1670 MACHINE_START(RK29, "RK29board")
1671 /* UART for LL DEBUG */
1672 .phys_io = RK29_UART1_PHYS,
1673 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
1674 .boot_params = RK29_SDRAM_PHYS + 0x88000,
1675 .fixup = machine_rk29_fixup,
1676 .map_io = machine_rk29_mapio,
1677 .init_irq = machine_rk29_init_irq,
1678 .init_machine = machine_rk29_board_init,
1679 .timer = &rk29_timer,