ddr3sdk: fix "TOUCH_SCREEN_DISPLAY_PIN gpio_request err" warning
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk29 / board-rk29-ddr3sdk.c
1 /* arch/arm/mach-rk29/board-rk29.c
2  *
3  * Copyright (C) 2010 ROCKCHIP, Inc.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
20 #include <linux/io.h>
21 #include <linux/delay.h>
22 #include <linux/i2c.h>
23 #include <linux/spi/spi.h>
24 #include <linux/mmc/host.h>
25 #include <linux/android_pmem.h>
26 #include <linux/usb/android_composite.h>
27
28 #include <mach/hardware.h>
29 #include <asm/setup.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/flash.h>
34 #include <asm/hardware/gic.h>
35
36 #include <mach/iomux.h>
37 #include <mach/gpio.h>
38 #include <mach/irqs.h>
39 #include <mach/rk29_iomap.h>
40 #include <mach/board.h>
41 #include <mach/rk29_nand.h>
42 #include <mach/rk29_camera.h>                          /* ddl@rock-chips.com : camera support */
43 #include <media/soc_camera.h>                               /* ddl@rock-chips.com : camera support */
44 #include <mach/vpu_mem.h>
45 #include <mach/sram.h>
46 #include <mach/ddr.h>
47 #include <mach/cpufreq.h>
48 #include <mach/rk29_smc.h>
49
50 #include <linux/regulator/rk29-pwm-regulator.h>
51 #include <linux/regulator/machine.h>
52
53 #include <linux/mtd/nand.h>
54 #include <linux/mtd/partitions.h>
55 #include <linux/i2c-gpio.h>
56
57 #include "devices.h"
58 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
59
60 #ifdef CONFIG_BU92747GUW_CIR
61 #include "../../../drivers/cir/bu92747guw_cir.h"
62 #endif
63 #ifdef CONFIG_VIDEO_RK29
64 /*---------------- Camera Sensor Macro Define Begin  ------------------------*/
65 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
66 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642                      /* back camera sensor */
67 #define CONFIG_SENSOR_IIC_ADDR_0            0x78
68 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0    1
69 #define CONFIG_SENSOR_POWER_PIN_0         INVALID_GPIO
70 #define CONFIG_SENSOR_RESET_PIN_0         INVALID_GPIO
71 #define CONFIG_SENSOR_POWERDN_PIN_0       RK29_PIN6_PB7
72 #define CONFIG_SENSOR_FALSH_PIN_0         INVALID_GPIO
73 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
74 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
75 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
76 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
77
78 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659                      /* front camera sensor */
79 #define CONFIG_SENSOR_IIC_ADDR_1            0x60
80 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    1
81 #define CONFIG_SENSOR_POWER_PIN_1         INVALID_GPIO
82 #define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
83 #define CONFIG_SENSOR_POWERDN_PIN_1       RK29_PIN5_PD7
84 #define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
85 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
86 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
87 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
88 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
89 #endif  //#ifdef CONFIG_VIDEO_RK29
90 /*---------------- Camera Sensor Configuration Macro End------------------------*/
91 #include "../../../drivers/media/video/rk29_camera.c"
92 /*---------------- Camera Sensor Macro Define End  ------------------------*/
93
94
95 /* Set memory size of pmem */
96 #ifdef CONFIG_RK29_MEM_SIZE_M
97 #define SDRAM_SIZE          (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
98 #else
99 #define SDRAM_SIZE          SZ_512M
100 #endif
101 #define PMEM_GPU_SIZE       SZ_64M
102 #define PMEM_UI_SIZE        SZ_32M
103 #define PMEM_VPU_SIZE       SZ_64M
104 #define PMEM_SKYPE_SIZE     0
105 #define PMEM_CAM_SIZE       PMEM_CAM_NECESSARY
106 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
107 #define MEM_CAMIPP_SIZE     SZ_4M
108 #else
109 #define MEM_CAMIPP_SIZE     0
110 #endif
111 #define MEM_FB_SIZE         (9*SZ_1M)
112 #ifdef CONFIG_FB_WORK_IPP
113 #define MEM_FBIPP_SIZE      SZ_8M   //1920 x 1080 x 2 x 2  //RGB565 = x2;RGB888 = x4
114 #else
115 #define MEM_FBIPP_SIZE      0
116 #endif
117 #if SDRAM_SIZE > SZ_512M
118 #define PMEM_GPU_BASE       (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
119 #else
120 #define PMEM_GPU_BASE       (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
121 #endif
122 #define PMEM_UI_BASE        (PMEM_GPU_BASE - PMEM_UI_SIZE)
123 #define PMEM_VPU_BASE       (PMEM_UI_BASE - PMEM_VPU_SIZE)
124 #define PMEM_CAM_BASE       (PMEM_VPU_BASE - PMEM_CAM_SIZE)
125 #define MEM_CAMIPP_BASE     (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
126 #define MEM_FB_BASE         (MEM_CAMIPP_BASE - MEM_FB_SIZE)
127 #define MEM_FBIPP_BASE      (MEM_FB_BASE - MEM_FBIPP_SIZE)
128 #define PMEM_SKYPE_BASE      (MEM_FBIPP_BASE - PMEM_SKYPE_SIZE)
129 #define LINUX_SIZE          (PMEM_SKYPE_BASE - RK29_SDRAM_PHYS)
130
131 #define PREALLOC_WLAN_SEC_NUM           4
132 #define PREALLOC_WLAN_BUF_NUM           160
133 #define PREALLOC_WLAN_SECTION_HEADER    24
134
135 #define WLAN_SECTION_SIZE_0     (PREALLOC_WLAN_BUF_NUM * 128)
136 #define WLAN_SECTION_SIZE_1     (PREALLOC_WLAN_BUF_NUM * 128)
137 #define WLAN_SECTION_SIZE_2     (PREALLOC_WLAN_BUF_NUM * 512)
138 #define WLAN_SECTION_SIZE_3     (PREALLOC_WLAN_BUF_NUM * 1024)
139
140 #define WLAN_SKB_BUF_NUM        16
141
142 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
143
144 struct wifi_mem_prealloc {
145         void *mem_ptr;
146         unsigned long size;
147 };
148
149 extern struct sys_timer rk29_timer;
150
151 static int rk29_nand_io_init(void)
152 {
153     return 0;
154 }
155
156 struct rk29_nand_platform_data rk29_nand_data = {
157     .width      = 1,     /* data bus width in bytes */
158     .hw_ecc     = 1,     /* hw ecc 0: soft ecc */
159     .num_flash    = 1,
160     .io_init   = rk29_nand_io_init,
161 };
162
163 #define TOUCH_SCREEN_STANDBY_PIN          RK29_PIN6_PD1
164 #define TOUCH_SCREEN_STANDBY_VALUE        GPIO_HIGH
165 #define TOUCH_SCREEN_DISPLAY_PIN          INVALID_GPIO
166 #define TOUCH_SCREEN_DISPLAY_VALUE        GPIO_HIGH
167 #ifdef CONFIG_FB_RK29
168 /*****************************************************************************************
169  * lcd  devices
170  * author: zyw@rock-chips.com
171  *****************************************************************************************/
172 //#ifdef  CONFIG_LCD_TD043MGEA1
173 #define LCD_TXD_PIN          INVALID_GPIO
174 #define LCD_CLK_PIN          INVALID_GPIO
175 #define LCD_CS_PIN           INVALID_GPIO
176 /*****************************************************************************************
177 * frame buffe  devices
178 * author: zyw@rock-chips.com
179 *****************************************************************************************/
180 #define FB_ID                       0
181 #define FB_DISPLAY_ON_PIN           INVALID_GPIO// RK29_PIN6_PD0
182 #define FB_LCD_STANDBY_PIN          INVALID_GPIO
183 #define FB_LCD_CABC_EN_PIN          RK29_PIN6_PD2
184 #define FB_MCU_FMK_PIN              INVALID_GPIO
185
186 #define FB_DISPLAY_ON_VALUE         GPIO_HIGH
187 #define FB_LCD_STANDBY_VALUE        GPIO_HIGH
188
189 static int rk29_lcd_io_init(void)
190 {
191     int ret = 0;
192     return ret;
193 }
194
195 static int rk29_lcd_io_deinit(void)
196 {
197     int ret = 0;
198     return ret;
199 }
200
201 static struct rk29lcd_info rk29_lcd_info = {
202     .txd_pin  = LCD_TXD_PIN,
203     .clk_pin = LCD_CLK_PIN,
204     .cs_pin = LCD_CS_PIN,
205     .io_init   = rk29_lcd_io_init,
206     .io_deinit = rk29_lcd_io_deinit,
207 };
208
209 int rk29_fb_io_enable(void)
210 {
211     if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
212     {
213         gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
214         gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);              
215     }
216     if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
217     {
218         gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
219         gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);             
220     }
221     return 0;
222 }
223
224 int rk29_fb_io_disable(void)
225 {
226     if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
227     {
228         gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
229         gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);              
230     }
231     if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
232     {
233         gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
234         gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);             
235     }
236     return 0;
237 }
238
239 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
240 {
241     int ret = 0;
242     if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
243     {
244         ret = gpio_request(FB_MCU_FMK_PIN, NULL);
245         if(ret != 0)
246         {
247             gpio_free(FB_MCU_FMK_PIN);
248             printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
249         }
250         gpio_direction_input(FB_MCU_FMK_PIN);
251     }
252     if(fb_setting->disp_on_en)
253     {
254         if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
255         {
256             ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
257             if(ret != 0)
258             {
259                 gpio_free(FB_DISPLAY_ON_PIN);
260                 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
261             }
262         }
263         else if (TOUCH_SCREEN_DISPLAY_PIN != INVALID_GPIO)
264         {
265              ret = gpio_request(TOUCH_SCREEN_DISPLAY_PIN, NULL);
266              if(ret != 0)
267              {
268                  gpio_free(TOUCH_SCREEN_DISPLAY_PIN);
269                  printk(">>>>>> TOUCH_SCREEN_DISPLAY_PIN gpio_request err \n ");
270              }
271              gpio_direction_output(TOUCH_SCREEN_DISPLAY_PIN, 0);
272              gpio_set_value(TOUCH_SCREEN_DISPLAY_PIN, TOUCH_SCREEN_DISPLAY_VALUE);
273         }
274     }
275
276     if(fb_setting->disp_on_en)
277     {
278         if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
279         {
280              ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
281              if(ret != 0)
282              {
283                  gpio_free(FB_LCD_STANDBY_PIN);
284                  printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
285              }
286         }
287         else if (TOUCH_SCREEN_STANDBY_PIN != INVALID_GPIO)
288         {
289              ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL);
290              if(ret != 0)
291              {
292                  gpio_free(TOUCH_SCREEN_STANDBY_PIN);
293                  printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n ");
294              }
295              gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0);
296              gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE);
297          }
298     }
299
300     if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
301     {
302         ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
303         if(ret != 0)
304         {
305             gpio_free(FB_LCD_CABC_EN_PIN);
306             printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
307         }
308         gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
309         gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
310     }
311     
312     rk29_fb_io_enable();   //enable it
313
314     return ret;
315 }
316
317
318 static struct rk29fb_info rk29_fb_info = {
319     .fb_id   = FB_ID,
320     .mcu_fmk_pin = FB_MCU_FMK_PIN,
321     .lcd_info = &rk29_lcd_info,
322     .io_init   = rk29_fb_io_init,
323     .io_enable = rk29_fb_io_enable,
324     .io_disable = rk29_fb_io_disable,
325 };
326
327 /* rk29 fb resource */
328 static struct resource rk29_fb_resource[] = {
329         [0] = {
330         .name  = "lcdc reg",
331                 .start = RK29_LCDC_PHYS,
332                 .end   = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
333                 .flags = IORESOURCE_MEM,
334         },
335         [1] = {
336             .name  = "lcdc irq",
337                 .start = IRQ_LCDC,
338                 .end   = IRQ_LCDC,
339                 .flags = IORESOURCE_IRQ,
340         },
341         [2] = {
342             .name   = "win1 buf",
343         .start  = MEM_FB_BASE,
344         .end    = MEM_FB_BASE + MEM_FB_SIZE - 1,
345         .flags  = IORESOURCE_MEM,
346     },
347     #ifdef CONFIG_FB_WORK_IPP
348     [3] = {
349             .name   = "win1 ipp buf",
350         .start  = MEM_FBIPP_BASE,
351         .end    = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
352         .flags  = IORESOURCE_MEM,
353     },
354     #endif
355 };
356
357 /*platform_device*/
358 struct platform_device rk29_device_fb = {
359         .name             = "rk29-fb",
360         .id               = 4,
361         .num_resources    = ARRAY_SIZE(rk29_fb_resource),
362         .resource         = rk29_fb_resource,
363         .dev            = {
364                 .platform_data  = &rk29_fb_info,
365         }
366 };
367
368 struct platform_device rk29_device_dma_cpy = {
369         .name             = "dma_memcpy",
370         .id               = 4,
371
372 };
373
374 #endif
375
376 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
377 #define BU92747GUW_RESET_PIN         RK29_PIN3_PD4// INVALID_GPIO //
378 #define BU92747GUW_RESET_MUX_NAME    GPIO3D4_HOSTWRN_NAME//NULL //
379 #define BU92747GUW_RESET_MUX_MODE    GPIO3H_GPIO3D4//NULL //
380
381 #define BU92747GUW_PWDN_PIN          RK29_PIN3_PD3//RK29_PIN5_PA7 //
382 #define BU92747GUW_PWDN_MUX_NAME     GPIO3D3_HOSTRDN_NAME//GPIO5A7_HSADCDATA2_NAME //
383 #define BU92747GUW_PWDN_MUX_MODE     GPIO3H_GPIO3D3//GPIO5L_GPIO5A7  //
384
385 static int bu92747guw_io_init(void)
386 {
387         int ret;
388         
389         //reset pin
390     if(BU92747GUW_RESET_MUX_NAME != NULL)
391     {
392         rk29_mux_api_set(BU92747GUW_RESET_MUX_NAME, BU92747GUW_RESET_MUX_MODE);
393     }
394         ret = gpio_request(BU92747GUW_RESET_PIN, NULL);
395         if(ret != 0)
396         {
397                 gpio_free(BU92747GUW_RESET_PIN);
398                 printk(">>>>>> BU92747GUW_RESET_PIN gpio_request err \n ");
399         }
400         gpio_direction_output(BU92747GUW_RESET_PIN, GPIO_HIGH);
401
402         //power down pin
403     if(BU92747GUW_PWDN_MUX_NAME != NULL)
404     {
405         rk29_mux_api_set(BU92747GUW_PWDN_MUX_NAME, BU92747GUW_PWDN_MUX_MODE);
406     }
407         ret = gpio_request(BU92747GUW_PWDN_PIN, NULL);
408         if(ret != 0)
409         {
410                 gpio_free(BU92747GUW_PWDN_PIN);
411                 printk(">>>>>> BU92747GUW_PWDN_PIN gpio_request err \n ");
412         }
413
414         //power down as default
415         gpio_direction_output(BU92747GUW_PWDN_PIN, GPIO_LOW);
416         
417         return 0;
418 }
419
420
421 static int bu92747guw_io_deinit(void)
422 {
423         gpio_free(BU92747GUW_PWDN_PIN);
424         gpio_free(BU92747GUW_RESET_PIN);
425         return 0;
426 }
427
428 //power ctl func is share with irda and remote
429 static int nPowerOnCount = 0;
430 static DEFINE_MUTEX(bu92747_power_mutex);
431
432 //1---power on;  0---power off
433 static int bu92747guw_power_ctl(int enable)
434 {
435     printk("%s \n",__FUNCTION__);
436
437         mutex_lock(&bu92747_power_mutex);
438         if (enable) {
439                 nPowerOnCount++;
440                 if (nPowerOnCount == 1) {//power on first       
441                         //smc0_init(NULL);
442                         gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_HIGH);
443                         gpio_set_value(BU92747GUW_RESET_PIN, GPIO_LOW);
444                         mdelay(5);
445                         gpio_set_value(BU92747GUW_RESET_PIN, GPIO_HIGH);
446                         mdelay(5);
447                 }
448         }
449         else {
450                 nPowerOnCount--;
451                 if (nPowerOnCount <= 0) {//power down final
452                         nPowerOnCount = 0;
453                         //smc0_exit();
454                         gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_LOW);
455                 }
456         }
457         mutex_unlock(&bu92747_power_mutex);
458         return 0;
459 }
460 #endif
461
462 #ifdef CONFIG_RK_IRDA
463 #define IRDA_IRQ_PIN           RK29_PIN5_PB2
464 #define IRDA_IRQ_MUX_NAME      GPIO5B2_HSADCDATA5_NAME
465 #define IRDA_IRQ_MUX_MODE      GPIO5L_GPIO5B2
466
467 int irda_iomux_init(void)
468 {
469     int ret = 0;
470
471         //irda irq pin
472     if(IRDA_IRQ_MUX_NAME != NULL)
473     {
474         rk29_mux_api_set(IRDA_IRQ_MUX_NAME, IRDA_IRQ_MUX_MODE);
475     }
476         ret = gpio_request(IRDA_IRQ_PIN, NULL);
477         if(ret != 0)
478         {
479                 gpio_free(IRDA_IRQ_PIN);
480                 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
481         }
482         gpio_pull_updown(IRDA_IRQ_PIN, GPIO_HIGH);
483         gpio_direction_input(IRDA_IRQ_PIN);
484
485     return 0;
486 }
487
488 int irda_iomux_deinit(void)
489 {
490         gpio_free(IRDA_IRQ_PIN);
491         return 0;
492 }
493
494 static struct irda_info rk29_irda_info = {
495     .intr_pin = IRDA_IRQ_PIN,
496     .iomux_init = irda_iomux_init,
497     .iomux_deinit = irda_iomux_deinit,
498         .irda_pwr_ctl = bu92747guw_power_ctl,
499 };
500
501 static struct platform_device irda_device = {
502 #ifdef CONFIG_RK_IRDA_NET
503                         .name   = "rk_irda",
504 #else
505                         .name = "bu92747_irda",
506 #endif
507     .id           = -1,
508         .dev            = {
509                 .platform_data  = &rk29_irda_info,
510         }
511 };
512 #endif
513
514 #ifdef CONFIG_BU92747GUW_CIR
515 #define BU92747_CIR_IRQ_PIN RK29_PIN5_PB0
516 #define CIR_IRQ_PIN_IOMUX_NAME GPIO5B0_HSADCDATA3_NAME
517 #define CIR_IRQ_PIN_IOMUX_VALUE GPIO5L_GPIO5B0
518 static int cir_iomux_init(void)
519 {
520         if (CIR_IRQ_PIN_IOMUX_NAME)
521                 rk29_mux_api_set(CIR_IRQ_PIN_IOMUX_NAME, CIR_IRQ_PIN_IOMUX_VALUE);
522         rk29_mux_api_set(GPIO5A7_HSADCDATA2_NAME, GPIO5L_GPIO5A7);
523         return 0;
524 }
525
526 static struct  bu92747guw_platform_data bu92747guw_pdata = {
527         .intr_pin = BU92747_CIR_IRQ_PIN,
528         .iomux_init = cir_iomux_init,
529         .iomux_deinit = NULL,
530         .cir_pwr_ctl = bu92747guw_power_ctl,
531 };  
532 #endif
533 #ifdef CONFIG_RK29_NEWTON
534 struct rk29_newton_data rk29_newton_info = {    
535 };
536 struct platform_device rk29_device_newton = {
537         .name          = "rk29_newton",
538         .id            = -1,            
539         .dev               = {
540         .platform_data = &rk29_newton_info,     
541                 }           
542         };
543 #endif
544 #if defined (CONFIG_TOUCHSCREEN_FT5406)
545 #define TOUCH_RESET_PIN RK29_PIN6_PC3
546 #define TOUCH_INT_PIN   RK29_PIN0_PA2
547 int ft5406_init_platform_hw(void)
548 {
549         printk("ft5406_init_platform_hw\n");
550     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
551       gpio_free(TOUCH_RESET_PIN);
552       printk("ft5406_init_platform_hw gpio_request error\n");
553       return -EIO;
554     }
555
556     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
557       gpio_free(TOUCH_INT_PIN);
558       printk("ift5406_init_platform_hw gpio_request error\n");
559       return -EIO;
560     }
561
562         gpio_direction_output(TOUCH_RESET_PIN, 0);
563         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
564         mdelay(10);
565         gpio_direction_input(TOUCH_INT_PIN);
566         mdelay(10);
567         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
568         msleep(300);
569     return 0;
570 }
571
572 void ft5406_exit_platform_hw(void)
573 {
574         printk("ft5406_exit_platform_hw\n");
575         gpio_free(TOUCH_RESET_PIN);
576         gpio_free(TOUCH_INT_PIN);
577 }
578
579 int ft5406_platform_sleep(void)
580 {
581         printk("ft5406_platform_sleep\n");
582         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
583         return 0;
584 }
585
586 int ft5406_platform_wakeup(void)
587 {
588         printk("ft5406_platform_wakeup\n");
589         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
590         msleep(300);
591         return 0;
592 }
593
594 struct ft5406_platform_data ft5406_info = {
595
596   .init_platform_hw= ft5406_init_platform_hw,
597   .exit_platform_hw= ft5406_exit_platform_hw,
598   .platform_sleep  = ft5406_platform_sleep,
599   .platform_wakeup = ft5406_platform_wakeup,
600
601 };
602 #endif
603
604 #if defined(CONFIG_TOUCHSCREEN_GT819)
605 #define TOUCH_RESET_PIN RK29_PIN6_PC3
606 #define TOUCH_INT_PIN   RK29_PIN0_PA2
607 int gt819_init_platform_hw(void)
608 {
609         printk("gt819_init_platform_hw\n");
610     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
611       gpio_free(TOUCH_RESET_PIN);
612       printk("gt819_init_platform_hw gpio_request error\n");
613       return -EIO;
614     }
615
616     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
617       gpio_free(TOUCH_INT_PIN);
618       printk("gt819_init_platform_hw gpio_request error\n");
619       return -EIO;
620     }
621         gpio_direction_output(TOUCH_RESET_PIN, 0);
622         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
623         mdelay(10);
624 //      gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
625 //      mdelay(10);
626 //      gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
627         gpio_direction_input(TOUCH_INT_PIN);
628 //      mdelay(10);
629         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
630         msleep(300);
631     return 0;
632 }
633
634
635 void gt819_exit_platform_hw(void)
636 {
637         printk("gt819_exit_platform_hw\n");
638         gpio_free(TOUCH_RESET_PIN);
639         gpio_free(TOUCH_INT_PIN);
640 }
641
642 int gt819_platform_sleep(void)
643 {
644         printk("gt819_platform_sleep\n");
645         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
646         return 0;
647 }
648
649 int gt819_platform_wakeup(void)
650 {
651         printk("gt819_platform_wakeup\n");
652         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
653         //msleep(5);
654         //gpio_set_value(TOUCH_INT_PIN, GPIO_LOW); 
655         //msleep(20);
656         //gpio_set_value(TOUCH_INT_PIN, GPIO_HIGH);
657         return 0;
658 }
659 struct goodix_platform_data goodix_info = {
660
661   .init_platform_hw= gt819_init_platform_hw,
662   .exit_platform_hw= gt819_exit_platform_hw,
663   .platform_sleep  = gt819_platform_sleep,
664   .platform_wakeup = gt819_platform_wakeup,
665
666 };
667 #endif
668
669
670 #if defined (CONFIG_SND_SOC_CS42L52)
671
672 int cs42l52_init_platform_hw()
673 {
674         printk("cs42l52_init_platform_hw\n");
675     if(gpio_request(RK29_PIN6_PB6,NULL) != 0){
676       gpio_free(RK29_PIN6_PB6);
677       printk("cs42l52_init_platform_hw gpio_request error\n");
678       return -EIO;
679     }
680     gpio_direction_output(RK29_PIN6_PB6, 0);
681         gpio_set_value(RK29_PIN6_PB6,GPIO_HIGH);
682         return 0;
683 }
684 struct cs42l52_platform_data cs42l52_info = {
685
686   .init_platform_hw= cs42l52_init_platform_hw,
687
688 };
689 #endif
690 #if defined (CONFIG_BATTERY_BQ27541)
691 #define DC_CHECK_PIN    RK29_PIN4_PA1
692 #define LI_LION_BAT_NUM 1
693 #define CHG_OK RK29_PIN4_PA3
694 #define BAT_LOW RK29_PIN4_PA2
695
696 static int bq27541_init_dc_check_pin(void){     
697         if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){      
698                 gpio_free(DC_CHECK_PIN);      
699                 printk("bq27541 init dc check pin request error\n");      
700                 return -EIO;    
701         }       
702         gpio_direction_input(DC_CHECK_PIN);     
703         return 0;
704 }
705
706 struct bq27541_platform_data bq27541_info = {   
707         .init_dc_check_pin = bq27541_init_dc_check_pin, 
708         .dc_check_pin =  DC_CHECK_PIN,          
709         .bat_num = LI_LION_BAT_NUM,
710         .chgok_check_pin =  CHG_OK,
711         .bat_check_pin =  BAT_LOW,
712 };
713 #endif
714 static struct android_pmem_platform_data android_pmem_pdata = {
715         .name           = "pmem",
716         .start          = PMEM_UI_BASE,
717         .size           = PMEM_UI_SIZE,
718         .no_allocator   = 0,
719         .cached         = 1,
720 };
721
722 static struct platform_device android_pmem_device = {
723         .name           = "android_pmem",
724         .id             = 0,
725         .dev            = {
726                 .platform_data = &android_pmem_pdata,
727         },
728 };
729
730
731 static struct vpu_mem_platform_data vpu_mem_pdata = {
732         .name           = "vpu_mem",
733         .start          = PMEM_VPU_BASE,
734         .size           = PMEM_VPU_SIZE,
735         .cached         = 1,
736 };
737
738 static struct platform_device rk29_vpu_mem_device = {
739         .name           = "vpu_mem",
740         .id                 = 2,
741         .dev            = {
742         .platform_data = &vpu_mem_pdata,
743         },
744 };
745 static struct android_pmem_platform_data android_pmem_skype_pdata = {
746         .name           = "pmem_skype",
747         .start          = PMEM_SKYPE_BASE,
748         .size           = PMEM_SKYPE_SIZE,
749         .no_allocator   = 0,
750         .cached         = 0,
751 };
752
753 static struct platform_device android_pmem_skype_device = {
754         .name           = "android_pmem",
755         .id             = 3,
756         .dev            = {
757                 .platform_data = &android_pmem_skype_pdata,
758         },
759 };
760 #ifdef CONFIG_VIDEO_RK29XX_VOUT
761 static struct platform_device rk29_v4l2_output_devce = {
762         .name           = "rk29_vout",
763 };
764 #endif
765 /*HANNSTAR_P1003 touch*/
766 #if defined (CONFIG_HANNSTAR_P1003)
767 #define TOUCH_RESET_PIN RK29_PIN6_PC3
768 #define TOUCH_INT_PIN   RK29_PIN0_PA2
769
770 int p1003_init_platform_hw(void)
771 {
772     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
773       gpio_free(TOUCH_RESET_PIN);
774       printk("p1003_init_platform_hw gpio_request error\n");
775       return -EIO;
776     }
777
778     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
779       gpio_free(TOUCH_INT_PIN);
780       printk("p1003_init_platform_hw gpio_request error\n");
781       return -EIO;
782     }
783     gpio_pull_updown(TOUCH_INT_PIN, 1);
784     gpio_direction_output(TOUCH_RESET_PIN, 0);
785     msleep(500);
786     gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
787     msleep(500);
788     gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
789
790     return 0;
791 }
792
793
794 struct p1003_platform_data p1003_info = {
795   .model= 1003,
796   .init_platform_hw= p1003_init_platform_hw,
797
798 };
799 #endif
800 #if defined (CONFIG_EETI_EGALAX)
801 #define TOUCH_RESET_PIN RK29_PIN6_PC3
802 #define TOUCH_INT_PIN   RK29_PIN0_PA2
803
804 static int EETI_EGALAX_init_platform_hw(void)
805 {
806     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
807       gpio_free(TOUCH_RESET_PIN);
808       printk("p1003_init_platform_hw gpio_request error\n");
809       return -EIO;
810     }
811
812     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
813       gpio_free(TOUCH_INT_PIN);
814       printk("p1003_init_platform_hw gpio_request error\n");
815       return -EIO;
816     }
817     gpio_pull_updown(TOUCH_INT_PIN, 1);
818     gpio_direction_output(TOUCH_RESET_PIN, 0);
819     msleep(500);
820     gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
821     msleep(500);
822     gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
823
824     return 0;
825 }
826
827
828 static struct eeti_egalax_platform_data eeti_egalax_info = {
829   .model= 1003,
830   .init_platform_hw= EETI_EGALAX_init_platform_hw,
831   .standby_pin = TOUCH_SCREEN_STANDBY_PIN,
832   .standby_value = TOUCH_SCREEN_STANDBY_VALUE,
833   .disp_on_pin = TOUCH_SCREEN_DISPLAY_PIN,
834   .disp_on_value = TOUCH_SCREEN_DISPLAY_VALUE,
835 };
836 #endif
837
838 #ifdef CONFIG_GS_KXTF9
839 #include <linux/kxtf9.h>
840 #define KXTF9_DEVICE_MAP 1
841 #define KXTF9_MAP_X (KXTF9_DEVICE_MAP-1)%2
842 #define KXTF9_MAP_Y KXTF9_DEVICE_MAP%2
843 #define KXTF9_NEG_X (KXTF9_DEVICE_MAP/2)%2
844 #define KXTF9_NEG_Y (KXTF9_DEVICE_MAP+1)/4
845 #define KXTF9_NEG_Z (KXTF9_DEVICE_MAP-1)/4
846 struct kxtf9_platform_data kxtf9_pdata = {
847         .min_interval = 1,
848         .poll_interval = 20,
849         .g_range = KXTF9_G_2G,
850         .axis_map_x = KXTF9_MAP_X,
851         .axis_map_y = KXTF9_MAP_Y,
852         .axis_map_z = 2,
853         .negate_x = KXTF9_NEG_X,
854         .negate_y = KXTF9_NEG_Y,
855         .negate_z = KXTF9_NEG_Z,
856         //.ctrl_regc_init = KXTF9_G_2G | ODR50F,
857         //.ctrl_regb_init = ENABLE,
858 };
859 #endif /* CONFIG_GS_KXTF9 */
860
861
862 /*MMA8452 gsensor*/
863 #if defined (CONFIG_GS_MMA8452)
864 #define MMA8452_INT_PIN   RK29_PIN0_PA3
865
866 static int mma8452_init_platform_hw(void)
867 {
868
869     if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
870       gpio_free(MMA8452_INT_PIN);
871       printk("mma8452_init_platform_hw gpio_request error\n");
872       return -EIO;
873     }
874     gpio_pull_updown(MMA8452_INT_PIN, 1);
875     return 0;
876 }
877
878
879 static struct mma8452_platform_data mma8452_info = {
880   .model= 8452,
881   .swap_xy = 1,
882   .init_platform_hw= mma8452_init_platform_hw,
883
884 };
885 #endif
886 #if defined (CONFIG_MPU_SENSORS_MPU3050)
887 /*mpu3050*/
888 static struct mpu3050_platform_data mpu3050_data = {
889                 .int_config = 0x10,
890                 //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
891                 //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
892                 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
893                 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
894                 .level_shifter = 0,
895 #if defined (CONFIG_MPU_SENSORS_KXTF9)
896                 .accel = {
897 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
898                                 .get_slave_descr = NULL ,
899 #else
900                                 .get_slave_descr = get_accel_slave_descr ,                      
901 #endif
902                                 .adapt_num = 0, // The i2c bus to which the mpu device is
903                                 // connected
904                                 //.irq = RK29_PIN0_PA3,
905                                 .bus = EXT_SLAVE_BUS_SECONDARY,  //The secondary I2C of MPU
906                                 .address = 0x0f,
907                                 //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
908                                 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
909                                 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
910                                 .orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
911                 },
912 #endif
913 #if defined (CONFIG_MPU_SENSORS_AK8975)
914                 .compass = {
915 #ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
916                                 .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
917 #else
918                                 .get_slave_descr = get_compass_slave_descr,
919 #endif                                          
920                                 .adapt_num = 0, // The i2c bus to which the compass device is. 
921                                 // It can be difference with mpu
922                                 // connected
923                                 //.irq = RK29_PIN0_PA4,
924                                 .bus = EXT_SLAVE_BUS_PRIMARY,
925                                 .address = 0x0d,
926                                 //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
927                                 //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
928                                 //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
929                                 //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
930                                 .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
931                 },
932 };
933 #endif
934 #endif
935 #if defined (CONFIG_BATTERY_BQ27510)
936 #define DC_CHECK_PIN    RK29_PIN4_PA1
937 #define LI_LION_BAT_NUM 2
938 static int bq27510_init_dc_check_pin(void){     
939         if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){      
940                 gpio_free(DC_CHECK_PIN);      
941                 printk("bq27510 init dc check pin request error\n");      
942                 return -EIO;    
943         }       
944         gpio_direction_input(DC_CHECK_PIN);     
945         return 0;
946 }
947
948 struct bq27510_platform_data bq27510_info = {   
949         .init_dc_check_pin = bq27510_init_dc_check_pin, 
950         .dc_check_pin =  DC_CHECK_PIN,          
951         .bat_num = LI_LION_BAT_NUM,
952 };
953 #endif
954
955
956 /*****************************************************************************************
957  * i2c devices
958  * author: kfx@rock-chips.com
959 *****************************************************************************************/
960 static int rk29_i2c0_io_init(void)
961 {
962 #ifdef CONFIG_RK29_I2C0_CONTROLLER
963         rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
964         rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
965 #else
966         rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
967         rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
968 #endif
969         return 0;
970 }
971
972 static int rk29_i2c1_io_init(void)
973 {
974 #ifdef CONFIG_RK29_I2C1_CONTROLLER
975         rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
976         rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
977 #else
978         rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
979         rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
980 #endif
981         return 0;
982 }
983 static int rk29_i2c2_io_init(void)
984 {
985 #ifdef CONFIG_RK29_I2C2_CONTROLLER
986         rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
987         rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
988 #else
989         rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
990         rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
991 #endif
992         return 0;
993 }
994
995 static int rk29_i2c3_io_init(void)
996 {
997 #ifdef CONFIG_RK29_I2C3_CONTROLLER
998         rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
999         rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
1000 #else
1001         rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
1002         rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
1003 #endif
1004         return 0;
1005 }
1006 #ifdef CONFIG_RK29_I2C0_CONTROLLER
1007 struct rk29_i2c_platform_data default_i2c0_data = {
1008         .bus_num    = 0,
1009         .flags      = 0,
1010         .slave_addr = 0xff,
1011         .scl_rate  = 400*1000,
1012         .mode           = I2C_MODE_IRQ,
1013         .io_init = rk29_i2c0_io_init,
1014 };
1015 #else
1016 struct i2c_gpio_platform_data default_i2c0_data = {
1017        .sda_pin = RK29_PIN2_PB6,
1018        .scl_pin = RK29_PIN2_PB7,
1019        .udelay = 5, // clk = 500/udelay = 100Khz
1020        .timeout = 100,//msecs_to_jiffies(200),
1021        .bus_num    = 0,
1022        .io_init = rk29_i2c0_io_init,
1023 };
1024 #endif
1025 #ifdef CONFIG_RK29_I2C1_CONTROLLER
1026 struct rk29_i2c_platform_data default_i2c1_data = {
1027         .bus_num    = 1,
1028         .flags      = 0,
1029         .slave_addr = 0xff,
1030         .scl_rate  = 400*1000,
1031         .mode           = I2C_MODE_IRQ,
1032         .io_init = rk29_i2c1_io_init,
1033 };
1034 #else
1035 struct i2c_gpio_platform_data default_i2c1_data = {
1036        .sda_pin = RK29_PIN1_PA6,
1037        .scl_pin = RK29_PIN1_PA7,
1038        .udelay = 5, // clk = 500/udelay = 100Khz
1039        .timeout = 100,//msecs_to_jiffies(200),
1040        .bus_num    = 1,
1041        .io_init = rk29_i2c1_io_init,
1042 };
1043 #endif
1044 #ifdef CONFIG_RK29_I2C2_CONTROLLER
1045 struct rk29_i2c_platform_data default_i2c2_data = {
1046         .bus_num    = 2,
1047         .flags      = 0,
1048         .slave_addr = 0xff,
1049         .scl_rate  = 400*1000,
1050         .mode           = I2C_MODE_IRQ,
1051         .io_init = rk29_i2c2_io_init,
1052 };
1053 #else
1054 struct i2c_gpio_platform_data default_i2c2_data = {
1055        .sda_pin = RK29_PIN5_PD3,
1056        .scl_pin = RK29_PIN5_PD4,
1057        .udelay = 5, // clk = 500/udelay = 100Khz
1058        .timeout = 100,//msecs_to_jiffies(200),
1059        .bus_num    = 2,
1060        .io_init = rk29_i2c2_io_init,
1061 };
1062 #endif
1063 #ifdef CONFIG_RK29_I2C3_CONTROLLER
1064 struct rk29_i2c_platform_data default_i2c3_data = {
1065         .bus_num    = 3,
1066         .flags      = 0,
1067         .slave_addr = 0xff,
1068         .scl_rate  = 400*1000,
1069         .mode           = I2C_MODE_IRQ,
1070         .io_init = rk29_i2c3_io_init,
1071 };
1072 #else
1073 struct i2c_gpio_platform_data default_i2c3_data = {
1074        .sda_pin = RK29_PIN5_PB5,
1075        .scl_pin = RK29_PIN5_PB4,
1076        .udelay = 5, // clk = 500/udelay = 100Khz
1077        .timeout = 100,//msecs_to_jiffies(200),
1078        .bus_num    = 3,
1079        .io_init = rk29_i2c3_io_init,
1080 };
1081 #endif
1082 #ifdef CONFIG_I2C0_RK29
1083 static struct i2c_board_info __initdata board_i2c0_devices[] = {
1084 #if defined (CONFIG_RK1000_CONTROL)
1085         {
1086                 .type                   = "rk1000_control",
1087                 .addr           = 0x40,
1088                 .flags                  = 0,
1089         },
1090 #endif
1091 #if defined (CONFIG_SND_SOC_alc5621)
1092         {
1093                 .type                   = "ALC5621",
1094                 .addr                   = 0x1a,
1095                 .flags                  = 0,
1096         },
1097 #endif
1098 #if defined (CONFIG_SND_SOC_alc5631)
1099         {
1100                 .type                   = "rt5631",
1101                 .addr                   = 0x1a,
1102                 .flags                  = 0,
1103         },
1104 #endif
1105 #if defined (CONFIG_SND_SOC_RK1000)
1106         {
1107                 .type                   = "rk1000_i2c_codec",
1108                 .addr           = 0x60,
1109                 .flags                  = 0,
1110         },
1111 #endif
1112 #if defined (CONFIG_SND_SOC_WM8900)
1113         {
1114                 .type                   = "wm8900",
1115                 .addr           = 0x1A,
1116                 .flags                  = 0,
1117         },
1118 #endif
1119 #if defined (CONFIG_BATTERY_STC3100)
1120         {
1121                 .type                   = "stc3100",
1122                 .addr           = 0x70,
1123                 .flags                  = 0,
1124         },
1125 #endif
1126 #if defined (CONFIG_BATTERY_BQ27510)
1127         {
1128                 .type                   = "bq27510",
1129                 .addr           = 0x55,
1130                 .flags                  = 0,
1131                 .platform_data  = &bq27510_info,
1132         },
1133 #endif
1134 #if defined (CONFIG_RTC_HYM8563)
1135         {
1136                 .type                   = "rtc_hym8563",
1137                 .addr           = 0x51,
1138                 .flags                  = 0,
1139                 .irq            = RK29_PIN0_PA1,
1140         },
1141 #endif
1142 #if defined (CONFIG_GS_MMA8452)
1143     {
1144       .type           = "gs_mma8452",
1145       .addr           = 0x1c,
1146       .flags          = 0,
1147       .irq            = MMA8452_INT_PIN,
1148       .platform_data  = &mma8452_info,
1149     },
1150 #endif
1151 #if defined (CONFIG_COMPASS_AK8973)
1152         {
1153                 .type                   = "ak8973",
1154                 .addr           = 0x1d,
1155                 .flags                  = 0,
1156                 .irq                    = RK29_PIN0_PA4,
1157         },
1158 #endif
1159 #if defined (CONFIG_COMPASS_AK8975)
1160         {
1161                 .type                   = "ak8975",
1162                 .addr           = 0x0d,
1163                 .flags                  = 0,
1164                 .irq                    = RK29_PIN0_PA4,
1165         },
1166 #endif
1167 /*mpu3050*/
1168 #if defined (CONFIG_MPU_SENSORS_MPU3050) 
1169         {
1170                 .type                   = "mpu3050",
1171                 .addr                   = 0x68,
1172                 .flags                  = 0,
1173                 .irq                    = RK29_PIN5_PA3,
1174                 .platform_data  = &mpu3050_data,
1175         },
1176 #endif
1177 #if defined (CONFIG_SND_SOC_CS42L52)
1178         {
1179                 .type                   = "cs42l52",
1180                 .addr           = 0x4A,
1181                 .flags                  = 0,
1182                 .platform_data  = &cs42l52_info,
1183         },
1184 #endif
1185 #if defined (CONFIG_RTC_M41T66)
1186         {
1187                 .type           = "rtc-M41T66",
1188                 .addr           = 0x68,
1189                 .flags          = 0,
1190                 .irq            = RK29_PIN0_PA1,
1191         },
1192 #endif
1193 };
1194 #endif
1195 #if defined (CONFIG_ANX7150)
1196 struct hdmi_platform_data anx7150_data = {
1197        //.io_init = anx7150_io_init,
1198 };
1199 #endif
1200 #ifdef CONFIG_I2C1_RK29
1201 static struct i2c_board_info __initdata board_i2c1_devices[] = {
1202 #if defined (CONFIG_RK1000_CONTROL1)
1203         {
1204                 .type                   = "rk1000_control",
1205                 .addr                   = 0x40,
1206                 .flags                  = 0,
1207         },
1208 #endif
1209 #if defined (CONFIG_ANX7150)
1210     {
1211                 .type           = "anx7150",
1212         .addr           = 0x39,             //0x39, 0x3d
1213         .flags          = 0,
1214         .irq            = RK29_PIN1_PD7,
1215                 .platform_data  = &anx7150_data,
1216     },
1217 #endif
1218 #ifdef CONFIG_BU92747GUW_CIR
1219     {
1220         .type   ="bu92747_cir",
1221         .addr   = 0x77,    
1222         .flags      =0,
1223         .irq            = BU92747_CIR_IRQ_PIN,
1224         .platform_data = &bu92747guw_pdata,
1225     },
1226 #endif
1227
1228 };
1229 #endif
1230
1231 #ifdef CONFIG_I2C2_RK29
1232 static struct i2c_board_info __initdata board_i2c2_devices[] = {
1233 #if defined (CONFIG_HANNSTAR_P1003)
1234     {
1235       .type           = "p1003_touch",
1236       .addr           = 0x04,
1237       .flags          = 0, //I2C_M_NEED_DELAY
1238       .irq            = RK29_PIN0_PA2,
1239       .platform_data  = &p1003_info,
1240       //.udelay           = 100
1241     },
1242 #endif
1243 #if defined (CONFIG_EETI_EGALAX)
1244     {
1245       .type           = "egalax_i2c",
1246       .addr           = 0x04,
1247       .flags          = 0,
1248       .irq            = RK29_PIN0_PA2,
1249       .platform_data  = &eeti_egalax_info,
1250     },
1251 #endif
1252 #if defined (CONFIG_TOUCHSCREEN_GT819)
1253     {
1254                 .type   = "Goodix-TS",
1255                 .addr   = 0x55,
1256                 .flags      =0,
1257                 .irq            =RK29_PIN0_PA2,
1258                 .platform_data = &goodix_info,
1259     },
1260 #endif
1261 #if defined (CONFIG_TOUCHSCREEN_FT5406)
1262     {
1263                 .type   ="ft5x0x_ts",
1264                 .addr   = 0x38,    //0x70,
1265                 .flags      =0,
1266                 .irq            =RK29_PIN0_PA2, // support goodix tp detect, 20110706
1267                 .platform_data = &ft5406_info,
1268     },
1269 #endif
1270 };
1271 #endif
1272
1273 #ifdef CONFIG_I2C3_RK29
1274 static struct i2c_board_info __initdata board_i2c3_devices[] = {
1275 #if defined (CONFIG_BATTERY_BQ27541)
1276         {
1277                 .type                   = "bq27541",
1278                 .addr           = 0x55,
1279                 .flags                  = 0,
1280                 .platform_data  = &bq27541_info,
1281         },
1282 #endif
1283 };
1284 #endif
1285
1286 /*****************************************************************************************
1287  * camera  devices
1288  * author: ddl@rock-chips.com
1289  *****************************************************************************************/
1290 #ifdef CONFIG_VIDEO_RK29
1291 #define CONFIG_SENSOR_POWER_IOCTL_USR      0
1292 #define CONFIG_SENSOR_RESET_IOCTL_USR      0
1293 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR      0
1294 #define CONFIG_SENSOR_FLASH_IOCTL_USR      0
1295
1296 #if CONFIG_SENSOR_POWER_IOCTL_USR
1297 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
1298 {
1299     #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
1300 }
1301 #endif
1302
1303 #if CONFIG_SENSOR_RESET_IOCTL_USR
1304 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
1305 {
1306     #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
1307 }
1308 #endif
1309
1310 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1311 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
1312 {
1313     #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
1314 }
1315 #endif
1316
1317 #if CONFIG_SENSOR_FLASH_IOCTL_USR
1318 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
1319 {
1320     #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
1321 }
1322 #endif
1323
1324 static struct rk29camera_platform_ioctl_cb  sensor_ioctl_cb = {
1325     #if CONFIG_SENSOR_POWER_IOCTL_USR
1326     .sensor_power_cb = sensor_power_usr_cb,
1327     #else
1328     .sensor_power_cb = NULL,
1329     #endif
1330
1331     #if CONFIG_SENSOR_RESET_IOCTL_USR
1332     .sensor_reset_cb = sensor_reset_usr_cb,
1333     #else
1334     .sensor_reset_cb = NULL,
1335     #endif
1336
1337     #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
1338     .sensor_powerdown_cb = sensor_powerdown_usr_cb,
1339     #else
1340     .sensor_powerdown_cb = NULL,
1341     #endif
1342
1343     #if CONFIG_SENSOR_FLASH_IOCTL_USR
1344     .sensor_flash_cb = sensor_flash_usr_cb,
1345     #else
1346     .sensor_flash_cb = NULL,
1347     #endif
1348 };
1349 #include "../../../drivers/media/video/rk29_camera.c"
1350 #endif
1351 /*****************************************************************************************
1352  * backlight  devices
1353  * author: nzy@rock-chips.com
1354  *****************************************************************************************/
1355 #ifdef CONFIG_BACKLIGHT_RK29_BL
1356  /*
1357  GPIO1B5_PWM0_NAME,       GPIO1L_PWM0
1358  GPIO5D2_PWM1_UART1SIRIN_NAME,  GPIO5H_PWM1
1359  GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME,   GPIO2L_PWM2
1360  GPIO1A5_EMMCPWREN_PWM3_NAME,     GPIO1L_PWM3
1361  */
1362
1363 #define PWM_ID            0
1364 #define PWM_MUX_NAME      GPIO1B5_PWM0_NAME
1365 #define PWM_MUX_MODE      GPIO1L_PWM0
1366 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
1367 #define PWM_GPIO RK29_PIN1_PB5
1368 #define PWM_EFFECT_VALUE  1
1369
1370 #define LCD_DISP_ON_PIN
1371
1372 #ifdef  LCD_DISP_ON_PIN
1373 //#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
1374 //#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
1375
1376 #define BL_EN_PIN         RK29_PIN6_PD0
1377 #define BL_EN_VALUE       GPIO_HIGH
1378 #endif
1379 static int rk29_backlight_io_init(void)
1380 {
1381     int ret = 0;
1382
1383     rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1384         #ifdef  LCD_DISP_ON_PIN
1385    // rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
1386
1387     ret = gpio_request(BL_EN_PIN, NULL);
1388     if(ret != 0)
1389     {
1390         gpio_free(BL_EN_PIN);
1391     }
1392
1393     gpio_direction_output(BL_EN_PIN, 0);
1394     gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1395         #endif
1396     return ret;
1397 }
1398
1399 static int rk29_backlight_io_deinit(void)
1400 {
1401     int ret = 0;
1402     #ifdef  LCD_DISP_ON_PIN
1403     gpio_free(BL_EN_PIN);
1404     #endif
1405     rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1406     
1407     return ret;
1408 }
1409
1410 static int rk29_backlight_pwm_suspend(void)
1411 {
1412         int ret = 0;
1413         rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
1414         if (gpio_request(PWM_GPIO, NULL)) {
1415                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
1416                 return -1;
1417         }
1418         gpio_direction_output(PWM_GPIO, GPIO_LOW);
1419    #ifdef  LCD_DISP_ON_PIN
1420     gpio_direction_output(BL_EN_PIN, 0);
1421     gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
1422    #endif
1423         return ret;
1424 }
1425
1426 static int rk29_backlight_pwm_resume(void)
1427 {
1428         gpio_free(PWM_GPIO);
1429         rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
1430
1431     #ifdef  LCD_DISP_ON_PIN
1432     msleep(30);
1433     gpio_direction_output(BL_EN_PIN, 1);
1434     gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
1435     #endif
1436         return 0;
1437 }
1438
1439 struct rk29_bl_info rk29_bl_info = {
1440     .pwm_id   = PWM_ID,
1441     .bl_ref   = PWM_EFFECT_VALUE,
1442     .io_init   = rk29_backlight_io_init,
1443     .io_deinit = rk29_backlight_io_deinit,
1444     .pwm_suspend = rk29_backlight_pwm_suspend,
1445     .pwm_resume = rk29_backlight_pwm_resume,
1446 };
1447 #endif
1448 /*****************************************************************************************
1449 * pwm voltage regulator devices
1450 ******************************************************************************************/
1451 #if defined (CONFIG_RK29_PWM_REGULATOR)
1452
1453 #define REGULATOR_PWM_ID                                        2
1454 #define REGULATOR_PWM_MUX_NAME                  GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
1455 #define REGULATOR_PWM_MUX_MODE                                          GPIO2L_PWM2
1456 #define REGULATOR_PWM_MUX_MODE_GPIO                             GPIO2L_GPIO2A3
1457 #define REGULATOR_PWM_GPIO                              RK29_PIN2_PA3
1458
1459 static struct regulator_consumer_supply pwm_consumers[] = {
1460         {
1461                 .supply = "vcore",
1462         }
1463 };
1464
1465 static struct regulator_init_data rk29_pwm_regulator_data = {
1466         .constraints = {
1467                 .name = "PWM2",
1468                 .min_uV =  950000,
1469                 .max_uV = 1400000,
1470                 .apply_uV = 1,
1471                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1472         },
1473         .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
1474         .consumer_supplies = pwm_consumers,
1475 };
1476
1477 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
1478         .pwm_id = REGULATOR_PWM_ID,
1479         .pwm_gpio = REGULATOR_PWM_GPIO,
1480         //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
1481         .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
1482         .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
1483         .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
1484         .init_data  = &rk29_pwm_regulator_data,
1485 };
1486
1487 static struct platform_device rk29_device_pwm_regulator = {
1488         .name = "pwm-voltage-regulator",
1489         .id   = -1,
1490         .dev  = {
1491                 .platform_data = &rk29_regulator_pwm_platform_data,
1492         },
1493 };
1494
1495 #endif
1496
1497 /*****************************************************************************************
1498  * SDMMC devices
1499 *****************************************************************************************/
1500 #ifdef CONFIG_SDMMC0_RK29
1501 static int rk29_sdmmc0_cfg_gpio(void)
1502 {
1503         rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1504         rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1505         rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1506         rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1507         rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1508         rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1509
1510 #ifdef CONFIG_SDMMC_RK29_OLD    
1511         rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
1512 #else
1513         rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
1514 #endif
1515
1516         rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5);   ///GPIO5H_SDMMC0_PWR_EN);  ///GPIO5H_GPIO5D5);
1517         gpio_request(RK29_PIN5_PD5,"sdmmc");
1518 #if 0
1519         gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1520         mdelay(100);
1521         gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1522 #else
1523         gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
1524 #endif
1525         return 0;
1526 }
1527
1528 #define CONFIG_SDMMC0_USE_DMA
1529 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1530         .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1531                                            MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1532                                            MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1533         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1534         .io_init = rk29_sdmmc0_cfg_gpio,
1535         .dma_name = "sd_mmc",
1536 #ifdef CONFIG_SDMMC0_USE_DMA
1537         .use_dma  = 1,
1538 #else
1539         .use_dma = 0,
1540 #endif
1541         .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
1542         .enable_sd_wakeup = 0,
1543 };
1544 #endif
1545 #ifdef CONFIG_SDMMC1_RK29
1546 #define CONFIG_SDMMC1_USE_DMA
1547 static int rk29_sdmmc1_cfg_gpio(void)
1548 {
1549         rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1550         rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1551         rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1552         rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1553         rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1554         rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1555         //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1556         return 0;
1557 }
1558
1559 #ifdef CONFIG_WIFI_CONTROL_FUNC
1560 static int rk29sdk_wifi_status(struct device *dev);
1561 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1562 #endif
1563
1564 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK29_PIN1_PD6
1565
1566 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1567         .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1568                                            MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1569                                            MMC_VDD_32_33|MMC_VDD_33_34),
1570         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1571                                    MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1572         .io_init = rk29_sdmmc1_cfg_gpio,
1573         .dma_name = "sdio",
1574 #ifdef CONFIG_SDMMC1_USE_DMA
1575         .use_dma  = 1,
1576 #else
1577         .use_dma = 0,
1578 #endif
1579 #ifdef CONFIG_WIFI_CONTROL_FUNC
1580         .status = rk29sdk_wifi_status,
1581         .register_status_notify = rk29sdk_wifi_status_register,
1582 #endif
1583 #if 0
1584         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1585 #endif
1586 };
1587 #endif
1588
1589 #ifdef CONFIG_WIFI_CONTROL_FUNC
1590 #define RK29SDK_WIFI_BT_GPIO_POWER_N       RK29_PIN5_PD6
1591 #define RK29SDK_WIFI_GPIO_RESET_N          RK29_PIN6_PC0
1592 #define RK29SDK_BT_GPIO_RESET_N            RK29_PIN6_PC4
1593
1594 static int rk29sdk_wifi_cd = 0;   /* wifi virtual 'card detect' status */
1595 static void (*wifi_status_cb)(int card_present, void *dev_id);
1596 static void *wifi_status_cb_devid;
1597 int rk29sdk_wifi_power_state = 0;
1598 int rk29sdk_bt_power_state = 0;
1599
1600 static int rk29sdk_wifi_status(struct device *dev)
1601 {
1602         return rk29sdk_wifi_cd;
1603 }
1604
1605 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1606 {
1607         if(wifi_status_cb)
1608                 return -EAGAIN;
1609         wifi_status_cb = callback;
1610         wifi_status_cb_devid = dev_id;
1611         return 0;
1612 }
1613
1614 static int rk29sdk_wifi_bt_gpio_control_init(void)
1615 {
1616     if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1617            pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1618            return -1;
1619     }
1620
1621     if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1622            pr_info("%s: request wifi reset gpio failed\n", __func__);
1623            gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1624            return -1;
1625     }
1626
1627     if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1628           pr_info("%s: request bt reset gpio failed\n", __func__);
1629           gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1630           return -1;
1631     }
1632
1633     gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1634     gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N,    GPIO_LOW);
1635     gpio_direction_output(RK29SDK_BT_GPIO_RESET_N,      GPIO_LOW);
1636
1637     pr_info("%s: init finished\n",__func__);
1638
1639     return 0;
1640 }
1641
1642 static int rk29sdk_wifi_power(int on)
1643 {
1644         pr_info("%s: %d\n", __func__, on);
1645         if (on){
1646                 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
1647                 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
1648                 mdelay(100);
1649                 pr_info("wifi turn on power\n");
1650         }else{
1651                 if (!rk29sdk_bt_power_state){
1652                         gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1653                         mdelay(100);
1654                         pr_info("wifi shut off power\n");
1655                 }else
1656                 {
1657                         pr_info("wifi shouldn't shut off power, bt is using it!\n");
1658                 }
1659                 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1660
1661         }
1662
1663         rk29sdk_wifi_power_state = on;
1664         return 0;
1665 }
1666
1667 static int rk29sdk_wifi_reset_state;
1668 static int rk29sdk_wifi_reset(int on)
1669 {
1670         pr_info("%s: %d\n", __func__, on);
1671         gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1672         mdelay(100);
1673         rk29sdk_wifi_reset_state = on;
1674         return 0;
1675 }
1676
1677 int rk29sdk_wifi_set_carddetect(int val)
1678 {
1679         pr_info("%s:%d\n", __func__, val);
1680         rk29sdk_wifi_cd = val;
1681         if (wifi_status_cb){
1682                 wifi_status_cb(val, wifi_status_cb_devid);
1683         }else {
1684                 pr_warning("%s, nobody to notify\n", __func__);
1685         }
1686         return 0;
1687 }
1688 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
1689
1690 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
1691         {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
1692         {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
1693         {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
1694         {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
1695 };
1696
1697 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
1698 {
1699         if (section == PREALLOC_WLAN_SEC_NUM)
1700                 return wlan_static_skb;
1701
1702         if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
1703                 return NULL;
1704
1705         if (wifi_mem_array[section].size < size)
1706                 return NULL;
1707
1708         return wifi_mem_array[section].mem_ptr;
1709 }
1710
1711 int __init rk29sdk_init_wifi_mem(void)
1712 {
1713         int i;
1714         int j;
1715
1716         for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
1717                 wlan_static_skb[i] = dev_alloc_skb(
1718                                 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
1719
1720                 if (!wlan_static_skb[i])
1721                         goto err_skb_alloc;
1722         }
1723
1724         for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
1725                 wifi_mem_array[i].mem_ptr =
1726                                 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
1727
1728                 if (!wifi_mem_array[i].mem_ptr)
1729                         goto err_mem_alloc;
1730         }
1731         return 0;
1732
1733 err_mem_alloc:
1734         pr_err("Failed to mem_alloc for WLAN\n");
1735         for (j = 0 ; j < i ; j++)
1736                kfree(wifi_mem_array[j].mem_ptr);
1737
1738         i = WLAN_SKB_BUF_NUM;
1739
1740 err_skb_alloc:
1741         pr_err("Failed to skb_alloc for WLAN\n");
1742         for (j = 0 ; j < i ; j++)
1743                 dev_kfree_skb(wlan_static_skb[j]);
1744
1745         return -ENOMEM;
1746 }
1747
1748 static struct wifi_platform_data rk29sdk_wifi_control = {
1749         .set_power = rk29sdk_wifi_power,
1750         .set_reset = rk29sdk_wifi_reset,
1751         .set_carddetect = rk29sdk_wifi_set_carddetect,
1752         .mem_prealloc   = rk29sdk_mem_prealloc,
1753 };
1754 static struct platform_device rk29sdk_wifi_device = {
1755         .name = "bcm4329_wlan",
1756         .id = 1,
1757         .dev = {
1758                 .platform_data = &rk29sdk_wifi_control,
1759          },
1760 };
1761 #endif
1762
1763
1764 /* bluetooth rfkill device */
1765 static struct platform_device rk29sdk_rfkill = {
1766         .name = "rk29sdk_rfkill",
1767         .id = -1,
1768 };
1769
1770
1771 #ifdef CONFIG_VIVANTE
1772 #define GPU_HIGH_CLOCK        552
1773 #define GPU_LOW_CLOCK         (periph_pll_default / 1000000) /* same as general pll clock rate below */
1774 static struct resource resources_gpu[] = {
1775     [0] = {
1776                 .name   = "gpu_irq",
1777         .start  = IRQ_GPU,
1778         .end    = IRQ_GPU,
1779         .flags  = IORESOURCE_IRQ,
1780     },
1781     [1] = {
1782                 .name   = "gpu_base",
1783         .start  = RK29_GPU_PHYS,
1784         .end    = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
1785         .flags  = IORESOURCE_MEM,
1786     },
1787     [2] = {
1788                 .name   = "gpu_mem",
1789         .start  = PMEM_GPU_BASE,
1790         .end    = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
1791         .flags  = IORESOURCE_MEM,
1792     },
1793     [3] = {
1794                 .name   = "gpu_clk",
1795         .start  = GPU_LOW_CLOCK,
1796         .end    = GPU_HIGH_CLOCK,
1797         .flags  = IORESOURCE_IO,
1798     },
1799 };
1800 static struct platform_device rk29_device_gpu = {
1801     .name             = "galcore",
1802     .id               = 0,
1803     .num_resources    = ARRAY_SIZE(resources_gpu),
1804     .resource         = resources_gpu,
1805 };
1806 #endif
1807
1808 #ifdef CONFIG_KEYS_RK29
1809 extern struct rk29_keys_platform_data rk29_keys_pdata;
1810 static struct platform_device rk29_device_keys = {
1811         .name           = "rk29-keypad",
1812         .id             = -1,
1813         .dev            = {
1814                 .platform_data  = &rk29_keys_pdata,
1815         },
1816 };
1817 #endif
1818
1819 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1820 struct gpio_led rk29_leds[] = {
1821                 {
1822                         .name = "rk29_red_led",
1823                         .gpio = RK29_PIN4_PB2,
1824                         .default_trigger = "timer",
1825                         .active_low = 0,
1826                         .retain_state_suspended = 1,
1827                         .default_state = LEDS_GPIO_DEFSTATE_OFF,
1828                 },
1829                 {
1830                         .name = "rk29_green_led",
1831                         .gpio = RK29_PIN4_PB1,
1832                         .default_trigger = "timer",
1833                         .active_low = 0,
1834                         .retain_state_suspended = 1,
1835                         .default_state = LEDS_GPIO_DEFSTATE_OFF,
1836                 },
1837                 {
1838                         .name = "rk29_blue_led",
1839                         .gpio = RK29_PIN4_PB0,
1840                         .default_trigger = "timer",
1841                         .active_low = 0,
1842                         .retain_state_suspended = 1,
1843                         .default_state = LEDS_GPIO_DEFSTATE_OFF,
1844                 },
1845 };
1846
1847 struct gpio_led_platform_data rk29_leds_pdata = {
1848         .leds = &rk29_leds,
1849         .num_leds       = ARRAY_SIZE(rk29_leds),
1850 };
1851
1852 struct platform_device rk29_device_gpio_leds = {
1853         .name   = "leds-gpio",
1854         .id     = -1,
1855         .dev    = {
1856            .platform_data  = &rk29_leds_pdata,
1857         },
1858 };
1859 #endif
1860
1861 #ifdef CONFIG_LEDS_NEWTON_PWM
1862 static struct led_newton_pwm rk29_pwm_leds[] = {
1863                 {
1864                         .name = "power_led",
1865                         .pwm_id = 1,
1866                         .pwm_gpio = RK29_PIN5_PD2,
1867                         .pwm_iomux_name = GPIO5D2_PWM1_UART1SIRIN_NAME,
1868                         .pwm_iomux_pwm = GPIO5H_PWM1,
1869                         .pwm_iomux_gpio = GPIO5H_GPIO5D2,
1870                         .freq = 1000,
1871                         .period = 255,
1872                 },
1873 };
1874
1875 static struct led_newton_pwm_platform_data rk29_pwm_leds_pdata = {
1876         .leds = &rk29_pwm_leds,
1877         .num_leds       = ARRAY_SIZE(rk29_pwm_leds),
1878 };
1879
1880 static struct platform_device rk29_device_pwm_leds = {
1881         .name   = "leds_newton_pwm",
1882         .id     = -1,
1883         .dev    = {
1884            .platform_data  = &rk29_pwm_leds_pdata,
1885         },
1886 };
1887
1888 #endif
1889 static void __init rk29_board_iomux_init(void)
1890 {
1891         #ifdef CONFIG_RK29_PWM_REGULATOR
1892         rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1893         #endif
1894 }
1895
1896 static struct platform_device *devices[] __initdata = {
1897
1898 #ifdef CONFIG_RK29_WATCHDOG
1899         &rk29_device_wdt,
1900 #endif
1901
1902 #ifdef CONFIG_UART1_RK29
1903         &rk29_device_uart1,
1904 #endif
1905 #ifdef CONFIG_UART0_RK29
1906         &rk29_device_uart0,
1907 #endif
1908 #ifdef CONFIG_UART2_RK29
1909         &rk29_device_uart2,
1910 #endif
1911 #ifdef CONFIG_UART3_RK29
1912         &rk29_device_uart3,
1913 #endif
1914
1915 #ifdef CONFIG_RK29_PWM_REGULATOR
1916         &rk29_device_pwm_regulator,
1917 #endif
1918 #ifdef CONFIG_SPIM0_RK29
1919     &rk29xx_device_spi0m,
1920 #endif
1921 #ifdef CONFIG_SPIM1_RK29
1922     &rk29xx_device_spi1m,
1923 #endif
1924 #ifdef CONFIG_ADC_RK29
1925         &rk29_device_adc,
1926 #endif
1927 #ifdef CONFIG_I2C0_RK29
1928         &rk29_device_i2c0,
1929 #endif
1930 #ifdef CONFIG_I2C1_RK29
1931         &rk29_device_i2c1,
1932 #endif
1933 #ifdef CONFIG_I2C2_RK29
1934         &rk29_device_i2c2,
1935 #endif
1936 #ifdef CONFIG_I2C3_RK29
1937         &rk29_device_i2c3,
1938 #endif
1939
1940 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1941         &rk29_device_iis_2ch,
1942 #endif
1943 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1944         &rk29_device_iis_8ch,
1945 #endif
1946
1947 #ifdef CONFIG_KEYS_RK29
1948         &rk29_device_keys,
1949 #endif
1950 #ifdef CONFIG_KEYS_RK29_NEWTON
1951         &rk29_device_keys,
1952 #endif
1953 #ifdef CONFIG_SDMMC0_RK29
1954         &rk29_device_sdmmc0,
1955 #endif
1956 #ifdef CONFIG_SDMMC1_RK29
1957         &rk29_device_sdmmc1,
1958 #endif
1959
1960 #ifdef CONFIG_MTD_NAND_RK29XX
1961         &rk29xx_device_nand,
1962 #endif
1963
1964 #ifdef CONFIG_WIFI_CONTROL_FUNC
1965         &rk29sdk_wifi_device,
1966 #endif
1967
1968 #ifdef CONFIG_BT
1969         &rk29sdk_rfkill,
1970 #endif
1971
1972 #ifdef CONFIG_MTD_NAND_RK29
1973         &rk29_device_nand,
1974 #endif
1975
1976 #ifdef CONFIG_FB_RK29
1977         &rk29_device_fb,
1978         &rk29_device_dma_cpy,
1979 #endif
1980 #ifdef CONFIG_BACKLIGHT_RK29_BL
1981         &rk29_device_backlight,
1982 #endif
1983 #ifdef CONFIG_BACKLIGHT_RK29_NEWTON_BL
1984         &rk29_device_backlight,
1985 #endif
1986 #ifdef CONFIG_RK29_VMAC
1987         &rk29_device_vmac,
1988 #endif
1989 #ifdef CONFIG_VIVANTE
1990         &rk29_device_gpu,
1991 #endif
1992 #ifdef CONFIG_VIDEO_RK29
1993         &rk29_device_camera,      /* ddl@rock-chips.com : camera support  */
1994         #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
1995         &rk29_soc_camera_pdrv_0,
1996         #endif
1997         &rk29_soc_camera_pdrv_1,
1998         &android_pmem_cam_device,
1999 #endif
2000   &android_pmem_skype_device,
2001         &android_pmem_device,
2002         &rk29_vpu_mem_device,
2003 #ifdef CONFIG_USB20_OTG
2004         &rk29_device_usb20_otg,
2005 #endif
2006 #ifdef CONFIG_USB20_HOST
2007         &rk29_device_usb20_host,
2008 #endif
2009 #ifdef CONFIG_USB11_HOST
2010         &rk29_device_usb11_host,
2011 #endif
2012 #ifdef CONFIG_USB_ANDROID
2013         &android_usb_device,
2014         &usb_mass_storage_device,
2015 #endif
2016 #ifdef CONFIG_USB_ANDROID_RNDIS
2017     &rk29_device_rndis,
2018 #endif
2019 #ifdef CONFIG_RK29_IPP
2020         &rk29_device_ipp,
2021 #endif
2022 #ifdef CONFIG_VIDEO_RK29XX_VOUT
2023         &rk29_v4l2_output_devce,
2024 #endif
2025 #ifdef CONFIG_RK29_NEWTON
2026         &rk29_device_newton,
2027 #endif
2028 #ifdef CONFIG_RK_IRDA
2029     &irda_device,
2030 #endif
2031 #ifdef CONFIG_LEDS_GPIO_PLATFORM
2032         &rk29_device_gpio_leds,
2033 #endif
2034 #ifdef CONFIG_LEDS_NEWTON_PWM
2035         &rk29_device_pwm_leds,
2036 #endif
2037 #ifdef CONFIG_SND_RK29_SOC_CS42L52
2038         &rk29_cs42l52_device,
2039 #endif
2040 };
2041
2042 /*****************************************************************************************
2043  * spi devices
2044  * author: cmc@rock-chips.com
2045  *****************************************************************************************/
2046 static int rk29_vmac_register_set(void)
2047 {
2048         //config rk29 vmac as rmii, 100MHz
2049         u32 value= readl(RK29_GRF_BASE + 0xbc);
2050         value = (value & 0xfff7ff) | (0x400);
2051         writel(value, RK29_GRF_BASE + 0xbc);
2052         return 0;
2053 }
2054
2055 static int rk29_rmii_io_init(void)
2056 {
2057         int err;
2058
2059         //phy power gpio
2060         err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
2061         if (err) {
2062                 gpio_free(RK29_PIN6_PB0);
2063                 printk("-------request RK29_PIN6_PB0 fail--------\n");
2064                 return -1;
2065         }
2066         //phy power down
2067         gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2068         gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2069
2070         return 0;
2071 }
2072
2073 static int rk29_rmii_io_deinit(void)
2074 {
2075         //phy power down
2076         gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2077         gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2078         //free
2079         gpio_free(RK29_PIN6_PB0);
2080         return 0;
2081 }
2082
2083 static int rk29_rmii_power_control(int enable)
2084 {
2085         if (enable) {
2086                 //enable phy power
2087                 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
2088                 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
2089         }
2090         else {
2091                 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
2092                 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
2093         }
2094         return 0;
2095 }
2096
2097 struct rk29_vmac_platform_data rk29_vmac_pdata = {
2098         .vmac_register_set = rk29_vmac_register_set,
2099         .rmii_io_init = rk29_rmii_io_init,
2100         .rmii_io_deinit = rk29_rmii_io_deinit,
2101         .rmii_power_control = rk29_rmii_power_control,
2102 };
2103
2104 /*****************************************************************************************
2105  * spi devices
2106  * author: cmc@rock-chips.com
2107  *****************************************************************************************/
2108 #define SPI_CHIPSELECT_NUM 2
2109 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
2110     {
2111                 .name = "spi0 cs0",
2112                 .cs_gpio = RK29_PIN2_PC1,
2113                 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
2114                 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
2115         },
2116         {
2117                 .name = "spi0 cs1",
2118                 .cs_gpio = RK29_PIN1_PA4,
2119                 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
2120                 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
2121         }
2122 };
2123
2124 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
2125     {
2126                 .name = "spi1 cs0",
2127                 .cs_gpio = RK29_PIN2_PC5,
2128                 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
2129                 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
2130         },
2131         {
2132                 .name = "spi1 cs1",
2133                 .cs_gpio = RK29_PIN1_PA3,
2134                 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
2135                 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
2136         }
2137 };
2138
2139 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
2140 {
2141 #if 1
2142         int i;
2143         if (cs_gpios) {
2144                 for (i=0; i<cs_num; i++) {
2145                         rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
2146                 }
2147         }
2148 #endif
2149         return 0;
2150 }
2151
2152 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
2153 {
2154         return 0;
2155 }
2156
2157 static int spi_io_fix_leakage_bug(void)
2158 {
2159 #if 0
2160         gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
2161 #endif
2162         return 0;
2163 }
2164
2165 static int spi_io_resume_leakage_bug(void)
2166 {
2167 #if 0
2168         gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
2169 #endif
2170         return 0;
2171 }
2172
2173 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
2174         .num_chipselect = SPI_CHIPSELECT_NUM,
2175         .chipselect_gpios = rk29xx_spi0_cs_gpios,
2176         .io_init = spi_io_init,
2177         .io_deinit = spi_io_deinit,
2178         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2179         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2180 };
2181
2182 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
2183         .num_chipselect = SPI_CHIPSELECT_NUM,
2184         .chipselect_gpios = rk29xx_spi1_cs_gpios,
2185         .io_init = spi_io_init,
2186         .io_deinit = spi_io_deinit,
2187         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
2188         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
2189 };
2190
2191 /*****************************************************************************************
2192  * xpt2046 touch panel
2193  * author: cmc@rock-chips.com
2194  *****************************************************************************************/
2195 #define XPT2046_GPIO_INT           RK29_PIN0_PA3
2196 #define DEBOUNCE_REPTIME  3
2197
2198 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
2199 static struct xpt2046_platform_data xpt2046_info = {
2200         .model                  = 2046,
2201         .keep_vref_on   = 1,
2202         .swap_xy                = 0,
2203         .x_min                  = 0,
2204         .x_max                  = 320,
2205         .y_min                  = 0,
2206         .y_max                  = 480,
2207         .debounce_max           = 7,
2208         .debounce_rep           = DEBOUNCE_REPTIME,
2209         .debounce_tol           = 20,
2210         .gpio_pendown           = XPT2046_GPIO_INT,
2211         .penirq_recheck_delay_usecs = 1,
2212 };
2213 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
2214 static struct xpt2046_platform_data xpt2046_info = {
2215         .model                  = 2046,
2216         .keep_vref_on   = 1,
2217         .swap_xy                = 0,
2218         .x_min                  = 0,
2219         .x_max                  = 320,
2220         .y_min                  = 0,
2221         .y_max                  = 480,
2222         .debounce_max           = 7,
2223         .debounce_rep           = DEBOUNCE_REPTIME,
2224         .debounce_tol           = 20,
2225         .gpio_pendown           = XPT2046_GPIO_INT,
2226         .penirq_recheck_delay_usecs = 1,
2227 };
2228 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
2229 static struct xpt2046_platform_data xpt2046_info = {
2230         .model                  = 2046,
2231         .keep_vref_on   = 1,
2232         .swap_xy                = 1,
2233         .x_min                  = 0,
2234         .x_max                  = 800,
2235         .y_min                  = 0,
2236         .y_max                  = 480,
2237         .debounce_max           = 7,
2238         .debounce_rep           = DEBOUNCE_REPTIME,
2239         .debounce_tol           = 20,
2240         .gpio_pendown           = XPT2046_GPIO_INT,
2241
2242         .penirq_recheck_delay_usecs = 1,
2243 };
2244 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2245 static struct xpt2046_platform_data xpt2046_info = {
2246         .model                  = 2046,
2247         .keep_vref_on   = 1,
2248         .swap_xy                = 1,
2249         .x_min                  = 0,
2250         .x_max                  = 800,
2251         .y_min                  = 0,
2252         .y_max                  = 480,
2253         .debounce_max           = 7,
2254         .debounce_rep           = DEBOUNCE_REPTIME,
2255         .debounce_tol           = 20,
2256         .gpio_pendown           = XPT2046_GPIO_INT,
2257
2258         .penirq_recheck_delay_usecs = 1,
2259 };
2260 #endif
2261
2262 static struct spi_board_info board_spi_devices[] = {
2263 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
2264     ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
2265         {
2266                 .modalias       = "xpt2046_ts",
2267                 .chip_select    = 0,
2268                 .max_speed_hz   = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
2269                 .bus_num        = 0,
2270                 .irq = XPT2046_GPIO_INT,
2271                 .platform_data = &xpt2046_info,
2272         },
2273 #endif
2274 };
2275
2276
2277 static void __init rk29_gic_init_irq(void)
2278 {
2279         gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
2280         gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
2281 }
2282
2283 static void __init machine_rk29_init_irq(void)
2284 {
2285         rk29_gic_init_irq();
2286         rk29_gpio_init();
2287 }
2288
2289 static struct cpufreq_frequency_table freq_table[] = {
2290         { .index = 1200000, .frequency =  408000 },
2291         { .index = 1200000, .frequency =  816000 },
2292         { .index = 1300000, .frequency = 1008000 },
2293         { .frequency = CPUFREQ_TABLE_END },
2294 };
2295
2296 static void __init machine_rk29_board_init(void)
2297 {
2298         rk29_board_iomux_init();
2299
2300         board_power_init();
2301         board_update_cpufreq_table(freq_table);
2302
2303                 platform_add_devices(devices, ARRAY_SIZE(devices));
2304 #ifdef CONFIG_I2C0_RK29
2305         i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
2306                         ARRAY_SIZE(board_i2c0_devices));
2307 #endif
2308 #ifdef CONFIG_I2C1_RK29
2309         i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
2310                         ARRAY_SIZE(board_i2c1_devices));
2311 #endif
2312 #ifdef CONFIG_I2C2_RK29
2313         i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
2314                         ARRAY_SIZE(board_i2c2_devices));
2315 #endif
2316 #ifdef CONFIG_I2C3_RK29
2317         i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
2318                         ARRAY_SIZE(board_i2c3_devices));
2319 #endif
2320
2321         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2322         
2323 #ifdef CONFIG_WIFI_CONTROL_FUNC
2324         rk29sdk_wifi_bt_gpio_control_init();
2325         rk29sdk_init_wifi_mem();
2326 #endif
2327
2328         board_usb_detect_init(RK29_PIN0_PA0);
2329 #if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR)
2330         smc0_init(NULL);
2331         bu92747guw_io_init();
2332 #endif
2333
2334 }
2335
2336 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
2337                                         char **cmdline, struct meminfo *mi)
2338 {
2339         mi->nr_banks = 1;
2340         mi->bank[0].start = RK29_SDRAM_PHYS;
2341         mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
2342         mi->bank[0].size = LINUX_SIZE;
2343 #if SDRAM_SIZE > SZ_512M
2344         mi->nr_banks = 2;
2345         mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
2346         mi->bank[1].size = SDRAM_SIZE - SZ_512M;
2347 #endif
2348 }
2349
2350 static void __init machine_rk29_mapio(void)
2351 {
2352         rk29_map_common_io();
2353         rk29_setup_early_printk();
2354         rk29_sram_init();
2355         rk29_clock_init(periph_pll_default);
2356         rk29_iomux_init();
2357         ddr_init(DDR_TYPE, DDR_FREQ);
2358 }
2359
2360 MACHINE_START(RK29, "RK29board")
2361         /* UART for LL DEBUG */
2362         .phys_io        = RK29_UART1_PHYS & 0xfff00000,
2363         .io_pg_offst    = ((RK29_UART1_BASE) >> 18) & 0xfffc,
2364         .boot_params    = RK29_SDRAM_PHYS + 0x88000,
2365         .fixup          = machine_rk29_fixup,
2366         .map_io         = machine_rk29_mapio,
2367         .init_irq       = machine_rk29_init_irq,
2368         .init_machine   = machine_rk29_board_init,
2369         .timer          = &rk29_timer,
2370 MACHINE_END