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,
96 /*****************************************************************************************
98 * author: zyw@rock-chips.com
99 *****************************************************************************************/
100 //#ifdef CONFIG_LCD_TD043MGEA1
101 #define LCD_TXD_PIN INVALID_GPIO
102 #define LCD_CLK_PIN INVALID_GPIO
103 #define LCD_CS_PIN INVALID_GPIO
104 /*****************************************************************************************
105 * frame buffe devices
106 * author: zyw@rock-chips.com
107 *****************************************************************************************/
109 #define FB_DISPLAY_ON_PIN RK29_PIN6_PD0
110 #define FB_LCD_STANDBY_PIN RK29_PIN6_PD1
111 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
112 #define FB_MCU_FMK_PIN INVALID_GPIO
114 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
115 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
118 static int rk29_lcd_io_init(void)
124 static int rk29_lcd_io_deinit(void)
130 struct rk29lcd_info rk29_lcd_info = {
131 .txd_pin = LCD_TXD_PIN,
132 .clk_pin = LCD_CLK_PIN,
133 .cs_pin = LCD_CS_PIN,
134 .io_init = rk29_lcd_io_init,
135 .io_deinit = rk29_lcd_io_deinit,
139 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
142 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
144 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
147 gpio_free(FB_MCU_FMK_PIN);
148 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
150 gpio_direction_input(FB_MCU_FMK_PIN);
152 if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
154 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
157 gpio_free(FB_DISPLAY_ON_PIN);
158 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
162 if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
164 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
167 gpio_free(FB_LCD_STANDBY_PIN);
168 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
172 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
174 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
177 gpio_free(FB_LCD_CABC_EN_PIN);
178 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
180 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
181 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
187 struct rk29fb_info rk29_fb_info = {
189 .disp_on_pin = FB_DISPLAY_ON_PIN,
190 .disp_on_value = FB_DISPLAY_ON_VALUE,
191 .standby_pin = FB_LCD_STANDBY_PIN,
192 .standby_value = FB_LCD_STANDBY_VALUE,
193 .mcu_fmk_pin = FB_MCU_FMK_PIN,
194 .lcd_info = &rk29_lcd_info,
195 .io_init = rk29_fb_io_init,
198 /* rk29 fb resource */
199 struct resource rk29_fb_resource[] = {
202 .start = RK29_LCDC_PHYS,
203 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
204 .flags = IORESOURCE_MEM,
210 .flags = IORESOURCE_IRQ,
214 .start = MEM_FB_BASE,
215 .end = MEM_FB_BASE + MEM_FB_SIZE,
216 .flags = IORESOURCE_MEM,
221 struct platform_device rk29_device_fb = {
224 .num_resources = ARRAY_SIZE(rk29_fb_resource),
225 .resource = rk29_fb_resource,
227 .platform_data = &rk29_fb_info,
232 static struct android_pmem_platform_data android_pmem_pdata = {
234 .start = PMEM_UI_BASE,
235 .size = PMEM_UI_SIZE,
240 static struct platform_device android_pmem_device = {
241 .name = "android_pmem",
244 .platform_data = &android_pmem_pdata,
249 static struct android_pmem_platform_data android_pmem_cam_pdata = {
251 .start = PMEM_CAM_BASE,
252 .size = PMEM_CAM_SIZE,
257 static struct platform_device android_pmem_cam_device = {
258 .name = "android_pmem",
261 .platform_data = &android_pmem_cam_pdata,
266 static struct vpu_mem_platform_data vpu_mem_pdata = {
268 .start = PMEM_VPU_BASE,
269 .size = PMEM_VPU_SIZE,
273 static struct platform_device rk29_vpu_mem_device = {
277 .platform_data = &vpu_mem_pdata,
282 /*HANNSTAR_P1003 touch*/
283 #if defined (CONFIG_HANNSTAR_P1003)
284 #define TOUCH_RESET_PIN RK29_PIN6_PC3
285 #define TOUCH_INT_PIN RK29_PIN0_PA2
287 int p1003_init_platform_hw(void)
289 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
290 gpio_free(TOUCH_RESET_PIN);
291 printk("p1003_init_platform_hw gpio_request error\n");
295 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
296 gpio_free(TOUCH_INT_PIN);
297 printk("p1003_init_platform_hw gpio_request error\n");
300 gpio_pull_updown(TOUCH_INT_PIN, 1);
301 gpio_direction_output(TOUCH_RESET_PIN, 0);
303 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
305 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
311 struct p1003_platform_data p1003_info = {
313 .init_platform_hw= p1003_init_platform_hw,
317 #if defined (CONFIG_EETI_EGALAX)
318 #define TOUCH_RESET_PIN RK29_PIN6_PC3
319 #define TOUCH_INT_PIN RK29_PIN0_PA2
321 int EETI_EGALAX_init_platform_hw(void)
323 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
324 gpio_free(TOUCH_RESET_PIN);
325 printk("p1003_init_platform_hw gpio_request error\n");
329 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
330 gpio_free(TOUCH_INT_PIN);
331 printk("p1003_init_platform_hw gpio_request error\n");
334 gpio_pull_updown(TOUCH_INT_PIN, 1);
335 gpio_direction_output(TOUCH_RESET_PIN, 0);
337 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
339 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
345 struct eeti_egalax_platform_data eeti_egalax_info = {
347 .init_platform_hw= EETI_EGALAX_init_platform_hw,
352 #if defined (CONFIG_GS_MMA8452)
353 #define MMA8452_INT_PIN RK29_PIN0_PA3
355 int mma8452_init_platform_hw(void)
358 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
359 gpio_free(MMA8452_INT_PIN);
360 printk("mma8452_init_platform_hw gpio_request error\n");
363 gpio_pull_updown(MMA8452_INT_PIN, 1);
368 struct mma8452_platform_data mma8452_info = {
371 .init_platform_hw= mma8452_init_platform_hw,
378 /*****************************************************************************************
380 * author: kfx@rock-chips.com
381 *****************************************************************************************/
382 static int rk29_i2c0_io_init(void)
384 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
385 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
389 static int rk29_i2c1_io_init(void)
391 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
392 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
395 static int rk29_i2c2_io_init(void)
397 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
398 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
402 static int rk29_i2c3_io_init(void)
404 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
405 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
409 struct rk29_i2c_platform_data default_i2c0_data = {
413 .scl_rate = 400*1000,
414 .mode = I2C_MODE_IRQ,
415 .io_init = rk29_i2c0_io_init,
418 struct rk29_i2c_platform_data default_i2c1_data = {
422 .scl_rate = 400*1000,
423 .mode = I2C_MODE_POLL,
424 .io_init = rk29_i2c1_io_init,
427 struct rk29_i2c_platform_data default_i2c2_data = {
431 .scl_rate = 400*1000,
432 .mode = I2C_MODE_IRQ,
433 .io_init = rk29_i2c2_io_init,
436 struct rk29_i2c_platform_data default_i2c3_data = {
440 .scl_rate = 400*1000,
441 .mode = I2C_MODE_POLL,
442 .io_init = rk29_i2c3_io_init,
445 #ifdef CONFIG_I2C0_RK29
446 static struct i2c_board_info __initdata board_i2c0_devices[] = {
447 #if defined (CONFIG_RK1000_CONTROL)
449 .type = "rk1000_control",
454 #if defined (CONFIG_SND_SOC_RK1000)
456 .type = "rk1000_i2c_codec",
461 #if defined (CONFIG_SND_SOC_WM8900)
468 #if defined (CONFIG_BATTERY_STC3100)
475 #if defined (CONFIG_BATTERY_BQ27510)
482 #if defined (CONFIG_RTC_HYM8563)
484 .type = "rtc_hym8563",
487 .irq = RK29_PIN0_PA1,
490 #if defined (CONFIG_GS_MMA8452)
492 .type = "gs_mma8452",
495 .irq = MMA8452_INT_PIN,
496 .platform_data = &mma8452_info,
499 #if defined (CONFIG_SENSORS_AK8973)
504 .irq = RK29_PIN0_PA4,
507 #if defined (CONFIG_SENSORS_AK8975)
512 .irq = RK29_PIN0_PA4,
518 #ifdef CONFIG_I2C1_RK29
519 static struct i2c_board_info __initdata board_i2c1_devices[] = {
520 #if defined (CONFIG_RK1000_CONTROL1)
522 .type = "rk1000_control",
527 #if defined (CONFIG_ANX7150)
530 .addr = 0x39, //0x39, 0x3d
532 .irq = RK29_PIN1_PD7,
539 #ifdef CONFIG_I2C2_RK29
540 static struct i2c_board_info __initdata board_i2c2_devices[] = {
541 #if defined (CONFIG_HANNSTAR_P1003)
543 .type = "p1003_touch",
546 .irq = RK29_PIN0_PA2,
547 .platform_data = &p1003_info,
550 #if defined (CONFIG_EETI_EGALAX)
552 .type = "egalax_i2c",
555 .irq = RK29_PIN0_PA2,
556 .platform_data = &eeti_egalax_info,
562 #ifdef CONFIG_I2C3_RK29
563 static struct i2c_board_info __initdata board_i2c3_devices[] = {
567 /*****************************************************************************************
569 * author: ddl@rock-chips.com
570 *****************************************************************************************/
571 #ifdef CONFIG_VIDEO_RK29
572 #define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_OV5642 /* back camera sensor */
573 #define SENSOR_IIC_ADDR_0 0x78
574 #define SENSOR_IIC_ADAPTER_ID_0 1
575 #define SENSOR_POWER_PIN_0 INVALID_GPIO
576 #define SENSOR_RESET_PIN_0 INVALID_GPIO
577 #define SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
578 #define SENSOR_FALSH_PIN_0 INVALID_GPIO
579 #define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
580 #define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
581 #define SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
582 #define SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
584 #define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_OV2659 /* front camera sensor */
585 #define SENSOR_IIC_ADDR_1 0x60
586 #define SENSOR_IIC_ADAPTER_ID_1 1
587 #define SENSOR_POWER_PIN_1 INVALID_GPIO
588 #define SENSOR_RESET_PIN_1 INVALID_GPIO
589 #define SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
590 #define SENSOR_FALSH_PIN_1 INVALID_GPIO
591 #define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
592 #define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
593 #define SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
594 #define SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
596 static int rk29_sensor_io_init(void);
597 static int rk29_sensor_io_deinit(int sensor);
598 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
600 struct rk29camera_platform_data rk29_camera_platform_data = {
601 .io_init = rk29_sensor_io_init,
602 .io_deinit = rk29_sensor_io_deinit,
603 .sensor_ioctrl = rk29_sensor_ioctrl,
606 .gpio_reset = SENSOR_RESET_PIN_0,
607 .gpio_power = SENSOR_POWER_PIN_0,
608 .gpio_powerdown = SENSOR_POWERDN_PIN_0,
609 .gpio_flash = SENSOR_FALSH_PIN_0,
610 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0|SENSOR_POWERDNACTIVE_LEVEL_0|SENSOR_FLASHACTIVE_LEVEL_0),
612 .dev_name = SENSOR_NAME_0,
614 .gpio_reset = SENSOR_RESET_PIN_1,
615 .gpio_power = SENSOR_POWER_PIN_1,
616 .gpio_powerdown = SENSOR_POWERDN_PIN_1,
617 .gpio_flash = SENSOR_FALSH_PIN_1,
618 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1|SENSOR_POWERDNACTIVE_LEVEL_1|SENSOR_FLASHACTIVE_LEVEL_1),
620 .dev_name = SENSOR_NAME_1,
623 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
625 .name = "camera_ipp_mem",
626 .start = MEM_CAMIPP_BASE,
627 .size = MEM_CAMIPP_SIZE,
632 static int rk29_sensor_io_init(void)
635 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
636 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
637 unsigned int camera_ioflag;
639 for (i=0; i<2; i++) {
640 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
641 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
642 camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
643 camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
644 camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
645 rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
647 if (camera_power != INVALID_GPIO) {
648 ret = gpio_request(camera_power, "camera power");
650 goto sensor_io_int_loop_end;
651 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
652 gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
653 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
655 //printk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
659 if (camera_reset != INVALID_GPIO) {
660 ret = gpio_request(camera_reset, "camera reset");
662 goto sensor_io_int_loop_end;
663 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
664 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
665 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
667 //printk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
671 if (camera_powerdown != INVALID_GPIO) {
672 ret = gpio_request(camera_powerdown, "camera powerdown");
674 goto sensor_io_int_loop_end;
675 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
676 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
677 gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
679 //printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
683 if (camera_flash != INVALID_GPIO) {
684 ret = gpio_request(camera_flash, "camera flash");
686 goto sensor_io_int_loop_end;
687 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
688 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
689 gpio_direction_output(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
691 //printk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
695 sensor_io_int_loop_end:
696 rk29_sensor_io_deinit(i);
703 static int rk29_sensor_io_deinit(int sensor)
705 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
706 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
708 camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
709 camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
710 camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
711 camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
713 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
714 if (camera_power != INVALID_GPIO) {
715 gpio_direction_input(camera_power);
716 gpio_free(camera_power);
720 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
721 if (camera_reset != INVALID_GPIO) {
722 gpio_direction_input(camera_reset);
723 gpio_free(camera_reset);
727 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
728 if (camera_powerdown != INVALID_GPIO) {
729 gpio_direction_input(camera_powerdown);
730 gpio_free(camera_powerdown);
734 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
735 if (camera_flash != INVALID_GPIO) {
736 gpio_direction_input(camera_flash);
737 gpio_free(camera_flash);
741 rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
744 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
746 unsigned int camera_power=INVALID_GPIO,camera_reset=INVALID_GPIO, camera_powerdown=INVALID_GPIO,camera_flash = INVALID_GPIO;
747 unsigned int camera_ioflag,camera_io_init;
748 int ret = RK29_CAM_IO_SUCCESS;
750 if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
751 camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
752 camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
753 camera_powerdown = rk29_camera_platform_data.gpio_res[0].gpio_powerdown;
754 camera_flash = rk29_camera_platform_data.gpio_res[0].gpio_flash;
755 camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
756 camera_io_init = rk29_camera_platform_data.gpio_res[0].gpio_init;
757 } 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)) {
758 camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
759 camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
760 camera_powerdown = rk29_camera_platform_data.gpio_res[1].gpio_powerdown;
761 camera_flash = rk29_camera_platform_data.gpio_res[1].gpio_flash;
762 camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
763 camera_io_init = rk29_camera_platform_data.gpio_res[1].gpio_init;
770 if (camera_power != INVALID_GPIO) {
771 if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
773 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
774 //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));
777 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
778 //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));
781 ret = RK29_CAM_EIO_REQUESTFAIL;
782 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
785 ret = RK29_CAM_EIO_INVALID;
791 if (camera_reset != INVALID_GPIO) {
792 if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
794 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
795 //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));
797 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
798 //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));
801 ret = RK29_CAM_EIO_REQUESTFAIL;
802 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
805 ret = RK29_CAM_EIO_INVALID;
812 if (camera_powerdown != INVALID_GPIO) {
813 if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
815 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
816 //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));
818 gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
819 //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));
822 ret = RK29_CAM_EIO_REQUESTFAIL;
823 printk("\n%s..%s..PowerDownPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_powerdown);
826 ret = RK29_CAM_EIO_INVALID;
833 if (camera_flash != INVALID_GPIO) {
834 if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
836 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
837 //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));
839 gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
840 //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));
843 ret = RK29_CAM_EIO_REQUESTFAIL;
844 printk("\n%s..%s..FlashPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_flash);
847 ret = RK29_CAM_EIO_INVALID;
854 printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
860 static int rk29_sensor_power(struct device *dev, int on)
862 rk29_sensor_ioctrl(dev,Cam_Power,on);
865 static int rk29_sensor_reset(struct device *dev)
867 rk29_sensor_ioctrl(dev,Cam_Reset,1);
869 rk29_sensor_ioctrl(dev,Cam_Reset,0);
872 static int rk29_sensor_powerdown(struct device *dev, int on)
874 return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
876 #if (SENSOR_IIC_ADDR_0 != 0x00)
877 static struct i2c_board_info rk29_i2c_cam_info_0[] = {
879 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
883 struct soc_camera_link rk29_iclink_0 = {
884 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
885 .power = rk29_sensor_power,
886 .powerdown = rk29_sensor_powerdown,
887 .board_info = &rk29_i2c_cam_info_0[0],
888 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
889 .module_name = SENSOR_NAME_0,
892 /*platform_device : soc-camera need */
893 struct platform_device rk29_soc_camera_pdrv_0 = {
894 .name = "soc-camera-pdrv",
897 .init_name = SENSOR_NAME_0,
898 .platform_data = &rk29_iclink_0,
902 static struct i2c_board_info rk29_i2c_cam_info_1[] = {
904 I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
908 struct soc_camera_link rk29_iclink_1 = {
909 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
910 .power = rk29_sensor_power,
911 .powerdown = rk29_sensor_powerdown,
912 .board_info = &rk29_i2c_cam_info_1[0],
913 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
914 .module_name = SENSOR_NAME_1,
917 /*platform_device : soc-camera need */
918 struct platform_device rk29_soc_camera_pdrv_1 = {
919 .name = "soc-camera-pdrv",
922 .init_name = SENSOR_NAME_1,
923 .platform_data = &rk29_iclink_1,
928 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
929 struct resource rk29_camera_resource[] = {
931 .start = RK29_VIP_PHYS,
932 .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
933 .flags = IORESOURCE_MEM,
938 .flags = IORESOURCE_IRQ,
942 /*platform_device : */
943 struct platform_device rk29_device_camera = {
944 .name = RK29_CAM_DRV_NAME,
945 .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
946 .num_resources = ARRAY_SIZE(rk29_camera_resource),
947 .resource = rk29_camera_resource,
949 .dma_mask = &rockchip_device_camera_dmamask,
950 .coherent_dma_mask = 0xffffffffUL,
951 .platform_data = &rk29_camera_platform_data,
955 /*****************************************************************************************
957 * author: nzy@rock-chips.com
958 *****************************************************************************************/
959 #ifdef CONFIG_BACKLIGHT_RK29_BL
961 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
962 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
963 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
964 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
968 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
969 #define PWM_MUX_MODE GPIO1L_PWM0
970 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
971 #define PWM_EFFECT_VALUE 1
973 //#define LCD_DISP_ON_PIN
975 #ifdef LCD_DISP_ON_PIN
976 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
977 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
979 #define BL_EN_PIN GPIO0L_GPIO0A5
980 #define BL_EN_VALUE GPIO_HIGH
982 static int rk29_backlight_io_init(void)
986 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
987 #ifdef LCD_DISP_ON_PIN
988 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
990 ret = gpio_request(BL_EN_PIN, NULL);
993 gpio_free(BL_EN_PIN);
996 gpio_direction_output(BL_EN_PIN, 0);
997 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1002 static int rk29_backlight_io_deinit(void)
1005 #ifdef LCD_DISP_ON_PIN
1006 gpio_free(BL_EN_PIN);
1008 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1011 struct rk29_bl_info rk29_bl_info = {
1013 .bl_ref = PWM_EFFECT_VALUE,
1014 .io_init = rk29_backlight_io_init,
1015 .io_deinit = rk29_backlight_io_deinit,
1018 /*****************************************************************************************
1019 * pwm voltage regulator devices
1020 ******************************************************************************************/
1021 #if defined (CONFIG_RK29_PWM_REGULATOR)
1023 #define REGULATOR_PWM_ID 2
1024 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1025 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1026 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1027 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1029 static struct regulator_consumer_supply pwm_consumers[] = {
1035 static struct regulator_init_data rk29_pwm_regulator_data = {
1041 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1043 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1044 .consumer_supplies = pwm_consumers,
1047 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1048 .pwm_id = REGULATOR_PWM_ID,
1049 .pwm_gpio = REGULATOR_PWM_GPIO,
1050 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1051 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1052 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1053 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1054 .init_data = &rk29_pwm_regulator_data,
1057 static struct platform_device rk29_device_pwm_regulator = {
1058 .name = "pwm-voltage-regulator",
1061 .platform_data = &rk29_regulator_pwm_platform_data,
1067 /*****************************************************************************************
1069 *****************************************************************************************/
1070 #ifdef CONFIG_SDMMC0_RK29
1071 static int rk29_sdmmc0_cfg_gpio(void)
1073 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1074 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1075 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1076 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1077 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1078 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1079 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
1080 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1081 gpio_request(RK29_PIN5_PD5,"sdmmc");
1082 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1084 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1088 #define CONFIG_SDMMC0_USE_DMA
1089 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1090 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1091 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1092 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1093 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1094 .io_init = rk29_sdmmc0_cfg_gpio,
1095 .dma_name = "sd_mmc",
1096 #ifdef CONFIG_SDMMC0_USE_DMA
1103 #ifdef CONFIG_SDMMC1_RK29
1104 #define CONFIG_SDMMC1_USE_DMA
1105 static int rk29_sdmmc1_cfg_gpio(void)
1107 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1108 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1109 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1110 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1111 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1112 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1113 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1117 #ifdef CONFIG_WIFI_CONTROL_FUNC
1118 static int rk29sdk_wifi_status(struct device *dev);
1119 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1122 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1124 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1125 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1126 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1127 MMC_VDD_32_33|MMC_VDD_33_34),
1128 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1129 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1130 .io_init = rk29_sdmmc1_cfg_gpio,
1132 #ifdef CONFIG_SDMMC1_USE_DMA
1137 #ifdef CONFIG_WIFI_CONTROL_FUNC
1138 .status = rk29sdk_wifi_status,
1139 .register_status_notify = rk29sdk_wifi_status_register,
1142 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1147 #ifdef CONFIG_WIFI_CONTROL_FUNC
1148 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1149 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1150 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1152 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1153 static void (*wifi_status_cb)(int card_present, void *dev_id);
1154 static void *wifi_status_cb_devid;
1155 int rk29sdk_wifi_power_state = 0;
1156 int rk29sdk_bt_power_state = 0;
1158 static int rk29sdk_wifi_status(struct device *dev)
1160 return rk29sdk_wifi_cd;
1163 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1167 wifi_status_cb = callback;
1168 wifi_status_cb_devid = dev_id;
1172 static int rk29sdk_wifi_bt_gpio_control_init(void)
1174 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1175 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1179 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1180 pr_info("%s: request wifi reset gpio failed\n", __func__);
1181 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1185 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1186 pr_info("%s: request bt reset gpio failed\n", __func__);
1187 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1191 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1192 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1193 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1195 pr_info("%s: init finished\n",__func__);
1200 static int rk29sdk_wifi_power(int on)
1202 pr_info("%s: %d\n", __func__, on);
1204 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
1206 pr_info("wifi turn on power\n");
1208 if (!rk29sdk_bt_power_state){
1209 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
1211 pr_info("wifi shut off power\n");
1214 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1219 rk29sdk_wifi_power_state = on;
1223 static int rk29sdk_wifi_reset_state;
1224 static int rk29sdk_wifi_reset(int on)
1226 pr_info("%s: %d\n", __func__, on);
1227 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1229 rk29sdk_wifi_reset_state = on;
1233 static int rk29sdk_wifi_set_carddetect(int val)
1235 pr_info("%s:%d\n", __func__, val);
1236 rk29sdk_wifi_cd = val;
1237 if (wifi_status_cb){
1238 wifi_status_cb(val, wifi_status_cb_devid);
1240 pr_warning("%s, nobody to notify\n", __func__);
1245 static struct wifi_platform_data rk29sdk_wifi_control = {
1246 .set_power = rk29sdk_wifi_power,
1247 .set_reset = rk29sdk_wifi_reset,
1248 .set_carddetect = rk29sdk_wifi_set_carddetect,
1250 static struct platform_device rk29sdk_wifi_device = {
1251 .name = "bcm4329_wlan",
1254 .platform_data = &rk29sdk_wifi_control,
1260 /* bluetooth rfkill device */
1261 static struct platform_device rk29sdk_rfkill = {
1262 .name = "rk29sdk_rfkill",
1267 #ifdef CONFIG_VIVANTE
1268 static struct resource resources_gpu[] = {
1273 .flags = IORESOURCE_IRQ,
1277 .start = RK29_GPU_PHYS,
1278 .end = RK29_GPU_PHYS + RK29_GPU_PHYS_SIZE,
1279 .flags = IORESOURCE_MEM,
1283 .start = PMEM_GPU_BASE,
1284 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE,
1285 .flags = IORESOURCE_MEM,
1288 struct platform_device rk29_device_gpu = {
1291 .num_resources = ARRAY_SIZE(resources_gpu),
1292 .resource = resources_gpu,
1295 #ifdef CONFIG_KEYS_RK29
1296 extern struct rk29_keys_platform_data rk29_keys_pdata;
1297 static struct platform_device rk29_device_keys = {
1298 .name = "rk29-keypad",
1301 .platform_data = &rk29_keys_pdata,
1306 static void __init rk29_board_iomux_init(void)
1308 #ifdef CONFIG_UART0_RK29
1309 rk29_mux_api_set(GPIO1B7_UART0SOUT_NAME, GPIO1L_UART0_SOUT);
1310 rk29_mux_api_set(GPIO1B6_UART0SIN_NAME, GPIO1L_UART0_SIN);
1311 #ifdef CONFIG_UART0_CTS_RTS_RK29
1312 rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N);
1313 rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_UART0_CTS_N);
1316 #ifdef CONFIG_UART1_RK29
1317 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
1318 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
1320 #ifdef CONFIG_UART2_RK29
1321 rk29_mux_api_set(GPIO2B1_UART2SOUT_NAME, GPIO2L_UART2_SOUT);
1322 rk29_mux_api_set(GPIO2B0_UART2SIN_NAME, GPIO2L_UART2_SIN);
1323 #ifdef CONFIG_UART2_CTS_RTS_RK29
1324 rk29_mux_api_set(GPIO2A7_UART2RTSN_NAME, GPIO2L_UART2_RTS_N);
1325 rk29_mux_api_set(GPIO2A6_UART2CTSN_NAME, GPIO2L_UART2_CTS_N);
1328 #ifdef CONFIG_UART3_RK29
1329 rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
1330 rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
1331 #ifdef CONFIG_UART3_CTS_RTS_RK29
1332 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_UART3_RTS_N);
1333 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_UART3_CTS_N);
1336 #ifdef CONFIG_SPIM0_RK29
1337 rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME, GPIO2H_SPI0_CLK);
1338 rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME, GPIO2H_SPI0_CSN0);
1339 rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME, GPIO2H_SPI0_TXD);
1340 rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME, GPIO2H_SPI0_RXD);
1342 #ifdef CONFIG_SPIM1_RK29
1343 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK);
1344 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME, GPIO2H_SPI1_CSN0);
1345 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME, GPIO2H_SPI1_TXD);
1346 rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME, GPIO2H_SPI1_RXD);
1348 #ifdef CONFIG_RK29_VMAC
1349 rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME, GPIO4H_RMII_CLKOUT);
1350 rk29_mux_api_set(GPIO4C1_RMIITXEN_MIITXEN_NAME, GPIO4H_RMII_TX_EN);
1351 rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME, GPIO4H_RMII_TXD1);
1352 rk29_mux_api_set(GPIO4C3_RMIITXD0_MIITXD0_NAME, GPIO4H_RMII_TXD0);
1353 rk29_mux_api_set(GPIO4C4_RMIIRXERR_MIIRXERR_NAME, GPIO4H_RMII_RX_ERR);
1354 rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME, GPIO4H_RMII_CSR_DVALID);
1355 rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME, GPIO4H_RMII_RXD1);
1356 rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME, GPIO4H_RMII_RXD0);
1358 rk29_mux_api_set(GPIO0A7_MIIMDCLK_NAME, GPIO0L_MII_MDCLK);
1359 rk29_mux_api_set(GPIO0A6_MIIMD_NAME, GPIO0L_MII_MD);
1361 #ifdef CONFIG_RK29_PWM_REGULATOR
1362 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1366 static struct platform_device *devices[] __initdata = {
1367 #ifdef CONFIG_UART1_RK29
1370 #ifdef CONFIG_UART0_RK29
1373 #ifdef CONFIG_UART2_RK29
1377 #ifdef CONFIG_RK29_PWM_REGULATOR
1378 &rk29_device_pwm_regulator,
1380 #ifdef CONFIG_SPIM0_RK29
1381 &rk29xx_device_spi0m,
1383 #ifdef CONFIG_SPIM1_RK29
1384 &rk29xx_device_spi1m,
1386 #ifdef CONFIG_ADC_RK29
1389 #ifdef CONFIG_I2C0_RK29
1392 #ifdef CONFIG_I2C1_RK29
1395 #ifdef CONFIG_I2C2_RK29
1398 #ifdef CONFIG_I2C3_RK29
1402 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1403 &rk29_device_iis_2ch,
1405 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1406 &rk29_device_iis_8ch,
1409 #ifdef CONFIG_KEYS_RK29
1412 #ifdef CONFIG_SDMMC0_RK29
1413 &rk29_device_sdmmc0,
1415 #ifdef CONFIG_SDMMC1_RK29
1416 &rk29_device_sdmmc1,
1419 #ifdef CONFIG_MTD_NAND_RK29XX
1420 &rk29xx_device_nand,
1423 #ifdef CONFIG_WIFI_CONTROL_FUNC
1424 &rk29sdk_wifi_device,
1431 #ifdef CONFIG_MTD_NAND_RK29
1435 #ifdef CONFIG_FB_RK29
1438 #ifdef CONFIG_BACKLIGHT_RK29_BL
1439 &rk29_device_backlight,
1441 #ifdef CONFIG_RK29_VMAC
1444 #ifdef CONFIG_VIVANTE
1447 #ifdef CONFIG_VIDEO_RK29
1448 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1449 #if (SENSOR_IIC_ADDR_0 != 0x00)
1450 &rk29_soc_camera_pdrv_0,
1452 &rk29_soc_camera_pdrv_1,
1453 &android_pmem_cam_device,
1455 &android_pmem_device,
1456 &rk29_vpu_mem_device,
1457 #ifdef CONFIG_USB20_OTG
1458 &rk29_device_usb20_otg,
1460 #ifdef CONFIG_USB20_HOST
1461 &rk29_device_usb20_host,
1463 #ifdef CONFIG_USB11_HOST
1464 &rk29_device_usb11_host,
1466 #ifdef CONFIG_USB_ANDROID
1467 &android_usb_device,
1468 &usb_mass_storage_device,
1470 #ifdef CONFIG_RK29_IPP
1475 /*****************************************************************************************
1477 * author: cmc@rock-chips.com
1478 *****************************************************************************************/
1479 static int rk29_vmac_register_set(void)
1481 //config rk29 vmac as rmii, 100MHz
1482 u32 value= readl(RK29_GRF_BASE + 0xbc);
1483 value = (value & 0xfff7ff) | (0x400);
1484 writel(value, RK29_GRF_BASE + 0xbc);
1488 static int rk29_rmii_io_init(void)
1493 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
1495 gpio_free(RK29_PIN6_PB0);
1496 printk("-------request RK29_PIN6_PB0 fail--------\n");
1500 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1501 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1506 static int rk29_rmii_io_deinit(void)
1509 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1510 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1512 gpio_free(RK29_PIN6_PB0);
1516 static int rk29_rmii_power_control(int enable)
1520 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
1521 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
1524 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1525 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1530 struct rk29_vmac_platform_data rk29_vmac_pdata = {
1531 .vmac_register_set = rk29_vmac_register_set,
1532 .rmii_io_init = rk29_rmii_io_init,
1533 .rmii_io_deinit = rk29_rmii_io_deinit,
1534 .rmii_power_control = rk29_rmii_power_control,
1537 /*****************************************************************************************
1539 * author: cmc@rock-chips.com
1540 *****************************************************************************************/
1541 #define SPI_CHIPSELECT_NUM 2
1542 struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
1545 .cs_gpio = RK29_PIN2_PC1,
1546 .cs_iomux_name = NULL,
1550 .cs_gpio = RK29_PIN1_PA4,
1551 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
1552 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
1556 struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
1559 .cs_gpio = RK29_PIN2_PC5,
1560 .cs_iomux_name = NULL,
1564 .cs_gpio = RK29_PIN1_PA3,
1565 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
1566 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
1570 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
1577 for (i=0; i<cs_num; i++) {
1578 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
1579 ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
1582 gpio_free(cs_gpios[j].cs_gpio);
1583 //rk29_mux_api_mode_resume(cs_gpios[j].cs_iomux_name);
1585 printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
1588 gpio_direction_output(cs_gpios[i].cs_gpio, GPIO_HIGH);
1595 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
1601 for (i=0; i<cs_num; i++) {
1602 gpio_free(cs_gpios[i].cs_gpio);
1603 //rk29_mux_api_mode_resume(cs_gpios[i].cs_iomux_name);
1610 static int spi_io_fix_leakage_bug(void)
1613 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
1618 static int spi_io_resume_leakage_bug(void)
1621 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
1626 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
1627 .num_chipselect = SPI_CHIPSELECT_NUM,
1628 .chipselect_gpios = rk29xx_spi0_cs_gpios,
1629 .io_init = spi_io_init,
1630 .io_deinit = spi_io_deinit,
1631 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1632 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1635 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
1636 .num_chipselect = SPI_CHIPSELECT_NUM,
1637 .chipselect_gpios = rk29xx_spi1_cs_gpios,
1638 .io_init = spi_io_init,
1639 .io_deinit = spi_io_deinit,
1640 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1641 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1644 /*****************************************************************************************
1645 * xpt2046 touch panel
1646 * author: cmc@rock-chips.com
1647 *****************************************************************************************/
1648 #define XPT2046_GPIO_INT RK29_PIN0_PA3
1649 #define DEBOUNCE_REPTIME 3
1651 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
1652 static struct xpt2046_platform_data xpt2046_info = {
1661 .debounce_rep = DEBOUNCE_REPTIME,
1663 .gpio_pendown = XPT2046_GPIO_INT,
1664 .penirq_recheck_delay_usecs = 1,
1666 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
1667 static struct xpt2046_platform_data xpt2046_info = {
1676 .debounce_rep = DEBOUNCE_REPTIME,
1678 .gpio_pendown = XPT2046_GPIO_INT,
1679 .penirq_recheck_delay_usecs = 1,
1681 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
1682 static struct xpt2046_platform_data xpt2046_info = {
1691 .debounce_rep = DEBOUNCE_REPTIME,
1693 .gpio_pendown = XPT2046_GPIO_INT,
1695 .penirq_recheck_delay_usecs = 1,
1697 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1698 static struct xpt2046_platform_data xpt2046_info = {
1707 .debounce_rep = DEBOUNCE_REPTIME,
1709 .gpio_pendown = XPT2046_GPIO_INT,
1711 .penirq_recheck_delay_usecs = 1,
1715 static struct spi_board_info board_spi_devices[] = {
1716 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
1717 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1719 .modalias = "xpt2046_ts",
1721 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
1723 .irq = XPT2046_GPIO_INT,
1724 .platform_data = &xpt2046_info,
1730 static void __init rk29_gic_init_irq(void)
1732 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
1733 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
1736 static void __init machine_rk29_init_irq(void)
1738 rk29_gic_init_irq();
1742 #define POWER_ON_PIN RK29_PIN4_PA4
1743 static void rk29_pm_power_off(void)
1745 printk(KERN_ERR "rk29_pm_power_off start...\n");
1746 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1750 static void __init machine_rk29_board_init(void)
1752 rk29_board_iomux_init();
1754 gpio_request(POWER_ON_PIN,"poweronpin");
1755 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
1756 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1757 pm_power_off = rk29_pm_power_off;
1759 #ifdef CONFIG_WIFI_CONTROL_FUNC
1760 rk29sdk_wifi_bt_gpio_control_init();
1763 platform_add_devices(devices, ARRAY_SIZE(devices));
1764 #ifdef CONFIG_I2C0_RK29
1765 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
1766 ARRAY_SIZE(board_i2c0_devices));
1768 #ifdef CONFIG_I2C1_RK29
1769 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
1770 ARRAY_SIZE(board_i2c1_devices));
1772 #ifdef CONFIG_I2C2_RK29
1773 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
1774 ARRAY_SIZE(board_i2c2_devices));
1776 #ifdef CONFIG_I2C3_RK29
1777 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
1778 ARRAY_SIZE(board_i2c3_devices));
1781 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1784 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
1785 char **cmdline, struct meminfo *mi)
1788 mi->bank[0].start = RK29_SDRAM_PHYS;
1789 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
1790 mi->bank[0].size = LINUX_SIZE;
1793 static void __init machine_rk29_mapio(void)
1795 rk29_map_common_io();
1800 MACHINE_START(RK29, "RK29board")
1801 /* UART for LL DEBUG */
1802 .phys_io = RK29_UART1_PHYS,
1803 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
1804 .boot_params = RK29_SDRAM_PHYS + 0x88000,
1805 .fixup = machine_rk29_fixup,
1806 .map_io = machine_rk29_mapio,
1807 .init_irq = machine_rk29_init_irq,
1808 .init_machine = machine_rk29_board_init,
1809 .timer = &rk29_timer,