A22 and phonesdk: make wm831x enter sleep in suspend, change vdd voltage to 1.0V
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk29 / board-rk29-phonesdk.c
1 /* arch/arm/mach-rk29/board-rk29-phonesdk.c
2  *
3  * Copyright (C) 2010 ROCKCHIP, Inc.
4  *
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.
8  *
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.
13  *
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
20 #include <linux/io.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>
27
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>
35
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>
46 #include <mach/ddr.h>
47
48 #include <linux/regulator/rk29-pwm-regulator.h>
49 #include <linux/regulator/machine.h>
50 #include <linux/mfd/wm831x/pdata.h>
51 #include <linux/mfd/wm831x/core.h>
52 #include <linux/mfd/wm831x/gpio.h>
53 #include <linux/mfd/wm8994/pdata.h>
54 #include <linux/mfd/wm8994/registers.h>
55
56 #include <linux/mtd/nand.h>
57 #include <linux/mtd/partitions.h>
58 #include <linux/i2c-gpio.h>
59 #include <linux/mpu.h>
60 #include "devices.h"
61
62 #if defined(CONFIG_MTK23D)
63 #include <linux/mtk23d.h>
64 #endif
65
66 #ifdef CONFIG_USE_GPIO_GENERATE_WAVE
67 #include "../../../drivers/testcode/gpio_wave.h"
68 #endif
69
70 #include "../../../drivers/headset_observe/rk_headset.h"
71 /*set touchscreen different type header*/
72 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI)
73 #include "../../../drivers/input/touchscreen/xpt2046_ts.h"
74 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
75 #include "../../../drivers/input/touchscreen/xpt2046_tslib_ts.h"
76 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
77 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
78 #endif
79 #include "../../../drivers/misc/gps/rk29_gps.h"
80 #include "../../../drivers/serial/sc8800.h"
81 #ifdef CONFIG_VIDEO_RK29
82 /*---------------- Camera Sensor Macro Define Begin  ------------------------*/
83 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
84 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642                      /* back camera sensor */
85 #define CONFIG_SENSOR_IIC_ADDR_0            0x78
86 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0    1
87 #define CONFIG_SENSOR_POWER_PIN_0         INVALID_GPIO
88 #define CONFIG_SENSOR_RESET_PIN_0         INVALID_GPIO
89 #define CONFIG_SENSOR_POWERDN_PIN_0       RK29_PIN6_PB7
90 #define CONFIG_SENSOR_FALSH_PIN_0         INVALID_GPIO
91 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
92 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
93 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
94 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
95
96 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659                      /* front camera sensor */
97 #define CONFIG_SENSOR_IIC_ADDR_1            0x60
98 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    1
99 #define CONFIG_SENSOR_POWER_PIN_1         INVALID_GPIO
100 #define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
101 #define CONFIG_SENSOR_POWERDN_PIN_1       RK29_PIN5_PD7
102 #define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
103 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
104 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
105 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
106 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
107 #endif  //#ifdef CONFIG_VIDEO_RK29
108 /*---------------- Camera Sensor Configuration Macro End------------------------*/
109 #include "../../../drivers/media/video/rk29_camera.c"
110 /*---------------- Camera Sensor Macro Define End  ------------------------*/
111
112
113 /* Set memory size of pmem */
114 #ifdef CONFIG_RK29_MEM_SIZE_M
115 #define SDRAM_SIZE          (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
116 #else
117 #define SDRAM_SIZE          SZ_512M
118 #endif
119 #define PMEM_GPU_SIZE       SZ_64M
120 #define PMEM_UI_SIZE        SZ_32M
121 #define PMEM_VPU_SIZE       SZ_64M
122 #define PMEM_CAM_SIZE       PMEM_CAM_NECESSARY
123 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
124 #define MEM_CAMIPP_SIZE     SZ_4M
125 #else
126 #define MEM_CAMIPP_SIZE     0
127 #endif
128 #define MEM_FB_SIZE         (3*SZ_2M)
129 #ifdef CONFIG_FB_WORK_IPP
130 #define MEM_FBIPP_SIZE      SZ_8M   //1920 x 1080 x 2 x 2  //RGB565 = x2;RGB888 = x4
131 #else
132 #define MEM_FBIPP_SIZE      0
133 #endif
134 #define PMEM_GPU_BASE       ((u32)RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
135 #define PMEM_UI_BASE        (PMEM_GPU_BASE - PMEM_UI_SIZE)
136 #define PMEM_VPU_BASE       (PMEM_UI_BASE - PMEM_VPU_SIZE)
137 #define PMEM_CAM_BASE       (PMEM_VPU_BASE - PMEM_CAM_SIZE)
138 #define MEM_CAMIPP_BASE     (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
139 #define MEM_FB_BASE         (MEM_CAMIPP_BASE - MEM_FB_SIZE)
140 #define MEM_FBIPP_BASE      (MEM_FB_BASE - MEM_FBIPP_SIZE)
141 #define LINUX_SIZE          (MEM_FBIPP_BASE - RK29_SDRAM_PHYS)
142
143 #define PREALLOC_WLAN_SEC_NUM           4
144 #define PREALLOC_WLAN_BUF_NUM           160
145 #define PREALLOC_WLAN_SECTION_HEADER    24
146
147 #define WLAN_SECTION_SIZE_0     (PREALLOC_WLAN_BUF_NUM * 128)
148 #define WLAN_SECTION_SIZE_1     (PREALLOC_WLAN_BUF_NUM * 128)
149 #define WLAN_SECTION_SIZE_2     (PREALLOC_WLAN_BUF_NUM * 512)
150 #define WLAN_SECTION_SIZE_3     (PREALLOC_WLAN_BUF_NUM * 1024)
151
152 #define WLAN_SKB_BUF_NUM        16
153
154 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
155
156 struct wifi_mem_prealloc {
157         void *mem_ptr;
158         unsigned long size;
159 };
160
161 extern struct sys_timer rk29_timer;
162
163 static int rk29_nand_io_init(void)
164 {
165     return 0;
166 }
167
168 struct rk29_nand_platform_data rk29_nand_data = {
169     .width      = 1,     /* data bus width in bytes */
170     .hw_ecc     = 1,     /* hw ecc 0: soft ecc */
171     .num_flash    = 1,
172     .io_init   = rk29_nand_io_init,
173 };
174
175 #ifdef CONFIG_FB_RK29
176 /*****************************************************************************************
177  * lcd  devices
178  * author: zyw@rock-chips.com
179  *****************************************************************************************/
180 //#ifdef  CONFIG_LCD_TD043MGEA1
181 #define LCD_RXD_PIN          RK29_PIN2_PC7
182 #define LCD_TXD_PIN          RK29_PIN2_PC6
183 #define LCD_CLK_PIN          RK29_PIN2_PC4
184 #define LCD_CS_PIN           RK29_PIN2_PC5
185 /*****************************************************************************************
186 * frame buffer  devices
187 * author: zyw@rock-chips.com
188 *****************************************************************************************/
189 #define FB_ID                       0
190 #define FB_DISPLAY_ON_PIN           INVALID_GPIO//RK29_PIN6_PD0
191 #define FB_LCD_STANDBY_PIN          INVALID_GPIO//RK29_PIN6_PD1
192 #define FB_LCD_CABC_EN_PIN          INVALID_GPIO//RK29_PIN6_PD2
193 #define FB_MCU_FMK_PIN              INVALID_GPIO
194
195 #define FB_DISPLAY_ON_VALUE         GPIO_HIGH
196 #define FB_LCD_STANDBY_VALUE        GPIO_HIGH
197
198 //#endif
199 static int rk29_lcd_io_init(void)
200 {
201     int ret = 0;
202     //printk("rk29_lcd_io_init\n");
203     //ret = gpio_request(LCD_RXD_PIN, NULL);
204     ret = gpio_request(LCD_TXD_PIN, NULL);
205         ret = gpio_request(LCD_CLK_PIN, NULL);
206         ret = gpio_request(LCD_CS_PIN, NULL);
207         //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_GPIO2C7);
208         rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_GPIO2C6);
209         rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_GPIO2C5);
210         rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_GPIO2C4);
211     return ret;
212 }
213
214 static int rk29_lcd_io_deinit(void)
215 {
216     int ret = 0;
217     //printk("rk29_lcd_io_deinit\n");
218     gpio_free(LCD_CS_PIN);
219         gpio_free(LCD_CLK_PIN);
220         gpio_free(LCD_TXD_PIN);
221         //gpio_free(LCD_RXD_PIN);
222         //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_SPI1_RXD);
223         rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_SPI1_TXD);
224         rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_SPI1_CSN0);
225         rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_SPI1_CLK);
226     return ret;
227 }
228
229 static struct rk29lcd_info rk29_lcd_info = {
230     .txd_pin  = LCD_TXD_PIN,
231     .clk_pin = LCD_CLK_PIN,
232     .cs_pin = LCD_CS_PIN,
233     .io_init   = rk29_lcd_io_init,
234     .io_deinit = rk29_lcd_io_deinit,
235 };
236
237 int rk29_fb_io_enable(void)
238 {
239     if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
240     {
241         gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
242         gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);              
243     }
244     if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
245     {
246         gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
247         gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);             
248     }
249     return 0;
250 }
251
252 int rk29_fb_io_disable(void)
253 {
254     if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
255     {
256         gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
257         gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);              
258     }
259     if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
260     {
261         gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
262         gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);             
263     }
264     return 0;
265 }
266
267 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
268 {
269     int ret = 0;
270     if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
271     {
272         ret = gpio_request(FB_MCU_FMK_PIN, NULL);
273         if(ret != 0)
274         {
275             gpio_free(FB_MCU_FMK_PIN);
276             printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
277         }
278         gpio_direction_input(FB_MCU_FMK_PIN);
279     }
280     if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
281     {
282         ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
283         if(ret != 0)
284         {
285             gpio_free(FB_DISPLAY_ON_PIN);
286             printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
287         }
288     }
289
290     if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
291     {
292         ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
293         if(ret != 0)
294         {
295             gpio_free(FB_LCD_STANDBY_PIN);
296             printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
297         }
298     }
299
300     if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
301     {
302         ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
303         if(ret != 0)
304         {
305             gpio_free(FB_LCD_CABC_EN_PIN);
306             printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
307         }
308         gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
309         gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
310     }
311     rk29_fb_io_enable();   //enable it
312
313     return ret;
314 }
315
316 static struct rk29fb_info rk29_fb_info = {
317     .fb_id   = FB_ID,
318     .mcu_fmk_pin = FB_MCU_FMK_PIN,
319     .lcd_info = &rk29_lcd_info,
320     .io_init   = rk29_fb_io_init,
321     .io_enable = rk29_fb_io_enable,
322     .io_disable = rk29_fb_io_disable,
323 };
324
325 /* rk29 fb resource */
326 static struct resource rk29_fb_resource[] = {
327         [0] = {
328         .name  = "lcdc reg",
329                 .start = RK29_LCDC_PHYS,
330                 .end   = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
331                 .flags = IORESOURCE_MEM,
332         },
333         [1] = {
334             .name  = "lcdc irq",
335                 .start = IRQ_LCDC,
336                 .end   = IRQ_LCDC,
337                 .flags = IORESOURCE_IRQ,
338         },
339         [2] = {
340             .name   = "win1 buf",
341         .start  = MEM_FB_BASE,
342         .end    = MEM_FB_BASE + MEM_FB_SIZE - 1,
343         .flags  = IORESOURCE_MEM,
344     },
345     #ifdef CONFIG_FB_WORK_IPP
346     [3] = {
347             .name   = "win1 ipp buf",
348         .start  = MEM_FBIPP_BASE,
349         .end    = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
350         .flags  = IORESOURCE_MEM,
351     },
352     #endif
353 };
354
355 /*platform_device*/
356 struct platform_device rk29_device_fb = {
357         .name             = "rk29-fb",
358         .id               = 4,
359         .num_resources    = ARRAY_SIZE(rk29_fb_resource),
360         .resource         = rk29_fb_resource,
361         .dev            = {
362                 .platform_data  = &rk29_fb_info,
363         }
364 };
365
366 struct platform_device rk29_device_dma_cpy = {
367         .name             = "dma_memcpy",
368         .id               = 4,
369
370 };
371
372 #endif
373
374 static struct android_pmem_platform_data android_pmem_pdata = {
375         .name           = "pmem",
376         .start          = PMEM_UI_BASE,
377         .size           = PMEM_UI_SIZE,
378         .no_allocator   = 0,
379         .cached         = 1,
380 };
381
382 static struct platform_device android_pmem_device = {
383         .name           = "android_pmem",
384         .id             = 0,
385         .dev            = {
386                 .platform_data = &android_pmem_pdata,
387         },
388 };
389
390
391 static struct vpu_mem_platform_data vpu_mem_pdata = {
392         .name           = "vpu_mem",
393         .start          = PMEM_VPU_BASE,
394         .size           = PMEM_VPU_SIZE,
395         .cached         = 1,
396 };
397
398 static struct platform_device rk29_vpu_mem_device = {
399         .name           = "vpu_mem",
400         .id                 = 2,
401         .dev            = {
402         .platform_data = &vpu_mem_pdata,
403         },
404 };
405
406 static struct platform_device rk29_v4l2_output_devce = {
407         .name           = "rk29_vout",
408 };
409
410 /* HANNSTAR_P1003 touch I2C */
411 #if defined (CONFIG_HANNSTAR_P1003)
412 #define TOUCH_RESET_PIN RK29_PIN6_PC3
413 #define TOUCH_INT_PIN   RK29_PIN4_PD5
414
415 int p1003_init_platform_hw(void)
416 {
417     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
418       gpio_free(TOUCH_RESET_PIN);
419       printk("p1003_init_platform_hw gpio_request error\n");
420       return -EIO;
421     }
422
423     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
424       gpio_free(TOUCH_INT_PIN);
425       printk("p1003_init_platform_hw gpio_request error\n");
426       return -EIO;
427     }
428     gpio_pull_updown(TOUCH_INT_PIN, 1);
429     gpio_direction_output(TOUCH_RESET_PIN, 0);
430     msleep(500);
431     gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
432     msleep(500);
433     gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
434
435     return 0;
436 }
437
438
439 struct p1003_platform_data p1003_info = {
440   .model= 1003,
441   .init_platform_hw= p1003_init_platform_hw,
442
443 };
444 #endif
445
446 #if defined(CONFIG_TOUCHSCREEN_GT801_IIC) 
447 #include "../../../drivers/input/touchscreen/gt801_ts.h"
448 #define GT801_GPIO_INT      RK29_PIN4_PD5
449 #define GT801_GPIO_RESET    RK29_PIN6_PC3
450 static struct gt801_platform_data gt801_info = {
451         .model                  = 801,
452         .swap_xy                = 0,
453         .x_min                  = 0,
454         .x_max                  = 480,
455         .y_min                  = 0,
456         .y_max                  = 800,
457         .gpio_reset     = GT801_GPIO_RESET,
458         .gpio_reset_active_low = 0,
459         .gpio_pendown           = GT801_GPIO_INT,
460     .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
461     .resetpin_iomux_name = NULL,
462     .pendown_iomux_mode = GPIO4H_GPIO4D5,
463     .resetpin_iomux_mode = 0,
464 };
465 #endif
466
467 #if defined(CONFIG_TOUCHSCREEN_ILI2102_IIC) 
468 #include "../../../drivers/input/touchscreen/ili2102_ts.h"
469 #define GT801_GPIO_INT      RK29_PIN4_PD5
470 #define GT801_GPIO_RESET    RK29_PIN6_PC3
471 static struct ili2102_platform_data ili2102_info = {
472         .model                  = 2102,
473         .swap_xy                = 0,
474         .x_min                  = 0,
475         .x_max                  = 481,
476         .y_min                  = 0,
477         .y_max                  = 801,
478         .gpio_reset     = GT801_GPIO_RESET,
479         .gpio_reset_active_low = 1,
480         .gpio_pendown           = GT801_GPIO_INT,
481     .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
482     .resetpin_iomux_name = NULL,
483     .pendown_iomux_mode = GPIO4H_GPIO4D5,
484     .resetpin_iomux_mode = 0,
485 };
486 #endif
487
488 /* EETI_EGALAX touch I2C */
489 #if defined (CONFIG_EETI_EGALAX)
490 #define TOUCH_RESET_PIN RK29_PIN6_PC3
491 #define TOUCH_INT_PIN   RK29_PIN4_PD5
492
493 static int EETI_EGALAX_init_platform_hw(void)
494 {
495     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
496       gpio_free(TOUCH_RESET_PIN);
497       printk("p1003_init_platform_hw gpio_request error\n");
498       return -EIO;
499     }
500
501     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
502       gpio_free(TOUCH_INT_PIN);
503       printk("p1003_init_platform_hw gpio_request error\n");
504       return -EIO;
505     }
506     gpio_pull_updown(TOUCH_INT_PIN, 1);
507     gpio_direction_output(TOUCH_RESET_PIN, 0);
508     msleep(500);
509     gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
510     msleep(500);
511     gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
512
513     return 0;
514 }
515
516
517 static struct eeti_egalax_platform_data eeti_egalax_info = {
518   .model= 1003,
519   .init_platform_hw= EETI_EGALAX_init_platform_hw,
520
521 };
522 #endif
523
524 /*MMA8452 gsensor*/
525 #if defined (CONFIG_GS_MMA8452)
526 #define MMA8452_INT_PIN   RK29_PIN6_PC4
527
528 static int mma8452_init_platform_hw(void)
529 {
530
531     if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
532       gpio_free(MMA8452_INT_PIN);
533       printk("mma8452_init_platform_hw gpio_request error\n");
534       return -EIO;
535     }
536     gpio_pull_updown(MMA8452_INT_PIN, 1);
537     return 0;
538 }
539
540
541 static struct mma8452_platform_data mma8452_info = {
542   .model= 8452,
543   .swap_xy = 0,
544   .init_platform_hw= mma8452_init_platform_hw,
545
546 };
547 #endif
548
549 #if defined (CONFIG_SENSORS_MPU3050)
550 /*mpu3050*/
551 static struct mpu3050_platform_data mpu3050_data = {
552                 .int_config = 0x10,
553                 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
554                 //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
555                 .orientation = { 1, 0, 0,0, 1, 0, 0, 0, 1 },
556                 .level_shifter = 0,
557 #if defined (CONFIG_SENSORS_KXTF9)
558                 .accel = {
559                                 .get_slave_descr = kxtf9_get_slave_descr ,
560                                 .adapt_num = 0, // The i2c bus to which the mpu device is
561                                 // connected
562                                 .irq = RK29_PIN6_PC4,
563                                 .bus = EXT_SLAVE_BUS_SECONDARY,  //The secondary I2C of MPU
564                                 .address = 0x0f,
565                                 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
566                                 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
567                                 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
568                                 .orientation = {1, 0, 0, 0, 1, 0, 0, 0, 1},
569                 },
570 #endif
571 #if defined (CONFIG_SENSORS_AK8975)
572                 .compass = {
573                                 .get_slave_descr = ak8975_get_slave_descr,/*ak5883_get_slave_descr,*/
574                                 .adapt_num = 0, // The i2c bus to which the compass device is. 
575                                 // It can be difference with mpu
576                                 // connected
577                                 .irq = RK29_PIN6_PC5,
578                                 .bus = EXT_SLAVE_BUS_PRIMARY,
579                                 .address = 0x0d,
580                                 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
581                                 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
582                                 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
583                 },
584 #endif
585 };
586 #endif
587
588 #if defined(CONFIG_GPIO_WM831X)
589 struct rk29_gpio_expander_info  wm831x_gpio_settinginfo[] = {
590         {
591                 .gpio_num               =WM831X_P01,// tp3
592                 .pin_type           = GPIO_OUT,
593                 .pin_value                      =GPIO_HIGH,
594          },
595          
596          {
597                 .gpio_num               =WM831X_P02,//tp4
598                 .pin_type           = GPIO_OUT,
599                 .pin_value                      =GPIO_HIGH,
600          },
601          {
602                 .gpio_num               =WM831X_P03,//tp2
603                 .pin_type           = GPIO_OUT,
604                 .pin_value                      =GPIO_HIGH,
605          },
606          {
607                 .gpio_num               =WM831X_P04,//tp1
608                 .pin_type           = GPIO_OUT,
609                 .pin_value                      =GPIO_HIGH,
610          },
611          {
612                 .gpio_num               =WM831X_P05,//tp1
613                 .pin_type           = GPIO_OUT,
614                 .pin_value                      =GPIO_HIGH,
615          },
616          {
617                 .gpio_num               =WM831X_P06,//tp1
618                 .pin_type           = GPIO_OUT,
619                 .pin_value                      =GPIO_HIGH,
620          },
621          {
622                 .gpio_num               =WM831X_P07,//tp1
623                 .pin_type           = GPIO_OUT,
624                 .pin_value                      =GPIO_HIGH,
625          },
626          {
627                 .gpio_num               =WM831X_P08,//tp1
628                 .pin_type           = GPIO_OUT,
629                 .pin_value                      =GPIO_HIGH,
630          },
631          {
632                 .gpio_num               =WM831X_P09,//tp1
633                 .pin_type           = GPIO_OUT,
634                 .pin_value                      =GPIO_HIGH,
635          },
636          {
637                 .gpio_num               =WM831X_P10,//tp1
638                 .pin_type           = GPIO_OUT,
639                 .pin_value                      =GPIO_HIGH,
640          },
641          {
642                 .gpio_num               =WM831X_P11,//tp1
643                 .pin_type           = GPIO_OUT,
644                 .pin_value                      =GPIO_HIGH,
645          },     
646          {
647                 .gpio_num               =WM831X_P12,
648                 .pin_type           = GPIO_OUT,
649                 .pin_value                      =GPIO_HIGH,
650          },
651 };
652
653 #endif
654
655
656
657 #if defined(CONFIG_MFD_WM831X)
658 static struct wm831x *gWm831x;
659 int wm831x_pre_init(struct wm831x *parm)
660 {
661         int ret;
662         printk("%s\n", __FUNCTION__);
663         gWm831x = parm;
664         //ILIM = 900ma
665         ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
666         wm831x_reg_write(parm, WM831X_POWER_STATE, (ret&0xfff8) | 0x04);        
667 #if 0
668         wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 3), 0);
669         wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 7), 0);
670         printk("%s:disable ldo4 and ldo8 because they are enabled in uboot\n",__FUNCTION__);
671 #endif  
672         return 0;
673 }
674 int wm831x_post_init(struct wm831x *parm)
675 {
676         struct regulator *dcdc;
677         struct regulator *ldo;
678         
679         dcdc = regulator_get(NULL, "dcdc3");            // 1th IO
680         regulator_set_voltage(dcdc,3000000,3000000);
681         regulator_set_suspend_voltage(dcdc, 3000000);
682         regulator_enable(dcdc);                 
683         printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
684         regulator_put(dcdc);
685         udelay(100);
686         
687         ldo = regulator_get(NULL, "ldo10");     // 1th modem IO
688         regulator_set_voltage(ldo,3000000,3000000);
689         regulator_set_suspend_voltage(ldo,3000000);
690         regulator_enable(ldo);                  
691         printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
692         regulator_put(ldo);
693         udelay(100);
694         
695         dcdc = regulator_get(NULL, "dcdc2");    // 2th CORE
696         regulator_set_voltage(dcdc,1300000,1300000);
697         regulator_set_suspend_voltage(dcdc,1000000);
698         regulator_enable(dcdc);                         
699         printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
700         regulator_put(dcdc);
701         udelay(100);
702         
703         dcdc = regulator_get(NULL, "dcdc1");    // 3th ddr
704         regulator_set_voltage(dcdc,1800000,1800000);
705         regulator_set_suspend_voltage(ldo, 1800000);
706         regulator_enable(dcdc);
707         printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));   
708         regulator_put(dcdc);
709         udelay(100);
710         
711         ldo = regulator_get(NULL, "ldo1");              // 3th nand
712         regulator_set_voltage(ldo,1800000,1800000);
713         regulator_set_suspend_voltage(ldo,1800000);
714         regulator_enable(ldo);                  
715         printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));             
716         regulator_put(ldo);
717         udelay(100);
718         
719         ldo = regulator_get(NULL, "ldo4");              // 4th usb
720         regulator_set_voltage(ldo,2500000,2500000);
721         regulator_set_suspend_voltage(ldo,2500000);
722         regulator_enable(ldo);  
723         printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
724         regulator_put(ldo);
725         udelay(100);
726         
727         ldo = regulator_get(NULL, "ldo7");              // 5th usb
728         regulator_set_voltage(ldo,3300000,3300000);
729         regulator_set_suspend_voltage(ldo,3300000);
730         regulator_enable(ldo);                  
731         printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
732         regulator_put(ldo);
733         udelay(100);
734         
735         dcdc = regulator_get(NULL, "dcdc4");    // backlight
736         regulator_set_voltage(dcdc,20000000,20000000);
737         regulator_set_suspend_voltage(dcdc, 20000000);
738         regulator_enable(dcdc); 
739         printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
740         regulator_put(dcdc);
741         udelay(100);
742 #if 1
743         
744         ldo = regulator_get(NULL, "ldo2");              //lcd
745         regulator_set_voltage(ldo,3000000,3000000);
746         regulator_set_suspend_voltage(ldo,3000000);
747         regulator_enable(ldo);                  
748         printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
749         regulator_put(ldo);
750
751         ldo = regulator_get(NULL, "ldo3");              //sram
752         regulator_set_voltage(ldo,1800000,1800000);
753         regulator_set_suspend_voltage(ldo,1800000);
754         regulator_enable(ldo);                  
755         printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
756         regulator_put(ldo);     
757
758         ldo = regulator_get(NULL, "ldo5");              //tf
759         regulator_set_voltage(ldo,3000000,3000000);
760         regulator_set_suspend_voltage(ldo,3000000);
761         regulator_enable(ldo);                  
762         printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
763         regulator_put(ldo);
764
765         ldo = regulator_get(NULL, "ldo6");              //camera
766         regulator_set_voltage(ldo,1800000,1800000);
767         regulator_set_suspend_voltage(ldo,1800000);
768         regulator_enable(ldo);                  
769         printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
770         regulator_put(ldo);
771
772         ldo = regulator_get(NULL, "ldo8");              //cmmb
773         regulator_set_voltage(ldo,1200000,1200000);
774         regulator_set_suspend_voltage(ldo,1200000);
775         regulator_enable(ldo);                  
776         printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
777         regulator_put(ldo);
778
779         ldo = regulator_get(NULL, "ldo9");              //cmmb
780         regulator_set_voltage(ldo,3000000,3000000);
781         regulator_set_suspend_voltage(ldo,3000000);
782         regulator_enable(ldo);                  
783         printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
784         regulator_put(ldo);
785         
786 #endif
787         
788         ldo = regulator_get(NULL, "ldo11");
789         //regulator_enable(ldo);                        
790         printk("%s set ldo11=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));    
791         regulator_put(ldo);     
792         
793                 
794         return 0;
795 }
796
797 extern void wm831x_enter_sleep(void);
798 extern void wm831x_exit_sleep(void);
799
800 void pmu_wm831x_set_suspend_voltage(void)
801 {
802
803 }
804 EXPORT_SYMBOL_GPL(pmu_wm831x_set_suspend_voltage);
805
806 void pmu_wm831x_set_resume_voltage(void)
807 {
808
809 }
810 EXPORT_SYMBOL_GPL(pmu_wm831x_set_resume_voltage);
811
812 int wm831x_last_deinit(struct wm831x *parm)
813 {
814         printk("%s\n", __FUNCTION__);
815
816         return 0;
817 }
818
819 struct wm831x_backlight_pdata wm831x_backlight_platdata = {
820         .isink = 1,     /** ISINK to use, 1 or 2 */
821         .max_uA = 19484,    /** Maximum current to allow */
822 };
823
824 struct wm831x_backup_pdata wm831x_backup_platdata = {
825         .charger_enable = 1,
826         .no_constant_voltage = 0,  /** Disable constant voltage charging */
827         .vlim = 3100,   /** Voltage limit in milivolts */
828         .ilim = 300,   /** Current limit in microamps */
829 };
830
831 struct wm831x_battery_pdata wm831x_battery_platdata = {
832         .enable = 1,         /** Enable charging */
833         .fast_enable = 1,    /** Enable fast charging */
834         .off_mask = 1,       /** Mask OFF while charging */
835         .trickle_ilim = 200,   /** Trickle charge current limit, in mA */
836         .vsel = 4200,           /** Target voltage, in mV */
837         .eoc_iterm = 90,      /** End of trickle charge current, in mA */
838         .fast_ilim = 1000,      /** Fast charge current limit, in mA */
839         .timeout = 180,        /** Charge cycle timeout, in minutes */
840         .syslo = 3300,    /* syslo threshold, in mV*/
841         .sysok = 3500,    /* sysko threshold, in mV*/
842 };
843
844 struct wm831x_status_pdata wm831x_status_platdata[WM831X_MAX_STATUS] = {
845         {
846         .default_src = WM831X_STATUS_OTP,
847         .name = "wm831x_status0",
848         .default_trigger = "wm831x_otp",
849         },
850         {
851         .default_src = WM831X_STATUS_POWER,
852         .name = "wm831x_status1",
853         .default_trigger = "wm831x_power",
854         },      
855 };
856
857
858 static struct regulator_consumer_supply dcdc1_consumers[] = {
859         {
860                 .supply = "dcdc1",
861         }
862 };
863 static struct regulator_consumer_supply dcdc2_consumers[] = {
864         {
865                 .supply = "dcdc2",
866         },
867         {
868                 .supply = "vcore",
869         }
870 };
871 static struct regulator_consumer_supply dcdc3_consumers[] = {
872         {
873                 .supply = "dcdc3",
874         }
875 };
876 static struct regulator_consumer_supply dcdc4_consumers[] = {
877         {
878                 .supply = "dcdc4",
879         }
880 };
881 static struct regulator_consumer_supply epe1_consumers[] = {
882         {
883                 .supply = "epe1",
884         }
885 };
886 static struct regulator_consumer_supply epe2_consumers[] = {
887         {
888                 .supply = "epe2",
889         }
890 };
891 static struct regulator_consumer_supply ldo1_consumers[] = {
892         {
893                 .supply = "ldo1",
894         }
895 };
896 static struct regulator_consumer_supply ldo2_consumers[] = {
897         {
898                 .supply = "ldo2",
899         }
900 };
901 static struct regulator_consumer_supply ldo3_consumers[] = {
902         {
903                 .supply = "ldo3",
904         }
905 };
906 static struct regulator_consumer_supply ldo4_consumers[] = {
907         {
908                 .supply = "ldo4",
909         }
910 };
911 static struct regulator_consumer_supply ldo5_consumers[] = {
912         {
913                 .supply = "ldo5",
914         }
915 };
916 static struct regulator_consumer_supply ldo6_consumers[] = {
917         {
918                 .supply = "ldo6",
919         }
920 };
921 static struct regulator_consumer_supply ldo7_consumers[] = {
922         {
923                 .supply = "ldo7",
924         }
925 };
926 static struct regulator_consumer_supply ldo8_consumers[] = {
927         {
928                 .supply = "ldo8",
929         }
930 };
931 static struct regulator_consumer_supply ldo9_consumers[] = {
932         {
933                 .supply = "ldo9",
934         }
935 };
936 static struct regulator_consumer_supply ldo10_consumers[] = {
937         {
938                 .supply = "ldo10",
939         }
940 };
941 static struct regulator_consumer_supply ldo11_consumers[] = {
942         {
943                 .supply = "ldo11",
944         }
945 };
946 static struct regulator_consumer_supply isink1_consumers[] = {
947         {
948                 .supply = "isink1",
949         }
950 };
951 static struct regulator_consumer_supply isink2_consumers[] = {
952         {
953                 .supply = "isink2",
954         }
955 };
956
957 struct regulator_init_data wm831x_regulator_init_dcdc[WM831X_MAX_DCDC] = {
958         {
959                 .constraints = {
960                         .name = "DCDC1",
961                         .min_uV = 600000,
962                         .max_uV = 1800000,//0.6-1.8V
963                         .apply_uV = true,               
964                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
965                 },
966                 .num_consumer_supplies = ARRAY_SIZE(dcdc1_consumers),
967                 .consumer_supplies = dcdc1_consumers,
968         },
969         {
970                 .constraints = {
971                         .name = "DCDC2",
972                         .min_uV = 600000,
973                         .max_uV = 1800000,//0.6-1.8V
974                         .apply_uV = true,               
975                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
976                 },
977                 .num_consumer_supplies = ARRAY_SIZE(dcdc2_consumers),
978                 .consumer_supplies = dcdc2_consumers,
979         },
980         {
981                 .constraints = {
982                         .name = "DCDC3",
983                         .min_uV = 850000,
984                         .max_uV = 3400000,//0.85-3.4V
985                         .apply_uV = true,               
986                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
987                 },
988                 .num_consumer_supplies = ARRAY_SIZE(dcdc3_consumers),
989                 .consumer_supplies = dcdc3_consumers,
990         },
991         {
992                 .constraints = {
993                         .name = "DCDC4",
994                         .min_uV = 00000000,
995                         .max_uV = 30000000,//30V/40mA
996                         .apply_uV = true,               
997                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
998                 },
999                 .num_consumer_supplies = ARRAY_SIZE(dcdc4_consumers),
1000                 .consumer_supplies = dcdc4_consumers,
1001         },
1002         
1003 };
1004 struct regulator_init_data wm831x_regulator_init_epe[WM831X_MAX_EPE] = {
1005         {
1006                 .constraints = {
1007                         .name = "EPE1",
1008                         .min_uV = 1200000,
1009                         .max_uV = 3000000,
1010                         .apply_uV = true,               
1011                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1012                 },
1013                 .num_consumer_supplies = ARRAY_SIZE(epe1_consumers),
1014                 .consumer_supplies = epe1_consumers,
1015         },
1016         {
1017                 .constraints = {
1018                         .name = "EPE2",
1019                         .min_uV = 1200000,
1020                         .max_uV = 3000000,
1021                         .apply_uV = true,               
1022                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1023                 },
1024                 .num_consumer_supplies = ARRAY_SIZE(epe2_consumers),
1025                 .consumer_supplies = epe2_consumers,
1026         },
1027 };
1028
1029 struct regulator_init_data wm831x_regulator_init_ldo[WM831X_MAX_LDO] = {
1030         {
1031                 .constraints = {
1032                         .name = "LDO1",
1033                         .min_uV = 900000,
1034                         .max_uV = 3300000,
1035                         .apply_uV = true,               
1036                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1037                 },
1038                 .num_consumer_supplies = ARRAY_SIZE(ldo1_consumers),
1039                 .consumer_supplies = ldo1_consumers,
1040         },
1041         {
1042                 .constraints = {
1043                         .name = "LDO2",
1044                         .min_uV = 900000,
1045                         .max_uV = 3300000,
1046                         .apply_uV = true,               
1047                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1048                 },
1049                 .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
1050                 .consumer_supplies = ldo2_consumers,
1051         },
1052         {
1053                 .constraints = {
1054                         .name = "LDO3",
1055                         .min_uV = 900000,
1056                         .max_uV = 3300000,
1057                         .apply_uV = true,               
1058                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1059                 },
1060                 .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
1061                 .consumer_supplies = ldo3_consumers,
1062         },
1063         {
1064                 .constraints = {
1065                         .name = "LDO4",
1066                         .min_uV = 900000,
1067                         .max_uV = 3300000,
1068                         .apply_uV = true,               
1069                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1070                 },
1071                 .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
1072                 .consumer_supplies = ldo4_consumers,
1073         },
1074         {
1075                 .constraints = {
1076                         .name = "LDO5",
1077                         .min_uV = 900000,
1078                         .max_uV = 3300000,
1079                         .apply_uV = true,               
1080                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1081                 },
1082                 .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
1083                 .consumer_supplies = ldo5_consumers,
1084         },
1085         {
1086                 .constraints = {
1087                         .name = "LDO6",
1088                         .min_uV = 900000,
1089                         .max_uV = 3300000,
1090                         .apply_uV = true,               
1091                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1092                 },
1093                 .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers),
1094                 .consumer_supplies = ldo6_consumers,
1095         },
1096         {
1097                 .constraints = {
1098                         .name = "LDO7",
1099                         .min_uV = 1000000,
1100                         .max_uV = 3500000,
1101                         .apply_uV = true,               
1102                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1103                 },
1104                 .num_consumer_supplies = ARRAY_SIZE(ldo7_consumers),
1105                 .consumer_supplies = ldo7_consumers,
1106         },
1107         {
1108                 .constraints = {
1109                         .name = "LDO8",
1110                         .min_uV = 1000000,
1111                         .max_uV = 3500000,
1112                         .apply_uV = true,               
1113                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1114                 },
1115                 .num_consumer_supplies = ARRAY_SIZE(ldo8_consumers),
1116                 .consumer_supplies = ldo8_consumers,
1117         },
1118         {
1119                 .constraints = {
1120                         .name = "LDO9",
1121                         .min_uV = 1000000,
1122                         .max_uV = 3500000,
1123                         .apply_uV = true,               
1124                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1125                 },
1126                 .num_consumer_supplies = ARRAY_SIZE(ldo9_consumers),
1127                 .consumer_supplies = ldo9_consumers,
1128         },
1129         {
1130                 .constraints = {
1131                         .name = "LDO10",
1132                         .min_uV = 1000000,
1133                         .max_uV = 3500000,
1134                         .apply_uV = true,               
1135                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1136                 },
1137                 .num_consumer_supplies = ARRAY_SIZE(ldo10_consumers),
1138                 .consumer_supplies = ldo10_consumers,
1139         },
1140         {
1141                 .constraints = {
1142                         .name = "LDO11",
1143                         .min_uV = 1200000,
1144                         .max_uV = 3000000,
1145                         .apply_uV = true,               
1146                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1147                 },
1148                 .num_consumer_supplies = ARRAY_SIZE(ldo11_consumers),
1149                 .consumer_supplies = ldo11_consumers,
1150         },
1151 };
1152
1153 struct regulator_init_data wm831x_regulator_init_isink[WM831X_MAX_ISINK] = {
1154         {
1155                 .constraints = {
1156                         .name = "ISINK1",
1157                         .min_uA = 00000,
1158                         .max_uA = 40000,
1159                         .always_on = true,
1160                         .apply_uV = true,               
1161                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,           
1162                 },
1163                 .num_consumer_supplies = ARRAY_SIZE(isink1_consumers),
1164                 .consumer_supplies = isink1_consumers,
1165         },
1166         {
1167                 .constraints = {
1168                         .name = "ISINK2",
1169                         .min_uA = 0000000,
1170                         .max_uA = 0000000,
1171                         .apply_uV = false,              
1172                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,           
1173                 },
1174                 .num_consumer_supplies = ARRAY_SIZE(isink2_consumers),
1175                 .consumer_supplies = isink2_consumers,
1176         },
1177 };
1178
1179 static int wm831x_checkrange(int start,int num,int val)
1180 {   
1181         if((val<(start+num))&&(val>=start))
1182                 return 0;
1183         else 
1184                 return -1;
1185 }
1186
1187 static int wm831x_init_pin_type(struct wm831x *wm831x)
1188 {
1189 #if 1
1190         struct wm831x_pdata *pdata = wm831x->dev->platform_data;
1191         struct rk29_gpio_expander_info *wm831x_gpio_settinginfo;
1192         uint16_t offset = 0;
1193         uint16_t wm831x_settingpin_num = 0;
1194         uint16_t ret = 0;
1195         int i = 0;
1196
1197         if(wm831x)
1198         {
1199                 wm831x_gpio_settinginfo=pdata->settinginfo;
1200                 if(wm831x_gpio_settinginfo)
1201                 {
1202                         wm831x_settingpin_num = pdata->settinginfolen;
1203                         for(i=0;i<wm831x_settingpin_num;i++)
1204                         {
1205                                 if(!wm831x_checkrange(pdata->gpio_base,pdata->gpio_pin_num,wm831x_gpio_settinginfo[i].gpio_num))
1206                                 {
1207                                         offset = wm831x_gpio_settinginfo[i].gpio_num - pdata->gpio_base;
1208
1209                                         if(wm831x_gpio_settinginfo[i].pin_type==GPIO_IN)
1210                                         {
1211                                                 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);
1212                                         }
1213                                         else
1214                                         {
1215                                                 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_TRI_SHIFT);
1216                                                 if(wm831x_gpio_settinginfo[i].pin_value==GPIO_HIGH)
1217                                                 {
1218                                                         wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(1 << offset));
1219                                                 }
1220                                                 else
1221                                                 {
1222                                                         wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(0 << offset));
1223                                                 }
1224                                         }
1225                                         
1226                                 }
1227                         }
1228                 }
1229         }
1230
1231         for(i=0;i<pdata->gpio_pin_num;i++)
1232         {
1233                 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+i), 
1234                         WM831X_GPN_PULL_MASK|WM831X_GPN_POL_MASK|WM831X_GPN_OD_MASK|WM831X_GPN_TRI_MASK, 
1235                         1<<WM831X_GPN_POL_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
1236                 ret =  wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL+i);
1237                 printk("Gpio%d Pin Configuration = %x\n",i,ret);
1238         }
1239 #endif
1240         return 0;
1241 }
1242
1243 /*
1244  * GPIO Buttons
1245  */
1246 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1247 static struct wm831x_gpio_keys_button wm831x_gpio_buttons[] = {
1248 {       
1249         .code           = KEY_MEDIA,
1250         .gpio           = TCA6424_P21,
1251         .active_low     = 1,
1252         .desc           = "media",
1253         .wakeup         = 0,
1254         .debounce_interval = 120,
1255 },
1256 {
1257     .code= KEY_VOLUMEUP,
1258                 .gpio= WM831X_P05,
1259                 .active_low= 1,
1260                 .desc= "volume_up",
1261                 .wakeup= 0,
1262 },
1263 {
1264                 .code= KEY_CAMERA,
1265                 .gpio= WM831X_P06,
1266                 .active_low= 1,
1267                 .desc= "camera",
1268                 .wakeup= 0,
1269 },
1270 {
1271                 .code= KEY_VOLUMEDOWN,
1272                 .gpio= WM831X_P07,
1273                 .active_low= 1,
1274                 .desc= "volume_down",
1275                 .wakeup= 0,
1276 },
1277 {
1278                 .code= KEY_END,
1279                 .gpio= WM831X_P09,
1280                 .active_low= 1,
1281                 .desc= "enter",
1282                 .wakeup= 0,
1283 },
1284 {
1285                 .code= KEY_MENU,
1286                 .gpio= WM831X_P10,
1287                 .active_low= 1,
1288                 .desc= "menu",
1289                 .wakeup= 0,
1290 },
1291 {
1292                 .code= KEY_SEND,
1293                 .gpio= WM831X_P11,
1294                 .active_low= 1,
1295                 .desc= "esc",
1296                 .wakeup= 0,
1297 },
1298 {
1299                 .code= KEY_BACK,
1300                 .gpio= WM831X_P12,
1301                 .active_low= 1,
1302                 .desc= "home",
1303                 .wakeup= 0,                     
1304 },
1305 };
1306
1307 struct wm831x_gpio_keys_pdata wm831x_gpio_keys_platdata = {
1308         .buttons        = wm831x_gpio_buttons,
1309         .nbuttons       = ARRAY_SIZE(wm831x_gpio_buttons),
1310 };
1311
1312 #endif
1313 struct wm831x_pdata wm831x_platdata = {
1314         /** Called before subdevices are set up */
1315         .pre_init= wm831x_pre_init,
1316         /** Called after subdevices are set up */
1317         .post_init = wm831x_post_init,
1318         /** Called before subdevices are power down */
1319         .last_deinit = wm831x_last_deinit,
1320         
1321 #if defined(CONFIG_GPIO_WM831X)
1322         .gpio_base=WM831X_GPIO_EXPANDER_BASE,
1323         .gpio_pin_num=WM831X_TOTOL_GPIO_NUM,
1324         .settinginfo=wm831x_gpio_settinginfo,
1325         .settinginfolen=ARRAY_SIZE(wm831x_gpio_settinginfo),
1326         .pin_type_init = wm831x_init_pin_type,
1327         .irq_base= NR_AIC_IRQS + 7*NUM_GROUP,
1328 #endif
1329
1330         .backlight = &wm831x_backlight_platdata,
1331
1332         .backup = &wm831x_backup_platdata,
1333         
1334         .battery = &wm831x_battery_platdata,
1335         //.wm831x_touch_pdata = NULL,
1336         //.watchdog = NULL,
1337         
1338 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)        
1339         .gpio_keys = &wm831x_gpio_keys_platdata,
1340 #endif
1341
1342         /** LED1 = 0 and so on */
1343         .status = {&wm831x_status_platdata[0], &wm831x_status_platdata[1]},
1344         
1345         /** DCDC1 = 0 and so on */
1346         .dcdc = {&wm831x_regulator_init_dcdc[0], &wm831x_regulator_init_dcdc[1], &wm831x_regulator_init_dcdc[2], &wm831x_regulator_init_dcdc[3]},
1347
1348         /** EPE1 = 0 and so on */
1349         .epe = {&wm831x_regulator_init_epe[0], &wm831x_regulator_init_epe[1]},
1350
1351         /** LDO1 = 0 and so on */
1352         .ldo = {&wm831x_regulator_init_ldo[0], &wm831x_regulator_init_ldo[1], &wm831x_regulator_init_ldo[2], &wm831x_regulator_init_ldo[3],
1353                         &wm831x_regulator_init_ldo[4], &wm831x_regulator_init_ldo[5], &wm831x_regulator_init_ldo[6], &wm831x_regulator_init_ldo[7],
1354                         &wm831x_regulator_init_ldo[8], &wm831x_regulator_init_ldo[9], &wm831x_regulator_init_ldo[10]},
1355
1356         /** ISINK1 = 0 and so on*/
1357         .isink = {&wm831x_regulator_init_isink[0], &wm831x_regulator_init_isink[1]},
1358 };
1359 #endif
1360
1361
1362
1363 #if defined(CONFIG_RK29_GPS)
1364
1365 #define         RK29_GPS_POWER_PIN              RK29_PIN6_PB2
1366 #define         RK29_GPS_RESET_PIN              RK29_PIN6_PC1
1367
1368 int rk29_gps_power_up(void)
1369 {       
1370         printk("%s \n", __FUNCTION__);  
1371
1372     gpio_request(RK29_GPS_POWER_PIN, NULL);    
1373         gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH);   
1374
1375         return 0;
1376 }
1377
1378 int rk29_gps_power_down(void)
1379 {       
1380         printk("%s \n", __FUNCTION__);  
1381
1382     gpio_request(RK29_GPS_POWER_PIN, NULL);
1383         gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW);            
1384
1385         return 0;
1386 }
1387
1388 int rk29_gps_reset_set(int level)
1389 {
1390         gpio_request(RK29_GPS_RESET_PIN, NULL);
1391         if (level)
1392                 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);
1393         else
1394                 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);
1395
1396         return 0;
1397 }
1398
1399 struct rk29_gps_data rk29_gps_info = {  
1400         .power_up = rk29_gps_power_up,  
1401         .power_down = rk29_gps_power_down,      
1402         .reset = rk29_gps_reset_set,
1403         .uart_id = 3,
1404 };
1405
1406 struct platform_device rk29_device_gps = {
1407         .name = "rk29_gps",
1408         .id = -1,               
1409         .dev            = {
1410         .platform_data = &rk29_gps_info,        
1411                 }           
1412         };
1413 #endif
1414
1415 /*****************************************************************************************
1416  * wm8994  codec
1417  * author: qjb@rock-chips.com
1418  *****************************************************************************************/
1419 //#if defined(CONFIG_MFD_WM8994)
1420 #if defined (CONFIG_REGULATOR_WM8994)
1421 static struct regulator_consumer_supply wm8994_ldo1_consumers[] = {
1422         {
1423                 .supply = "DBVDD",
1424         },
1425         {
1426                 .supply = "AVDD1",
1427         },
1428         {
1429                 .supply = "CPVDD",
1430         },
1431         {
1432                 .supply = "SPKVDD1",
1433         }               
1434 };
1435 static struct regulator_consumer_supply wm8994_ldo2_consumers[] = {
1436         {
1437                 .supply = "DCVDD",
1438         },
1439         {
1440                 .supply = "AVDD2",
1441         },
1442         {
1443                 .supply = "SPKVDD2",
1444         }                       
1445 };
1446 struct regulator_init_data regulator_init_data_ldo1 = {
1447         .constraints = {
1448                 .name = "wm8994-ldo1",
1449                 .min_uA = 00000,
1450                 .max_uA = 18000,
1451                 .always_on = true,
1452                 .apply_uV = true,               
1453                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,           
1454         },
1455         .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo1_consumers),
1456         .consumer_supplies = wm8994_ldo1_consumers,     
1457 };
1458 struct regulator_init_data regulator_init_data_ldo2 = {
1459         .constraints = {
1460                 .name = "wm8994-ldo2",
1461                 .min_uA = 00000,
1462                 .max_uA = 18000,
1463                 .always_on = true,
1464                 .apply_uV = true,               
1465                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,           
1466         },
1467         .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo2_consumers),
1468         .consumer_supplies = wm8994_ldo2_consumers,     
1469 };
1470 #endif 
1471 struct wm8994_drc_cfg wm8994_drc_cfg_pdata = {
1472         .name = "wm8994_DRC",
1473         .regs = {0,0,0,0,0},
1474 };
1475
1476 struct wm8994_retune_mobile_cfg wm8994_retune_mobile_cfg_pdata = {
1477         .name = "wm8994_EQ",
1478         .rate = 0,
1479         .regs = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
1480 }; 
1481
1482 struct wm8994_pdata wm8994_platdata = { 
1483 #if defined (CONFIG_GPIO_WM8994)
1484         .gpio_base = WM8994_GPIO_EXPANDER_BASE,
1485         //Fill value to initialize the GPIO
1486         .gpio_defaults ={},
1487 #endif  
1488         //enable=0 disable ldo
1489 #if defined (CONFIG_REGULATOR_WM8994)   
1490         .ldo = {
1491                 {
1492                         .enable = 0,
1493                         //RK29_PIN5_PA1
1494                         .supply = NULL,
1495                         .init_data = &regulator_init_data_ldo1,
1496                 },
1497                 {
1498                         .enable = 0,
1499                         .supply = NULL,         
1500                         .init_data = &regulator_init_data_ldo2,
1501                 }
1502         },
1503 #endif  
1504         //DRC 0--use default
1505         .num_drc_cfgs = 0,
1506         .drc_cfgs = &wm8994_drc_cfg_pdata,
1507         //EQ   0--use default 
1508         .num_retune_mobile_cfgs = 0,
1509         .retune_mobile_cfgs = &wm8994_retune_mobile_cfg_pdata,
1510         
1511         .lineout1_diff = 1,
1512         .lineout2_diff = 1,
1513         
1514         .lineout1fb = 1,
1515         .lineout2fb = 1,
1516         
1517         .micbias1_lvl = 1,
1518         .micbias2_lvl = 1,
1519         
1520         .jd_scthr = 0,
1521         .jd_thr = 0,
1522
1523         .PA_control =0,
1524
1525         .speaker_incall_vol = 0,
1526         .speaker_incall_mic_vol = -9,
1527         .speaker_normal_vol = 6,
1528         .earpiece_incall_vol = 0,
1529         .headset_incall_vol = 6,
1530         .headset_incall_mic_vol = -6,
1531         .headset_normal_vol = 6,
1532         .BT_incall_vol = 0,
1533         .BT_incall_mic_vol = 0,
1534         .recorder_vol = 50,
1535         
1536 };
1537 //#endif 
1538
1539 #ifdef CONFIG_RK_HEADSET_DET
1540 #define HEADSET_GPIO RK29_PIN4_PD2
1541 struct rk2818_headset_data rk2818_headset_info = {
1542         .gpio           = HEADSET_GPIO,
1543         .irq_type       = IRQF_TRIGGER_RISING,//IRQF_TRIGGER_RISING -- ??????   IRQF_TRIGGER_FALLING -- ?½???
1544         .headset_in_type= HEADSET_IN_HIGH,
1545 };
1546
1547 struct platform_device rk28_device_headset = {
1548                 .name   = "rk2818_headsetdet",
1549                 .id     = 0,
1550                 .dev    = {
1551                     .platform_data = &rk2818_headset_info,
1552                 }
1553 };
1554 #endif
1555
1556 #if defined(CONFIG_GS_L3G4200D)
1557
1558 #include <linux/l3g4200d.h>
1559 #define L3G4200D_INT_PIN  RK29_PIN5_PA3
1560
1561 static int l3g4200d_init_platform_hw(void)
1562 {
1563         if (gpio_request(L3G4200D_INT_PIN, NULL) != 0) {
1564                 gpio_free(L3G4200D_INT_PIN);
1565                 printk("%s: request l3g4200d int pin error\n", __func__);
1566                 return -EIO;
1567         }
1568         gpio_pull_updown(L3G4200D_INT_PIN, 1);
1569         return 0;
1570 }
1571
1572 static struct l3g4200d_platform_data l3g4200d_info = {
1573         .fs_range = 1,
1574         
1575         .axis_map_x = 0,
1576         .axis_map_y = 1,
1577         .axis_map_z = 2,
1578
1579         .negate_x = 1,
1580         .negate_y = 1,
1581         .negate_z = 0,
1582
1583         .init = l3g4200d_init_platform_hw,
1584 };
1585
1586 #endif
1587
1588 /*****************************************************************************************
1589  * i2c devices
1590  * author: kfx@rock-chips.com
1591 *****************************************************************************************/
1592 static int rk29_i2c0_io_init(void)
1593 {
1594 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1595         rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
1596         rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
1597 #else
1598         rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
1599         rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
1600 #endif
1601         return 0;
1602 }
1603
1604 static int rk29_i2c1_io_init(void)
1605 {
1606 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1607         rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
1608         rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
1609 #else
1610         rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
1611         rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
1612 #endif
1613         return 0;
1614 }
1615 static int rk29_i2c2_io_init(void)
1616 {
1617 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1618         rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
1619         rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
1620 #else
1621         rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
1622         rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
1623 #endif
1624         return 0;
1625 }
1626
1627 static int rk29_i2c3_io_init(void)
1628 {
1629 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1630         rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
1631         rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1632 #else
1633         rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
1634         rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
1635 #endif
1636         return 0;
1637 }
1638 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1639 struct rk29_i2c_platform_data default_i2c0_data = {
1640         .bus_num    = 0,
1641         .flags      = 0,
1642         .slave_addr = 0xff,
1643         .scl_rate  = 400*1000,
1644         .mode           = I2C_MODE_IRQ,
1645         .io_init = rk29_i2c0_io_init,
1646 };
1647 #else
1648 struct i2c_gpio_platform_data default_i2c0_data = {
1649        .sda_pin = RK29_PIN2_PB6,
1650        .scl_pin = RK29_PIN2_PB7,
1651        .udelay = 5, // clk = 500/udelay = 100Khz
1652        .timeout = 100,//msecs_to_jiffies(200),
1653        .bus_num    = 0,
1654        .io_init = rk29_i2c0_io_init,
1655 };
1656 #endif
1657 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1658 struct rk29_i2c_platform_data default_i2c1_data = {
1659         .bus_num    = 1,
1660         .flags      = 0,
1661         .slave_addr = 0xff,
1662         .scl_rate  = 400*1000,
1663         .mode           = I2C_MODE_IRQ,
1664         .io_init = rk29_i2c1_io_init,
1665 };
1666 #else
1667 struct i2c_gpio_platform_data default_i2c1_data = {
1668        .sda_pin = RK29_PIN1_PA6,
1669        .scl_pin = RK29_PIN1_PA7,
1670        .udelay = 5, // clk = 500/udelay = 100Khz
1671        .timeout = 100,//msecs_to_jiffies(200),
1672        .bus_num    = 1,
1673        .io_init = rk29_i2c1_io_init,
1674 };
1675 #endif
1676 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1677 struct rk29_i2c_platform_data default_i2c2_data = {
1678         .bus_num    = 2,
1679         .flags      = 0,
1680         .slave_addr = 0xff,
1681         .scl_rate  = 400*1000,
1682         .mode           = I2C_MODE_IRQ,
1683         .io_init = rk29_i2c2_io_init,
1684 };
1685 #else
1686 struct i2c_gpio_platform_data default_i2c2_data = {
1687        .sda_pin = RK29_PIN5_PD3,
1688        .scl_pin = RK29_PIN5_PD4,
1689        .udelay = 5, // clk = 500/udelay = 100Khz
1690        .timeout = 100,//msecs_to_jiffies(200),
1691        .bus_num    = 2,
1692        .io_init = rk29_i2c2_io_init,
1693 };
1694 #endif
1695 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1696 struct rk29_i2c_platform_data default_i2c3_data = {
1697         .bus_num    = 3,
1698         .flags      = 0,
1699         .slave_addr = 0xff,
1700         .scl_rate  = 400*1000,
1701         .mode           = I2C_MODE_IRQ,
1702         .io_init = rk29_i2c3_io_init,
1703 };
1704 #else
1705 struct i2c_gpio_platform_data default_i2c3_data = {
1706        .sda_pin = RK29_PIN5_PB5,
1707        .scl_pin = RK29_PIN5_PB4,
1708        .udelay = 5, // clk = 500/udelay = 100Khz
1709        .timeout = 100,//msecs_to_jiffies(200),
1710        .bus_num    = 3,
1711        .io_init = rk29_i2c3_io_init,
1712 };
1713 #endif
1714 #ifdef CONFIG_I2C0_RK29
1715 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1716 #if defined (CONFIG_RK1000_CONTROL)
1717         {
1718                 .type                   = "rk1000_control",
1719                 .addr           = 0x40,
1720                 .flags                  = 0,
1721         },
1722 #endif
1723 #if defined (CONFIG_SND_SOC_RK1000)
1724         {
1725                 .type                   = "rk1000_i2c_codec",
1726                 .addr           = 0x60,
1727                 .flags                  = 0,
1728         },
1729 #endif
1730 #if defined (CONFIG_SND_SOC_WM8900)
1731         {
1732                 .type                   = "wm8900",
1733                 .addr           = 0x1A,
1734                 .flags                  = 0,
1735         },
1736 #endif
1737 #if defined (CONFIG_SND_SOC_WM8994)
1738         {
1739                 .type                   = "wm8994",
1740                 .addr           = 0x1a,
1741                 .flags                  = 0,
1742 //      #if defined(CONFIG_MFD_WM8994)  
1743                 .platform_data  = &wm8994_platdata,     
1744 //      #endif  
1745         },
1746 #endif
1747 #if defined (CONFIG_BATTERY_STC3100)
1748         {
1749                 .type                   = "stc3100",
1750                 .addr           = 0x70,
1751                 .flags                  = 0,
1752         },
1753 #endif
1754 #if defined (CONFIG_BATTERY_BQ27510)
1755         {
1756                 .type                   = "bq27510",
1757                 .addr           = 0x55,
1758                 .flags                  = 0,
1759         },
1760 #endif
1761 #if defined (CONFIG_RTC_HYM8563)
1762         {
1763                 .type                   = "rtc_hym8563",
1764                 .addr           = 0x51,
1765                 .flags                  = 0,
1766                 .irq            = RK29_PIN0_PA1,
1767         },
1768 #endif
1769 #if defined (CONFIG_GS_MMA8452)
1770     {
1771       .type           = "gs_mma8452",
1772       .addr           = 0x1c,
1773       .flags          = 0,
1774       .irq            = MMA8452_INT_PIN,
1775       .platform_data  = &mma8452_info,
1776     },
1777 #endif
1778 #if defined (CONFIG_COMPASS_AK8973)
1779         {
1780                 .type                   = "ak8973",
1781                 .addr           = 0x1d,
1782                 .flags                  = 0,
1783                 .irq                    = RK29_PIN6_PC5,
1784         },
1785 #endif
1786 #if defined (CONFIG_COMPASS_AK8975)
1787         {
1788                 .type                   = "ak8975",
1789                 .addr           = 0x0d,
1790                 .flags                  = 0,
1791                 .irq                    = RK29_PIN6_PC5,
1792         },
1793 #endif
1794 #if defined (CONFIG_INPUT_LPSENSOR_ISL29028)
1795         {
1796                 .type           = "isl29028",
1797                 .addr           = 0x44,
1798                 .flags          = 0,
1799                 .irq            = RK29_PIN4_PD3,
1800         },
1801 #endif
1802 #if defined (CONFIG_ANX7150)
1803     {
1804                 .type           = "anx7150",
1805         .addr           = 0x39,             //0x39, 0x3d
1806         .flags          = 0,
1807         .irq            = RK29_PIN2_PA3,
1808     },
1809 #endif
1810 #if defined (CONFIG_GS_L3G4200D)
1811         {
1812                 .type           = "gs_l3g4200d",
1813                 .addr           = 0x69,
1814                 .flags          = 0,
1815                 .irq            = L3G4200D_INT_PIN,
1816                 .platform_data  = &l3g4200d_info,
1817         },
1818 #endif
1819 #if defined (CONFIG_SENSORS_MPU3050) 
1820         {
1821                 .type                   = "mpu3050",
1822                 .addr                   = 0x68,
1823                 .flags                  = 0,
1824                 .irq                    = RK29_PIN4_PC4,
1825                 .platform_data  = &mpu3050_data,
1826         },
1827 #endif
1828 };
1829 #endif
1830
1831 #ifdef CONFIG_I2C1_RK29
1832 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1833 #if defined (CONFIG_RK1000_CONTROL1)
1834         {
1835                 .type                   = "rk1000_control",
1836                 .addr                   = 0x40,
1837                 .flags                  = 0,
1838         },
1839 #endif
1840
1841 };
1842 #endif
1843
1844 #ifdef CONFIG_I2C2_RK29
1845 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1846 #if defined (CONFIG_TOUCHSCREEN_GT801_IIC)
1847 {
1848         .type           = "gt801_ts",
1849         .addr           = 0x55,
1850         .flags          = 0,
1851         .irq            = RK29_PIN4_PD5,
1852         .platform_data = &gt801_info,
1853 },      
1854 #endif
1855
1856 #if defined (CONFIG_TOUCHSCREEN_ILI2102_IIC)
1857 {
1858         .type           = "ili2102_ts",
1859         .addr           = 0x41,
1860         .flags          = I2C_M_NEED_DELAY,
1861         .udelay      = 600,
1862         .irq            = RK29_PIN4_PD5,
1863         .platform_data = &ili2102_info,
1864 },      
1865 #endif
1866
1867 #if defined (CONFIG_MFD_WM831X_I2C)
1868 {
1869         .type           = "wm8310",
1870         .addr           = 0x34,
1871         .flags          = 0,
1872         .irq            = RK29_PIN4_PD0,
1873         .platform_data = &wm831x_platdata,
1874 },      
1875 #endif
1876 #if defined (CONFIG_HANNSTAR_P1003)
1877     {
1878       .type           = "p1003_touch",
1879       .addr           = 0x04,
1880       .flags          = 0,
1881       .irq            = RK29_PIN0_PA2,
1882       .platform_data  = &p1003_info,
1883     },
1884 #endif
1885 #if defined (CONFIG_EETI_EGALAX)
1886     {
1887       .type           = "egalax_i2c",
1888       .addr           = 0x04,
1889       .flags          = 0,
1890       .irq            = RK29_PIN4_PD5,
1891       .platform_data  = &eeti_egalax_info,
1892     },
1893 #endif
1894 };
1895 #endif
1896
1897 #ifdef CONFIG_I2C3_RK29
1898 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1899 };
1900 #endif
1901
1902 /*****************************************************************************************
1903  * camera  devices
1904  * author: ddl@rock-chips.com
1905  *****************************************************************************************/
1906 #ifdef CONFIG_VIDEO_RK29 
1907 #define CONFIG_SENSOR_POWER_IOCTL_USR      0
1908 #define CONFIG_SENSOR_RESET_IOCTL_USR      0
1909 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR      0
1910 #define CONFIG_SENSOR_FLASH_IOCTL_USR      0
1911
1912 #if CONFIG_SENSOR_POWER_IOCTL_USR
1913 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
1914 {
1915     #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
1916 }
1917 #endif
1918
1919 #if CONFIG_SENSOR_RESET_IOCTL_USR
1920 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
1921 {
1922     #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
1923 }
1924 #endif
1925
1926 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1927 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
1928 {
1929     #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
1930 }
1931 #endif
1932
1933 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1934 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
1935 {
1936     #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
1937 }
1938 #endif
1939
1940 static struct rk29camera_platform_ioctl_cb  sensor_ioctl_cb = {
1941     #if CONFIG_SENSOR_POWER_IOCTL_USR
1942     .sensor_power_cb = sensor_power_usr_cb,
1943     #else
1944     .sensor_power_cb = NULL,
1945     #endif
1946
1947     #if CONFIG_SENSOR_RESET_IOCTL_USR
1948     .sensor_reset_cb = sensor_reset_usr_cb,
1949     #else
1950     .sensor_reset_cb = NULL,
1951     #endif
1952
1953     #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1954     .sensor_powerdown_cb = sensor_powerdown_usr_cb,
1955     #else
1956     .sensor_powerdown_cb = NULL,
1957     #endif
1958
1959     #if CONFIG_SENSOR_FLASH_IOCTL_USR
1960     .sensor_flash_cb = sensor_flash_usr_cb,
1961     #else
1962     .sensor_flash_cb = NULL,
1963     #endif
1964 };
1965 #include "../../../drivers/media/video/rk29_camera.c"
1966 #endif
1967
1968 /*****************************************************************************************
1969  * backlight  devices
1970  * author: nzy@rock-chips.com
1971  *****************************************************************************************/
1972 #ifdef CONFIG_BACKLIGHT_RK29_BL
1973  /*
1974  GPIO1B5_PWM0_NAME,       GPIO1L_PWM0
1975  GPIO5D2_PWM1_UART1SIRIN_NAME,  GPIO5H_PWM1
1976  GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME,   GPIO2L_PWM2
1977  GPIO1A5_EMMCPWREN_PWM3_NAME,     GPIO1L_PWM3
1978  */
1979
1980 #define PWM_ID            0
1981 #define PWM_MUX_NAME      GPIO1B5_PWM0_NAME
1982 #define PWM_MUX_MODE      GPIO1L_PWM0
1983 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1984 #define PWM_EFFECT_VALUE  1
1985
1986 //#define LCD_DISP_ON_PIN
1987
1988 #ifdef  LCD_DISP_ON_PIN
1989 #define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
1990 #define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
1991
1992 #define BL_EN_PIN         GPIO0L_GPIO0A5
1993 #define BL_EN_VALUE       GPIO_HIGH
1994 #endif
1995 static int rk29_backlight_io_init(void)
1996 {
1997     int ret = 0;
1998
1999     rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
2000         #ifdef  LCD_DISP_ON_PIN
2001     rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
2002
2003     ret = gpio_request(BL_EN_PIN, NULL);
2004     if(ret != 0)
2005     {
2006         gpio_free(BL_EN_PIN);
2007     }
2008
2009     gpio_direction_output(BL_EN_PIN, 0);
2010     gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
2011         #endif
2012     return ret;
2013 }
2014
2015 static int rk29_backlight_io_deinit(void)
2016 {
2017     int ret = 0;
2018     #ifdef  LCD_DISP_ON_PIN
2019     gpio_free(BL_EN_PIN);
2020     #endif
2021     rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
2022     return ret;
2023 }
2024 struct rk29_bl_info rk29_bl_info = {
2025     .pwm_id   = PWM_ID,
2026     .bl_ref   = PWM_EFFECT_VALUE,
2027     .io_init   = rk29_backlight_io_init,
2028     .io_deinit = rk29_backlight_io_deinit,
2029 };
2030 #endif
2031 /*****************************************************************************************
2032 * pwm voltage regulator devices
2033 ******************************************************************************************/
2034 #if defined (CONFIG_RK29_PWM_REGULATOR)
2035
2036 #define REGULATOR_PWM_ID                                        2
2037 #define REGULATOR_PWM_MUX_NAME                  GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
2038 #define REGULATOR_PWM_MUX_MODE                                          GPIO2L_PWM2
2039 #define REGULATOR_PWM_MUX_MODE_GPIO                             GPIO2L_GPIO2A3
2040 #define REGULATOR_PWM_GPIO                              RK29_PIN2_PA3
2041
2042 static struct regulator_consumer_supply pwm_consumers[] = {
2043         {
2044                 .supply = "vcore",
2045         }
2046 };
2047
2048 static struct regulator_init_data rk29_pwm_regulator_data = {
2049         .constraints = {
2050                 .name = "PWM2",
2051                 .min_uV =  950000,
2052                 .max_uV = 1400000,
2053                 .apply_uV = 1,
2054                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
2055         },
2056         .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
2057         .consumer_supplies = pwm_consumers,
2058 };
2059
2060 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
2061         .pwm_id = REGULATOR_PWM_ID,
2062         .pwm_gpio = REGULATOR_PWM_GPIO,
2063         //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
2064         .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
2065         .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
2066         .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
2067         .init_data  = &rk29_pwm_regulator_data,
2068 };
2069
2070 static struct platform_device rk29_device_pwm_regulator = {
2071         .name = "pwm-voltage-regulator",
2072         .id   = -1,
2073         .dev  = {
2074                 .platform_data = &rk29_regulator_pwm_platform_data,
2075         },
2076 };
2077
2078 #endif
2079
2080
2081 #if defined(CONFIG_MTK23D)
2082 static int mtk23d_io_init(void)
2083 {
2084         
2085         return 0;
2086 }
2087
2088 static int mtk23d_io_deinit(void)
2089 {
2090         
2091         return 0;
2092 }
2093  
2094 struct rk2818_23d_data rk2818_23d_info = {
2095         .io_init = mtk23d_io_init,
2096   .io_deinit = mtk23d_io_deinit,
2097         .bp_power = RK29_PIN0_PA0,
2098         .bp_power_active_low = 0,
2099         .bp_reset = RK29_PIN0_PA1,
2100         .bp_reset_active_low = 1,
2101         .bp_statue = RK29_PIN0_PA2,//input  high bp sleep;
2102         .ap_statue = RK29_PIN0_PA4,//output high ap sleep;
2103         .ap_bp_wakeup = RK29_PIN0_PA3, //output AP wake up BP used rising edge;
2104         .bp_ap_wakeup = 0,//input BP wake up AP
2105 };
2106 struct platform_device rk2818_device_mtk23d = { 
2107         .name = "mtk23d",       
2108         .id = -1,       
2109         .dev            = {
2110                 .platform_data = &rk2818_23d_info,
2111         }       
2112     };
2113 #endif
2114
2115
2116 /*****************************************************************************************
2117  * SDMMC devices
2118 *****************************************************************************************/
2119 #ifdef CONFIG_SDMMC0_RK29
2120 static int rk29_sdmmc0_cfg_gpio(void)
2121 {
2122         rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
2123         rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
2124         rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
2125         rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
2126         rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
2127         rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
2128         rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
2129         rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5);   ///GPIO5H_SDMMC0_PWR_EN);  ///GPIO5H_GPIO5D5);
2130         gpio_request(RK29_PIN5_PD5,"sdmmc");
2131         gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
2132         mdelay(100);
2133         gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
2134         return 0;
2135 }
2136
2137 #define CONFIG_SDMMC0_USE_DMA
2138 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
2139         .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
2140                                            MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
2141                                            MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
2142         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2143         .io_init = rk29_sdmmc0_cfg_gpio,
2144         .dma_name = "sd_mmc",
2145 #ifdef CONFIG_SDMMC0_USE_DMA
2146         .use_dma  = 1,
2147 #else
2148         .use_dma = 0,
2149 #endif
2150         .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
2151         .enable_sd_wakeup = 0,
2152 };
2153 #endif
2154 #ifdef CONFIG_SDMMC1_RK29
2155 #define CONFIG_SDMMC1_USE_DMA
2156 static int rk29_sdmmc1_cfg_gpio(void)
2157 {
2158         rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2159         rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2160         rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2161         rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2162         rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2163         rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2164         //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
2165         return 0;
2166 }
2167
2168 #ifdef CONFIG_WIFI_CONTROL_FUNC
2169 static int rk29sdk_wifi_status(struct device *dev);
2170 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
2171 #endif
2172
2173 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK29_PIN1_PD6
2174
2175 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
2176         .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
2177                                            MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
2178                                            MMC_VDD_32_33|MMC_VDD_33_34),
2179         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
2180                                    MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2181         .io_init = rk29_sdmmc1_cfg_gpio,
2182         .dma_name = "sdio",
2183 #ifdef CONFIG_SDMMC1_USE_DMA
2184         .use_dma  = 1,
2185 #else
2186         .use_dma = 0,
2187 #endif
2188 #ifdef CONFIG_WIFI_CONTROL_FUNC
2189         .status = rk29sdk_wifi_status,
2190         .register_status_notify = rk29sdk_wifi_status_register,
2191 #endif
2192 #if 0
2193         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
2194 #endif
2195 };
2196 #endif
2197
2198 #ifdef CONFIG_WIFI_CONTROL_FUNC
2199 #define RK29SDK_WIFI_BT_GPIO_POWER_N       RK29_PIN5_PD6
2200 #define RK29SDK_WIFI_GPIO_RESET_N          RK29_PIN6_PC0
2201 #define RK29SDK_BT_GPIO_RESET_N            RK29_PIN6_PC7
2202
2203 static int rk29sdk_wifi_cd = 0;   /* wifi virtual 'card detect' status */
2204 static void (*wifi_status_cb)(int card_present, void *dev_id);
2205 static void *wifi_status_cb_devid;
2206 int rk29sdk_wifi_power_state = 0;
2207 int rk29sdk_bt_power_state = 0;
2208
2209 static int rk29sdk_wifi_status(struct device *dev)
2210 {
2211         return rk29sdk_wifi_cd;
2212 }
2213
2214 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
2215 {
2216         if(wifi_status_cb)
2217                 return -EAGAIN;
2218         wifi_status_cb = callback;
2219         wifi_status_cb_devid = dev_id;
2220         return 0;
2221 }
2222
2223 static int rk29sdk_wifi_bt_gpio_control_init(void)
2224 {
2225     if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
2226            pr_info("%s: request wifi_bt power gpio failed\n", __func__);
2227            return -1;
2228     }
2229
2230     if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
2231            pr_info("%s: request wifi reset gpio failed\n", __func__);
2232            gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
2233            return -1;
2234     }
2235
2236     if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
2237           pr_info("%s: request bt reset gpio failed\n", __func__);
2238           gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
2239           return -1;
2240     }
2241
2242     gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2243     gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N,    GPIO_LOW);
2244     gpio_direction_output(RK29SDK_BT_GPIO_RESET_N,      GPIO_LOW);
2245
2246     pr_info("%s: init finished\n",__func__);
2247
2248     return 0;
2249 }
2250
2251 static int rk29sdk_wifi_power(int on)
2252 {
2253         pr_info("%s: %d\n", __func__, on);
2254         if (on){
2255                 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
2256                 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
2257                 mdelay(100);
2258                 pr_info("wifi turn on power\n");
2259         }else{
2260                 if (!rk29sdk_bt_power_state){
2261                         gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2262                         mdelay(100);
2263                         pr_info("wifi shut off power\n");
2264                 }else
2265                 {
2266                         pr_info("wifi shouldn't shut off power, bt is using it!\n");
2267                 }
2268                 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2269
2270         }
2271
2272         rk29sdk_wifi_power_state = on;
2273         return 0;
2274 }
2275
2276 static int rk29sdk_wifi_reset_state;
2277 static int rk29sdk_wifi_reset(int on)
2278 {
2279         pr_info("%s: %d\n", __func__, on);
2280         gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
2281         mdelay(100);
2282         rk29sdk_wifi_reset_state = on;
2283         return 0;
2284 }
2285
2286 int rk29sdk_wifi_set_carddetect(int val)
2287 {
2288         pr_info("%s:%d\n", __func__, val);
2289         rk29sdk_wifi_cd = val;
2290         if (wifi_status_cb){
2291                 wifi_status_cb(val, wifi_status_cb_devid);
2292         }else {
2293                 pr_warning("%s, nobody to notify\n", __func__);
2294         }
2295         return 0;
2296 }
2297 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
2298
2299 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
2300         {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
2301         {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
2302         {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
2303         {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
2304 };
2305
2306 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
2307 {
2308         if (section == PREALLOC_WLAN_SEC_NUM)
2309                 return wlan_static_skb;
2310
2311         if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
2312                 return NULL;
2313
2314         if (wifi_mem_array[section].size < size)
2315                 return NULL;
2316
2317         return wifi_mem_array[section].mem_ptr;
2318 }
2319
2320 int __init rk29sdk_init_wifi_mem(void)
2321 {
2322         int i;
2323         int j;
2324
2325         for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
2326                 wlan_static_skb[i] = dev_alloc_skb(
2327                                 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
2328
2329                 if (!wlan_static_skb[i])
2330                         goto err_skb_alloc;
2331         }
2332
2333         for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
2334                 wifi_mem_array[i].mem_ptr =
2335                                 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
2336
2337                 if (!wifi_mem_array[i].mem_ptr)
2338                         goto err_mem_alloc;
2339         }
2340         return 0;
2341
2342  err_mem_alloc:
2343         pr_err("Failed to mem_alloc for WLAN\n");
2344         for (j = 0 ; j < i ; j++)
2345                 kfree(wifi_mem_array[j].mem_ptr);
2346
2347         i = WLAN_SKB_BUF_NUM;
2348
2349  err_skb_alloc:
2350         pr_err("Failed to skb_alloc for WLAN\n");
2351         for (j = 0 ; j < i ; j++)
2352                 dev_kfree_skb(wlan_static_skb[j]);
2353
2354         return -ENOMEM;
2355 }
2356
2357 static struct wifi_platform_data rk29sdk_wifi_control = {
2358         .set_power = rk29sdk_wifi_power,
2359         .set_reset = rk29sdk_wifi_reset,
2360         .set_carddetect = rk29sdk_wifi_set_carddetect,
2361         .mem_prealloc   = rk29sdk_mem_prealloc,
2362 };
2363 static struct platform_device rk29sdk_wifi_device = {
2364         .name = "bcm4329_wlan",
2365         .id = 1,
2366         .dev = {
2367                 .platform_data = &rk29sdk_wifi_control,
2368          },
2369 };
2370 #endif
2371
2372
2373 /* bluetooth rfkill device */
2374 static struct platform_device rk29sdk_rfkill = {
2375         .name = "rk29sdk_rfkill",
2376         .id = -1,
2377 };
2378
2379
2380 #ifdef CONFIG_VIVANTE
2381 static struct resource resources_gpu[] = {
2382     [0] = {
2383                 .name   = "gpu_irq",
2384         .start  = IRQ_GPU,
2385         .end    = IRQ_GPU,
2386         .flags  = IORESOURCE_IRQ,
2387     },
2388     [1] = {
2389                 .name = "gpu_base",
2390         .start  = RK29_GPU_PHYS,
2391         .end    = RK29_GPU_PHYS + RK29_GPU_SIZE,
2392         .flags  = IORESOURCE_MEM,
2393     },
2394     [2] = {
2395                 .name = "gpu_mem",
2396         .start  = PMEM_GPU_BASE,
2397         .end    = PMEM_GPU_BASE + PMEM_GPU_SIZE,
2398         .flags  = IORESOURCE_MEM,
2399     },
2400 };
2401 static struct platform_device rk29_device_gpu = {
2402     .name             = "galcore",
2403     .id               = 0,
2404     .num_resources    = ARRAY_SIZE(resources_gpu),
2405     .resource         = resources_gpu,
2406 };
2407 #endif
2408 #ifdef CONFIG_KEYS_RK29
2409 extern struct rk29_keys_platform_data rk29_keys_pdata;
2410 static struct platform_device rk29_device_keys = {
2411         .name           = "rk29-keypad",
2412         .id             = -1,
2413         .dev            = {
2414                 .platform_data  = &rk29_keys_pdata,
2415         },
2416 };
2417 #endif
2418
2419 #ifdef CONFIG_USE_GPIO_GENERATE_WAVE
2420 static struct gpio_wave_platform_data gpio_wave_pdata = {
2421         .gpio = RK29_PIN0_PA0,
2422         .Htime = 2000,
2423         .Ltime = 300,
2424         .Dvalue = GPIO_HIGH,
2425 };
2426 static struct platform_device gpio_wave_device = {
2427         .name           = "gpio_wave",
2428         .id     = -1,
2429         .dev            = {
2430                 .platform_data  = &gpio_wave_pdata,
2431         },
2432 };
2433 #endif
2434
2435 static void __init rk29_board_iomux_init(void)
2436 {
2437         #ifdef CONFIG_RK29_PWM_REGULATOR
2438         rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
2439         #endif
2440 }
2441
2442 static struct platform_device *devices[] __initdata = {
2443 #ifdef CONFIG_UART1_RK29
2444         &rk29_device_uart1,
2445 #endif
2446 #ifdef CONFIG_UART0_RK29
2447         &rk29_device_uart0,
2448 #endif
2449 #ifdef CONFIG_UART2_RK29
2450         &rk29_device_uart2,
2451 #endif
2452 #ifdef CONFIG_UART3_RK29
2453         &rk29_device_uart3,
2454 #endif
2455
2456 #ifdef CONFIG_RK29_PWM_REGULATOR
2457         &rk29_device_pwm_regulator,
2458 #endif
2459 #ifdef CONFIG_SPIM0_RK29
2460     &rk29xx_device_spi0m,
2461 #endif
2462 #ifdef CONFIG_SPIM1_RK29
2463     &rk29xx_device_spi1m,
2464 #endif
2465 #ifdef CONFIG_ADC_RK29
2466         &rk29_device_adc,
2467 #endif
2468 #ifdef CONFIG_I2C0_RK29
2469         &rk29_device_i2c0,
2470 #endif
2471 #ifdef CONFIG_I2C1_RK29
2472         &rk29_device_i2c1,
2473 #endif
2474 #ifdef CONFIG_I2C2_RK29
2475         &rk29_device_i2c2,
2476 #endif
2477 #ifdef CONFIG_I2C3_RK29
2478         &rk29_device_i2c3,
2479 #endif
2480
2481 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
2482         &rk29_device_iis_2ch,
2483 #endif
2484 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
2485         &rk29_device_iis_8ch,
2486 #endif
2487
2488 #ifdef CONFIG_KEYS_RK29
2489         &rk29_device_keys,
2490 #endif
2491 #ifdef CONFIG_USE_GPIO_GENERATE_WAVE
2492         &gpio_wave_device,
2493 #endif
2494 #ifdef CONFIG_SDMMC0_RK29
2495         &rk29_device_sdmmc0,
2496 #endif
2497 #ifdef CONFIG_SDMMC1_RK29
2498         &rk29_device_sdmmc1,
2499 #endif
2500
2501 #ifdef CONFIG_MTD_NAND_RK29XX
2502         &rk29xx_device_nand,
2503 #endif
2504
2505 #ifdef CONFIG_WIFI_CONTROL_FUNC
2506         &rk29sdk_wifi_device,
2507 #endif
2508
2509 #ifdef CONFIG_BT
2510         &rk29sdk_rfkill,
2511 #endif
2512
2513 #if defined(CONFIG_MTK23D)
2514         &rk2818_device_mtk23d,
2515 #endif
2516
2517 #ifdef CONFIG_MTD_NAND_RK29
2518         &rk29_device_nand,
2519 #endif
2520
2521 #ifdef CONFIG_FB_RK29
2522         &rk29_device_fb,
2523         &rk29_device_dma_cpy,
2524 #endif
2525 #ifdef CONFIG_BACKLIGHT_RK29_BL
2526         &rk29_device_backlight,
2527 #endif
2528 #ifdef CONFIG_RK29_VMAC
2529         &rk29_device_vmac,
2530 #endif
2531 #ifdef CONFIG_VIVANTE
2532         &rk29_device_gpu,
2533 #endif
2534 #ifdef CONFIG_VIDEO_RK29
2535         &rk29_device_camera,      /* ddl@rock-chips.com : camera support  */
2536         #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
2537         &rk29_soc_camera_pdrv_0,
2538         #endif
2539         &rk29_soc_camera_pdrv_1,
2540         &android_pmem_cam_device,
2541 #endif
2542         &android_pmem_device,
2543         &rk29_vpu_mem_device,
2544 #ifdef CONFIG_USB20_OTG
2545         &rk29_device_usb20_otg,
2546 #endif
2547 #ifdef CONFIG_USB20_HOST
2548         &rk29_device_usb20_host,
2549 #endif
2550 #ifdef CONFIG_USB11_HOST
2551         &rk29_device_usb11_host,
2552 #endif
2553 #ifdef CONFIG_USB_ANDROID
2554         &android_usb_device,
2555         &usb_mass_storage_device,
2556 #endif
2557 #ifdef CONFIG_RK29_IPP
2558         &rk29_device_ipp,
2559 #endif
2560 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2561         &rk29_v4l2_output_devce,
2562 #endif
2563 #ifdef CONFIG_RK_HEADSET_DET
2564     &rk28_device_headset,
2565 #endif
2566 #ifdef CONFIG_RK29_GPS
2567         &rk29_device_gps,
2568 #endif
2569 };
2570
2571 #ifdef CONFIG_RK29_VMAC
2572 /*****************************************************************************************
2573  * vmac devices
2574  * author: lyx@rock-chips.com
2575  *****************************************************************************************/
2576 static int rk29_vmac_register_set(void)
2577 {
2578         //config rk29 vmac as rmii, 100MHz
2579         u32 value= readl(RK29_GRF_BASE + 0xbc);
2580         value = (value & 0xfff7ff) | (0x400);
2581         writel(value, RK29_GRF_BASE + 0xbc);
2582         return 0;
2583 }
2584
2585 static int rk29_rmii_io_init(void)
2586 {
2587         int err;
2588
2589         //phy power gpio
2590         err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2591         if (err) {
2592                 gpio_free(RK29_PIN6_PB0);
2593                 printk("-------request RK29_PIN6_PB0 fail--------\n");
2594                 return -1;
2595         }
2596         //phy power down
2597         gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2598         gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2599
2600         return 0;
2601 }
2602
2603 static int rk29_rmii_io_deinit(void)
2604 {
2605         //phy power down
2606         gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2607         gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2608         //free
2609         gpio_free(RK29_PIN6_PB0);
2610         return 0;
2611 }
2612
2613 static int rk29_rmii_power_control(int enable)
2614 {
2615         if (enable) {
2616                 //enable phy power
2617                 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2618                 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2619         }
2620         else {
2621                 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2622                 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2623         }
2624         return 0;
2625 }
2626
2627 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2628         .vmac_register_set = rk29_vmac_register_set,
2629         .rmii_io_init = rk29_rmii_io_init,
2630         .rmii_io_deinit = rk29_rmii_io_deinit,
2631         .rmii_power_control = rk29_rmii_power_control,
2632 };
2633 #endif
2634
2635 /*****************************************************************************************
2636  * spi devices
2637  * author: cmc@rock-chips.com
2638  *****************************************************************************************/
2639 #define SPI_CHIPSELECT_NUM 2
2640 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2641     {
2642                 .name = "spi0 cs0",
2643                 .cs_gpio = RK29_PIN2_PC1,
2644                 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2645                 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2646         },
2647         {
2648                 .name = "spi0 cs1",
2649                 .cs_gpio = RK29_PIN1_PA4,
2650                 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2651                 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2652         }
2653 };
2654
2655 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2656     {
2657                 .name = "spi1 cs0",
2658                 .cs_gpio = RK29_PIN2_PC5,
2659                 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2660                 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2661         },
2662         {
2663                 .name = "spi1 cs1",
2664                 .cs_gpio = RK29_PIN1_PA3,
2665                 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2666                 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2667         }
2668 };
2669
2670 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2671 {
2672 #if 1
2673                 int i;
2674                 if (cs_gpios) {
2675                         for (i=0; i<cs_num; i++) {
2676                                 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2677                         }
2678                 }
2679 #endif
2680         return 0;
2681 }
2682
2683 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2684 {
2685         return 0;
2686 }
2687
2688 static int spi_io_fix_leakage_bug(void)
2689 {
2690 #if 0
2691         gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2692 #endif
2693         return 0;
2694 }
2695
2696 static int spi_io_resume_leakage_bug(void)
2697 {
2698 #if 0
2699         gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2700 #endif
2701         return 0;
2702 }
2703
2704 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2705         .num_chipselect = SPI_CHIPSELECT_NUM,
2706         .chipselect_gpios = rk29xx_spi0_cs_gpios,
2707         .io_init = spi_io_init,
2708         .io_deinit = spi_io_deinit,
2709         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2710         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2711 };
2712
2713 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2714         .num_chipselect = SPI_CHIPSELECT_NUM,
2715         .chipselect_gpios = rk29xx_spi1_cs_gpios,
2716         .io_init = spi_io_init,
2717         .io_deinit = spi_io_deinit,
2718         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2719         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2720 };
2721
2722 /*****************************************************************************************
2723  * xpt2046 touch panel
2724  * author: hhb@rock-chips.com
2725  *****************************************************************************************/
2726 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
2727 #define XPT2046_GPIO_INT           RK29_PIN4_PD5 //中断???#define DEBOUNCE_REPTIME  3
2728
2729 static struct xpt2046_platform_data xpt2046_info = {
2730         .model                  = 2046,
2731         .keep_vref_on   = 1,
2732         .swap_xy                = 0,
2733         .debounce_max           = 7,
2734         .debounce_rep           = DEBOUNCE_REPTIME,
2735         .debounce_tol           = 20,
2736         .gpio_pendown           = XPT2046_GPIO_INT,
2737         .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME, 
2738         .pendown_iomux_mode = GPIO4H_GPIO4D5,   
2739         .touch_virtualkey_length = 60,
2740         .penirq_recheck_delay_usecs = 1,
2741 #if defined(CONFIG_TOUCHSCREEN_480X800)
2742         .x_min                  = 0,
2743         .x_max                  = 480,
2744         .y_min                  = 0,
2745         .y_max                  = 800,
2746         .touch_ad_top = 3940,
2747         .touch_ad_bottom = 310,
2748         .touch_ad_left = 3772,
2749         .touch_ad_right = 340,
2750 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2751         .x_min                  = 0,
2752         .x_max                  = 800,
2753         .y_min                  = 0,
2754         .y_max                  = 480,
2755         .touch_ad_top = 2447,
2756         .touch_ad_bottom = 207,
2757         .touch_ad_left = 5938,
2758         .touch_ad_right = 153,
2759 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2760         .x_min                  = 0,
2761         .x_max                  = 320,
2762         .y_min                  = 0,
2763         .y_max                  = 480,
2764         .touch_ad_top = 3166,
2765         .touch_ad_bottom = 256,
2766         .touch_ad_left = 3658,
2767         .touch_ad_right = 380,
2768 #endif  
2769 };
2770 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2771 static struct xpt2046_platform_data xpt2046_info = {
2772         .model                  = 2046,
2773         .keep_vref_on   = 1,
2774         .swap_xy                = 0,
2775         .debounce_max           = 7,
2776         .debounce_rep           = DEBOUNCE_REPTIME,
2777         .debounce_tol           = 20,
2778         .gpio_pendown           = XPT2046_GPIO_INT,
2779         .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME, 
2780         .pendown_iomux_mode = GPIO4H_GPIO4D5,   
2781         .touch_virtualkey_length = 60,
2782         .penirq_recheck_delay_usecs = 1,
2783         
2784 #if defined(CONFIG_TOUCHSCREEN_480X800)
2785         .x_min                  = 0,
2786         .x_max                  = 480,
2787         .y_min                  = 0,
2788         .y_max                  = 800,
2789         .screen_x = { 70,  410, 70, 410, 240},
2790         .screen_y = { 50, 50,  740, 740, 400},
2791         .uncali_x_default = {  3267,  831, 3139, 715, 1845 },
2792         .uncali_y_default = { 3638,  3664, 564,  591, 2087 },
2793 #elif defined(CONFIG_TOUCHSCREEN_800X480)
2794         .x_min                  = 0,
2795         .x_max                  = 800,
2796         .y_min                  = 0,
2797         .y_max                  = 480,
2798         .screen_x[5] = { 50, 750,  50, 750, 400};
2799         .screen_y[5] = { 40,  40, 440, 440, 240};
2800         .uncali_x_default[5] = { 438,  565, 3507,  3631, 2105 };
2801         .uncali_y_default[5] = {  3756,  489, 3792, 534, 2159 };
2802 #elif defined(CONFIG_TOUCHSCREEN_320X480)
2803         .x_min                  = 0,
2804         .x_max                  = 320,
2805         .y_min                  = 0,
2806         .y_max                  = 480,
2807         .screen_x[5] = { 50, 270,  50, 270, 160}; 
2808         .screen_y[5] = { 40,  40, 440, 440, 240}; 
2809         .uncali_x_default[5] = { 812,  3341, 851,  3371, 2183 };
2810         .uncali_y_default[5] = {  442,  435, 3193, 3195, 2004 };
2811 #endif  
2812 };
2813 #endif
2814
2815 #if defined(CONFIG_SERIAL_SC8800)
2816 static struct plat_sc8800 sc8800_plat_data = {
2817         .slav_rts_pin = RK29_PIN4_PD4,
2818         .slav_rdy_pin = RK29_PIN4_PD1,
2819         .master_rts_pin = RK29_PIN4_PD2,
2820         .master_rdy_pin = RK29_PIN4_PD3,
2821         //.poll_time = 100,
2822 };
2823 #endif
2824
2825 static struct spi_board_info board_spi_devices[] = {
2826 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2827         {
2828                 .modalias       = "xpt2046_ts",
2829                 .chip_select    = 0,// 2,
2830                 .max_speed_hz   = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2831                 .bus_num        = 0,
2832                 .irq = XPT2046_GPIO_INT,
2833                 .platform_data = &xpt2046_info,
2834         },
2835 #endif
2836
2837 #if defined(CONFIG_MFD_WM831X_SPI)
2838         {
2839                 .modalias       = "wm8310",
2840                 .chip_select    = 1,
2841                 .max_speed_hz   = 1*1000*1000,
2842                 .bus_num        = 1,
2843                 .irq            = RK29_PIN4_PD0,
2844                 .platform_data = &wm831x_platdata,
2845         },
2846 #endif
2847 #if defined(CONFIG_SERIAL_SC8800)
2848         {
2849                 .modalias  = "sc8800",
2850                 .bus_num = 0,
2851                 .platform_data = &sc8800_plat_data,
2852                 .max_speed_hz  = 12*1000*1000,
2853                 .chip_select   = 0,
2854         },
2855 #endif
2856 };
2857
2858
2859 /**********************************************************************************************
2860  *
2861  * The virtual keys for android "back", "home", "menu", "search", these four keys are touch key
2862  * on the touch screen panel. (added by hhb@rock-chips.com 2011.03.31)
2863  *
2864  ***********************************************************************************************/
2865 static ssize_t rk29xx_virtual_keys_show(struct kobject *kobj,
2866                         struct kobj_attribute *attr, char *buf)
2867 {
2868 #if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
2869         || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC)
2870         /* center: x: home: 50, menu: 184, back: 315, search 435, y: 830*/
2871     /* centerx;centery;width;height; */
2872         return sprintf(buf,
2873                 __stringify(EV_KEY) ":" __stringify(KEY_BACK)       ":315:815:120:50"     //":50:830:98:50"  //":210:796:98:50"
2874                 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU)   ":85:815:88:50"   // ":184:830:120:50"  // ":435:796:120:50"
2875                 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME)   ":184:815:100:50"   //":315:830:100:50"  //":320:796:100:50"
2876                 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":435:815:88:50"   //":50:815:98:50"    //   //":85:796:88:50"
2877                 "\n");
2878 #endif
2879         return 0;
2880 }
2881
2882 static struct kobj_attribute rk29xx_virtual_keys_attr = {
2883         .attr = {
2884 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2885                 .name = "virtualkeys.xpt2046-touchscreen",
2886 #elif defined(CONFIG_TOUCHSCREEN_HX8520_IIC)
2887         .name = "virtualkeys.hx8520-touchscreen",
2888 #elif defined(CONFIG_TOUCHSCREEN_GT801_IIC)
2889                 .name = "virtualkeys.gt801-touchscreen",
2890 #elif defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
2891                 .name = "virtualkeys.ili2102-touchscreen",              
2892 #endif
2893
2894
2895                 .mode = S_IRUGO,
2896         },
2897         .show = &rk29xx_virtual_keys_show,
2898 };
2899
2900 static struct attribute *rk29xx_properties_attrs[] = {
2901         &rk29xx_virtual_keys_attr.attr,
2902         NULL
2903 };
2904
2905 static struct attribute_group rk29xx_properties_attr_group = {
2906         .attrs = rk29xx_properties_attrs,
2907 };
2908 static int rk29xx_virtual_keys_init(void)
2909 {
2910         int ret;
2911         struct kobject *properties_kobj;
2912         printk("rk29xx_virtual_keys_init \n");
2913         properties_kobj = kobject_create_and_add("board_properties", NULL);
2914         if (properties_kobj)
2915                 ret = sysfs_create_group(properties_kobj,
2916                                 &rk29xx_properties_attr_group);
2917         if (!properties_kobj || ret)
2918         {
2919                 pr_err("failed to create board_properties\n");
2920         }
2921         return ret;
2922 }
2923
2924
2925 static void __init rk29_gic_init_irq(void)
2926 {
2927         gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2928         gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2929 }
2930
2931 static void __init machine_rk29_init_irq(void)
2932 {
2933         rk29_gic_init_irq();
2934         rk29_gpio_init();
2935 }
2936
2937 #define POWER_ON_PIN RK29_PIN4_PA4
2938 static void rk29_pm_power_off(void)
2939 {
2940         printk(KERN_ERR "rk29_pm_power_off start...\n");
2941         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2942 #if defined(CONFIG_MFD_WM831X)
2943         wm831x_device_shutdown(gWm831x);
2944 #endif
2945         while (1);
2946 }
2947 static void rk29_pm_power_restart(void)
2948 {
2949         printk("%s\n",__FUNCTION__);
2950         mdelay(2);
2951 #if defined(CONFIG_MFD_WM831X)
2952         wm831x_device_restart(gWm831x);
2953 #endif
2954
2955 }
2956
2957 static void __init machine_rk29_board_init(void)
2958 {
2959         rk29_board_iomux_init();
2960
2961         gpio_request(POWER_ON_PIN,"poweronpin");
2962         gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
2963         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2964         pm_power_off = rk29_pm_power_off;
2965         arm_pm_restart = rk29_pm_power_restart;
2966
2967         platform_add_devices(devices, ARRAY_SIZE(devices));
2968 #ifdef CONFIG_I2C0_RK29
2969         i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2970                         ARRAY_SIZE(board_i2c0_devices));
2971 #endif
2972 #ifdef CONFIG_I2C1_RK29
2973         i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2974                         ARRAY_SIZE(board_i2c1_devices));
2975 #endif
2976 #ifdef CONFIG_I2C2_RK29
2977         i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2978                         ARRAY_SIZE(board_i2c2_devices));
2979 #endif
2980 #ifdef CONFIG_I2C3_RK29
2981         i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2982                         ARRAY_SIZE(board_i2c3_devices));
2983 #endif
2984
2985         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2986
2987 #ifdef CONFIG_WIFI_CONTROL_FUNC
2988         rk29sdk_wifi_bt_gpio_control_init();
2989         rk29sdk_init_wifi_mem();
2990 #endif
2991
2992         rk29xx_virtual_keys_init();
2993 }
2994
2995 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2996                                         char **cmdline, struct meminfo *mi)
2997 {
2998         mi->nr_banks = 1;
2999         mi->bank[0].start = RK29_SDRAM_PHYS;
3000         mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
3001         mi->bank[0].size = LINUX_SIZE;
3002 }
3003
3004 static void __init machine_rk29_mapio(void)
3005 {
3006         rk29_map_common_io();
3007         rk29_setup_early_printk();
3008         rk29_sram_init();
3009         rk29_clock_init(periph_pll_288mhz);
3010         rk29_iomux_init();
3011         ddr_init(DDR_TYPE, DDR_FREQ);
3012 }
3013
3014 MACHINE_START(RK29, "RK29board")
3015         /* UART for LL DEBUG */
3016         .phys_io        = RK29_UART1_PHYS,
3017         .io_pg_offst    = ((RK29_UART1_BASE) >> 18) & 0xfffc,
3018         .boot_params    = RK29_SDRAM_PHYS + 0x88000,
3019         .fixup          = machine_rk29_fixup,
3020         .map_io         = machine_rk29_mapio,
3021         .init_irq       = machine_rk29_init_irq,
3022         .init_machine   = machine_rk29_board_init,
3023         .timer          = &rk29_timer,
3024 MACHINE_END