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