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_TXD_PIN INVALID_GPIO
137 #define LCD_CLK_PIN INVALID_GPIO
138 #define LCD_CS_PIN INVALID_GPIO
139 /*****************************************************************************************
140 * frame buffer devices
141 * author: zyw@rock-chips.com
142 *****************************************************************************************/
144 #define FB_DISPLAY_ON_PIN RK29_PIN6_PD0
145 #define FB_LCD_STANDBY_PIN RK29_PIN6_PD1
146 #define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2
147 #define FB_MCU_FMK_PIN INVALID_GPIO
149 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
150 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
153 static int rk29_lcd_io_init(void)
159 static int rk29_lcd_io_deinit(void)
165 static struct rk29lcd_info rk29_lcd_info = {
166 .txd_pin = LCD_TXD_PIN,
167 .clk_pin = LCD_CLK_PIN,
168 .cs_pin = LCD_CS_PIN,
169 .io_init = rk29_lcd_io_init,
170 .io_deinit = rk29_lcd_io_deinit,
174 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
177 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
179 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
182 gpio_free(FB_MCU_FMK_PIN);
183 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
185 gpio_direction_input(FB_MCU_FMK_PIN);
187 if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
189 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
192 gpio_free(FB_DISPLAY_ON_PIN);
193 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
197 if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
199 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
202 gpio_free(FB_LCD_STANDBY_PIN);
203 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
207 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
209 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
212 gpio_free(FB_LCD_CABC_EN_PIN);
213 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
215 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
216 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
222 static struct rk29fb_info rk29_fb_info = {
224 .disp_on_pin = FB_DISPLAY_ON_PIN,
225 .disp_on_value = FB_DISPLAY_ON_VALUE,
226 .standby_pin = FB_LCD_STANDBY_PIN,
227 .standby_value = FB_LCD_STANDBY_VALUE,
228 .mcu_fmk_pin = FB_MCU_FMK_PIN,
229 .lcd_info = &rk29_lcd_info,
230 .io_init = rk29_fb_io_init,
233 /* rk29 fb resource */
234 static struct resource rk29_fb_resource[] = {
237 .start = RK29_LCDC_PHYS,
238 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
239 .flags = IORESOURCE_MEM,
245 .flags = IORESOURCE_IRQ,
249 .start = MEM_FB_BASE,
250 .end = MEM_FB_BASE + MEM_FB_SIZE,
251 .flags = IORESOURCE_MEM,
256 struct platform_device rk29_device_fb = {
259 .num_resources = ARRAY_SIZE(rk29_fb_resource),
260 .resource = rk29_fb_resource,
262 .platform_data = &rk29_fb_info,
266 struct platform_device rk29_device_dma_cpy = {
267 .name = "dma_memcpy",
274 static struct android_pmem_platform_data android_pmem_pdata = {
276 .start = PMEM_UI_BASE,
277 .size = PMEM_UI_SIZE,
282 static struct platform_device android_pmem_device = {
283 .name = "android_pmem",
286 .platform_data = &android_pmem_pdata,
291 static struct android_pmem_platform_data android_pmem_cam_pdata = {
293 .start = PMEM_CAM_BASE,
294 .size = PMEM_CAM_SIZE,
299 static struct platform_device android_pmem_cam_device = {
300 .name = "android_pmem",
303 .platform_data = &android_pmem_cam_pdata,
308 static struct vpu_mem_platform_data vpu_mem_pdata = {
310 .start = PMEM_VPU_BASE,
311 .size = PMEM_VPU_SIZE,
315 static struct platform_device rk29_vpu_mem_device = {
319 .platform_data = &vpu_mem_pdata,
323 static struct platform_device rk29_v4l2_output_devce = {
327 /* HANNSTAR_P1003 touch I2C */
328 #if defined (CONFIG_HANNSTAR_P1003)
329 #define TOUCH_RESET_PIN RK29_PIN6_PC3
330 #define TOUCH_INT_PIN RK29_PIN4_PD5
332 int p1003_init_platform_hw(void)
334 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
335 gpio_free(TOUCH_RESET_PIN);
336 printk("p1003_init_platform_hw gpio_request error\n");
340 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
341 gpio_free(TOUCH_INT_PIN);
342 printk("p1003_init_platform_hw gpio_request error\n");
345 gpio_pull_updown(TOUCH_INT_PIN, 1);
346 gpio_direction_output(TOUCH_RESET_PIN, 0);
348 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
350 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
356 struct p1003_platform_data p1003_info = {
358 .init_platform_hw= p1003_init_platform_hw,
363 #if defined(CONFIG_TOUCHSCREEN_GT801_IIC)
364 #include "../../../drivers/input/touchscreen/gt801_ts.h"
365 #define GT801_GPIO_INT RK29_PIN4_PD5
366 #define GT801_GPIO_RESET RK29_PIN6_PC3
367 static struct gt801_platform_data gt801_info = {
374 .gpio_reset = GT801_GPIO_RESET,
375 .gpio_reset_active_low = 1,
376 .gpio_pendown = GT801_GPIO_INT,
377 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
378 .resetpin_iomux_name = NULL,
379 .pendown_iomux_mode = GPIO4H_GPIO4D5,
380 .resetpin_iomux_mode = 0,
384 /* EETI_EGALAX touch I2C */
385 #if defined (CONFIG_EETI_EGALAX)
386 #define TOUCH_RESET_PIN RK29_PIN6_PC3
387 #define TOUCH_INT_PIN RK29_PIN4_PD5
389 static int EETI_EGALAX_init_platform_hw(void)
391 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
392 gpio_free(TOUCH_RESET_PIN);
393 printk("p1003_init_platform_hw gpio_request error\n");
397 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
398 gpio_free(TOUCH_INT_PIN);
399 printk("p1003_init_platform_hw gpio_request error\n");
402 gpio_pull_updown(TOUCH_INT_PIN, 1);
403 gpio_direction_output(TOUCH_RESET_PIN, 0);
405 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
407 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
413 static struct eeti_egalax_platform_data eeti_egalax_info = {
415 .init_platform_hw= EETI_EGALAX_init_platform_hw,
420 /* GT801 touch I2C */
421 #if defined (CONFIG_GT801)
422 #include <drivers/input/touchscreen/gt801.h>
423 #define TOUCH_RESET_PIN RK29_PIN6_PC3
424 #define TOUCH_INT_PIN RK29_PIN4_PD5
426 static struct gt801_platform_data gt801_info = {
433 .gpio_reset = TOUCH_RESET_PIN,
434 .gpio_reset_active_low = 1,
435 .gpio_pendown = TOUCH_INT_PIN,
436 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
437 .resetpin_iomux_name = "FFF",
438 .pendown_iomux_mode = GPIO4H_GPIO4D5,
439 .resetpin_iomux_mode = 0,
440 .get_pendown_state = NULL,
445 #if defined (CONFIG_GS_MMA8452)
446 #define MMA8452_INT_PIN RK29_PIN6_PC4
448 static int mma8452_init_platform_hw(void)
451 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
452 gpio_free(MMA8452_INT_PIN);
453 printk("mma8452_init_platform_hw gpio_request error\n");
456 gpio_pull_updown(MMA8452_INT_PIN, 1);
461 static struct mma8452_platform_data mma8452_info = {
464 .init_platform_hw= mma8452_init_platform_hw,
469 #if defined(CONFIG_GPIO_WM831X)
470 struct rk29_gpio_expander_info wm831x_gpio_settinginfo[] = {
472 .gpio_num =WM831X_P01,// tp3
473 .pin_type = GPIO_OUT,
474 .pin_value =GPIO_HIGH,
478 .gpio_num =WM831X_P02,//tp4
479 .pin_type = GPIO_OUT,
480 .pin_value =GPIO_HIGH,
483 .gpio_num =WM831X_P03,//tp2
484 .pin_type = GPIO_OUT,
485 .pin_value =GPIO_HIGH,
488 .gpio_num =WM831X_P04,//tp1
489 .pin_type = GPIO_OUT,
490 .pin_value =GPIO_HIGH,
493 .gpio_num =WM831X_P05,//tp1
494 .pin_type = GPIO_OUT,
495 .pin_value =GPIO_HIGH,
498 .gpio_num =WM831X_P06,//tp1
499 .pin_type = GPIO_OUT,
500 .pin_value =GPIO_HIGH,
503 .gpio_num =WM831X_P07,//tp1
504 .pin_type = GPIO_OUT,
505 .pin_value =GPIO_HIGH,
508 .gpio_num =WM831X_P08,//tp1
509 .pin_type = GPIO_OUT,
510 .pin_value =GPIO_HIGH,
513 .gpio_num =WM831X_P09,//tp1
514 .pin_type = GPIO_OUT,
515 .pin_value =GPIO_HIGH,
518 .gpio_num =WM831X_P10,//tp1
519 .pin_type = GPIO_OUT,
520 .pin_value =GPIO_HIGH,
523 .gpio_num =WM831X_P11,//tp1
524 .pin_type = GPIO_OUT,
525 .pin_value =GPIO_HIGH,
528 .gpio_num =WM831X_P12,
529 .pin_type = GPIO_OUT,
530 .pin_value =GPIO_HIGH,
538 #if defined(CONFIG_MFD_WM831X)
540 int wm831x_pre_init(struct wm831x *parm)
543 printk("%s\n", __FUNCTION__);
546 ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
547 wm831x_reg_write(parm, WM831X_POWER_STATE, (ret&0xfff8) | 0x04);
549 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 3), 0);
550 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 7), 0);
551 printk("%s:disable ldo4 and ldo8 because they are enabled in uboot\n",__FUNCTION__);
555 int wm831x_post_init(struct wm831x *parm)
557 struct regulator *dcdc;
558 struct regulator *ldo;
561 dcdc = regulator_get(NULL, "dcdc3"); // 1th IO
562 regulator_set_voltage(dcdc,3000000,3000000);
563 regulator_enable(dcdc);
564 printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
568 ldo = regulator_get(NULL, "ldo10"); // 1th modem IO
569 regulator_set_voltage(ldo,3000000,3000000);
570 regulator_enable(ldo);
571 printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
575 dcdc = regulator_get(NULL, "dcdc2"); // 2th CORE
576 regulator_set_voltage(dcdc,1300000,1300000);
577 regulator_enable(dcdc);
578 printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
582 dcdc = regulator_get(NULL, "dcdc1"); // 3th ddr
583 regulator_set_voltage(dcdc,1800000,1800000);
584 regulator_enable(dcdc);
585 printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
589 ldo = regulator_get(NULL, "ldo1"); // 3th nand
590 regulator_set_voltage(ldo,1800000,1800000);
591 regulator_enable(ldo);
592 printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
596 ldo = regulator_get(NULL, "ldo4"); // 4th usb
597 regulator_set_voltage(ldo,2500000,2500000);
598 regulator_enable(ldo);
599 printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
603 ldo = regulator_get(NULL, "ldo7"); // 5th usb
604 regulator_set_voltage(ldo,3300000,3300000);
605 regulator_enable(ldo);
606 printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
610 dcdc = regulator_get(NULL, "dcdc4"); // backlight
611 regulator_set_voltage(dcdc,20000000,20000000);
612 regulator_enable(dcdc);
613 printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
618 ldo = regulator_get(NULL, "ldo2"); //lcd
619 regulator_set_voltage(ldo,3000000,3000000);
620 regulator_enable(ldo);
621 printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
624 ldo = regulator_get(NULL, "ldo3"); //sram
625 regulator_set_voltage(ldo,1800000,1800000);
626 regulator_enable(ldo);
627 printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
630 ldo = regulator_get(NULL, "ldo5"); //tf
631 regulator_set_voltage(ldo,3000000,3000000);
632 regulator_enable(ldo);
633 printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
636 ldo = regulator_get(NULL, "ldo6"); //camera
637 regulator_set_voltage(ldo,2800000,2800000);
638 regulator_enable(ldo);
639 printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
642 ldo = regulator_get(NULL, "ldo8"); //cmmb
643 regulator_set_voltage(ldo,1200000,1200000);
644 regulator_enable(ldo);
645 printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
648 ldo = regulator_get(NULL, "ldo9"); //cmmb
649 regulator_set_voltage(ldo,3000000,3000000);
650 regulator_enable(ldo);
651 printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
656 ldo = regulator_get(NULL, "ldo11");
657 //regulator_enable(ldo);
658 printk("%s set ldo11=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
665 extern void wm831x_enter_sleep(void);
666 extern void wm831x_exit_sleep(void);
668 void pmu_wm831x_set_suspend_voltage(void)
672 EXPORT_SYMBOL_GPL(pmu_wm831x_set_suspend_voltage);
674 void pmu_wm831x_set_resume_voltage(void)
678 EXPORT_SYMBOL_GPL(pmu_wm831x_set_resume_voltage);
680 int wm831x_last_deinit(struct wm831x *parm)
682 printk("%s\n", __FUNCTION__);
687 struct wm831x_backlight_pdata wm831x_backlight_platdata = {
688 .isink = 1, /** ISINK to use, 1 or 2 */
689 .max_uA = 5000, /** Maximum current to allow */
692 struct wm831x_backup_pdata wm831x_backup_platdata = {
694 .no_constant_voltage = 0, /** Disable constant voltage charging */
695 .vlim = 3100, /** Voltage limit in milivolts */
696 .ilim = 300, /** Current limit in microamps */
699 struct wm831x_battery_pdata wm831x_battery_platdata = {
700 .enable = 1, /** Enable charging */
701 .fast_enable = 1, /** Enable fast charging */
702 .off_mask = 1, /** Mask OFF while charging */
703 .trickle_ilim = 200, /** Trickle charge current limit, in mA */
704 .vsel = 4200, /** Target voltage, in mV */
705 .eoc_iterm = 90, /** End of trickle charge current, in mA */
706 .fast_ilim = 1000, /** Fast charge current limit, in mA */
707 .timeout = 180, /** Charge cycle timeout, in minutes */
708 .syslo = 3300, /* syslo threshold, in mV*/
709 .sysok = 3500, /* sysko threshold, in mV*/
712 struct wm831x_status_pdata wm831x_status_platdata[WM831X_MAX_STATUS] = {
714 .default_src = WM831X_STATUS_OTP,
715 .name = "wm831x_status0",
716 .default_trigger = "wm831x_otp",
719 .default_src = WM831X_STATUS_POWER,
720 .name = "wm831x_status1",
721 .default_trigger = "wm831x_power",
726 static struct regulator_consumer_supply dcdc1_consumers[] = {
731 static struct regulator_consumer_supply dcdc2_consumers[] = {
736 static struct regulator_consumer_supply dcdc3_consumers[] = {
741 static struct regulator_consumer_supply dcdc4_consumers[] = {
746 static struct regulator_consumer_supply epe1_consumers[] = {
751 static struct regulator_consumer_supply epe2_consumers[] = {
756 static struct regulator_consumer_supply ldo1_consumers[] = {
761 static struct regulator_consumer_supply ldo2_consumers[] = {
766 static struct regulator_consumer_supply ldo3_consumers[] = {
771 static struct regulator_consumer_supply ldo4_consumers[] = {
776 static struct regulator_consumer_supply ldo5_consumers[] = {
781 static struct regulator_consumer_supply ldo6_consumers[] = {
786 static struct regulator_consumer_supply ldo7_consumers[] = {
791 static struct regulator_consumer_supply ldo8_consumers[] = {
796 static struct regulator_consumer_supply ldo9_consumers[] = {
801 static struct regulator_consumer_supply ldo10_consumers[] = {
806 static struct regulator_consumer_supply ldo11_consumers[] = {
811 static struct regulator_consumer_supply isink1_consumers[] = {
816 static struct regulator_consumer_supply isink2_consumers[] = {
822 struct regulator_init_data wm831x_regulator_init_dcdc[WM831X_MAX_DCDC] = {
827 .max_uV = 1800000,//0.6-1.8V
829 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
831 .num_consumer_supplies = ARRAY_SIZE(dcdc1_consumers),
832 .consumer_supplies = dcdc1_consumers,
838 .max_uV = 1800000,//0.6-1.8V
840 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
842 .num_consumer_supplies = ARRAY_SIZE(dcdc2_consumers),
843 .consumer_supplies = dcdc2_consumers,
849 .max_uV = 3400000,//0.85-3.4V
851 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
853 .num_consumer_supplies = ARRAY_SIZE(dcdc3_consumers),
854 .consumer_supplies = dcdc3_consumers,
860 .max_uV = 30000000,//30V/40mA
862 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
864 .num_consumer_supplies = ARRAY_SIZE(dcdc4_consumers),
865 .consumer_supplies = dcdc4_consumers,
869 struct regulator_init_data wm831x_regulator_init_epe[WM831X_MAX_EPE] = {
876 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
878 .num_consumer_supplies = ARRAY_SIZE(epe1_consumers),
879 .consumer_supplies = epe1_consumers,
887 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
889 .num_consumer_supplies = ARRAY_SIZE(epe2_consumers),
890 .consumer_supplies = epe2_consumers,
894 struct regulator_init_data wm831x_regulator_init_ldo[WM831X_MAX_LDO] = {
901 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
903 .num_consumer_supplies = ARRAY_SIZE(ldo1_consumers),
904 .consumer_supplies = ldo1_consumers,
912 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
914 .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
915 .consumer_supplies = ldo2_consumers,
923 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
925 .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
926 .consumer_supplies = ldo3_consumers,
934 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
936 .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
937 .consumer_supplies = ldo4_consumers,
945 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
947 .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
948 .consumer_supplies = ldo5_consumers,
956 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
958 .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers),
959 .consumer_supplies = ldo6_consumers,
967 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
969 .num_consumer_supplies = ARRAY_SIZE(ldo7_consumers),
970 .consumer_supplies = ldo7_consumers,
978 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
980 .num_consumer_supplies = ARRAY_SIZE(ldo8_consumers),
981 .consumer_supplies = ldo8_consumers,
989 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
991 .num_consumer_supplies = ARRAY_SIZE(ldo9_consumers),
992 .consumer_supplies = ldo9_consumers,
1000 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1002 .num_consumer_supplies = ARRAY_SIZE(ldo10_consumers),
1003 .consumer_supplies = ldo10_consumers,
1011 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1013 .num_consumer_supplies = ARRAY_SIZE(ldo11_consumers),
1014 .consumer_supplies = ldo11_consumers,
1018 struct regulator_init_data wm831x_regulator_init_isink[WM831X_MAX_ISINK] = {
1026 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1028 .num_consumer_supplies = ARRAY_SIZE(isink1_consumers),
1029 .consumer_supplies = isink1_consumers,
1037 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1039 .num_consumer_supplies = ARRAY_SIZE(isink2_consumers),
1040 .consumer_supplies = isink2_consumers,
1044 static int wm831x_checkrange(int start,int num,int val)
1046 if((val<(start+num))&&(val>=start))
1052 static int wm831x_init_pin_type(struct wm831x *wm831x)
1055 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
1056 struct rk29_gpio_expander_info *wm831x_gpio_settinginfo;
1057 uint16_t offset = 0;
1058 uint16_t wm831x_settingpin_num = 0;
1064 wm831x_gpio_settinginfo=pdata->settinginfo;
1065 if(wm831x_gpio_settinginfo)
1067 wm831x_settingpin_num = pdata->settinginfolen;
1068 for(i=0;i<wm831x_settingpin_num;i++)
1070 if(!wm831x_checkrange(pdata->gpio_base,pdata->gpio_pin_num,wm831x_gpio_settinginfo[i].gpio_num))
1072 offset = wm831x_gpio_settinginfo[i].gpio_num - pdata->gpio_base;
1074 if(wm831x_gpio_settinginfo[i].pin_type==GPIO_IN)
1076 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);
1080 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_TRI_SHIFT);
1081 if(wm831x_gpio_settinginfo[i].pin_value==GPIO_HIGH)
1083 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(1 << offset));
1087 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(0 << offset));
1096 for(i=0;i<pdata->gpio_pin_num;i++)
1098 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+i),
1099 WM831X_GPN_PULL_MASK|WM831X_GPN_POL_MASK|WM831X_GPN_OD_MASK|WM831X_GPN_TRI_MASK,
1100 1<<WM831X_GPN_POL_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
1101 ret = wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL+i);
1102 printk("Gpio%d Pin Configuration = %x\n",i,ret);
1111 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1112 static struct wm831x_gpio_keys_button wm831x_gpio_buttons[] = {
1115 .gpio = TCA6424_P21,
1119 .debounce_interval = 120,
1122 .code= KEY_VOLUMEUP,
1136 .code= KEY_VOLUMEDOWN,
1139 .desc= "volume_down",
1172 struct wm831x_gpio_keys_pdata wm831x_gpio_keys_platdata = {
1173 .buttons = wm831x_gpio_buttons,
1174 .nbuttons = ARRAY_SIZE(wm831x_gpio_buttons),
1178 struct wm831x_pdata wm831x_platdata = {
1179 /** Called before subdevices are set up */
1180 .pre_init= wm831x_pre_init,
1181 /** Called after subdevices are set up */
1182 .post_init = wm831x_post_init,
1183 /** Called before subdevices are power down */
1184 .last_deinit = wm831x_last_deinit,
1186 #if defined(CONFIG_GPIO_WM831X)
1187 .gpio_base=WM831X_GPIO_EXPANDER_BASE,
1188 .gpio_pin_num=WM831X_TOTOL_GPIO_NUM,
1189 .settinginfo=wm831x_gpio_settinginfo,
1190 .settinginfolen=ARRAY_SIZE(wm831x_gpio_settinginfo),
1191 .pin_type_init = wm831x_init_pin_type,
1192 .irq_base= NR_AIC_IRQS + 2*NUM_GROUP + TCA6424_TOTOL_GPIO_IRQ_NUM + CONFIG_SPI_FPGA_GPIO_IRQ_NUM,
1195 .backlight = &wm831x_backlight_platdata,
1197 .backup = &wm831x_backup_platdata,
1199 .battery = &wm831x_battery_platdata,
1200 //.wm831x_touch_pdata = NULL,
1203 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1204 .gpio_keys = &wm831x_gpio_keys_platdata,
1207 /** LED1 = 0 and so on */
1208 .status = {&wm831x_status_platdata[0], &wm831x_status_platdata[1]},
1210 /** DCDC1 = 0 and so on */
1211 .dcdc = {&wm831x_regulator_init_dcdc[0], &wm831x_regulator_init_dcdc[1], &wm831x_regulator_init_dcdc[2], &wm831x_regulator_init_dcdc[3]},
1213 /** EPE1 = 0 and so on */
1214 .epe = {&wm831x_regulator_init_epe[0], &wm831x_regulator_init_epe[1]},
1216 /** LDO1 = 0 and so on */
1217 .ldo = {&wm831x_regulator_init_ldo[0], &wm831x_regulator_init_ldo[1], &wm831x_regulator_init_ldo[2], &wm831x_regulator_init_ldo[3],
1218 &wm831x_regulator_init_ldo[4], &wm831x_regulator_init_ldo[5], &wm831x_regulator_init_ldo[6], &wm831x_regulator_init_ldo[7],
1219 &wm831x_regulator_init_ldo[8], &wm831x_regulator_init_ldo[9], &wm831x_regulator_init_ldo[10]},
1221 /** ISINK1 = 0 and so on*/
1222 .isink = {&wm831x_regulator_init_isink[0], &wm831x_regulator_init_isink[1]},
1228 #if defined(CONFIG_RK29_GPS)
1230 #define RK29_GPS_POWER_PIN RK29_PIN6_PB2
1231 #define RK29_GPS_RESET_PIN RK29_PIN6_PC1
1233 static int gps_open =0;
1235 int rk29_gps_power_up(void)
1238 printk("%s \n", __FUNCTION__);
1239 gpio_request(RK29_GPS_POWER_PIN, NULL);
1240 gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH);
1241 gpio_request(RK29_GPS_RESET_PIN, NULL);
1242 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);
1243 rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
1244 rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
1246 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);
1250 int rk29_gps_power_down(void)
1253 printk("%s \n", __FUNCTION__);
1254 gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW);
1256 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW); //uart1
1261 struct rk29_gps_data rk29_gps_info = {
1262 .power_up = rk29_gps_power_up,
1263 .power_down = rk29_gps_power_down,
1265 .powerpin = RK29_GPS_POWER_PIN,
1269 struct platform_device rk29_device_gps = {
1273 .platform_data = &rk29_gps_info,
1278 /*****************************************************************************************
1280 * author: qjb@rock-chips.com
1281 *****************************************************************************************/
1282 #if defined(CONFIG_MFD_WM8994)
1283 #if defined (CONFIG_REGULATOR_WM8994)
1284 static struct regulator_consumer_supply wm8994_ldo1_consumers[] = {
1295 .supply = "SPKVDD1",
1298 static struct regulator_consumer_supply wm8994_ldo2_consumers[] = {
1306 .supply = "SPKVDD2",
1309 struct regulator_init_data regulator_init_data_ldo1 = {
1311 .name = "wm8994-ldo1",
1316 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1318 .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo1_consumers),
1319 .consumer_supplies = wm8994_ldo1_consumers,
1321 struct regulator_init_data regulator_init_data_ldo2 = {
1323 .name = "wm8994-ldo2",
1328 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1330 .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo2_consumers),
1331 .consumer_supplies = wm8994_ldo2_consumers,
1334 struct wm8994_drc_cfg wm8994_drc_cfg_pdata = {
1335 .name = "wm8994_DRC",
1336 .regs = {0,0,0,0,0},
1339 struct wm8994_retune_mobile_cfg wm8994_retune_mobile_cfg_pdata = {
1340 .name = "wm8994_EQ",
1342 .regs = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
1345 struct wm8994_pdata wm8994_platdata = {
1346 #if defined (CONFIG_GPIO_WM8994)
1347 .gpio_base = WM8994_GPIO_EXPANDER_BASE,
1348 //Fill value to initialize the GPIO
1351 //enable=0 disable ldo
1352 #if defined (CONFIG_REGULATOR_WM8994)
1357 .supply = "wm8994-ldo1",
1358 .init_data = ®ulator_init_data_ldo1,
1362 .supply = "wm8994-ldo2",
1363 .init_data = ®ulator_init_data_ldo2,
1367 //DRC 0--use default
1369 .drc_cfgs = &wm8994_drc_cfg_pdata,
1371 .num_retune_mobile_cfgs = 0,
1372 .retune_mobile_cfgs = &wm8994_retune_mobile_cfg_pdata,
1388 /*****************************************************************************************
1390 * author: kfx@rock-chips.com
1391 *****************************************************************************************/
1392 static int rk29_i2c0_io_init(void)
1394 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
1395 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
1399 static int rk29_i2c1_io_init(void)
1401 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
1402 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
1405 static int rk29_i2c2_io_init(void)
1407 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
1408 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
1412 static int rk29_i2c3_io_init(void)
1414 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
1415 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1419 struct rk29_i2c_platform_data default_i2c0_data = {
1423 .scl_rate = 400*1000,
1424 .mode = I2C_MODE_IRQ,
1425 .io_init = rk29_i2c0_io_init,
1428 struct rk29_i2c_platform_data default_i2c1_data = {
1432 .scl_rate = 400*1000,
1433 .mode = I2C_MODE_POLL,
1434 .io_init = rk29_i2c1_io_init,
1437 struct rk29_i2c_platform_data default_i2c2_data = {
1441 .scl_rate = 400*1000,
1442 .mode = I2C_MODE_IRQ,
1443 .io_init = rk29_i2c2_io_init,
1446 struct rk29_i2c_platform_data default_i2c3_data = {
1450 .scl_rate = 400*1000,
1451 .mode = I2C_MODE_POLL,
1452 .io_init = rk29_i2c3_io_init,
1455 #ifdef CONFIG_I2C0_RK29
1456 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1457 #if defined (CONFIG_RK1000_CONTROL)
1459 .type = "rk1000_control",
1464 #if defined (CONFIG_SND_SOC_RK1000)
1466 .type = "rk1000_i2c_codec",
1471 #if defined (CONFIG_SND_SOC_WM8900)
1478 #if defined (CONFIG_SND_SOC_WM8994)
1483 .platform_data = &wm8994_platdata,
1486 #if defined (CONFIG_BATTERY_STC3100)
1493 #if defined (CONFIG_BATTERY_BQ27510)
1500 #if defined (CONFIG_RTC_HYM8563)
1502 .type = "rtc_hym8563",
1505 .irq = RK29_PIN0_PA1,
1508 #if defined (CONFIG_GS_MMA8452)
1510 .type = "gs_mma8452",
1513 .irq = MMA8452_INT_PIN,
1514 .platform_data = &mma8452_info,
1517 #if defined (CONFIG_COMPASS_AK8973)
1522 .irq = RK29_PIN0_PA4,
1525 #if defined (CONFIG_COMPASS_AK8975)
1530 .irq = RK29_PIN0_PA4,
1533 #if defined (CONFIG_INPUT_LPSENSOR_ISL29028)
1538 .irq = RK29_PIN4_PD3,
1541 #if defined (CONFIG_ANX7150)
1544 .addr = 0x39, //0x39, 0x3d
1546 .irq = RK29_PIN2_PA3,
1552 #ifdef CONFIG_I2C1_RK29
1553 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1554 #if defined (CONFIG_RK1000_CONTROL1)
1556 .type = "rk1000_control",
1565 #ifdef CONFIG_I2C2_RK29
1566 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1567 #if defined (CONFIG_TOUCHSCREEN_GT801_IIC)
1572 .irq = RK29_PIN4_PD5,
1573 .platform_data = >801_info,
1576 #if defined (CONFIG_GT801)
1578 .type = "gt801_touch",
1581 .irq = RK29_PIN4_PD5,
1582 .platform_data = >801_info,
1585 #if defined (CONFIG_MFD_WM831X_I2C)
1590 .irq = RK29_PIN4_PD0,
1591 .platform_data = &wm831x_platdata,
1594 #if defined (CONFIG_HANNSTAR_P1003)
1596 .type = "p1003_touch",
1599 .irq = RK29_PIN0_PA2,
1600 .platform_data = &p1003_info,
1603 #if defined (CONFIG_EETI_EGALAX)
1605 .type = "egalax_i2c",
1608 .irq = RK29_PIN4_PD5,
1609 .platform_data = &eeti_egalax_info,
1615 #ifdef CONFIG_I2C3_RK29
1616 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1620 /*****************************************************************************************
1622 * author: ddl@rock-chips.com
1623 *****************************************************************************************/
1624 #ifdef CONFIG_VIDEO_RK29
1625 #define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_OV5642 /* back camera sensor */
1626 #define SENSOR_IIC_ADDR_0 0x78
1627 #define SENSOR_IIC_ADAPTER_ID_0 1
1628 #define SENSOR_POWER_PIN_0 INVALID_GPIO
1629 #define SENSOR_RESET_PIN_0 INVALID_GPIO
1630 #define SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
1631 #define SENSOR_FALSH_PIN_0 INVALID_GPIO
1632 #define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
1633 #define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
1634 #define SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
1635 #define SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
1637 #define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_OV2659 /* front camera sensor */
1638 #define SENSOR_IIC_ADDR_1 0x60
1639 #define SENSOR_IIC_ADAPTER_ID_1 1
1640 #define SENSOR_POWER_PIN_1 INVALID_GPIO
1641 #define SENSOR_RESET_PIN_1 INVALID_GPIO
1642 #define SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
1643 #define SENSOR_FALSH_PIN_1 INVALID_GPIO
1644 #define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
1645 #define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
1646 #define SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
1647 #define SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
1649 static int rk29_sensor_io_init(void);
1650 static int rk29_sensor_io_deinit(int sensor);
1651 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
1653 static struct rk29camera_platform_data rk29_camera_platform_data = {
1654 .io_init = rk29_sensor_io_init,
1655 .io_deinit = rk29_sensor_io_deinit,
1656 .sensor_ioctrl = rk29_sensor_ioctrl,
1659 .gpio_reset = SENSOR_RESET_PIN_0,
1660 .gpio_power = SENSOR_POWER_PIN_0,
1661 .gpio_powerdown = SENSOR_POWERDN_PIN_0,
1662 .gpio_flash = SENSOR_FALSH_PIN_0,
1663 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0|SENSOR_POWERDNACTIVE_LEVEL_0|SENSOR_FLASHACTIVE_LEVEL_0),
1665 .dev_name = SENSOR_NAME_0,
1667 .gpio_reset = SENSOR_RESET_PIN_1,
1668 .gpio_power = SENSOR_POWER_PIN_1,
1669 .gpio_powerdown = SENSOR_POWERDN_PIN_1,
1670 .gpio_flash = SENSOR_FALSH_PIN_1,
1671 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1|SENSOR_POWERDNACTIVE_LEVEL_1|SENSOR_FLASHACTIVE_LEVEL_1),
1673 .dev_name = SENSOR_NAME_1,
1676 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
1678 .name = "camera_ipp_mem",
1679 .start = MEM_CAMIPP_BASE,
1680 .size = MEM_CAMIPP_SIZE,
1685 static int rk29_sensor_io_init(void)
1688 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1689 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1690 unsigned int camera_ioflag;
1692 for (i=0; i<2; i++) {
1693 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
1694 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
1695 camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
1696 camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
1697 camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
1698 rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
1700 if (camera_power != INVALID_GPIO) {
1701 ret = gpio_request(camera_power, "camera power");
1703 goto sensor_io_int_loop_end;
1704 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
1705 gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1706 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1708 //printk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1712 if (camera_reset != INVALID_GPIO) {
1713 ret = gpio_request(camera_reset, "camera reset");
1715 goto sensor_io_int_loop_end;
1716 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
1717 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1718 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1720 //printk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1724 if (camera_powerdown != INVALID_GPIO) {
1725 ret = gpio_request(camera_powerdown, "camera powerdown");
1727 goto sensor_io_int_loop_end;
1728 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
1729 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1730 gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1732 //printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1736 if (camera_flash != INVALID_GPIO) {
1737 ret = gpio_request(camera_flash, "camera flash");
1739 goto sensor_io_int_loop_end;
1740 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
1741 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1742 gpio_direction_output(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1744 //printk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1748 sensor_io_int_loop_end:
1749 rk29_sensor_io_deinit(i);
1756 static int rk29_sensor_io_deinit(int sensor)
1758 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1759 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1761 camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
1762 camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
1763 camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
1764 camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
1766 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
1767 if (camera_power != INVALID_GPIO) {
1768 gpio_direction_input(camera_power);
1769 gpio_free(camera_power);
1773 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
1774 if (camera_reset != INVALID_GPIO) {
1775 gpio_direction_input(camera_reset);
1776 gpio_free(camera_reset);
1780 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
1781 if (camera_powerdown != INVALID_GPIO) {
1782 gpio_direction_input(camera_powerdown);
1783 gpio_free(camera_powerdown);
1787 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
1788 if (camera_flash != INVALID_GPIO) {
1789 gpio_direction_input(camera_flash);
1790 gpio_free(camera_flash);
1794 rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
1797 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
1799 unsigned int camera_power=INVALID_GPIO,camera_reset=INVALID_GPIO, camera_powerdown=INVALID_GPIO,camera_flash = INVALID_GPIO;
1800 unsigned int camera_ioflag,camera_io_init;
1801 int ret = RK29_CAM_IO_SUCCESS;
1803 if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
1804 camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
1805 camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
1806 camera_powerdown = rk29_camera_platform_data.gpio_res[0].gpio_powerdown;
1807 camera_flash = rk29_camera_platform_data.gpio_res[0].gpio_flash;
1808 camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
1809 camera_io_init = rk29_camera_platform_data.gpio_res[0].gpio_init;
1810 } 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)) {
1811 camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
1812 camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
1813 camera_powerdown = rk29_camera_platform_data.gpio_res[1].gpio_powerdown;
1814 camera_flash = rk29_camera_platform_data.gpio_res[1].gpio_flash;
1815 camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
1816 camera_io_init = rk29_camera_platform_data.gpio_res[1].gpio_init;
1823 if (camera_power != INVALID_GPIO) {
1824 if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
1826 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1827 //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));
1830 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1831 //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));
1834 ret = RK29_CAM_EIO_REQUESTFAIL;
1835 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1838 ret = RK29_CAM_EIO_INVALID;
1844 if (camera_reset != INVALID_GPIO) {
1845 if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
1847 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1848 //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));
1850 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1851 //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));
1854 ret = RK29_CAM_EIO_REQUESTFAIL;
1855 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1858 ret = RK29_CAM_EIO_INVALID;
1865 if (camera_powerdown != INVALID_GPIO) {
1866 if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
1868 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1869 //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));
1871 gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1872 //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));
1875 ret = RK29_CAM_EIO_REQUESTFAIL;
1876 printk("\n%s..%s..PowerDownPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_powerdown);
1879 ret = RK29_CAM_EIO_INVALID;
1886 if (camera_flash != INVALID_GPIO) {
1887 if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
1889 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1890 //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));
1892 gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1893 //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));
1896 ret = RK29_CAM_EIO_REQUESTFAIL;
1897 printk("\n%s..%s..FlashPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_flash);
1900 ret = RK29_CAM_EIO_INVALID;
1907 printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
1913 static int rk29_sensor_power(struct device *dev, int on)
1915 rk29_sensor_ioctrl(dev,Cam_Power,on);
1918 static int rk29_sensor_reset(struct device *dev)
1920 rk29_sensor_ioctrl(dev,Cam_Reset,1);
1922 rk29_sensor_ioctrl(dev,Cam_Reset,0);
1925 static int rk29_sensor_powerdown(struct device *dev, int on)
1927 return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
1929 #if (SENSOR_IIC_ADDR_0 != 0x00)
1930 static struct i2c_board_info rk29_i2c_cam_info_0[] = {
1932 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
1936 static struct soc_camera_link rk29_iclink_0 = {
1937 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1938 .power = rk29_sensor_power,
1939 .powerdown = rk29_sensor_powerdown,
1940 .board_info = &rk29_i2c_cam_info_0[0],
1941 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
1942 .module_name = SENSOR_NAME_0,
1945 /*platform_device : soc-camera need */
1946 static struct platform_device rk29_soc_camera_pdrv_0 = {
1947 .name = "soc-camera-pdrv",
1950 .init_name = SENSOR_NAME_0,
1951 .platform_data = &rk29_iclink_0,
1955 static struct i2c_board_info rk29_i2c_cam_info_1[] = {
1957 I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
1961 static struct soc_camera_link rk29_iclink_1 = {
1962 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1963 .power = rk29_sensor_power,
1964 .powerdown = rk29_sensor_powerdown,
1965 .board_info = &rk29_i2c_cam_info_1[0],
1966 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
1967 .module_name = SENSOR_NAME_1,
1970 /*platform_device : soc-camera need */
1971 static struct platform_device rk29_soc_camera_pdrv_1 = {
1972 .name = "soc-camera-pdrv",
1975 .init_name = SENSOR_NAME_1,
1976 .platform_data = &rk29_iclink_1,
1981 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
1982 static struct resource rk29_camera_resource[] = {
1984 .start = RK29_VIP_PHYS,
1985 .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
1986 .flags = IORESOURCE_MEM,
1991 .flags = IORESOURCE_IRQ,
1995 /*platform_device : */
1996 static struct platform_device rk29_device_camera = {
1997 .name = RK29_CAM_DRV_NAME,
1998 .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
1999 .num_resources = ARRAY_SIZE(rk29_camera_resource),
2000 .resource = rk29_camera_resource,
2002 .dma_mask = &rockchip_device_camera_dmamask,
2003 .coherent_dma_mask = 0xffffffffUL,
2004 .platform_data = &rk29_camera_platform_data,
2008 /*****************************************************************************************
2010 * author: nzy@rock-chips.com
2011 *****************************************************************************************/
2012 #ifdef CONFIG_BACKLIGHT_RK29_BL
2014 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
2015 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
2016 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
2017 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
2021 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
2022 #define PWM_MUX_MODE GPIO1L_PWM0
2023 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
2024 #define PWM_EFFECT_VALUE 1
2026 //#define LCD_DISP_ON_PIN
2028 #ifdef LCD_DISP_ON_PIN
2029 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
2030 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
2032 #define BL_EN_PIN GPIO0L_GPIO0A5
2033 #define BL_EN_VALUE GPIO_HIGH
2035 static int rk29_backlight_io_init(void)
2039 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
2040 #ifdef LCD_DISP_ON_PIN
2041 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
2043 ret = gpio_request(BL_EN_PIN, NULL);
2046 gpio_free(BL_EN_PIN);
2049 gpio_direction_output(BL_EN_PIN, 0);
2050 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
2055 static int rk29_backlight_io_deinit(void)
2058 #ifdef LCD_DISP_ON_PIN
2059 gpio_free(BL_EN_PIN);
2061 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
2064 struct rk29_bl_info rk29_bl_info = {
2066 .bl_ref = PWM_EFFECT_VALUE,
2067 .io_init = rk29_backlight_io_init,
2068 .io_deinit = rk29_backlight_io_deinit,
2071 /*****************************************************************************************
2072 * pwm voltage regulator devices
2073 ******************************************************************************************/
2074 #if defined (CONFIG_RK29_PWM_REGULATOR)
2076 #define REGULATOR_PWM_ID 2
2077 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
2078 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
2079 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
2080 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
2082 static struct regulator_consumer_supply pwm_consumers[] = {
2088 static struct regulator_init_data rk29_pwm_regulator_data = {
2094 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
2096 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
2097 .consumer_supplies = pwm_consumers,
2100 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
2101 .pwm_id = REGULATOR_PWM_ID,
2102 .pwm_gpio = REGULATOR_PWM_GPIO,
2103 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
2104 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
2105 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
2106 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
2107 .init_data = &rk29_pwm_regulator_data,
2110 static struct platform_device rk29_device_pwm_regulator = {
2111 .name = "pwm-voltage-regulator",
2114 .platform_data = &rk29_regulator_pwm_platform_data,
2120 /*****************************************************************************************
2122 *****************************************************************************************/
2123 #ifdef CONFIG_SDMMC0_RK29
2124 static int rk29_sdmmc0_cfg_gpio(void)
2126 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
2127 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
2128 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
2129 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
2130 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
2131 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
2132 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
2133 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
2134 gpio_request(RK29_PIN5_PD5,"sdmmc");
2135 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
2137 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
2141 #define CONFIG_SDMMC0_USE_DMA
2142 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
2143 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
2144 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
2145 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
2146 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2147 .io_init = rk29_sdmmc0_cfg_gpio,
2148 .dma_name = "sd_mmc",
2149 #ifdef CONFIG_SDMMC0_USE_DMA
2156 #ifdef CONFIG_SDMMC1_RK29
2157 #define CONFIG_SDMMC1_USE_DMA
2158 static int rk29_sdmmc1_cfg_gpio(void)
2160 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2161 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2162 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2163 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2164 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2165 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2166 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
2170 #ifdef CONFIG_WIFI_CONTROL_FUNC
2171 static int rk29sdk_wifi_status(struct device *dev);
2172 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
2175 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
2177 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
2178 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
2179 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
2180 MMC_VDD_32_33|MMC_VDD_33_34),
2181 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
2182 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2183 .io_init = rk29_sdmmc1_cfg_gpio,
2185 #ifdef CONFIG_SDMMC1_USE_DMA
2190 #ifdef CONFIG_WIFI_CONTROL_FUNC
2191 .status = rk29sdk_wifi_status,
2192 .register_status_notify = rk29sdk_wifi_status_register,
2195 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
2200 #ifdef CONFIG_WIFI_CONTROL_FUNC
2201 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
2202 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
2203 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC7
2205 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
2206 static void (*wifi_status_cb)(int card_present, void *dev_id);
2207 static void *wifi_status_cb_devid;
2208 int rk29sdk_wifi_power_state = 0;
2209 int rk29sdk_bt_power_state = 0;
2211 static int rk29sdk_wifi_status(struct device *dev)
2213 return rk29sdk_wifi_cd;
2216 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
2220 wifi_status_cb = callback;
2221 wifi_status_cb_devid = dev_id;
2225 static int rk29sdk_wifi_bt_gpio_control_init(void)
2227 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
2228 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
2232 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
2233 pr_info("%s: request wifi reset gpio failed\n", __func__);
2234 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
2238 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
2239 pr_info("%s: request bt reset gpio failed\n", __func__);
2240 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
2244 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2245 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2246 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
2248 pr_info("%s: init finished\n",__func__);
2253 static int rk29sdk_wifi_power(int on)
2255 pr_info("%s: %d\n", __func__, on);
2257 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
2259 pr_info("wifi turn on power\n");
2261 if (!rk29sdk_bt_power_state){
2262 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
2264 pr_info("wifi shut off power\n");
2267 pr_info("wifi shouldn't shut off power, bt is using it!\n");
2272 rk29sdk_wifi_power_state = on;
2276 static int rk29sdk_wifi_reset_state;
2277 static int rk29sdk_wifi_reset(int on)
2279 pr_info("%s: %d\n", __func__, on);
2280 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
2282 rk29sdk_wifi_reset_state = on;
2286 int rk29sdk_wifi_set_carddetect(int val)
2288 pr_info("%s:%d\n", __func__, val);
2289 rk29sdk_wifi_cd = val;
2290 if (wifi_status_cb){
2291 wifi_status_cb(val, wifi_status_cb_devid);
2293 pr_warning("%s, nobody to notify\n", __func__);
2297 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
2299 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
2300 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
2301 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
2302 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
2303 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
2306 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
2308 if (section == PREALLOC_WLAN_SEC_NUM)
2309 return wlan_static_skb;
2311 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
2314 if (wifi_mem_array[section].size < size)
2317 return wifi_mem_array[section].mem_ptr;
2320 int __init rk29sdk_init_wifi_mem(void)
2325 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
2326 wlan_static_skb[i] = dev_alloc_skb(
2327 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
2329 if (!wlan_static_skb[i])
2333 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
2334 wifi_mem_array[i].mem_ptr =
2335 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
2337 if (!wifi_mem_array[i].mem_ptr)
2343 pr_err("Failed to mem_alloc for WLAN\n");
2344 for (j = 0 ; j < i ; j++)
2345 kfree(wifi_mem_array[j].mem_ptr);
2347 i = WLAN_SKB_BUF_NUM;
2350 pr_err("Failed to skb_alloc for WLAN\n");
2351 for (j = 0 ; j < i ; j++)
2352 dev_kfree_skb(wlan_static_skb[j]);
2357 static struct wifi_platform_data rk29sdk_wifi_control = {
2358 .set_power = rk29sdk_wifi_power,
2359 .set_reset = rk29sdk_wifi_reset,
2360 .set_carddetect = rk29sdk_wifi_set_carddetect,
2361 .mem_prealloc = rk29sdk_mem_prealloc,
2363 static struct platform_device rk29sdk_wifi_device = {
2364 .name = "bcm4329_wlan",
2367 .platform_data = &rk29sdk_wifi_control,
2373 /* bluetooth rfkill device */
2374 static struct platform_device rk29sdk_rfkill = {
2375 .name = "rk29sdk_rfkill",
2380 #ifdef CONFIG_VIVANTE
2381 static struct resource resources_gpu[] = {
2386 .flags = IORESOURCE_IRQ,
2390 .start = RK29_GPU_PHYS,
2391 .end = RK29_GPU_PHYS + RK29_GPU_PHYS_SIZE,
2392 .flags = IORESOURCE_MEM,
2396 .start = PMEM_GPU_BASE,
2397 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE,
2398 .flags = IORESOURCE_MEM,
2401 static struct platform_device rk29_device_gpu = {
2404 .num_resources = ARRAY_SIZE(resources_gpu),
2405 .resource = resources_gpu,
2408 #ifdef CONFIG_KEYS_RK29
2409 extern struct rk29_keys_platform_data rk29_keys_pdata;
2410 static struct platform_device rk29_device_keys = {
2411 .name = "rk29-keypad",
2414 .platform_data = &rk29_keys_pdata,
2419 static void __init rk29_board_iomux_init(void)
2421 #ifdef CONFIG_UART0_RK29
2422 rk29_mux_api_set(GPIO1B7_UART0SOUT_NAME, GPIO1L_UART0_SOUT);
2423 rk29_mux_api_set(GPIO1B6_UART0SIN_NAME, GPIO1L_UART0_SIN);
2424 #ifdef CONFIG_UART0_CTS_RTS_RK29
2425 rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N);
2426 rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_UART0_CTS_N);
2429 #ifdef CONFIG_UART1_RK29
2430 rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
2431 rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
2433 #ifdef CONFIG_UART2_RK29
2434 rk29_mux_api_set(GPIO2B1_UART2SOUT_NAME, GPIO2L_UART2_SOUT);
2435 rk29_mux_api_set(GPIO2B0_UART2SIN_NAME, GPIO2L_UART2_SIN);
2436 #ifdef CONFIG_UART2_CTS_RTS_RK29
2437 rk29_mux_api_set(GPIO2A7_UART2RTSN_NAME, GPIO2L_UART2_RTS_N);
2438 rk29_mux_api_set(GPIO2A6_UART2CTSN_NAME, GPIO2L_UART2_CTS_N);
2441 #ifdef CONFIG_UART3_RK29
2442 rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
2443 rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
2444 #ifdef CONFIG_UART3_CTS_RTS_RK29
2445 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_UART3_RTS_N);
2446 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_UART3_CTS_N);
2449 #ifdef CONFIG_SPIM0_RK29
2450 rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME, GPIO2H_SPI0_CLK);
2451 rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME, GPIO2H_SPI0_CSN0);
2452 rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME, GPIO2H_SPI0_TXD);
2453 rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME, GPIO2H_SPI0_RXD);
2455 #ifdef CONFIG_SPIM1_RK29
2456 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK);
2457 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME, GPIO2H_SPI1_CSN0);
2458 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME, GPIO2H_SPI1_TXD);
2459 rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME, GPIO2H_SPI1_RXD);
2461 #ifdef CONFIG_RK29_VMAC
2462 rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME, GPIO4H_RMII_CLKOUT);
2463 rk29_mux_api_set(GPIO4C1_RMIITXEN_MIITXEN_NAME, GPIO4H_RMII_TX_EN);
2464 rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME, GPIO4H_RMII_TXD1);
2465 rk29_mux_api_set(GPIO4C3_RMIITXD0_MIITXD0_NAME, GPIO4H_RMII_TXD0);
2466 rk29_mux_api_set(GPIO4C4_RMIIRXERR_MIIRXERR_NAME, GPIO4H_RMII_RX_ERR);
2467 rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME, GPIO4H_RMII_CSR_DVALID);
2468 rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME, GPIO4H_RMII_RXD1);
2469 rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME, GPIO4H_RMII_RXD0);
2471 rk29_mux_api_set(GPIO0A7_MIIMDCLK_NAME, GPIO0L_MII_MDCLK);
2472 rk29_mux_api_set(GPIO0A6_MIIMD_NAME, GPIO0L_MII_MD);
2474 #ifdef CONFIG_RK29_PWM_REGULATOR
2475 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
2479 static struct platform_device *devices[] __initdata = {
2480 #ifdef CONFIG_UART1_RK29
2483 #ifdef CONFIG_UART0_RK29
2486 #ifdef CONFIG_UART2_RK29
2490 #ifdef CONFIG_RK29_PWM_REGULATOR
2491 &rk29_device_pwm_regulator,
2493 #ifdef CONFIG_SPIM0_RK29
2494 &rk29xx_device_spi0m,
2496 #ifdef CONFIG_SPIM1_RK29
2497 &rk29xx_device_spi1m,
2499 #ifdef CONFIG_ADC_RK29
2502 #ifdef CONFIG_I2C0_RK29
2505 #ifdef CONFIG_I2C1_RK29
2508 #ifdef CONFIG_I2C2_RK29
2511 #ifdef CONFIG_I2C3_RK29
2515 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
2516 &rk29_device_iis_2ch,
2518 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
2519 &rk29_device_iis_8ch,
2522 #ifdef CONFIG_KEYS_RK29
2525 #ifdef CONFIG_SDMMC0_RK29
2526 &rk29_device_sdmmc0,
2528 #ifdef CONFIG_SDMMC1_RK29
2529 &rk29_device_sdmmc1,
2532 #ifdef CONFIG_MTD_NAND_RK29XX
2533 &rk29xx_device_nand,
2536 #ifdef CONFIG_WIFI_CONTROL_FUNC
2537 &rk29sdk_wifi_device,
2544 #ifdef CONFIG_MTD_NAND_RK29
2548 #ifdef CONFIG_FB_RK29
2550 &rk29_device_dma_cpy,
2552 #ifdef CONFIG_BACKLIGHT_RK29_BL
2553 &rk29_device_backlight,
2555 #ifdef CONFIG_RK29_VMAC
2558 #ifdef CONFIG_VIVANTE
2561 #ifdef CONFIG_VIDEO_RK29
2562 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
2563 #if (SENSOR_IIC_ADDR_0 != 0x00)
2564 &rk29_soc_camera_pdrv_0,
2566 &rk29_soc_camera_pdrv_1,
2567 &android_pmem_cam_device,
2569 &android_pmem_device,
2570 &rk29_vpu_mem_device,
2571 #ifdef CONFIG_USB20_OTG
2572 &rk29_device_usb20_otg,
2574 #ifdef CONFIG_USB20_HOST
2575 &rk29_device_usb20_host,
2577 #ifdef CONFIG_USB11_HOST
2578 &rk29_device_usb11_host,
2580 #ifdef CONFIG_USB_ANDROID
2581 &android_usb_device,
2582 &usb_mass_storage_device,
2584 #ifdef CONFIG_RK29_IPP
2587 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2588 &rk29_v4l2_output_devce,
2592 #ifdef CONFIG_RK29_VMAC
2593 /*****************************************************************************************
2595 * author: lyx@rock-chips.com
2596 *****************************************************************************************/
2597 static int rk29_vmac_register_set(void)
2599 //config rk29 vmac as rmii, 100MHz
2600 u32 value= readl(RK29_GRF_BASE + 0xbc);
2601 value = (value & 0xfff7ff) | (0x400);
2602 writel(value, RK29_GRF_BASE + 0xbc);
2606 static int rk29_rmii_io_init(void)
2611 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2613 gpio_free(RK29_PIN6_PB0);
2614 printk("-------request RK29_PIN6_PB0 fail--------\n");
2618 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2619 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2624 static int rk29_rmii_io_deinit(void)
2627 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2628 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2630 gpio_free(RK29_PIN6_PB0);
2634 static int rk29_rmii_power_control(int enable)
2638 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2639 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2642 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2643 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2648 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2649 .vmac_register_set = rk29_vmac_register_set,
2650 .rmii_io_init = rk29_rmii_io_init,
2651 .rmii_io_deinit = rk29_rmii_io_deinit,
2652 .rmii_power_control = rk29_rmii_power_control,
2656 /*****************************************************************************************
2658 * author: cmc@rock-chips.com
2659 *****************************************************************************************/
2660 #define SPI_CHIPSELECT_NUM 2
2661 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2664 .cs_gpio = RK29_PIN2_PC1,
2665 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2666 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2670 .cs_gpio = RK29_PIN1_PA4,
2671 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2672 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2676 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2679 .cs_gpio = RK29_PIN2_PC5,
2680 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2681 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2685 .cs_gpio = RK29_PIN1_PA3,
2686 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2687 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2691 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2696 for (i=0; i<cs_num; i++) {
2697 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2704 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2709 static int spi_io_fix_leakage_bug(void)
2712 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2717 static int spi_io_resume_leakage_bug(void)
2720 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2725 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2726 .num_chipselect = SPI_CHIPSELECT_NUM,
2727 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2728 .io_init = spi_io_init,
2729 .io_deinit = spi_io_deinit,
2730 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2731 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2734 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2735 .num_chipselect = SPI_CHIPSELECT_NUM,
2736 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2737 .io_init = spi_io_init,
2738 .io_deinit = spi_io_deinit,
2739 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2740 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2743 /*****************************************************************************************
2744 * xpt2046 touch panel
2745 * author: hhb@rock-chips.com
2746 *****************************************************************************************/
2747 #define XPT2046_GPIO_INT RK29_PIN4_PD5 //中断脚
2748 #define DEBOUNCE_REPTIME 3
2750 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
2751 static struct xpt2046_platform_data xpt2046_info = {
2756 .debounce_rep = DEBOUNCE_REPTIME,
2758 .gpio_pendown = XPT2046_GPIO_INT,
2759 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
2760 .pendown_iomux_mode = GPIO4H_GPIO4D5,
2761 .touch_virtualkey_length = 60,
2762 .penirq_recheck_delay_usecs = 1,
2763 #if defined(CONFIG_TOUCHSCREEN_480X800)
2768 .touch_ad_top = 3940,
2769 .touch_ad_bottom = 310,
2770 .touch_ad_left = 3772,
2771 .touch_ad_right = 340,
2772 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2777 .touch_ad_top = 2447,
2778 .touch_ad_bottom = 207,
2779 .touch_ad_left = 5938,
2780 .touch_ad_right = 153,
2781 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2786 .touch_ad_top = 3166,
2787 .touch_ad_bottom = 256,
2788 .touch_ad_left = 3658,
2789 .touch_ad_right = 380,
2792 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2793 static struct xpt2046_platform_data xpt2046_info = {
2798 .debounce_rep = DEBOUNCE_REPTIME,
2800 .gpio_pendown = XPT2046_GPIO_INT,
2801 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
2802 .pendown_iomux_mode = GPIO4H_GPIO4D5,
2803 .touch_virtualkey_length = 60,
2804 .penirq_recheck_delay_usecs = 1,
2806 #if defined(CONFIG_TOUCHSCREEN_480X800)
2811 .screen_x = { 70, 410, 70, 410, 240},
2812 .screen_y = { 50, 50, 740, 740, 400},
2813 .uncali_x_default = { 3267, 831, 3139, 715, 1845 },
2814 .uncali_y_default = { 3638, 3664, 564, 591, 2087 },
2815 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2820 .screen_x[5] = { 50, 750, 50, 750, 400};
2821 .screen_y[5] = { 40, 40, 440, 440, 240};
2822 .uncali_x_default[5] = { 438, 565, 3507, 3631, 2105 };
2823 .uncali_y_default[5] = { 3756, 489, 3792, 534, 2159 };
2824 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2829 .screen_x[5] = { 50, 270, 50, 270, 160};
2830 .screen_y[5] = { 40, 40, 440, 440, 240};
2831 .uncali_x_default[5] = { 812, 3341, 851, 3371, 2183 };
2832 .uncali_y_default[5] = { 442, 435, 3193, 3195, 2004 };
2837 static struct spi_board_info board_spi_devices[] = {
2838 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2840 .modalias = "xpt2046_ts",
2841 .chip_select = 0,// 2,
2842 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2844 .irq = XPT2046_GPIO_INT,
2845 .platform_data = &xpt2046_info,
2849 #if defined(CONFIG_MFD_WM831X_SPI)
2851 .modalias = "wm8310",
2853 .max_speed_hz = 12*1000*1000,
2855 .irq = RK29_PIN4_PD0,
2856 .platform_data = &wm831x_platdata,
2863 static void __init rk29_gic_init_irq(void)
2865 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2866 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2869 static void __init machine_rk29_init_irq(void)
2871 rk29_gic_init_irq();
2875 #define POWER_ON_PIN RK29_PIN4_PA4
2876 static void rk29_pm_power_off(void)
2878 printk(KERN_ERR "rk29_pm_power_off start...\n");
2879 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2883 static void __init machine_rk29_board_init(void)
2885 rk29_board_iomux_init();
2887 gpio_request(POWER_ON_PIN,"poweronpin");
2888 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
2889 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2890 pm_power_off = rk29_pm_power_off;
2892 #ifdef CONFIG_WIFI_CONTROL_FUNC
2893 rk29sdk_wifi_bt_gpio_control_init();
2896 platform_add_devices(devices, ARRAY_SIZE(devices));
2897 #ifdef CONFIG_I2C0_RK29
2898 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2899 ARRAY_SIZE(board_i2c0_devices));
2901 #ifdef CONFIG_I2C1_RK29
2902 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2903 ARRAY_SIZE(board_i2c1_devices));
2905 #ifdef CONFIG_I2C2_RK29
2906 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2907 ARRAY_SIZE(board_i2c2_devices));
2909 #ifdef CONFIG_I2C3_RK29
2910 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2911 ARRAY_SIZE(board_i2c3_devices));
2914 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2916 rk29sdk_init_wifi_mem();
2919 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2920 char **cmdline, struct meminfo *mi)
2923 mi->bank[0].start = RK29_SDRAM_PHYS;
2924 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
2925 mi->bank[0].size = LINUX_SIZE;
2928 static void __init machine_rk29_mapio(void)
2930 rk29_map_common_io();
2931 rk29_setup_early_printk();
2937 MACHINE_START(RK29, "RK29board")
2938 /* UART for LL DEBUG */
2939 .phys_io = RK29_UART1_PHYS,
2940 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2941 .boot_params = RK29_SDRAM_PHYS + 0x88000,
2942 .fixup = machine_rk29_fixup,
2943 .map_io = machine_rk29_mapio,
2944 .init_irq = machine_rk29_init_irq,
2945 .init_machine = machine_rk29_board_init,
2946 .timer = &rk29_timer,