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