Merge branch 'develop' of 10.10.10.29:/home/rockchip/kernel into develop
[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
49 #include <linux/regulator/rk29-pwm-regulator.h>
50 #include <linux/regulator/machine.h>
51
52 #include <linux/mtd/nand.h>
53 #include <linux/mtd/partitions.h>
54 #include <linux/i2c-gpio.h>
55
56 #include "devices.h"
57 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
58
59 #ifdef CONFIG_VIDEO_RK29
60 /*---------------- Camera Sensor Macro Define Begin  ------------------------*/
61 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
62 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642                      /* back camera sensor */
63 #define CONFIG_SENSOR_IIC_ADDR_0            0x78
64 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0    1
65 #define CONFIG_SENSOR_POWER_PIN_0         INVALID_GPIO
66 #define CONFIG_SENSOR_RESET_PIN_0         INVALID_GPIO
67 #define CONFIG_SENSOR_POWERDN_PIN_0       RK29_PIN6_PB7
68 #define CONFIG_SENSOR_FALSH_PIN_0         INVALID_GPIO
69 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
70 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
71 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
72 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
73
74 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659                      /* front camera sensor */
75 #define CONFIG_SENSOR_IIC_ADDR_1            0x60
76 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    1
77 #define CONFIG_SENSOR_POWER_PIN_1         INVALID_GPIO
78 #define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
79 #define CONFIG_SENSOR_POWERDN_PIN_1       RK29_PIN5_PD7
80 #define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
81 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
82 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
83 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
84 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
85 #endif  //#ifdef CONFIG_VIDEO_RK29
86 /*---------------- Camera Sensor Configuration Macro End------------------------*/
87 #include "../../../drivers/media/video/rk29_camera.c"
88 /*---------------- Camera Sensor Macro Define End  ------------------------*/
89
90 /* Set memory size of pmem */
91 #ifdef CONFIG_RK29_MEM_SIZE_M
92 #define SDRAM_SIZE          (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
93 #else
94 #define SDRAM_SIZE          SZ_512M
95 #endif
96 #define PMEM_GPU_SIZE       SZ_64M
97 #define PMEM_UI_SIZE        SZ_32M
98 #define PMEM_VPU_SIZE       SZ_64M
99 #define PMEM_CAM_SIZE       PMEM_CAM_NECESSARY
100 #ifdef CONFIG_VIDEO_RK29_WORK_IPP
101 #define MEM_CAMIPP_SIZE     SZ_4M
102 #else
103 #define MEM_CAMIPP_SIZE     0
104 #endif
105 #define MEM_FB_SIZE         (3*SZ_2M)
106 #ifdef CONFIG_FB_WORK_IPP
107 #define MEM_FBIPP_SIZE      SZ_8M   //1920 x 1080 x 2 x 2  //RGB565 = x2;RGB888 = x4
108 #else
109 #define MEM_FBIPP_SIZE      0
110 #endif
111 #if SDRAM_SIZE > SZ_512M
112 #define PMEM_GPU_BASE       (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
113 #else
114 #define PMEM_GPU_BASE       (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
115 #endif
116 #define PMEM_UI_BASE        (PMEM_GPU_BASE - PMEM_UI_SIZE)
117 #define PMEM_VPU_BASE       (PMEM_UI_BASE - PMEM_VPU_SIZE)
118 #define PMEM_CAM_BASE       (PMEM_VPU_BASE - PMEM_CAM_SIZE)
119 #define MEM_CAMIPP_BASE     (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
120 #define MEM_FB_BASE         (MEM_CAMIPP_BASE - MEM_FB_SIZE)
121 #define MEM_FBIPP_BASE      (MEM_FB_BASE - MEM_FBIPP_SIZE)
122 #define LINUX_SIZE          (MEM_FBIPP_BASE - RK29_SDRAM_PHYS)
123
124 #define PREALLOC_WLAN_SEC_NUM           4
125 #define PREALLOC_WLAN_BUF_NUM           160
126 #define PREALLOC_WLAN_SECTION_HEADER    24
127
128 #define WLAN_SECTION_SIZE_0     (PREALLOC_WLAN_BUF_NUM * 128)
129 #define WLAN_SECTION_SIZE_1     (PREALLOC_WLAN_BUF_NUM * 128)
130 #define WLAN_SECTION_SIZE_2     (PREALLOC_WLAN_BUF_NUM * 512)
131 #define WLAN_SECTION_SIZE_3     (PREALLOC_WLAN_BUF_NUM * 1024)
132
133 #define WLAN_SKB_BUF_NUM        16
134
135 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
136
137 struct wifi_mem_prealloc {
138         void *mem_ptr;
139         unsigned long size;
140 };
141
142 extern struct sys_timer rk29_timer;
143
144 static int rk29_nand_io_init(void)
145 {
146     return 0;
147 }
148
149 struct rk29_nand_platform_data rk29_nand_data = {
150     .width      = 1,     /* data bus width in bytes */
151     .hw_ecc     = 1,     /* hw ecc 0: soft ecc */
152     .num_flash    = 1,
153     .io_init   = rk29_nand_io_init,
154 };
155
156 #define TOUCH_SCREEN_STANDBY_PIN          RK29_PIN6_PD1
157 #define TOUCH_SCREEN_STANDBY_VALUE        GPIO_HIGH
158 #define TOUCH_SCREEN_DISPLAY_PIN          INVALID_GPIO
159 #define TOUCH_SCREEN_DISPLAY_VALUE        GPIO_HIGH
160 #ifdef CONFIG_FB_RK29
161 /*****************************************************************************************
162  * lcd  devices
163  * author: zyw@rock-chips.com
164  *****************************************************************************************/
165 //#ifdef  CONFIG_LCD_TD043MGEA1
166 #define LCD_TXD_PIN          INVALID_GPIO
167 #define LCD_CLK_PIN          INVALID_GPIO
168 #define LCD_CS_PIN           INVALID_GPIO
169 /*****************************************************************************************
170 * frame buffe  devices
171 * author: zyw@rock-chips.com
172 *****************************************************************************************/
173 #define FB_ID                       0
174 #define FB_DISPLAY_ON_PIN           INVALID_GPIO// RK29_PIN6_PD0
175 #define FB_LCD_STANDBY_PIN          INVALID_GPIO
176 #define FB_LCD_CABC_EN_PIN          RK29_PIN6_PD2
177 #define FB_MCU_FMK_PIN              INVALID_GPIO
178
179 #define FB_DISPLAY_ON_VALUE         GPIO_HIGH
180 #define FB_LCD_STANDBY_VALUE        GPIO_HIGH
181
182 static int rk29_lcd_io_init(void)
183 {
184     int ret = 0;
185     return ret;
186 }
187
188 static int rk29_lcd_io_deinit(void)
189 {
190     int ret = 0;
191     return ret;
192 }
193
194 static struct rk29lcd_info rk29_lcd_info = {
195     .txd_pin  = LCD_TXD_PIN,
196     .clk_pin = LCD_CLK_PIN,
197     .cs_pin = LCD_CS_PIN,
198     .io_init   = rk29_lcd_io_init,
199     .io_deinit = rk29_lcd_io_deinit,
200 };
201
202 int rk29_fb_io_enable(void)
203 {
204     if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
205     {
206         gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
207         gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);              
208     }
209     if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
210     {
211         gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
212         gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);             
213     }
214     return 0;
215 }
216
217 int rk29_fb_io_disable(void)
218 {
219     if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
220     {
221         gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
222         gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);              
223     }
224     if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
225     {
226         gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
227         gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);             
228     }
229     return 0;
230 }
231
232 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
233 {
234     int ret = 0;
235     if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
236     {
237         ret = gpio_request(FB_MCU_FMK_PIN, NULL);
238         if(ret != 0)
239         {
240             gpio_free(FB_MCU_FMK_PIN);
241             printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
242         }
243         gpio_direction_input(FB_MCU_FMK_PIN);
244     }
245     if(fb_setting->disp_on_en)
246     {
247         if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
248         {
249             ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
250             if(ret != 0)
251             {
252                 gpio_free(FB_DISPLAY_ON_PIN);
253                 printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
254             }
255         }
256         else
257         {
258              ret = gpio_request(TOUCH_SCREEN_DISPLAY_PIN, NULL);
259              if(ret != 0)
260              {
261                  gpio_free(TOUCH_SCREEN_DISPLAY_PIN);
262                  printk(">>>>>> TOUCH_SCREEN_DISPLAY_PIN gpio_request err \n ");
263              }
264              gpio_direction_output(TOUCH_SCREEN_DISPLAY_PIN, 0);
265              gpio_set_value(TOUCH_SCREEN_DISPLAY_PIN, TOUCH_SCREEN_DISPLAY_VALUE);
266         }
267     }
268
269     if(fb_setting->disp_on_en)
270     {
271         if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
272         {
273              ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
274              if(ret != 0)
275              {
276                  gpio_free(FB_LCD_STANDBY_PIN);
277                  printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
278              }
279         }
280         else
281         {
282              ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL);
283              if(ret != 0)
284              {
285                  gpio_free(TOUCH_SCREEN_STANDBY_PIN);
286                  printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n ");
287              }
288              gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0);
289              gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE);
290          }
291     }
292
293     if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
294     {
295         ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
296         if(ret != 0)
297         {
298             gpio_free(FB_LCD_CABC_EN_PIN);
299             printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
300         }
301         gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
302         gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
303     }
304     
305     rk29_fb_io_enable();   //enable it
306
307     return ret;
308 }
309
310 static struct rk29fb_info rk29_fb_info = {
311     .fb_id   = FB_ID,
312     .mcu_fmk_pin = FB_MCU_FMK_PIN,
313     .lcd_info = &rk29_lcd_info,
314     .io_init   = rk29_fb_io_init,
315     .io_enable = rk29_fb_io_enable,
316     .io_disable = rk29_fb_io_disable,
317 };
318
319 /* rk29 fb resource */
320 static struct resource rk29_fb_resource[] = {
321         [0] = {
322         .name  = "lcdc reg",
323                 .start = RK29_LCDC_PHYS,
324                 .end   = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
325                 .flags = IORESOURCE_MEM,
326         },
327         [1] = {
328             .name  = "lcdc irq",
329                 .start = IRQ_LCDC,
330                 .end   = IRQ_LCDC,
331                 .flags = IORESOURCE_IRQ,
332         },
333         [2] = {
334             .name   = "win1 buf",
335         .start  = MEM_FB_BASE,
336         .end    = MEM_FB_BASE + MEM_FB_SIZE - 1,
337         .flags  = IORESOURCE_MEM,
338     },
339     #ifdef CONFIG_FB_WORK_IPP
340     [3] = {
341             .name   = "win1 ipp buf",
342         .start  = MEM_FBIPP_BASE,
343         .end    = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
344         .flags  = IORESOURCE_MEM,
345     },
346     #endif
347 };
348
349 /*platform_device*/
350 struct platform_device rk29_device_fb = {
351         .name             = "rk29-fb",
352         .id               = 4,
353         .num_resources    = ARRAY_SIZE(rk29_fb_resource),
354         .resource         = rk29_fb_resource,
355         .dev            = {
356                 .platform_data  = &rk29_fb_info,
357         }
358 };
359
360 struct platform_device rk29_device_dma_cpy = {
361         .name             = "dma_memcpy",
362         .id               = 4,
363
364 };
365
366 #endif
367
368 static struct android_pmem_platform_data android_pmem_pdata = {
369         .name           = "pmem",
370         .start          = PMEM_UI_BASE,
371         .size           = PMEM_UI_SIZE,
372         .no_allocator   = 0,
373         .cached         = 1,
374 };
375
376 static struct platform_device android_pmem_device = {
377         .name           = "android_pmem",
378         .id             = 0,
379         .dev            = {
380                 .platform_data = &android_pmem_pdata,
381         },
382 };
383
384
385 static struct vpu_mem_platform_data vpu_mem_pdata = {
386         .name           = "vpu_mem",
387         .start          = PMEM_VPU_BASE,
388         .size           = PMEM_VPU_SIZE,
389         .cached         = 1,
390 };
391
392 static struct platform_device rk29_vpu_mem_device = {
393         .name           = "vpu_mem",
394         .id                 = 2,
395         .dev            = {
396         .platform_data = &vpu_mem_pdata,
397         },
398 };
399 #ifdef CONFIG_VIDEO_RK29XX_VOUT
400 static struct platform_device rk29_v4l2_output_devce = {
401         .name           = "rk29_vout",
402 };
403 #endif
404 /*HANNSTAR_P1003 touch*/
405 #if defined (CONFIG_HANNSTAR_P1003)
406 #define TOUCH_RESET_PIN RK29_PIN6_PC3
407 #define TOUCH_INT_PIN   RK29_PIN0_PA2
408
409 int p1003_init_platform_hw(void)
410 {
411     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
412       gpio_free(TOUCH_RESET_PIN);
413       printk("p1003_init_platform_hw gpio_request error\n");
414       return -EIO;
415     }
416
417     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
418       gpio_free(TOUCH_INT_PIN);
419       printk("p1003_init_platform_hw gpio_request error\n");
420       return -EIO;
421     }
422     gpio_pull_updown(TOUCH_INT_PIN, 1);
423     gpio_direction_output(TOUCH_RESET_PIN, 0);
424     msleep(500);
425     gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
426     msleep(500);
427     gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
428
429     return 0;
430 }
431
432
433 struct p1003_platform_data p1003_info = {
434   .model= 1003,
435   .init_platform_hw= p1003_init_platform_hw,
436
437 };
438 #endif
439 #if defined (CONFIG_EETI_EGALAX)
440 #define TOUCH_RESET_PIN RK29_PIN6_PC3
441 #define TOUCH_INT_PIN   RK29_PIN0_PA2
442
443 static int EETI_EGALAX_init_platform_hw(void)
444 {
445     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
446       gpio_free(TOUCH_RESET_PIN);
447       printk("p1003_init_platform_hw gpio_request error\n");
448       return -EIO;
449     }
450
451     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
452       gpio_free(TOUCH_INT_PIN);
453       printk("p1003_init_platform_hw gpio_request error\n");
454       return -EIO;
455     }
456     gpio_pull_updown(TOUCH_INT_PIN, 1);
457     gpio_direction_output(TOUCH_RESET_PIN, 0);
458     msleep(500);
459     gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
460     msleep(500);
461     gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
462
463     return 0;
464 }
465
466
467 static struct eeti_egalax_platform_data eeti_egalax_info = {
468   .model= 1003,
469   .init_platform_hw= EETI_EGALAX_init_platform_hw,
470   .standby_pin = TOUCH_SCREEN_STANDBY_PIN,
471   .standby_value = TOUCH_SCREEN_STANDBY_VALUE,
472   .disp_on_pin = TOUCH_SCREEN_DISPLAY_PIN,
473   .disp_on_value = TOUCH_SCREEN_DISPLAY_VALUE,
474 };
475 #endif
476 /*MMA8452 gsensor*/
477 #if defined (CONFIG_GS_MMA8452)
478 #define MMA8452_INT_PIN   RK29_PIN0_PA3
479
480 static int mma8452_init_platform_hw(void)
481 {
482
483     if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
484       gpio_free(MMA8452_INT_PIN);
485       printk("mma8452_init_platform_hw gpio_request error\n");
486       return -EIO;
487     }
488     gpio_pull_updown(MMA8452_INT_PIN, 1);
489     return 0;
490 }
491
492
493 static struct mma8452_platform_data mma8452_info = {
494   .model= 8452,
495   .swap_xy = 0,
496   .init_platform_hw= mma8452_init_platform_hw,
497
498 };
499 #endif
500
501 #if defined (CONFIG_BATTERY_BQ27510)
502 #define DC_CHECK_PIN    RK29_PIN4_PA1
503 #define LI_LION_BAT_NUM 2
504 static int bq27510_init_dc_check_pin(void){     
505         if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){      
506                 gpio_free(DC_CHECK_PIN);      
507                 printk("bq27510 init dc check pin request error\n");      
508                 return -EIO;    
509         }       
510         gpio_direction_input(DC_CHECK_PIN);     
511         return 0;
512 }
513
514 struct bq27510_platform_data bq27510_info = {   
515         .init_dc_check_pin = bq27510_init_dc_check_pin, 
516         .dc_check_pin =  DC_CHECK_PIN,          
517         .bat_num = LI_LION_BAT_NUM,
518 };
519 #endif
520
521
522 /*****************************************************************************************
523  * i2c devices
524  * author: kfx@rock-chips.com
525 *****************************************************************************************/
526 static int rk29_i2c0_io_init(void)
527 {
528 #ifdef CONFIG_RK29_I2C0_CONTROLLER
529         rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
530         rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
531 #else
532         rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
533         rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
534 #endif
535         return 0;
536 }
537
538 static int rk29_i2c1_io_init(void)
539 {
540 #ifdef CONFIG_RK29_I2C1_CONTROLLER
541         rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
542         rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
543 #else
544         rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
545         rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
546 #endif
547         return 0;
548 }
549 static int rk29_i2c2_io_init(void)
550 {
551 #ifdef CONFIG_RK29_I2C2_CONTROLLER
552         rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
553         rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
554 #else
555         rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
556         rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
557 #endif
558         return 0;
559 }
560
561 static int rk29_i2c3_io_init(void)
562 {
563 #ifdef CONFIG_RK29_I2C3_CONTROLLER
564         rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
565         rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
566 #else
567         rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
568         rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
569 #endif
570         return 0;
571 }
572 #ifdef CONFIG_RK29_I2C0_CONTROLLER
573 struct rk29_i2c_platform_data default_i2c0_data = {
574         .bus_num    = 0,
575         .flags      = 0,
576         .slave_addr = 0xff,
577         .scl_rate  = 400*1000,
578         .mode           = I2C_MODE_IRQ,
579         .io_init = rk29_i2c0_io_init,
580 };
581 #else
582 struct i2c_gpio_platform_data default_i2c0_data = {
583        .sda_pin = RK29_PIN2_PB6,
584        .scl_pin = RK29_PIN2_PB7,
585        .udelay = 5, // clk = 500/udelay = 100Khz
586        .timeout = 100,//msecs_to_jiffies(200),
587        .bus_num    = 0,
588        .io_init = rk29_i2c0_io_init,
589 };
590 #endif
591 #ifdef CONFIG_RK29_I2C1_CONTROLLER
592 struct rk29_i2c_platform_data default_i2c1_data = {
593         .bus_num    = 1,
594         .flags      = 0,
595         .slave_addr = 0xff,
596         .scl_rate  = 400*1000,
597         .mode           = I2C_MODE_IRQ,
598         .io_init = rk29_i2c1_io_init,
599 };
600 #else
601 struct i2c_gpio_platform_data default_i2c1_data = {
602        .sda_pin = RK29_PIN1_PA6,
603        .scl_pin = RK29_PIN1_PA7,
604        .udelay = 5, // clk = 500/udelay = 100Khz
605        .timeout = 100,//msecs_to_jiffies(200),
606        .bus_num    = 1,
607        .io_init = rk29_i2c1_io_init,
608 };
609 #endif
610 #ifdef CONFIG_RK29_I2C2_CONTROLLER
611 struct rk29_i2c_platform_data default_i2c2_data = {
612         .bus_num    = 2,
613         .flags      = 0,
614         .slave_addr = 0xff,
615         .scl_rate  = 400*1000,
616         .mode           = I2C_MODE_IRQ,
617         .io_init = rk29_i2c2_io_init,
618 };
619 #else
620 struct i2c_gpio_platform_data default_i2c2_data = {
621        .sda_pin = RK29_PIN5_PD3,
622        .scl_pin = RK29_PIN5_PD4,
623        .udelay = 5, // clk = 500/udelay = 100Khz
624        .timeout = 100,//msecs_to_jiffies(200),
625        .bus_num    = 2,
626        .io_init = rk29_i2c2_io_init,
627 };
628 #endif
629 #ifdef CONFIG_RK29_I2C3_CONTROLLER
630 struct rk29_i2c_platform_data default_i2c3_data = {
631         .bus_num    = 3,
632         .flags      = 0,
633         .slave_addr = 0xff,
634         .scl_rate  = 400*1000,
635         .mode           = I2C_MODE_IRQ,
636         .io_init = rk29_i2c3_io_init,
637 };
638 #else
639 struct i2c_gpio_platform_data default_i2c3_data = {
640        .sda_pin = RK29_PIN5_PB5,
641        .scl_pin = RK29_PIN5_PB4,
642        .udelay = 5, // clk = 500/udelay = 100Khz
643        .timeout = 100,//msecs_to_jiffies(200),
644        .bus_num    = 3,
645        .io_init = rk29_i2c3_io_init,
646 };
647 #endif
648 #ifdef CONFIG_I2C0_RK29
649 static struct i2c_board_info __initdata board_i2c0_devices[] = {
650 #if defined (CONFIG_RK1000_CONTROL)
651         {
652                 .type                   = "rk1000_control",
653                 .addr           = 0x40,
654                 .flags                  = 0,
655         },
656 #endif
657 #if defined (CONFIG_SND_SOC_alc5621)
658         {
659                 .type                   = "ALC5621",
660                 .addr                   = 0x1a,
661                 .flags                  = 0,
662         },
663 #endif
664 #if defined (CONFIG_SND_SOC_alc5631)
665         {
666                 .type                   = "rt5631",
667                 .addr                   = 0x1a,
668                 .flags                  = 0,
669         },
670 #endif
671 #if defined (CONFIG_SND_SOC_RK1000)
672         {
673                 .type                   = "rk1000_i2c_codec",
674                 .addr           = 0x60,
675                 .flags                  = 0,
676         },
677 #endif
678 #if defined (CONFIG_SND_SOC_WM8900)
679         {
680                 .type                   = "wm8900",
681                 .addr           = 0x1A,
682                 .flags                  = 0,
683         },
684 #endif
685 #if defined (CONFIG_BATTERY_STC3100)
686         {
687                 .type                   = "stc3100",
688                 .addr           = 0x70,
689                 .flags                  = 0,
690         },
691 #endif
692 #if defined (CONFIG_BATTERY_BQ27510)
693         {
694                 .type                   = "bq27510",
695                 .addr           = 0x55,
696                 .flags                  = 0,
697                 .platform_data  = &bq27510_info,
698         },
699 #endif
700 #if defined (CONFIG_RTC_HYM8563)
701         {
702                 .type                   = "rtc_hym8563",
703                 .addr           = 0x51,
704                 .flags                  = 0,
705                 .irq            = RK29_PIN0_PA1,
706         },
707 #endif
708 #if defined (CONFIG_GS_MMA8452)
709     {
710       .type           = "gs_mma8452",
711       .addr           = 0x1c,
712       .flags          = 0,
713       .irq            = MMA8452_INT_PIN,
714       .platform_data  = &mma8452_info,
715     },
716 #endif
717 #if defined (CONFIG_COMPASS_AK8973)
718         {
719                 .type                   = "ak8973",
720                 .addr           = 0x1d,
721                 .flags                  = 0,
722                 .irq                    = RK29_PIN0_PA4,
723         },
724 #endif
725 #if defined (CONFIG_COMPASS_AK8975)
726         {
727                 .type                   = "ak8975",
728                 .addr           = 0x0d,
729                 .flags                  = 0,
730                 .irq                    = RK29_PIN0_PA4,
731         },
732 #endif
733 };
734 #endif
735
736 #ifdef CONFIG_I2C1_RK29
737 static struct i2c_board_info __initdata board_i2c1_devices[] = {
738 #if defined (CONFIG_RK1000_CONTROL1)
739         {
740                 .type                   = "rk1000_control",
741                 .addr                   = 0x40,
742                 .flags                  = 0,
743         },
744 #endif
745 #if defined (CONFIG_ANX7150) || defined (CONFIG_ANX7150_NEW)
746     {
747                 .type           = "anx7150",
748         .addr           = 0x39,             //0x39, 0x3d
749         .flags          = 0,
750         .irq            = RK29_PIN1_PD7,
751     },
752 #endif
753
754 };
755 #endif
756
757 #ifdef CONFIG_I2C2_RK29
758 static struct i2c_board_info __initdata board_i2c2_devices[] = {
759 #if defined (CONFIG_HANNSTAR_P1003)
760     {
761       .type           = "p1003_touch",
762       .addr           = 0x04,
763       .flags          = 0, //I2C_M_NEED_DELAY
764       .irq            = RK29_PIN0_PA2,
765       .platform_data  = &p1003_info,
766       //.udelay           = 100
767     },
768 #endif
769 #if defined (CONFIG_EETI_EGALAX)
770     {
771       .type           = "egalax_i2c",
772       .addr           = 0x04,
773       .flags          = 0,
774       .irq            = RK29_PIN0_PA2,
775       .platform_data  = &eeti_egalax_info,
776     },
777 #endif
778 };
779 #endif
780
781 #ifdef CONFIG_I2C3_RK29
782 static struct i2c_board_info __initdata board_i2c3_devices[] = {
783 };
784 #endif
785
786 /*****************************************************************************************
787  * camera  devices
788  * author: ddl@rock-chips.com
789  *****************************************************************************************/
790 #ifdef CONFIG_VIDEO_RK29 
791 #define CONFIG_SENSOR_POWER_IOCTL_USR      0
792 #define CONFIG_SENSOR_RESET_IOCTL_USR      0
793 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR      0
794 #define CONFIG_SENSOR_FLASH_IOCTL_USR      0
795
796 #if CONFIG_SENSOR_POWER_IOCTL_USR
797 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
798 {
799     #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
800 }
801 #endif
802
803 #if CONFIG_SENSOR_RESET_IOCTL_USR
804 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
805 {
806     #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
807 }
808 #endif
809
810 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
811 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
812 {
813     #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
814 }
815 #endif
816
817 #if CONFIG_SENSOR_FLASH_IOCTL_USR
818 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
819 {
820     #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
821 }
822 #endif
823
824 static struct rk29camera_platform_ioctl_cb  sensor_ioctl_cb = {
825     #if CONFIG_SENSOR_POWER_IOCTL_USR
826     .sensor_power_cb = sensor_power_usr_cb,
827     #else
828     .sensor_power_cb = NULL,
829     #endif
830
831     #if CONFIG_SENSOR_RESET_IOCTL_USR
832     .sensor_reset_cb = sensor_reset_usr_cb,
833     #else
834     .sensor_reset_cb = NULL,
835     #endif
836
837     #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
838     .sensor_powerdown_cb = sensor_powerdown_usr_cb,
839     #else
840     .sensor_powerdown_cb = NULL,
841     #endif
842
843     #if CONFIG_SENSOR_FLASH_IOCTL_USR
844     .sensor_flash_cb = sensor_flash_usr_cb,
845     #else
846     .sensor_flash_cb = NULL,
847     #endif
848 };
849
850 #include "../../../drivers/media/video/rk29_camera.c"
851 #endif
852 /*****************************************************************************************
853  * backlight  devices
854  * author: nzy@rock-chips.com
855  *****************************************************************************************/
856 #ifdef CONFIG_BACKLIGHT_RK29_BL
857  /*
858  GPIO1B5_PWM0_NAME,       GPIO1L_PWM0
859  GPIO5D2_PWM1_UART1SIRIN_NAME,  GPIO5H_PWM1
860  GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME,   GPIO2L_PWM2
861  GPIO1A5_EMMCPWREN_PWM3_NAME,     GPIO1L_PWM3
862  */
863
864 #define PWM_ID            0
865 #define PWM_MUX_NAME      GPIO1B5_PWM0_NAME
866 #define PWM_MUX_MODE      GPIO1L_PWM0
867 #define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
868 #define PWM_GPIO RK29_PIN1_PB5
869 #define PWM_EFFECT_VALUE  1
870
871 #define LCD_DISP_ON_PIN
872
873 #ifdef  LCD_DISP_ON_PIN
874 //#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
875 //#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
876
877 #define BL_EN_PIN         RK29_PIN6_PD0
878 #define BL_EN_VALUE       GPIO_HIGH
879 #endif
880 static int rk29_backlight_io_init(void)
881 {
882     int ret = 0;
883
884     rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
885         #ifdef  LCD_DISP_ON_PIN
886    // rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
887
888     ret = gpio_request(BL_EN_PIN, NULL);
889     if(ret != 0)
890     {
891         gpio_free(BL_EN_PIN);
892     }
893
894     gpio_direction_output(BL_EN_PIN, 0);
895     gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
896         #endif
897     return ret;
898 }
899
900 static int rk29_backlight_io_deinit(void)
901 {
902     int ret = 0;
903     #ifdef  LCD_DISP_ON_PIN
904     gpio_free(BL_EN_PIN);
905     #endif
906     rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
907     return ret;
908 }
909
910 static int rk29_backlight_pwm_suspend(void)
911 {
912         int ret = 0;
913         rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
914         if (gpio_request(PWM_GPIO, NULL)) {
915                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
916                 return -1;
917         }
918         gpio_direction_output(PWM_GPIO, GPIO_LOW);
919    #ifdef  LCD_DISP_ON_PIN
920     gpio_direction_output(BL_EN_PIN, 0);
921     gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
922    #endif
923         return ret;
924 }
925
926 static int rk29_backlight_pwm_resume(void)
927 {
928         gpio_free(PWM_GPIO);
929         rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
930
931     #ifdef  LCD_DISP_ON_PIN
932     msleep(30);
933     gpio_direction_output(BL_EN_PIN, 1);
934     gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
935     #endif
936         return 0;
937 }
938
939 struct rk29_bl_info rk29_bl_info = {
940     .pwm_id   = PWM_ID,
941     .bl_ref   = PWM_EFFECT_VALUE,
942     .io_init   = rk29_backlight_io_init,
943     .io_deinit = rk29_backlight_io_deinit,
944     .pwm_suspend = rk29_backlight_pwm_suspend,
945     .pwm_resume = rk29_backlight_pwm_resume,
946 };
947 #endif
948 /*****************************************************************************************
949 * pwm voltage regulator devices
950 ******************************************************************************************/
951 #if defined (CONFIG_RK29_PWM_REGULATOR)
952
953 #define REGULATOR_PWM_ID                                        2
954 #define REGULATOR_PWM_MUX_NAME                  GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
955 #define REGULATOR_PWM_MUX_MODE                                          GPIO2L_PWM2
956 #define REGULATOR_PWM_MUX_MODE_GPIO                             GPIO2L_GPIO2A3
957 #define REGULATOR_PWM_GPIO                              RK29_PIN2_PA3
958
959 static struct regulator_consumer_supply pwm_consumers[] = {
960         {
961                 .supply = "vcore",
962         }
963 };
964
965 static struct regulator_init_data rk29_pwm_regulator_data = {
966         .constraints = {
967                 .name = "PWM2",
968                 .min_uV =  950000,
969                 .max_uV = 1400000,
970                 .apply_uV = 1,
971                 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
972         },
973         .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
974         .consumer_supplies = pwm_consumers,
975 };
976
977 static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
978         .pwm_id = REGULATOR_PWM_ID,
979         .pwm_gpio = REGULATOR_PWM_GPIO,
980         //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
981         .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
982         .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
983         .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
984         .init_data  = &rk29_pwm_regulator_data,
985 };
986
987 static struct platform_device rk29_device_pwm_regulator = {
988         .name = "pwm-voltage-regulator",
989         .id   = -1,
990         .dev  = {
991                 .platform_data = &rk29_regulator_pwm_platform_data,
992         },
993 };
994
995 #endif
996
997 /*****************************************************************************************
998  * SDMMC devices
999 *****************************************************************************************/
1000 #ifdef CONFIG_SDMMC0_RK29
1001 static int rk29_sdmmc0_cfg_gpio(void)
1002 {
1003         rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
1004         rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
1005         rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
1006         rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
1007         rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
1008         rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
1009         rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
1010         rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5);   ///GPIO5H_SDMMC0_PWR_EN);  ///GPIO5H_GPIO5D5);
1011         gpio_request(RK29_PIN5_PD5,"sdmmc");
1012 #if 0
1013         gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
1014         mdelay(100);
1015         gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
1016 #else
1017         gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
1018 #endif
1019         return 0;
1020 }
1021
1022 #define CONFIG_SDMMC0_USE_DMA
1023 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1024         .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
1025                                            MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
1026                                            MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
1027         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1028         .io_init = rk29_sdmmc0_cfg_gpio,
1029         .dma_name = "sd_mmc",
1030 #ifdef CONFIG_SDMMC0_USE_DMA
1031         .use_dma  = 1,
1032 #else
1033         .use_dma = 0,
1034 #endif
1035         .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
1036         .enable_sd_wakeup = 0,
1037 };
1038 #endif
1039 #ifdef CONFIG_SDMMC1_RK29
1040 #define CONFIG_SDMMC1_USE_DMA
1041 static int rk29_sdmmc1_cfg_gpio(void)
1042 {
1043         rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
1044         rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
1045         rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
1046         rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
1047         rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
1048         rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
1049         //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
1050         return 0;
1051 }
1052
1053 #ifdef CONFIG_WIFI_CONTROL_FUNC
1054 static int rk29sdk_wifi_status(struct device *dev);
1055 static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
1056 #endif
1057
1058 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK29_PIN1_PD6
1059
1060 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1061         .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
1062                                            MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
1063                                            MMC_VDD_32_33|MMC_VDD_33_34),
1064         .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
1065                                    MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
1066         .io_init = rk29_sdmmc1_cfg_gpio,
1067         .dma_name = "sdio",
1068 #ifdef CONFIG_SDMMC1_USE_DMA
1069         .use_dma  = 1,
1070 #else
1071         .use_dma = 0,
1072 #endif
1073 #ifdef CONFIG_WIFI_CONTROL_FUNC
1074         .status = rk29sdk_wifi_status,
1075         .register_status_notify = rk29sdk_wifi_status_register,
1076 #endif
1077 #if 0
1078         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1079 #endif
1080 };
1081 #endif
1082
1083 #ifdef CONFIG_WIFI_CONTROL_FUNC
1084 #define RK29SDK_WIFI_BT_GPIO_POWER_N       RK29_PIN5_PD6
1085 #define RK29SDK_WIFI_GPIO_RESET_N          RK29_PIN6_PC0
1086 #define RK29SDK_BT_GPIO_RESET_N            RK29_PIN6_PC4
1087
1088 static int rk29sdk_wifi_cd = 0;   /* wifi virtual 'card detect' status */
1089 static void (*wifi_status_cb)(int card_present, void *dev_id);
1090 static void *wifi_status_cb_devid;
1091 int rk29sdk_wifi_power_state = 0;
1092 int rk29sdk_bt_power_state = 0;
1093
1094 static int rk29sdk_wifi_status(struct device *dev)
1095 {
1096         return rk29sdk_wifi_cd;
1097 }
1098
1099 static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
1100 {
1101         if(wifi_status_cb)
1102                 return -EAGAIN;
1103         wifi_status_cb = callback;
1104         wifi_status_cb_devid = dev_id;
1105         return 0;
1106 }
1107
1108 static int rk29sdk_wifi_bt_gpio_control_init(void)
1109 {
1110     if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
1111            pr_info("%s: request wifi_bt power gpio failed\n", __func__);
1112            return -1;
1113     }
1114
1115     if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
1116            pr_info("%s: request wifi reset gpio failed\n", __func__);
1117            gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
1118            return -1;
1119     }
1120
1121     if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
1122           pr_info("%s: request bt reset gpio failed\n", __func__);
1123           gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
1124           return -1;
1125     }
1126
1127     gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1128     gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N,    GPIO_LOW);
1129     gpio_direction_output(RK29SDK_BT_GPIO_RESET_N,      GPIO_LOW);
1130
1131     pr_info("%s: init finished\n",__func__);
1132
1133     return 0;
1134 }
1135
1136 static int rk29sdk_wifi_power(int on)
1137 {
1138         pr_info("%s: %d\n", __func__, on);
1139         if (on){
1140                 gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
1141                 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
1142                 mdelay(100);
1143                 pr_info("wifi turn on power\n");
1144         }else{
1145                 if (!rk29sdk_bt_power_state){
1146                         gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
1147                         mdelay(100);
1148                         pr_info("wifi shut off power\n");
1149                 }else
1150                 {
1151                         pr_info("wifi shouldn't shut off power, bt is using it!\n");
1152                 }
1153                 gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
1154
1155         }
1156
1157         rk29sdk_wifi_power_state = on;
1158         return 0;
1159 }
1160
1161 static int rk29sdk_wifi_reset_state;
1162 static int rk29sdk_wifi_reset(int on)
1163 {
1164         pr_info("%s: %d\n", __func__, on);
1165         gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
1166         mdelay(100);
1167         rk29sdk_wifi_reset_state = on;
1168         return 0;
1169 }
1170
1171 int rk29sdk_wifi_set_carddetect(int val)
1172 {
1173         pr_info("%s:%d\n", __func__, val);
1174         rk29sdk_wifi_cd = val;
1175         if (wifi_status_cb){
1176                 wifi_status_cb(val, wifi_status_cb_devid);
1177         }else {
1178                 pr_warning("%s, nobody to notify\n", __func__);
1179         }
1180         return 0;
1181 }
1182 EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
1183
1184 static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
1185         {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
1186         {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
1187         {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
1188         {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
1189 };
1190
1191 static void *rk29sdk_mem_prealloc(int section, unsigned long size)
1192 {
1193         if (section == PREALLOC_WLAN_SEC_NUM)
1194                 return wlan_static_skb;
1195
1196         if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
1197                 return NULL;
1198
1199         if (wifi_mem_array[section].size < size)
1200                 return NULL;
1201
1202         return wifi_mem_array[section].mem_ptr;
1203 }
1204
1205 int __init rk29sdk_init_wifi_mem(void)
1206 {
1207         int i;
1208         int j;
1209
1210         for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
1211                 wlan_static_skb[i] = dev_alloc_skb(
1212                                 ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
1213
1214                 if (!wlan_static_skb[i])
1215                         goto err_skb_alloc;
1216         }
1217
1218         for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
1219                 wifi_mem_array[i].mem_ptr =
1220                                 kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
1221
1222                 if (!wifi_mem_array[i].mem_ptr)
1223                         goto err_mem_alloc;
1224         }
1225         return 0;
1226
1227 err_mem_alloc:
1228         pr_err("Failed to mem_alloc for WLAN\n");
1229         for (j = 0 ; j < i ; j++)
1230                kfree(wifi_mem_array[j].mem_ptr);
1231
1232         i = WLAN_SKB_BUF_NUM;
1233
1234 err_skb_alloc:
1235         pr_err("Failed to skb_alloc for WLAN\n");
1236         for (j = 0 ; j < i ; j++)
1237                 dev_kfree_skb(wlan_static_skb[j]);
1238
1239         return -ENOMEM;
1240 }
1241
1242 static struct wifi_platform_data rk29sdk_wifi_control = {
1243         .set_power = rk29sdk_wifi_power,
1244         .set_reset = rk29sdk_wifi_reset,
1245         .set_carddetect = rk29sdk_wifi_set_carddetect,
1246         .mem_prealloc   = rk29sdk_mem_prealloc,
1247 };
1248 static struct platform_device rk29sdk_wifi_device = {
1249         .name = "bcm4329_wlan",
1250         .id = 1,
1251         .dev = {
1252                 .platform_data = &rk29sdk_wifi_control,
1253          },
1254 };
1255 #endif
1256
1257
1258 /* bluetooth rfkill device */
1259 static struct platform_device rk29sdk_rfkill = {
1260         .name = "rk29sdk_rfkill",
1261         .id = -1,
1262 };
1263
1264
1265 #ifdef CONFIG_VIVANTE
1266 #define GPU_HIGH_CLOCK        552
1267 #define GPU_LOW_CLOCK         288 /* same as general pll clock rate below */
1268 static struct resource resources_gpu[] = {
1269     [0] = {
1270                 .name   = "gpu_irq",
1271         .start  = IRQ_GPU,
1272         .end    = IRQ_GPU,
1273         .flags  = IORESOURCE_IRQ,
1274     },
1275     [1] = {
1276                 .name   = "gpu_base",
1277         .start  = RK29_GPU_PHYS,
1278         .end    = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
1279         .flags  = IORESOURCE_MEM,
1280     },
1281     [2] = {
1282                 .name   = "gpu_mem",
1283         .start  = PMEM_GPU_BASE,
1284         .end    = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
1285         .flags  = IORESOURCE_MEM,
1286     },
1287     [3] = {
1288                 .name   = "gpu_clk",
1289         .start  = GPU_LOW_CLOCK,
1290         .end    = GPU_HIGH_CLOCK,
1291         .flags  = IORESOURCE_IO,
1292     },
1293 };
1294 static struct platform_device rk29_device_gpu = {
1295     .name             = "galcore",
1296     .id               = 0,
1297     .num_resources    = ARRAY_SIZE(resources_gpu),
1298     .resource         = resources_gpu,
1299 };
1300 #endif
1301
1302 #ifdef CONFIG_KEYS_RK29
1303 extern struct rk29_keys_platform_data rk29_keys_pdata;
1304 static struct platform_device rk29_device_keys = {
1305         .name           = "rk29-keypad",
1306         .id             = -1,
1307         .dev            = {
1308                 .platform_data  = &rk29_keys_pdata,
1309         },
1310 };
1311 #endif
1312
1313 static void __init rk29_board_iomux_init(void)
1314 {
1315         #ifdef CONFIG_RK29_PWM_REGULATOR
1316         rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
1317         #endif
1318 }
1319
1320 static struct platform_device *devices[] __initdata = {
1321
1322 #ifdef CONFIG_RK29_WATCHDOG
1323         &rk29_device_wdt,
1324 #endif
1325
1326 #ifdef CONFIG_UART1_RK29
1327         &rk29_device_uart1,
1328 #endif
1329 #ifdef CONFIG_UART0_RK29
1330         &rk29_device_uart0,
1331 #endif
1332 #ifdef CONFIG_UART2_RK29
1333         &rk29_device_uart2,
1334 #endif
1335 #ifdef CONFIG_UART3_RK29
1336         &rk29_device_uart3,
1337 #endif
1338
1339 #ifdef CONFIG_RK29_PWM_REGULATOR
1340         &rk29_device_pwm_regulator,
1341 #endif
1342 #ifdef CONFIG_SPIM0_RK29
1343     &rk29xx_device_spi0m,
1344 #endif
1345 #ifdef CONFIG_SPIM1_RK29
1346     &rk29xx_device_spi1m,
1347 #endif
1348 #ifdef CONFIG_ADC_RK29
1349         &rk29_device_adc,
1350 #endif
1351 #ifdef CONFIG_I2C0_RK29
1352         &rk29_device_i2c0,
1353 #endif
1354 #ifdef CONFIG_I2C1_RK29
1355         &rk29_device_i2c1,
1356 #endif
1357 #ifdef CONFIG_I2C2_RK29
1358         &rk29_device_i2c2,
1359 #endif
1360 #ifdef CONFIG_I2C3_RK29
1361         &rk29_device_i2c3,
1362 #endif
1363
1364 #ifdef CONFIG_SND_RK29_SOC_I2S_2CH
1365         &rk29_device_iis_2ch,
1366 #endif
1367 #ifdef CONFIG_SND_RK29_SOC_I2S_8CH
1368         &rk29_device_iis_8ch,
1369 #endif
1370
1371 #ifdef CONFIG_KEYS_RK29
1372         &rk29_device_keys,
1373 #endif
1374 #ifdef CONFIG_SDMMC0_RK29
1375         &rk29_device_sdmmc0,
1376 #endif
1377 #ifdef CONFIG_SDMMC1_RK29
1378         &rk29_device_sdmmc1,
1379 #endif
1380
1381 #ifdef CONFIG_MTD_NAND_RK29XX
1382         &rk29xx_device_nand,
1383 #endif
1384
1385 #ifdef CONFIG_WIFI_CONTROL_FUNC
1386         &rk29sdk_wifi_device,
1387 #endif
1388
1389 #ifdef CONFIG_BT
1390         &rk29sdk_rfkill,
1391 #endif
1392
1393 #ifdef CONFIG_MTD_NAND_RK29
1394         &rk29_device_nand,
1395 #endif
1396
1397 #ifdef CONFIG_FB_RK29
1398         &rk29_device_fb,
1399         &rk29_device_dma_cpy,
1400 #endif
1401 #ifdef CONFIG_BACKLIGHT_RK29_BL
1402         &rk29_device_backlight,
1403 #endif
1404 #ifdef CONFIG_RK29_VMAC
1405         &rk29_device_vmac,
1406 #endif
1407 #ifdef CONFIG_VIVANTE
1408         &rk29_device_gpu,
1409 #endif
1410 #ifdef CONFIG_VIDEO_RK29
1411         &rk29_device_camera,      /* ddl@rock-chips.com : camera support  */
1412         #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
1413         &rk29_soc_camera_pdrv_0,
1414         #endif
1415         &rk29_soc_camera_pdrv_1,
1416         &android_pmem_cam_device,
1417 #endif
1418         &android_pmem_device,
1419         &rk29_vpu_mem_device,
1420 #ifdef CONFIG_USB20_OTG
1421         &rk29_device_usb20_otg,
1422 #endif
1423 #ifdef CONFIG_USB20_HOST
1424         &rk29_device_usb20_host,
1425 #endif
1426 #ifdef CONFIG_USB11_HOST
1427         &rk29_device_usb11_host,
1428 #endif
1429 #ifdef CONFIG_USB_ANDROID
1430         &android_usb_device,
1431         &usb_mass_storage_device,
1432 #endif
1433 #ifdef CONFIG_RK29_IPP
1434         &rk29_device_ipp,
1435 #endif
1436 #ifdef CONFIG_VIDEO_RK29XX_VOUT
1437         &rk29_v4l2_output_devce,
1438 #endif
1439 };
1440
1441 /*****************************************************************************************
1442  * spi devices
1443  * author: cmc@rock-chips.com
1444  *****************************************************************************************/
1445 static int rk29_vmac_register_set(void)
1446 {
1447         //config rk29 vmac as rmii, 100MHz
1448         u32 value= readl(RK29_GRF_BASE + 0xbc);
1449         value = (value & 0xfff7ff) | (0x400);
1450         writel(value, RK29_GRF_BASE + 0xbc);
1451         return 0;
1452 }
1453
1454 static int rk29_rmii_io_init(void)
1455 {
1456         int err;
1457
1458         //phy power gpio
1459         err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
1460         if (err) {
1461                 gpio_free(RK29_PIN6_PB0);
1462                 printk("-------request RK29_PIN6_PB0 fail--------\n");
1463                 return -1;
1464         }
1465         //phy power down
1466         gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1467         gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1468
1469         return 0;
1470 }
1471
1472 static int rk29_rmii_io_deinit(void)
1473 {
1474         //phy power down
1475         gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1476         gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1477         //free
1478         gpio_free(RK29_PIN6_PB0);
1479         return 0;
1480 }
1481
1482 static int rk29_rmii_power_control(int enable)
1483 {
1484         if (enable) {
1485                 //enable phy power
1486                 gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
1487                 gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
1488         }
1489         else {
1490                 gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
1491                 gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
1492         }
1493         return 0;
1494 }
1495
1496 struct rk29_vmac_platform_data rk29_vmac_pdata = {
1497         .vmac_register_set = rk29_vmac_register_set,
1498         .rmii_io_init = rk29_rmii_io_init,
1499         .rmii_io_deinit = rk29_rmii_io_deinit,
1500         .rmii_power_control = rk29_rmii_power_control,
1501 };
1502
1503 /*****************************************************************************************
1504  * spi devices
1505  * author: cmc@rock-chips.com
1506  *****************************************************************************************/
1507 #define SPI_CHIPSELECT_NUM 2
1508 static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
1509     {
1510                 .name = "spi0 cs0",
1511                 .cs_gpio = RK29_PIN2_PC1,
1512                 .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
1513                 .cs_iomux_mode = GPIO2H_SPI0_CSN0,
1514         },
1515         {
1516                 .name = "spi0 cs1",
1517                 .cs_gpio = RK29_PIN1_PA4,
1518                 .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
1519                 .cs_iomux_mode = GPIO1L_SPI0_CSN1,
1520         }
1521 };
1522
1523 static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
1524     {
1525                 .name = "spi1 cs0",
1526                 .cs_gpio = RK29_PIN2_PC5,
1527                 .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
1528                 .cs_iomux_mode = GPIO2H_SPI1_CSN0,
1529         },
1530         {
1531                 .name = "spi1 cs1",
1532                 .cs_gpio = RK29_PIN1_PA3,
1533                 .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
1534                 .cs_iomux_mode = GPIO1L_SPI1_CSN1,
1535         }
1536 };
1537
1538 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
1539 {
1540 #if 1
1541         int i;
1542         if (cs_gpios) {
1543                 for (i=0; i<cs_num; i++) {
1544                         rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
1545                 }
1546         }
1547 #endif
1548         return 0;
1549 }
1550
1551 static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
1552 {
1553         return 0;
1554 }
1555
1556 static int spi_io_fix_leakage_bug(void)
1557 {
1558 #if 0
1559         gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
1560 #endif
1561         return 0;
1562 }
1563
1564 static int spi_io_resume_leakage_bug(void)
1565 {
1566 #if 0
1567         gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
1568 #endif
1569         return 0;
1570 }
1571
1572 struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
1573         .num_chipselect = SPI_CHIPSELECT_NUM,
1574         .chipselect_gpios = rk29xx_spi0_cs_gpios,
1575         .io_init = spi_io_init,
1576         .io_deinit = spi_io_deinit,
1577         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1578         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1579 };
1580
1581 struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
1582         .num_chipselect = SPI_CHIPSELECT_NUM,
1583         .chipselect_gpios = rk29xx_spi1_cs_gpios,
1584         .io_init = spi_io_init,
1585         .io_deinit = spi_io_deinit,
1586         .io_fix_leakage_bug = spi_io_fix_leakage_bug,
1587         .io_resume_leakage_bug = spi_io_resume_leakage_bug,
1588 };
1589
1590 /*****************************************************************************************
1591  * xpt2046 touch panel
1592  * author: cmc@rock-chips.com
1593  *****************************************************************************************/
1594 #define XPT2046_GPIO_INT           RK29_PIN0_PA3
1595 #define DEBOUNCE_REPTIME  3
1596
1597 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
1598 static struct xpt2046_platform_data xpt2046_info = {
1599         .model                  = 2046,
1600         .keep_vref_on   = 1,
1601         .swap_xy                = 0,
1602         .x_min                  = 0,
1603         .x_max                  = 320,
1604         .y_min                  = 0,
1605         .y_max                  = 480,
1606         .debounce_max           = 7,
1607         .debounce_rep           = DEBOUNCE_REPTIME,
1608         .debounce_tol           = 20,
1609         .gpio_pendown           = XPT2046_GPIO_INT,
1610         .penirq_recheck_delay_usecs = 1,
1611 };
1612 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
1613 static struct xpt2046_platform_data xpt2046_info = {
1614         .model                  = 2046,
1615         .keep_vref_on   = 1,
1616         .swap_xy                = 0,
1617         .x_min                  = 0,
1618         .x_max                  = 320,
1619         .y_min                  = 0,
1620         .y_max                  = 480,
1621         .debounce_max           = 7,
1622         .debounce_rep           = DEBOUNCE_REPTIME,
1623         .debounce_tol           = 20,
1624         .gpio_pendown           = XPT2046_GPIO_INT,
1625         .penirq_recheck_delay_usecs = 1,
1626 };
1627 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
1628 static struct xpt2046_platform_data xpt2046_info = {
1629         .model                  = 2046,
1630         .keep_vref_on   = 1,
1631         .swap_xy                = 1,
1632         .x_min                  = 0,
1633         .x_max                  = 800,
1634         .y_min                  = 0,
1635         .y_max                  = 480,
1636         .debounce_max           = 7,
1637         .debounce_rep           = DEBOUNCE_REPTIME,
1638         .debounce_tol           = 20,
1639         .gpio_pendown           = XPT2046_GPIO_INT,
1640
1641         .penirq_recheck_delay_usecs = 1,
1642 };
1643 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1644 static struct xpt2046_platform_data xpt2046_info = {
1645         .model                  = 2046,
1646         .keep_vref_on   = 1,
1647         .swap_xy                = 1,
1648         .x_min                  = 0,
1649         .x_max                  = 800,
1650         .y_min                  = 0,
1651         .y_max                  = 480,
1652         .debounce_max           = 7,
1653         .debounce_rep           = DEBOUNCE_REPTIME,
1654         .debounce_tol           = 20,
1655         .gpio_pendown           = XPT2046_GPIO_INT,
1656
1657         .penirq_recheck_delay_usecs = 1,
1658 };
1659 #endif
1660
1661 static struct spi_board_info board_spi_devices[] = {
1662 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
1663     ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
1664         {
1665                 .modalias       = "xpt2046_ts",
1666                 .chip_select    = 0,
1667                 .max_speed_hz   = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
1668                 .bus_num        = 0,
1669                 .irq = XPT2046_GPIO_INT,
1670                 .platform_data = &xpt2046_info,
1671         },
1672 #endif
1673 };
1674
1675
1676 static void __init rk29_gic_init_irq(void)
1677 {
1678         gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
1679         gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
1680 }
1681
1682 static void __init machine_rk29_init_irq(void)
1683 {
1684         rk29_gic_init_irq();
1685         rk29_gpio_init();
1686 }
1687
1688 static struct cpufreq_frequency_table freq_table[] = {
1689         { .index = 1200000, .frequency =  408000 },
1690         { .index = 1200000, .frequency =  816000 },
1691         { .index = 1300000, .frequency = 1008000 },
1692         { .frequency = CPUFREQ_TABLE_END },
1693 };
1694
1695 static void __init machine_rk29_board_init(void)
1696 {
1697         rk29_board_iomux_init();
1698
1699         board_power_init();
1700         board_update_cpufreq_table(freq_table);
1701
1702                 platform_add_devices(devices, ARRAY_SIZE(devices));
1703 #ifdef CONFIG_I2C0_RK29
1704         i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
1705                         ARRAY_SIZE(board_i2c0_devices));
1706 #endif
1707 #ifdef CONFIG_I2C1_RK29
1708         i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
1709                         ARRAY_SIZE(board_i2c1_devices));
1710 #endif
1711 #ifdef CONFIG_I2C2_RK29
1712         i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
1713                         ARRAY_SIZE(board_i2c2_devices));
1714 #endif
1715 #ifdef CONFIG_I2C3_RK29
1716         i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
1717                         ARRAY_SIZE(board_i2c3_devices));
1718 #endif
1719
1720         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1721         
1722 #ifdef CONFIG_WIFI_CONTROL_FUNC
1723         rk29sdk_wifi_bt_gpio_control_init();
1724         rk29sdk_init_wifi_mem();
1725 #endif
1726
1727         board_usb_detect_init(RK29_PIN0_PA0);
1728 }
1729
1730 static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
1731                                         char **cmdline, struct meminfo *mi)
1732 {
1733         mi->nr_banks = 1;
1734         mi->bank[0].start = RK29_SDRAM_PHYS;
1735         mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
1736         mi->bank[0].size = LINUX_SIZE;
1737 #if SDRAM_SIZE > SZ_512M
1738         mi->nr_banks = 2;
1739         mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
1740         mi->bank[1].size = SDRAM_SIZE - SZ_512M;
1741 #endif
1742 }
1743
1744 static void __init machine_rk29_mapio(void)
1745 {
1746         rk29_map_common_io();
1747         rk29_setup_early_printk();
1748         rk29_sram_init();
1749         rk29_clock_init(periph_pll_default);
1750         rk29_iomux_init();
1751         ddr_init(DDR_TYPE, DDR_FREQ);
1752 }
1753
1754 MACHINE_START(RK29, "RK29board")
1755         /* UART for LL DEBUG */
1756         .phys_io        = RK29_UART1_PHYS & 0xfff00000,
1757         .io_pg_offst    = ((RK29_UART1_BASE) >> 18) & 0xfffc,
1758         .boot_params    = RK29_SDRAM_PHYS + 0x88000,
1759         .fixup          = machine_rk29_fixup,
1760         .map_io         = machine_rk29_mapio,
1761         .init_irq       = machine_rk29_init_irq,
1762         .init_machine   = machine_rk29_board_init,
1763         .timer          = &rk29_timer,
1764 MACHINE_END