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