1 /* arch/arm/mach-rk29/board-rk29-phonesdk.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>
49 #include <linux/mfd/wm831x/pdata.h>
50 #include <linux/mfd/wm831x/core.h>
51 #include <linux/mfd/wm831x/gpio.h>
52 #include <linux/mfd/wm8994/pdata.h>
53 #include <linux/mfd/wm8994/registers.h>
55 #include <linux/mtd/nand.h>
56 #include <linux/mtd/partitions.h>
62 /*set touchscreen different type header*/
63 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI)
64 #include "../../../drivers/input/touchscreen/xpt2046_ts.h"
65 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
66 #include "../../../drivers/input/touchscreen/xpt2046_tslib_ts.h"
67 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
68 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
71 #include "../../../drivers/misc/gps/rk29_gps.h"
73 /* Set memory size of pmem */
74 #ifdef CONFIG_RK29_MEM_SIZE_M
75 #define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
77 #define SDRAM_SIZE SZ_512M
79 #define PMEM_GPU_SIZE SZ_64M
80 #define PMEM_UI_SIZE SZ_32M
81 #define PMEM_VPU_SIZE SZ_64M
82 #define PMEM_CAM_SIZE 0x01300000
83 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
84 #define MEM_CAMIPP_SIZE SZ_4M
86 #define MEM_CAMIPP_SIZE 0
88 #define MEM_FB_SIZE (3*SZ_2M)
90 #define PMEM_GPU_BASE ((u32)RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
91 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
92 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
93 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
94 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
95 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
96 #define LINUX_SIZE (MEM_FB_BASE - RK29_SDRAM_PHYS)
98 #define PREALLOC_WLAN_SEC_NUM 4
99 #define PREALLOC_WLAN_BUF_NUM 160
100 #define PREALLOC_WLAN_SECTION_HEADER 24
102 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
103 #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
104 #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
105 #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
107 #define WLAN_SKB_BUF_NUM 16
109 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
111 struct wifi_mem_prealloc {
116 extern struct sys_timer rk29_timer;
118 static int rk29_nand_io_init(void)
123 struct rk29_nand_platform_data rk29_nand_data = {
124 .width = 1, /* data bus width in bytes */
125 .hw_ecc = 1, /* hw ecc 0: soft ecc */
127 .io_init = rk29_nand_io_init,
130 #ifdef CONFIG_FB_RK29
131 /*****************************************************************************************
133 * author: zyw@rock-chips.com
134 *****************************************************************************************/
135 //#ifdef CONFIG_LCD_TD043MGEA1
136 #define LCD_RXD_PIN RK29_PIN2_PC7
137 #define LCD_TXD_PIN RK29_PIN2_PC6
138 #define LCD_CLK_PIN RK29_PIN2_PC4
139 #define LCD_CS_PIN RK29_PIN2_PC5
140 /*****************************************************************************************
141 * frame buffer devices
142 * author: zyw@rock-chips.com
143 *****************************************************************************************/
145 #define FB_DISPLAY_ON_PIN INVALID_GPIO//RK29_PIN6_PD0
146 #define FB_LCD_STANDBY_PIN INVALID_GPIO//RK29_PIN6_PD1
147 #define FB_LCD_CABC_EN_PIN INVALID_GPIO//RK29_PIN6_PD2
148 #define FB_MCU_FMK_PIN INVALID_GPIO
150 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
151 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
154 static int rk29_lcd_io_init(void)
157 //printk("rk29_lcd_io_init\n");
158 //ret = gpio_request(LCD_RXD_PIN, NULL);
159 ret = gpio_request(LCD_TXD_PIN, NULL);
160 ret = gpio_request(LCD_CLK_PIN, NULL);
161 ret = gpio_request(LCD_CS_PIN, NULL);
162 //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_GPIO2C7);
163 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_GPIO2C6);
164 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_GPIO2C5);
165 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_GPIO2C4);
169 static int rk29_lcd_io_deinit(void)
172 //printk("rk29_lcd_io_deinit\n");
173 gpio_free(LCD_CS_PIN);
174 gpio_free(LCD_CLK_PIN);
175 gpio_free(LCD_TXD_PIN);
176 //gpio_free(LCD_RXD_PIN);
177 //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_SPI1_RXD);
178 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_SPI1_TXD);
179 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_SPI1_CSN0);
180 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_SPI1_CLK);
184 static struct rk29lcd_info rk29_lcd_info = {
185 .txd_pin = LCD_TXD_PIN,
186 .clk_pin = LCD_CLK_PIN,
187 .cs_pin = LCD_CS_PIN,
188 .io_init = rk29_lcd_io_init,
189 .io_deinit = rk29_lcd_io_deinit,
193 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
196 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
198 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
201 gpio_free(FB_MCU_FMK_PIN);
202 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
204 gpio_direction_input(FB_MCU_FMK_PIN);
206 if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
208 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
211 gpio_free(FB_DISPLAY_ON_PIN);
212 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
216 if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
218 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
221 gpio_free(FB_LCD_STANDBY_PIN);
222 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
226 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
228 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
231 gpio_free(FB_LCD_CABC_EN_PIN);
232 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
234 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
235 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
241 static struct rk29fb_info rk29_fb_info = {
243 .disp_on_pin = FB_DISPLAY_ON_PIN,
244 .disp_on_value = FB_DISPLAY_ON_VALUE,
245 .standby_pin = FB_LCD_STANDBY_PIN,
246 .standby_value = FB_LCD_STANDBY_VALUE,
247 .mcu_fmk_pin = FB_MCU_FMK_PIN,
248 .lcd_info = &rk29_lcd_info,
249 .io_init = rk29_fb_io_init,
252 /* rk29 fb resource */
253 static struct resource rk29_fb_resource[] = {
256 .start = RK29_LCDC_PHYS,
257 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
258 .flags = IORESOURCE_MEM,
264 .flags = IORESOURCE_IRQ,
268 .start = MEM_FB_BASE,
269 .end = MEM_FB_BASE + MEM_FB_SIZE,
270 .flags = IORESOURCE_MEM,
275 struct platform_device rk29_device_fb = {
278 .num_resources = ARRAY_SIZE(rk29_fb_resource),
279 .resource = rk29_fb_resource,
281 .platform_data = &rk29_fb_info,
285 struct platform_device rk29_device_dma_cpy = {
286 .name = "dma_memcpy",
293 static struct android_pmem_platform_data android_pmem_pdata = {
295 .start = PMEM_UI_BASE,
296 .size = PMEM_UI_SIZE,
301 static struct platform_device android_pmem_device = {
302 .name = "android_pmem",
305 .platform_data = &android_pmem_pdata,
310 static struct android_pmem_platform_data android_pmem_cam_pdata = {
312 .start = PMEM_CAM_BASE,
313 .size = PMEM_CAM_SIZE,
318 static struct platform_device android_pmem_cam_device = {
319 .name = "android_pmem",
322 .platform_data = &android_pmem_cam_pdata,
327 static struct vpu_mem_platform_data vpu_mem_pdata = {
329 .start = PMEM_VPU_BASE,
330 .size = PMEM_VPU_SIZE,
334 static struct platform_device rk29_vpu_mem_device = {
338 .platform_data = &vpu_mem_pdata,
342 static struct platform_device rk29_v4l2_output_devce = {
346 /* HANNSTAR_P1003 touch I2C */
347 #if defined (CONFIG_HANNSTAR_P1003)
348 #define TOUCH_RESET_PIN RK29_PIN6_PC3
349 #define TOUCH_INT_PIN RK29_PIN4_PD5
351 int p1003_init_platform_hw(void)
353 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
354 gpio_free(TOUCH_RESET_PIN);
355 printk("p1003_init_platform_hw gpio_request error\n");
359 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
360 gpio_free(TOUCH_INT_PIN);
361 printk("p1003_init_platform_hw gpio_request error\n");
364 gpio_pull_updown(TOUCH_INT_PIN, 1);
365 gpio_direction_output(TOUCH_RESET_PIN, 0);
367 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
369 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
375 struct p1003_platform_data p1003_info = {
377 .init_platform_hw= p1003_init_platform_hw,
382 #if defined(CONFIG_TOUCHSCREEN_GT801_IIC)
383 #include "../../../drivers/input/touchscreen/gt801_ts.h"
384 #define GT801_GPIO_INT RK29_PIN4_PD5
385 #define GT801_GPIO_RESET RK29_PIN6_PC3
386 static struct gt801_platform_data gt801_info = {
393 .gpio_reset = GT801_GPIO_RESET,
394 .gpio_reset_active_low = 1,
395 .gpio_pendown = GT801_GPIO_INT,
396 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
397 .resetpin_iomux_name = NULL,
398 .pendown_iomux_mode = GPIO4H_GPIO4D5,
399 .resetpin_iomux_mode = 0,
403 /* EETI_EGALAX touch I2C */
404 #if defined (CONFIG_EETI_EGALAX)
405 #define TOUCH_RESET_PIN RK29_PIN6_PC3
406 #define TOUCH_INT_PIN RK29_PIN4_PD5
408 static int EETI_EGALAX_init_platform_hw(void)
410 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
411 gpio_free(TOUCH_RESET_PIN);
412 printk("p1003_init_platform_hw gpio_request error\n");
416 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
417 gpio_free(TOUCH_INT_PIN);
418 printk("p1003_init_platform_hw gpio_request error\n");
421 gpio_pull_updown(TOUCH_INT_PIN, 1);
422 gpio_direction_output(TOUCH_RESET_PIN, 0);
424 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
426 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
432 static struct eeti_egalax_platform_data eeti_egalax_info = {
434 .init_platform_hw= EETI_EGALAX_init_platform_hw,
440 #if defined (CONFIG_GS_MMA8452)
441 #define MMA8452_INT_PIN RK29_PIN6_PC4
443 static int mma8452_init_platform_hw(void)
446 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
447 gpio_free(MMA8452_INT_PIN);
448 printk("mma8452_init_platform_hw gpio_request error\n");
451 gpio_pull_updown(MMA8452_INT_PIN, 1);
456 static struct mma8452_platform_data mma8452_info = {
459 .init_platform_hw= mma8452_init_platform_hw,
464 #if defined(CONFIG_GPIO_WM831X)
465 struct rk29_gpio_expander_info wm831x_gpio_settinginfo[] = {
467 .gpio_num =WM831X_P01,// tp3
468 .pin_type = GPIO_OUT,
469 .pin_value =GPIO_HIGH,
473 .gpio_num =WM831X_P02,//tp4
474 .pin_type = GPIO_OUT,
475 .pin_value =GPIO_HIGH,
478 .gpio_num =WM831X_P03,//tp2
479 .pin_type = GPIO_OUT,
480 .pin_value =GPIO_HIGH,
483 .gpio_num =WM831X_P04,//tp1
484 .pin_type = GPIO_OUT,
485 .pin_value =GPIO_HIGH,
488 .gpio_num =WM831X_P05,//tp1
489 .pin_type = GPIO_OUT,
490 .pin_value =GPIO_HIGH,
493 .gpio_num =WM831X_P06,//tp1
494 .pin_type = GPIO_OUT,
495 .pin_value =GPIO_HIGH,
498 .gpio_num =WM831X_P07,//tp1
499 .pin_type = GPIO_OUT,
500 .pin_value =GPIO_HIGH,
503 .gpio_num =WM831X_P08,//tp1
504 .pin_type = GPIO_OUT,
505 .pin_value =GPIO_HIGH,
508 .gpio_num =WM831X_P09,//tp1
509 .pin_type = GPIO_OUT,
510 .pin_value =GPIO_HIGH,
513 .gpio_num =WM831X_P10,//tp1
514 .pin_type = GPIO_OUT,
515 .pin_value =GPIO_HIGH,
518 .gpio_num =WM831X_P11,//tp1
519 .pin_type = GPIO_OUT,
520 .pin_value =GPIO_HIGH,
523 .gpio_num =WM831X_P12,
524 .pin_type = GPIO_OUT,
525 .pin_value =GPIO_HIGH,
533 #if defined(CONFIG_MFD_WM831X)
535 int wm831x_pre_init(struct wm831x *parm)
538 printk("%s\n", __FUNCTION__);
541 ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
542 wm831x_reg_write(parm, WM831X_POWER_STATE, (ret&0xfff8) | 0x04);
544 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 3), 0);
545 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 7), 0);
546 printk("%s:disable ldo4 and ldo8 because they are enabled in uboot\n",__FUNCTION__);
550 int wm831x_post_init(struct wm831x *parm)
552 struct regulator *dcdc;
553 struct regulator *ldo;
556 dcdc = regulator_get(NULL, "dcdc3"); // 1th IO
557 regulator_set_voltage(dcdc,3000000,3000000);
558 regulator_enable(dcdc);
559 printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
563 ldo = regulator_get(NULL, "ldo10"); // 1th modem IO
564 regulator_set_voltage(ldo,3000000,3000000);
565 regulator_enable(ldo);
566 printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
570 dcdc = regulator_get(NULL, "dcdc2"); // 2th CORE
571 regulator_set_voltage(dcdc,1300000,1300000);
572 regulator_enable(dcdc);
573 printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
577 dcdc = regulator_get(NULL, "dcdc1"); // 3th ddr
578 regulator_set_voltage(dcdc,1800000,1800000);
579 regulator_enable(dcdc);
580 printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
584 ldo = regulator_get(NULL, "ldo1"); // 3th nand
585 regulator_set_voltage(ldo,1800000,1800000);
586 regulator_enable(ldo);
587 printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
591 ldo = regulator_get(NULL, "ldo4"); // 4th usb
592 regulator_set_voltage(ldo,2500000,2500000);
593 regulator_enable(ldo);
594 printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
598 ldo = regulator_get(NULL, "ldo7"); // 5th usb
599 regulator_set_voltage(ldo,3300000,3300000);
600 regulator_enable(ldo);
601 printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
605 dcdc = regulator_get(NULL, "dcdc4"); // backlight
606 regulator_set_voltage(dcdc,20000000,20000000);
607 regulator_enable(dcdc);
608 printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
613 ldo = regulator_get(NULL, "ldo2"); //lcd
614 regulator_set_voltage(ldo,3000000,3000000);
615 regulator_enable(ldo);
616 printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
619 ldo = regulator_get(NULL, "ldo3"); //sram
620 regulator_set_voltage(ldo,1800000,1800000);
621 regulator_enable(ldo);
622 printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
625 ldo = regulator_get(NULL, "ldo5"); //tf
626 regulator_set_voltage(ldo,3000000,3000000);
627 regulator_enable(ldo);
628 printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
631 ldo = regulator_get(NULL, "ldo6"); //camera
632 regulator_set_voltage(ldo,2800000,2800000);
633 regulator_enable(ldo);
634 printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
637 ldo = regulator_get(NULL, "ldo8"); //cmmb
638 regulator_set_voltage(ldo,1200000,1200000);
639 regulator_enable(ldo);
640 printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
643 ldo = regulator_get(NULL, "ldo9"); //cmmb
644 regulator_set_voltage(ldo,3000000,3000000);
645 regulator_enable(ldo);
646 printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
651 ldo = regulator_get(NULL, "ldo11");
652 //regulator_enable(ldo);
653 printk("%s set ldo11=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
660 extern void wm831x_enter_sleep(void);
661 extern void wm831x_exit_sleep(void);
663 void pmu_wm831x_set_suspend_voltage(void)
667 EXPORT_SYMBOL_GPL(pmu_wm831x_set_suspend_voltage);
669 void pmu_wm831x_set_resume_voltage(void)
673 EXPORT_SYMBOL_GPL(pmu_wm831x_set_resume_voltage);
675 int wm831x_last_deinit(struct wm831x *parm)
677 printk("%s\n", __FUNCTION__);
682 struct wm831x_backlight_pdata wm831x_backlight_platdata = {
683 .isink = 1, /** ISINK to use, 1 or 2 */
684 .max_uA = 19484, /** Maximum current to allow */
687 struct wm831x_backup_pdata wm831x_backup_platdata = {
689 .no_constant_voltage = 0, /** Disable constant voltage charging */
690 .vlim = 3100, /** Voltage limit in milivolts */
691 .ilim = 300, /** Current limit in microamps */
694 struct wm831x_battery_pdata wm831x_battery_platdata = {
695 .enable = 1, /** Enable charging */
696 .fast_enable = 1, /** Enable fast charging */
697 .off_mask = 1, /** Mask OFF while charging */
698 .trickle_ilim = 200, /** Trickle charge current limit, in mA */
699 .vsel = 4200, /** Target voltage, in mV */
700 .eoc_iterm = 90, /** End of trickle charge current, in mA */
701 .fast_ilim = 1000, /** Fast charge current limit, in mA */
702 .timeout = 180, /** Charge cycle timeout, in minutes */
703 .syslo = 3300, /* syslo threshold, in mV*/
704 .sysok = 3500, /* sysko threshold, in mV*/
707 struct wm831x_status_pdata wm831x_status_platdata[WM831X_MAX_STATUS] = {
709 .default_src = WM831X_STATUS_OTP,
710 .name = "wm831x_status0",
711 .default_trigger = "wm831x_otp",
714 .default_src = WM831X_STATUS_POWER,
715 .name = "wm831x_status1",
716 .default_trigger = "wm831x_power",
721 static struct regulator_consumer_supply dcdc1_consumers[] = {
726 static struct regulator_consumer_supply dcdc2_consumers[] = {
731 static struct regulator_consumer_supply dcdc3_consumers[] = {
736 static struct regulator_consumer_supply dcdc4_consumers[] = {
741 static struct regulator_consumer_supply epe1_consumers[] = {
746 static struct regulator_consumer_supply epe2_consumers[] = {
751 static struct regulator_consumer_supply ldo1_consumers[] = {
756 static struct regulator_consumer_supply ldo2_consumers[] = {
761 static struct regulator_consumer_supply ldo3_consumers[] = {
766 static struct regulator_consumer_supply ldo4_consumers[] = {
771 static struct regulator_consumer_supply ldo5_consumers[] = {
776 static struct regulator_consumer_supply ldo6_consumers[] = {
781 static struct regulator_consumer_supply ldo7_consumers[] = {
786 static struct regulator_consumer_supply ldo8_consumers[] = {
791 static struct regulator_consumer_supply ldo9_consumers[] = {
796 static struct regulator_consumer_supply ldo10_consumers[] = {
801 static struct regulator_consumer_supply ldo11_consumers[] = {
806 static struct regulator_consumer_supply isink1_consumers[] = {
811 static struct regulator_consumer_supply isink2_consumers[] = {
817 struct regulator_init_data wm831x_regulator_init_dcdc[WM831X_MAX_DCDC] = {
822 .max_uV = 1800000,//0.6-1.8V
824 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
826 .num_consumer_supplies = ARRAY_SIZE(dcdc1_consumers),
827 .consumer_supplies = dcdc1_consumers,
833 .max_uV = 1800000,//0.6-1.8V
835 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
837 .num_consumer_supplies = ARRAY_SIZE(dcdc2_consumers),
838 .consumer_supplies = dcdc2_consumers,
844 .max_uV = 3400000,//0.85-3.4V
846 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
848 .num_consumer_supplies = ARRAY_SIZE(dcdc3_consumers),
849 .consumer_supplies = dcdc3_consumers,
855 .max_uV = 30000000,//30V/40mA
857 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
859 .num_consumer_supplies = ARRAY_SIZE(dcdc4_consumers),
860 .consumer_supplies = dcdc4_consumers,
864 struct regulator_init_data wm831x_regulator_init_epe[WM831X_MAX_EPE] = {
871 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
873 .num_consumer_supplies = ARRAY_SIZE(epe1_consumers),
874 .consumer_supplies = epe1_consumers,
882 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
884 .num_consumer_supplies = ARRAY_SIZE(epe2_consumers),
885 .consumer_supplies = epe2_consumers,
889 struct regulator_init_data wm831x_regulator_init_ldo[WM831X_MAX_LDO] = {
896 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
898 .num_consumer_supplies = ARRAY_SIZE(ldo1_consumers),
899 .consumer_supplies = ldo1_consumers,
907 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
909 .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
910 .consumer_supplies = ldo2_consumers,
918 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
920 .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
921 .consumer_supplies = ldo3_consumers,
929 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
931 .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
932 .consumer_supplies = ldo4_consumers,
940 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
942 .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
943 .consumer_supplies = ldo5_consumers,
951 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
953 .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers),
954 .consumer_supplies = ldo6_consumers,
962 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
964 .num_consumer_supplies = ARRAY_SIZE(ldo7_consumers),
965 .consumer_supplies = ldo7_consumers,
973 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
975 .num_consumer_supplies = ARRAY_SIZE(ldo8_consumers),
976 .consumer_supplies = ldo8_consumers,
984 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
986 .num_consumer_supplies = ARRAY_SIZE(ldo9_consumers),
987 .consumer_supplies = ldo9_consumers,
995 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
997 .num_consumer_supplies = ARRAY_SIZE(ldo10_consumers),
998 .consumer_supplies = ldo10_consumers,
1006 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1008 .num_consumer_supplies = ARRAY_SIZE(ldo11_consumers),
1009 .consumer_supplies = ldo11_consumers,
1013 struct regulator_init_data wm831x_regulator_init_isink[WM831X_MAX_ISINK] = {
1021 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1023 .num_consumer_supplies = ARRAY_SIZE(isink1_consumers),
1024 .consumer_supplies = isink1_consumers,
1032 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1034 .num_consumer_supplies = ARRAY_SIZE(isink2_consumers),
1035 .consumer_supplies = isink2_consumers,
1039 static int wm831x_checkrange(int start,int num,int val)
1041 if((val<(start+num))&&(val>=start))
1047 static int wm831x_init_pin_type(struct wm831x *wm831x)
1050 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
1051 struct rk29_gpio_expander_info *wm831x_gpio_settinginfo;
1052 uint16_t offset = 0;
1053 uint16_t wm831x_settingpin_num = 0;
1059 wm831x_gpio_settinginfo=pdata->settinginfo;
1060 if(wm831x_gpio_settinginfo)
1062 wm831x_settingpin_num = pdata->settinginfolen;
1063 for(i=0;i<wm831x_settingpin_num;i++)
1065 if(!wm831x_checkrange(pdata->gpio_base,pdata->gpio_pin_num,wm831x_gpio_settinginfo[i].gpio_num))
1067 offset = wm831x_gpio_settinginfo[i].gpio_num - pdata->gpio_base;
1069 if(wm831x_gpio_settinginfo[i].pin_type==GPIO_IN)
1071 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_DIR_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
1075 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_TRI_SHIFT);
1076 if(wm831x_gpio_settinginfo[i].pin_value==GPIO_HIGH)
1078 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(1 << offset));
1082 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(0 << offset));
1091 for(i=0;i<pdata->gpio_pin_num;i++)
1093 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+i),
1094 WM831X_GPN_PULL_MASK|WM831X_GPN_POL_MASK|WM831X_GPN_OD_MASK|WM831X_GPN_TRI_MASK,
1095 1<<WM831X_GPN_POL_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
1096 ret = wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL+i);
1097 printk("Gpio%d Pin Configuration = %x\n",i,ret);
1106 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1107 static struct wm831x_gpio_keys_button wm831x_gpio_buttons[] = {
1110 .gpio = TCA6424_P21,
1114 .debounce_interval = 120,
1117 .code= KEY_VOLUMEUP,
1131 .code= KEY_VOLUMEDOWN,
1134 .desc= "volume_down",
1167 struct wm831x_gpio_keys_pdata wm831x_gpio_keys_platdata = {
1168 .buttons = wm831x_gpio_buttons,
1169 .nbuttons = ARRAY_SIZE(wm831x_gpio_buttons),
1173 struct wm831x_pdata wm831x_platdata = {
1174 /** Called before subdevices are set up */
1175 .pre_init= wm831x_pre_init,
1176 /** Called after subdevices are set up */
1177 .post_init = wm831x_post_init,
1178 /** Called before subdevices are power down */
1179 .last_deinit = wm831x_last_deinit,
1181 #if defined(CONFIG_GPIO_WM831X)
1182 .gpio_base=WM831X_GPIO_EXPANDER_BASE,
1183 .gpio_pin_num=WM831X_TOTOL_GPIO_NUM,
1184 .settinginfo=wm831x_gpio_settinginfo,
1185 .settinginfolen=ARRAY_SIZE(wm831x_gpio_settinginfo),
1186 .pin_type_init = wm831x_init_pin_type,
1187 .irq_base= NR_AIC_IRQS + 2*NUM_GROUP + TCA6424_TOTOL_GPIO_IRQ_NUM + CONFIG_SPI_FPGA_GPIO_IRQ_NUM,
1190 .backlight = &wm831x_backlight_platdata,
1192 .backup = &wm831x_backup_platdata,
1194 .battery = &wm831x_battery_platdata,
1195 //.wm831x_touch_pdata = NULL,
1198 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1199 .gpio_keys = &wm831x_gpio_keys_platdata,
1202 /** LED1 = 0 and so on */
1203 .status = {&wm831x_status_platdata[0], &wm831x_status_platdata[1]},
1205 /** DCDC1 = 0 and so on */
1206 .dcdc = {&wm831x_regulator_init_dcdc[0], &wm831x_regulator_init_dcdc[1], &wm831x_regulator_init_dcdc[2], &wm831x_regulator_init_dcdc[3]},
1208 /** EPE1 = 0 and so on */
1209 .epe = {&wm831x_regulator_init_epe[0], &wm831x_regulator_init_epe[1]},
1211 /** LDO1 = 0 and so on */
1212 .ldo = {&wm831x_regulator_init_ldo[0], &wm831x_regulator_init_ldo[1], &wm831x_regulator_init_ldo[2], &wm831x_regulator_init_ldo[3],
1213 &wm831x_regulator_init_ldo[4], &wm831x_regulator_init_ldo[5], &wm831x_regulator_init_ldo[6], &wm831x_regulator_init_ldo[7],
1214 &wm831x_regulator_init_ldo[8], &wm831x_regulator_init_ldo[9], &wm831x_regulator_init_ldo[10]},
1216 /** ISINK1 = 0 and so on*/
1217 .isink = {&wm831x_regulator_init_isink[0], &wm831x_regulator_init_isink[1]},
1223 #if defined(CONFIG_RK29_GPS)
1225 #define RK29_GPS_POWER_PIN RK29_PIN6_PB2
1226 #define RK29_GPS_RESET_PIN RK29_PIN6_PC1
1228 static int gps_open =0;
1230 int rk29_gps_power_up(void)
1233 printk("%s \n", __FUNCTION__);
1234 gpio_request(RK29_GPS_POWER_PIN, NULL);
1235 gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH);
1236 gpio_request(RK29_GPS_RESET_PIN, NULL);
1237 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);
1238 rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
1239 rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
1241 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);
1245 int rk29_gps_power_down(void)
1248 printk("%s \n", __FUNCTION__);
1249 gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW);
1251 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW); //uart1
1256 struct rk29_gps_data rk29_gps_info = {
1257 .power_up = rk29_gps_power_up,
1258 .power_down = rk29_gps_power_down,
1260 .powerpin = RK29_GPS_POWER_PIN,
1264 struct platform_device rk29_device_gps = {
1268 .platform_data = &rk29_gps_info,
1273 /*****************************************************************************************
1275 * author: qjb@rock-chips.com
1276 *****************************************************************************************/
1277 #if defined(CONFIG_MFD_WM8994)
1278 #if defined (CONFIG_REGULATOR_WM8994)
1279 static struct regulator_consumer_supply wm8994_ldo1_consumers[] = {
1290 .supply = "SPKVDD1",
1293 static struct regulator_consumer_supply wm8994_ldo2_consumers[] = {
1301 .supply = "SPKVDD2",
1304 struct regulator_init_data regulator_init_data_ldo1 = {
1306 .name = "wm8994-ldo1",
1311 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1313 .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo1_consumers),
1314 .consumer_supplies = wm8994_ldo1_consumers,
1316 struct regulator_init_data regulator_init_data_ldo2 = {
1318 .name = "wm8994-ldo2",
1323 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1325 .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo2_consumers),
1326 .consumer_supplies = wm8994_ldo2_consumers,
1329 struct wm8994_drc_cfg wm8994_drc_cfg_pdata = {
1330 .name = "wm8994_DRC",
1331 .regs = {0,0,0,0,0},
1334 struct wm8994_retune_mobile_cfg wm8994_retune_mobile_cfg_pdata = {
1335 .name = "wm8994_EQ",
1337 .regs = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
1340 struct wm8994_pdata wm8994_platdata = {
1341 #if defined (CONFIG_GPIO_WM8994)
1342 .gpio_base = WM8994_GPIO_EXPANDER_BASE,
1343 //Fill value to initialize the GPIO
1346 //enable=0 disable ldo
1347 #if defined (CONFIG_REGULATOR_WM8994)
1352 .supply = "wm8994-ldo1",
1353 .init_data = ®ulator_init_data_ldo1,
1357 .supply = "wm8994-ldo2",
1358 .init_data = ®ulator_init_data_ldo2,
1362 //DRC 0--use default
1364 .drc_cfgs = &wm8994_drc_cfg_pdata,
1366 .num_retune_mobile_cfgs = 0,
1367 .retune_mobile_cfgs = &wm8994_retune_mobile_cfg_pdata,
1383 /*****************************************************************************************
1385 * author: kfx@rock-chips.com
1386 *****************************************************************************************/
1387 static int rk29_i2c0_io_init(void)
1389 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
1390 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
1394 static int rk29_i2c1_io_init(void)
1396 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
1397 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
1400 static int rk29_i2c2_io_init(void)
1402 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
1403 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
1407 static int rk29_i2c3_io_init(void)
1409 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
1410 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1414 struct rk29_i2c_platform_data default_i2c0_data = {
1418 .scl_rate = 400*1000,
1419 .mode = I2C_MODE_IRQ,
1420 .io_init = rk29_i2c0_io_init,
1423 struct rk29_i2c_platform_data default_i2c1_data = {
1427 .scl_rate = 400*1000,
1428 .mode = I2C_MODE_POLL,
1429 .io_init = rk29_i2c1_io_init,
1432 struct rk29_i2c_platform_data default_i2c2_data = {
1436 .scl_rate = 400*1000,
1437 .mode = I2C_MODE_IRQ,
1438 .io_init = rk29_i2c2_io_init,
1441 struct rk29_i2c_platform_data default_i2c3_data = {
1445 .scl_rate = 400*1000,
1446 .mode = I2C_MODE_POLL,
1447 .io_init = rk29_i2c3_io_init,
1450 #ifdef CONFIG_I2C0_RK29
1451 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1452 #if defined (CONFIG_RK1000_CONTROL)
1454 .type = "rk1000_control",
1459 #if defined (CONFIG_SND_SOC_RK1000)
1461 .type = "rk1000_i2c_codec",
1466 #if defined (CONFIG_SND_SOC_WM8900)
1473 #if defined (CONFIG_SND_SOC_WM8994)
1478 .platform_data = &wm8994_platdata,
1481 #if defined (CONFIG_BATTERY_STC3100)
1488 #if defined (CONFIG_BATTERY_BQ27510)
1495 #if defined (CONFIG_RTC_HYM8563)
1497 .type = "rtc_hym8563",
1500 .irq = RK29_PIN0_PA1,
1503 #if defined (CONFIG_GS_MMA8452)
1505 .type = "gs_mma8452",
1508 .irq = MMA8452_INT_PIN,
1509 .platform_data = &mma8452_info,
1512 #if defined (CONFIG_COMPASS_AK8973)
1517 .irq = RK29_PIN0_PA4,
1520 #if defined (CONFIG_COMPASS_AK8975)
1525 .irq = RK29_PIN0_PA4,
1528 #if defined (CONFIG_INPUT_LPSENSOR_ISL29028)
1533 .irq = RK29_PIN4_PD3,
1536 #if defined (CONFIG_ANX7150)
1539 .addr = 0x39, //0x39, 0x3d
1541 .irq = RK29_PIN2_PA3,
1547 #ifdef CONFIG_I2C1_RK29
1548 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1549 #if defined (CONFIG_RK1000_CONTROL1)
1551 .type = "rk1000_control",
1560 #ifdef CONFIG_I2C2_RK29
1561 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1562 #if defined (CONFIG_TOUCHSCREEN_GT801_IIC)
1567 .irq = RK29_PIN4_PD5,
1568 .platform_data = >801_info,
1571 #if defined (CONFIG_MFD_WM831X_I2C)
1576 .irq = RK29_PIN4_PD0,
1577 .platform_data = &wm831x_platdata,
1580 #if defined (CONFIG_HANNSTAR_P1003)
1582 .type = "p1003_touch",
1585 .irq = RK29_PIN0_PA2,
1586 .platform_data = &p1003_info,
1589 #if defined (CONFIG_EETI_EGALAX)
1591 .type = "egalax_i2c",
1594 .irq = RK29_PIN4_PD5,
1595 .platform_data = &eeti_egalax_info,
1601 #ifdef CONFIG_I2C3_RK29
1602 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1606 /*****************************************************************************************
1608 * author: ddl@rock-chips.com
1609 *****************************************************************************************/
1610 #ifdef CONFIG_VIDEO_RK29
1611 #define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_OV5642 /* back camera sensor */
1612 #define SENSOR_IIC_ADDR_0 0x78
1613 #define SENSOR_IIC_ADAPTER_ID_0 1
1614 #define SENSOR_POWER_PIN_0 INVALID_GPIO
1615 #define SENSOR_RESET_PIN_0 INVALID_GPIO
1616 #define SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
1617 #define SENSOR_FALSH_PIN_0 INVALID_GPIO
1618 #define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
1619 #define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
1620 #define SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
1621 #define SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
1623 #define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_OV2659 /* front camera sensor */
1624 #define SENSOR_IIC_ADDR_1 0x60
1625 #define SENSOR_IIC_ADAPTER_ID_1 1
1626 #define SENSOR_POWER_PIN_1 INVALID_GPIO
1627 #define SENSOR_RESET_PIN_1 INVALID_GPIO
1628 #define SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
1629 #define SENSOR_FALSH_PIN_1 INVALID_GPIO
1630 #define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
1631 #define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
1632 #define SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
1633 #define SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
1635 static int rk29_sensor_io_init(void);
1636 static int rk29_sensor_io_deinit(int sensor);
1637 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
1639 static struct rk29camera_platform_data rk29_camera_platform_data = {
1640 .io_init = rk29_sensor_io_init,
1641 .io_deinit = rk29_sensor_io_deinit,
1642 .sensor_ioctrl = rk29_sensor_ioctrl,
1645 .gpio_reset = SENSOR_RESET_PIN_0,
1646 .gpio_power = SENSOR_POWER_PIN_0,
1647 .gpio_powerdown = SENSOR_POWERDN_PIN_0,
1648 .gpio_flash = SENSOR_FALSH_PIN_0,
1649 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0|SENSOR_POWERDNACTIVE_LEVEL_0|SENSOR_FLASHACTIVE_LEVEL_0),
1651 .dev_name = SENSOR_NAME_0,
1653 .gpio_reset = SENSOR_RESET_PIN_1,
1654 .gpio_power = SENSOR_POWER_PIN_1,
1655 .gpio_powerdown = SENSOR_POWERDN_PIN_1,
1656 .gpio_flash = SENSOR_FALSH_PIN_1,
1657 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1|SENSOR_POWERDNACTIVE_LEVEL_1|SENSOR_FLASHACTIVE_LEVEL_1),
1659 .dev_name = SENSOR_NAME_1,
1662 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
1664 .name = "camera_ipp_mem",
1665 .start = MEM_CAMIPP_BASE,
1666 .size = MEM_CAMIPP_SIZE,
1671 static int rk29_sensor_io_init(void)
1674 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1675 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1676 unsigned int camera_ioflag;
1678 for (i=0; i<2; i++) {
1679 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
1680 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
1681 camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
1682 camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
1683 camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
1684 rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
1686 if (camera_power != INVALID_GPIO) {
1687 ret = gpio_request(camera_power, "camera power");
1689 goto sensor_io_int_loop_end;
1690 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
1691 gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1692 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1694 //printk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1698 if (camera_reset != INVALID_GPIO) {
1699 ret = gpio_request(camera_reset, "camera reset");
1701 goto sensor_io_int_loop_end;
1702 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
1703 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1704 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1706 //printk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1710 if (camera_powerdown != INVALID_GPIO) {
1711 ret = gpio_request(camera_powerdown, "camera powerdown");
1713 goto sensor_io_int_loop_end;
1714 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
1715 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1716 gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1718 //printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1722 if (camera_flash != INVALID_GPIO) {
1723 ret = gpio_request(camera_flash, "camera flash");
1725 goto sensor_io_int_loop_end;
1726 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
1727 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1728 gpio_direction_output(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1730 //printk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1734 sensor_io_int_loop_end:
1735 rk29_sensor_io_deinit(i);
1742 static int rk29_sensor_io_deinit(int sensor)
1744 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1745 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1747 camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
1748 camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
1749 camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
1750 camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
1752 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
1753 if (camera_power != INVALID_GPIO) {
1754 gpio_direction_input(camera_power);
1755 gpio_free(camera_power);
1759 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
1760 if (camera_reset != INVALID_GPIO) {
1761 gpio_direction_input(camera_reset);
1762 gpio_free(camera_reset);
1766 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
1767 if (camera_powerdown != INVALID_GPIO) {
1768 gpio_direction_input(camera_powerdown);
1769 gpio_free(camera_powerdown);
1773 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
1774 if (camera_flash != INVALID_GPIO) {
1775 gpio_direction_input(camera_flash);
1776 gpio_free(camera_flash);
1780 rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
1783 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
1785 unsigned int camera_power=INVALID_GPIO,camera_reset=INVALID_GPIO, camera_powerdown=INVALID_GPIO,camera_flash = INVALID_GPIO;
1786 unsigned int camera_ioflag,camera_io_init;
1787 int ret = RK29_CAM_IO_SUCCESS;
1789 if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
1790 camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
1791 camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
1792 camera_powerdown = rk29_camera_platform_data.gpio_res[0].gpio_powerdown;
1793 camera_flash = rk29_camera_platform_data.gpio_res[0].gpio_flash;
1794 camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
1795 camera_io_init = rk29_camera_platform_data.gpio_res[0].gpio_init;
1796 } 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)) {
1797 camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
1798 camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
1799 camera_powerdown = rk29_camera_platform_data.gpio_res[1].gpio_powerdown;
1800 camera_flash = rk29_camera_platform_data.gpio_res[1].gpio_flash;
1801 camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
1802 camera_io_init = rk29_camera_platform_data.gpio_res[1].gpio_init;
1809 if (camera_power != INVALID_GPIO) {
1810 if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
1812 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1813 //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));
1816 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1817 //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));
1820 ret = RK29_CAM_EIO_REQUESTFAIL;
1821 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1824 ret = RK29_CAM_EIO_INVALID;
1830 if (camera_reset != INVALID_GPIO) {
1831 if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
1833 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1834 //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));
1836 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1837 //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));
1840 ret = RK29_CAM_EIO_REQUESTFAIL;
1841 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1844 ret = RK29_CAM_EIO_INVALID;
1851 if (camera_powerdown != INVALID_GPIO) {
1852 if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
1854 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1855 //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));
1857 gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1858 //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));
1861 ret = RK29_CAM_EIO_REQUESTFAIL;
1862 printk("\n%s..%s..PowerDownPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_powerdown);
1865 ret = RK29_CAM_EIO_INVALID;
1872 if (camera_flash != INVALID_GPIO) {
1873 if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
1875 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1876 //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));
1878 gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1879 //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));
1882 ret = RK29_CAM_EIO_REQUESTFAIL;
1883 printk("\n%s..%s..FlashPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_flash);
1886 ret = RK29_CAM_EIO_INVALID;
1893 printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
1899 static int rk29_sensor_power(struct device *dev, int on)
1901 rk29_sensor_ioctrl(dev,Cam_Power,on);
1904 static int rk29_sensor_reset(struct device *dev)
1906 rk29_sensor_ioctrl(dev,Cam_Reset,1);
1908 rk29_sensor_ioctrl(dev,Cam_Reset,0);
1911 static int rk29_sensor_powerdown(struct device *dev, int on)
1913 return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
1915 #if (SENSOR_IIC_ADDR_0 != 0x00)
1916 static struct i2c_board_info rk29_i2c_cam_info_0[] = {
1918 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
1922 static struct soc_camera_link rk29_iclink_0 = {
1923 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1924 .power = rk29_sensor_power,
1925 .powerdown = rk29_sensor_powerdown,
1926 .board_info = &rk29_i2c_cam_info_0[0],
1927 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
1928 .module_name = SENSOR_NAME_0,
1931 /*platform_device : soc-camera need */
1932 static struct platform_device rk29_soc_camera_pdrv_0 = {
1933 .name = "soc-camera-pdrv",
1936 .init_name = SENSOR_NAME_0,
1937 .platform_data = &rk29_iclink_0,
1941 static struct i2c_board_info rk29_i2c_cam_info_1[] = {
1943 I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
1947 static struct soc_camera_link rk29_iclink_1 = {
1948 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1949 .power = rk29_sensor_power,
1950 .powerdown = rk29_sensor_powerdown,
1951 .board_info = &rk29_i2c_cam_info_1[0],
1952 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
1953 .module_name = SENSOR_NAME_1,
1956 /*platform_device : soc-camera need */
1957 static struct platform_device rk29_soc_camera_pdrv_1 = {
1958 .name = "soc-camera-pdrv",
1961 .init_name = SENSOR_NAME_1,
1962 .platform_data = &rk29_iclink_1,
1967 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
1968 static struct resource rk29_camera_resource[] = {
1970 .start = RK29_VIP_PHYS,
1971 .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
1972 .flags = IORESOURCE_MEM,
1977 .flags = IORESOURCE_IRQ,
1981 /*platform_device : */
1982 static struct platform_device rk29_device_camera = {
1983 .name = RK29_CAM_DRV_NAME,
1984 .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
1985 .num_resources = ARRAY_SIZE(rk29_camera_resource),
1986 .resource = rk29_camera_resource,
1988 .dma_mask = &rockchip_device_camera_dmamask,
1989 .coherent_dma_mask = 0xffffffffUL,
1990 .platform_data = &rk29_camera_platform_data,
1994 /*****************************************************************************************
1996 * author: nzy@rock-chips.com
1997 *****************************************************************************************/
1998 #ifdef CONFIG_BACKLIGHT_RK29_BL
2000 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
2001 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
2002 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
2003 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
2007 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
2008 #define PWM_MUX_MODE GPIO1L_PWM0
2009 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
2010 #define PWM_EFFECT_VALUE 1
2012 //#define LCD_DISP_ON_PIN
2014 #ifdef LCD_DISP_ON_PIN
2015 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
2016 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
2018 #define BL_EN_PIN GPIO0L_GPIO0A5
2019 #define BL_EN_VALUE GPIO_HIGH
2021 static int rk29_backlight_io_init(void)
2025 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
2026 #ifdef LCD_DISP_ON_PIN
2027 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
2029 ret = gpio_request(BL_EN_PIN, NULL);
2032 gpio_free(BL_EN_PIN);
2035 gpio_direction_output(BL_EN_PIN, 0);
2036 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
2041 static int rk29_backlight_io_deinit(void)
2044 #ifdef LCD_DISP_ON_PIN
2045 gpio_free(BL_EN_PIN);
2047 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
2050 struct rk29_bl_info rk29_bl_info = {
2052 .bl_ref = PWM_EFFECT_VALUE,
2053 .io_init = rk29_backlight_io_init,
2054 .io_deinit = rk29_backlight_io_deinit,
2057 /*****************************************************************************************
2058 * pwm voltage regulator devices
2059 ******************************************************************************************/
2060 #if defined (CONFIG_RK29_PWM_REGULATOR)
2062 #define REGULATOR_PWM_ID 2
2063 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
2064 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
2065 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
2066 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
2068 static struct regulator_consumer_supply pwm_consumers[] = {
2074 static struct regulator_init_data rk29_pwm_regulator_data = {
2080 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
2082 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
2083 .consumer_supplies = pwm_consumers,
2086 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
2087 .pwm_id = REGULATOR_PWM_ID,
2088 .pwm_gpio = REGULATOR_PWM_GPIO,
2089 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
2090 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
2091 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
2092 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
2093 .init_data = &rk29_pwm_regulator_data,
2096 static struct platform_device rk29_device_pwm_regulator = {
2097 .name = "pwm-voltage-regulator",
2100 .platform_data = &rk29_regulator_pwm_platform_data,
2106 /*****************************************************************************************
2108 *****************************************************************************************/
2109 #ifdef CONFIG_SDMMC0_RK29
2110 static int rk29_sdmmc0_cfg_gpio(void)
2112 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
2113 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
2114 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
2115 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
2116 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
2117 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
2118 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
2119 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
2120 gpio_request(RK29_PIN5_PD5,"sdmmc");
2121 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
2123 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
2127 #define CONFIG_SDMMC0_USE_DMA
2128 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
2129 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
2130 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
2131 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
2132 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2133 .io_init = rk29_sdmmc0_cfg_gpio,
2134 .dma_name = "sd_mmc",
2135 #ifdef CONFIG_SDMMC0_USE_DMA
2142 #ifdef CONFIG_SDMMC1_RK29
2143 #define CONFIG_SDMMC1_USE_DMA
2144 static int rk29_sdmmc1_cfg_gpio(void)
2146 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2147 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2148 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2149 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2150 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2151 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2152 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
2156 #ifdef CONFIG_WIFI_CONTROL_FUNC
2157 static int rk29sdk_wifi_status(struct device *dev);
2158 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
2161 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
2163 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
2164 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
2165 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
2166 MMC_VDD_32_33|MMC_VDD_33_34),
2167 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
2168 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2169 .io_init = rk29_sdmmc1_cfg_gpio,
2171 #ifdef CONFIG_SDMMC1_USE_DMA
2176 #ifdef CONFIG_WIFI_CONTROL_FUNC
2177 .status = rk29sdk_wifi_status,
2178 .register_status_notify = rk29sdk_wifi_status_register,
2181 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
2186 #ifdef CONFIG_WIFI_CONTROL_FUNC
2187 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
2188 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
2189 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC7
2191 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
2192 static void (*wifi_status_cb)(int card_present, void *dev_id);
2193 static void *wifi_status_cb_devid;
2194 int rk29sdk_wifi_power_state = 0;
2195 int rk29sdk_bt_power_state = 0;
2197 static int rk29sdk_wifi_status(struct device *dev)
2199 return rk29sdk_wifi_cd;
2202 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
2206 wifi_status_cb = callback;
2207 wifi_status_cb_devid = dev_id;
2211 static int rk29sdk_wifi_bt_gpio_control_init(void)
2213 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
2214 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
2218 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
2219 pr_info("%s: request wifi reset gpio failed\n", __func__);
2220 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
2224 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
2225 pr_info("%s: request bt reset gpio failed\n", __func__);
2226 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
2230 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2231 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2232 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
2234 pr_info("%s: init finished\n",__func__);
2239 static int rk29sdk_wifi_power(int on)
2241 pr_info("%s: %d\n", __func__, on);
2243 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
2245 pr_info("wifi turn on power\n");
2247 if (!rk29sdk_bt_power_state){
2248 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
2250 pr_info("wifi shut off power\n");
2253 pr_info("wifi shouldn't shut off power, bt is using it!\n");
2258 rk29sdk_wifi_power_state = on;
2262 static int rk29sdk_wifi_reset_state;
2263 static int rk29sdk_wifi_reset(int on)
2265 pr_info("%s: %d\n", __func__, on);
2266 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
2268 rk29sdk_wifi_reset_state = on;
2272 int rk29sdk_wifi_set_carddetect(int val)
2274 pr_info("%s:%d\n", __func__, val);
2275 rk29sdk_wifi_cd = val;
2276 if (wifi_status_cb){
2277 wifi_status_cb(val, wifi_status_cb_devid);
2279 pr_warning("%s, nobody to notify\n", __func__);
2283 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
2285 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
2286 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
2287 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
2288 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
2289 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
2292 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
2294 if (section == PREALLOC_WLAN_SEC_NUM)
2295 return wlan_static_skb;
2297 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
2300 if (wifi_mem_array[section].size < size)
2303 return wifi_mem_array[section].mem_ptr;
2306 int __init rk29sdk_init_wifi_mem(void)
2311 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
2312 wlan_static_skb[i] = dev_alloc_skb(
2313 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
2315 if (!wlan_static_skb[i])
2319 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
2320 wifi_mem_array[i].mem_ptr =
2321 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
2323 if (!wifi_mem_array[i].mem_ptr)
2329 pr_err("Failed to mem_alloc for WLAN\n");
2330 for (j = 0 ; j < i ; j++)
2331 kfree(wifi_mem_array[j].mem_ptr);
2333 i = WLAN_SKB_BUF_NUM;
2336 pr_err("Failed to skb_alloc for WLAN\n");
2337 for (j = 0 ; j < i ; j++)
2338 dev_kfree_skb(wlan_static_skb[j]);
2343 static struct wifi_platform_data rk29sdk_wifi_control = {
2344 .set_power = rk29sdk_wifi_power,
2345 .set_reset = rk29sdk_wifi_reset,
2346 .set_carddetect = rk29sdk_wifi_set_carddetect,
2347 .mem_prealloc = rk29sdk_mem_prealloc,
2349 static struct platform_device rk29sdk_wifi_device = {
2350 .name = "bcm4329_wlan",
2353 .platform_data = &rk29sdk_wifi_control,
2359 /* bluetooth rfkill device */
2360 static struct platform_device rk29sdk_rfkill = {
2361 .name = "rk29sdk_rfkill",
2366 #ifdef CONFIG_VIVANTE
2367 static struct resource resources_gpu[] = {
2372 .flags = IORESOURCE_IRQ,
2376 .start = RK29_GPU_PHYS,
2377 .end = RK29_GPU_PHYS + RK29_GPU_SIZE,
2378 .flags = IORESOURCE_MEM,
2382 .start = PMEM_GPU_BASE,
2383 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE,
2384 .flags = IORESOURCE_MEM,
2387 static struct platform_device rk29_device_gpu = {
2390 .num_resources = ARRAY_SIZE(resources_gpu),
2391 .resource = resources_gpu,
2394 #ifdef CONFIG_KEYS_RK29
2395 extern struct rk29_keys_platform_data rk29_keys_pdata;
2396 static struct platform_device rk29_device_keys = {
2397 .name = "rk29-keypad",
2400 .platform_data = &rk29_keys_pdata,
2405 static void __init rk29_board_iomux_init(void)
2407 #ifdef CONFIG_UART0_RK29
2408 rk29_mux_api_set(GPIO1B7_UART0SOUT_NAME, GPIO1L_UART0_SOUT);
2409 rk29_mux_api_set(GPIO1B6_UART0SIN_NAME, GPIO1L_UART0_SIN);
2410 #ifdef CONFIG_UART0_CTS_RTS_RK29
2411 rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N);
2412 rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_UART0_CTS_N);
2415 #ifdef CONFIG_UART1_RK29
2416 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
2417 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
2419 #ifdef CONFIG_UART2_RK29
2420 rk29_mux_api_set(GPIO2B1_UART2SOUT_NAME, GPIO2L_UART2_SOUT);
2421 rk29_mux_api_set(GPIO2B0_UART2SIN_NAME, GPIO2L_UART2_SIN);
2422 #ifdef CONFIG_UART2_CTS_RTS_RK29
2423 rk29_mux_api_set(GPIO2A7_UART2RTSN_NAME, GPIO2L_UART2_RTS_N);
2424 rk29_mux_api_set(GPIO2A6_UART2CTSN_NAME, GPIO2L_UART2_CTS_N);
2427 #ifdef CONFIG_UART3_RK29
2428 rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
2429 rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
2430 #ifdef CONFIG_UART3_CTS_RTS_RK29
2431 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_UART3_RTS_N);
2432 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_UART3_CTS_N);
2435 #ifdef CONFIG_SPIM0_RK29
2436 rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME, GPIO2H_SPI0_CLK);
2437 rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME, GPIO2H_SPI0_CSN0);
2438 rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME, GPIO2H_SPI0_TXD);
2439 rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME, GPIO2H_SPI0_RXD);
2441 #ifdef CONFIG_SPIM1_RK29
2442 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK);
2443 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME, GPIO2H_SPI1_CSN0);
2444 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME, GPIO2H_SPI1_TXD);
2445 rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME, GPIO2H_SPI1_RXD);
2447 #ifdef CONFIG_RK29_VMAC
2448 rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME, GPIO4H_RMII_CLKOUT);
2449 rk29_mux_api_set(GPIO4C1_RMIITXEN_MIITXEN_NAME, GPIO4H_RMII_TX_EN);
2450 rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME, GPIO4H_RMII_TXD1);
2451 rk29_mux_api_set(GPIO4C3_RMIITXD0_MIITXD0_NAME, GPIO4H_RMII_TXD0);
2452 rk29_mux_api_set(GPIO4C4_RMIIRXERR_MIIRXERR_NAME, GPIO4H_RMII_RX_ERR);
2453 rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME, GPIO4H_RMII_CSR_DVALID);
2454 rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME, GPIO4H_RMII_RXD1);
2455 rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME, GPIO4H_RMII_RXD0);
2457 rk29_mux_api_set(GPIO0A7_MIIMDCLK_NAME, GPIO0L_MII_MDCLK);
2458 rk29_mux_api_set(GPIO0A6_MIIMD_NAME, GPIO0L_MII_MD);
2460 #ifdef CONFIG_RK29_PWM_REGULATOR
2461 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
2465 static struct platform_device *devices[] __initdata = {
2466 #ifdef CONFIG_UART1_RK29
2469 #ifdef CONFIG_UART0_RK29
2472 #ifdef CONFIG_UART2_RK29
2476 #ifdef CONFIG_RK29_PWM_REGULATOR
2477 &rk29_device_pwm_regulator,
2479 #ifdef CONFIG_SPIM0_RK29
2480 &rk29xx_device_spi0m,
2482 #ifdef CONFIG_SPIM1_RK29
2483 &rk29xx_device_spi1m,
2485 #ifdef CONFIG_ADC_RK29
2488 #ifdef CONFIG_I2C0_RK29
2491 #ifdef CONFIG_I2C1_RK29
2494 #ifdef CONFIG_I2C2_RK29
2497 #ifdef CONFIG_I2C3_RK29
2501 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
2502 &rk29_device_iis_2ch,
2504 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
2505 &rk29_device_iis_8ch,
2508 #ifdef CONFIG_KEYS_RK29
2511 #ifdef CONFIG_SDMMC0_RK29
2512 &rk29_device_sdmmc0,
2514 #ifdef CONFIG_SDMMC1_RK29
2515 &rk29_device_sdmmc1,
2518 #ifdef CONFIG_MTD_NAND_RK29XX
2519 &rk29xx_device_nand,
2522 #ifdef CONFIG_WIFI_CONTROL_FUNC
2523 &rk29sdk_wifi_device,
2530 #ifdef CONFIG_MTD_NAND_RK29
2534 #ifdef CONFIG_FB_RK29
2536 &rk29_device_dma_cpy,
2538 #ifdef CONFIG_BACKLIGHT_RK29_BL
2539 &rk29_device_backlight,
2541 #ifdef CONFIG_RK29_VMAC
2544 #ifdef CONFIG_VIVANTE
2547 #ifdef CONFIG_VIDEO_RK29
2548 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
2549 #if (SENSOR_IIC_ADDR_0 != 0x00)
2550 &rk29_soc_camera_pdrv_0,
2552 &rk29_soc_camera_pdrv_1,
2553 &android_pmem_cam_device,
2555 &android_pmem_device,
2556 &rk29_vpu_mem_device,
2557 #ifdef CONFIG_USB20_OTG
2558 &rk29_device_usb20_otg,
2560 #ifdef CONFIG_USB20_HOST
2561 &rk29_device_usb20_host,
2563 #ifdef CONFIG_USB11_HOST
2564 &rk29_device_usb11_host,
2566 #ifdef CONFIG_USB_ANDROID
2567 &android_usb_device,
2568 &usb_mass_storage_device,
2570 #ifdef CONFIG_RK29_IPP
2573 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2574 &rk29_v4l2_output_devce,
2578 #ifdef CONFIG_RK29_VMAC
2579 /*****************************************************************************************
2581 * author: lyx@rock-chips.com
2582 *****************************************************************************************/
2583 static int rk29_vmac_register_set(void)
2585 //config rk29 vmac as rmii, 100MHz
2586 u32 value= readl(RK29_GRF_BASE + 0xbc);
2587 value = (value & 0xfff7ff) | (0x400);
2588 writel(value, RK29_GRF_BASE + 0xbc);
2592 static int rk29_rmii_io_init(void)
2597 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2599 gpio_free(RK29_PIN6_PB0);
2600 printk("-------request RK29_PIN6_PB0 fail--------\n");
2604 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2605 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2610 static int rk29_rmii_io_deinit(void)
2613 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2614 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2616 gpio_free(RK29_PIN6_PB0);
2620 static int rk29_rmii_power_control(int enable)
2624 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2625 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2628 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2629 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2634 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2635 .vmac_register_set = rk29_vmac_register_set,
2636 .rmii_io_init = rk29_rmii_io_init,
2637 .rmii_io_deinit = rk29_rmii_io_deinit,
2638 .rmii_power_control = rk29_rmii_power_control,
2642 /*****************************************************************************************
2644 * author: cmc@rock-chips.com
2645 *****************************************************************************************/
2646 #define SPI_CHIPSELECT_NUM 2
2647 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2650 .cs_gpio = RK29_PIN2_PC1,
2651 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2652 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2656 .cs_gpio = RK29_PIN1_PA4,
2657 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2658 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2662 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2665 .cs_gpio = RK29_PIN2_PC5,
2666 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2667 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2671 .cs_gpio = RK29_PIN1_PA3,
2672 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2673 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2677 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2682 for (i=0; i<cs_num; i++) {
2683 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2690 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2695 static int spi_io_fix_leakage_bug(void)
2698 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2703 static int spi_io_resume_leakage_bug(void)
2706 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2711 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2712 .num_chipselect = SPI_CHIPSELECT_NUM,
2713 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2714 .io_init = spi_io_init,
2715 .io_deinit = spi_io_deinit,
2716 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2717 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2720 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2721 .num_chipselect = SPI_CHIPSELECT_NUM,
2722 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2723 .io_init = spi_io_init,
2724 .io_deinit = spi_io_deinit,
2725 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2726 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2729 /*****************************************************************************************
2730 * xpt2046 touch panel
2731 * author: hhb@rock-chips.com
2732 *****************************************************************************************/
2733 #define XPT2046_GPIO_INT RK29_PIN4_PD5 //ä¸æ–è„š
2734 #define DEBOUNCE_REPTIME 3
2736 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
2737 static struct xpt2046_platform_data xpt2046_info = {
2742 .debounce_rep = DEBOUNCE_REPTIME,
2744 .gpio_pendown = XPT2046_GPIO_INT,
2745 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
2746 .pendown_iomux_mode = GPIO4H_GPIO4D5,
2747 .touch_virtualkey_length = 60,
2748 .penirq_recheck_delay_usecs = 1,
2749 #if defined(CONFIG_TOUCHSCREEN_480X800)
2754 .touch_ad_top = 3940,
2755 .touch_ad_bottom = 310,
2756 .touch_ad_left = 3772,
2757 .touch_ad_right = 340,
2758 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2763 .touch_ad_top = 2447,
2764 .touch_ad_bottom = 207,
2765 .touch_ad_left = 5938,
2766 .touch_ad_right = 153,
2767 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2772 .touch_ad_top = 3166,
2773 .touch_ad_bottom = 256,
2774 .touch_ad_left = 3658,
2775 .touch_ad_right = 380,
2778 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2779 static struct xpt2046_platform_data xpt2046_info = {
2784 .debounce_rep = DEBOUNCE_REPTIME,
2786 .gpio_pendown = XPT2046_GPIO_INT,
2787 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
2788 .pendown_iomux_mode = GPIO4H_GPIO4D5,
2789 .touch_virtualkey_length = 60,
2790 .penirq_recheck_delay_usecs = 1,
2792 #if defined(CONFIG_TOUCHSCREEN_480X800)
2797 .screen_x = { 70, 410, 70, 410, 240},
2798 .screen_y = { 50, 50, 740, 740, 400},
2799 .uncali_x_default = { 3267, 831, 3139, 715, 1845 },
2800 .uncali_y_default = { 3638, 3664, 564, 591, 2087 },
2801 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2806 .screen_x[5] = { 50, 750, 50, 750, 400};
2807 .screen_y[5] = { 40, 40, 440, 440, 240};
2808 .uncali_x_default[5] = { 438, 565, 3507, 3631, 2105 };
2809 .uncali_y_default[5] = { 3756, 489, 3792, 534, 2159 };
2810 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2815 .screen_x[5] = { 50, 270, 50, 270, 160};
2816 .screen_y[5] = { 40, 40, 440, 440, 240};
2817 .uncali_x_default[5] = { 812, 3341, 851, 3371, 2183 };
2818 .uncali_y_default[5] = { 442, 435, 3193, 3195, 2004 };
2823 static struct spi_board_info board_spi_devices[] = {
2824 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2826 .modalias = "xpt2046_ts",
2827 .chip_select = 0,// 2,
2828 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2830 .irq = XPT2046_GPIO_INT,
2831 .platform_data = &xpt2046_info,
2835 #if defined(CONFIG_MFD_WM831X_SPI)
2837 .modalias = "wm8310",
2839 .max_speed_hz = 2*1000*1000,
2841 .irq = RK29_PIN4_PD0,
2842 .platform_data = &wm831x_platdata,
2849 static void __init rk29_gic_init_irq(void)
2851 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2852 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2855 static void __init machine_rk29_init_irq(void)
2857 rk29_gic_init_irq();
2861 #define POWER_ON_PIN RK29_PIN4_PA4
2862 static void rk29_pm_power_off(void)
2864 printk(KERN_ERR "rk29_pm_power_off start...\n");
2865 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2869 static void __init machine_rk29_board_init(void)
2871 rk29_board_iomux_init();
2873 gpio_request(POWER_ON_PIN,"poweronpin");
2874 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
2875 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2876 pm_power_off = rk29_pm_power_off;
2878 #ifdef CONFIG_WIFI_CONTROL_FUNC
2879 rk29sdk_wifi_bt_gpio_control_init();
2882 platform_add_devices(devices, ARRAY_SIZE(devices));
2883 #ifdef CONFIG_I2C0_RK29
2884 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2885 ARRAY_SIZE(board_i2c0_devices));
2887 #ifdef CONFIG_I2C1_RK29
2888 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2889 ARRAY_SIZE(board_i2c1_devices));
2891 #ifdef CONFIG_I2C2_RK29
2892 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2893 ARRAY_SIZE(board_i2c2_devices));
2895 #ifdef CONFIG_I2C3_RK29
2896 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2897 ARRAY_SIZE(board_i2c3_devices));
2900 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2902 rk29sdk_init_wifi_mem();
2905 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2906 char **cmdline, struct meminfo *mi)
2909 mi->bank[0].start = RK29_SDRAM_PHYS;
2910 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
2911 mi->bank[0].size = LINUX_SIZE;
2914 static void __init machine_rk29_mapio(void)
2916 rk29_map_common_io();
2917 rk29_setup_early_printk();
2923 MACHINE_START(RK29, "RK29board")
2924 /* UART for LL DEBUG */
2925 .phys_io = RK29_UART1_PHYS,
2926 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2927 .boot_params = RK29_SDRAM_PHYS + 0x88000,
2928 .fixup = machine_rk29_fixup,
2929 .map_io = machine_rk29_mapio,
2930 .init_irq = machine_rk29_init_irq,
2931 .init_machine = machine_rk29_board_init,
2932 .timer = &rk29_timer,