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/rk2818_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,
1386 #ifdef CONFIG_HEADSET_DET
1387 #define HEADSET_GPIO RK29_PIN4_PD2
1388 struct rk2818_headset_data rk2818_headset_info = {
1389 .gpio = HEADSET_GPIO,
1390 .irq_type = IRQF_TRIGGER_RISING,//IRQF_TRIGGER_RISING -- ÉÏÉýÑØ IRQF_TRIGGER_FALLING -- ϽµÑØ
1391 .headset_in_type= HEADSET_IN_HIGH,
1394 struct platform_device rk28_device_headset = {
1395 .name = "rk2818_headsetdet",
1398 .platform_data = &rk2818_headset_info,
1403 /*****************************************************************************************
1405 * author: kfx@rock-chips.com
1406 *****************************************************************************************/
1407 static int rk29_i2c0_io_init(void)
1409 rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
1410 rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
1414 static int rk29_i2c1_io_init(void)
1416 rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
1417 rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
1420 static int rk29_i2c2_io_init(void)
1422 rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
1423 rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
1427 static int rk29_i2c3_io_init(void)
1429 rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
1430 rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1434 struct rk29_i2c_platform_data default_i2c0_data = {
1438 .scl_rate = 400*1000,
1439 .mode = I2C_MODE_IRQ,
1440 .io_init = rk29_i2c0_io_init,
1443 struct rk29_i2c_platform_data default_i2c1_data = {
1447 .scl_rate = 400*1000,
1448 .mode = I2C_MODE_POLL,
1449 .io_init = rk29_i2c1_io_init,
1452 struct rk29_i2c_platform_data default_i2c2_data = {
1456 .scl_rate = 400*1000,
1457 .mode = I2C_MODE_IRQ,
1458 .io_init = rk29_i2c2_io_init,
1461 struct rk29_i2c_platform_data default_i2c3_data = {
1465 .scl_rate = 400*1000,
1466 .mode = I2C_MODE_POLL,
1467 .io_init = rk29_i2c3_io_init,
1470 #ifdef CONFIG_I2C0_RK29
1471 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1472 #if defined (CONFIG_RK1000_CONTROL)
1474 .type = "rk1000_control",
1479 #if defined (CONFIG_SND_SOC_RK1000)
1481 .type = "rk1000_i2c_codec",
1486 #if defined (CONFIG_SND_SOC_WM8900)
1493 #if defined (CONFIG_SND_SOC_WM8994)
1498 #if defined(CONFIG_MFD_WM8994)
1499 .platform_data = &wm8994_platdata,
1503 #if defined (CONFIG_BATTERY_STC3100)
1510 #if defined (CONFIG_BATTERY_BQ27510)
1517 #if defined (CONFIG_RTC_HYM8563)
1519 .type = "rtc_hym8563",
1522 .irq = RK29_PIN0_PA1,
1525 #if defined (CONFIG_GS_MMA8452)
1527 .type = "gs_mma8452",
1530 .irq = MMA8452_INT_PIN,
1531 .platform_data = &mma8452_info,
1534 #if defined (CONFIG_COMPASS_AK8973)
1539 .irq = RK29_PIN6_PC5,
1542 #if defined (CONFIG_COMPASS_AK8975)
1547 .irq = RK29_PIN6_PC5,
1550 #if defined (CONFIG_INPUT_LPSENSOR_ISL29028)
1555 .irq = RK29_PIN4_PD3,
1558 #if defined (CONFIG_ANX7150)
1561 .addr = 0x39, //0x39, 0x3d
1563 .irq = RK29_PIN2_PA3,
1569 #ifdef CONFIG_I2C1_RK29
1570 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1571 #if defined (CONFIG_RK1000_CONTROL1)
1573 .type = "rk1000_control",
1582 #ifdef CONFIG_I2C2_RK29
1583 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1584 #if defined (CONFIG_TOUCHSCREEN_GT801_IIC)
1589 .irq = RK29_PIN4_PD5,
1590 .platform_data = >801_info,
1593 #if defined (CONFIG_MFD_WM831X_I2C)
1598 .irq = RK29_PIN4_PD0,
1599 .platform_data = &wm831x_platdata,
1602 #if defined (CONFIG_HANNSTAR_P1003)
1604 .type = "p1003_touch",
1607 .irq = RK29_PIN0_PA2,
1608 .platform_data = &p1003_info,
1611 #if defined (CONFIG_EETI_EGALAX)
1613 .type = "egalax_i2c",
1616 .irq = RK29_PIN4_PD5,
1617 .platform_data = &eeti_egalax_info,
1623 #ifdef CONFIG_I2C3_RK29
1624 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1628 /*****************************************************************************************
1630 * author: ddl@rock-chips.com
1631 *****************************************************************************************/
1632 #ifdef CONFIG_VIDEO_RK29
1633 #define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_OV5642 /* back camera sensor */
1634 #define SENSOR_IIC_ADDR_0 0x78
1635 #define SENSOR_IIC_ADAPTER_ID_0 1
1636 #define SENSOR_POWER_PIN_0 INVALID_GPIO
1637 #define SENSOR_RESET_PIN_0 INVALID_GPIO
1638 #define SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
1639 #define SENSOR_FALSH_PIN_0 INVALID_GPIO
1640 #define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
1641 #define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
1642 #define SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
1643 #define SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
1645 #define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_OV2659 /* front camera sensor */
1646 #define SENSOR_IIC_ADDR_1 0x60
1647 #define SENSOR_IIC_ADAPTER_ID_1 1
1648 #define SENSOR_POWER_PIN_1 INVALID_GPIO
1649 #define SENSOR_RESET_PIN_1 INVALID_GPIO
1650 #define SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
1651 #define SENSOR_FALSH_PIN_1 INVALID_GPIO
1652 #define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
1653 #define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
1654 #define SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
1655 #define SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
1657 static int rk29_sensor_io_init(void);
1658 static int rk29_sensor_io_deinit(int sensor);
1659 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
1661 static struct rk29camera_platform_data rk29_camera_platform_data = {
1662 .io_init = rk29_sensor_io_init,
1663 .io_deinit = rk29_sensor_io_deinit,
1664 .sensor_ioctrl = rk29_sensor_ioctrl,
1667 .gpio_reset = SENSOR_RESET_PIN_0,
1668 .gpio_power = SENSOR_POWER_PIN_0,
1669 .gpio_powerdown = SENSOR_POWERDN_PIN_0,
1670 .gpio_flash = SENSOR_FALSH_PIN_0,
1671 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0|SENSOR_POWERDNACTIVE_LEVEL_0|SENSOR_FLASHACTIVE_LEVEL_0),
1673 .dev_name = SENSOR_NAME_0,
1675 .gpio_reset = SENSOR_RESET_PIN_1,
1676 .gpio_power = SENSOR_POWER_PIN_1,
1677 .gpio_powerdown = SENSOR_POWERDN_PIN_1,
1678 .gpio_flash = SENSOR_FALSH_PIN_1,
1679 .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1|SENSOR_POWERDNACTIVE_LEVEL_1|SENSOR_FLASHACTIVE_LEVEL_1),
1681 .dev_name = SENSOR_NAME_1,
1684 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
1686 .name = "camera_ipp_mem",
1687 .start = MEM_CAMIPP_BASE,
1688 .size = MEM_CAMIPP_SIZE,
1693 static int rk29_sensor_io_init(void)
1696 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1697 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1698 unsigned int camera_ioflag;
1700 for (i=0; i<2; i++) {
1701 camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
1702 camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
1703 camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
1704 camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
1705 camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
1706 rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
1708 if (camera_power != INVALID_GPIO) {
1709 ret = gpio_request(camera_power, "camera power");
1711 goto sensor_io_int_loop_end;
1712 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
1713 gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1714 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1716 //printk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1720 if (camera_reset != INVALID_GPIO) {
1721 ret = gpio_request(camera_reset, "camera reset");
1723 goto sensor_io_int_loop_end;
1724 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
1725 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1726 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1728 //printk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1732 if (camera_powerdown != INVALID_GPIO) {
1733 ret = gpio_request(camera_powerdown, "camera powerdown");
1735 goto sensor_io_int_loop_end;
1736 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
1737 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1738 gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1740 //printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1744 if (camera_flash != INVALID_GPIO) {
1745 ret = gpio_request(camera_flash, "camera flash");
1747 goto sensor_io_int_loop_end;
1748 rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
1749 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1750 gpio_direction_output(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1752 //printk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1756 sensor_io_int_loop_end:
1757 rk29_sensor_io_deinit(i);
1764 static int rk29_sensor_io_deinit(int sensor)
1766 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
1767 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
1769 camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
1770 camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
1771 camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
1772 camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
1774 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
1775 if (camera_power != INVALID_GPIO) {
1776 gpio_direction_input(camera_power);
1777 gpio_free(camera_power);
1781 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
1782 if (camera_reset != INVALID_GPIO) {
1783 gpio_direction_input(camera_reset);
1784 gpio_free(camera_reset);
1788 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
1789 if (camera_powerdown != INVALID_GPIO) {
1790 gpio_direction_input(camera_powerdown);
1791 gpio_free(camera_powerdown);
1795 if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
1796 if (camera_flash != INVALID_GPIO) {
1797 gpio_direction_input(camera_flash);
1798 gpio_free(camera_flash);
1802 rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
1805 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
1807 unsigned int camera_power=INVALID_GPIO,camera_reset=INVALID_GPIO, camera_powerdown=INVALID_GPIO,camera_flash = INVALID_GPIO;
1808 unsigned int camera_ioflag,camera_io_init;
1809 int ret = RK29_CAM_IO_SUCCESS;
1811 if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
1812 camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
1813 camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
1814 camera_powerdown = rk29_camera_platform_data.gpio_res[0].gpio_powerdown;
1815 camera_flash = rk29_camera_platform_data.gpio_res[0].gpio_flash;
1816 camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
1817 camera_io_init = rk29_camera_platform_data.gpio_res[0].gpio_init;
1818 } 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)) {
1819 camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
1820 camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
1821 camera_powerdown = rk29_camera_platform_data.gpio_res[1].gpio_powerdown;
1822 camera_flash = rk29_camera_platform_data.gpio_res[1].gpio_flash;
1823 camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
1824 camera_io_init = rk29_camera_platform_data.gpio_res[1].gpio_init;
1831 if (camera_power != INVALID_GPIO) {
1832 if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
1834 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1835 //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));
1838 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
1839 //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));
1842 ret = RK29_CAM_EIO_REQUESTFAIL;
1843 printk("\n%s..%s..PowerPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1846 ret = RK29_CAM_EIO_INVALID;
1852 if (camera_reset != INVALID_GPIO) {
1853 if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
1855 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1856 //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));
1858 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
1859 //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));
1862 ret = RK29_CAM_EIO_REQUESTFAIL;
1863 printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
1866 ret = RK29_CAM_EIO_INVALID;
1873 if (camera_powerdown != INVALID_GPIO) {
1874 if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
1876 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1877 //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));
1879 gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1880 //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));
1883 ret = RK29_CAM_EIO_REQUESTFAIL;
1884 printk("\n%s..%s..PowerDownPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_powerdown);
1887 ret = RK29_CAM_EIO_INVALID;
1894 if (camera_flash != INVALID_GPIO) {
1895 if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
1900 gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1901 //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));
1907 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1908 //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));
1914 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
1915 //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));
1921 printk("\n%s..%s..Flash command(%d) is invalidate \n",__FUNCTION__,dev_name(dev),on);
1926 ret = RK29_CAM_EIO_REQUESTFAIL;
1927 printk("\n%s..%s..FlashPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_flash);
1930 ret = RK29_CAM_EIO_INVALID;
1937 printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
1943 static int rk29_sensor_power(struct device *dev, int on)
1945 rk29_sensor_ioctrl(dev,Cam_Power,on);
1948 static int rk29_sensor_reset(struct device *dev)
1950 rk29_sensor_ioctrl(dev,Cam_Reset,1);
1952 rk29_sensor_ioctrl(dev,Cam_Reset,0);
1955 static int rk29_sensor_powerdown(struct device *dev, int on)
1957 return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
1959 #if (SENSOR_IIC_ADDR_0 != 0x00)
1960 static struct i2c_board_info rk29_i2c_cam_info_0[] = {
1962 I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
1966 static struct soc_camera_link rk29_iclink_0 = {
1967 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1968 .power = rk29_sensor_power,
1969 .powerdown = rk29_sensor_powerdown,
1970 .board_info = &rk29_i2c_cam_info_0[0],
1971 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
1972 .module_name = SENSOR_NAME_0,
1975 /*platform_device : soc-camera need */
1976 static struct platform_device rk29_soc_camera_pdrv_0 = {
1977 .name = "soc-camera-pdrv",
1980 .init_name = SENSOR_NAME_0,
1981 .platform_data = &rk29_iclink_0,
1985 static struct i2c_board_info rk29_i2c_cam_info_1[] = {
1987 I2C_BOARD_INFO(SENSOR_NAME_1, SENSOR_IIC_ADDR_1>>1)
1991 static struct soc_camera_link rk29_iclink_1 = {
1992 .bus_id = RK29_CAM_PLATFORM_DEV_ID,
1993 .power = rk29_sensor_power,
1994 .powerdown = rk29_sensor_powerdown,
1995 .board_info = &rk29_i2c_cam_info_1[0],
1996 .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
1997 .module_name = SENSOR_NAME_1,
2000 /*platform_device : soc-camera need */
2001 static struct platform_device rk29_soc_camera_pdrv_1 = {
2002 .name = "soc-camera-pdrv",
2005 .init_name = SENSOR_NAME_1,
2006 .platform_data = &rk29_iclink_1,
2011 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
2012 static struct resource rk29_camera_resource[] = {
2014 .start = RK29_VIP_PHYS,
2015 .end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
2016 .flags = IORESOURCE_MEM,
2021 .flags = IORESOURCE_IRQ,
2025 /*platform_device : */
2026 static struct platform_device rk29_device_camera = {
2027 .name = RK29_CAM_DRV_NAME,
2028 .id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
2029 .num_resources = ARRAY_SIZE(rk29_camera_resource),
2030 .resource = rk29_camera_resource,
2032 .dma_mask = &rockchip_device_camera_dmamask,
2033 .coherent_dma_mask = 0xffffffffUL,
2034 .platform_data = &rk29_camera_platform_data,
2038 /*****************************************************************************************
2040 * author: nzy@rock-chips.com
2041 *****************************************************************************************/
2042 #ifdef CONFIG_BACKLIGHT_RK29_BL
2044 GPIO1B5_PWM0_NAME, GPIO1L_PWM0
2045 GPIO5D2_PWM1_UART1SIRIN_NAME, GPIO5H_PWM1
2046 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME, GPIO2L_PWM2
2047 GPIO1A5_EMMCPWREN_PWM3_NAME, GPIO1L_PWM3
2051 #define PWM_MUX_NAME GPIO1B5_PWM0_NAME
2052 #define PWM_MUX_MODE GPIO1L_PWM0
2053 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
2054 #define PWM_EFFECT_VALUE 1
2056 //#define LCD_DISP_ON_PIN
2058 #ifdef LCD_DISP_ON_PIN
2059 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
2060 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
2062 #define BL_EN_PIN GPIO0L_GPIO0A5
2063 #define BL_EN_VALUE GPIO_HIGH
2065 static int rk29_backlight_io_init(void)
2069 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
2070 #ifdef LCD_DISP_ON_PIN
2071 rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
2073 ret = gpio_request(BL_EN_PIN, NULL);
2076 gpio_free(BL_EN_PIN);
2079 gpio_direction_output(BL_EN_PIN, 0);
2080 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
2085 static int rk29_backlight_io_deinit(void)
2088 #ifdef LCD_DISP_ON_PIN
2089 gpio_free(BL_EN_PIN);
2091 rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
2094 struct rk29_bl_info rk29_bl_info = {
2096 .bl_ref = PWM_EFFECT_VALUE,
2097 .io_init = rk29_backlight_io_init,
2098 .io_deinit = rk29_backlight_io_deinit,
2101 /*****************************************************************************************
2102 * pwm voltage regulator devices
2103 ******************************************************************************************/
2104 #if defined (CONFIG_RK29_PWM_REGULATOR)
2106 #define REGULATOR_PWM_ID 2
2107 #define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
2108 #define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
2109 #define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
2110 #define REGULATOR_PWM_GPIO RK29_PIN2_PA3
2112 static struct regulator_consumer_supply pwm_consumers[] = {
2118 static struct regulator_init_data rk29_pwm_regulator_data = {
2124 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
2126 .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
2127 .consumer_supplies = pwm_consumers,
2130 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
2131 .pwm_id = REGULATOR_PWM_ID,
2132 .pwm_gpio = REGULATOR_PWM_GPIO,
2133 //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
2134 .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
2135 .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
2136 .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
2137 .init_data = &rk29_pwm_regulator_data,
2140 static struct platform_device rk29_device_pwm_regulator = {
2141 .name = "pwm-voltage-regulator",
2144 .platform_data = &rk29_regulator_pwm_platform_data,
2151 #if defined(CONFIG_MTK23D)
2152 struct rk2818_23d_data rk2818_23d_info = {
2153 .bp_power = RK29_PIN0_PA0,
2154 .bp_reset = RK29_PIN0_PA1,
2155 .bp_statue = RK29_PIN0_PA3,//input high bp sleep;
2156 .ap_statue = RK29_PIN0_PA2,//output high ap sleep;
2157 .ap_bp_wakeup = RK29_PIN0_PA4, //output AP wake up BP used rising edge;
2158 //.bp_ap_wakeup = RK2818_PIN_PE0,//input BP wake up AP
2160 struct platform_device rk2818_device_mtk23d = {
2164 .platform_data = &rk2818_23d_info,
2170 /*****************************************************************************************
2172 *****************************************************************************************/
2173 #ifdef CONFIG_SDMMC0_RK29
2174 static int rk29_sdmmc0_cfg_gpio(void)
2176 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
2177 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
2178 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
2179 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
2180 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
2181 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
2182 rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
2183 rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
2184 gpio_request(RK29_PIN5_PD5,"sdmmc");
2185 gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
2187 gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
2191 #define CONFIG_SDMMC0_USE_DMA
2192 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
2193 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
2194 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
2195 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
2196 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2197 .io_init = rk29_sdmmc0_cfg_gpio,
2198 .dma_name = "sd_mmc",
2199 #ifdef CONFIG_SDMMC0_USE_DMA
2206 #ifdef CONFIG_SDMMC1_RK29
2207 #define CONFIG_SDMMC1_USE_DMA
2208 static int rk29_sdmmc1_cfg_gpio(void)
2210 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2211 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2212 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2213 rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2214 rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2215 rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2216 //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
2220 #ifdef CONFIG_WIFI_CONTROL_FUNC
2221 static int rk29sdk_wifi_status(struct device *dev);
2222 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
2225 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK29_PIN1_PD6
2227 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
2228 .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
2229 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
2230 MMC_VDD_32_33|MMC_VDD_33_34),
2231 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
2232 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2233 .io_init = rk29_sdmmc1_cfg_gpio,
2235 #ifdef CONFIG_SDMMC1_USE_DMA
2240 #ifdef CONFIG_WIFI_CONTROL_FUNC
2241 .status = rk29sdk_wifi_status,
2242 .register_status_notify = rk29sdk_wifi_status_register,
2245 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
2250 #ifdef CONFIG_WIFI_CONTROL_FUNC
2251 #define RK29SDK_WIFI_BT_GPIO_POWER_N RK29_PIN5_PD6
2252 #define RK29SDK_WIFI_GPIO_RESET_N RK29_PIN6_PC0
2253 #define RK29SDK_BT_GPIO_RESET_N RK29_PIN6_PC7
2255 static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */
2256 static void (*wifi_status_cb)(int card_present, void *dev_id);
2257 static void *wifi_status_cb_devid;
2258 int rk29sdk_wifi_power_state = 0;
2259 int rk29sdk_bt_power_state = 0;
2261 static int rk29sdk_wifi_status(struct device *dev)
2263 return rk29sdk_wifi_cd;
2266 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
2270 wifi_status_cb = callback;
2271 wifi_status_cb_devid = dev_id;
2275 static int rk29sdk_wifi_bt_gpio_control_init(void)
2277 if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
2278 pr_info("%s: request wifi_bt power gpio failed\n", __func__);
2282 if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
2283 pr_info("%s: request wifi reset gpio failed\n", __func__);
2284 gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
2288 if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
2289 pr_info("%s: request bt reset gpio failed\n", __func__);
2290 gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
2294 gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2295 gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
2296 gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_HIGH);
2298 pr_info("%s: init finished\n",__func__);
2303 static int rk29sdk_wifi_power(int on)
2305 pr_info("%s: %d\n", __func__, on);
2307 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
2309 pr_info("wifi turn on power\n");
2311 if (!rk29sdk_bt_power_state){
2312 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
2314 pr_info("wifi shut off power\n");
2317 pr_info("wifi shouldn't shut off power, bt is using it!\n");
2322 rk29sdk_wifi_power_state = on;
2326 static int rk29sdk_wifi_reset_state;
2327 static int rk29sdk_wifi_reset(int on)
2329 pr_info("%s: %d\n", __func__, on);
2330 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
2332 rk29sdk_wifi_reset_state = on;
2336 int rk29sdk_wifi_set_carddetect(int val)
2338 pr_info("%s:%d\n", __func__, val);
2339 rk29sdk_wifi_cd = val;
2340 if (wifi_status_cb){
2341 wifi_status_cb(val, wifi_status_cb_devid);
2343 pr_warning("%s, nobody to notify\n", __func__);
2347 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
2349 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
2350 {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
2351 {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
2352 {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
2353 {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
2356 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
2358 if (section == PREALLOC_WLAN_SEC_NUM)
2359 return wlan_static_skb;
2361 if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
2364 if (wifi_mem_array[section].size < size)
2367 return wifi_mem_array[section].mem_ptr;
2370 int __init rk29sdk_init_wifi_mem(void)
2375 for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
2376 wlan_static_skb[i] = dev_alloc_skb(
2377 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
2379 if (!wlan_static_skb[i])
2383 for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
2384 wifi_mem_array[i].mem_ptr =
2385 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
2387 if (!wifi_mem_array[i].mem_ptr)
2393 pr_err("Failed to mem_alloc for WLAN\n");
2394 for (j = 0 ; j < i ; j++)
2395 kfree(wifi_mem_array[j].mem_ptr);
2397 i = WLAN_SKB_BUF_NUM;
2400 pr_err("Failed to skb_alloc for WLAN\n");
2401 for (j = 0 ; j < i ; j++)
2402 dev_kfree_skb(wlan_static_skb[j]);
2407 static struct wifi_platform_data rk29sdk_wifi_control = {
2408 .set_power = rk29sdk_wifi_power,
2409 .set_reset = rk29sdk_wifi_reset,
2410 .set_carddetect = rk29sdk_wifi_set_carddetect,
2411 .mem_prealloc = rk29sdk_mem_prealloc,
2413 static struct platform_device rk29sdk_wifi_device = {
2414 .name = "bcm4329_wlan",
2417 .platform_data = &rk29sdk_wifi_control,
2423 /* bluetooth rfkill device */
2424 static struct platform_device rk29sdk_rfkill = {
2425 .name = "rk29sdk_rfkill",
2430 #ifdef CONFIG_VIVANTE
2431 static struct resource resources_gpu[] = {
2436 .flags = IORESOURCE_IRQ,
2440 .start = RK29_GPU_PHYS,
2441 .end = RK29_GPU_PHYS + RK29_GPU_SIZE,
2442 .flags = IORESOURCE_MEM,
2446 .start = PMEM_GPU_BASE,
2447 .end = PMEM_GPU_BASE + PMEM_GPU_SIZE,
2448 .flags = IORESOURCE_MEM,
2451 static struct platform_device rk29_device_gpu = {
2454 .num_resources = ARRAY_SIZE(resources_gpu),
2455 .resource = resources_gpu,
2458 #ifdef CONFIG_KEYS_RK29
2459 extern struct rk29_keys_platform_data rk29_keys_pdata;
2460 static struct platform_device rk29_device_keys = {
2461 .name = "rk29-keypad",
2464 .platform_data = &rk29_keys_pdata,
2469 static void __init rk29_board_iomux_init(void)
2471 #ifdef CONFIG_RK29_PWM_REGULATOR
2472 rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
2476 static struct platform_device *devices[] __initdata = {
2477 #ifdef CONFIG_UART1_RK29
2480 #ifdef CONFIG_UART0_RK29
2483 #ifdef CONFIG_UART2_RK29
2487 #ifdef CONFIG_RK29_PWM_REGULATOR
2488 &rk29_device_pwm_regulator,
2490 #ifdef CONFIG_SPIM0_RK29
2491 &rk29xx_device_spi0m,
2493 #ifdef CONFIG_SPIM1_RK29
2494 &rk29xx_device_spi1m,
2496 #ifdef CONFIG_ADC_RK29
2499 #ifdef CONFIG_I2C0_RK29
2502 #ifdef CONFIG_I2C1_RK29
2505 #ifdef CONFIG_I2C2_RK29
2508 #ifdef CONFIG_I2C3_RK29
2512 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
2513 &rk29_device_iis_2ch,
2515 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
2516 &rk29_device_iis_8ch,
2519 #ifdef CONFIG_KEYS_RK29
2522 #ifdef CONFIG_SDMMC0_RK29
2523 &rk29_device_sdmmc0,
2525 #ifdef CONFIG_SDMMC1_RK29
2526 &rk29_device_sdmmc1,
2529 #ifdef CONFIG_MTD_NAND_RK29XX
2530 &rk29xx_device_nand,
2533 #ifdef CONFIG_WIFI_CONTROL_FUNC
2534 &rk29sdk_wifi_device,
2541 #if defined(CONFIG_MTK23D)
2542 &rk2818_device_mtk23d,
2545 #ifdef CONFIG_MTD_NAND_RK29
2549 #ifdef CONFIG_FB_RK29
2551 &rk29_device_dma_cpy,
2553 #ifdef CONFIG_BACKLIGHT_RK29_BL
2554 &rk29_device_backlight,
2556 #ifdef CONFIG_RK29_VMAC
2559 #ifdef CONFIG_VIVANTE
2562 #ifdef CONFIG_VIDEO_RK29
2563 &rk29_device_camera, /* ddl@rock-chips.com : camera support */
2564 #if (SENSOR_IIC_ADDR_0 != 0x00)
2565 &rk29_soc_camera_pdrv_0,
2567 &rk29_soc_camera_pdrv_1,
2568 &android_pmem_cam_device,
2570 &android_pmem_device,
2571 &rk29_vpu_mem_device,
2572 #ifdef CONFIG_USB20_OTG
2573 &rk29_device_usb20_otg,
2575 #ifdef CONFIG_USB20_HOST
2576 &rk29_device_usb20_host,
2578 #ifdef CONFIG_USB11_HOST
2579 &rk29_device_usb11_host,
2581 #ifdef CONFIG_USB_ANDROID
2582 &android_usb_device,
2583 &usb_mass_storage_device,
2585 #ifdef CONFIG_RK29_IPP
2588 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2589 &rk29_v4l2_output_devce,
2591 #ifdef CONFIG_HEADSET_DET
2592 &rk28_device_headset,
2596 #ifdef CONFIG_RK29_VMAC
2597 /*****************************************************************************************
2599 * author: lyx@rock-chips.com
2600 *****************************************************************************************/
2601 static int rk29_vmac_register_set(void)
2603 //config rk29 vmac as rmii, 100MHz
2604 u32 value= readl(RK29_GRF_BASE + 0xbc);
2605 value = (value & 0xfff7ff) | (0x400);
2606 writel(value, RK29_GRF_BASE + 0xbc);
2610 static int rk29_rmii_io_init(void)
2615 err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2617 gpio_free(RK29_PIN6_PB0);
2618 printk("-------request RK29_PIN6_PB0 fail--------\n");
2622 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2623 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2628 static int rk29_rmii_io_deinit(void)
2631 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2632 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2634 gpio_free(RK29_PIN6_PB0);
2638 static int rk29_rmii_power_control(int enable)
2642 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2643 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2646 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2647 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2652 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2653 .vmac_register_set = rk29_vmac_register_set,
2654 .rmii_io_init = rk29_rmii_io_init,
2655 .rmii_io_deinit = rk29_rmii_io_deinit,
2656 .rmii_power_control = rk29_rmii_power_control,
2660 /*****************************************************************************************
2662 * author: cmc@rock-chips.com
2663 *****************************************************************************************/
2664 #define SPI_CHIPSELECT_NUM 2
2665 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2668 .cs_gpio = RK29_PIN2_PC1,
2669 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2670 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2674 .cs_gpio = RK29_PIN1_PA4,
2675 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2676 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2680 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2683 .cs_gpio = RK29_PIN2_PC5,
2684 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2685 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2689 .cs_gpio = RK29_PIN1_PA3,
2690 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2691 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2695 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2700 for (i=0; i<cs_num; i++) {
2701 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2708 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2713 static int spi_io_fix_leakage_bug(void)
2716 gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2721 static int spi_io_resume_leakage_bug(void)
2724 gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2729 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2730 .num_chipselect = SPI_CHIPSELECT_NUM,
2731 .chipselect_gpios = rk29xx_spi0_cs_gpios,
2732 .io_init = spi_io_init,
2733 .io_deinit = spi_io_deinit,
2734 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2735 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2738 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2739 .num_chipselect = SPI_CHIPSELECT_NUM,
2740 .chipselect_gpios = rk29xx_spi1_cs_gpios,
2741 .io_init = spi_io_init,
2742 .io_deinit = spi_io_deinit,
2743 .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2744 .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2747 /*****************************************************************************************
2748 * xpt2046 touch panel
2749 * author: hhb@rock-chips.com
2750 *****************************************************************************************/
2751 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
2752 #define XPT2046_GPIO_INT RK29_PIN4_PD5 //ä¸æ
\96è
\84?#define DEBOUNCE_REPTIME 3
2754 static struct xpt2046_platform_data xpt2046_info = {
2759 .debounce_rep = DEBOUNCE_REPTIME,
2761 .gpio_pendown = XPT2046_GPIO_INT,
2762 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
2763 .pendown_iomux_mode = GPIO4H_GPIO4D5,
2764 .touch_virtualkey_length = 60,
2765 .penirq_recheck_delay_usecs = 1,
2766 #if defined(CONFIG_TOUCHSCREEN_480X800)
2771 .touch_ad_top = 3940,
2772 .touch_ad_bottom = 310,
2773 .touch_ad_left = 3772,
2774 .touch_ad_right = 340,
2775 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2780 .touch_ad_top = 2447,
2781 .touch_ad_bottom = 207,
2782 .touch_ad_left = 5938,
2783 .touch_ad_right = 153,
2784 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2789 .touch_ad_top = 3166,
2790 .touch_ad_bottom = 256,
2791 .touch_ad_left = 3658,
2792 .touch_ad_right = 380,
2795 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2796 static struct xpt2046_platform_data xpt2046_info = {
2801 .debounce_rep = DEBOUNCE_REPTIME,
2803 .gpio_pendown = XPT2046_GPIO_INT,
2804 .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
2805 .pendown_iomux_mode = GPIO4H_GPIO4D5,
2806 .touch_virtualkey_length = 60,
2807 .penirq_recheck_delay_usecs = 1,
2809 #if defined(CONFIG_TOUCHSCREEN_480X800)
2814 .screen_x = { 70, 410, 70, 410, 240},
2815 .screen_y = { 50, 50, 740, 740, 400},
2816 .uncali_x_default = { 3267, 831, 3139, 715, 1845 },
2817 .uncali_y_default = { 3638, 3664, 564, 591, 2087 },
2818 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2823 .screen_x[5] = { 50, 750, 50, 750, 400};
2824 .screen_y[5] = { 40, 40, 440, 440, 240};
2825 .uncali_x_default[5] = { 438, 565, 3507, 3631, 2105 };
2826 .uncali_y_default[5] = { 3756, 489, 3792, 534, 2159 };
2827 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2832 .screen_x[5] = { 50, 270, 50, 270, 160};
2833 .screen_y[5] = { 40, 40, 440, 440, 240};
2834 .uncali_x_default[5] = { 812, 3341, 851, 3371, 2183 };
2835 .uncali_y_default[5] = { 442, 435, 3193, 3195, 2004 };
2840 static struct spi_board_info board_spi_devices[] = {
2841 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2843 .modalias = "xpt2046_ts",
2844 .chip_select = 0,// 2,
2845 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2847 .irq = XPT2046_GPIO_INT,
2848 .platform_data = &xpt2046_info,
2852 #if defined(CONFIG_MFD_WM831X_SPI)
2854 .modalias = "wm8310",
2856 .max_speed_hz = 1*1000*1000,
2858 .irq = RK29_PIN4_PD0,
2859 .platform_data = &wm831x_platdata,
2866 /**********************************************************************************************
2868 * The virtual keys for android "back", "home", "menu", "search", these four keys are touch key
2869 * on the touch screen panel. (added by hhb@rock-chips.com 2011.03.31)
2871 ***********************************************************************************************/
2872 static ssize_t rk29xx_virtual_keys_show(struct kobject *kobj,
2873 struct kobj_attribute *attr, char *buf)
2875 #if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
2876 || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC)
2877 /* center: x: home: 50, menu: 184, back: 315, search 435, y: 830*/
2878 /* centerx;centery;width;height; */
2880 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":315:815:120:50" //":50:830:98:50" //":210:796:98:50"
2881 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":85:815:88:50" // ":184:830:120:50" // ":435:796:120:50"
2882 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":184:815:100:50" //":315:830:100:50" //":320:796:100:50"
2883 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":435:815:88:50" //":50:815:98:50" // //":85:796:88:50"
2889 static struct kobj_attribute rk29xx_virtual_keys_attr = {
2891 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2892 .name = "virtualkeys.xpt2046-touchscreen",
2893 #elif defined(CONFIG_TOUCHSCREEN_HX8520_IIC)
2894 .name = "virtualkeys.hx8520-touchscreen",
2895 #elif defined(CONFIG_TOUCHSCREEN_GT801_IIC)
2896 .name = "virtualkeys.gt801-touchscreen",
2902 .show = &rk29xx_virtual_keys_show,
2905 static struct attribute *rk29xx_properties_attrs[] = {
2906 &rk29xx_virtual_keys_attr.attr,
2910 static struct attribute_group rk29xx_properties_attr_group = {
2911 .attrs = rk29xx_properties_attrs,
2913 static int rk29xx_virtual_keys_init(void)
2916 struct kobject *properties_kobj;
2917 printk("rk29xx_virtual_keys_init \n");
2918 properties_kobj = kobject_create_and_add("board_properties", NULL);
2919 if (properties_kobj)
2920 ret = sysfs_create_group(properties_kobj,
2921 &rk29xx_properties_attr_group);
2922 if (!properties_kobj || ret)
2924 pr_err("failed to create board_properties\n");
2930 static void __init rk29_gic_init_irq(void)
2932 gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2933 gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2936 static void __init machine_rk29_init_irq(void)
2938 rk29_gic_init_irq();
2942 #define POWER_ON_PIN RK29_PIN4_PA4
2943 static void rk29_pm_power_off(void)
2945 printk(KERN_ERR "rk29_pm_power_off start...\n");
2946 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2950 static void __init machine_rk29_board_init(void)
2952 rk29_board_iomux_init();
2954 gpio_request(POWER_ON_PIN,"poweronpin");
2955 gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
2956 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2957 pm_power_off = rk29_pm_power_off;
2960 gpio_request(RK29_PIN5_PA1, NULL);
2961 gpio_direction_output(RK29_PIN5_PA1,GPIO_HIGH);
2962 gpio_free(RK29_PIN5_PA1);
2964 platform_add_devices(devices, ARRAY_SIZE(devices));
2965 #ifdef CONFIG_I2C0_RK29
2966 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2967 ARRAY_SIZE(board_i2c0_devices));
2969 #ifdef CONFIG_I2C1_RK29
2970 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2971 ARRAY_SIZE(board_i2c1_devices));
2973 #ifdef CONFIG_I2C2_RK29
2974 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2975 ARRAY_SIZE(board_i2c2_devices));
2977 #ifdef CONFIG_I2C3_RK29
2978 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2979 ARRAY_SIZE(board_i2c3_devices));
2982 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2984 #ifdef CONFIG_WIFI_CONTROL_FUNC
2985 rk29sdk_wifi_bt_gpio_control_init();
2986 rk29sdk_init_wifi_mem();
2989 rk29xx_virtual_keys_init();
2992 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2993 char **cmdline, struct meminfo *mi)
2996 mi->bank[0].start = RK29_SDRAM_PHYS;
2997 mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
2998 mi->bank[0].size = LINUX_SIZE;
3001 static void __init machine_rk29_mapio(void)
3003 rk29_map_common_io();
3004 rk29_setup_early_printk();
3006 rk29_clock_init(periph_pll_288mhz);
3010 MACHINE_START(RK29, "RK29board")
3011 /* UART for LL DEBUG */
3012 .phys_io = RK29_UART1_PHYS,
3013 .io_pg_offst = ((RK29_UART1_BASE) >> 18) & 0xfffc,
3014 .boot_params = RK29_SDRAM_PHYS + 0x88000,
3015 .fixup = machine_rk29_fixup,
3016 .map_io = machine_rk29_mapio,
3017 .init_irq = machine_rk29_init_irq,
3018 .init_machine = machine_rk29_board_init,
3019 .timer = &rk29_timer,