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>
60 #if defined(CONFIG_MTK23D)
61 #include <linux/mtk23d.h>
64 #include "../../../drivers/headset_observe/rk_headset.h"
65 /*set touchscreen different type header*/
66 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI)
67 #include "../../../drivers/input/touchscreen/xpt2046_ts.h"
68 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
69 #include "../../../drivers/input/touchscreen/xpt2046_tslib_ts.h"
70 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
71 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
74 #include "../../../drivers/misc/gps/rk29_gps.h"
76 /* Set memory size of pmem */
77 #ifdef CONFIG_RK29_MEM_SIZE_M
78 #define SDRAM_SIZE (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
80 #define SDRAM_SIZE SZ_512M
82 #define PMEM_GPU_SIZE SZ_64M
83 #define PMEM_UI_SIZE SZ_32M
84 #define PMEM_VPU_SIZE SZ_64M
85 #define PMEM_CAM_SIZE 0x01300000
86 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
87 #define MEM_CAMIPP_SIZE SZ_4M
89 #define MEM_CAMIPP_SIZE 0
91 #define MEM_FB_SIZE (3*SZ_2M)
93 #define PMEM_GPU_BASE ((u32)RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
94 #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE)
95 #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE)
96 #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE)
97 #define MEM_CAMIPP_BASE (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
98 #define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
99 #define LINUX_SIZE (MEM_FB_BASE - RK29_SDRAM_PHYS)
101 #define PREALLOC_WLAN_SEC_NUM 4
102 #define PREALLOC_WLAN_BUF_NUM 160
103 #define PREALLOC_WLAN_SECTION_HEADER 24
105 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
106 #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
107 #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
108 #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
110 #define WLAN_SKB_BUF_NUM 16
112 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
114 struct wifi_mem_prealloc {
119 extern struct sys_timer rk29_timer;
121 static int rk29_nand_io_init(void)
126 struct rk29_nand_platform_data rk29_nand_data = {
127 .width = 1, /* data bus width in bytes */
128 .hw_ecc = 1, /* hw ecc 0: soft ecc */
130 .io_init = rk29_nand_io_init,
133 #ifdef CONFIG_FB_RK29
134 /*****************************************************************************************
136 * author: zyw@rock-chips.com
137 *****************************************************************************************/
138 //#ifdef CONFIG_LCD_TD043MGEA1
139 #define LCD_RXD_PIN RK29_PIN2_PC7
140 #define LCD_TXD_PIN RK29_PIN2_PC6
141 #define LCD_CLK_PIN RK29_PIN2_PC4
142 #define LCD_CS_PIN RK29_PIN2_PC5
143 /*****************************************************************************************
144 * frame buffer devices
145 * author: zyw@rock-chips.com
146 *****************************************************************************************/
148 #define FB_DISPLAY_ON_PIN INVALID_GPIO//RK29_PIN6_PD0
149 #define FB_LCD_STANDBY_PIN INVALID_GPIO//RK29_PIN6_PD1
150 #define FB_LCD_CABC_EN_PIN INVALID_GPIO//RK29_PIN6_PD2
151 #define FB_MCU_FMK_PIN INVALID_GPIO
153 #define FB_DISPLAY_ON_VALUE GPIO_HIGH
154 #define FB_LCD_STANDBY_VALUE GPIO_HIGH
157 static int rk29_lcd_io_init(void)
160 //printk("rk29_lcd_io_init\n");
161 //ret = gpio_request(LCD_RXD_PIN, NULL);
162 ret = gpio_request(LCD_TXD_PIN, NULL);
163 ret = gpio_request(LCD_CLK_PIN, NULL);
164 ret = gpio_request(LCD_CS_PIN, NULL);
165 //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_GPIO2C7);
166 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_GPIO2C6);
167 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_GPIO2C5);
168 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_GPIO2C4);
172 static int rk29_lcd_io_deinit(void)
175 //printk("rk29_lcd_io_deinit\n");
176 gpio_free(LCD_CS_PIN);
177 gpio_free(LCD_CLK_PIN);
178 gpio_free(LCD_TXD_PIN);
179 //gpio_free(LCD_RXD_PIN);
180 //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_SPI1_RXD);
181 rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_SPI1_TXD);
182 rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_SPI1_CSN0);
183 rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_SPI1_CLK);
187 static struct rk29lcd_info rk29_lcd_info = {
188 .txd_pin = LCD_TXD_PIN,
189 .clk_pin = LCD_CLK_PIN,
190 .cs_pin = LCD_CS_PIN,
191 .io_init = rk29_lcd_io_init,
192 .io_deinit = rk29_lcd_io_deinit,
196 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
199 if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
201 ret = gpio_request(FB_MCU_FMK_PIN, NULL);
204 gpio_free(FB_MCU_FMK_PIN);
205 printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
207 gpio_direction_input(FB_MCU_FMK_PIN);
209 if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
211 ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
214 gpio_free(FB_DISPLAY_ON_PIN);
215 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
219 if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
221 ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
224 gpio_free(FB_LCD_STANDBY_PIN);
225 printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
229 if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
231 ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
234 gpio_free(FB_LCD_CABC_EN_PIN);
235 printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
237 gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
238 gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
244 static struct rk29fb_info rk29_fb_info = {
246 .disp_on_pin = FB_DISPLAY_ON_PIN,
247 .disp_on_value = FB_DISPLAY_ON_VALUE,
248 .standby_pin = FB_LCD_STANDBY_PIN,
249 .standby_value = FB_LCD_STANDBY_VALUE,
250 .mcu_fmk_pin = FB_MCU_FMK_PIN,
251 .lcd_info = &rk29_lcd_info,
252 .io_init = rk29_fb_io_init,
255 /* rk29 fb resource */
256 static struct resource rk29_fb_resource[] = {
259 .start = RK29_LCDC_PHYS,
260 .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
261 .flags = IORESOURCE_MEM,
267 .flags = IORESOURCE_IRQ,
271 .start = MEM_FB_BASE,
272 .end = MEM_FB_BASE + MEM_FB_SIZE,
273 .flags = IORESOURCE_MEM,
278 struct platform_device rk29_device_fb = {
281 .num_resources = ARRAY_SIZE(rk29_fb_resource),
282 .resource = rk29_fb_resource,
284 .platform_data = &rk29_fb_info,
288 struct platform_device rk29_device_dma_cpy = {
289 .name = "dma_memcpy",
296 static struct android_pmem_platform_data android_pmem_pdata = {
298 .start = PMEM_UI_BASE,
299 .size = PMEM_UI_SIZE,
304 static struct platform_device android_pmem_device = {
305 .name = "android_pmem",
308 .platform_data = &android_pmem_pdata,
313 static struct android_pmem_platform_data android_pmem_cam_pdata = {
315 .start = PMEM_CAM_BASE,
316 .size = PMEM_CAM_SIZE,
321 static struct platform_device android_pmem_cam_device = {
322 .name = "android_pmem",
325 .platform_data = &android_pmem_cam_pdata,
330 static struct vpu_mem_platform_data vpu_mem_pdata = {
332 .start = PMEM_VPU_BASE,
333 .size = PMEM_VPU_SIZE,
337 static struct platform_device rk29_vpu_mem_device = {
341 .platform_data = &vpu_mem_pdata,
345 static struct platform_device rk29_v4l2_output_devce = {
349 /* HANNSTAR_P1003 touch I2C */
350 #if defined (CONFIG_HANNSTAR_P1003)
351 #define TOUCH_RESET_PIN RK29_PIN6_PC3
352 #define TOUCH_INT_PIN RK29_PIN4_PD5
354 int p1003_init_platform_hw(void)
356 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
357 gpio_free(TOUCH_RESET_PIN);
358 printk("p1003_init_platform_hw gpio_request error\n");
362 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
363 gpio_free(TOUCH_INT_PIN);
364 printk("p1003_init_platform_hw gpio_request error\n");
367 gpio_pull_updown(TOUCH_INT_PIN, 1);
368 gpio_direction_output(TOUCH_RESET_PIN, 0);
370 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
372 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
378 struct p1003_platform_data p1003_info = {
380 .init_platform_hw= p1003_init_platform_hw,
385 #if defined(CONFIG_TOUCHSCREEN_GT801_IIC)
386 #include "../../../drivers/input/touchscreen/gt801_ts.h"
387 #define GT801_GPIO_INT RK29_PIN4_PD5
388 #define GT801_GPIO_RESET RK29_PIN6_PC3
389 static struct gt801_platform_data gt801_info = {
396 .gpio_reset = GT801_GPIO_RESET,
397 .gpio_reset_active_low = 0,
398 .gpio_pendown = GT801_GPIO_INT,
399 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
400 .resetpin_iomux_name = NULL,
401 .pendown_iomux_mode = GPIO4H_GPIO4D5,
402 .resetpin_iomux_mode = 0,
406 /* EETI_EGALAX touch I2C */
407 #if defined (CONFIG_EETI_EGALAX)
408 #define TOUCH_RESET_PIN RK29_PIN6_PC3
409 #define TOUCH_INT_PIN RK29_PIN4_PD5
411 static int EETI_EGALAX_init_platform_hw(void)
413 if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
414 gpio_free(TOUCH_RESET_PIN);
415 printk("p1003_init_platform_hw gpio_request error\n");
419 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
420 gpio_free(TOUCH_INT_PIN);
421 printk("p1003_init_platform_hw gpio_request error\n");
424 gpio_pull_updown(TOUCH_INT_PIN, 1);
425 gpio_direction_output(TOUCH_RESET_PIN, 0);
427 gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
429 gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
435 static struct eeti_egalax_platform_data eeti_egalax_info = {
437 .init_platform_hw= EETI_EGALAX_init_platform_hw,
443 #if defined (CONFIG_GS_MMA8452)
444 #define MMA8452_INT_PIN RK29_PIN6_PC4
446 static int mma8452_init_platform_hw(void)
449 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
450 gpio_free(MMA8452_INT_PIN);
451 printk("mma8452_init_platform_hw gpio_request error\n");
454 gpio_pull_updown(MMA8452_INT_PIN, 1);
459 static struct mma8452_platform_data mma8452_info = {
462 .init_platform_hw= mma8452_init_platform_hw,
467 #if defined(CONFIG_GPIO_WM831X)
468 struct rk29_gpio_expander_info wm831x_gpio_settinginfo[] = {
470 .gpio_num =WM831X_P01,// tp3
471 .pin_type = GPIO_OUT,
472 .pin_value =GPIO_HIGH,
476 .gpio_num =WM831X_P02,//tp4
477 .pin_type = GPIO_OUT,
478 .pin_value =GPIO_HIGH,
481 .gpio_num =WM831X_P03,//tp2
482 .pin_type = GPIO_OUT,
483 .pin_value =GPIO_HIGH,
486 .gpio_num =WM831X_P04,//tp1
487 .pin_type = GPIO_OUT,
488 .pin_value =GPIO_HIGH,
491 .gpio_num =WM831X_P05,//tp1
492 .pin_type = GPIO_OUT,
493 .pin_value =GPIO_HIGH,
496 .gpio_num =WM831X_P06,//tp1
497 .pin_type = GPIO_OUT,
498 .pin_value =GPIO_HIGH,
501 .gpio_num =WM831X_P07,//tp1
502 .pin_type = GPIO_OUT,
503 .pin_value =GPIO_HIGH,
506 .gpio_num =WM831X_P08,//tp1
507 .pin_type = GPIO_OUT,
508 .pin_value =GPIO_HIGH,
511 .gpio_num =WM831X_P09,//tp1
512 .pin_type = GPIO_OUT,
513 .pin_value =GPIO_HIGH,
516 .gpio_num =WM831X_P10,//tp1
517 .pin_type = GPIO_OUT,
518 .pin_value =GPIO_HIGH,
521 .gpio_num =WM831X_P11,//tp1
522 .pin_type = GPIO_OUT,
523 .pin_value =GPIO_HIGH,
526 .gpio_num =WM831X_P12,
527 .pin_type = GPIO_OUT,
528 .pin_value =GPIO_HIGH,
536 #if defined(CONFIG_MFD_WM831X)
538 int wm831x_pre_init(struct wm831x *parm)
541 printk("%s\n", __FUNCTION__);
544 ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
545 wm831x_reg_write(parm, WM831X_POWER_STATE, (ret&0xfff8) | 0x04);
547 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 3), 0);
548 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 7), 0);
549 printk("%s:disable ldo4 and ldo8 because they are enabled in uboot\n",__FUNCTION__);
553 int wm831x_post_init(struct wm831x *parm)
555 struct regulator *dcdc;
556 struct regulator *ldo;
559 dcdc = regulator_get(NULL, "dcdc3"); // 1th IO
560 regulator_set_voltage(dcdc,3000000,3000000);
561 regulator_enable(dcdc);
562 printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
566 ldo = regulator_get(NULL, "ldo10"); // 1th modem IO
567 regulator_set_voltage(ldo,3000000,3000000);
568 regulator_enable(ldo);
569 printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
573 dcdc = regulator_get(NULL, "dcdc2"); // 2th CORE
574 regulator_set_voltage(dcdc,1300000,1300000);
575 regulator_enable(dcdc);
576 printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
580 dcdc = regulator_get(NULL, "dcdc1"); // 3th ddr
581 regulator_set_voltage(dcdc,1800000,1800000);
582 regulator_enable(dcdc);
583 printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
587 ldo = regulator_get(NULL, "ldo1"); // 3th nand
588 regulator_set_voltage(ldo,1800000,1800000);
589 regulator_enable(ldo);
590 printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
594 ldo = regulator_get(NULL, "ldo4"); // 4th usb
595 regulator_set_voltage(ldo,2500000,2500000);
596 regulator_enable(ldo);
597 printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
601 ldo = regulator_get(NULL, "ldo7"); // 5th usb
602 regulator_set_voltage(ldo,3300000,3300000);
603 regulator_enable(ldo);
604 printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
608 dcdc = regulator_get(NULL, "dcdc4"); // backlight
609 regulator_set_voltage(dcdc,20000000,20000000);
610 regulator_enable(dcdc);
611 printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
616 ldo = regulator_get(NULL, "ldo2"); //lcd
617 regulator_set_voltage(ldo,3000000,3000000);
618 regulator_enable(ldo);
619 printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
622 ldo = regulator_get(NULL, "ldo3"); //sram
623 regulator_set_voltage(ldo,1800000,1800000);
624 regulator_enable(ldo);
625 printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
628 ldo = regulator_get(NULL, "ldo5"); //tf
629 regulator_set_voltage(ldo,3000000,3000000);
630 regulator_enable(ldo);
631 printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
634 ldo = regulator_get(NULL, "ldo6"); //camera
635 regulator_set_voltage(ldo,1800000,1800000);
636 regulator_enable(ldo);
637 printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
640 ldo = regulator_get(NULL, "ldo8"); //cmmb
641 regulator_set_voltage(ldo,1200000,1200000);
642 regulator_enable(ldo);
643 printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
646 ldo = regulator_get(NULL, "ldo9"); //cmmb
647 regulator_set_voltage(ldo,3000000,3000000);
648 regulator_enable(ldo);
649 printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
654 ldo = regulator_get(NULL, "ldo11");
655 //regulator_enable(ldo);
656 printk("%s set ldo11=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
663 extern void wm831x_enter_sleep(void);
664 extern void wm831x_exit_sleep(void);
666 void pmu_wm831x_set_suspend_voltage(void)
670 EXPORT_SYMBOL_GPL(pmu_wm831x_set_suspend_voltage);
672 void pmu_wm831x_set_resume_voltage(void)
676 EXPORT_SYMBOL_GPL(pmu_wm831x_set_resume_voltage);
678 int wm831x_last_deinit(struct wm831x *parm)
680 printk("%s\n", __FUNCTION__);
685 struct wm831x_backlight_pdata wm831x_backlight_platdata = {
686 .isink = 1, /** ISINK to use, 1 or 2 */
687 .max_uA = 19484, /** Maximum current to allow */
690 struct wm831x_backup_pdata wm831x_backup_platdata = {
692 .no_constant_voltage = 0, /** Disable constant voltage charging */
693 .vlim = 3100, /** Voltage limit in milivolts */
694 .ilim = 300, /** Current limit in microamps */
697 struct wm831x_battery_pdata wm831x_battery_platdata = {
698 .enable = 1, /** Enable charging */
699 .fast_enable = 1, /** Enable fast charging */
700 .off_mask = 1, /** Mask OFF while charging */
701 .trickle_ilim = 200, /** Trickle charge current limit, in mA */
702 .vsel = 4200, /** Target voltage, in mV */
703 .eoc_iterm = 90, /** End of trickle charge current, in mA */
704 .fast_ilim = 1000, /** Fast charge current limit, in mA */
705 .timeout = 180, /** Charge cycle timeout, in minutes */
706 .syslo = 3300, /* syslo threshold, in mV*/
707 .sysok = 3500, /* sysko threshold, in mV*/
710 struct wm831x_status_pdata wm831x_status_platdata[WM831X_MAX_STATUS] = {
712 .default_src = WM831X_STATUS_OTP,
713 .name = "wm831x_status0",
714 .default_trigger = "wm831x_otp",
717 .default_src = WM831X_STATUS_POWER,
718 .name = "wm831x_status1",
719 .default_trigger = "wm831x_power",
724 static struct regulator_consumer_supply dcdc1_consumers[] = {
729 static struct regulator_consumer_supply dcdc2_consumers[] = {
734 static struct regulator_consumer_supply dcdc3_consumers[] = {
739 static struct regulator_consumer_supply dcdc4_consumers[] = {
744 static struct regulator_consumer_supply epe1_consumers[] = {
749 static struct regulator_consumer_supply epe2_consumers[] = {
754 static struct regulator_consumer_supply ldo1_consumers[] = {
759 static struct regulator_consumer_supply ldo2_consumers[] = {
764 static struct regulator_consumer_supply ldo3_consumers[] = {
769 static struct regulator_consumer_supply ldo4_consumers[] = {
774 static struct regulator_consumer_supply ldo5_consumers[] = {
779 static struct regulator_consumer_supply ldo6_consumers[] = {
784 static struct regulator_consumer_supply ldo7_consumers[] = {
789 static struct regulator_consumer_supply ldo8_consumers[] = {
794 static struct regulator_consumer_supply ldo9_consumers[] = {
799 static struct regulator_consumer_supply ldo10_consumers[] = {
804 static struct regulator_consumer_supply ldo11_consumers[] = {
809 static struct regulator_consumer_supply isink1_consumers[] = {
814 static struct regulator_consumer_supply isink2_consumers[] = {
820 struct regulator_init_data wm831x_regulator_init_dcdc[WM831X_MAX_DCDC] = {
825 .max_uV = 1800000,//0.6-1.8V
827 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
829 .num_consumer_supplies = ARRAY_SIZE(dcdc1_consumers),
830 .consumer_supplies = dcdc1_consumers,
836 .max_uV = 1800000,//0.6-1.8V
838 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
840 .num_consumer_supplies = ARRAY_SIZE(dcdc2_consumers),
841 .consumer_supplies = dcdc2_consumers,
847 .max_uV = 3400000,//0.85-3.4V
849 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
851 .num_consumer_supplies = ARRAY_SIZE(dcdc3_consumers),
852 .consumer_supplies = dcdc3_consumers,
858 .max_uV = 30000000,//30V/40mA
860 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
862 .num_consumer_supplies = ARRAY_SIZE(dcdc4_consumers),
863 .consumer_supplies = dcdc4_consumers,
867 struct regulator_init_data wm831x_regulator_init_epe[WM831X_MAX_EPE] = {
874 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
876 .num_consumer_supplies = ARRAY_SIZE(epe1_consumers),
877 .consumer_supplies = epe1_consumers,
885 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
887 .num_consumer_supplies = ARRAY_SIZE(epe2_consumers),
888 .consumer_supplies = epe2_consumers,
892 struct regulator_init_data wm831x_regulator_init_ldo[WM831X_MAX_LDO] = {
899 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
901 .num_consumer_supplies = ARRAY_SIZE(ldo1_consumers),
902 .consumer_supplies = ldo1_consumers,
910 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
912 .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
913 .consumer_supplies = ldo2_consumers,
921 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
923 .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
924 .consumer_supplies = ldo3_consumers,
932 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
934 .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
935 .consumer_supplies = ldo4_consumers,
943 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
945 .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
946 .consumer_supplies = ldo5_consumers,
954 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
956 .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers),
957 .consumer_supplies = ldo6_consumers,
965 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
967 .num_consumer_supplies = ARRAY_SIZE(ldo7_consumers),
968 .consumer_supplies = ldo7_consumers,
976 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
978 .num_consumer_supplies = ARRAY_SIZE(ldo8_consumers),
979 .consumer_supplies = ldo8_consumers,
987 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
989 .num_consumer_supplies = ARRAY_SIZE(ldo9_consumers),
990 .consumer_supplies = ldo9_consumers,
998 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1000 .num_consumer_supplies = ARRAY_SIZE(ldo10_consumers),
1001 .consumer_supplies = ldo10_consumers,
1009 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1011 .num_consumer_supplies = ARRAY_SIZE(ldo11_consumers),
1012 .consumer_supplies = ldo11_consumers,
1016 struct regulator_init_data wm831x_regulator_init_isink[WM831X_MAX_ISINK] = {
1024 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1026 .num_consumer_supplies = ARRAY_SIZE(isink1_consumers),
1027 .consumer_supplies = isink1_consumers,
1035 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1037 .num_consumer_supplies = ARRAY_SIZE(isink2_consumers),
1038 .consumer_supplies = isink2_consumers,
1042 static int wm831x_checkrange(int start,int num,int val)
1044 if((val<(start+num))&&(val>=start))
1050 static int wm831x_init_pin_type(struct wm831x *wm831x)
1053 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
1054 struct rk29_gpio_expander_info *wm831x_gpio_settinginfo;
1055 uint16_t offset = 0;
1056 uint16_t wm831x_settingpin_num = 0;
1062 wm831x_gpio_settinginfo=pdata->settinginfo;
1063 if(wm831x_gpio_settinginfo)
1065 wm831x_settingpin_num = pdata->settinginfolen;
1066 for(i=0;i<wm831x_settingpin_num;i++)
1068 if(!wm831x_checkrange(pdata->gpio_base,pdata->gpio_pin_num,wm831x_gpio_settinginfo[i].gpio_num))
1070 offset = wm831x_gpio_settinginfo[i].gpio_num - pdata->gpio_base;
1072 if(wm831x_gpio_settinginfo[i].pin_type==GPIO_IN)
1074 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);
1078 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_TRI_SHIFT);
1079 if(wm831x_gpio_settinginfo[i].pin_value==GPIO_HIGH)
1081 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(1 << offset));
1085 wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(0 << offset));
1094 for(i=0;i<pdata->gpio_pin_num;i++)
1096 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+i),
1097 WM831X_GPN_PULL_MASK|WM831X_GPN_POL_MASK|WM831X_GPN_OD_MASK|WM831X_GPN_TRI_MASK,
1098 1<<WM831X_GPN_POL_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
1099 ret = wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL+i);
1100 printk("Gpio%d Pin Configuration = %x\n",i,ret);
1109 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1110 static struct wm831x_gpio_keys_button wm831x_gpio_buttons[] = {
1113 .gpio = TCA6424_P21,
1117 .debounce_interval = 120,
1120 .code= KEY_VOLUMEUP,
1134 .code= KEY_VOLUMEDOWN,
1137 .desc= "volume_down",
1170 struct wm831x_gpio_keys_pdata wm831x_gpio_keys_platdata = {
1171 .buttons = wm831x_gpio_buttons,
1172 .nbuttons = ARRAY_SIZE(wm831x_gpio_buttons),
1176 struct wm831x_pdata wm831x_platdata = {
1177 /** Called before subdevices are set up */
1178 .pre_init= wm831x_pre_init,
1179 /** Called after subdevices are set up */
1180 .post_init = wm831x_post_init,
1181 /** Called before subdevices are power down */
1182 .last_deinit = wm831x_last_deinit,
1184 #if defined(CONFIG_GPIO_WM831X)
1185 .gpio_base=WM831X_GPIO_EXPANDER_BASE,
1186 .gpio_pin_num=WM831X_TOTOL_GPIO_NUM,
1187 .settinginfo=wm831x_gpio_settinginfo,
1188 .settinginfolen=ARRAY_SIZE(wm831x_gpio_settinginfo),
1189 .pin_type_init = wm831x_init_pin_type,
1190 .irq_base= NR_AIC_IRQS + 2*NUM_GROUP + TCA6424_TOTOL_GPIO_IRQ_NUM + CONFIG_SPI_FPGA_GPIO_IRQ_NUM,
1193 .backlight = &wm831x_backlight_platdata,
1195 .backup = &wm831x_backup_platdata,
1197 .battery = &wm831x_battery_platdata,
1198 //.wm831x_touch_pdata = NULL,
1201 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1202 .gpio_keys = &wm831x_gpio_keys_platdata,
1205 /** LED1 = 0 and so on */
1206 .status = {&wm831x_status_platdata[0], &wm831x_status_platdata[1]},
1208 /** DCDC1 = 0 and so on */
1209 .dcdc = {&wm831x_regulator_init_dcdc[0], &wm831x_regulator_init_dcdc[1], &wm831x_regulator_init_dcdc[2], &wm831x_regulator_init_dcdc[3]},
1211 /** EPE1 = 0 and so on */
1212 .epe = {&wm831x_regulator_init_epe[0], &wm831x_regulator_init_epe[1]},
1214 /** LDO1 = 0 and so on */
1215 .ldo = {&wm831x_regulator_init_ldo[0], &wm831x_regulator_init_ldo[1], &wm831x_regulator_init_ldo[2], &wm831x_regulator_init_ldo[3],
1216 &wm831x_regulator_init_ldo[4], &wm831x_regulator_init_ldo[5], &wm831x_regulator_init_ldo[6], &wm831x_regulator_init_ldo[7],
1217 &wm831x_regulator_init_ldo[8], &wm831x_regulator_init_ldo[9], &wm831x_regulator_init_ldo[10]},
1219 /** ISINK1 = 0 and so on*/
1220 .isink = {&wm831x_regulator_init_isink[0], &wm831x_regulator_init_isink[1]},
1226 #if defined(CONFIG_RK29_GPS)
1228 #define RK29_GPS_POWER_PIN RK29_PIN6_PB2
1229 #define RK29_GPS_RESET_PIN RK29_PIN6_PC1
1231 static int gps_open =0;
1233 int rk29_gps_power_up(void)
1236 printk("%s \n", __FUNCTION__);
1237 gpio_request(RK29_GPS_POWER_PIN, NULL);
1238 gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH);
1239 gpio_request(RK29_GPS_RESET_PIN, NULL);
1240 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);
1241 rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT);
1242 rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN);
1244 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);
1248 int rk29_gps_power_down(void)
1251 printk("%s \n", __FUNCTION__);
1252 gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW);
1254 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW); //uart1
1259 struct rk29_gps_data rk29_gps_info = {
1260 .power_up = rk29_gps_power_up,
1261 .power_down = rk29_gps_power_down,
1263 .powerpin = RK29_GPS_POWER_PIN,
1267 struct platform_device rk29_device_gps = {
1271 .platform_data = &rk29_gps_info,
1276 /*****************************************************************************************
1278 * author: qjb@rock-chips.com
1279 *****************************************************************************************/
1280 //#if defined(CONFIG_MFD_WM8994)
1281 #if defined (CONFIG_REGULATOR_WM8994)
1282 static struct regulator_consumer_supply wm8994_ldo1_consumers[] = {
1293 .supply = "SPKVDD1",
1296 static struct regulator_consumer_supply wm8994_ldo2_consumers[] = {
1304 .supply = "SPKVDD2",
1307 struct regulator_init_data regulator_init_data_ldo1 = {
1309 .name = "wm8994-ldo1",
1314 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1316 .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo1_consumers),
1317 .consumer_supplies = wm8994_ldo1_consumers,
1319 struct regulator_init_data regulator_init_data_ldo2 = {
1321 .name = "wm8994-ldo2",
1326 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
1328 .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo2_consumers),
1329 .consumer_supplies = wm8994_ldo2_consumers,
1332 struct wm8994_drc_cfg wm8994_drc_cfg_pdata = {
1333 .name = "wm8994_DRC",
1334 .regs = {0,0,0,0,0},
1337 struct wm8994_retune_mobile_cfg wm8994_retune_mobile_cfg_pdata = {
1338 .name = "wm8994_EQ",
1340 .regs = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
1343 struct wm8994_pdata wm8994_platdata = {
1344 #if defined (CONFIG_GPIO_WM8994)
1345 .gpio_base = WM8994_GPIO_EXPANDER_BASE,
1346 //Fill value to initialize the GPIO
1349 //enable=0 disable ldo
1350 #if defined (CONFIG_REGULATOR_WM8994)
1356 .init_data = ®ulator_init_data_ldo1,
1361 .init_data = ®ulator_init_data_ldo2,
1365 //DRC 0--use default
1367 .drc_cfgs = &wm8994_drc_cfg_pdata,
1369 .num_retune_mobile_cfgs = 0,
1370 .retune_mobile_cfgs = &wm8994_retune_mobile_cfg_pdata,
1388 #ifdef CONFIG_RK_HEADSET_DET
1389 #define HEADSET_GPIO RK29_PIN4_PD2
1390 struct rk2818_headset_data rk2818_headset_info = {
1391 .gpio = HEADSET_GPIO,
1392 .irq_type = IRQF_TRIGGER_RISING,//IRQF_TRIGGER_RISING -- ÉÏÉýÑØ IRQF_TRIGGER_FALLING -- ϽµÑØ
1393 .headset_in_type= HEADSET_IN_HIGH,
1396 struct platform_device rk28_device_headset = {
1397 .name = "rk2818_headsetdet",
1400 .platform_data = &rk2818_headset_info,
1405 /*****************************************************************************************
1407 * author: kfx@rock-chips.com
1408 *****************************************************************************************/
1409 static int rk29_i2c0_io_init(void)
1411 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
1412 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
1416 static int rk29_i2c1_io_init(void)
1418 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
1419 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
1422 static int rk29_i2c2_io_init(void)
1424 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
1425 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
1429 static int rk29_i2c3_io_init(void)
1431 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
1432 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1436 struct rk29_i2c_platform_data default_i2c0_data = {
1440 .scl_rate = 400*1000,
1441 .mode = I2C_MODE_IRQ,
1442 .io_init = rk29_i2c0_io_init,
1445 struct rk29_i2c_platform_data default_i2c1_data = {
1449 .scl_rate = 400*1000,
1450 .mode = I2C_MODE_POLL,
1451 .io_init = rk29_i2c1_io_init,
1454 struct rk29_i2c_platform_data default_i2c2_data = {
1458 .scl_rate = 400*1000,
1459 .mode = I2C_MODE_IRQ,
1460 .io_init = rk29_i2c2_io_init,
1463 struct rk29_i2c_platform_data default_i2c3_data = {
1467 .scl_rate = 400*1000,
1468 .mode = I2C_MODE_POLL,
1469 .io_init = rk29_i2c3_io_init,
1472 #ifdef CONFIG_I2C0_RK29
1473 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1474 #if defined (CONFIG_RK1000_CONTROL)
1476 .type = "rk1000_control",
1481 #if defined (CONFIG_SND_SOC_RK1000)
1483 .type = "rk1000_i2c_codec",
1488 #if defined (CONFIG_SND_SOC_WM8900)
1495 #if defined (CONFIG_SND_SOC_WM8994)
1500 // #if defined(CONFIG_MFD_WM8994)
1501 .platform_data = &wm8994_platdata,
1505 #if defined (CONFIG_BATTERY_STC3100)
1512 #if defined (CONFIG_BATTERY_BQ27510)
1519 #if defined (CONFIG_RTC_HYM8563)
1521 .type = "rtc_hym8563",
1524 .irq = RK29_PIN0_PA1,
1527 #if defined (CONFIG_GS_MMA8452)
1529 .type = "gs_mma8452",
1532 .irq = MMA8452_INT_PIN,
1533 .platform_data = &mma8452_info,
1536 #if defined (CONFIG_COMPASS_AK8973)
1541 .irq = RK29_PIN6_PC5,
1544 #if defined (CONFIG_COMPASS_AK8975)
1549 .irq = RK29_PIN6_PC5,
1552 #if defined (CONFIG_INPUT_LPSENSOR_ISL29028)
1557 .irq = RK29_PIN4_PD3,
1560 #if defined (CONFIG_ANX7150)
1563 .addr = 0x39, //0x39, 0x3d
1565 .irq = RK29_PIN2_PA3,
1571 #ifdef CONFIG_I2C1_RK29
1572 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1573 #if defined (CONFIG_RK1000_CONTROL1)
1575 .type = "rk1000_control",
1584 #ifdef CONFIG_I2C2_RK29
1585 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1586 #if defined (CONFIG_TOUCHSCREEN_GT801_IIC)
1591 .irq = RK29_PIN4_PD5,
1592 .platform_data = >801_info,
1595 #if defined (CONFIG_MFD_WM831X_I2C)
1600 .irq = RK29_PIN4_PD0,
1601 .platform_data = &wm831x_platdata,
1604 #if defined (CONFIG_HANNSTAR_P1003)
1606 .type = "p1003_touch",
1609 .irq = RK29_PIN0_PA2,
1610 .platform_data = &p1003_info,
1613 #if defined (CONFIG_EETI_EGALAX)
1615 .type = "egalax_i2c",
1618 .irq = RK29_PIN4_PD5,
1619 .platform_data = &eeti_egalax_info,
1625 #ifdef CONFIG_I2C3_RK29
1626 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1630 /*****************************************************************************************
1632 * author: ddl@rock-chips.com
1633 *****************************************************************************************/
1634 #ifdef CONFIG_VIDEO_RK29
1635 #define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_OV5642 /* back camera sensor */
1636 #define SENSOR_IIC_ADDR_0 0x78
1637 #define SENSOR_IIC_ADAPTER_ID_0 1
1638 #define SENSOR_POWER_PIN_0 INVALID_GPIO
1639 #define SENSOR_RESET_PIN_0 INVALID_GPIO
1640 #define SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
1641 #define SENSOR_FALSH_PIN_0 INVALID_GPIO
1642 #define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
1643 #define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
1644 #define SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
1645 #define SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
1647 #define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_OV2659 /* front camera sensor */
1648 #define SENSOR_IIC_ADDR_1 0x60
1649 #define SENSOR_IIC_ADAPTER_ID_1 1
1650 #define SENSOR_POWER_PIN_1 INVALID_GPIO
1651 #define SENSOR_RESET_PIN_1 INVALID_GPIO
1652 #define SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
1653 #define SENSOR_FALSH_PIN_1 INVALID_GPIO
1654 #define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
1655 #define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
1656 #define SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
1657 #define SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
1659 static int rk29_sensor_io_init(void);
1660 static int rk29_sensor_io_deinit(int sensor);
1661 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
1663 static struct rk29camera_platform_data rk29_camera_platform_data = {
1664 .io_init = rk29_sensor_io_init,
1665 .io_deinit = rk29_sensor_io_deinit,
1666 .sensor_ioctrl = rk29_sensor_ioctrl,
1669 .gpio_reset = SENSOR_RESET_PIN_0,
1670 .gpio_power = SENSOR_POWER_PIN_0,
1671 .gpio_powerdown = SENSOR_POWERDN_PIN_0,
1672 .gpio_flash = SENSOR_FALSH_PIN_0,
1673 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0|SENSOR_POWERDNACTIVE_LEVEL_0|SENSOR_FLASHACTIVE_LEVEL_0),
1675 .dev_name = SENSOR_NAME_0,
1677 .gpio_reset = SENSOR_RESET_PIN_1,
1678 .gpio_power = SENSOR_POWER_PIN_1,
1679 .gpio_powerdown = SENSOR_POWERDN_PIN_1,
1680 .gpio_flash = SENSOR_FALSH_PIN_1,
1681 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1|SENSOR_POWERDNACTIVE_LEVEL_1|SENSOR_FLASHACTIVE_LEVEL_1),
1683 .dev_name = SENSOR_NAME_1,
1686 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
1688 .name = "camera_ipp_mem",
1689 .start = MEM_CAMIPP_BASE,
1690 .size = MEM_CAMIPP_SIZE,
1695 static int rk29_sensor_io_init(void)
1698 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1699 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1700 unsigned int camera_ioflag;
1702 for (i=0; i<2; i++) {
1703 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
1704 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
1705 camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
1706 camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
1707 camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
1708 rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
1710 if (camera_power != INVALID_GPIO) {
1711 ret = gpio_request(camera_power, "camera power");
1713 goto sensor_io_int_loop_end;
1714 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
1715 gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1716 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1718 //printk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1722 if (camera_reset != INVALID_GPIO) {
1723 ret = gpio_request(camera_reset, "camera reset");
1725 goto sensor_io_int_loop_end;
1726 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
1727 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1728 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1730 //printk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1734 if (camera_powerdown != INVALID_GPIO) {
1735 ret = gpio_request(camera_powerdown, "camera powerdown");
1737 goto sensor_io_int_loop_end;
1738 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
1739 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1740 gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1742 //printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1746 if (camera_flash != INVALID_GPIO) {
1747 ret = gpio_request(camera_flash, "camera flash");
1749 goto sensor_io_int_loop_end;
1750 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
1751 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1752 gpio_direction_output(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1754 //printk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1758 sensor_io_int_loop_end:
1759 rk29_sensor_io_deinit(i);
1766 static int rk29_sensor_io_deinit(int sensor)
1768 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1769 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1771 camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
1772 camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
1773 camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
1774 camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
1776 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
1777 if (camera_power != INVALID_GPIO) {
1778 gpio_direction_input(camera_power);
1779 gpio_free(camera_power);
1783 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
1784 if (camera_reset != INVALID_GPIO) {
1785 gpio_direction_input(camera_reset);
1786 gpio_free(camera_reset);
1790 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
1791 if (camera_powerdown != INVALID_GPIO) {
1792 gpio_direction_input(camera_powerdown);
1793 gpio_free(camera_powerdown);
1797 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
1798 if (camera_flash != INVALID_GPIO) {
1799 gpio_direction_input(camera_flash);
1800 gpio_free(camera_flash);
1804 rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
1807 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
1809 unsigned int camera_power=INVALID_GPIO,camera_reset=INVALID_GPIO, camera_powerdown=INVALID_GPIO,camera_flash = INVALID_GPIO;
1810 unsigned int camera_ioflag,camera_io_init;
1811 int ret = RK29_CAM_IO_SUCCESS;
1813 if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
1814 camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
1815 camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
1816 camera_powerdown = rk29_camera_platform_data.gpio_res[0].gpio_powerdown;
1817 camera_flash = rk29_camera_platform_data.gpio_res[0].gpio_flash;
1818 camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
1819 camera_io_init = rk29_camera_platform_data.gpio_res[0].gpio_init;
1820 } 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)) {
1821 camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
1822 camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
1823 camera_powerdown = rk29_camera_platform_data.gpio_res[1].gpio_powerdown;
1824 camera_flash = rk29_camera_platform_data.gpio_res[1].gpio_flash;
1825 camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
1826 camera_io_init = rk29_camera_platform_data.gpio_res[1].gpio_init;
1833 if (camera_power != INVALID_GPIO) {
1834 if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
1836 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1837 //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));
1840 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1841 //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));
1844 ret = RK29_CAM_EIO_REQUESTFAIL;
1845 printk("\n%s..%s..PowerPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1848 ret = RK29_CAM_EIO_INVALID;
1854 if (camera_reset != INVALID_GPIO) {
1855 if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
1857 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1858 //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));
1860 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1861 //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));
1864 ret = RK29_CAM_EIO_REQUESTFAIL;
1865 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1868 ret = RK29_CAM_EIO_INVALID;
1875 if (camera_powerdown != INVALID_GPIO) {
1876 if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
1878 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1879 //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));
1881 gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1882 //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));
1885 ret = RK29_CAM_EIO_REQUESTFAIL;
1886 printk("\n%s..%s..PowerDownPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_powerdown);
1889 ret = RK29_CAM_EIO_INVALID;
1896 if (camera_flash != INVALID_GPIO) {
1897 if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
1902 gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1903 //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));
1909 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1910 //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));
1916 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1917 //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));
1923 printk("\n%s..%s..Flash command(%d) is invalidate \n",__FUNCTION__,dev_name(dev),on);
1928 ret = RK29_CAM_EIO_REQUESTFAIL;
1929 printk("\n%s..%s..FlashPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_flash);
1932 ret = RK29_CAM_EIO_INVALID;
1939 printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
1945 static int rk29_sensor_power(struct device *dev, int on)
1947 rk29_sensor_ioctrl(dev,Cam_Power,on);
1950 static int rk29_sensor_reset(struct device *dev)
1952 rk29_sensor_ioctrl(dev,Cam_Reset,1);
1954 rk29_sensor_ioctrl(dev,Cam_Reset,0);
1957 static int rk29_sensor_powerdown(struct device *dev, int on)
1959 return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
1961 #if (SENSOR_IIC_ADDR_0 != 0x00)
1962 static struct i2c_board_info rk29_i2c_cam_info_0[] = {
1964 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
1968 static struct soc_camera_link rk29_iclink_0 = {
1969 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1970 .power = rk29_sensor_power,
1971 .powerdown = rk29_sensor_powerdown,
1972 .board_info = &rk29_i2c_cam_info_0[0],
1973 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
1974 .module_name = SENSOR_NAME_0,
1977 /*platform_device : soc-camera need */
1978 static struct platform_device rk29_soc_camera_pdrv_0 = {
1979 .name = "soc-camera-pdrv",
1982 .init_name = SENSOR_NAME_0,
1983 .platform_data = &rk29_iclink_0,
1987 static struct i2c_board_info rk29_i2c_cam_info_1[] = {
1989 I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
1993 static struct soc_camera_link rk29_iclink_1 = {
1994 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1995 .power = rk29_sensor_power,
1996 .powerdown = rk29_sensor_powerdown,
1997 .board_info = &rk29_i2c_cam_info_1[0],
1998 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
1999 .module_name = SENSOR_NAME_1,
2002 /*platform_device : soc-camera need */
2003 static struct platform_device rk29_soc_camera_pdrv_1 = {
2004 .name = "soc-camera-pdrv",
2007 .init_name = SENSOR_NAME_1,
2008 .platform_data = &rk29_iclink_1,
2013 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
2014 static struct resource rk29_camera_resource[] = {
2016 .start = RK29_VIP_PHYS,
2017 .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
2018 .flags = IORESOURCE_MEM,
2023 .flags = IORESOURCE_IRQ,
2027 /*platform_device : */
2028 static struct platform_device rk29_device_camera = {
2029 .name = RK29_CAM_DRV_NAME,
2030 .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
2031 .num_resources = ARRAY_SIZE(rk29_camera_resource),
2032 .resource = rk29_camera_resource,
2034 .dma_mask = &rockchip_device_camera_dmamask,
2035 .coherent_dma_mask = 0xffffffffUL,
2036 .platform_data = &rk29_camera_platform_data,
2040 /*****************************************************************************************
2042 * author: nzy@rock-chips.com
2043 *****************************************************************************************/
2044 #ifdef CONFIG_BACKLIGHT_RK29_BL
2046 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
2047 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
2048 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
2049 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
2053 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
2054 #define PWM_MUX_MODE GPIO1L_PWM0
2055 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
2056 #define PWM_EFFECT_VALUE 1
2058 //#define LCD_DISP_ON_PIN
2060 #ifdef LCD_DISP_ON_PIN
2061 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
2062 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
2064 #define BL_EN_PIN GPIO0L_GPIO0A5
2065 #define BL_EN_VALUE GPIO_HIGH
2067 static int rk29_backlight_io_init(void)
2071 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
2072 #ifdef LCD_DISP_ON_PIN
2073 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
2075 ret = gpio_request(BL_EN_PIN, NULL);
2078 gpio_free(BL_EN_PIN);
2081 gpio_direction_output(BL_EN_PIN, 0);
2082 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
2087 static int rk29_backlight_io_deinit(void)
2090 #ifdef LCD_DISP_ON_PIN
2091 gpio_free(BL_EN_PIN);
2093 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
2096 struct rk29_bl_info rk29_bl_info = {
2098 .bl_ref = PWM_EFFECT_VALUE,
2099 .io_init = rk29_backlight_io_init,
2100 .io_deinit = rk29_backlight_io_deinit,
2103 /*****************************************************************************************
2104 * pwm voltage regulator devices
2105 ******************************************************************************************/
2106 #if defined (CONFIG_RK29_PWM_REGULATOR)
2108 #define REGULATOR_PWM_ID 2
2109 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
2110 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
2111 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
2112 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
2114 static struct regulator_consumer_supply pwm_consumers[] = {
2120 static struct regulator_init_data rk29_pwm_regulator_data = {
2126 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
2128 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
2129 .consumer_supplies = pwm_consumers,
2132 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
2133 .pwm_id = REGULATOR_PWM_ID,
2134 .pwm_gpio = REGULATOR_PWM_GPIO,
2135 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
2136 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
2137 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
2138 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
2139 .init_data = &rk29_pwm_regulator_data,
2142 static struct platform_device rk29_device_pwm_regulator = {
2143 .name = "pwm-voltage-regulator",
2146 .platform_data = &rk29_regulator_pwm_platform_data,
2153 #if defined(CONFIG_MTK23D)
2154 struct rk2818_23d_data rk2818_23d_info = {
2155 .bp_power = RK29_PIN0_PA0,
2156 .bp_reset = RK29_PIN0_PA1,
2157 .bp_statue = RK29_PIN0_PA3,//input high bp sleep;
2158 .ap_statue = RK29_PIN0_PA2,//output high ap sleep;
2159 .ap_bp_wakeup = RK29_PIN0_PA4, //output AP wake up BP used rising edge;
2160 //.bp_ap_wakeup = RK2818_PIN_PE0,//input BP wake up AP
2162 struct platform_device rk2818_device_mtk23d = {
2166 .platform_data = &rk2818_23d_info,
2172 /*****************************************************************************************
2174 *****************************************************************************************/
2175 #ifdef CONFIG_SDMMC0_RK29
2176 static int rk29_sdmmc0_cfg_gpio(void)
2178 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
2179 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
2180 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
2181 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
2182 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
2183 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
2184 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
2185 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
2186 gpio_request(RK29_PIN5_PD5,"sdmmc");
2187 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
2189 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
2193 #define CONFIG_SDMMC0_USE_DMA
2194 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
2195 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
2196 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
2197 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
2198 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2199 .io_init = rk29_sdmmc0_cfg_gpio,
2200 .dma_name = "sd_mmc",
2201 #ifdef CONFIG_SDMMC0_USE_DMA
2208 #ifdef CONFIG_SDMMC1_RK29
2209 #define CONFIG_SDMMC1_USE_DMA
2210 static int rk29_sdmmc1_cfg_gpio(void)
2212 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2213 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2214 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2215 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2216 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2217 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2218 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
2222 #ifdef CONFIG_WIFI_CONTROL_FUNC
2223 static int rk29sdk_wifi_status(struct device *dev);
2224 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
2227 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
2229 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
2230 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
2231 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
2232 MMC_VDD_32_33|MMC_VDD_33_34),
2233 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
2234 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2235 .io_init = rk29_sdmmc1_cfg_gpio,
2237 #ifdef CONFIG_SDMMC1_USE_DMA
2242 #ifdef CONFIG_WIFI_CONTROL_FUNC
2243 .status = rk29sdk_wifi_status,
2244 .register_status_notify = rk29sdk_wifi_status_register,
2247 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
2252 #ifdef CONFIG_WIFI_CONTROL_FUNC
2253 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
2254 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
2255 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC7
2257 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
2258 static void (*wifi_status_cb)(int card_present, void *dev_id);
2259 static void *wifi_status_cb_devid;
2260 int rk29sdk_wifi_power_state = 0;
2261 int rk29sdk_bt_power_state = 0;
2263 static int rk29sdk_wifi_status(struct device *dev)
2265 return rk29sdk_wifi_cd;
2268 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
2272 wifi_status_cb = callback;
2273 wifi_status_cb_devid = dev_id;
2277 static int rk29sdk_wifi_bt_gpio_control_init(void)
2279 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
2280 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
2284 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
2285 pr_info("%s: request wifi reset gpio failed\n", __func__);
2286 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
2290 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
2291 pr_info("%s: request bt reset gpio failed\n", __func__);
2292 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
2296 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2297 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
2298 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_HIGH);
2300 pr_info("%s: init finished\n",__func__);
2305 static int rk29sdk_wifi_power(int on)
2307 pr_info("%s: %d\n", __func__, on);
2309 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
2311 pr_info("wifi turn on power\n");
2313 if (!rk29sdk_bt_power_state){
2314 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
2316 pr_info("wifi shut off power\n");
2319 pr_info("wifi shouldn't shut off power, bt is using it!\n");
2324 rk29sdk_wifi_power_state = on;
2328 static int rk29sdk_wifi_reset_state;
2329 static int rk29sdk_wifi_reset(int on)
2331 pr_info("%s: %d\n", __func__, on);
2332 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
2334 rk29sdk_wifi_reset_state = on;
2338 int rk29sdk_wifi_set_carddetect(int val)
2340 pr_info("%s:%d\n", __func__, val);
2341 rk29sdk_wifi_cd = val;
2342 if (wifi_status_cb){
2343 wifi_status_cb(val, wifi_status_cb_devid);
2345 pr_warning("%s, nobody to notify\n", __func__);
2349 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
2351 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
2352 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
2353 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
2354 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
2355 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
2358 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
2360 if (section == PREALLOC_WLAN_SEC_NUM)
2361 return wlan_static_skb;
2363 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
2366 if (wifi_mem_array[section].size < size)
2369 return wifi_mem_array[section].mem_ptr;
2372 int __init rk29sdk_init_wifi_mem(void)
2377 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
2378 wlan_static_skb[i] = dev_alloc_skb(
2379 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
2381 if (!wlan_static_skb[i])
2385 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
2386 wifi_mem_array[i].mem_ptr =
2387 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
2389 if (!wifi_mem_array[i].mem_ptr)
2395 pr_err("Failed to mem_alloc for WLAN\n");
2396 for (j = 0 ; j < i ; j++)
2397 kfree(wifi_mem_array[j].mem_ptr);
2399 i = WLAN_SKB_BUF_NUM;
2402 pr_err("Failed to skb_alloc for WLAN\n");
2403 for (j = 0 ; j < i ; j++)
2404 dev_kfree_skb(wlan_static_skb[j]);
2409 static struct wifi_platform_data rk29sdk_wifi_control = {
2410 .set_power = rk29sdk_wifi_power,
2411 .set_reset = rk29sdk_wifi_reset,
2412 .set_carddetect = rk29sdk_wifi_set_carddetect,
2413 .mem_prealloc = rk29sdk_mem_prealloc,
2415 static struct platform_device rk29sdk_wifi_device = {
2416 .name = "bcm4329_wlan",
2419 .platform_data = &rk29sdk_wifi_control,
2425 /* bluetooth rfkill device */
2426 static struct platform_device rk29sdk_rfkill = {
2427 .name = "rk29sdk_rfkill",
2432 #ifdef CONFIG_VIVANTE
2433 static struct resource resources_gpu[] = {
2438 .flags = IORESOURCE_IRQ,
2442 .start = RK29_GPU_PHYS,
2443 .end = RK29_GPU_PHYS + RK29_GPU_SIZE,
2444 .flags = IORESOURCE_MEM,
2448 .start = PMEM_GPU_BASE,
2449 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE,
2450 .flags = IORESOURCE_MEM,
2453 static struct platform_device rk29_device_gpu = {
2456 .num_resources = ARRAY_SIZE(resources_gpu),
2457 .resource = resources_gpu,
2460 #ifdef CONFIG_KEYS_RK29
2461 extern struct rk29_keys_platform_data rk29_keys_pdata;
2462 static struct platform_device rk29_device_keys = {
2463 .name = "rk29-keypad",
2466 .platform_data = &rk29_keys_pdata,
2471 static void __init rk29_board_iomux_init(void)
2473 #ifdef CONFIG_RK29_PWM_REGULATOR
2474 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
2478 static struct platform_device *devices[] __initdata = {
2479 #ifdef CONFIG_UART1_RK29
2482 #ifdef CONFIG_UART0_RK29
2485 #ifdef CONFIG_UART2_RK29
2488 #ifdef CONFIG_UART3_RK29
2492 #ifdef CONFIG_RK29_PWM_REGULATOR
2493 &rk29_device_pwm_regulator,
2495 #ifdef CONFIG_SPIM0_RK29
2496 &rk29xx_device_spi0m,
2498 #ifdef CONFIG_SPIM1_RK29
2499 &rk29xx_device_spi1m,
2501 #ifdef CONFIG_ADC_RK29
2504 #ifdef CONFIG_I2C0_RK29
2507 #ifdef CONFIG_I2C1_RK29
2510 #ifdef CONFIG_I2C2_RK29
2513 #ifdef CONFIG_I2C3_RK29
2517 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
2518 &rk29_device_iis_2ch,
2520 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
2521 &rk29_device_iis_8ch,
2524 #ifdef CONFIG_KEYS_RK29
2527 #ifdef CONFIG_SDMMC0_RK29
2528 &rk29_device_sdmmc0,
2530 #ifdef CONFIG_SDMMC1_RK29
2531 &rk29_device_sdmmc1,
2534 #ifdef CONFIG_MTD_NAND_RK29XX
2535 &rk29xx_device_nand,
2538 #ifdef CONFIG_WIFI_CONTROL_FUNC
2539 &rk29sdk_wifi_device,
2546 #if defined(CONFIG_MTK23D)
2547 &rk2818_device_mtk23d,
2550 #ifdef CONFIG_MTD_NAND_RK29
2554 #ifdef CONFIG_FB_RK29
2556 &rk29_device_dma_cpy,
2558 #ifdef CONFIG_BACKLIGHT_RK29_BL
2559 &rk29_device_backlight,
2561 #ifdef CONFIG_RK29_VMAC
2564 #ifdef CONFIG_VIVANTE
2567 #ifdef CONFIG_VIDEO_RK29
2568 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
2569 #if (SENSOR_IIC_ADDR_0 != 0x00)
2570 &rk29_soc_camera_pdrv_0,
2572 &rk29_soc_camera_pdrv_1,
2573 &android_pmem_cam_device,
2575 &android_pmem_device,
2576 &rk29_vpu_mem_device,
2577 #ifdef CONFIG_USB20_OTG
2578 &rk29_device_usb20_otg,
2580 #ifdef CONFIG_USB20_HOST
2581 &rk29_device_usb20_host,
2583 #ifdef CONFIG_USB11_HOST
2584 &rk29_device_usb11_host,
2586 #ifdef CONFIG_USB_ANDROID
2587 &android_usb_device,
2588 &usb_mass_storage_device,
2590 #ifdef CONFIG_RK29_IPP
2593 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2594 &rk29_v4l2_output_devce,
2596 #ifdef CONFIG_RK_HEADSET_DET
2597 &rk28_device_headset,
2601 #ifdef CONFIG_RK29_VMAC
2602 /*****************************************************************************************
2604 * author: lyx@rock-chips.com
2605 *****************************************************************************************/
2606 static int rk29_vmac_register_set(void)
2608 //config rk29 vmac as rmii, 100MHz
2609 u32 value= readl(RK29_GRF_BASE + 0xbc);
2610 value = (value & 0xfff7ff) | (0x400);
2611 writel(value, RK29_GRF_BASE + 0xbc);
2615 static int rk29_rmii_io_init(void)
2620 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2622 gpio_free(RK29_PIN6_PB0);
2623 printk("-------request RK29_PIN6_PB0 fail--------\n");
2627 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2628 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2633 static int rk29_rmii_io_deinit(void)
2636 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2637 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2639 gpio_free(RK29_PIN6_PB0);
2643 static int rk29_rmii_power_control(int enable)
2647 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2648 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2651 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2652 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2657 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2658 .vmac_register_set = rk29_vmac_register_set,
2659 .rmii_io_init = rk29_rmii_io_init,
2660 .rmii_io_deinit = rk29_rmii_io_deinit,
2661 .rmii_power_control = rk29_rmii_power_control,
2665 /*****************************************************************************************
2667 * author: cmc@rock-chips.com
2668 *****************************************************************************************/
2669 #define SPI_CHIPSELECT_NUM 2
2670 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2673 .cs_gpio = RK29_PIN2_PC1,
2674 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2675 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2679 .cs_gpio = RK29_PIN1_PA4,
2680 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2681 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2685 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2688 .cs_gpio = RK29_PIN2_PC5,
2689 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2690 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2694 .cs_gpio = RK29_PIN1_PA3,
2695 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2696 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2700 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2705 for (i=0; i<cs_num; i++) {
2706 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2713 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2718 static int spi_io_fix_leakage_bug(void)
2721 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2726 static int spi_io_resume_leakage_bug(void)
2729 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2734 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2735 .num_chipselect = SPI_CHIPSELECT_NUM,
2736 .chipselect_gpios = rk29xx_spi0_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 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2744 .num_chipselect = SPI_CHIPSELECT_NUM,
2745 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2746 .io_init = spi_io_init,
2747 .io_deinit = spi_io_deinit,
2748 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2749 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2752 /*****************************************************************************************
2753 * xpt2046 touch panel
2754 * author: hhb@rock-chips.com
2755 *****************************************************************************************/
2756 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
2757 #define XPT2046_GPIO_INT RK29_PIN4_PD5 //ä¸æ
\96è
\84?#define DEBOUNCE_REPTIME 3
2759 static struct xpt2046_platform_data xpt2046_info = {
2764 .debounce_rep = DEBOUNCE_REPTIME,
2766 .gpio_pendown = XPT2046_GPIO_INT,
2767 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
2768 .pendown_iomux_mode = GPIO4H_GPIO4D5,
2769 .touch_virtualkey_length = 60,
2770 .penirq_recheck_delay_usecs = 1,
2771 #if defined(CONFIG_TOUCHSCREEN_480X800)
2776 .touch_ad_top = 3940,
2777 .touch_ad_bottom = 310,
2778 .touch_ad_left = 3772,
2779 .touch_ad_right = 340,
2780 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2785 .touch_ad_top = 2447,
2786 .touch_ad_bottom = 207,
2787 .touch_ad_left = 5938,
2788 .touch_ad_right = 153,
2789 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2794 .touch_ad_top = 3166,
2795 .touch_ad_bottom = 256,
2796 .touch_ad_left = 3658,
2797 .touch_ad_right = 380,
2800 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2801 static struct xpt2046_platform_data xpt2046_info = {
2806 .debounce_rep = DEBOUNCE_REPTIME,
2808 .gpio_pendown = XPT2046_GPIO_INT,
2809 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
2810 .pendown_iomux_mode = GPIO4H_GPIO4D5,
2811 .touch_virtualkey_length = 60,
2812 .penirq_recheck_delay_usecs = 1,
2814 #if defined(CONFIG_TOUCHSCREEN_480X800)
2819 .screen_x = { 70, 410, 70, 410, 240},
2820 .screen_y = { 50, 50, 740, 740, 400},
2821 .uncali_x_default = { 3267, 831, 3139, 715, 1845 },
2822 .uncali_y_default = { 3638, 3664, 564, 591, 2087 },
2823 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2828 .screen_x[5] = { 50, 750, 50, 750, 400};
2829 .screen_y[5] = { 40, 40, 440, 440, 240};
2830 .uncali_x_default[5] = { 438, 565, 3507, 3631, 2105 };
2831 .uncali_y_default[5] = { 3756, 489, 3792, 534, 2159 };
2832 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2837 .screen_x[5] = { 50, 270, 50, 270, 160};
2838 .screen_y[5] = { 40, 40, 440, 440, 240};
2839 .uncali_x_default[5] = { 812, 3341, 851, 3371, 2183 };
2840 .uncali_y_default[5] = { 442, 435, 3193, 3195, 2004 };
2845 static struct spi_board_info board_spi_devices[] = {
2846 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2848 .modalias = "xpt2046_ts",
2849 .chip_select = 0,// 2,
2850 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2852 .irq = XPT2046_GPIO_INT,
2853 .platform_data = &xpt2046_info,
2857 #if defined(CONFIG_MFD_WM831X_SPI)
2859 .modalias = "wm8310",
2861 .max_speed_hz = 1*1000*1000,
2863 .irq = RK29_PIN4_PD0,
2864 .platform_data = &wm831x_platdata,
2871 /**********************************************************************************************
2873 * The virtual keys for android "back", "home", "menu", "search", these four keys are touch key
2874 * on the touch screen panel. (added by hhb@rock-chips.com 2011.03.31)
2876 ***********************************************************************************************/
2877 static ssize_t rk29xx_virtual_keys_show(struct kobject *kobj,
2878 struct kobj_attribute *attr, char *buf)
2880 #if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
2881 || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC)
2882 /* center: x: home: 50, menu: 184, back: 315, search 435, y: 830*/
2883 /* centerx;centery;width;height; */
2885 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":315:815:120:50" //":50:830:98:50" //":210:796:98:50"
2886 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":85:815:88:50" // ":184:830:120:50" // ":435:796:120:50"
2887 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":184:815:100:50" //":315:830:100:50" //":320:796:100:50"
2888 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":435:815:88:50" //":50:815:98:50" // //":85:796:88:50"
2894 static struct kobj_attribute rk29xx_virtual_keys_attr = {
2896 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2897 .name = "virtualkeys.xpt2046-touchscreen",
2898 #elif defined(CONFIG_TOUCHSCREEN_HX8520_IIC)
2899 .name = "virtualkeys.hx8520-touchscreen",
2900 #elif defined(CONFIG_TOUCHSCREEN_GT801_IIC)
2901 .name = "virtualkeys.gt801-touchscreen",
2907 .show = &rk29xx_virtual_keys_show,
2910 static struct attribute *rk29xx_properties_attrs[] = {
2911 &rk29xx_virtual_keys_attr.attr,
2915 static struct attribute_group rk29xx_properties_attr_group = {
2916 .attrs = rk29xx_properties_attrs,
2918 static int rk29xx_virtual_keys_init(void)
2921 struct kobject *properties_kobj;
2922 printk("rk29xx_virtual_keys_init \n");
2923 properties_kobj = kobject_create_and_add("board_properties", NULL);
2924 if (properties_kobj)
2925 ret = sysfs_create_group(properties_kobj,
2926 &rk29xx_properties_attr_group);
2927 if (!properties_kobj || ret)
2929 pr_err("failed to create board_properties\n");
2935 static void __init rk29_gic_init_irq(void)
2937 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2938 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2941 static void __init machine_rk29_init_irq(void)
2943 rk29_gic_init_irq();
2947 #define POWER_ON_PIN RK29_PIN4_PA4
2948 static void rk29_pm_power_off(void)
2950 printk(KERN_ERR "rk29_pm_power_off start...\n");
2951 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2955 static void __init machine_rk29_board_init(void)
2957 rk29_board_iomux_init();
2959 gpio_request(POWER_ON_PIN,"poweronpin");
2960 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
2961 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2962 pm_power_off = rk29_pm_power_off;
2965 gpio_request(RK29_PIN5_PA1, NULL);
2966 gpio_direction_output(RK29_PIN5_PA1,GPIO_HIGH);
2967 gpio_free(RK29_PIN5_PA1);
2969 platform_add_devices(devices, ARRAY_SIZE(devices));
2970 #ifdef CONFIG_I2C0_RK29
2971 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2972 ARRAY_SIZE(board_i2c0_devices));
2974 #ifdef CONFIG_I2C1_RK29
2975 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2976 ARRAY_SIZE(board_i2c1_devices));
2978 #ifdef CONFIG_I2C2_RK29
2979 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2980 ARRAY_SIZE(board_i2c2_devices));
2982 #ifdef CONFIG_I2C3_RK29
2983 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2984 ARRAY_SIZE(board_i2c3_devices));
2987 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2989 #ifdef CONFIG_WIFI_CONTROL_FUNC
2990 rk29sdk_wifi_bt_gpio_control_init();
2991 rk29sdk_init_wifi_mem();
2994 rk29xx_virtual_keys_init();
2997 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2998 char **cmdline, struct meminfo *mi)
3001 mi->bank[0].start = RK29_SDRAM_PHYS;
3002 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
3003 mi->bank[0].size = LINUX_SIZE;
3006 static void __init machine_rk29_mapio(void)
3008 rk29_map_common_io();
3009 rk29_setup_early_printk();
3011 rk29_clock_init(periph_pll_288mhz);
3015 MACHINE_START(RK29, "RK29board")
3016 /* UART for LL DEBUG */
3017 .phys_io = RK29_UART1_PHYS,
3018 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
3019 .boot_params = RK29_SDRAM_PHYS + 0x88000,
3020 .fixup = machine_rk29_fixup,
3021 .map_io = machine_rk29_mapio,
3022 .init_irq = machine_rk29_init_irq,
3023 .init_machine = machine_rk29_board_init,
3024 .timer = &rk29_timer,