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