c68ecfecd5935aed1f4d183949cf6aff4deff8a4
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk29 / board-rk29-z5.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 #include <linux/mpu.h>
28 #include <linux/mpu3050.h>
29
30 #include <mach/hardware.h>
31 #include <asm/setup.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/flash.h>
36 #include <asm/hardware/gic.h>
37
38 #include <mach/iomux.h>
39 #include <mach/gpio.h>
40 #include <mach/irqs.h>
41 #include <mach/rk29_iomap.h>
42 #include <mach/board.h>
43 #include <mach/rk29_nand.h>
44 #include <mach/rk29_camera.h>                          /* ddl@rock-chips.com : camera support */
45 #include <media/soc_camera.h>                               /* ddl@rock-chips.com : camera support */
46 #include <mach/vpu_mem.h>
47 #include <mach/sram.h>
48 #include <mach/ddr.h>
49 #include <mach/cpufreq.h>
50
51 #include <linux/regulator/rk29-pwm-regulator.h>
52 #include <linux/regulator/machine.h>
53 #include <linux/mfd/wm831x/pdata.h>
54 #include <linux/mfd/wm831x/core.h>
55 #include <linux/mfd/wm831x/gpio.h>
56 #include <linux/mfd/wm8994/pdata.h>
57 #include <linux/mfd/wm8994/registers.h>
58
59 #include <linux/mtd/nand.h>
60 #include <linux/mtd/partitions.h>
61 #include <linux/i2c-gpio.h>
62
63 #include "devices.h"
64
65 #if defined(CONFIG_MTK23D)
66 #include <linux/mtk23d.h>
67 #endif
68
69 #include "../../../drivers/staging/android/timed_gpio.h"
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
80 #include "../../../drivers/misc/gps/rk29_gps.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_OV5640                      /* back camera sensor */
85 #define CONFIG_SENSOR_IIC_ADDR_0            0x78
86 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0    1
87 #define CONFIG_SENSOR_ORIENTATION_0       0
88 #define CONFIG_SENSOR_POWER_PIN_0         RK29_PIN5_PA0
89 #define CONFIG_SENSOR_RESET_PIN_0         INVALID_GPIO
90 #define CONFIG_SENSOR_POWERDN_PIN_0       RK29_PIN6_PB7
91 #define CONFIG_SENSOR_FALSH_PIN_0         RK29_PIN6_PB5
92 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_H
93 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
94 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
95 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_H
96
97 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV7690                      /* front camera sensor */
98 #define CONFIG_SENSOR_IIC_ADDR_1            0x42
99 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    1
100 #define CONFIG_SENSOR_ORIENTATION_1       0
101 #define CONFIG_SENSOR_POWER_PIN_1         RK29_PIN5_PA0
102 #define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
103 #define CONFIG_SENSOR_POWERDN_PIN_1       RK29_PIN6_PB6
104 #define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
105 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_H
106 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
107 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
108 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
109 #endif  //#ifdef CONFIG_VIDEO_RK29
110 /*---------------- Camera Sensor Configuration Macro End------------------------*/
111 #include "../../../drivers/media/video/rk29_camera.c"
112 /*---------------- Camera Sensor Macro Define End  ------------------------*/
113
114
115 /* Set memory size of pmem */
116 #ifdef CONFIG_RK29_MEM_SIZE_M
117 #define SDRAM_SIZE          (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
118 #else
119 #define SDRAM_SIZE          SZ_512M
120 #endif
121 #define PMEM_GPU_SIZE       SZ_16M
122 #define PMEM_UI_SIZE        SZ_32M /* 1280x800: 64M 1024x768: 48M ... */
123 #define PMEM_VPU_SIZE       SZ_64M
124 #define PMEM_CAM_SIZE       PMEM_CAM_NECESSARY
125 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
126 #define MEM_CAMIPP_SIZE     PMEM_CAMIPP_NECESSARY
127 #else
128 #define MEM_CAMIPP_SIZE     0
129 #endif
130 #define MEM_FB_SIZE         (3*SZ_2M)
131 #ifdef CONFIG_FB_WORK_IPP
132 #define MEM_FBIPP_SIZE      SZ_2M//SZ_8M   //1920 x 1080 x 2 x 2  //RGB565 = x2;RGB888 = x4
133 #else
134 #define MEM_FBIPP_SIZE      0
135 #endif
136 #if SDRAM_SIZE > SZ_512M
137 #define PMEM_GPU_BASE       (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
138 #else
139 #define PMEM_GPU_BASE       (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
140 #endif
141 #define PMEM_UI_BASE        (PMEM_GPU_BASE - PMEM_UI_SIZE)
142 #define PMEM_VPU_BASE       (PMEM_UI_BASE - PMEM_VPU_SIZE)
143 #define PMEM_CAM_BASE       (PMEM_VPU_BASE - PMEM_CAM_SIZE)
144 #define MEM_CAMIPP_BASE     (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
145 #define MEM_FB_BASE         (MEM_CAMIPP_BASE - MEM_FB_SIZE)
146 #define MEM_FBIPP_BASE      (MEM_FB_BASE - MEM_FBIPP_SIZE)
147 #define LINUX_SIZE          (MEM_FBIPP_BASE - RK29_SDRAM_PHYS)
148
149 #define PREALLOC_WLAN_SEC_NUM           4
150 #define PREALLOC_WLAN_BUF_NUM           160
151 #define PREALLOC_WLAN_SECTION_HEADER    24
152
153 #define WLAN_SECTION_SIZE_0     (PREALLOC_WLAN_BUF_NUM * 128)
154 #define WLAN_SECTION_SIZE_1     (PREALLOC_WLAN_BUF_NUM * 128)
155 #define WLAN_SECTION_SIZE_2     (PREALLOC_WLAN_BUF_NUM * 512)
156 #define WLAN_SECTION_SIZE_3     (PREALLOC_WLAN_BUF_NUM * 1024)
157
158 #define WLAN_SKB_BUF_NUM        16
159 #define UNLOCK_SECURITY_KEY     ~(0x1<<5)
160 #define LOCK_SECURITY_KEY       0x00
161
162 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
163
164 struct wifi_mem_prealloc {
165         void *mem_ptr;
166         unsigned long size;
167 };
168
169 extern struct sys_timer rk29_timer;
170
171 static int rk29_nand_io_init(void)
172 {
173     return 0;
174 }
175
176 struct rk29_nand_platform_data rk29_nand_data = {
177     .width      = 1,     /* data bus width in bytes */
178     .hw_ecc     = 1,     /* hw ecc 0: soft ecc */
179     .num_flash    = 1,
180     .io_init   = rk29_nand_io_init,
181 };
182
183 #ifdef CONFIG_FB_RK29
184 /*****************************************************************************************
185  * lcd  devices
186  * author: zyw@rock-chips.com
187  *****************************************************************************************/
188 //#ifdef  CONFIG_LCD_TD043MGEA1
189 #define LCD_RXD_PIN          RK29_PIN4_PC3
190 #define LCD_TXD_PIN          RK29_PIN4_PC7
191 #define LCD_CLK_PIN          RK29_PIN4_PC6
192 #define LCD_CS_PIN           RK29_PIN4_PC2
193 /*****************************************************************************************
194 * frame buffer  devices
195 * author: zyw@rock-chips.com
196 *****************************************************************************************/
197 #define FB_ID                       0
198 #define FB_DISPLAY_ON_PIN           INVALID_GPIO//RK29_PIN6_PD0
199 #define FB_LCD_STANDBY_PIN          INVALID_GPIO//RK29_PIN6_PD1
200 #define FB_LCD_CABC_EN_PIN          INVALID_GPIO//RK29_PIN6_PD2
201 #define FB_MCU_FMK_PIN              INVALID_GPIO
202
203 #define FB_DISPLAY_ON_VALUE         GPIO_HIGH
204 #define FB_LCD_STANDBY_VALUE        GPIO_HIGH
205
206 //#endif
207 static int rk29_lcd_io_init(void)
208 {
209         int ret = 0;
210
211         ret = gpio_request(LCD_TXD_PIN, NULL);
212         ret = gpio_request(LCD_CLK_PIN, NULL);
213         ret = gpio_request(LCD_CS_PIN, NULL);
214         ret = gpio_request(RK29_PIN6_PC6, NULL);
215
216         ret = gpio_request(RK29_PIN4_PC1, NULL);//RS
217         gpio_direction_output(RK29_PIN4_PC1, 0);
218         gpio_set_value(RK29_PIN4_PC1, GPIO_HIGH);       
219                 
220         rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME,GPIO4H_GPIO4C7);
221         rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME,GPIO4H_GPIO4C6);
222         rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME,GPIO4H_GPIO4C2);
223         rk29_mux_api_set(GPIO4C1_RMIITXEN_MIITXEN_NAME,GPIO4H_GPIO4C1);
224         
225     return ret;
226 }
227
228 static int rk29_lcd_io_deinit(void)
229 {
230         int ret = 0;
231         gpio_free(LCD_CS_PIN);
232         gpio_free(LCD_CLK_PIN);
233         gpio_free(LCD_TXD_PIN);
234         gpio_free(RK29_PIN6_PC6);
235         gpio_free(RK29_PIN4_PC1);
236         rk29_mux_api_set(GPIO4C7_RMIIRXD0_MIIRXD0_NAME,GPIO4H_RMII_RXD0);
237         rk29_mux_api_set(GPIO4C6_RMIIRXD1_MIIRXD1_NAME,GPIO4H_RMII_RXD1);
238         rk29_mux_api_set(GPIO4C2_RMIITXD1_MIITXD1_NAME,GPIO4H_RMII_TXD1);
239         return ret;
240 }
241
242 static struct rk29lcd_info rk29_lcd_info = {
243     .txd_pin  = LCD_TXD_PIN,
244     .clk_pin = LCD_CLK_PIN,
245     .cs_pin = LCD_CS_PIN,
246     .io_init   = rk29_lcd_io_init,
247     .io_deinit = rk29_lcd_io_deinit,
248 };
249
250 int rk29_fb_io_enable(void)
251 {
252     if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
253     {
254         gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
255         gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);              
256     }
257     if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
258     {
259         gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
260         gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);             
261     }
262     return 0;
263 }
264
265 int rk29_fb_io_disable(void)
266 {
267     if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
268     {
269         gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
270         gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);              
271     }
272     if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
273     {
274         gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
275         gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);             
276     }
277     return 0;
278 }
279
280 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
281 {
282     int ret = 0;
283     if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
284     {
285         ret = gpio_request(FB_MCU_FMK_PIN, NULL);
286         if(ret != 0)
287         {
288             gpio_free(FB_MCU_FMK_PIN);
289             printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
290         }
291         gpio_direction_input(FB_MCU_FMK_PIN);
292     }
293     if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
294     {
295         ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
296         if(ret != 0)
297         {
298             gpio_free(FB_DISPLAY_ON_PIN);
299             printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
300         }
301     }
302
303     if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
304     {
305         ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
306         if(ret != 0)
307         {
308             gpio_free(FB_LCD_STANDBY_PIN);
309             printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
310         }
311     }
312
313     if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
314     {
315         ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
316         if(ret != 0)
317         {
318             gpio_free(FB_LCD_CABC_EN_PIN);
319             printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
320         }
321         gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
322         gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
323     }
324     rk29_fb_io_enable();   //enable it
325
326     return ret;
327 }
328
329 static struct rk29fb_info rk29_fb_info = {
330     .fb_id   = FB_ID,
331     .mcu_fmk_pin = FB_MCU_FMK_PIN,
332     .lcd_info = &rk29_lcd_info,
333     .io_init   = rk29_fb_io_init,
334     .io_enable = rk29_fb_io_enable,
335     .io_disable = rk29_fb_io_disable,
336 };
337
338 /* rk29 fb resource */
339 static struct resource rk29_fb_resource[] = {
340         [0] = {
341         .name  = "lcdc reg",
342                 .start = RK29_LCDC_PHYS,
343                 .end   = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
344                 .flags = IORESOURCE_MEM,
345         },
346         [1] = {
347             .name  = "lcdc irq",
348                 .start = IRQ_LCDC,
349                 .end   = IRQ_LCDC,
350                 .flags = IORESOURCE_IRQ,
351         },
352         [2] = {
353             .name   = "win1 buf",
354         .start  = MEM_FB_BASE,
355         .end    = MEM_FB_BASE + MEM_FB_SIZE - 1,
356         .flags  = IORESOURCE_MEM,
357     },
358     #ifdef CONFIG_FB_WORK_IPP
359     [3] = {
360             .name   = "win1 ipp buf",
361         .start  = MEM_FBIPP_BASE,
362         .end    = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
363         .flags  = IORESOURCE_MEM,
364     },
365     #endif
366 };
367
368 /*platform_device*/
369 struct platform_device rk29_device_fb = {
370         .name             = "rk29-fb",
371         .id               = 4,
372         .num_resources    = ARRAY_SIZE(rk29_fb_resource),
373         .resource         = rk29_fb_resource,
374         .dev            = {
375                 .platform_data  = &rk29_fb_info,
376         }
377 };
378
379 struct platform_device rk29_device_dma_cpy = {
380         .name             = "dma_memcpy",
381         .id               = 4,
382
383 };
384
385 #endif
386
387 static struct android_pmem_platform_data android_pmem_pdata = {
388         .name           = "pmem",
389         .start          = PMEM_UI_BASE,
390         .size           = PMEM_UI_SIZE,
391         .no_allocator   = 1,
392         .cached         = 1,
393 };
394
395 static struct platform_device android_pmem_device = {
396         .name           = "android_pmem",
397         .id             = 0,
398         .dev            = {
399                 .platform_data = &android_pmem_pdata,
400         },
401 };
402
403
404
405 static struct vpu_mem_platform_data vpu_mem_pdata = {
406         .name           = "vpu_mem",
407         .start          = PMEM_VPU_BASE,
408         .size           = PMEM_VPU_SIZE,
409         .cached         = 1,
410 };
411
412 static struct platform_device rk29_vpu_mem_device = {
413         .name           = "vpu_mem",
414         .id                 = 2,
415         .dev            = {
416         .platform_data = &vpu_mem_pdata,
417         },
418 };
419
420 static struct platform_device rk29_v4l2_output_devce = {
421         .name           = "rk29_vout",
422 };
423
424 /*HANNSTAR_P1003 touch*/
425 #if defined (CONFIG_HANNSTAR_P1003)
426 #define TOUCH_RESET_PIN RK29_PIN6_PC3
427 #define TOUCH_INT_PIN   RK29_PIN4_PD5
428
429 int p1003_init_platform_hw(void)
430 {
431     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
432       gpio_free(TOUCH_RESET_PIN);
433       printk("p1003_init_platform_hw gpio_request error\n");
434       return -EIO;
435     }
436
437     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
438       gpio_free(TOUCH_INT_PIN);
439       printk("p1003_init_platform_hw gpio_request error\n");
440       return -EIO;
441     }
442     gpio_pull_updown(TOUCH_INT_PIN, 1);
443     gpio_direction_output(TOUCH_RESET_PIN, 0);
444     msleep(500);
445     gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
446     msleep(500);
447     gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
448
449     return 0;
450 }
451
452
453 struct p1003_platform_data p1003_info = {
454   .model= 1003,
455   .init_platform_hw= p1003_init_platform_hw,
456
457 };
458 #endif
459
460 #if defined (CONFIG_TOUCHSCREEN_GT801_IIC)
461 #include "../../../drivers/input/touchscreen/gt801_ts.h"
462
463 #define TOUCH_RESET_PIN  RK29_PIN6_PC3
464 #define TOUCH_INT_PIN    RK29_PIN4_PD5
465
466 int gt801_init_platform_hw(void)
467 {
468     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
469       gpio_free(TOUCH_RESET_PIN);
470       printk("gt801_init_platform_hw gpio_request error\n");
471       return -EIO;
472     }
473
474     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
475       gpio_free(TOUCH_INT_PIN);
476       printk("gt801_init_platform_hw gpio_request error\n");
477       return -EIO;
478     }
479     gpio_pull_updown(TOUCH_INT_PIN, 1);
480     gpio_direction_output(TOUCH_RESET_PIN, 0);
481     msleep(500);
482     gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
483     msleep(500);
484     gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
485         mdelay(100);
486
487     return 0;
488 }
489
490
491 static struct gt801_platform_data gt801_info = {
492   .model= 801,
493   .gpio_reset = TOUCH_RESET_PIN,
494   .init_platform_hw = gt801_init_platform_hw,
495 };
496 #endif
497
498 #if defined(CONFIG_TOUCHSCREEN_GT801_Z5)
499 #include "../../../drivers/input/touchscreen/gt801_z5_ts.h"
500 #define TOUCH_RESET_PIN  RK29_PIN6_PC3
501 #define TOUCH_INT_PIN    RK29_PIN4_PD5
502
503 int gt801_init_platform_hw(void)
504 {
505         if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
506           gpio_free(TOUCH_RESET_PIN);
507           printk("gt801_init_platform_hw gpio_request error\n");
508           return -EIO;
509         }
510
511         if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
512           gpio_free(TOUCH_INT_PIN);
513           printk("gt801_init_platform_hw gpio_request error\n");
514           return -EIO;
515         }
516         gpio_pull_updown(TOUCH_INT_PIN, 1);
517         gpio_direction_output(TOUCH_RESET_PIN, 0);
518         msleep(500);
519         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
520         msleep(500);
521         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
522         mdelay(100);
523         return 0;
524 }
525
526
527 static struct gt801_platform_data gt801_info = {
528   .model= 801,
529   .gpio_reset = TOUCH_RESET_PIN,
530   .init_platform_hw= gt801_init_platform_hw,
531 };
532 #endif 
533
534 #if defined(CONFIG_TOUCHSCREEN_GT818_IIC)
535 #include "../../../drivers/input/touchscreen/gt818_ts.h"
536 #define GT818_GPIO_INT      RK29_PIN4_PD5
537 #define GT818_GPIO_RESET    RK29_PIN6_PC3
538 static struct gt818_platform_data gt818_info = {
539         .model                  = 818,
540         .swap_xy                = 0,
541         .x_min                  = 0,
542         .x_max                  = 480,
543         .y_min                  = 0,
544         .y_max                  = 800,
545         .gpio_reset     = GT818_GPIO_RESET,
546         .gpio_reset_active_low = 0,
547         .gpio_pendown           = GT818_GPIO_INT,
548     .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
549     .resetpin_iomux_name = NULL,
550     .pendown_iomux_mode = GPIO4H_GPIO4D5,
551     .resetpin_iomux_mode = 0,
552 };
553 #endif
554
555 #if defined(CONFIG_TOUCHSCREEN_FT5X0X_Z5) || defined (CONFIG_TOUCHSCREEN_FT5306)
556
557 #define TOUCH_RESET_PIN RK29_PIN6_PC3
558 #define TOUCH_INT_PIN   RK29_PIN4_PD5
559 int ft5406_init_platform_hw(void)
560 {
561     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
562       gpio_free(TOUCH_RESET_PIN);
563       printk("ft5406_init_platform_hw gpio_request error\n");
564       return -EIO;
565     }
566
567     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
568       gpio_free(TOUCH_INT_PIN);
569       printk("ift5406_init_platform_hw gpio_request error\n");
570       return -EIO;
571     }
572         gpio_pull_updown(TOUCH_INT_PIN, 0);
573         gpio_direction_output(TOUCH_RESET_PIN, GPIO_HIGH); 
574         msleep(5);
575         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
576         mdelay(5);
577         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
578     return 0;
579 }
580
581 void ft5406_exit_platform_hw(void)
582 {
583         printk("ft5406_exit_platform_hw\n");
584         gpio_free(TOUCH_RESET_PIN);
585         gpio_free(TOUCH_INT_PIN);
586 }
587
588 int ft5406_platform_sleep(void)
589 {
590         //printk("ft5406_platform_sleep\n");
591         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
592         return 0;
593 }
594
595 int ft5406_platform_wakeup(void)
596 {
597         //printk("ft5406_platform_wakeup\n");
598         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
599         return 0;
600 }
601
602 struct ft5406_platform_data ft5406_info = {
603
604   .init_platform_hw= ft5406_init_platform_hw,
605   .exit_platform_hw= ft5406_exit_platform_hw,
606   .platform_sleep  = ft5406_platform_sleep,
607   .platform_wakeup = ft5406_platform_wakeup,
608 };
609
610 #endif
611
612 #if defined(CONFIG_TOUCHSCREEN_ILI2102_IIC) 
613 #include "../../../drivers/input/touchscreen/ili2102_ts.h"
614 #define GT801_GPIO_INT      RK29_PIN4_PD5
615 #define GT801_GPIO_RESET    RK29_PIN6_PC3
616 static struct ili2102_platform_data ili2102_info = {
617         .model                  = 2102,
618         .swap_xy                = 0,
619         .x_min                  = 0,
620         .x_max                  = 481,
621         .y_min                  = 0,
622         .y_max                  = 801,
623         .gpio_reset     = GT801_GPIO_RESET,
624         .gpio_reset_active_low = 1,
625         .gpio_pendown           = GT801_GPIO_INT,
626     .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
627     .resetpin_iomux_name = NULL,
628     .pendown_iomux_mode = GPIO4H_GPIO4D5,
629     .resetpin_iomux_mode = 0,
630 };
631 #endif
632
633 /* EETI_EGALAX touch I2C */
634 #if defined (CONFIG_EETI_EGALAX)
635 #define TOUCH_RESET_PIN RK29_PIN6_PC3
636 #define TOUCH_INT_PIN   RK29_PIN4_PD5
637
638 static int EETI_EGALAX_init_platform_hw(void)
639 {
640     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
641       gpio_free(TOUCH_RESET_PIN);
642       printk("p1003_init_platform_hw gpio_request error\n");
643       return -EIO;
644     }
645
646     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
647       gpio_free(TOUCH_INT_PIN);
648       printk("p1003_init_platform_hw gpio_request error\n");
649       return -EIO;
650     }
651     gpio_pull_updown(TOUCH_INT_PIN, 1);
652     gpio_direction_output(TOUCH_RESET_PIN, 0);
653     msleep(500);
654     gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
655     msleep(500);
656     gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
657
658     return 0;
659 }
660
661
662 static struct eeti_egalax_platform_data eeti_egalax_info = {
663   .model= 1003,
664   .init_platform_hw= EETI_EGALAX_init_platform_hw,
665
666 };
667 #endif
668
669 /*MMA8452 gsensor*/
670 #if defined (CONFIG_GS_MMA8452)
671 #define MMA8452_INT_PIN   RK29_PIN6_PC4
672
673 static int mma8452_init_platform_hw(void)
674 {
675
676     if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
677       gpio_free(MMA8452_INT_PIN);
678       printk("mma8452_init_platform_hw gpio_request error\n");
679       return -EIO;
680     }
681     gpio_pull_updown(MMA8452_INT_PIN, 1);
682     return 0;
683 }
684
685
686 static struct mma8452_platform_data mma8452_info = {
687   .model= 8452,
688   .swap_xy = 0,
689   .init_platform_hw= mma8452_init_platform_hw,
690
691 };
692 #endif
693
694 #if defined (CONFIG_MPU_SENSORS_MPU3050)
695 /*mpu3050*/
696 static struct mpu3050_platform_data mpu3050_data = {
697                 .int_config = 0x10,
698                 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
699                 .orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
700                 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
701                 //.orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
702                 //.orientation = { 1, 0, 0,0, 1, 0, 0, 0, 1 },
703                 .level_shifter = 0,
704 #if defined (CONFIG_MPU_SENSORS_KXTF9)
705                 .accel = {
706 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
707                                 .get_slave_descr = NULL ,
708 #else
709                                 .get_slave_descr = get_accel_slave_descr ,                      
710 #endif
711                                 .adapt_num = 0, // The i2c bus to which the mpu device is
712                                 // connected
713                                 //.irq = RK29_PIN6_PC4,
714                                 .bus = EXT_SLAVE_BUS_SECONDARY,  //The secondary I2C of MPU
715                                 .address = 0x0f,
716                                 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
717                                 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
718                                 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
719                                 //.orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
720                                 .orientation = {1, 0, 0, 0, 1, 0, 0, 0, 1},
721                 },
722 #endif
723
724 #if defined (CONFIG_MPU_SENSORS_MMA845X)
725                 .accel = {
726 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
727                                 .get_slave_descr = NULL ,
728 #else
729                                 .get_slave_descr = get_accel_slave_descr ,                      
730 #endif
731                                 .adapt_num = 0, // The i2c bus to which the mpu device is
732                                 // connected
733                                 //.irq = RK29_PIN6_PC4,
734                                 .bus = EXT_SLAVE_BUS_SECONDARY,  //The secondary I2C of MPU
735                                 .address = 0x1c,
736                                 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
737                                 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
738                                 .orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
739                                 //.orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
740                 },
741 #endif
742
743 #if defined (CONFIG_MPU_SENSORS_AK8975)
744                 .compass = {
745 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
746                                 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
747 #else
748                                 .get_slave_descr = get_compass_slave_descr,
749 #endif                                          
750                                 .adapt_num = 0, // The i2c bus to which the compass device is. 
751                                 // It can be difference with mpu
752                                 // connected
753                                 //.irq = RK29_PIN6_PC5,
754                                 .bus = EXT_SLAVE_BUS_PRIMARY,
755                                 .address = 0x0d,
756                                 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
757                                 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },  
758                                 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },   
759                                 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
760                                 //.orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
761                                 .orientation = { 1, 0 ,0, 0 ,-1, 0, 0, 0, -1 },
762                 },
763 };
764 #endif
765 #endif
766
767 #if defined(CONFIG_GPIO_WM831X)
768 struct rk29_gpio_expander_info  wm831x_gpio_settinginfo[] = {
769         {
770                 .gpio_num               =WM831X_P01,// tp3
771                 .pin_type           = GPIO_OUT,
772                 .pin_value                      =GPIO_HIGH,
773          },
774          
775          {
776                 .gpio_num               =WM831X_P02,//tp4
777                 .pin_type           = GPIO_OUT,
778                 .pin_value                      =GPIO_HIGH,
779          },
780          {
781                 .gpio_num               =WM831X_P03,//tp2
782                 .pin_type           = GPIO_OUT,
783                 .pin_value                      =GPIO_HIGH,
784          },
785          {
786                 .gpio_num               =WM831X_P04,//tp1
787                 .pin_type           = GPIO_OUT,
788                 .pin_value                      =GPIO_HIGH,
789          },
790          {
791                 .gpio_num               =WM831X_P05,//tp1
792                 .pin_type           = GPIO_OUT,
793                 .pin_value                      =GPIO_HIGH,
794          },
795          {
796                 .gpio_num               =WM831X_P06,//tp1
797                 .pin_type           = GPIO_OUT,
798                 .pin_value                      =GPIO_HIGH,
799          },
800          {
801                 .gpio_num               =WM831X_P07,//tp1
802                 .pin_type           = GPIO_OUT,
803                 .pin_value                      =GPIO_HIGH,
804          },
805          {
806                 .gpio_num               =WM831X_P08,//tp1
807                 .pin_type           = GPIO_OUT,
808                 .pin_value                      =GPIO_HIGH,
809          },
810          {
811                 .gpio_num               =WM831X_P09,//tp1
812                 .pin_type           = GPIO_OUT,
813                 .pin_value                      =GPIO_HIGH,
814          },
815          {
816                 .gpio_num               =WM831X_P10,//tp1
817                 .pin_type           = GPIO_OUT,
818                 .pin_value                      =GPIO_HIGH,
819          },
820          {
821                 .gpio_num               =WM831X_P11,//tp1
822                 .pin_type           = GPIO_OUT,
823                 .pin_value                      =GPIO_HIGH,
824          },     
825          {
826                 .gpio_num               =WM831X_P12,
827                 .pin_type           = GPIO_OUT,
828                 .pin_value                      =GPIO_HIGH,
829          },
830 };
831
832 #endif
833
834
835
836 #if defined(CONFIG_MFD_WM831X)
837 static struct wm831x *gWm831x;
838 int wm831x_pre_init(struct wm831x *parm)
839 {
840         int ret;
841         printk("%s\n", __FUNCTION__);
842         gWm831x = parm;
843         //ILIM = 900ma
844         ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
845         wm831x_reg_write(parm, WM831X_POWER_STATE, (ret&0xfff8) | 0x04);        
846         
847         //BATT_FET_ENA = 1
848     wm831x_reg_write(parm,WM831X_SECURITY_KEY,0x9716); // unlock security key
849     wm831x_set_bits(parm, WM831X_RESET_CONTROL,0x1000,0x1000);
850     ret = wm831x_reg_read(parm, WM831X_RESET_CONTROL) & 0xffff&UNLOCK_SECURITY_KEY;// enternal reset active in sleep
851     printk("%s:WM831X_RESET_CONTROL=0x%x\n",__FUNCTION__,ret);
852     wm831x_reg_write(parm, WM831X_RESET_CONTROL, ret);
853         
854         
855     wm831x_reg_write(parm,WM831X_SECURITY_KEY,LOCK_SECURITY_KEY); // lock security key 
856        
857         
858 #if 0
859         wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 3), 0);
860         wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 7), 0);
861         printk("%s:disable ldo4 and ldo8 because they are enabled in uboot\n",__FUNCTION__);
862 #endif  
863         return 0;
864 }
865 int wm831x_post_init(struct wm831x *parm)
866 {
867         struct regulator *dcdc;
868         struct regulator *ldo;
869         
870
871         dcdc = regulator_get(NULL, "dcdc3");            // 1th IO
872         regulator_set_voltage(dcdc,3000000,3000000);
873         regulator_set_suspend_voltage(dcdc, 2800000);
874         regulator_enable(dcdc);                 
875         printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
876         regulator_put(dcdc);
877         udelay(100);
878         
879         ldo = regulator_get(NULL, "ldo10");     // 1th modem IO
880         regulator_set_voltage(ldo,3000000,3000000);
881         regulator_set_suspend_voltage(ldo,3000000);
882         regulator_enable(ldo);                  
883         printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
884         regulator_put(ldo);
885         udelay(100);
886         
887         dcdc = regulator_get(NULL, "dcdc2");    // 2th CORE
888         regulator_set_voltage(dcdc,1300000,1300000);
889         regulator_set_suspend_voltage(dcdc,1000000);
890         regulator_enable(dcdc);                         
891         printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
892         regulator_put(dcdc);
893         udelay(100);
894         
895         dcdc = regulator_get(NULL, "dcdc1");    // 3th ddr
896         regulator_set_voltage(dcdc,1800000,1800000);
897         regulator_set_suspend_voltage(dcdc,1800000);
898         regulator_enable(dcdc);
899         printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));   
900         regulator_put(dcdc);
901         udelay(100);
902         
903         ldo = regulator_get(NULL, "ldo1");              // 3th nand
904         regulator_set_voltage(ldo,1800000,1800000);
905         regulator_set_suspend_voltage(ldo,1800000);
906         regulator_enable(ldo);                  
907         printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));             
908         regulator_put(ldo);
909         udelay(100);
910         
911         ldo = regulator_get(NULL, "ldo4");              // 4th usb
912         regulator_set_voltage(ldo,2500000,2500000);
913         regulator_set_suspend_voltage(ldo,0000000);
914         regulator_enable(ldo);  
915         printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
916         regulator_put(ldo);
917         udelay(100);
918         
919         ldo = regulator_get(NULL, "ldo7");              // 5th usb
920         regulator_set_voltage(ldo,3300000,3300000);
921         regulator_set_suspend_voltage(ldo,3300000);
922         regulator_enable(ldo);                  
923         printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
924         regulator_put(ldo);
925         udelay(100);
926         
927         dcdc = regulator_get(NULL, "dcdc4");    // backlight
928         regulator_set_voltage(dcdc,20000000,16000000);
929         regulator_set_suspend_voltage(dcdc, 16000000);
930         regulator_enable(dcdc); 
931         printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
932         regulator_put(dcdc);
933         udelay(100);
934 #if 1
935         
936         ldo = regulator_get(NULL, "ldo2");              //lcd
937         regulator_set_voltage(ldo,3000000,3000000);
938         regulator_set_suspend_voltage(ldo,3000000);
939         regulator_enable(ldo);                  
940         printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
941         regulator_put(ldo);
942
943
944         ldo = regulator_get(NULL, "ldo5");              //tf
945         regulator_set_voltage(ldo,3000000,3000000);
946         regulator_set_suspend_voltage(ldo,3000000);
947         regulator_enable(ldo);                  
948         printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
949         regulator_put(ldo);
950
951         ldo = regulator_get(NULL, "ldo6");              //camera
952         regulator_set_voltage(ldo,2800000,2800000);
953         regulator_set_suspend_voltage(ldo,2800000);
954         regulator_enable(ldo);                  
955         printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
956         regulator_put(ldo);
957
958
959
960 #if 1
961 #if 0
962         ldo = regulator_get(NULL, "ldo3");              //sram
963         regulator_set_voltage(ldo,1800000,1800000);
964         regulator_set_suspend_voltage(ldo,1800000);
965         regulator_enable(ldo);                  
966         printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
967         regulator_put(ldo);     
968 #endif
969
970         ldo = regulator_get(NULL, "ldo8");              //cmmb
971         regulator_set_voltage(ldo,1200000,1200000);
972         regulator_set_suspend_voltage(ldo,1200000);
973         regulator_enable(ldo);                  
974         printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
975         regulator_put(ldo);
976
977         ldo = regulator_get(NULL, "ldo9");              //cmmb
978         regulator_set_voltage(ldo,3000000,3000000);
979         regulator_set_suspend_voltage(ldo,3000000);
980         regulator_enable(ldo);                  
981         printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
982         regulator_put(ldo);
983 #endif
984
985 #endif
986         
987         ldo = regulator_get(NULL, "ldo11");
988         //regulator_enable(ldo);                        
989         printk("%s set ldo11=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));    
990         regulator_put(ldo);     
991         
992                 
993         return 0;
994 }
995
996 extern void wm831x_enter_sleep(void);
997 extern void wm831x_exit_sleep(void);
998
999 void pmu_wm831x_set_suspend_voltage(void)
1000 {
1001
1002 }
1003 EXPORT_SYMBOL_GPL(pmu_wm831x_set_suspend_voltage);
1004
1005 void pmu_wm831x_set_resume_voltage(void)
1006 {
1007
1008 }
1009 EXPORT_SYMBOL_GPL(pmu_wm831x_set_resume_voltage);
1010
1011 int wm831x_last_deinit(struct wm831x *parm)
1012 {
1013         struct regulator* ldo;
1014
1015         printk("%s\n", __FUNCTION__);
1016
1017         ldo = regulator_get(NULL, "ldo1");
1018         regulator_disable(ldo);                 
1019         regulator_put(ldo);
1020         
1021         ldo = regulator_get(NULL, "ldo2");
1022         regulator_disable(ldo);                 
1023         regulator_put(ldo);
1024         
1025         ldo = regulator_get(NULL, "ldo3");
1026         regulator_disable(ldo);                 
1027         regulator_put(ldo);
1028         
1029         ldo = regulator_get(NULL, "ldo4");
1030         //regulator_disable(ldo);       
1031         regulator_put(ldo);
1032
1033         ldo = regulator_get(NULL, "ldo5");
1034         regulator_disable(ldo);                 
1035         regulator_put(ldo);
1036
1037         ldo = regulator_get(NULL, "ldo6");
1038         regulator_disable(ldo);                 
1039         regulator_put(ldo);
1040
1041         ldo = regulator_get(NULL, "ldo7");
1042         regulator_disable(ldo);                 
1043         regulator_put(ldo);
1044
1045         ldo = regulator_get(NULL, "ldo8");
1046         //regulator_disable(ldo);                       
1047         regulator_put(ldo);
1048
1049         ldo = regulator_get(NULL, "ldo9");
1050         regulator_disable(ldo);                 
1051         regulator_put(ldo);
1052
1053         ldo = regulator_get(NULL, "ldo10");
1054         regulator_disable(ldo);                                         
1055         regulator_put(ldo);
1056
1057         return 0;
1058 }
1059
1060 struct wm831x_backlight_pdata wm831x_backlight_platdata = {
1061         .isink = 1,     /** ISINK to use, 1 or 2 */
1062         .max_uA = 19484,    /** Maximum current to allow */
1063 };
1064
1065 struct wm831x_backup_pdata wm831x_backup_platdata = {
1066         .charger_enable = 1,
1067         .no_constant_voltage = 0,  /** Disable constant voltage charging */
1068         .vlim = 3100,   /** Voltage limit in milivolts */
1069         .ilim = 300,   /** Current limit in microamps */
1070 };
1071
1072 struct wm831x_battery_pdata wm831x_battery_platdata = {
1073         .enable = 1,         /** Enable charging */
1074         .fast_enable = 1,    /** Enable fast charging */
1075         .off_mask = 1,       /** Mask OFF while charging */
1076         .trickle_ilim = 200,   /** Trickle charge current limit, in mA */
1077         .vsel = 4200,           /** Target voltage, in mV */
1078         .eoc_iterm = 50,      /** End of trickle charge current, in mA */
1079         .fast_ilim = 600,      /** Fast charge current limit, in mA */
1080         .timeout = 480,        /** Charge cycle timeout, in minutes */
1081         .syslo = 3300,    /* syslo threshold, in mV*/
1082         .sysok = 3500,    /* sysko threshold, in mV*/
1083 };
1084
1085 struct wm831x_status_pdata wm831x_status_platdata[WM831X_MAX_STATUS] = {
1086         {
1087         .default_src = WM831X_STATUS_OTP,
1088         .name = "wm831x_status0",
1089         .default_trigger = "wm831x_otp",
1090         },
1091         {
1092         .default_src = WM831X_STATUS_POWER,
1093         .name = "wm831x_status1",
1094         .default_trigger = "wm831x_power",
1095         },      
1096 };
1097
1098
1099 static struct regulator_consumer_supply dcdc1_consumers[] = {
1100         {
1101                 .supply = "dcdc1",
1102         }
1103 };
1104 static struct regulator_consumer_supply dcdc2_consumers[] = {
1105         {
1106                 .supply = "dcdc2",
1107         },
1108         {
1109                 .supply = "vcore",
1110         }
1111 };
1112 static struct regulator_consumer_supply dcdc3_consumers[] = {
1113         {
1114                 .supply = "dcdc3",
1115         }
1116 };
1117 static struct regulator_consumer_supply dcdc4_consumers[] = {
1118         {
1119                 .supply = "dcdc4",
1120         }
1121 };
1122 static struct regulator_consumer_supply epe1_consumers[] = {
1123         {
1124                 .supply = "epe1",
1125         }
1126 };
1127 static struct regulator_consumer_supply epe2_consumers[] = {
1128         {
1129                 .supply = "epe2",
1130         }
1131 };
1132 static struct regulator_consumer_supply ldo1_consumers[] = {
1133         {
1134                 .supply = "ldo1",
1135         }
1136 };
1137 static struct regulator_consumer_supply ldo2_consumers[] = {
1138         {
1139                 .supply = "ldo2",
1140         }
1141 };
1142 static struct regulator_consumer_supply ldo3_consumers[] = {
1143         {
1144                 .supply = "ldo3",
1145         }
1146 };
1147 static struct regulator_consumer_supply ldo4_consumers[] = {
1148         {
1149                 .supply = "ldo4",
1150         }
1151 };
1152 static struct regulator_consumer_supply ldo5_consumers[] = {
1153         {
1154                 .supply = "ldo5",
1155         }
1156 };
1157 static struct regulator_consumer_supply ldo6_consumers[] = {
1158         {
1159                 .supply = "ldo6",
1160         }
1161 };
1162 static struct regulator_consumer_supply ldo7_consumers[] = {
1163         {
1164                 .supply = "ldo7",
1165         }
1166 };
1167 static struct regulator_consumer_supply ldo8_consumers[] = {
1168         {
1169                 .supply = "ldo8",
1170         }
1171 };
1172 static struct regulator_consumer_supply ldo9_consumers[] = {
1173         {
1174                 .supply = "ldo9",
1175         }
1176 };
1177 static struct regulator_consumer_supply ldo10_consumers[] = {
1178         {
1179                 .supply = "ldo10",
1180         }
1181 };
1182 static struct regulator_consumer_supply ldo11_consumers[] = {
1183         {
1184                 .supply = "ldo11",
1185         }
1186 };
1187 static struct regulator_consumer_supply isink1_consumers[] = {
1188         {
1189                 .supply = "isink1",
1190         }
1191 };
1192 static struct regulator_consumer_supply isink2_consumers[] = {
1193         {
1194                 .supply = "isink2",
1195         }
1196 };
1197
1198 struct regulator_init_data wm831x_regulator_init_dcdc[WM831X_MAX_DCDC] = {
1199         {
1200                 .constraints = {
1201                         .name = "DCDC1",
1202                         .min_uV = 600000,
1203                         .max_uV = 1800000,//0.6-1.8V
1204                         .apply_uV = true,               
1205                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1206                 },
1207                 .num_consumer_supplies = ARRAY_SIZE(dcdc1_consumers),
1208                 .consumer_supplies = dcdc1_consumers,
1209         },
1210         {
1211                 .constraints = {
1212                         .name = "DCDC2",
1213                         .min_uV = 600000,
1214                         .max_uV = 1800000,//0.6-1.8V
1215                         .apply_uV = true,               
1216                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1217                 },
1218                 .num_consumer_supplies = ARRAY_SIZE(dcdc2_consumers),
1219                 .consumer_supplies = dcdc2_consumers,
1220         },
1221         {
1222                 .constraints = {
1223                         .name = "DCDC3",
1224                         .min_uV = 850000,
1225                         .max_uV = 3400000,//0.85-3.4V
1226                         .apply_uV = true,               
1227                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1228                 },
1229                 .num_consumer_supplies = ARRAY_SIZE(dcdc3_consumers),
1230                 .consumer_supplies = dcdc3_consumers,
1231         },
1232         {
1233                 .constraints = {
1234                         .name = "DCDC4",
1235                         .min_uV = 00000000,
1236                         .max_uV = 30000000,//30V/40mA
1237                         .apply_uV = true,               
1238                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1239                 },
1240                 .num_consumer_supplies = ARRAY_SIZE(dcdc4_consumers),
1241                 .consumer_supplies = dcdc4_consumers,
1242         },
1243         
1244 };
1245 struct regulator_init_data wm831x_regulator_init_epe[WM831X_MAX_EPE] = {
1246         {
1247                 .constraints = {
1248                         .name = "EPE1",
1249                         .min_uV = 1200000,
1250                         .max_uV = 3000000,
1251                         .apply_uV = true,               
1252                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1253                 },
1254                 .num_consumer_supplies = ARRAY_SIZE(epe1_consumers),
1255                 .consumer_supplies = epe1_consumers,
1256         },
1257         {
1258                 .constraints = {
1259                         .name = "EPE2",
1260                         .min_uV = 1200000,
1261                         .max_uV = 3000000,
1262                         .apply_uV = true,               
1263                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1264                 },
1265                 .num_consumer_supplies = ARRAY_SIZE(epe2_consumers),
1266                 .consumer_supplies = epe2_consumers,
1267         },
1268 };
1269
1270 struct regulator_init_data wm831x_regulator_init_ldo[WM831X_MAX_LDO] = {
1271         {
1272                 .constraints = {
1273                         .name = "LDO1",
1274                         .min_uV = 900000,
1275                         .max_uV = 3300000,
1276                         .apply_uV = true,               
1277                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1278                 },
1279                 .num_consumer_supplies = ARRAY_SIZE(ldo1_consumers),
1280                 .consumer_supplies = ldo1_consumers,
1281         },
1282         {
1283                 .constraints = {
1284                         .name = "LDO2",
1285                         .min_uV = 900000,
1286                         .max_uV = 3300000,
1287                         .apply_uV = true,               
1288                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1289                 },
1290                 .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
1291                 .consumer_supplies = ldo2_consumers,
1292         },
1293         {
1294                 .constraints = {
1295                         .name = "LDO3",
1296                         .min_uV = 900000,
1297                         .max_uV = 3300000,
1298                         .apply_uV = true,               
1299                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1300                 },
1301                 .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
1302                 .consumer_supplies = ldo3_consumers,
1303         },
1304         {
1305                 .constraints = {
1306                         .name = "LDO4",
1307                         .min_uV = 900000,
1308                         .max_uV = 3300000,
1309                         .apply_uV = true,               
1310                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1311                 },
1312                 .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
1313                 .consumer_supplies = ldo4_consumers,
1314         },
1315         {
1316                 .constraints = {
1317                         .name = "LDO5",
1318                         .min_uV = 900000,
1319                         .max_uV = 3300000,
1320                         .apply_uV = true,               
1321                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1322                 },
1323                 .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
1324                 .consumer_supplies = ldo5_consumers,
1325         },
1326         {
1327                 .constraints = {
1328                         .name = "LDO6",
1329                         .min_uV = 900000,
1330                         .max_uV = 3300000,
1331                         .apply_uV = true,               
1332                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1333                 },
1334                 .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers),
1335                 .consumer_supplies = ldo6_consumers,
1336         },
1337         {
1338                 .constraints = {
1339                         .name = "LDO7",
1340                         .min_uV = 1000000,
1341                         .max_uV = 3500000,
1342                         .apply_uV = true,               
1343                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1344                 },
1345                 .num_consumer_supplies = ARRAY_SIZE(ldo7_consumers),
1346                 .consumer_supplies = ldo7_consumers,
1347         },
1348         {
1349                 .constraints = {
1350                         .name = "LDO8",
1351                         .min_uV = 1000000,
1352                         .max_uV = 3500000,
1353                         .apply_uV = true,               
1354                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1355                 },
1356                 .num_consumer_supplies = ARRAY_SIZE(ldo8_consumers),
1357                 .consumer_supplies = ldo8_consumers,
1358         },
1359         {
1360                 .constraints = {
1361                         .name = "LDO9",
1362                         .min_uV = 1000000,
1363                         .max_uV = 3500000,
1364                         .apply_uV = true,               
1365                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1366                 },
1367                 .num_consumer_supplies = ARRAY_SIZE(ldo9_consumers),
1368                 .consumer_supplies = ldo9_consumers,
1369         },
1370         {
1371                 .constraints = {
1372                         .name = "LDO10",
1373                         .min_uV = 1000000,
1374                         .max_uV = 3500000,
1375                         .apply_uV = true,               
1376                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1377                 },
1378                 .num_consumer_supplies = ARRAY_SIZE(ldo10_consumers),
1379                 .consumer_supplies = ldo10_consumers,
1380         },
1381         {
1382                 .constraints = {
1383                         .name = "LDO11",
1384                         .min_uV = 1200000,
1385                         .max_uV = 3000000,
1386                         .apply_uV = true,               
1387                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,           
1388                 },
1389                 .num_consumer_supplies = ARRAY_SIZE(ldo11_consumers),
1390                 .consumer_supplies = ldo11_consumers,
1391         },
1392 };
1393
1394 struct regulator_init_data wm831x_regulator_init_isink[WM831X_MAX_ISINK] = {
1395         {
1396                 .constraints = {
1397                         .name = "ISINK1",
1398                         .min_uA = 00000,
1399                         .max_uA = 40000,
1400                         .always_on = true,
1401                         .apply_uV = true,               
1402                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,           
1403                 },
1404                 .num_consumer_supplies = ARRAY_SIZE(isink1_consumers),
1405                 .consumer_supplies = isink1_consumers,
1406         },
1407         {
1408                 .constraints = {
1409                         .name = "ISINK2",
1410                         .min_uA = 0000000,
1411                         .max_uA = 0000000,
1412                         .apply_uV = false,              
1413                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,           
1414                 },
1415                 .num_consumer_supplies = ARRAY_SIZE(isink2_consumers),
1416                 .consumer_supplies = isink2_consumers,
1417         },
1418 };
1419
1420 static int wm831x_checkrange(int start,int num,int val)
1421 {   
1422         if((val<(start+num))&&(val>=start))
1423                 return 0;
1424         else 
1425                 return -1;
1426 }
1427
1428 static int wm831x_init_pin_type(struct wm831x *wm831x)
1429 {
1430 #if 1
1431         struct wm831x_pdata *pdata = wm831x->dev->platform_data;
1432         struct rk29_gpio_expander_info *wm831x_gpio_settinginfo;
1433         uint16_t offset = 0;
1434         uint16_t wm831x_settingpin_num = 0;
1435         uint16_t ret = 0;
1436         int i = 0;
1437
1438         if(wm831x)
1439         {
1440                 wm831x_gpio_settinginfo=pdata->settinginfo;
1441                 if(wm831x_gpio_settinginfo)
1442                 {
1443                         wm831x_settingpin_num = pdata->settinginfolen;
1444                         for(i=0;i<wm831x_settingpin_num;i++)
1445                         {
1446                                 if(!wm831x_checkrange(pdata->gpio_base,pdata->gpio_pin_num,wm831x_gpio_settinginfo[i].gpio_num))
1447                                 {
1448                                         offset = wm831x_gpio_settinginfo[i].gpio_num - pdata->gpio_base;
1449
1450                                         if(wm831x_gpio_settinginfo[i].pin_type==GPIO_IN)
1451                                         {
1452                                                 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);
1453                                         }
1454                                         else
1455                                         {
1456                                                 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_TRI_SHIFT);
1457                                                 if(wm831x_gpio_settinginfo[i].pin_value==GPIO_HIGH)
1458                                                 {
1459                                                         wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(1 << offset));
1460                                                 }
1461                                                 else
1462                                                 {
1463                                                         wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(0 << offset));
1464                                                 }
1465                                         }
1466                                         
1467                                 }
1468                         }
1469                 }
1470         }
1471
1472         for(i=0;i<pdata->gpio_pin_num;i++)
1473         {
1474                 wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+i), 
1475                         WM831X_GPN_PULL_MASK|WM831X_GPN_POL_MASK|WM831X_GPN_OD_MASK|WM831X_GPN_TRI_MASK, 
1476                         1<<WM831X_GPN_POL_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
1477                 ret =  wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL+i);
1478                 printk("Gpio%d Pin Configuration = %x\n",i,ret);
1479         }
1480 #endif
1481         return 0;
1482 }
1483
1484 /*
1485  * GPIO Buttons
1486  */
1487 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)
1488 static struct wm831x_gpio_keys_button wm831x_gpio_buttons[] = {
1489 {       
1490         .code           = KEY_MEDIA,
1491         .gpio           = TCA6424_P21,
1492         .active_low     = 1,
1493         .desc           = "media",
1494         .wakeup         = 0,
1495         .debounce_interval = 120,
1496 },
1497 {
1498     .code= KEY_VOLUMEUP,
1499                 .gpio= WM831X_P05,
1500                 .active_low= 1,
1501                 .desc= "volume_up",
1502                 .wakeup= 0,
1503 },
1504 {
1505                 .code= KEY_CAMERA,
1506                 .gpio= WM831X_P06,
1507                 .active_low= 1,
1508                 .desc= "camera",
1509                 .wakeup= 0,
1510 },
1511 {
1512                 .code= KEY_VOLUMEDOWN,
1513                 .gpio= WM831X_P07,
1514                 .active_low= 1,
1515                 .desc= "volume_down",
1516                 .wakeup= 0,
1517 },
1518 {
1519                 .code= KEY_END,
1520                 .gpio= WM831X_P09,
1521                 .active_low= 1,
1522                 .desc= "enter",
1523                 .wakeup= 0,
1524 },
1525 {
1526                 .code= KEY_MENU,
1527                 .gpio= WM831X_P10,
1528                 .active_low= 1,
1529                 .desc= "menu",
1530                 .wakeup= 0,
1531 },
1532 {
1533                 .code= KEY_SEND,
1534                 .gpio= WM831X_P11,
1535                 .active_low= 1,
1536                 .desc= "esc",
1537                 .wakeup= 0,
1538 },
1539 {
1540                 .code= KEY_BACK,
1541                 .gpio= WM831X_P12,
1542                 .active_low= 1,
1543                 .desc= "home",
1544                 .wakeup= 0,                     
1545 },
1546 };
1547
1548 struct wm831x_gpio_keys_pdata wm831x_gpio_keys_platdata = {
1549         .buttons        = wm831x_gpio_buttons,
1550         .nbuttons       = ARRAY_SIZE(wm831x_gpio_buttons),
1551 };
1552
1553 #endif
1554 struct wm831x_pdata wm831x_platdata = {
1555         /** Called before subdevices are set up */
1556         .pre_init= wm831x_pre_init,
1557         /** Called after subdevices are set up */
1558         .post_init = wm831x_post_init,
1559         /** Called before subdevices are power down */
1560         .last_deinit = wm831x_last_deinit,
1561         
1562 #if defined(CONFIG_GPIO_WM831X)
1563         .gpio_base=WM831X_GPIO_EXPANDER_BASE,
1564         .gpio_pin_num=WM831X_TOTOL_GPIO_NUM,
1565         .settinginfo=wm831x_gpio_settinginfo,
1566         .settinginfolen=ARRAY_SIZE(wm831x_gpio_settinginfo),
1567         .pin_type_init = wm831x_init_pin_type,
1568         .irq_base= NR_AIC_IRQS + 7*NUM_GROUP,
1569 #endif
1570
1571         .backlight = &wm831x_backlight_platdata,
1572
1573         .backup = &wm831x_backup_platdata,
1574         
1575         .battery = &wm831x_battery_platdata,
1576         //.wm831x_touch_pdata = NULL,
1577         //.watchdog = NULL,
1578         
1579 #if defined(CONFIG_KEYBOARD_WM831X_GPIO)        
1580         .gpio_keys = &wm831x_gpio_keys_platdata,
1581 #endif
1582
1583         /** LED1 = 0 and so on */
1584         .status = {&wm831x_status_platdata[0], &wm831x_status_platdata[1]},
1585         
1586         /** DCDC1 = 0 and so on */
1587         .dcdc = {&wm831x_regulator_init_dcdc[0], &wm831x_regulator_init_dcdc[1], &wm831x_regulator_init_dcdc[2], &wm831x_regulator_init_dcdc[3]},
1588
1589         /** EPE1 = 0 and so on */
1590         .epe = {&wm831x_regulator_init_epe[0], &wm831x_regulator_init_epe[1]},
1591
1592         /** LDO1 = 0 and so on */
1593         .ldo = {&wm831x_regulator_init_ldo[0], &wm831x_regulator_init_ldo[1], &wm831x_regulator_init_ldo[2], &wm831x_regulator_init_ldo[3],
1594                         &wm831x_regulator_init_ldo[4], &wm831x_regulator_init_ldo[5], &wm831x_regulator_init_ldo[6], &wm831x_regulator_init_ldo[7],
1595                         &wm831x_regulator_init_ldo[8], &wm831x_regulator_init_ldo[9], &wm831x_regulator_init_ldo[10]},
1596
1597         /** ISINK1 = 0 and so on*/
1598         .isink = {&wm831x_regulator_init_isink[0], &wm831x_regulator_init_isink[1]},
1599 };
1600 #endif
1601
1602 #if defined(CONFIG_RK29_GPIO_SUSPEND)
1603 static void gpio_set_request(void)
1604 {
1605         gpio_request(RK29_PIN6_PA0, NULL);
1606         gpio_request(RK29_PIN6_PA1, NULL);
1607         gpio_request(RK29_PIN6_PA2, NULL);
1608         gpio_request(RK29_PIN6_PA3, NULL);
1609         gpio_request(RK29_PIN6_PA4, NULL);
1610         gpio_request(RK29_PIN6_PA5, NULL);
1611         gpio_request(RK29_PIN6_PA6, NULL);
1612
1613         gpio_request(RK29_PIN2_PA5, NULL);
1614         gpio_request(RK29_PIN2_PA4, NULL);
1615         gpio_request(RK29_PIN2_PB0, NULL);
1616         gpio_request(RK29_PIN2_PB1, NULL);
1617         gpio_request(RK29_PIN2_PB2, NULL);
1618         gpio_request(RK29_PIN2_PB3, NULL);
1619
1620         gpio_request(RK29_PIN1_PA4, NULL);
1621         gpio_request(RK29_PIN1_PA3, NULL);
1622
1623         gpio_request(RK29_PIN2_PC7, NULL);
1624         gpio_request(RK29_PIN2_PC6, NULL);
1625         gpio_request(RK29_PIN2_PC5, NULL);
1626         gpio_request(RK29_PIN2_PC4, NULL);
1627         gpio_request(RK29_PIN2_PC3, NULL);
1628         gpio_request(RK29_PIN2_PC2, NULL);
1629         gpio_request(RK29_PIN2_PC1, NULL);
1630         gpio_request(RK29_PIN2_PC0, NULL);
1631 }
1632
1633 static void gpio_set_free(void)
1634 {
1635         gpio_free(RK29_PIN6_PA0);
1636         gpio_free(RK29_PIN6_PA1);
1637         gpio_free(RK29_PIN6_PA2);
1638         gpio_free(RK29_PIN6_PA3);
1639         gpio_free(RK29_PIN6_PA4);
1640         gpio_free(RK29_PIN6_PA5);
1641         gpio_free(RK29_PIN6_PA6);
1642
1643         gpio_free(RK29_PIN2_PA5);
1644         gpio_free(RK29_PIN2_PA4);
1645         gpio_free(RK29_PIN2_PB0);
1646         gpio_free(RK29_PIN2_PB1);
1647         gpio_free(RK29_PIN2_PB2);
1648         gpio_free(RK29_PIN2_PB3);
1649
1650         gpio_free(RK29_PIN1_PA4);
1651         gpio_free(RK29_PIN1_PA3);
1652
1653         gpio_free(RK29_PIN2_PC7);
1654         gpio_free(RK29_PIN2_PC6);
1655         gpio_free(RK29_PIN2_PC5);
1656         gpio_free(RK29_PIN2_PC4);
1657         gpio_free(RK29_PIN2_PC3);
1658         gpio_free(RK29_PIN2_PC2);
1659         gpio_free(RK29_PIN2_PC1);
1660         gpio_free(RK29_PIN2_PC0);
1661 }
1662
1663 static void rk29_keygpio_suspend(void)
1664 {
1665         gpio_pull_updown(RK29_PIN6_PA0, 0);
1666         gpio_pull_updown(RK29_PIN6_PA1, 0);
1667         gpio_pull_updown(RK29_PIN6_PA2, 0);
1668         gpio_pull_updown(RK29_PIN6_PA3, 0);
1669         gpio_pull_updown(RK29_PIN6_PA4, 0);
1670         gpio_pull_updown(RK29_PIN6_PA5, 0);
1671         gpio_pull_updown(RK29_PIN6_PA6, 0);//key pullup/pulldown disable
1672
1673         gpio_pull_updown(RK29_PIN2_PA4, 0);
1674         gpio_pull_updown(RK29_PIN2_PA5, 0);
1675         gpio_pull_updown(RK29_PIN2_PB0, 0);
1676         gpio_pull_updown(RK29_PIN2_PB1, 0);
1677         gpio_pull_updown(RK29_PIN2_PB2, 0);
1678         gpio_pull_updown(RK29_PIN2_PB3, 0);
1679 }
1680
1681 static void rk29_keygpio_resume(void)
1682 {
1683         gpio_pull_updown(RK29_PIN6_PA0, 1);
1684         gpio_pull_updown(RK29_PIN6_PA1, 1);
1685         gpio_pull_updown(RK29_PIN6_PA2, 1);
1686         gpio_pull_updown(RK29_PIN6_PA3, 1);
1687         gpio_pull_updown(RK29_PIN6_PA4, 1);
1688         gpio_pull_updown(RK29_PIN6_PA5, 1);
1689         gpio_pull_updown(RK29_PIN6_PA6, 1);//key pullup/pulldown enable
1690
1691         gpio_pull_updown(RK29_PIN2_PA4, 1);
1692         gpio_pull_updown(RK29_PIN2_PA5, 1);
1693         gpio_pull_updown(RK29_PIN2_PB0, 1);
1694         gpio_pull_updown(RK29_PIN2_PB1, 1);
1695         gpio_pull_updown(RK29_PIN2_PB2, 1);
1696         gpio_pull_updown(RK29_PIN2_PB3, 1);
1697 }
1698
1699 static void spi_gpio_suspend(void)
1700 {       
1701         rk29_mux_api_set(GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,GPIO1L_GPIO1A4);  //set iomux is gpio mode
1702         rk29_mux_api_set(GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,GPIO1L_GPIO1A3);
1703
1704         rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_GPIO2C7);
1705         rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_GPIO2C6);
1706         //rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_GPIO2C5);
1707         rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_GPIO2C4);
1708         rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME,GPIO2H_GPIO2C3);
1709         rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME,GPIO2H_GPIO2C2);
1710         rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME,GPIO2H_GPIO2C1);
1711         rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME,GPIO2H_GPIO2C0);
1712
1713         gpio_direction_input(RK29_PIN1_PA4);             //set gpio is input
1714         gpio_direction_input(RK29_PIN1_PA3);
1715         gpio_direction_input(RK29_PIN2_PC7);
1716         gpio_direction_input(RK29_PIN2_PC6);
1717         // gpio_direction_input(RK29_PIN2_PC5);
1718         gpio_direction_input(RK29_PIN2_PC4);
1719         gpio_direction_input(RK29_PIN2_PC3);
1720         gpio_direction_input(RK29_PIN2_PC2);
1721         gpio_direction_input(RK29_PIN2_PC1);
1722         gpio_direction_input(RK29_PIN2_PC0);
1723
1724         gpio_pull_updown(RK29_PIN1_PA4, 0);   //set gpio pullup/down disable
1725         gpio_pull_updown(RK29_PIN1_PA3, 0);
1726
1727         gpio_pull_updown(RK29_PIN2_PC7, 0);
1728         gpio_pull_updown(RK29_PIN2_PC6, 0);
1729         //gpio_pull_updown(RK29_PIN2_PC5, 0);
1730         gpio_pull_updown(RK29_PIN2_PC4, 0);
1731         gpio_pull_updown(RK29_PIN2_PC3, 0);
1732         gpio_pull_updown(RK29_PIN2_PC2, 0);
1733         gpio_pull_updown(RK29_PIN2_PC1, 0);
1734         gpio_pull_updown(RK29_PIN2_PC0, 0);
1735 }
1736
1737 static void spi_gpio_resume(void)
1738 {       
1739         gpio_pull_updown(RK29_PIN1_PA4, 1);         //set gpio pullup/down enable
1740         gpio_pull_updown(RK29_PIN1_PA3, 1);
1741
1742         gpio_pull_updown(RK29_PIN2_PC7, 1);
1743         gpio_pull_updown(RK29_PIN2_PC6, 1);
1744         //gpio_pull_updown(RK29_PIN2_PC5, 1);
1745         gpio_pull_updown(RK29_PIN2_PC4, 1);
1746         gpio_pull_updown(RK29_PIN2_PC3, 1);
1747         gpio_pull_updown(RK29_PIN2_PC2, 1);
1748         gpio_pull_updown(RK29_PIN2_PC1, 1);
1749         gpio_pull_updown(RK29_PIN2_PC0, 1);
1750
1751         rk29_mux_api_set(GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,GPIO1L_SPI0_CSN1);   //set iomux is spi mode
1752         rk29_mux_api_set(GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,GPIO1L_SPI1_CSN1);
1753
1754         rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_SPI1_RXD);
1755         rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_SPI1_TXD);
1756         //rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_SPI1_CSN0);
1757         rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK);
1758         rk29_mux_api_set(GPIO2C3_SPI0RXD_NAME,GPIO2H_SPI0_RXD);
1759         rk29_mux_api_set(GPIO2C2_SPI0TXD_NAME,GPIO2H_SPI0_TXD);
1760         rk29_mux_api_set(GPIO2C1_SPI0CSN0_NAME,GPIO2H_SPI0_CSN0);
1761         rk29_mux_api_set(GPIO2C0_SPI0CLK_NAME,GPIO2H_SPI0_CLK);
1762 }
1763
1764 void rk29_setgpio_suspend_board(void)
1765 {
1766         gpio_set_request();
1767         rk29_keygpio_suspend();
1768         spi_gpio_suspend();
1769         gpio_set_free();
1770 }
1771
1772 void rk29_setgpio_resume_board(void)
1773 {
1774         gpio_set_request();
1775         rk29_keygpio_resume();
1776         spi_gpio_resume();
1777         gpio_set_free();
1778 }
1779 #endif
1780
1781 #if defined(CONFIG_RK29_GPS)
1782
1783 #define         RK29_GPS_POWER_PIN              RK29_PIN6_PB2
1784 #define         RK29_GPS_RESET_PIN              RK29_PIN6_PA7//RK29_PIN6_PC1  //modif by zwx CONFIG_CSR_GPS_GSD4E
1785
1786 int rk29_gps_power_up(void)
1787 {       
1788         printk("%s \n", __FUNCTION__);  
1789
1790     gpio_request(RK29_GPS_POWER_PIN, NULL);    
1791         gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH);   
1792
1793         return 0;
1794 }
1795
1796 int rk29_gps_power_down(void)
1797 {       
1798         printk("%s \n", __FUNCTION__);  
1799
1800     gpio_request(RK29_GPS_POWER_PIN, NULL);    
1801         gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW);            
1802
1803         return 0;
1804 }
1805
1806 int rk29_gps_reset_set(int level)
1807 {
1808         gpio_request(RK29_GPS_RESET_PIN, NULL);
1809         if (level)
1810                 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);
1811         else
1812                 gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);
1813         return 0;
1814 }
1815 #ifdef CONFIG_CSR_GPS_GSD4E  
1816 struct gps_rfkill_platform_data gps_rfkill_data=
1817 {
1818         .nshutdown_gpio=RK29_PIN6_PB2,
1819         .reset_gpio=RK29_PIN6_PA7,
1820 };
1821 static struct platform_device rk_csrgps_device={
1822
1823         .name = "csr-gps",
1824         .id = -1,
1825         .dev            = {
1826                 .platform_data  = &gps_rfkill_data,
1827         },
1828 };
1829 #else
1830 struct rk29_gps_data rk29_gps_info = {  
1831         .power_up = rk29_gps_power_up,  
1832         .power_down = rk29_gps_power_down,      
1833         .reset = rk29_gps_reset_set,
1834         .uart_id = 3,
1835 };
1836
1837 struct platform_device rk29_device_gps = {
1838         .name = "rk29_gps",
1839         .id = -1,               
1840         .dev            = {
1841         .platform_data = &rk29_gps_info,        
1842                 }           
1843         };
1844 #endif
1845 #endif
1846
1847 /*****************************************************************************************
1848  * wm8994  codec
1849  * author: qjb@rock-chips.com
1850  *****************************************************************************************/
1851 #if defined (CONFIG_SND_SOC_WM8994)
1852 struct wm8994_pdata wm8994_platdata = { 
1853         .BB_input_diff = 0,
1854         .BB_class = NO_PCM_BB,
1855         
1856         .no_earpiece = 0,
1857         .sp_hp_same_channel = 0,
1858
1859         .PA_control_pin = 0,    
1860         .Power_EN_Pin = RK29_PIN5_PA1,
1861         
1862         .speaker_incall_vol = 0,
1863         .speaker_incall_mic_vol = -9,
1864         .speaker_normal_vol = 6,
1865         .earpiece_incall_vol = 0,
1866         .headset_incall_vol = 6,
1867         .headset_incall_mic_vol = -6,
1868         .headset_normal_vol = -6,
1869         .BT_incall_vol = 0,
1870         .BT_incall_mic_vol = 0,
1871         .recorder_vol = 30,
1872                 
1873 };
1874 #endif
1875
1876 #ifdef CONFIG_RK_HEADSET_DET
1877 #define HEADSET_GPIO RK29_PIN4_PD2
1878 struct rk_headset_pdata rk_headset_info = {
1879         .Headset_gpio           = RK29_PIN4_PD2,
1880         .headset_in_type= HEADSET_IN_HIGH,
1881         .Hook_gpio = RK29_PIN4_PD1,//Detection Headset--Must be set
1882         .hook_key_code = KEY_MEDIA,
1883 };
1884
1885 struct platform_device rk_device_headset = {
1886                 .name   = "rk_headsetdet",
1887                 .id     = 0,
1888                 .dev    = {
1889                     .platform_data = &rk_headset_info,
1890                 }
1891 };
1892 #endif
1893
1894 #if defined(CONFIG_GS_L3G4200D)
1895
1896 #include <linux/l3g4200d.h>
1897 #define L3G4200D_INT_PIN  RK29_PIN5_PA3
1898
1899 static int l3g4200d_init_platform_hw(void)
1900 {
1901         if (gpio_request(L3G4200D_INT_PIN, NULL) != 0) {
1902                 gpio_free(L3G4200D_INT_PIN);
1903                 printk("%s: request l3g4200d int pin error\n", __func__);
1904                 return -EIO;
1905         }
1906         gpio_pull_updown(L3G4200D_INT_PIN, 1);
1907         return 0;
1908 }
1909
1910 static struct l3g4200d_platform_data l3g4200d_info = {
1911         .fs_range = 1,
1912         
1913         .axis_map_x = 0,
1914         .axis_map_y = 1,
1915         .axis_map_z = 2,
1916
1917         .negate_x = 1,
1918         .negate_y = 1,
1919         .negate_z = 0,
1920
1921         .init = l3g4200d_init_platform_hw,
1922 };
1923
1924 #endif
1925
1926 /*****************************************************************************************
1927  * i2c devices
1928  * author: kfx@rock-chips.com
1929 *****************************************************************************************/
1930 static int rk29_i2c0_io_init(void)
1931 {
1932 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1933         rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
1934         rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
1935 #else
1936         rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
1937         rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
1938 #endif
1939         return 0;
1940 }
1941
1942 static int rk29_i2c1_io_init(void)
1943 {
1944 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1945         rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
1946         rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
1947 #else
1948         rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
1949         rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
1950 #endif
1951         return 0;
1952 }
1953 static int rk29_i2c2_io_init(void)
1954 {
1955 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1956         rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
1957         rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
1958 #else
1959         rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
1960         rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
1961 #endif
1962         return 0;
1963 }
1964
1965 static int rk29_i2c3_io_init(void)
1966 {
1967 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1968         rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
1969         rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1970 #else
1971         rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
1972         rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
1973 #endif
1974         return 0;
1975 }
1976 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1977 struct rk29_i2c_platform_data default_i2c0_data = {
1978         .bus_num    = 0,
1979         .flags      = 0,
1980         .slave_addr = 0xff,
1981         .scl_rate  = 400*1000,
1982         .mode           = I2C_MODE_IRQ,
1983         .io_init = rk29_i2c0_io_init,
1984 };
1985 #else
1986 struct i2c_gpio_platform_data default_i2c0_data = {
1987        .sda_pin = RK29_PIN2_PB6,
1988        .scl_pin = RK29_PIN2_PB7,
1989        .udelay = 5, // clk = 500/udelay = 100Khz
1990        .timeout = 100,//msecs_to_jiffies(200),
1991        .bus_num    = 0,
1992        .io_init = rk29_i2c0_io_init,
1993 };
1994 #endif
1995 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1996 struct rk29_i2c_platform_data default_i2c1_data = {
1997         .bus_num    = 1,
1998         .flags      = 0,
1999         .slave_addr = 0xff,
2000         .scl_rate  = 400*1000,
2001         .mode           = I2C_MODE_IRQ,
2002         .io_init = rk29_i2c1_io_init,
2003 };
2004 #else
2005 struct i2c_gpio_platform_data default_i2c1_data = {
2006        .sda_pin = RK29_PIN1_PA6,
2007        .scl_pin = RK29_PIN1_PA7,
2008        .udelay = 5, // clk = 500/udelay = 100Khz
2009        .timeout = 100,//msecs_to_jiffies(200),
2010        .bus_num    = 1,
2011        .io_init = rk29_i2c1_io_init,
2012 };
2013 #endif
2014 #ifdef CONFIG_RK29_I2C2_CONTROLLER
2015 struct rk29_i2c_platform_data default_i2c2_data = {
2016         .bus_num    = 2,
2017         .flags      = 0,
2018         .slave_addr = 0xff,
2019         .scl_rate  = 400*1000,
2020         .mode           = I2C_MODE_IRQ,
2021         .io_init = rk29_i2c2_io_init,
2022 };
2023 #else
2024 struct i2c_gpio_platform_data default_i2c2_data = {
2025        .sda_pin = RK29_PIN5_PD3,
2026        .scl_pin = RK29_PIN5_PD4,
2027        .udelay = 5, // clk = 500/udelay = 100Khz
2028        .timeout = 100,//msecs_to_jiffies(200),
2029        .bus_num    = 2,
2030        .io_init = rk29_i2c2_io_init,
2031 };
2032 #endif
2033 #ifdef CONFIG_RK29_I2C3_CONTROLLER
2034 struct rk29_i2c_platform_data default_i2c3_data = {
2035         .bus_num    = 3,
2036         .flags      = 0,
2037         .slave_addr = 0xff,
2038         .scl_rate  = 400*1000,
2039         .mode           = I2C_MODE_IRQ,
2040         .io_init = rk29_i2c3_io_init,
2041 };
2042 #else
2043 struct i2c_gpio_platform_data default_i2c3_data = {
2044        .sda_pin = RK29_PIN5_PB5,
2045        .scl_pin = RK29_PIN5_PB4,
2046        .udelay = 5, // clk = 500/udelay = 100Khz
2047        .timeout = 100,//msecs_to_jiffies(200),
2048        .bus_num    = 3,
2049        .io_init = rk29_i2c3_io_init,
2050 };
2051 #endif
2052 #ifdef CONFIG_I2C0_RK29
2053 static struct i2c_board_info __initdata board_i2c0_devices[] = {
2054 #if defined (CONFIG_RK1000_CONTROL)
2055         {
2056                 .type                   = "rk1000_control",
2057                 .addr           = 0x40,
2058                 .flags                  = 0,
2059         },
2060 #endif
2061 #if defined (CONFIG_SND_SOC_RK1000)
2062         {
2063                 .type                   = "rk1000_i2c_codec",
2064                 .addr           = 0x60,
2065                 .flags                  = 0,
2066         },
2067 #endif
2068 #if defined (CONFIG_SND_SOC_WM8900)
2069         {
2070                 .type                   = "wm8900",
2071                 .addr           = 0x1A,
2072                 .flags                  = 0,
2073         },
2074 #endif
2075 #if defined (CONFIG_SND_SOC_WM8994)
2076         {
2077                 .type                   = "wm8994",
2078                 .addr           = 0x1a,
2079                 .flags                  = 0,
2080 //      #if defined(CONFIG_MFD_WM8994)  
2081                 .platform_data  = &wm8994_platdata,     
2082 //      #endif  
2083         },
2084 #endif
2085 #if defined (CONFIG_BATTERY_STC3100)
2086         {
2087                 .type                   = "stc3100",
2088                 .addr           = 0x70,
2089                 .flags                  = 0,
2090         },
2091 #endif
2092 #if defined (CONFIG_BATTERY_BQ27510)
2093         {
2094                 .type                   = "bq27510",
2095                 .addr           = 0x55,
2096                 .flags                  = 0,
2097         },
2098 #endif
2099 #if defined (CONFIG_RTC_HYM8563)
2100         {
2101                 .type                   = "rtc_hym8563",
2102                 .addr           = 0x51,
2103                 .flags                  = 0,
2104                 .irq            = RK29_PIN0_PA1,
2105         },
2106 #endif
2107 #if defined (CONFIG_GS_MMA8452)
2108     {
2109       .type           = "gs_mma8452",
2110       .addr           = 0x1c,
2111       .flags          = 0,
2112       .irq            = MMA8452_INT_PIN,
2113       .platform_data  = &mma8452_info,
2114     },
2115 #endif
2116 #if defined (CONFIG_COMPASS_AK8973)
2117         {
2118                 .type                   = "ak8973",
2119                 .addr           = 0x1d,
2120                 .flags                  = 0,
2121                 .irq                    = RK29_PIN6_PC5,
2122         },
2123 #endif
2124 #if defined (CONFIG_COMPASS_AK8975)
2125         {
2126                 .type                   = "ak8975",
2127                 .addr           = 0x0d,
2128                 .flags                  = 0,
2129                 .irq                    = RK29_PIN6_PC5,
2130         },
2131 #endif
2132 #if defined (CONFIG_INPUT_LPSENSOR_ISL29028)
2133         {
2134                 .type           = "isl29028",
2135                 .addr           = 0x44,
2136                 .flags          = 0,
2137                 .irq            = RK29_PIN4_PD3,
2138         },
2139 #endif
2140 #if defined (CONFIG_INPUT_LPSENSOR_APDS9900)
2141         {
2142                 .type                   = "apds9900",
2143                 .addr                   = 0x39,
2144                 .flags                  = 0,
2145                 .irq                    = RK29_PIN4_PD3,
2146         },
2147 #endif
2148 #if defined (CONFIG_ANX7150)
2149     {
2150                 .type           = "anx7150",
2151         .addr           = 0x39,             //0x39, 0x3d
2152         .flags          = 0,
2153         .irq            = RK29_PIN2_PA3,
2154     },
2155 #endif
2156 #if defined (CONFIG_GS_L3G4200D)
2157         {
2158                 .type           = "gs_l3g4200d",
2159                 .addr           = 0x69,
2160                 .flags          = 0,
2161                 .irq            = L3G4200D_INT_PIN,
2162                 .platform_data  = &l3g4200d_info,
2163         },
2164 #endif
2165 #if defined (CONFIG_MPU_SENSORS_MPU3050) 
2166         {
2167                 .type                   = "mpu3050",
2168                 .addr                   = 0x68,
2169                 .flags                  = 0,
2170                 .irq                    = RK29_PIN4_PC4,
2171                 .platform_data  = &mpu3050_data,
2172         },
2173 #endif
2174 };
2175 #endif
2176
2177 #ifdef CONFIG_I2C1_RK29
2178 static struct i2c_board_info __initdata board_i2c1_devices[] = {
2179 #if defined (CONFIG_RK1000_CONTROL1)
2180         {
2181                 .type                   = "rk1000_control",
2182                 .addr                   = 0x40,
2183                 .flags                  = 0,
2184         },
2185 #endif
2186
2187 };
2188 #endif
2189
2190 #ifdef CONFIG_I2C2_RK29
2191 static struct i2c_board_info __initdata board_i2c2_devices[] = {
2192 #if defined (CONFIG_TOUCHSCREEN_GT801_IIC) || defined (CONFIG_TOUCHSCREEN_GT801_Z5)
2193 {
2194         .type           = "gt801_ts",
2195         .addr           = 0x55,
2196         .flags          = 0,
2197         .irq            = RK29_PIN4_PD5,
2198         .platform_data = &gt801_info,
2199 },      
2200 #endif
2201 #if defined (CONFIG_TOUCHSCREEN_GT818_IIC)
2202 {
2203         .type           = "gt818_ts",
2204         .addr           = 0x5d,
2205         .flags          = 0,
2206         .irq            = RK29_PIN4_PD5,
2207         .platform_data = &gt818_info,
2208 },
2209 #endif
2210
2211 #if defined(CONFIG_TOUCHSCREEN_FT5X0X_Z5) || defined (CONFIG_TOUCHSCREEN_FT5306)
2212 {
2213         .type           = "ft5x0x_ts",
2214         .addr           =0x38 ,
2215         .flags          = 0,
2216         .irq            = RK29_PIN4_PD5,
2217         .platform_data = &ft5406_info,
2218 },
2219 #endif
2220
2221 #if defined (CONFIG_TOUCHSCREEN_ILI2102_IIC)
2222 {
2223         .type           = "ili2102_ts",
2224         .addr           = 0x41,
2225         .flags          = I2C_M_NEED_DELAY,
2226         .udelay      = 600,
2227         .irq            = RK29_PIN4_PD5,
2228         .platform_data = &ili2102_info,
2229 },      
2230 #endif
2231
2232 #if defined (CONFIG_MFD_WM831X_I2C)
2233 {
2234         .type           = "wm8310",
2235         .addr           = 0x34,
2236         .flags          = 0,
2237         .irq            = RK29_PIN4_PD0,
2238         .platform_data = &wm831x_platdata,
2239 },      
2240 #endif
2241 #if defined (CONFIG_HANNSTAR_P1003)
2242     {
2243       .type           = "p1003_touch",
2244       .addr           = 0x04,
2245       .flags          = 0,
2246       .irq            = RK29_PIN0_PA2,
2247       .platform_data  = &p1003_info,
2248     },
2249 #endif
2250 #if defined (CONFIG_EETI_EGALAX)
2251     {
2252       .type           = "egalax_i2c",
2253       .addr           = 0x04,
2254       .flags          = 0,
2255       .irq            = RK29_PIN4_PD5,
2256       .platform_data  = &eeti_egalax_info,
2257     },
2258 #endif
2259 };
2260 #endif
2261
2262 #ifdef CONFIG_I2C3_RK29
2263 static struct i2c_board_info __initdata board_i2c3_devices[] = {
2264 };
2265 #endif
2266
2267 /*****************************************************************************************
2268  * camera  devices
2269  * author: ddl@rock-chips.com
2270  *****************************************************************************************/
2271 #ifdef CONFIG_VIDEO_RK29
2272 #define CONFIG_SENSOR_POWER_IOCTL_USR      0
2273 #define CONFIG_SENSOR_RESET_IOCTL_USR      0
2274 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR      0
2275 #define CONFIG_SENSOR_FLASH_IOCTL_USR      0
2276
2277 #if CONFIG_SENSOR_POWER_IOCTL_USR
2278 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
2279 {
2280     #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
2281 }
2282 #endif
2283
2284 #if CONFIG_SENSOR_RESET_IOCTL_USR
2285 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
2286 {
2287     #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
2288 }
2289 #endif
2290
2291 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
2292 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
2293 {
2294     #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
2295 }
2296 #endif
2297
2298 #if CONFIG_SENSOR_FLASH_IOCTL_USR
2299 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
2300 {
2301     #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
2302 }
2303 #endif
2304
2305 static struct rk29camera_platform_ioctl_cb  sensor_ioctl_cb = {
2306     #if CONFIG_SENSOR_POWER_IOCTL_USR
2307     .sensor_power_cb = sensor_power_usr_cb,
2308     #else
2309     .sensor_power_cb = NULL,
2310     #endif
2311
2312     #if CONFIG_SENSOR_RESET_IOCTL_USR
2313     .sensor_reset_cb = sensor_reset_usr_cb,
2314     #else
2315     .sensor_reset_cb = NULL,
2316     #endif
2317
2318     #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
2319     .sensor_powerdown_cb = sensor_powerdown_usr_cb,
2320     #else
2321     .sensor_powerdown_cb = NULL,
2322     #endif
2323
2324     #if CONFIG_SENSOR_FLASH_IOCTL_USR
2325     .sensor_flash_cb = sensor_flash_usr_cb,
2326     #else
2327     .sensor_flash_cb = NULL,
2328     #endif
2329 };
2330 #include "../../../drivers/media/video/rk29_camera.c"
2331 #endif
2332
2333 /*****************************************************************************************
2334  * backlight  devices
2335  * author: nzy@rock-chips.com
2336  *****************************************************************************************/
2337 #ifdef CONFIG_BACKLIGHT_RK29_BL
2338  /*
2339  GPIO1B5_PWM0_NAME,       GPIO1L_PWM0
2340  GPIO5D2_PWM1_UART1SIRIN_NAME,  GPIO5H_PWM1
2341  GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME,   GPIO2L_PWM2
2342  GPIO1A5_EMMCPWREN_PWM3_NAME,     GPIO1L_PWM3
2343  */
2344
2345 #define PWM_ID            0
2346 #define PWM_MUX_NAME      GPIO1B5_PWM0_NAME
2347 #define PWM_MUX_MODE      GPIO1L_PWM0
2348 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
2349 #define PWM_EFFECT_VALUE  1
2350
2351 //#define LCD_DISP_ON_PIN
2352
2353 #ifdef  LCD_DISP_ON_PIN
2354 #define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
2355 #define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
2356
2357 #define BL_EN_PIN         GPIO0L_GPIO0A5
2358 #define BL_EN_VALUE       GPIO_HIGH
2359 #endif
2360 static int rk29_backlight_io_init(void)
2361 {
2362     int ret = 0;
2363
2364     rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
2365         #ifdef  LCD_DISP_ON_PIN
2366     rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
2367
2368     ret = gpio_request(BL_EN_PIN, NULL);
2369     if(ret != 0)
2370     {
2371         gpio_free(BL_EN_PIN);
2372     }
2373
2374     gpio_direction_output(BL_EN_PIN, 0);
2375     gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
2376         #endif
2377     return ret;
2378 }
2379
2380 static int rk29_backlight_io_deinit(void)
2381 {
2382     int ret = 0;
2383     #ifdef  LCD_DISP_ON_PIN
2384     gpio_free(BL_EN_PIN);
2385     #endif
2386     rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
2387     return ret;
2388 }
2389 struct rk29_bl_info rk29_bl_info = {
2390     .pwm_id   = PWM_ID,
2391     .bl_ref   = PWM_EFFECT_VALUE,
2392     .io_init   = rk29_backlight_io_init,
2393     .io_deinit = rk29_backlight_io_deinit,
2394 };
2395 #endif
2396 /*****************************************************************************************
2397 * pwm voltage regulator devices
2398 ******************************************************************************************/
2399 #if defined (CONFIG_RK29_PWM_REGULATOR)
2400
2401 #define REGULATOR_PWM_ID                                        2
2402 #define REGULATOR_PWM_MUX_NAME                  GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
2403 #define REGULATOR_PWM_MUX_MODE                                          GPIO2L_PWM2
2404 #define REGULATOR_PWM_MUX_MODE_GPIO                             GPIO2L_GPIO2A3
2405 #define REGULATOR_PWM_GPIO                              RK29_PIN2_PA3
2406
2407 static struct regulator_consumer_supply pwm_consumers[] = {
2408         {
2409                 .supply = "vcore",
2410         }
2411 };
2412
2413 static struct regulator_init_data rk29_pwm_regulator_data = {
2414         .constraints = {
2415                 .name = "PWM2",
2416                 .min_uV =  950000,
2417                 .max_uV = 1400000,
2418                 .apply_uV = 1,
2419                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
2420         },
2421         .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
2422         .consumer_supplies = pwm_consumers,
2423 };
2424
2425 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
2426         .pwm_id = REGULATOR_PWM_ID,
2427         .pwm_gpio = REGULATOR_PWM_GPIO,
2428         //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
2429         .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
2430         .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
2431         .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
2432         .init_data  = &rk29_pwm_regulator_data,
2433 };
2434
2435 static struct platform_device rk29_device_pwm_regulator = {
2436         .name = "pwm-voltage-regulator",
2437         .id   = -1,
2438         .dev  = {
2439                 .platform_data = &rk29_regulator_pwm_platform_data,
2440         },
2441 };
2442
2443 #endif
2444
2445
2446 #if defined(CONFIG_MTK23D)
2447 static int mtk23d_io_init(void)
2448 {
2449          return 0;
2450 }
2451
2452 static int mtk23d_io_deinit(void)
2453 {
2454  
2455          return 0;
2456 }
2457  
2458 struct rk2818_23d_data rk2818_23d_info = {
2459         .io_init = mtk23d_io_init,
2460         .io_deinit = mtk23d_io_deinit,
2461         .bp_power = RK29_PIN6_PB0,
2462         .bp_power_active_low = 0,
2463         .bp_reset = RK29_PIN6_PB1,
2464         .bp_reset_active_low = 0,
2465         .bp_statue = RK29_PIN0_PA2,//input  high bp sleep;
2466         .ap_statue = RK29_PIN0_PA3,//output high ap sleep;
2467         .ap_bp_wakeup = RK29_PIN0_PA0, //output AP wake up BP used rising edge;
2468         .bp_ap_wakeup = RK29_PIN0_PA4,//input BP wake up AP
2469 };
2470 struct platform_device rk2818_device_mtk23d = {
2471         .name = "mtk23d",
2472         .id = -1,
2473         .dev            = {
2474                 .platform_data = &rk2818_23d_info,
2475         }
2476     };
2477 #endif
2478
2479 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
2480 #define SDMMC0_WRITE_PROTECT_PIN                RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin.
2481 #endif
2482
2483
2484 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
2485 #define SDMMC1_WRITE_PROTECT_PIN                RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin.
2486 #endif
2487
2488 /*****************************************************************************************
2489  * SDMMC devices
2490 *****************************************************************************************/
2491 #if !defined(CONFIG_SDMMC_RK29_OLD)     
2492 static void rk29_sdmmc_gpio_open(int device_id, int on)
2493 {
2494     switch(device_id)
2495     {
2496         case 0://mmc0
2497         {
2498             #ifdef CONFIG_SDMMC0_RK29
2499             if(on)
2500             {
2501                 gpio_direction_output(RK29_PIN1_PD0,GPIO_HIGH);//set mmc0-clk to high
2502                 gpio_direction_output(RK29_PIN1_PD1,GPIO_HIGH);//set mmc0-cmd to high.
2503                 gpio_direction_output(RK29_PIN1_PD2,GPIO_HIGH);//set mmc0-data0 to high.
2504                 gpio_direction_output(RK29_PIN1_PD3,GPIO_HIGH);//set mmc0-data1 to high.
2505                 gpio_direction_output(RK29_PIN1_PD4,GPIO_HIGH);//set mmc0-data2 to high.
2506                 gpio_direction_output(RK29_PIN1_PD5,GPIO_HIGH);//set mmc0-data3 to high.
2507
2508                 mdelay(30);
2509             }
2510             else
2511             {
2512                 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_GPIO1_D0);
2513                 gpio_request(RK29_PIN1_PD0, "mmc0-clk");
2514                 gpio_direction_output(RK29_PIN1_PD0,GPIO_LOW);//set mmc0-clk to low.
2515
2516                 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_GPIO1_D1);
2517                 gpio_request(RK29_PIN1_PD1, "mmc0-cmd");
2518                 gpio_direction_output(RK29_PIN1_PD1,GPIO_LOW);//set mmc0-cmd to low.
2519
2520                 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_GPIO1D2);
2521                 gpio_request(RK29_PIN1_PD2, "mmc0-data0");
2522                 gpio_direction_output(RK29_PIN1_PD2,GPIO_LOW);//set mmc0-data0 to low.
2523
2524                 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_GPIO1D3);
2525                 gpio_request(RK29_PIN1_PD3, "mmc0-data1");
2526                 gpio_direction_output(RK29_PIN1_PD3,GPIO_LOW);//set mmc0-data1 to low.
2527
2528                 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_GPIO1D4);
2529                 gpio_request(RK29_PIN1_PD4, "mmc0-data2");
2530                 gpio_direction_output(RK29_PIN1_PD4,GPIO_LOW);//set mmc0-data2 to low.
2531
2532                 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_GPIO1D5);
2533                 gpio_request(RK29_PIN1_PD5, "mmc0-data3");
2534                 gpio_direction_output(RK29_PIN1_PD5,GPIO_LOW);//set mmc0-data3 to low.
2535
2536                 mdelay(30);
2537             }
2538             #endif
2539         }
2540         break;
2541         
2542         case 1://mmc1
2543         {
2544             #ifdef CONFIG_SDMMC1_RK29
2545             if(on)
2546             {
2547                 gpio_direction_output(RK29_PIN1_PC7,GPIO_HIGH);//set mmc1-clk to high
2548                 gpio_direction_output(RK29_PIN1_PC2,GPIO_HIGH);//set mmc1-cmd to high.
2549                 gpio_direction_output(RK29_PIN1_PC3,GPIO_HIGH);//set mmc1-data0 to high.
2550                 gpio_direction_output(RK29_PIN1_PC4,GPIO_HIGH);//set mmc1-data1 to high.
2551                 gpio_direction_output(RK29_PIN1_PC5,GPIO_HIGH);//set mmc1-data2 to high.
2552                 gpio_direction_output(RK29_PIN1_PC6,GPIO_HIGH);//set mmc1-data3 to high.
2553                 mdelay(100);
2554             }
2555             else
2556             {
2557                 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_GPIO1C7);
2558                 gpio_request(RK29_PIN1_PC7, "mmc1-clk");
2559                 gpio_direction_output(RK29_PIN1_PC7,GPIO_LOW);//set mmc1-clk to low.
2560
2561                 rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_GPIO1C2);
2562                 gpio_request(RK29_PIN1_PC2, "mmc1-cmd");
2563                 gpio_direction_output(RK29_PIN1_PC2,GPIO_LOW);//set mmc1-cmd to low.
2564
2565                 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_GPIO1C3);
2566                 gpio_request(RK29_PIN1_PC3, "mmc1-data0");
2567                 gpio_direction_output(RK29_PIN1_PC3,GPIO_LOW);//set mmc1-data0 to low.
2568
2569                 mdelay(100);
2570             }
2571             #endif
2572         }
2573         break; 
2574         
2575         case 2: //mmc2
2576         break;
2577         
2578         default:
2579         break;
2580     }
2581 }
2582
2583
2584 static void rk29_sdmmc_set_iomux_mmc0(unsigned int bus_width)
2585 {
2586     switch (bus_width)
2587     {
2588         
2589         case 1://SDMMC_CTYPE_4BIT:
2590         {
2591                 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
2592                 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
2593                 rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
2594         }
2595         break;
2596
2597         case 0x10000://SDMMC_CTYPE_8BIT:
2598             break;
2599         case 0xFFFF: //gpio_reset
2600         {
2601             rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5);   
2602             gpio_request(RK29_PIN5_PD5,"sdmmc-power");
2603             gpio_direction_output(RK29_PIN5_PD5,GPIO_HIGH); //power-off
2604
2605             rk29_sdmmc_gpio_open(0, 0);
2606
2607             gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW); //power-on
2608
2609             rk29_sdmmc_gpio_open(0, 1);
2610         }
2611         break;
2612
2613         default: //case 0://SDMMC_CTYPE_1BIT:
2614         {
2615                 rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
2616                 rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
2617                 rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
2618
2619                 rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_GPIO1D3);
2620                 gpio_request(RK29_PIN1_PD3, "mmc0-data1");
2621                 gpio_direction_output(RK29_PIN1_PD3,GPIO_HIGH);
2622
2623                 rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_GPIO1D4);
2624                 gpio_request(RK29_PIN1_PD4, "mmc0-data2");
2625                 gpio_direction_output(RK29_PIN1_PD4,GPIO_HIGH);
2626                 
2627             rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_GPIO1D5);
2628             gpio_request(RK29_PIN1_PD5, "mmc0-data3");
2629                 gpio_direction_output(RK29_PIN1_PD5,GPIO_HIGH);
2630         }
2631         break;
2632         }
2633 }
2634
2635 static void rk29_sdmmc_set_iomux_mmc1(unsigned int bus_width)
2636 {
2637 #if 0
2638     switch (bus_width)
2639     {
2640         
2641         case 1://SDMMC_CTYPE_4BIT:
2642         {
2643             rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2644             rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2645             rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2646             rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2647             rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2648             rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2649         }
2650         break;
2651
2652         case 0x10000://SDMMC_CTYPE_8BIT:
2653             break;
2654         case 0xFFFF:
2655         {
2656            rk29_sdmmc_gpio_open(1, 0); 
2657            rk29_sdmmc_gpio_open(1, 1);
2658         }
2659         break;
2660
2661         default: //case 0://SDMMC_CTYPE_1BIT:
2662         {
2663             rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2664                 rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2665                 rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2666
2667             rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_GPIO1C4);
2668             gpio_request(RK29_PIN1_PC4, "mmc1-data1");
2669                 gpio_direction_output(RK29_PIN1_PC4,GPIO_HIGH);
2670                 
2671             rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_GPIO1C5);
2672             gpio_request(RK29_PIN1_PC5, "mmc1-data2");
2673                 gpio_direction_output(RK29_PIN1_PC5,GPIO_HIGH);
2674
2675             rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_GPIO1C6);
2676             gpio_request(RK29_PIN1_PC6, "mmc1-data3");
2677                 gpio_direction_output(RK29_PIN1_PC6,GPIO_HIGH);
2678
2679         }
2680         break;
2681         }
2682 #else
2683     rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2684     rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2685     rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2686     rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2687     rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2688     rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2689
2690 #endif
2691 }
2692
2693 static void rk29_sdmmc_set_iomux_mmc2(unsigned int bus_width)
2694 {
2695     ;//
2696 }
2697
2698 static void rk29_sdmmc_set_iomux(int device_id, unsigned int bus_width)
2699 {
2700     switch(device_id)
2701     {
2702         case 0:
2703             #ifdef CONFIG_SDMMC0_RK29
2704             rk29_sdmmc_set_iomux_mmc0(bus_width);
2705             #endif
2706             break;
2707         case 1:
2708             #ifdef CONFIG_SDMMC1_RK29
2709             rk29_sdmmc_set_iomux_mmc1(bus_width);
2710             #endif
2711             break;
2712         case 2:
2713             rk29_sdmmc_set_iomux_mmc2(bus_width);
2714             break;
2715         default:
2716             break;
2717     }    
2718 }
2719
2720 #endif
2721
2722 #ifdef CONFIG_WIFI_CONTROL_FUNC
2723 static int rk29sdk_wifi_status(struct device *dev);
2724 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
2725 #endif
2726
2727 #ifdef CONFIG_SDMMC0_RK29
2728 static int rk29_sdmmc0_cfg_gpio(void)
2729 {
2730 #ifdef CONFIG_SDMMC_RK29_OLD    
2731     rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
2732         rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
2733         rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
2734         rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
2735         rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
2736         rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
2737         
2738         rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
2739
2740     rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5);   ///GPIO5H_SDMMC0_PWR_EN);  ///GPIO5H_GPIO5D5);
2741         gpio_request(RK29_PIN5_PD5,"sdmmc");
2742 #if 0
2743         gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
2744         mdelay(100);
2745         gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
2746 #else
2747         gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
2748 #endif
2749
2750 #else
2751     rk29_sdmmc_set_iomux(0, 0xFFFF);
2752     
2753         rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
2754
2755         #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
2756     gpio_request(SDMMC0_WRITE_PROTECT_PIN,"sdmmc-wp");
2757     gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);         
2758     #endif
2759
2760 #endif
2761
2762         return 0;
2763 }
2764
2765 #define CONFIG_SDMMC0_USE_DMA
2766 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
2767         .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
2768                                            MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
2769                                            MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
2770         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2771         .io_init = rk29_sdmmc0_cfg_gpio,
2772         
2773 #if !defined(CONFIG_SDMMC_RK29_OLD)             
2774         .set_iomux = rk29_sdmmc_set_iomux,
2775 #endif
2776
2777         .dma_name = "sd_mmc",
2778 #ifdef CONFIG_SDMMC0_USE_DMA
2779         .use_dma  = 1,
2780 #else
2781         .use_dma = 0,
2782 #endif
2783         .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
2784         .enable_sd_wakeup = 0,
2785
2786 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
2787     .write_prt = SDMMC0_WRITE_PROTECT_PIN,
2788 #else
2789     .write_prt = INVALID_GPIO,
2790 #endif
2791 };
2792 #endif
2793 #ifdef CONFIG_SDMMC1_RK29
2794 #define CONFIG_SDMMC1_USE_DMA
2795 static int rk29_sdmmc1_cfg_gpio(void)
2796 {
2797 #if defined(CONFIG_SDMMC_RK29_OLD)
2798         rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
2799         rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
2800         rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
2801         rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
2802         rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
2803         rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
2804         //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
2805
2806 #else
2807
2808 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
2809     gpio_request(SDMMC1_WRITE_PROTECT_PIN,"sdio-wp");
2810     gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);         
2811 #endif
2812
2813 #endif
2814
2815         return 0;
2816 }
2817
2818
2819
2820 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK29_PIN1_PD6
2821
2822 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
2823         .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
2824                                            MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
2825                                            MMC_VDD_32_33|MMC_VDD_33_34),
2826
2827 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)                                     
2828         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
2829                                    MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2830 #else
2831     .host_caps  = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
2832 #endif
2833
2834         .io_init = rk29_sdmmc1_cfg_gpio,
2835         
2836 #if !defined(CONFIG_SDMMC_RK29_OLD)             
2837         .set_iomux = rk29_sdmmc_set_iomux,
2838 #endif  
2839
2840         .dma_name = "sdio",
2841 #ifdef CONFIG_SDMMC1_USE_DMA
2842         .use_dma  = 1,
2843 #else
2844         .use_dma = 0,
2845 #endif
2846
2847 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
2848 #ifdef CONFIG_WIFI_CONTROL_FUNC
2849         .status = rk29sdk_wifi_status,
2850         .register_status_notify = rk29sdk_wifi_status_register,
2851 #endif
2852 #if 0
2853         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
2854 #endif
2855
2856 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
2857     .write_prt = SDMMC1_WRITE_PROTECT_PIN,
2858 #else
2859     .write_prt = INVALID_GPIO, 
2860 #endif  
2861
2862 #else
2863 //for wifi develop board
2864     .detect_irq = INVALID_GPIO,
2865     .enable_sd_wakeup = 0,
2866 #endif
2867
2868 }; 
2869 #endif ////endif--#ifdef CONFIG_SDMMC1_RK29
2870
2871
2872 int rk29sdk_wifi_power_state = 0;
2873 int rk29sdk_bt_power_state = 0;
2874
2875 #ifdef CONFIG_WIFI_CONTROL_FUNC
2876 #define RK29SDK_WIFI_BT_GPIO_POWER_N       RK29_PIN5_PD6
2877 #define RK29SDK_WIFI_GPIO_RESET_N          RK29_PIN6_PC0
2878 #define RK29SDK_BT_GPIO_RESET_N            RK29_PIN6_PC7
2879
2880 static int rk29sdk_wifi_cd = 0;   /* wifi virtual 'card detect' status */
2881 static void (*wifi_status_cb)(int card_present, void *dev_id);
2882 static void *wifi_status_cb_devid;
2883
2884 static int rk29sdk_wifi_status(struct device *dev)
2885 {
2886         return rk29sdk_wifi_cd;
2887 }
2888
2889 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
2890 {
2891         if(wifi_status_cb)
2892                 return -EAGAIN;
2893         wifi_status_cb = callback;
2894         wifi_status_cb_devid = dev_id;
2895         return 0;
2896 }
2897
2898 static int rk29sdk_wifi_bt_gpio_control_init(void)
2899 {
2900     if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
2901            pr_info("%s: request wifi_bt power gpio failed\n", __func__);
2902            return -1;
2903     }
2904
2905     if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
2906            pr_info("%s: request wifi reset gpio failed\n", __func__);
2907            gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
2908            return -1;
2909     }
2910
2911     if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
2912           pr_info("%s: request bt reset gpio failed\n", __func__);
2913           gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
2914           return -1;
2915     }
2916
2917     gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2918     gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N,    GPIO_LOW);
2919     gpio_direction_output(RK29SDK_BT_GPIO_RESET_N,      GPIO_LOW);
2920
2921     #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
2922     
2923     rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_GPIO1C4);
2924     gpio_request(RK29_PIN1_PC4, "mmc1-data1");
2925     gpio_direction_output(RK29_PIN1_PC4,GPIO_LOW);//set mmc1-data1 to low.
2926
2927     rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_GPIO1C5);
2928     gpio_request(RK29_PIN1_PC5, "mmc1-data2");
2929     gpio_direction_output(RK29_PIN1_PC5,GPIO_LOW);//set mmc1-data2 to low.
2930
2931     rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_GPIO1C6);
2932     gpio_request(RK29_PIN1_PC6, "mmc1-data3");
2933     gpio_direction_output(RK29_PIN1_PC6,GPIO_LOW);//set mmc1-data3 to low.
2934     
2935     rk29_sdmmc_gpio_open(1, 0); //added by xbw at 2011-10-13
2936     #endif    
2937     pr_info("%s: init finished\n",__func__);
2938
2939     return 0;
2940 }
2941
2942 static int rk29sdk_wifi_power(int on)
2943 {
2944         pr_info("%s: %d\n", __func__, on);
2945         if (on){
2946                 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
2947
2948                 #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)      
2949                 rk29_sdmmc_gpio_open(1, 1); //added by xbw at 2011-10-13
2950                 #endif
2951
2952                 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
2953                 mdelay(100);
2954                 pr_info("wifi turn on power\n");
2955         }else{
2956                 if (!rk29sdk_bt_power_state){
2957                         gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
2958
2959                         #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)      
2960                         rk29_sdmmc_gpio_open(1, 0); //added by xbw at 2011-10-13
2961                         #endif
2962                         
2963                         mdelay(100);
2964                         pr_info("wifi shut off power\n");
2965                 }else
2966                 {
2967                         pr_info("wifi shouldn't shut off power, bt is using it!\n");
2968                 }
2969                 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
2970
2971         }
2972
2973         rk29sdk_wifi_power_state = on;
2974         return 0;
2975 }
2976
2977 static int rk29sdk_wifi_reset_state;
2978 static int rk29sdk_wifi_reset(int on)
2979 {
2980         pr_info("%s: %d\n", __func__, on);
2981         gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
2982         mdelay(100);
2983         rk29sdk_wifi_reset_state = on;
2984         return 0;
2985 }
2986
2987 int rk29sdk_wifi_set_carddetect(int val)
2988 {
2989         pr_info("%s:%d\n", __func__, val);
2990         rk29sdk_wifi_cd = val;
2991         if (wifi_status_cb){
2992                 wifi_status_cb(val, wifi_status_cb_devid);
2993         }else {
2994                 pr_warning("%s, nobody to notify\n", __func__);
2995         }
2996         return 0;
2997 }
2998 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
2999
3000 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
3001         {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
3002         {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
3003         {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
3004         {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
3005 };
3006
3007 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
3008 {
3009         if (section == PREALLOC_WLAN_SEC_NUM)
3010                 return wlan_static_skb;
3011
3012         if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
3013                 return NULL;
3014
3015         if (wifi_mem_array[section].size < size)
3016                 return NULL;
3017
3018         return wifi_mem_array[section].mem_ptr;
3019 }
3020
3021 int __init rk29sdk_init_wifi_mem(void)
3022 {
3023         int i;
3024         int j;
3025
3026         for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
3027                 wlan_static_skb[i] = dev_alloc_skb(
3028                                 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
3029
3030                 if (!wlan_static_skb[i])
3031                         goto err_skb_alloc;
3032         }
3033
3034         for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
3035                 wifi_mem_array[i].mem_ptr =
3036                                 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
3037
3038                 if (!wifi_mem_array[i].mem_ptr)
3039                         goto err_mem_alloc;
3040         }
3041         return 0;
3042
3043 err_mem_alloc:
3044         pr_err("Failed to mem_alloc for WLAN\n");
3045         for (j = 0 ; j < i ; j++)
3046                kfree(wifi_mem_array[j].mem_ptr);
3047
3048         i = WLAN_SKB_BUF_NUM;
3049
3050 err_skb_alloc:
3051         pr_err("Failed to skb_alloc for WLAN\n");
3052         for (j = 0 ; j < i ; j++)
3053                 dev_kfree_skb(wlan_static_skb[j]);
3054
3055         return -ENOMEM;
3056 }
3057
3058 static struct wifi_platform_data rk29sdk_wifi_control = {
3059         .set_power = rk29sdk_wifi_power,
3060         .set_reset = rk29sdk_wifi_reset,
3061         .set_carddetect = rk29sdk_wifi_set_carddetect,
3062         .mem_prealloc   = rk29sdk_mem_prealloc,
3063 };
3064 static struct platform_device rk29sdk_wifi_device = {
3065         .name = "bcm4329_wlan",
3066         .id = 1,
3067         .dev = {
3068                 .platform_data = &rk29sdk_wifi_control,
3069          },
3070 };
3071 #endif
3072
3073
3074 /* bluetooth rfkill device */
3075 static struct platform_device rk29sdk_rfkill = {
3076         .name = "rk29sdk_rfkill",
3077         .id = -1,
3078 };
3079
3080
3081 #ifdef CONFIG_VIVANTE
3082 static struct resource resources_gpu[] = {
3083     [0] = {
3084                 .name   = "gpu_irq",
3085         .start  = IRQ_GPU,
3086         .end    = IRQ_GPU,
3087         .flags  = IORESOURCE_IRQ,
3088     },
3089     [1] = {
3090                 .name = "gpu_base",
3091         .start  = RK29_GPU_PHYS,
3092         .end    = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
3093         .flags  = IORESOURCE_MEM,
3094     },
3095     [2] = {
3096                 .name = "gpu_mem",
3097         .start  = PMEM_GPU_BASE,
3098         .end    = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
3099         .flags  = IORESOURCE_MEM,
3100     },
3101 };
3102 static struct platform_device rk29_device_gpu = {
3103     .name             = "galcore",
3104     .id               = 0,
3105     .num_resources    = ARRAY_SIZE(resources_gpu),
3106     .resource         = resources_gpu,
3107 };
3108 #endif
3109 #ifdef CONFIG_KEYS_RK29
3110 extern struct rk29_keys_platform_data rk29_keys_pdata;
3111 static struct platform_device rk29_device_keys = {
3112         .name           = "rk29-keypad",
3113         .id             = -1,
3114         .dev            = {
3115                 .platform_data  = &rk29_keys_pdata,
3116         },
3117 };
3118 #endif
3119
3120 #if CONFIG_ANDROID_TIMED_GPIO
3121 static struct timed_gpio timed_gpios[] = {
3122         {
3123                 .name = "vibrator",
3124                 .gpio = RK29_PIN1_PB5,
3125                 .max_timeout = 1000,
3126                 .active_low = 0,
3127                 .adjust_time =20,      //adjust for diff product
3128         },
3129 };
3130
3131 struct timed_gpio_platform_data rk29_vibrator_info = {
3132         .num_gpios = 1,
3133         .gpios = timed_gpios,
3134 };
3135
3136 struct platform_device rk29_device_vibrator ={
3137         .name = "timed-gpio",
3138         .id = -1,
3139         .dev = {
3140                 .platform_data = &rk29_vibrator_info,
3141                 },
3142
3143 };
3144 #endif 
3145
3146 static void __init rk29_board_iomux_init(void)
3147 {
3148         int err;
3149
3150 #ifdef CONFIG_UART1_RK29
3151         //disable uart1 pull down
3152         rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_GPIO2A5);                       
3153         rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_GPIO2A4);                
3154
3155         gpio_request(RK29_PIN2_PA5, NULL);
3156         gpio_request(RK29_PIN2_PA4, NULL);
3157
3158         gpio_pull_updown(RK29_PIN2_PA5, PullDisable);
3159         gpio_pull_updown(RK29_PIN2_PA4, PullDisable);
3160
3161         rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);                    
3162         rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN); 
3163
3164         gpio_free(RK29_PIN2_PA5);
3165         gpio_free(RK29_PIN2_PA4);
3166 #endif
3167
3168         #if CONFIG_ANDROID_TIMED_GPIO
3169         rk29_mux_api_set(GPIO1B5_PWM0_NAME, GPIO1L_GPIO1B5);//for timed gpio
3170         #endif
3171         #ifdef CONFIG_RK29_PWM_REGULATOR
3172         rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
3173         #endif
3174         #ifdef CONFIG_RK_HEADSET_DET
3175         rk29_mux_api_set(GPIO3A6_SMCADDR14_HOSTDATA14_NAME,GPIO3L_GPIO3A6);
3176         #endif
3177         
3178         rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME,GPIO4H_GPIO4C0);
3179
3180         err = gpio_request(RK29_PIN4_PC0, "clk27M_control");
3181         if (err) {
3182                 gpio_free(RK29_PIN4_PC0);
3183                 printk("-------request RK29_PIN4_PC0 fail--------\n");
3184                 return -1;
3185         }
3186         //phy power down
3187
3188         #if defined (CONFIG_RK29_WORKING_POWER_MANAGEMENT)
3189         gpio_direction_output(RK29_PIN4_PC0, GPIO_HIGH);
3190         gpio_set_value(RK29_PIN4_PC0, GPIO_HIGH);
3191         #else
3192         gpio_direction_output(RK29_PIN4_PC0, GPIO_LOW);
3193         gpio_set_value(RK29_PIN4_PC0, GPIO_LOW);
3194         #endif
3195
3196         rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME,GPIO4H_GPIO4C5);
3197
3198         err = gpio_request(RK29_PIN4_PC5, "clk24M_control");
3199         if (err) {
3200                 gpio_free(RK29_PIN4_PC5);
3201                 printk("-------request RK29_PIN4_PC5 fail--------\n");
3202                 return -1;
3203         }
3204         //phy power down
3205         gpio_direction_output(RK29_PIN4_PC5, GPIO_LOW);
3206         gpio_set_value(RK29_PIN4_PC5, GPIO_LOW);        
3207 }
3208
3209 // For phone,just a disk only, add by phc,20110816
3210 #ifdef CONFIG_USB_ANDROID
3211 struct usb_mass_storage_platform_data phone_mass_storage_pdata = {
3212         .nluns          = 1,  
3213         .vendor         = "RockChip",
3214         .product        = "rk29 sdk",
3215         .release        = 0x0100,
3216 };
3217
3218 //static 
3219 struct platform_device phone_usb_mass_storage_device = {
3220         .name   = "usb_mass_storage",
3221         .id     = -1,
3222         .dev    = {
3223                 .platform_data = &phone_mass_storage_pdata,
3224         },
3225 };
3226 #endif
3227
3228 #ifdef CONFIG_RK29_CHARGE_EARLYSUSPEND
3229
3230 struct platform_device charge_lowerpower_device = {
3231         .name   = "charge_lowerpower",
3232         .id     = -1,
3233 };
3234 #endif
3235
3236 static struct platform_device *devices[] __initdata = {
3237 #ifdef CONFIG_UART1_RK29
3238         &rk29_device_uart1,
3239 #endif
3240 #ifdef CONFIG_UART0_RK29
3241         &rk29_device_uart0,
3242 #endif
3243 #ifdef CONFIG_UART2_RK29
3244         &rk29_device_uart2,
3245 #endif
3246 #ifdef CONFIG_UART3_RK29
3247         &rk29_device_uart3,
3248 #endif
3249
3250 #ifdef CONFIG_RK29_PWM_REGULATOR
3251         &rk29_device_pwm_regulator,
3252 #endif
3253 #ifdef CONFIG_SPIM0_RK29
3254     &rk29xx_device_spi0m,
3255 #endif
3256 #ifdef CONFIG_SPIM1_RK29
3257     &rk29xx_device_spi1m,
3258 #endif
3259 #ifdef CONFIG_ADC_RK29
3260         &rk29_device_adc,
3261 #endif
3262 #ifdef CONFIG_I2C0_RK29
3263         &rk29_device_i2c0,
3264 #endif
3265 #ifdef CONFIG_I2C1_RK29
3266         &rk29_device_i2c1,
3267 #endif
3268 #ifdef CONFIG_I2C2_RK29
3269         &rk29_device_i2c2,
3270 #endif
3271 #ifdef CONFIG_I2C3_RK29
3272         &rk29_device_i2c3,
3273 #endif
3274
3275 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
3276         &rk29_device_iis_2ch,
3277 #endif
3278 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
3279         &rk29_device_iis_8ch,
3280 #endif
3281
3282 #ifdef CONFIG_KEYS_RK29
3283         &rk29_device_keys,
3284 #endif
3285 #ifdef CONFIG_SDMMC0_RK29
3286         &rk29_device_sdmmc0,
3287 #endif
3288 #ifdef CONFIG_SDMMC1_RK29
3289         &rk29_device_sdmmc1,
3290 #endif
3291
3292 #ifdef CONFIG_MTD_NAND_RK29XX
3293         &rk29xx_device_nand,
3294 #endif
3295
3296 #ifdef CONFIG_WIFI_CONTROL_FUNC
3297         &rk29sdk_wifi_device,
3298 #endif
3299
3300 #ifdef CONFIG_BT
3301         &rk29sdk_rfkill,
3302 #endif
3303
3304 #if defined(CONFIG_MTK23D)
3305         &rk2818_device_mtk23d,
3306 #endif
3307
3308 #ifdef CONFIG_MTD_NAND_RK29
3309         &rk29_device_nand,
3310 #endif
3311
3312 #ifdef CONFIG_FB_RK29
3313         &rk29_device_fb,
3314         &rk29_device_dma_cpy,
3315 #endif
3316 #ifdef CONFIG_BACKLIGHT_RK29_BL
3317         &rk29_device_backlight,
3318 #endif
3319 #ifdef CONFIG_RK29_VMAC
3320         &rk29_device_vmac,
3321 #endif
3322 #ifdef CONFIG_VIVANTE
3323         &rk29_device_gpu,
3324 #endif
3325 #ifdef CONFIG_VIDEO_RK29
3326         &rk29_device_camera,      /* ddl@rock-chips.com : camera support  */
3327         #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
3328         &rk29_soc_camera_pdrv_0,
3329         #endif
3330         &rk29_soc_camera_pdrv_1,
3331         &android_pmem_cam_device,
3332 #endif
3333         &android_pmem_device,
3334         &rk29_vpu_mem_device,
3335 #ifdef CONFIG_USB20_OTG
3336         &rk29_device_usb20_otg,
3337 #endif
3338 #ifdef CONFIG_USB20_HOST
3339         &rk29_device_usb20_host,
3340 #endif
3341 #ifdef CONFIG_USB11_HOST
3342         &rk29_device_usb11_host,
3343 #endif
3344 #ifdef CONFIG_USB_ANDROID
3345         &android_usb_device,
3346         &phone_usb_mass_storage_device,
3347 #endif
3348 #ifdef CONFIG_RK29_IPP
3349         &rk29_device_ipp,
3350 #endif
3351 #ifdef CONFIG_VIDEO_RK29XX_VOUT
3352         &rk29_v4l2_output_devce,
3353 #endif
3354 #ifdef CONFIG_RK_HEADSET_DET
3355     &rk_device_headset,
3356 #endif
3357 #ifdef CONFIG_RK29_GPS
3358         &rk29_device_gps,
3359 #endif
3360 #ifdef CONFIG_ANDROID_TIMED_GPIO
3361         &rk29_device_vibrator,
3362 #endif
3363 };
3364
3365 #ifdef CONFIG_RK29_VMAC
3366 /*****************************************************************************************
3367  * vmac devices
3368  * author: lyx@rock-chips.com
3369  *****************************************************************************************/
3370 static int rk29_vmac_register_set(void)
3371 {
3372         //config rk29 vmac as rmii, 100MHz
3373         u32 value= readl(RK29_GRF_BASE + 0xbc);
3374         value = (value & 0xfff7ff) | (0x400);
3375         writel(value, RK29_GRF_BASE + 0xbc);
3376         return 0;
3377 }
3378
3379 static int rk29_rmii_io_init(void)
3380 {
3381         int err;
3382
3383         //phy power gpio
3384         err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
3385         if (err) {
3386                 gpio_free(RK29_PIN6_PB0);
3387                 printk("-------request RK29_PIN6_PB0 fail--------\n");
3388                 return -1;
3389         }
3390         //phy power down
3391         gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
3392         gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
3393
3394         return 0;
3395 }
3396
3397 static int rk29_rmii_io_deinit(void)
3398 {
3399         //phy power down
3400         gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
3401         gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
3402         //free
3403         gpio_free(RK29_PIN6_PB0);
3404         return 0;
3405 }
3406
3407 static int rk29_rmii_power_control(int enable)
3408 {
3409         if (enable) {
3410                 //enable phy power
3411                 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
3412                 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
3413         }
3414         else {
3415                 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
3416                 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
3417         }
3418         return 0;
3419 }
3420
3421 struct rk29_vmac_platform_data rk29_vmac_pdata = {
3422         .vmac_register_set = rk29_vmac_register_set,
3423         .rmii_io_init = rk29_rmii_io_init,
3424         .rmii_io_deinit = rk29_rmii_io_deinit,
3425         .rmii_power_control = rk29_rmii_power_control,
3426 };
3427 #endif
3428
3429 /*****************************************************************************************
3430  * spi devices
3431  * author: cmc@rock-chips.com
3432  *****************************************************************************************/
3433 #define SPI_CHIPSELECT_NUM 2
3434 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
3435     {
3436                 .name = "spi0 cs0",
3437                 .cs_gpio = RK29_PIN2_PC1,
3438                 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
3439                 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
3440         },
3441         {
3442                 .name = "spi0 cs1",
3443                 .cs_gpio = RK29_PIN1_PA4,
3444                 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
3445                 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
3446         }
3447 };
3448
3449 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
3450     {
3451                 .name = "spi1 cs0",
3452                 .cs_gpio = RK29_PIN2_PC5,
3453                 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
3454                 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
3455         },
3456         {
3457                 .name = "spi1 cs1",
3458                 .cs_gpio = RK29_PIN1_PA3,
3459                 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
3460                 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
3461         }
3462 };
3463
3464 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
3465 {
3466 #if 1
3467                 int i;
3468                 if (cs_gpios) {
3469                         for (i=0; i<cs_num; i++) {
3470                                 rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
3471                         }
3472                 }
3473 #endif
3474         return 0;
3475 }
3476
3477 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
3478 {
3479         return 0;
3480 }
3481
3482 static int spi_io_fix_leakage_bug(void)
3483 {
3484 #if 0
3485         gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
3486 #endif
3487         return 0;
3488 }
3489
3490 static int spi_io_resume_leakage_bug(void)
3491 {
3492 #if 0
3493         gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
3494 #endif
3495         return 0;
3496 }
3497
3498 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
3499         .num_chipselect = SPI_CHIPSELECT_NUM,
3500         .chipselect_gpios = rk29xx_spi0_cs_gpios,
3501         .io_init = spi_io_init,
3502         .io_deinit = spi_io_deinit,
3503         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
3504         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
3505 };
3506
3507 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
3508         .num_chipselect = SPI_CHIPSELECT_NUM,
3509         .chipselect_gpios = rk29xx_spi1_cs_gpios,
3510         .io_init = spi_io_init,
3511         .io_deinit = spi_io_deinit,
3512         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
3513         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
3514 };
3515
3516
3517 /*****************************************************************************************
3518  * xpt2046 touch panel
3519  * author: hhb@rock-chips.com
3520  *****************************************************************************************/
3521 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
3522 #define XPT2046_GPIO_INT           RK29_PIN4_PD5 //中断???#define DEBOUNCE_REPTIME  3
3523
3524 static struct xpt2046_platform_data xpt2046_info = {
3525         .model                  = 2046,
3526         .keep_vref_on   = 1,
3527         .swap_xy                = 0,
3528         .debounce_max           = 7,
3529         .debounce_rep           = DEBOUNCE_REPTIME,
3530         .debounce_tol           = 20,
3531         .gpio_pendown           = XPT2046_GPIO_INT,
3532         .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME, 
3533         .pendown_iomux_mode = GPIO4H_GPIO4D5,   
3534         .touch_virtualkey_length = 60,
3535         .penirq_recheck_delay_usecs = 1,
3536 #if defined(CONFIG_TOUCHSCREEN_480X800)
3537         .x_min                  = 0,
3538         .x_max                  = 480,
3539         .y_min                  = 0,
3540         .y_max                  = 800,
3541         .touch_ad_top = 3940,
3542         .touch_ad_bottom = 310,
3543         .touch_ad_left = 3772,
3544         .touch_ad_right = 340,
3545 #elif defined(CONFIG_TOUCHSCREEN_800X480)
3546         .x_min                  = 0,
3547         .x_max                  = 800,
3548         .y_min                  = 0,
3549         .y_max                  = 480,
3550         .touch_ad_top = 2447,
3551         .touch_ad_bottom = 207,
3552         .touch_ad_left = 5938,
3553         .touch_ad_right = 153,
3554 #elif defined(CONFIG_TOUCHSCREEN_320X480)
3555         .x_min                  = 0,
3556         .x_max                  = 320,
3557         .y_min                  = 0,
3558         .y_max                  = 480,
3559         .touch_ad_top = 3166,
3560         .touch_ad_bottom = 256,
3561         .touch_ad_left = 3658,
3562         .touch_ad_right = 380,
3563 #endif  
3564 };
3565 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
3566 static struct xpt2046_platform_data xpt2046_info = {
3567         .model                  = 2046,
3568         .keep_vref_on   = 1,
3569         .swap_xy                = 0,
3570         .debounce_max           = 7,
3571         .debounce_rep           = DEBOUNCE_REPTIME,
3572         .debounce_tol           = 20,
3573         .gpio_pendown           = XPT2046_GPIO_INT,
3574         .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME, 
3575         .pendown_iomux_mode = GPIO4H_GPIO4D5,   
3576         .touch_virtualkey_length = 60,
3577         .penirq_recheck_delay_usecs = 1,
3578         
3579 #if defined(CONFIG_TOUCHSCREEN_480X800)
3580         .x_min                  = 0,
3581         .x_max                  = 480,
3582         .y_min                  = 0,
3583         .y_max                  = 800,
3584         .screen_x = { 70,  410, 70, 410, 240},
3585         .screen_y = { 50, 50,  740, 740, 400},
3586         .uncali_x_default = {  3267,  831, 3139, 715, 1845 },
3587         .uncali_y_default = { 3638,  3664, 564,  591, 2087 },
3588 #elif defined(CONFIG_TOUCHSCREEN_800X480)
3589         .x_min                  = 0,
3590         .x_max                  = 800,
3591         .y_min                  = 0,
3592         .y_max                  = 480,
3593         .screen_x[5] = { 50, 750,  50, 750, 400};
3594         .screen_y[5] = { 40,  40, 440, 440, 240};
3595         .uncali_x_default[5] = { 438,  565, 3507,  3631, 2105 };
3596         .uncali_y_default[5] = {  3756,  489, 3792, 534, 2159 };
3597 #elif defined(CONFIG_TOUCHSCREEN_320X480)
3598         .x_min                  = 0,
3599         .x_max                  = 320,
3600         .y_min                  = 0,
3601         .y_max                  = 480,
3602         .screen_x[5] = { 50, 270,  50, 270, 160}; 
3603         .screen_y[5] = { 40,  40, 440, 440, 240}; 
3604         .uncali_x_default[5] = { 812,  3341, 851,  3371, 2183 };
3605         .uncali_y_default[5] = {  442,  435, 3193, 3195, 2004 };
3606 #endif  
3607 };
3608 #endif
3609
3610 static struct spi_board_info board_spi_devices[] = {
3611 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
3612         {
3613                 .modalias       = "xpt2046_ts",
3614                 .chip_select    = 0,// 2,
3615                 .max_speed_hz   = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
3616                 .bus_num        = 0,
3617                 .irq = XPT2046_GPIO_INT,
3618                 .platform_data = &xpt2046_info,
3619         },
3620 #endif
3621
3622 #if defined(CONFIG_MFD_WM831X_SPI)
3623         {
3624                 .modalias       = "wm8310",
3625                 .chip_select    = 1,
3626                 .max_speed_hz   = 2*1000*1000,
3627                 .bus_num        = 1,
3628                 .irq            = RK29_PIN4_PD0,
3629                 .platform_data = &wm831x_platdata,
3630         },
3631 #endif
3632
3633 };
3634
3635
3636 /**********************************************************************************************
3637  *
3638  * The virtual keys for android "back", "home", "menu", "search", these four keys are touch key
3639  * on the touch screen panel. (added by hhb@rock-chips.com 2011.03.31)
3640  *
3641  ***********************************************************************************************/
3642 static ssize_t rk29xx_virtual_keys_show(struct kobject *kobj,
3643                         struct kobj_attribute *attr, char *buf)
3644 {
3645 #if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
3646         || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC) \
3647          || defined (CONFIG_TOUCHSCREEN_GT801_Z5)
3648         /* center: x: home: 50, menu: 184, back: 315, search 435, y: 830*/
3649     /* centerx;centery;width;height; */
3650         return sprintf(buf,
3651                 __stringify(EV_KEY) ":" __stringify(KEY_BACK)           ":300:860:120:60"//":315:815:120:50"     //":50:830:98:50"      //":210:796:98:50"
3652                 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU)       ":60:860:120:60"//":85:815:88:50"       // ":184:830:120:50"  // ":435:796:120:50"
3653                 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME)       ":180:860:120:60"//":184:815:100:50"   //":315:830:100:50"      //":320:796:100:50"
3654                 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:860:120:60"//":435:815:88:50"   //":50:815:98:50"    //       //":85:796:88:50"
3655                 "\n");
3656
3657 #elif defined (CONFIG_TOUCHSCREEN_FT5306)
3658                 return sprintf(buf,
3659                 __stringify(EV_KEY) ":" __stringify(KEY_BACK)                   ":400:830:120:60"//":315:815:120:50"     //":50:830:98:50"      //":210:796:98:50"
3660                 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU)               ":80:830:120:60"//":85:815:88:50"       // ":184:830:120:50"  // ":435:796:120:50"
3661                 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME)               ":240:830:120:60"//":184:815:100:50"   //":315:830:100:50"      //":320:796:100:50"
3662                 "\n");
3663 #endif
3664         return 0;
3665 }
3666
3667 static struct kobj_attribute rk29xx_virtual_keys_attr = {
3668         .attr = {
3669 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
3670                 .name = "virtualkeys.xpt2046-touchscreen",
3671 #elif defined(CONFIG_TOUCHSCREEN_HX8520_IIC)
3672         .name = "virtualkeys.hx8520-touchscreen",
3673 #elif defined(CONFIG_TOUCHSCREEN_GT801_IIC) || defined (CONFIG_TOUCHSCREEN_GT801_Z5)
3674                 .name = "virtualkeys.gt801-touchscreen",
3675 #elif defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
3676                 .name = "virtualkeys.ili2102-touchscreen",              
3677 #elif defined (CONFIG_TOUCHSCREEN_FT5306)
3678                 .name = "virtualkeys.ft5x0x_ts-touchscreen",
3679 #else
3680                 .name = "virtualkeys",
3681 #endif
3682                 .mode = S_IRUGO,
3683         },
3684         .show = &rk29xx_virtual_keys_show,
3685 };
3686
3687 static struct attribute *rk29xx_properties_attrs[] = {
3688         &rk29xx_virtual_keys_attr.attr,
3689         NULL
3690 };
3691
3692 static struct attribute_group rk29xx_properties_attr_group = {
3693         .attrs = rk29xx_properties_attrs,
3694 };
3695 static int rk29xx_virtual_keys_init(void)
3696 {
3697         int ret;
3698         struct kobject *properties_kobj;
3699         printk("rk29xx_virtual_keys_init \n");
3700         properties_kobj = kobject_create_and_add("board_properties", NULL);
3701         if (properties_kobj)
3702                 ret = sysfs_create_group(properties_kobj,
3703                                 &rk29xx_properties_attr_group);
3704         if (!properties_kobj || ret)
3705         {
3706                 pr_err("failed to create board_properties\n");
3707         }
3708         return ret;
3709 }
3710
3711
3712 static void __init rk29_gic_init_irq(void)
3713 {
3714 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38))
3715         gic_init(0, 32, (void __iomem *)RK29_GICPERI_BASE, (void __iomem *)RK29_GICCPU_BASE);
3716 #else
3717         gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
3718         gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
3719 #endif
3720 }
3721
3722 static void __init machine_rk29_init_irq(void)
3723 {
3724         rk29_gic_init_irq();
3725         rk29_gpio_init();
3726 }
3727
3728 #define POWER_ON_PIN RK29_PIN4_PA4
3729
3730 static void rk29_pm_power_restart(void)
3731 {
3732         printk("%s,line=%d\n",__FUNCTION__,__LINE__);
3733         mdelay(2);
3734 #if defined(CONFIG_MFD_WM831X)
3735         wm831x_device_restart(gWm831x);
3736 #endif
3737
3738 }
3739
3740 static void rk29_pm_power_off(void)
3741 {
3742         printk(KERN_ERR "rk29_pm_power_off start...\n");
3743         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
3744 #if defined(CONFIG_MFD_WM831X)
3745         if(wm831x_read_usb(gWm831x))
3746         rk29_pm_power_restart();        //if charging then restart
3747         else
3748         wm831x_device_shutdown(gWm831x);//else shutdown
3749 #endif
3750         while (1);
3751 }
3752
3753
3754 static struct cpufreq_frequency_table freq_table[] =
3755 {
3756         { .index = 1100000, .frequency =  408000 },
3757         { .index = 1150000, .frequency =  600000 },
3758         { .index = 1200000, .frequency =  816000 },
3759         { .index = 1300000, .frequency = 1008000 },
3760         { .frequency = CPUFREQ_TABLE_END },
3761 };
3762
3763 static void __init machine_rk29_board_init(void)
3764 {
3765         rk29_board_iomux_init();
3766
3767         gpio_request(POWER_ON_PIN,"poweronpin");
3768         gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
3769         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
3770         pm_power_off = rk29_pm_power_off;
3771         //arm_pm_restart = rk29_pm_power_restart;
3772
3773         board_update_cpufreq_table(freq_table);
3774
3775         platform_add_devices(devices, ARRAY_SIZE(devices));
3776 #ifdef CONFIG_I2C0_RK29
3777         i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
3778                         ARRAY_SIZE(board_i2c0_devices));
3779 #endif
3780 #ifdef CONFIG_I2C1_RK29
3781         i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
3782                         ARRAY_SIZE(board_i2c1_devices));
3783 #endif
3784 #ifdef CONFIG_I2C2_RK29
3785         i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
3786                         ARRAY_SIZE(board_i2c2_devices));
3787 #endif
3788 #ifdef CONFIG_I2C3_RK29
3789         i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
3790                         ARRAY_SIZE(board_i2c3_devices));
3791 #endif
3792
3793         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
3794
3795 #ifdef CONFIG_WIFI_CONTROL_FUNC
3796         rk29sdk_wifi_bt_gpio_control_init();
3797         rk29sdk_init_wifi_mem();
3798 #endif
3799
3800 #if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
3801         || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC) \
3802          || defined (CONFIG_TOUCHSCREEN_GT801_Z5) || defined (CONFIG_TOUCHSCREEN_FT5306)
3803         rk29xx_virtual_keys_init();
3804 #endif
3805
3806 }
3807
3808 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
3809                                         char **cmdline, struct meminfo *mi)
3810 {
3811         mi->nr_banks = 1;
3812         mi->bank[0].start = RK29_SDRAM_PHYS;
3813         mi->bank[0].size = LINUX_SIZE;
3814 #if SDRAM_SIZE > SZ_512M
3815         mi->nr_banks = 2;
3816         mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
3817         mi->bank[1].size = SDRAM_SIZE - SZ_512M;
3818 #endif
3819 }
3820
3821 static void __init machine_rk29_mapio(void)
3822 {
3823         rk29_map_common_io();
3824         rk29_setup_early_printk();
3825         rk29_sram_init();
3826         rk29_clock_init2(periph_pll_96mhz, codec_pll_300mhz, false);
3827         rk29_iomux_init();
3828         ddr_init(DDR_TYPE, DDR_FREQ);
3829 }
3830
3831 MACHINE_START(RK29, "RK29board")
3832         /* UART for LL DEBUG */
3833 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37))
3834         /* UART for LL DEBUG */
3835         .phys_io        = RK29_UART1_PHYS & 0xfff00000,
3836         .io_pg_offst    = ((RK29_UART1_BASE) >> 18) & 0xfffc,
3837 #endif
3838         .boot_params    = RK29_SDRAM_PHYS + 0x88000,
3839         .fixup          = machine_rk29_fixup,
3840         .map_io         = machine_rk29_mapio,
3841         .init_irq       = machine_rk29_init_irq,
3842         .init_machine   = machine_rk29_board_init,
3843         .timer          = &rk29_timer,
3844 MACHINE_END