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>
45 #include <mach/sram.h>
47 #include <linux/regulator/rk29-pwm-regulator.h>
48 #include <linux/regulator/machine.h>
50 #include <linux/mtd/nand.h>
51 #include <linux/mtd/partitions.h>
54 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
57 /* Set memory size of pmem */
58 #ifdef CONFIG_RK29_MEM_SIZE_M
59 #define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
61 #define SDRAM_SIZE SZ_512M
63 #define PMEM_GPU_SIZE SZ_64M
64 #define PMEM_UI_SIZE SZ_32M
65 #define PMEM_VPU_SIZE SZ_64M
66 #define PMEM_CAM_SIZE 0x01300000
67 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
68 #define MEM_CAMIPP_SIZE SZ_4M
70 #define MEM_CAMIPP_SIZE 0
72 #define MEM_FB_SIZE (3*SZ_2M)
73 #ifdef CONFIG_FB_WORK_IPP
74 #define MEM_FBIPP_SIZE SZ_8M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4
76 #define MEM_FBIPP_SIZE 0
78 #define PMEM_GPU_BASE ((u32)RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
79 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
80 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
81 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
82 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
83 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
84 #define MEM_FBIPP_BASE (MEM_FB_BASE - MEM_FBIPP_SIZE)
85 #define LINUX_SIZE (MEM_FBIPP_BASE - RK29_SDRAM_PHYS)
87 #define PREALLOC_WLAN_SEC_NUM 4
88 #define PREALLOC_WLAN_BUF_NUM 160
89 #define PREALLOC_WLAN_SECTION_HEADER 24
91 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
92 #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
93 #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
94 #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
96 #define WLAN_SKB_BUF_NUM 16
98 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
100 struct wifi_mem_prealloc {
105 extern struct sys_timer rk29_timer;
107 static int rk29_nand_io_init(void)
112 struct rk29_nand_platform_data rk29_nand_data = {
113 .width = 1, /* data bus width in bytes */
114 .hw_ecc = 1, /* hw ecc 0: soft ecc */
116 .io_init = rk29_nand_io_init,
119 #ifdef CONFIG_FB_RK29
120 /*****************************************************************************************
122 * author: zyw@rock-chips.com
123 *****************************************************************************************/
124 //#ifdef CONFIG_LCD_TD043MGEA1
125 #define LCD_TXD_PIN INVALID_GPIO
126 #define LCD_CLK_PIN INVALID_GPIO
127 #define LCD_CS_PIN INVALID_GPIO
128 /*****************************************************************************************
129 * frame buffe devices
130 * author: zyw@rock-chips.com
131 *****************************************************************************************/
133 #define FB_DISPLAY_ON_PIN RK29_PIN6_PD0
134 #define FB_LCD_STANDBY_PIN INVALID_GPIO
135 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
136 #define FB_MCU_FMK_PIN INVALID_GPIO
138 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
139 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
142 /*****************************************************************************************
143 * touch screen devices
144 * author: cf@rock-chips.com
145 *****************************************************************************************/
146 #define TOUCH_SCREEN_STANDBY_PIN RK29_PIN6_PD1
147 #define TOUCH_SCREEN_STANDBY_VALUE GPIO_HIGH
149 static int rk29_lcd_io_init(void)
155 static int rk29_lcd_io_deinit(void)
161 static 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)
195 if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
197 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
200 gpio_free(FB_LCD_STANDBY_PIN);
201 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
206 ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL);
209 gpio_free(TOUCH_SCREEN_STANDBY_PIN);
210 printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n ");
212 gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0);
213 gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE);
217 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
219 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
222 gpio_free(FB_LCD_CABC_EN_PIN);
223 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
225 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
226 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
232 static struct rk29fb_info rk29_fb_info = {
234 .disp_on_pin = FB_DISPLAY_ON_PIN,
235 .disp_on_value = FB_DISPLAY_ON_VALUE,
236 .standby_pin = FB_LCD_STANDBY_PIN,
237 .standby_value = FB_LCD_STANDBY_VALUE,
238 .mcu_fmk_pin = FB_MCU_FMK_PIN,
239 .lcd_info = &rk29_lcd_info,
240 .io_init = rk29_fb_io_init,
243 /* rk29 fb resource */
244 static struct resource rk29_fb_resource[] = {
247 .start = RK29_LCDC_PHYS,
248 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
249 .flags = IORESOURCE_MEM,
255 .flags = IORESOURCE_IRQ,
259 .start = MEM_FB_BASE,
260 .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
261 .flags = IORESOURCE_MEM,
263 #ifdef CONFIG_FB_WORK_IPP
265 .name = "win1 ipp buf",
266 .start = MEM_FBIPP_BASE,
267 .end = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
268 .flags = IORESOURCE_MEM,
274 struct platform_device rk29_device_fb = {
277 .num_resources = ARRAY_SIZE(rk29_fb_resource),
278 .resource = rk29_fb_resource,
280 .platform_data = &rk29_fb_info,
284 struct platform_device rk29_device_dma_cpy = {
285 .name = "dma_memcpy",
292 static struct android_pmem_platform_data android_pmem_pdata = {
294 .start = PMEM_UI_BASE,
295 .size = PMEM_UI_SIZE,
300 static struct platform_device android_pmem_device = {
301 .name = "android_pmem",
304 .platform_data = &android_pmem_pdata,
309 static struct android_pmem_platform_data android_pmem_cam_pdata = {
311 .start = PMEM_CAM_BASE,
312 .size = PMEM_CAM_SIZE,
317 static struct platform_device android_pmem_cam_device = {
318 .name = "android_pmem",
321 .platform_data = &android_pmem_cam_pdata,
326 static struct vpu_mem_platform_data vpu_mem_pdata = {
328 .start = PMEM_VPU_BASE,
329 .size = PMEM_VPU_SIZE,
333 static struct platform_device rk29_vpu_mem_device = {
337 .platform_data = &vpu_mem_pdata,
341 static struct platform_device rk29_v4l2_output_devce = {
345 /*HANNSTAR_P1003 touch*/
346 #if defined (CONFIG_HANNSTAR_P1003)
347 #define TOUCH_RESET_PIN RK29_PIN6_PC3
348 #define TOUCH_INT_PIN RK29_PIN0_PA2
350 int p1003_init_platform_hw(void)
352 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
353 gpio_free(TOUCH_RESET_PIN);
354 printk("p1003_init_platform_hw gpio_request error\n");
358 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
359 gpio_free(TOUCH_INT_PIN);
360 printk("p1003_init_platform_hw gpio_request error\n");
363 gpio_pull_updown(TOUCH_INT_PIN, 1);
364 gpio_direction_output(TOUCH_RESET_PIN, 0);
366 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
368 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
374 struct p1003_platform_data p1003_info = {
376 .init_platform_hw= p1003_init_platform_hw,
380 #if defined (CONFIG_EETI_EGALAX)
381 #define TOUCH_RESET_PIN RK29_PIN6_PC3
382 #define TOUCH_INT_PIN RK29_PIN0_PA2
384 static int EETI_EGALAX_init_platform_hw(void)
386 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
387 gpio_free(TOUCH_RESET_PIN);
388 printk("p1003_init_platform_hw gpio_request error\n");
392 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
393 gpio_free(TOUCH_INT_PIN);
394 printk("p1003_init_platform_hw gpio_request error\n");
397 gpio_pull_updown(TOUCH_INT_PIN, 1);
398 gpio_direction_output(TOUCH_RESET_PIN, 0);
400 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
402 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
408 static struct eeti_egalax_platform_data eeti_egalax_info = {
410 .init_platform_hw= EETI_EGALAX_init_platform_hw,
411 .standby_pin = TOUCH_SCREEN_STANDBY_PIN,
412 .standby_value = TOUCH_SCREEN_STANDBY_VALUE,
416 #if defined (CONFIG_GS_MMA8452)
417 #define MMA8452_INT_PIN RK29_PIN0_PA3
419 static int mma8452_init_platform_hw(void)
422 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
423 gpio_free(MMA8452_INT_PIN);
424 printk("mma8452_init_platform_hw gpio_request error\n");
427 gpio_pull_updown(MMA8452_INT_PIN, 1);
432 static struct mma8452_platform_data mma8452_info = {
435 .init_platform_hw= mma8452_init_platform_hw,
440 #if defined (CONFIG_BATTERY_BQ27510)
441 #define DC_CHECK_PIN RK29_PIN4_PA1
442 #define LI_LION_BAT_NUM 2
443 static int bq27510_init_dc_check_pin(void){
444 if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
445 gpio_free(DC_CHECK_PIN);
446 printk("bq27510 init dc check pin request error\n");
449 gpio_direction_input(DC_CHECK_PIN);
453 struct bq27510_platform_data bq27510_info = {
454 .init_dc_check_pin = bq27510_init_dc_check_pin,
455 .dc_check_pin = DC_CHECK_PIN,
456 .bat_num = LI_LION_BAT_NUM,
461 /*****************************************************************************************
463 * author: kfx@rock-chips.com
464 *****************************************************************************************/
465 static int rk29_i2c0_io_init(void)
467 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
468 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
472 static int rk29_i2c1_io_init(void)
474 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
475 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
478 static int rk29_i2c2_io_init(void)
480 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
481 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
485 static int rk29_i2c3_io_init(void)
487 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
488 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
492 struct rk29_i2c_platform_data default_i2c0_data = {
496 .scl_rate = 400*1000,
497 .mode = I2C_MODE_IRQ,
498 .io_init = rk29_i2c0_io_init,
501 struct rk29_i2c_platform_data default_i2c1_data = {
505 .scl_rate = 400*1000,
506 .mode = I2C_MODE_POLL,
507 .io_init = rk29_i2c1_io_init,
510 struct rk29_i2c_platform_data default_i2c2_data = {
514 .scl_rate = 400*1000,
515 .mode = I2C_MODE_IRQ,
516 .io_init = rk29_i2c2_io_init,
519 struct rk29_i2c_platform_data default_i2c3_data = {
523 .scl_rate = 400*1000,
524 .mode = I2C_MODE_POLL,
525 .io_init = rk29_i2c3_io_init,
528 #ifdef CONFIG_I2C0_RK29
529 static struct i2c_board_info __initdata board_i2c0_devices[] = {
530 #if defined (CONFIG_RK1000_CONTROL)
532 .type = "rk1000_control",
537 #if defined (CONFIG_SND_SOC_RK1000)
539 .type = "rk1000_i2c_codec",
544 #if defined (CONFIG_SND_SOC_WM8900)
551 #if defined (CONFIG_BATTERY_STC3100)
558 #if defined (CONFIG_BATTERY_BQ27510)
563 .platform_data = &bq27510_info,
566 #if defined (CONFIG_RTC_HYM8563)
568 .type = "rtc_hym8563",
571 .irq = RK29_PIN0_PA1,
574 #if defined (CONFIG_GS_MMA8452)
576 .type = "gs_mma8452",
579 .irq = MMA8452_INT_PIN,
580 .platform_data = &mma8452_info,
583 #if defined (CONFIG_COMPASS_AK8973)
588 .irq = RK29_PIN0_PA4,
591 #if defined (CONFIG_COMPASS_AK8975)
596 .irq = RK29_PIN0_PA4,
602 #ifdef CONFIG_I2C1_RK29
603 static struct i2c_board_info __initdata board_i2c1_devices[] = {
604 #if defined (CONFIG_RK1000_CONTROL1)
606 .type = "rk1000_control",
611 #if defined (CONFIG_ANX7150)
614 .addr = 0x39, //0x39, 0x3d
616 .irq = RK29_PIN1_PD7,
623 #ifdef CONFIG_I2C2_RK29
624 static struct i2c_board_info __initdata board_i2c2_devices[] = {
625 #if defined (CONFIG_HANNSTAR_P1003)
627 .type = "p1003_touch",
630 .irq = RK29_PIN0_PA2,
631 .platform_data = &p1003_info,
634 #if defined (CONFIG_EETI_EGALAX)
636 .type = "egalax_i2c",
639 .irq = RK29_PIN0_PA2,
640 .platform_data = &eeti_egalax_info,
646 #ifdef CONFIG_I2C3_RK29
647 static struct i2c_board_info __initdata board_i2c3_devices[] = {
651 /*****************************************************************************************
653 * author: ddl@rock-chips.com
654 *****************************************************************************************/
655 #ifdef CONFIG_VIDEO_RK29
656 #define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_OV5642 /* back camera sensor */
657 #define SENSOR_IIC_ADDR_0 0x78
658 #define SENSOR_IIC_ADAPTER_ID_0 1
659 #define SENSOR_POWER_PIN_0 INVALID_GPIO
660 #define SENSOR_RESET_PIN_0 INVALID_GPIO
661 #define SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
662 #define SENSOR_FALSH_PIN_0 INVALID_GPIO
663 #define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
664 #define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
665 #define SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
666 #define SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
668 #define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_OV2659 /* front camera sensor */
669 #define SENSOR_IIC_ADDR_1 0x60
670 #define SENSOR_IIC_ADAPTER_ID_1 1
671 #define SENSOR_POWER_PIN_1 INVALID_GPIO
672 #define SENSOR_RESET_PIN_1 INVALID_GPIO
673 #define SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
674 #define SENSOR_FALSH_PIN_1 INVALID_GPIO
675 #define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
676 #define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
677 #define SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
678 #define SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
680 static int rk29_sensor_io_init(void);
681 static int rk29_sensor_io_deinit(int sensor);
682 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
684 static struct rk29camera_platform_data rk29_camera_platform_data = {
685 .io_init = rk29_sensor_io_init,
686 .io_deinit = rk29_sensor_io_deinit,
687 .sensor_ioctrl = rk29_sensor_ioctrl,
690 .gpio_reset = SENSOR_RESET_PIN_0,
691 .gpio_power = SENSOR_POWER_PIN_0,
692 .gpio_powerdown = SENSOR_POWERDN_PIN_0,
693 .gpio_flash = SENSOR_FALSH_PIN_0,
694 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0|SENSOR_POWERDNACTIVE_LEVEL_0|SENSOR_FLASHACTIVE_LEVEL_0),
696 .dev_name = SENSOR_NAME_0,
698 .gpio_reset = SENSOR_RESET_PIN_1,
699 .gpio_power = SENSOR_POWER_PIN_1,
700 .gpio_powerdown = SENSOR_POWERDN_PIN_1,
701 .gpio_flash = SENSOR_FALSH_PIN_1,
702 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1|SENSOR_POWERDNACTIVE_LEVEL_1|SENSOR_FLASHACTIVE_LEVEL_1),
704 .dev_name = SENSOR_NAME_1,
707 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
709 .name = "camera_ipp_mem",
710 .start = MEM_CAMIPP_BASE,
711 .size = MEM_CAMIPP_SIZE,
716 static int rk29_sensor_io_init(void)
719 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
720 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
721 unsigned int camera_ioflag;
723 for (i=0; i<2; i++) {
724 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
725 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
726 camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
727 camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
728 camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
729 rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
731 if (camera_power != INVALID_GPIO) {
732 ret = gpio_request(camera_power, "camera power");
734 goto sensor_io_int_loop_end;
735 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
736 gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
737 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
739 //printk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
743 if (camera_reset != INVALID_GPIO) {
744 ret = gpio_request(camera_reset, "camera reset");
746 goto sensor_io_int_loop_end;
747 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
748 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
749 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
751 //printk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
755 if (camera_powerdown != INVALID_GPIO) {
756 ret = gpio_request(camera_powerdown, "camera powerdown");
758 goto sensor_io_int_loop_end;
759 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
760 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
761 gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
763 //printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
767 if (camera_flash != INVALID_GPIO) {
768 ret = gpio_request(camera_flash, "camera flash");
770 goto sensor_io_int_loop_end;
771 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
772 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
773 gpio_direction_output(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
775 //printk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
779 sensor_io_int_loop_end:
780 rk29_sensor_io_deinit(i);
787 static int rk29_sensor_io_deinit(int sensor)
789 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
790 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
792 camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
793 camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
794 camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
795 camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
797 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
798 if (camera_power != INVALID_GPIO) {
799 gpio_direction_input(camera_power);
800 gpio_free(camera_power);
804 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
805 if (camera_reset != INVALID_GPIO) {
806 gpio_direction_input(camera_reset);
807 gpio_free(camera_reset);
811 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
812 if (camera_powerdown != INVALID_GPIO) {
813 gpio_direction_input(camera_powerdown);
814 gpio_free(camera_powerdown);
818 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
819 if (camera_flash != INVALID_GPIO) {
820 gpio_direction_input(camera_flash);
821 gpio_free(camera_flash);
825 rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
828 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
830 unsigned int camera_power=INVALID_GPIO,camera_reset=INVALID_GPIO, camera_powerdown=INVALID_GPIO,camera_flash = INVALID_GPIO;
831 unsigned int camera_ioflag,camera_io_init;
832 int ret = RK29_CAM_IO_SUCCESS;
834 if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
835 camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
836 camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
837 camera_powerdown = rk29_camera_platform_data.gpio_res[0].gpio_powerdown;
838 camera_flash = rk29_camera_platform_data.gpio_res[0].gpio_flash;
839 camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
840 camera_io_init = rk29_camera_platform_data.gpio_res[0].gpio_init;
841 } 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)) {
842 camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
843 camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
844 camera_powerdown = rk29_camera_platform_data.gpio_res[1].gpio_powerdown;
845 camera_flash = rk29_camera_platform_data.gpio_res[1].gpio_flash;
846 camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
847 camera_io_init = rk29_camera_platform_data.gpio_res[1].gpio_init;
854 if (camera_power != INVALID_GPIO) {
855 if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
857 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
858 //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));
861 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
862 //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));
865 ret = RK29_CAM_EIO_REQUESTFAIL;
866 printk("\n%s..%s..PowerPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
869 ret = RK29_CAM_EIO_INVALID;
875 if (camera_reset != INVALID_GPIO) {
876 if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
878 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
879 //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));
881 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
882 //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));
885 ret = RK29_CAM_EIO_REQUESTFAIL;
886 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
889 ret = RK29_CAM_EIO_INVALID;
896 if (camera_powerdown != INVALID_GPIO) {
897 if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
899 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
900 //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));
902 gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
903 //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));
906 ret = RK29_CAM_EIO_REQUESTFAIL;
907 printk("\n%s..%s..PowerDownPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_powerdown);
910 ret = RK29_CAM_EIO_INVALID;
917 if (camera_flash != INVALID_GPIO) {
918 if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
920 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
921 //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));
923 gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
924 //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));
927 ret = RK29_CAM_EIO_REQUESTFAIL;
928 printk("\n%s..%s..FlashPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_flash);
931 ret = RK29_CAM_EIO_INVALID;
938 printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
944 static int rk29_sensor_power(struct device *dev, int on)
946 rk29_sensor_ioctrl(dev,Cam_Power,on);
949 static int rk29_sensor_reset(struct device *dev)
951 rk29_sensor_ioctrl(dev,Cam_Reset,1);
953 rk29_sensor_ioctrl(dev,Cam_Reset,0);
956 static int rk29_sensor_powerdown(struct device *dev, int on)
958 return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
960 #if (SENSOR_IIC_ADDR_0 != 0x00)
961 static struct i2c_board_info rk29_i2c_cam_info_0[] = {
963 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
967 static struct soc_camera_link rk29_iclink_0 = {
968 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
969 .power = rk29_sensor_power,
970 .powerdown = rk29_sensor_powerdown,
971 .board_info = &rk29_i2c_cam_info_0[0],
972 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
973 .module_name = SENSOR_NAME_0,
976 /*platform_device : soc-camera need */
977 static struct platform_device rk29_soc_camera_pdrv_0 = {
978 .name = "soc-camera-pdrv",
981 .init_name = SENSOR_NAME_0,
982 .platform_data = &rk29_iclink_0,
986 static struct i2c_board_info rk29_i2c_cam_info_1[] = {
988 I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
992 static struct soc_camera_link rk29_iclink_1 = {
993 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
994 .power = rk29_sensor_power,
995 .powerdown = rk29_sensor_powerdown,
996 .board_info = &rk29_i2c_cam_info_1[0],
997 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
998 .module_name = SENSOR_NAME_1,
1001 /*platform_device : soc-camera need */
1002 static struct platform_device rk29_soc_camera_pdrv_1 = {
1003 .name = "soc-camera-pdrv",
1006 .init_name = SENSOR_NAME_1,
1007 .platform_data = &rk29_iclink_1,
1012 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
1013 static struct resource rk29_camera_resource[] = {
1015 .start = RK29_VIP_PHYS,
1016 .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
1017 .flags = IORESOURCE_MEM,
1022 .flags = IORESOURCE_IRQ,
1026 /*platform_device : */
1027 static struct platform_device rk29_device_camera = {
1028 .name = RK29_CAM_DRV_NAME,
1029 .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
1030 .num_resources = ARRAY_SIZE(rk29_camera_resource),
1031 .resource = rk29_camera_resource,
1033 .dma_mask = &rockchip_device_camera_dmamask,
1034 .coherent_dma_mask = 0xffffffffUL,
1035 .platform_data = &rk29_camera_platform_data,
1039 /*****************************************************************************************
1041 * author: nzy@rock-chips.com
1042 *****************************************************************************************/
1043 #ifdef CONFIG_BACKLIGHT_RK29_BL
1045 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
1046 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
1047 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
1048 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
1052 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
1053 #define PWM_MUX_MODE GPIO1L_PWM0
1054 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1055 #define PWM_GPIO RK29_PIN1_PB5
1056 #define PWM_EFFECT_VALUE 1
1058 //#define LCD_DISP_ON_PIN
1060 #ifdef LCD_DISP_ON_PIN
1061 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
1062 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
1064 #define BL_EN_PIN GPIO0L_GPIO0A5
1065 #define BL_EN_VALUE GPIO_HIGH
1067 static int rk29_backlight_io_init(void)
1071 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1072 #ifdef LCD_DISP_ON_PIN
1073 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
1075 ret = gpio_request(BL_EN_PIN, NULL);
1078 gpio_free(BL_EN_PIN);
1081 gpio_direction_output(BL_EN_PIN, 0);
1082 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1087 static int rk29_backlight_io_deinit(void)
1090 #ifdef LCD_DISP_ON_PIN
1091 gpio_free(BL_EN_PIN);
1093 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1097 static int rk29_backlight_pwm_suspend(void)
1100 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1101 if (ret = gpio_request(PWM_GPIO, NULL)) {
1102 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
1105 gpio_direction_output(PWM_GPIO, GPIO_LOW);
1109 static int rk29_backlight_pwm_resume(void)
1111 gpio_free(PWM_GPIO);
1112 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1116 struct rk29_bl_info rk29_bl_info = {
1118 .bl_ref = PWM_EFFECT_VALUE,
1119 .io_init = rk29_backlight_io_init,
1120 .io_deinit = rk29_backlight_io_deinit,
1121 .pwm_suspend = rk29_backlight_pwm_suspend,
1122 .pwm_resume = rk29_backlight_pwm_resume,
1125 /*****************************************************************************************
1126 * pwm voltage regulator devices
1127 ******************************************************************************************/
1128 #if defined (CONFIG_RK29_PWM_REGULATOR)
1130 #define REGULATOR_PWM_ID 2
1131 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1132 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
1133 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
1134 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
1136 static struct regulator_consumer_supply pwm_consumers[] = {
1142 static struct regulator_init_data rk29_pwm_regulator_data = {
1148 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1150 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1151 .consumer_supplies = pwm_consumers,
1154 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1155 .pwm_id = REGULATOR_PWM_ID,
1156 .pwm_gpio = REGULATOR_PWM_GPIO,
1157 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1158 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1159 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1160 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1161 .init_data = &rk29_pwm_regulator_data,
1164 static struct platform_device rk29_device_pwm_regulator = {
1165 .name = "pwm-voltage-regulator",
1168 .platform_data = &rk29_regulator_pwm_platform_data,
1174 /*****************************************************************************************
1176 *****************************************************************************************/
1177 #ifdef CONFIG_SDMMC0_RK29
1178 static int rk29_sdmmc0_cfg_gpio(void)
1180 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1181 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1182 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1183 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1184 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1185 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1186 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
1187 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
1188 gpio_request(RK29_PIN5_PD5,"sdmmc");
1190 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1192 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1194 gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
1199 #define CONFIG_SDMMC0_USE_DMA
1200 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1201 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1202 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1203 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1204 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1205 .io_init = rk29_sdmmc0_cfg_gpio,
1206 .dma_name = "sd_mmc",
1207 #ifdef CONFIG_SDMMC0_USE_DMA
1212 .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
1213 .enable_sd_wakeup = 0,
1216 #ifdef CONFIG_SDMMC1_RK29
1217 #define CONFIG_SDMMC1_USE_DMA
1218 static int rk29_sdmmc1_cfg_gpio(void)
1220 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1221 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1222 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1223 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1224 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1225 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1226 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1230 #ifdef CONFIG_WIFI_CONTROL_FUNC
1231 static int rk29sdk_wifi_status(struct device *dev);
1232 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1235 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
1237 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1238 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1239 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1240 MMC_VDD_32_33|MMC_VDD_33_34),
1241 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1242 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1243 .io_init = rk29_sdmmc1_cfg_gpio,
1245 #ifdef CONFIG_SDMMC1_USE_DMA
1250 #ifdef CONFIG_WIFI_CONTROL_FUNC
1251 .status = rk29sdk_wifi_status,
1252 .register_status_notify = rk29sdk_wifi_status_register,
1255 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1260 #ifdef CONFIG_WIFI_CONTROL_FUNC
1261 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
1262 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
1263 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC4
1265 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
1266 static void (*wifi_status_cb)(int card_present, void *dev_id);
1267 static void *wifi_status_cb_devid;
1268 int rk29sdk_wifi_power_state = 0;
1269 int rk29sdk_bt_power_state = 0;
1271 static int rk29sdk_wifi_status(struct device *dev)
1273 return rk29sdk_wifi_cd;
1276 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1280 wifi_status_cb = callback;
1281 wifi_status_cb_devid = dev_id;
1285 static int rk29sdk_wifi_bt_gpio_control_init(void)
1287 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1288 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1292 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1293 pr_info("%s: request wifi reset gpio failed\n", __func__);
1294 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1298 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1299 pr_info("%s: request bt reset gpio failed\n", __func__);
1300 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1304 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1305 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1306 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
1308 pr_info("%s: init finished\n",__func__);
1313 static int rk29sdk_wifi_power(int on)
1315 pr_info("%s: %d\n", __func__, on);
1317 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
1318 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
1320 pr_info("wifi turn on power\n");
1322 if (!rk29sdk_bt_power_state){
1323 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1325 pr_info("wifi shut off power\n");
1328 pr_info("wifi shouldn't shut off power, bt is using it!\n");
1330 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1334 rk29sdk_wifi_power_state = on;
1338 static int rk29sdk_wifi_reset_state;
1339 static int rk29sdk_wifi_reset(int on)
1341 pr_info("%s: %d\n", __func__, on);
1342 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1344 rk29sdk_wifi_reset_state = on;
1348 int rk29sdk_wifi_set_carddetect(int val)
1350 pr_info("%s:%d\n", __func__, val);
1351 rk29sdk_wifi_cd = val;
1352 if (wifi_status_cb){
1353 wifi_status_cb(val, wifi_status_cb_devid);
1355 pr_warning("%s, nobody to notify\n", __func__);
1359 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
1361 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
1362 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
1363 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
1364 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
1365 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
1368 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
1370 if (section == PREALLOC_WLAN_SEC_NUM)
1371 return wlan_static_skb;
1373 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
1376 if (wifi_mem_array[section].size < size)
1379 return wifi_mem_array[section].mem_ptr;
1382 int __init rk29sdk_init_wifi_mem(void)
1387 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
1388 wlan_static_skb[i] = dev_alloc_skb(
1389 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
1391 if (!wlan_static_skb[i])
1395 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
1396 wifi_mem_array[i].mem_ptr =
1397 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
1399 if (!wifi_mem_array[i].mem_ptr)
1405 pr_err("Failed to mem_alloc for WLAN\n");
1406 for (j = 0 ; j < i ; j++)
1407 kfree(wifi_mem_array[j].mem_ptr);
1409 i = WLAN_SKB_BUF_NUM;
1412 pr_err("Failed to skb_alloc for WLAN\n");
1413 for (j = 0 ; j < i ; j++)
1414 dev_kfree_skb(wlan_static_skb[j]);
1419 static struct wifi_platform_data rk29sdk_wifi_control = {
1420 .set_power = rk29sdk_wifi_power,
1421 .set_reset = rk29sdk_wifi_reset,
1422 .set_carddetect = rk29sdk_wifi_set_carddetect,
1423 .mem_prealloc = rk29sdk_mem_prealloc,
1425 static struct platform_device rk29sdk_wifi_device = {
1426 .name = "bcm4329_wlan",
1429 .platform_data = &rk29sdk_wifi_control,
1435 /* bluetooth rfkill device */
1436 static struct platform_device rk29sdk_rfkill = {
1437 .name = "rk29sdk_rfkill",
1442 #ifdef CONFIG_VIVANTE
1443 static struct resource resources_gpu[] = {
1448 .flags = IORESOURCE_IRQ,
1452 .start = RK29_GPU_PHYS,
1453 .end = RK29_GPU_PHYS + RK29_GPU_SIZE,
1454 .flags = IORESOURCE_MEM,
1458 .start = PMEM_GPU_BASE,
1459 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE,
1460 .flags = IORESOURCE_MEM,
1463 static struct platform_device rk29_device_gpu = {
1466 .num_resources = ARRAY_SIZE(resources_gpu),
1467 .resource = resources_gpu,
1470 #ifdef CONFIG_KEYS_RK29
1471 extern struct rk29_keys_platform_data rk29_keys_pdata;
1472 static struct platform_device rk29_device_keys = {
1473 .name = "rk29-keypad",
1476 .platform_data = &rk29_keys_pdata,
1481 static void __init rk29_board_iomux_init(void)
1483 #ifdef CONFIG_RK29_PWM_REGULATOR
1484 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1488 static struct platform_device *devices[] __initdata = {
1489 #ifdef CONFIG_UART1_RK29
1492 #ifdef CONFIG_UART0_RK29
1495 #ifdef CONFIG_UART2_RK29
1498 #ifdef CONFIG_UART3_RK29
1502 #ifdef CONFIG_RK29_PWM_REGULATOR
1503 &rk29_device_pwm_regulator,
1505 #ifdef CONFIG_SPIM0_RK29
1506 &rk29xx_device_spi0m,
1508 #ifdef CONFIG_SPIM1_RK29
1509 &rk29xx_device_spi1m,
1511 #ifdef CONFIG_ADC_RK29
1514 #ifdef CONFIG_I2C0_RK29
1517 #ifdef CONFIG_I2C1_RK29
1520 #ifdef CONFIG_I2C2_RK29
1523 #ifdef CONFIG_I2C3_RK29
1527 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1528 &rk29_device_iis_2ch,
1530 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1531 &rk29_device_iis_8ch,
1534 #ifdef CONFIG_KEYS_RK29
1537 #ifdef CONFIG_SDMMC0_RK29
1538 &rk29_device_sdmmc0,
1540 #ifdef CONFIG_SDMMC1_RK29
1541 &rk29_device_sdmmc1,
1544 #ifdef CONFIG_MTD_NAND_RK29XX
1545 &rk29xx_device_nand,
1548 #ifdef CONFIG_WIFI_CONTROL_FUNC
1549 &rk29sdk_wifi_device,
1556 #ifdef CONFIG_MTD_NAND_RK29
1560 #ifdef CONFIG_FB_RK29
1562 &rk29_device_dma_cpy,
1564 #ifdef CONFIG_BACKLIGHT_RK29_BL
1565 &rk29_device_backlight,
1567 #ifdef CONFIG_RK29_VMAC
1570 #ifdef CONFIG_VIVANTE
1573 #ifdef CONFIG_VIDEO_RK29
1574 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
1575 #if (SENSOR_IIC_ADDR_0 != 0x00)
1576 &rk29_soc_camera_pdrv_0,
1578 &rk29_soc_camera_pdrv_1,
1579 &android_pmem_cam_device,
1581 &android_pmem_device,
1582 &rk29_vpu_mem_device,
1583 #ifdef CONFIG_USB20_OTG
1584 &rk29_device_usb20_otg,
1586 #ifdef CONFIG_USB20_HOST
1587 &rk29_device_usb20_host,
1589 #ifdef CONFIG_USB11_HOST
1590 &rk29_device_usb11_host,
1592 #ifdef CONFIG_USB_ANDROID
1593 &android_usb_device,
1594 &usb_mass_storage_device,
1596 #ifdef CONFIG_RK29_IPP
1599 #ifdef CONFIG_VIDEO_RK29XX_VOUT
1600 &rk29_v4l2_output_devce,
1604 /*****************************************************************************************
1606 * author: cmc@rock-chips.com
1607 *****************************************************************************************/
1608 static int rk29_vmac_register_set(void)
1610 //config rk29 vmac as rmii, 100MHz
1611 u32 value= readl(RK29_GRF_BASE + 0xbc);
1612 value = (value & 0xfff7ff) | (0x400);
1613 writel(value, RK29_GRF_BASE + 0xbc);
1617 static int rk29_rmii_io_init(void)
1622 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
1624 gpio_free(RK29_PIN6_PB0);
1625 printk("-------request RK29_PIN6_PB0 fail--------\n");
1629 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1630 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1635 static int rk29_rmii_io_deinit(void)
1638 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1639 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1641 gpio_free(RK29_PIN6_PB0);
1645 static int rk29_rmii_power_control(int enable)
1649 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
1650 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
1653 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1654 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1659 struct rk29_vmac_platform_data rk29_vmac_pdata = {
1660 .vmac_register_set = rk29_vmac_register_set,
1661 .rmii_io_init = rk29_rmii_io_init,
1662 .rmii_io_deinit = rk29_rmii_io_deinit,
1663 .rmii_power_control = rk29_rmii_power_control,
1666 /*****************************************************************************************
1668 * author: cmc@rock-chips.com
1669 *****************************************************************************************/
1670 #define SPI_CHIPSELECT_NUM 2
1671 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
1674 .cs_gpio = RK29_PIN2_PC1,
1675 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
1676 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
1680 .cs_gpio = RK29_PIN1_PA4,
1681 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
1682 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
1686 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
1689 .cs_gpio = RK29_PIN2_PC5,
1690 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
1691 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
1695 .cs_gpio = RK29_PIN1_PA3,
1696 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
1697 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
1701 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
1706 for (i=0; i<cs_num; i++) {
1707 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
1714 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
1719 static int spi_io_fix_leakage_bug(void)
1722 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
1727 static int spi_io_resume_leakage_bug(void)
1730 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
1735 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
1736 .num_chipselect = SPI_CHIPSELECT_NUM,
1737 .chipselect_gpios = rk29xx_spi0_cs_gpios,
1738 .io_init = spi_io_init,
1739 .io_deinit = spi_io_deinit,
1740 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1741 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1744 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
1745 .num_chipselect = SPI_CHIPSELECT_NUM,
1746 .chipselect_gpios = rk29xx_spi1_cs_gpios,
1747 .io_init = spi_io_init,
1748 .io_deinit = spi_io_deinit,
1749 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1750 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1753 /*****************************************************************************************
1754 * xpt2046 touch panel
1755 * author: cmc@rock-chips.com
1756 *****************************************************************************************/
1757 #define XPT2046_GPIO_INT RK29_PIN0_PA3
1758 #define DEBOUNCE_REPTIME 3
1760 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
1761 static struct xpt2046_platform_data xpt2046_info = {
1770 .debounce_rep = DEBOUNCE_REPTIME,
1772 .gpio_pendown = XPT2046_GPIO_INT,
1773 .penirq_recheck_delay_usecs = 1,
1775 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
1776 static struct xpt2046_platform_data xpt2046_info = {
1785 .debounce_rep = DEBOUNCE_REPTIME,
1787 .gpio_pendown = XPT2046_GPIO_INT,
1788 .penirq_recheck_delay_usecs = 1,
1790 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
1791 static struct xpt2046_platform_data xpt2046_info = {
1800 .debounce_rep = DEBOUNCE_REPTIME,
1802 .gpio_pendown = XPT2046_GPIO_INT,
1804 .penirq_recheck_delay_usecs = 1,
1806 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1807 static struct xpt2046_platform_data xpt2046_info = {
1816 .debounce_rep = DEBOUNCE_REPTIME,
1818 .gpio_pendown = XPT2046_GPIO_INT,
1820 .penirq_recheck_delay_usecs = 1,
1824 static struct spi_board_info board_spi_devices[] = {
1825 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
1826 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1828 .modalias = "xpt2046_ts",
1830 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
1832 .irq = XPT2046_GPIO_INT,
1833 .platform_data = &xpt2046_info,
1839 static void __init rk29_gic_init_irq(void)
1841 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
1842 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
1845 static void __init machine_rk29_init_irq(void)
1847 rk29_gic_init_irq();
1851 static void __init machine_rk29_board_init(void)
1853 rk29_board_iomux_init();
1857 platform_add_devices(devices, ARRAY_SIZE(devices));
1858 #ifdef CONFIG_I2C0_RK29
1859 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
1860 ARRAY_SIZE(board_i2c0_devices));
1862 #ifdef CONFIG_I2C1_RK29
1863 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
1864 ARRAY_SIZE(board_i2c1_devices));
1866 #ifdef CONFIG_I2C2_RK29
1867 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
1868 ARRAY_SIZE(board_i2c2_devices));
1870 #ifdef CONFIG_I2C3_RK29
1871 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
1872 ARRAY_SIZE(board_i2c3_devices));
1875 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1877 #ifdef CONFIG_WIFI_CONTROL_FUNC
1878 rk29sdk_wifi_bt_gpio_control_init();
1879 rk29sdk_init_wifi_mem();
1882 board_usb_detect_init(RK29_PIN0_PA0);
1885 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
1886 char **cmdline, struct meminfo *mi)
1889 mi->bank[0].start = RK29_SDRAM_PHYS;
1890 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
1891 mi->bank[0].size = LINUX_SIZE;
1894 static void __init machine_rk29_mapio(void)
1896 rk29_map_common_io();
1897 rk29_setup_early_printk();
1899 rk29_clock_init(periph_pll_300mhz);
1903 MACHINE_START(RK29, "RK29board")
1904 /* UART for LL DEBUG */
1905 .phys_io = RK29_UART1_PHYS,
1906 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
1907 .boot_params = RK29_SDRAM_PHYS + 0x88000,
1908 .fixup = machine_rk29_fixup,
1909 .map_io = machine_rk29_mapio,
1910 .init_irq = machine_rk29_init_irq,
1911 .init_machine = machine_rk29_board_init,
1912 .timer = &rk29_timer,