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