rk3026: i2s add several attempts to double confirm i2s frac effect
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk3188 / board-rk3188-fac.c
1 /*
2  *
3  * Copyright (C) 2012 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/skbuff.h>
24 #include <linux/spi/spi.h>
25 #include <linux/mmc/host.h>
26 #include <linux/ion.h>
27 #include <linux/cpufreq.h>
28 #include <linux/clk.h>
29 #include <mach/dvfs.h>
30
31 #include <asm/setup.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/flash.h>
36 #include <asm/hardware/gic.h>
37
38 #include <mach/board.h>
39 #include <mach/hardware.h>
40 #include <mach/io.h>
41 #include <mach/gpio.h>
42 #include <mach/iomux.h>
43 #include <linux/rk_fb.h>
44 #include <linux/regulator/machine.h>
45 #include <linux/rfkill-rk.h>
46 #include <linux/sensor-dev.h>
47 #include <linux/mfd/tps65910.h>
48 #include <linux/regulator/act8846.h>
49 #include <linux/mfd/rk808.h>
50 #include <linux/regulator/rk29-pwm-regulator.h>
51
52 #if defined(CONFIG_MFD_RK610)
53 #include <linux/mfd/rk610_core.h>
54 #endif
55
56 #if defined(CONFIG_MFD_RK616)
57 #include <linux/mfd/rk616.h>
58 #endif
59
60
61 #if defined(CONFIG_RK_HDMI)
62         #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
63 #endif
64
65 #if defined(CONFIG_SPIM_RK29)
66 #include "../../../drivers/spi/rk29_spim.h"
67 #endif
68 #if defined(CONFIG_GPS_RK)
69 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
70 #endif
71 #if defined(CONFIG_MU509)
72 #include <linux/mu509.h>
73 #endif
74 #if defined(CONFIG_MW100)
75 #include <linux/mw100.h>
76 #endif
77 #if defined(CONFIG_MT6229)
78 #include <linux/mt6229.h>
79 #endif
80 #if defined(CONFIG_ANDROID_TIMED_GPIO)
81 #include "../../../drivers/staging/android/timed_gpio.h"
82 #endif
83
84 #if defined(CONFIG_MT6620)
85 #include <linux/gps.h>
86 #endif
87 #include "../mach-rk30/board-rk3168-tb-camera.c"
88
89 #include <plat/config.h>
90 #include <plat/board.h>
91 #include "../plat-rk/rk-fac-config.c"
92 #if 1
93 #define INIT_ERR(name)     do { printk("%s: %s init Failed: \n", __func__, (name)); } while(0)
94 #else
95 #define INIT_ERR(name)
96 #endif
97
98 ////////////////////////////////////////////////////////////////////////////////////////
99 #include <plat/key.h>
100 static struct rk29_keys_button key_button[] = { 
101         {               
102                 .desc   = "play",               
103                 .code   = KEY_POWER,            
104                 .wakeup = 1,    
105         },      
106         {               
107                 .desc   = "vol-",       
108                 .code   = KEY_VOLUMEDOWN,       
109         },      
110         {               
111                 .desc   = "vol+",               
112                 .code   = KEY_VOLUMEUP, 
113         },      
114         {               
115                 .desc   = "menu",               
116                 .code   = EV_MENU,      
117         },      
118         {               
119                 .desc   = "esc",                
120                 .code   = KEY_BACK,     
121         },      
122         {               
123                 .desc   = "home",               
124                 .code   = KEY_HOME,     
125         },      
126 };
127 struct rk29_keys_platform_data rk29_keys_pdata = {      
128         .buttons        = key_button,   
129         .chn    = -1,  //chn: 0-7, if do not use ADC,set 'chn' -1
130 };
131 ////////////////////////////////////////////////////////////////////////////////////////
132 //Backlight
133 ////////////////////////////////////////////////////////////////////////////////////////
134 #ifdef CONFIG_BACKLIGHT_RK29_BL
135 static int rk29_backlight_io_init(void)
136 {
137         int ret = 0;
138         printk("rk29_backlight_io_init %d\n",bl_pwm_mode);
139         iomux_set(bl_pwm_mode);         
140         msleep(100);
141
142         if(bl_en== -1)                
143                 return 0;        
144         ret = port_output_init(bl_en, 1, "bl_en");        
145         if(ret < 0){                
146                 printk("%s: port output init faild\n", __func__);
147                 return ret;        
148         }        
149         port_output_on(bl_en);
150         return ret;
151 }
152
153 static int rk29_backlight_io_deinit(void)
154 {
155         int ret = 0, pwm_gpio;  
156         
157         if(bl_en != -1)                
158                 port_deinit(bl_en); 
159         
160         pwm_gpio = iomux_mode_to_gpio(bl_pwm_mode);
161         gpio_request(pwm_gpio, NULL);
162         gpio_direction_output(pwm_gpio, GPIO_LOW);
163         return ret;
164 }
165
166 static int rk29_backlight_pwm_suspend(void)
167 {
168         int ret = 0, pwm_gpio;
169
170         pwm_gpio = iomux_mode_to_gpio(bl_pwm_mode);
171         if (gpio_request(pwm_gpio, NULL)) {
172                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
173                 return -1;
174         }
175         gpio_direction_output(pwm_gpio, GPIO_LOW);
176         port_output_off(bl_en);
177         return ret;
178 }
179
180 static int rk29_backlight_pwm_resume(void)
181 {
182         int pwm_gpio = iomux_mode_to_gpio(bl_pwm_mode);
183         gpio_free(pwm_gpio);
184         iomux_set(bl_pwm_mode);
185         msleep(150);
186         port_output_on(bl_en);
187         return 0;
188 }
189
190 static struct rk29_bl_info rk29_bl_info = {
191         .io_init = rk29_backlight_io_init,
192         .io_deinit = rk29_backlight_io_deinit,
193         .pwm_suspend = rk29_backlight_pwm_suspend,
194         .pwm_resume = rk29_backlight_pwm_resume,
195 };
196
197 static struct platform_device rk29_device_backlight = {
198         .name   = "rk29_backlight",
199         .id     = -1,
200         .dev    = {
201                 .platform_data  = &rk29_bl_info,
202         }
203 };
204
205 #endif
206 ////////////////////////////////////////////////////////////////////////////////////////
207 //LCD
208 ////////////////////////////////////////////////////////////////////////////////////////
209 #ifdef CONFIG_FB_ROCKCHIP
210 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
211 {
212         int ret = 0; 
213         //printk("rk_fb_io_init %x,%x,%x\n",lcd_cs,lcd_en,lcd_std);
214         if(lcd_cs != -1){                
215                 ret = port_output_init(lcd_cs, 1, "lcd_cs"); 
216                 if(ret < 0)                       
217                         printk("%s: port output init faild\n", __func__);
218                 port_output_on(lcd_cs);
219         }   
220         
221         if(lcd_en != -1){          
222                 ret = port_output_init(lcd_en, 1, "lcd_en");        
223                 if(ret < 0)                
224                         printk("%s: port output init faild\n", __func__);       
225                 port_output_on(lcd_en); 
226         }
227         
228         return 0;
229 }
230 static int rk_fb_io_disable(void)
231 {
232         if(lcd_cs != -1)                
233                 port_output_off(lcd_cs);        
234         if(lcd_en != -1)                
235                 port_output_on(lcd_en); 
236         return 0;
237 }
238 static int rk_fb_io_enable(void)
239 {
240         if(lcd_en != -1)                
241                 port_output_on(lcd_en); 
242         if(lcd_cs != -1)                
243                 port_output_on(lcd_cs);         
244         return 0;
245 }
246
247 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
248 struct rk29fb_info lcdc0_screen_info = {
249 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC0) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
250         .prop      = EXTEND,    //extend display device
251         .io_init    = NULL,
252         .io_disable = NULL,
253         .io_enable = NULL,
254         .set_screen_info = hdmi_init_lcdc,
255 #else
256         .prop      = PRMRY,             //primary display device
257         .io_init   = rk_fb_io_init,
258         .io_disable = rk_fb_io_disable,
259         .io_enable = rk_fb_io_enable,
260         .set_screen_info = set_lcd_info,
261 #endif
262 };
263 #endif
264
265 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
266 struct rk29fb_info lcdc1_screen_info = {
267 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC1) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
268         .prop      = EXTEND,    //extend display device
269         .io_init    = NULL,
270         .io_disable = NULL,
271         .io_enable = NULL,
272         .set_screen_info = hdmi_init_lcdc,
273 #else
274         .prop      = PRMRY,             //primary display device
275         .io_init   = rk_fb_io_init,
276         .io_disable = rk_fb_io_disable,
277         .io_enable = rk_fb_io_enable,
278         .set_screen_info = set_lcd_info,
279 #endif
280 };
281 #endif
282
283 static struct resource resource_fb[] = {
284         [0] = {
285                 .name  = "fb0 buf",
286                 .start = 0,
287                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
288                 .flags = IORESOURCE_MEM,
289         },
290         [1] = {
291                 .name  = "ipp buf",  //for rotate
292                 .start = 0,
293                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
294                 .flags = IORESOURCE_MEM,
295         },
296         [2] = {
297                 .name  = "fb2 buf",
298                 .start = 0,
299                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
300                 .flags = IORESOURCE_MEM,
301         },
302 };
303
304 static struct platform_device device_fb = {
305         .name           = "rk-fb",
306         .id             = -1,
307         .num_resources  = ARRAY_SIZE(resource_fb),
308         .resource       = resource_fb,
309 };
310 #endif
311
312 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
313 static struct resource resource_lcdc0[] = {
314         [0] = {
315                 .name  = "lcdc0 reg",
316                 .start = RK30_LCDC0_PHYS,
317                 .end   = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
318                 .flags = IORESOURCE_MEM,
319         },
320         
321         [1] = {
322                 .name  = "lcdc0 irq",
323                 .start = IRQ_LCDC0,
324                 .end   = IRQ_LCDC0,
325                 .flags = IORESOURCE_IRQ,
326         },
327 };
328
329 static struct platform_device device_lcdc0 = {
330         .name             = "rk30-lcdc",
331         .id               = 0,
332         .num_resources    = ARRAY_SIZE(resource_lcdc0),
333         .resource         = resource_lcdc0,
334         .dev            = {
335                 .platform_data = &lcdc0_screen_info,
336         },
337 };
338 #endif
339 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
340 static struct resource resource_lcdc1[] = {
341         [0] = {
342                 .name  = "lcdc1 reg",
343                 .start = RK30_LCDC1_PHYS,
344                 .end   = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
345                 .flags = IORESOURCE_MEM,
346         },
347         [1] = {
348                 .name  = "lcdc1 irq",
349                 .start = IRQ_LCDC1,
350                 .end   = IRQ_LCDC1,
351                 .flags = IORESOURCE_IRQ,
352         },
353 };
354
355 static struct platform_device device_lcdc1 = {
356         .name             = "rk30-lcdc",
357         .id               = 1,
358         .num_resources    = ARRAY_SIZE(resource_lcdc1),
359         .resource         = resource_lcdc1,
360         .dev            = {
361                 .platform_data = &lcdc1_screen_info,
362         },
363 };
364 #endif
365 ////////////////////////////////////////////////////////////////////////////////////////
366 //TP
367 ////////////////////////////////////////////////////////////////////////////////////////
368 #if defined (CONFIG_TOUCHSCREEN_GSLX680_RK3168)
369 static int gslx680_init_platform_hw()
370 {
371         int ret;
372         if(tp_rst!=-1){
373         ret = port_output_init(tp_rst, 1, "tp_rst"); 
374                 if(ret<0)
375                         printk("%s: port output init faild\n", __func__);       
376         }
377     
378     port_output_on(tp_rst);
379     mdelay(10);
380     port_output_off(tp_rst);
381     mdelay(10);
382     port_output_on(tp_rst);
383     msleep(300);
384     return 0;
385 }
386
387 static struct tp_platform_data gslx680_data = {
388
389   .init_platform_hw = gslx680_init_platform_hw,
390 };
391 struct i2c_board_info __initdata gslx680_info = {
392         .type = "gslX680",
393         .flags = 0,
394         .platform_data = &gslx680_data,
395 };
396 #endif
397
398
399 #if defined (CONFIG_TOUCHSCREEN_86V_GT811_IIC)
400 int gt811_init_platform_hw(int irq,int reset)
401 {
402     int ret;
403         if(tp_rst!=-1){
404         ret = port_output_init(tp_rst, 1, "tp_rst"); 
405                 if(ret<0)
406                         printk("%s: port output init faild\n", __func__);       
407         }
408
409         port_output_off(tp_rst);
410     msleep(500);
411     port_output_off(tp_rst);
412     msleep(500);
413     port_output_on(tp_rst);
414     mdelay(100);
415     return 0;
416 }
417
418
419 static struct tp_platform_data gt811_data = {
420   .model= 811,
421   .init_platform_hw= gt811_init_platform_hw,
422 };
423
424 struct i2c_board_info __initdata gt811_info = {
425         .type = "gt811_ts",
426         .flags = 0,
427         .platform_data = &gt811_data,
428 };
429 #endif
430
431
432 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
433 #define TOUCH_PWR_PIN    RK30_PIN0_PC5   // need to fly line by hardware engineer
434 static int goodix_init_platform_hw(void)
435 {
436         int ret;
437         
438         if (TOUCH_PWR_PIN != INVALID_GPIO) {
439                 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
440                 if (ret != 0) {
441                         gpio_free(TOUCH_PWR_PIN);
442                         printk("goodix power error\n");
443                         return -EIO;
444                 }
445                 gpio_direction_output(TOUCH_PWR_PIN, 0);
446                 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
447                 msleep(100);
448         }
449
450         if(tp_rst!=-1){
451         ret = port_output_init(tp_rst, 1, "tp_rst"); 
452                 if(ret<0)
453                         printk("%s: port output init faild\n", __func__);       
454         }
455         port_output_on(tp_rst);
456         msleep(100);
457         return 0;
458 }
459
460 struct tp_platform_data goodix_data = {
461         .model = 8105,
462         .init_platform_hw = goodix_init_platform_hw,
463 };
464
465 struct i2c_board_info __initdata goodix_info = {
466   .type = "Goodix-TS",
467   .flags = 0,
468   .platform_data = &goodix_data,
469 };
470 #endif
471
472 ////////////////////////////////////////////////////////////////////////////////////////
473 //Gsensor
474 ////////////////////////////////////////////////////////////////////////////////////////
475 /*MMA7660 gsensor*/
476 #if defined (CONFIG_GS_MMA7660)
477 static int mma7660_init_platform_hw(void)
478 {
479         //rk30_mux_api_set(GPIO1B2_SPI_RXD_UART1_SIN_NAME, GPIO1B_GPIO1B2);
480
481         return 0;
482 }
483
484 static struct sensor_platform_data mma7660_data = {
485         .type = SENSOR_TYPE_ACCEL,
486         .irq_enable = 1,
487         .poll_delay_ms = 30,
488     .init_platform_hw = mma7660_init_platform_hw,
489 };
490 struct i2c_board_info __initdata mma7660_info = {
491         .type                   = "gs_mma7660",
492         .flags                  = 0,
493         .platform_data          =&mma7660_data, 
494 };
495 #endif
496
497 #if defined (CONFIG_GS_MXC6225)
498 static int mxc6225_init_platform_hw(void)
499 {
500 //        rk30_mux_api_set(GPIO1B1_SPI_TXD_UART1_SOUT_NAME, GPIO1B_GPIO1B1);
501         return 0;
502 }
503
504 static struct sensor_platform_data mxc6225_data = {
505         .type = SENSOR_TYPE_ACCEL,
506         .irq_enable = 0,
507         .poll_delay_ms = 30,
508         .init_platform_hw = mxc6225_init_platform_hw,    
509 };
510 struct i2c_board_info __initdata mxc6225_info = {
511         .type                   = "gs_mxc6225",
512         .flags                  = 0,
513         .platform_data          =&mxc6225_data, 
514 };
515 #endif
516
517 #if defined (CONFIG_GS_DMT10)
518 static int dmt10_init_platform_hw(void)
519 {
520         return 0;
521 }
522
523 static struct sensor_platform_data dmt10_data = {
524         .type = SENSOR_TYPE_ACCEL,
525         .irq_enable = 0,
526         .poll_delay_ms = 30,
527         .init_platform_hw = dmt10_init_platform_hw,    
528 };
529 struct i2c_board_info __initdata dmt10_info = {
530         .type                   = "gs_dmard10",
531         .flags                  = 0,
532         .platform_data          =&dmt10_data, 
533 };
534 #endif
535
536
537 #if defined (CONFIG_GS_LIS3DH)
538 static int lis3dh_init_platform_hw(void)
539 {
540         return 0;
541 }
542 static struct sensor_platform_data lis3dh_data = {
543         .type = SENSOR_TYPE_ACCEL,
544         .irq_enable = 1,
545         .poll_delay_ms = 30,
546         .init_platform_hw = lis3dh_init_platform_hw,
547 };
548 struct i2c_board_info __initdata lis3dh_info = {
549         .type                   = "gs_lis3dh",
550         .flags                  = 0,
551         .platform_data          =&lis3dh_data, 
552 };
553 #endif
554
555 #if defined (CONFIG_GS_LSM303D)
556 static int lms303d_init_platform_hw(void)
557 {
558         return 0;
559 }
560 static struct sensor_platform_data lms303d_data = {
561         .type = SENSOR_TYPE_ACCEL,
562         .irq_enable = 1,
563         .poll_delay_ms = 30,
564     .init_platform_hw = lms303d_init_platform_hw,
565 };
566 struct i2c_board_info __initdata lms303d_info = {
567     .type                   = "gs_lsm303d",
568     .flags                  = 0,
569     .platform_data          =&lms303d_data, 
570 };
571 #endif
572
573 #if defined (CONFIG_GS_MMA8452)
574 static int mma8452_init_platform_hw(void)
575 {
576         return 0;
577 }
578
579 static struct sensor_platform_data mma8452_data = {
580         .type = SENSOR_TYPE_ACCEL,
581         .irq_enable = 1,
582         .poll_delay_ms = 30,
583     .init_platform_hw = mma8452_init_platform_hw,
584 };
585 struct i2c_board_info __initdata mma8452_info = {
586     .type                   = "gs_mma8452",
587     .flags                  = 0,
588     .platform_data          =&mma8452_data, 
589 };
590 #endif
591
592 ////////////////////////////////////////////////////////////////////////////////////////
593 //battery
594 ////////////////////////////////////////////////////////////////////////////////////////
595 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
596 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
597
598 };
599  
600
601 static struct platform_device rk30_device_adc_battery = {
602         .name   = "rk30-battery",
603         .id     = -1,
604         .dev = {
605                 .platform_data = &rk30_adc_battery_platdata,
606         },
607 };
608 #endif
609
610 ////////////////////////////////////////////////////////////////////////////////////////
611 //codec
612 ////////////////////////////////////////////////////////////////////////////////////////
613 #if defined (CONFIG_SND_RK29_SOC_RT5631)
614 static struct codec_platform_data rt5631_data = {
615 };
616 struct i2c_board_info __initdata rt5631_info = {
617         .type                   = "rt5631",
618         .flags                  = 0,
619         .platform_data          =&rt5631_data, 
620 };
621 #endif
622
623 #if defined (CONFIG_SND_RK29_SOC_ES8323)
624 static struct codec_platform_data es8323_data = {
625 };
626 struct i2c_board_info __initdata es8323_info = {
627         .type                   = "es8323",
628         .flags                  = 0,
629         .platform_data          =&es8323_data, 
630 };
631 #endif
632
633 #if defined(CONFIG_MFD_RK616)
634 #define RK616_SCL_RATE                  (100*1000)   //i2c scl rate
635 static int rk616_power_on_init(void)
636 {
637         int ret;
638                 
639         if(codec_power!=-1)
640         {
641                 ret = port_output_init(codec_power, 1, "codec_power"); 
642                 if(ret < 0)                       
643                         printk("%s: port output init faild\n", __func__);
644                 port_output_on(codec_power);
645         }
646         
647         if(codec_rst!=-1)
648         {
649                 ret = port_output_init(codec_rst, 1, "codec_rst"); 
650                 if(ret < 0)                       
651                         printk("%s: port output init faild\n", __func__);
652                 port_output_on(codec_rst);
653                 msleep(100);
654                 port_output_off(codec_rst);
655                 msleep(100);
656                 port_output_on(codec_rst);
657         }
658         return 0;
659         
660 }
661
662
663 static int rk616_power_deinit(void)
664 {
665         if(codec_power!=-1)
666         {
667                 port_output_off(codec_power);
668                 port_deinit(codec_power);
669         }
670         if(codec_rst!=-1)
671         {
672                 port_output_off(codec_rst);
673                 port_deinit(codec_rst);
674         }
675         return 0;
676 }
677
678 static struct rk616_platform_data rk616_pdata = {
679         .power_init = rk616_power_on_init,
680         .power_deinit = rk616_power_deinit,
681         .scl_rate   = RK616_SCL_RATE,
682         .lcd0_func = INPUT,             //port lcd0 as input
683         .lcd1_func = INPUT,             //port lcd1 as input
684         .lvds_ch_nr = 1,                //the number of used lvds channel  
685         //.hdmi_irq = RK30_PIN2_PD6,
686         //.spk_ctl_gpio = RK30_PIN2_PD7,
687         .hp_ctl_gpio = RK30_PIN2_PD7,
688 };
689
690 struct i2c_board_info __initdata rk616_info = {
691         .type          = "rk616",
692         .flags         = 0,
693         .platform_data = &rk616_pdata,
694 };
695 #endif
696
697
698 ////////////////////////////////////////////////////////////////////////////////////////
699 //spi
700 ////////////////////////////////////////////////////////////////////////////////////////
701 static struct spi_board_info board_spi_devices[] = {
702 };
703
704 ////////////////////////////////////////////////////////////////////////////////////////
705 //modem
706 ////////////////////////////////////////////////////////////////////////////////////////
707 #ifdef CONFIG_RK29_SUPPORT_MODEM
708
709 #define RK30_MODEM_POWER        RK30_PIN0_PC6
710 #define RK30_MODEM_POWER_IOMUX  iomux_set(GPIO0_C6)
711
712 static int rk30_modem_io_init(void)
713 {
714     printk("%s\n", __FUNCTION__);
715     RK30_MODEM_POWER_IOMUX;
716
717         return 0;
718 }
719
720 static struct rk29_io_t rk30_modem_io = {
721     .io_addr    = RK30_MODEM_POWER,
722     .enable     = GPIO_HIGH,
723     .disable    = GPIO_LOW,
724     .io_init    = rk30_modem_io_init,
725 };
726
727 static struct platform_device rk30_device_modem = {
728         .name   = "rk30_modem",
729         .id     = -1,
730         .dev    = {
731                 .platform_data  = &rk30_modem_io,
732         }
733 };
734 #endif
735 #if defined(CONFIG_MU509)
736 static int mu509_io_init(void)
737 {
738
739         iomux_set(GPIO2_D5);
740         iomux_set(GPIO0_C6);
741         iomux_set(GPIO2_D4);
742         iomux_set(GPIO0_C4);
743         iomux_set(GPIO0_C5);
744         return 0;
745 }
746
747 static int mu509_io_deinit(void)
748 {
749         
750         return 0;
751 }
752  
753 struct rk29_mu509_data rk29_mu509_info = {
754         .io_init = mu509_io_init,
755         .io_deinit = mu509_io_deinit,
756         .modem_power_en = RK30_PIN2_PD5,   
757         .bp_power = RK30_PIN0_PC6,              
758         .bp_reset = RK30_PIN2_PD4,              
759         .ap_wakeup_bp = RK30_PIN0_PC4,  
760         .bp_wakeup_ap = RK30_PIN0_PC5,  
761 };
762 struct platform_device rk29_device_mu509 = {    
763         .name = "mu509",        
764         .id = -1,       
765         .dev            = {
766                 .platform_data = &rk29_mu509_info,
767         }       
768     };
769 #endif
770 #if defined(CONFIG_MW100)
771 static int mw100_io_init(void)
772 {
773         iomux_set(GPIO2_D5);
774         iomux_set(GPIO0_C6);
775         iomux_set(GPIO2_D4);
776         iomux_set(GPIO0_C4);
777         iomux_set(GPIO0_C5);
778         return 0;
779 }
780
781 static int mw100_io_deinit(void)
782 {
783         
784         return 0;
785 }
786  
787 struct rk29_mw100_data rk29_mw100_info = {
788         .io_init = mw100_io_init,
789         .io_deinit = mw100_io_deinit,
790         .modem_power_en = RK30_PIN2_PD5,
791         .bp_power = RK30_PIN0_PC6,
792         .bp_reset = RK30_PIN2_PD4,
793         .ap_wakeup_bp = RK30_PIN0_PC4,
794         .bp_wakeup_ap = RK30_PIN0_PC5,
795 };
796 struct platform_device rk29_device_mw100 = {    
797         .name = "mw100",        
798         .id = -1,       
799         .dev            = {
800                 .platform_data = &rk29_mw100_info,
801         }       
802     };
803 #endif
804 #if defined(CONFIG_MT6229)
805 static int mt6229_io_init(void)
806 {
807         iomux_set(GPIO2_D5);
808         iomux_set(GPIO0_C6);
809         iomux_set(GPIO2_D4);
810         iomux_set(GPIO0_C4);
811         iomux_set(GPIO0_C5);
812         return 0;
813 }
814
815 static int mt6229_io_deinit(void)
816 {
817         
818         return 0;
819 }
820  
821 struct rk29_mt6229_data rk29_mt6229_info = {
822         .io_init = mt6229_io_init,
823         .io_deinit = mt6229_io_deinit,
824         .modem_power_en = RK30_PIN2_PD5,
825         .bp_power = RK30_PIN0_PC6,
826         .bp_reset = RK30_PIN2_PD4,
827         .ap_wakeup_bp = RK30_PIN0_PC4,
828         .bp_wakeup_ap = RK30_PIN0_PC5,
829 };
830 struct platform_device rk29_device_mt6229 = {   
831         .name = "mt6229",       
832         .id = -1,       
833         .dev            = {
834                 .platform_data = &rk29_mt6229_info,
835         }       
836     };
837 #endif
838
839
840 ////////////////////////////////////////////////////////////////////////////////////////
841 //compass
842 ////////////////////////////////////////////////////////////////////////////////////////
843 #if defined (CONFIG_COMPASS_AK8975)
844 static struct sensor_platform_data akm8975_info =
845 {
846         .type = SENSOR_TYPE_COMPASS,
847         .irq_enable = 1,
848         .poll_delay_ms = 30,
849         .m_layout = 
850         {
851                 {
852                         {1, 0, 0},
853                         {0, 1, 0},
854                         {0, 0, 1},
855                 },
856
857                 {
858                         {1, 0, 0},
859                         {0, 1, 0},
860                         {0, 0, 1},
861                 },
862
863                 {
864                         {1, 0, 0},
865                         {0, 1, 0},
866                         {0, 0, 1},
867                 },
868
869                 {
870                         {1, 0, 0},
871                         {0, 1, 0},
872                         {0, 0, 1},
873                 },
874         }
875 };
876
877 #endif
878
879 #if defined(CONFIG_GYRO_L3G4200D)
880
881 #include <linux/l3g4200d.h>
882 #define L3G4200D_INT_PIN  RK30_PIN0_PB4
883
884 static int l3g4200d_init_platform_hw(void)
885 {
886         return 0;
887 }
888
889 static struct sensor_platform_data l3g4200d_info = {
890         .type = SENSOR_TYPE_GYROSCOPE,
891         .irq_enable = 1,
892         .poll_delay_ms = 30,
893         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
894         .init_platform_hw = l3g4200d_init_platform_hw,
895         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
896         .y_min = 40,
897         .z_min = 20,
898 };
899
900 #endif
901
902 #ifdef CONFIG_LS_CM3217
903 static struct sensor_platform_data cm3217_info = {
904         .type = SENSOR_TYPE_LIGHT,
905         .irq_enable = 0,
906         .poll_delay_ms = 500,
907 };
908
909 #endif
910
911
912
913 ////////////////////////////////////////////////////////////////////////////////////////
914 //GPU
915 ////////////////////////////////////////////////////////////////////////////////////////
916 #if defined(CONFIG_ARCH_RK3188)
917 static struct resource resource_mali[] = {
918         [0] = {
919         .name  = "ump buf",
920         .start = 0,
921         .end   = 0,
922         .flags = IORESOURCE_MEM,
923         },
924
925 };
926
927 static struct platform_device device_mali= {
928         .name           = "mali400_ump",
929         .id             = -1,
930         .num_resources  = ARRAY_SIZE(resource_mali),
931         .resource       = resource_mali,
932 };
933 #endif
934
935 ////////////////////////////////////////////////////////////////////////////////////////
936 //TimeGpio
937 ////////////////////////////////////////////////////////////////////////////////////////
938 #ifdef CONFIG_ANDROID_TIMED_GPIO
939 static struct timed_gpio timed_gpios[] = {
940         {
941                 .name = "vibrator",
942                 .gpio = INVALID_GPIO,
943                 .max_timeout = 1000,
944                 .active_low = 0,
945                 .adjust_time =20,      //adjust for diff product
946         },
947 };
948
949 static struct timed_gpio_platform_data rk29_vibrator_info = {
950         .num_gpios = 1,
951         .gpios = timed_gpios,
952 };
953
954 static struct platform_device rk29_device_vibrator = {
955         .name = "timed-gpio",
956         .id = -1,
957         .dev = {
958                 .platform_data = &rk29_vibrator_info,
959         },
960
961 };
962 #endif
963
964 #ifdef CONFIG_LEDS_GPIO_PLATFORM
965 static struct gpio_led rk29_leds[] = {
966         {
967                 .name = "button-backlight",
968                 .gpio = INVALID_GPIO,
969                 .default_trigger = "timer",
970                 .active_low = 0,
971                 .retain_state_suspended = 0,
972                 .default_state = LEDS_GPIO_DEFSTATE_OFF,
973         },
974 };
975
976 static struct gpio_led_platform_data rk29_leds_pdata = {
977         .leds = rk29_leds,
978         .num_leds = ARRAY_SIZE(rk29_leds),
979 };
980
981 static struct platform_device rk29_device_gpio_leds = {
982         .name   = "leds-gpio",
983         .id     = -1,
984         .dev    = {
985                 .platform_data  = &rk29_leds_pdata,
986         },
987 };
988 #endif
989
990 #ifdef CONFIG_RK_IRDA
991 #define IRDA_IRQ_PIN           INVALID_GPIO //RK30_PIN0_PA3
992
993 static int irda_iomux_init(void)
994 {
995         int ret = 0;
996
997         //irda irq pin
998         ret = gpio_request(IRDA_IRQ_PIN, NULL);
999         if (ret != 0) {
1000                 gpio_free(IRDA_IRQ_PIN);
1001                 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1002         }
1003         gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
1004         gpio_direction_input(IRDA_IRQ_PIN);
1005
1006         return 0;
1007 }
1008
1009 static int irda_iomux_deinit(void)
1010 {
1011         gpio_free(IRDA_IRQ_PIN);
1012         return 0;
1013 }
1014
1015 static struct irda_info rk29_irda_info = {
1016         .intr_pin = IRDA_IRQ_PIN,
1017         .iomux_init = irda_iomux_init,
1018         .iomux_deinit = irda_iomux_deinit,
1019         //.irda_pwr_ctl = bu92747guw_power_ctl,
1020 };
1021
1022 static struct platform_device irda_device = {
1023 #ifdef CONFIG_RK_IRDA_NET
1024         .name = "rk_irda",
1025 #else
1026         .name = "bu92747_irda",
1027 #endif
1028         .id = -1,
1029         .dev = {
1030                 .platform_data = &rk29_irda_info,
1031         }
1032 };
1033 #endif
1034
1035
1036 ////////////////////////////////////////////////////////////////////////////////////////
1037 //ION
1038 ////////////////////////////////////////////////////////////////////////////////////////
1039 #ifdef CONFIG_ION
1040 #define ION_RESERVE_SIZE        (80 * SZ_1M)
1041 static struct ion_platform_data rk30_ion_pdata = {
1042         .nr = 1,
1043         .heaps = {
1044                 {
1045                         .type = ION_HEAP_TYPE_CARVEOUT,
1046                         .id = ION_NOR_HEAP_ID,
1047                         .name = "norheap",
1048                         .size = ION_RESERVE_SIZE,
1049                 }
1050         },
1051 };
1052
1053 static struct platform_device device_ion = {
1054         .name = "ion-rockchip",
1055         .id = 0,
1056         .dev = {
1057                 .platform_data = &rk30_ion_pdata,
1058         },
1059 };
1060 #endif
1061
1062 /**************************************************************************************************
1063  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
1064 **************************************************************************************************/
1065 #ifdef CONFIG_SDMMC_RK29
1066 #include "../mach-rk30/board-rk3168-tb-sdmmc-conifg.c"
1067 #include "../plat-rk/rk-sdmmc-ops.c"
1068 #include "../plat-rk/rk-sdmmc-wifi.c"
1069 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
1070
1071 #ifdef CONFIG_SDMMC0_RK29
1072 static int rk29_sdmmc0_cfg_gpio(void)
1073 {
1074 #ifdef CONFIG_SDMMC_RK29_OLD
1075         iomux_set(MMC0_CMD);
1076         iomux_set(MMC0_CLKOUT);
1077         iomux_set(MMC0_D0);
1078         iomux_set(MMC0_D1);
1079         iomux_set(MMC0_D2);
1080         iomux_set(MMC0_D3);
1081
1082         iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
1083
1084         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
1085         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
1086
1087 #else
1088         rk29_sdmmc_set_iomux(0, 0xFFFF);
1089
1090     #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
1091         #if SDMMC_USE_NEW_IOMUX_API
1092         iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
1093         #else
1094         rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
1095         #endif
1096     #else
1097         #if SDMMC_USE_NEW_IOMUX_API       
1098         iomux_set(MMC0_DETN);
1099         #else
1100         rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
1101         #endif
1102     #endif      
1103
1104 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1105         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1106         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1107 #endif
1108
1109 #endif
1110
1111         return 0;
1112 }
1113
1114 #define CONFIG_SDMMC0_USE_DMA
1115 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1116         .host_ocr_avail =
1117             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1118              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1119              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1120         .host_caps =
1121             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1122         .io_init = rk29_sdmmc0_cfg_gpio,
1123
1124 #if !defined(CONFIG_SDMMC_RK29_OLD)
1125         .set_iomux = rk29_sdmmc_set_iomux,
1126 #endif
1127
1128         .dma_name = "sd_mmc",
1129 #ifdef CONFIG_SDMMC0_USE_DMA
1130         .use_dma = 1,
1131 #else
1132         .use_dma = 0,
1133 #endif
1134
1135 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
1136     .status = rk29sdk_wifi_mmc0_status,
1137     .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1138 #endif
1139
1140 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
1141     .power_en = RK29SDK_SD_CARD_PWR_EN,
1142     .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
1143 #else
1144     .power_en = INVALID_GPIO,
1145     .power_en_level = GPIO_LOW,
1146 #endif    
1147         .enable_sd_wakeup = 0,
1148
1149 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1150         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1151         .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
1152 #else
1153         .write_prt = INVALID_GPIO,
1154 #endif
1155
1156     .det_pin_info = {    
1157     #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
1158         .io             = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
1159         .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
1160         #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1161         .iomux          = {
1162             .name       = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1163             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1164             .fgpio      = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1165             #endif
1166             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1167             .fmux       = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1168             #endif
1169         },
1170         #endif
1171     #else
1172         .io             = INVALID_GPIO,
1173         .enable         = GPIO_LOW,
1174     #endif    
1175     }, 
1176
1177 };
1178 #endif // CONFIG_SDMMC0_RK29
1179
1180 #ifdef CONFIG_SDMMC1_RK29
1181 #define CONFIG_SDMMC1_USE_DMA
1182 static int rk29_sdmmc1_cfg_gpio(void)
1183 {
1184 #if defined(CONFIG_SDMMC_RK29_OLD)
1185         iomux_set(MMC1_CMD);
1186         iomux_set(MMC1_CLKOUT);
1187         iomux_set(MMC1_D0);
1188         iomux_set(MMC1_D1);
1189         iomux_set(MMC1_D2);
1190         iomux_set(MMC1_D3);
1191 #else
1192
1193 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1194         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1195         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1196 #endif
1197
1198 #endif
1199
1200         return 0;
1201 }
1202
1203 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1204         .host_ocr_avail =
1205             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1206              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1207              MMC_VDD_33_34),
1208
1209 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1210         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1211                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1212 #else
1213         .host_caps =
1214             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1215 #endif
1216
1217         .io_init = rk29_sdmmc1_cfg_gpio,
1218
1219 #if !defined(CONFIG_SDMMC_RK29_OLD)
1220         .set_iomux = rk29_sdmmc_set_iomux,
1221 #endif
1222
1223         .dma_name = "sdio",
1224 #ifdef CONFIG_SDMMC1_USE_DMA
1225         .use_dma = 1,
1226 #else
1227         .use_dma = 0,
1228 #endif
1229
1230 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1231     .status = rk29sdk_wifi_status,
1232     .register_status_notify = rk29sdk_wifi_status_register,
1233 #endif
1234
1235 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1236         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1237             .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1238 #else
1239         .write_prt = INVALID_GPIO,
1240 #endif
1241
1242     #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1243         .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1244     #endif
1245
1246     .det_pin_info = {    
1247 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1248      #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
1249         .io             = RK29SDK_SD_CARD_DETECT_N,
1250      #else
1251          .io             = INVALID_GPIO,
1252      #endif   
1253
1254         .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
1255         #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1256         .iomux          = {
1257             .name       = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1258             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1259             .fgpio      = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1260             #endif
1261             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1262             .fmux       = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1263             #endif
1264         },
1265         #endif
1266  #else
1267         .io             = INVALID_GPIO,
1268         .enable         = GPIO_LOW,
1269 #endif
1270     },
1271    
1272         .enable_sd_wakeup = 0,
1273 };
1274 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1275
1276 ////////////////////////////////////////////////////////////////////////////////////////
1277 //PMU
1278 ////////////////////////////////////////////////////////////////////////////////////////
1279 #ifdef CONFIG_RK30_PWM_REGULATOR
1280 static int pwm_voltage_map[] = {
1281         800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
1282 };
1283 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1284         {
1285                 .supply = "vdd_cpu",
1286         }
1287 };
1288
1289 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1290 {
1291         {
1292                 .constraints = {
1293                         .name = "PWM_DCDC1",
1294                         .min_uV = 600000,
1295                         .max_uV = 1800000,      //0.6-1.8V
1296                         .apply_uV = true,
1297                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1298                 },
1299                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1300                 .consumer_supplies = pwm_dcdc1_consumers,
1301         },
1302 };
1303
1304 static struct pwm_platform_data pwm_regulator_info[1] = {
1305         {
1306                 .pwm_id = 1,
1307                 .pwm_gpio = RK30_PIN3_PD4,
1308                 .pwm_iomux_pwm = PWM1,
1309                 .pwm_iomux_gpio = GPIO3_D4,
1310                 .pwm_voltage = 1100000,
1311                 .suspend_voltage = 1000000,
1312                 .min_uV = 800000,
1313                 .max_uV = 1375000,
1314                 .coefficient = 575,     //57.5%
1315                 .pwm_voltage_map = pwm_voltage_map,
1316                 .init_data      = &pwm_regulator_init_dcdc[0],
1317         },
1318 };
1319
1320 struct platform_device pwm_regulator_device[1] = {
1321         {
1322                 .name = "pwm-voltage-regulator",
1323                 .id = 0,
1324                 .dev            = {
1325                         .platform_data = &pwm_regulator_info[0],
1326                 }
1327         },
1328 };
1329 #endif
1330
1331 #ifdef CONFIG_RK29_VMAC
1332 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1333 #include "board-rk30-sdk-vmac.c"
1334 #endif
1335
1336 #ifdef CONFIG_RFKILL_RK
1337 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1338 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1339     .type               = RFKILL_TYPE_BLUETOOTH,
1340
1341     .poweron_gpio       = { // BT_REG_ON
1342         .io             = INVALID_GPIO, //RK30_PIN3_PC7,
1343         .enable         = GPIO_HIGH,
1344         .iomux          = {
1345             .name       = "bt_poweron",
1346             .fgpio      = GPIO3_C7,
1347         },
1348     },
1349
1350     .reset_gpio         = { // BT_RST
1351         .io             = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1352         .enable         = GPIO_LOW,
1353         .iomux          = {
1354             .name       = "bt_reset",
1355             .fgpio      = GPIO3_C7,
1356        },
1357    }, 
1358
1359     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
1360         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1361         .enable         = GPIO_HIGH,
1362         .iomux          = {
1363             .name       = "bt_wake",
1364             .fgpio      = GPIO3_C6,
1365         },
1366     },
1367
1368     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1369         .gpio           = {
1370             .io         = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1371             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
1372             .iomux      = {
1373                 .name   = NULL,
1374             },
1375         },
1376     },
1377
1378     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
1379         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1380         .enable         = GPIO_LOW,
1381         .iomux          = {
1382             .name       = "bt_rts",
1383             .fgpio      = GPIO1_A3,
1384             .fmux       = UART0_RTSN,
1385         },
1386     },
1387 };
1388
1389 static struct platform_device device_rfkill_rk = {
1390     .name   = "rfkill_rk",
1391     .id     = -1,
1392     .dev    = {
1393         .platform_data = &rfkill_rk_platdata,
1394     },
1395 };
1396 #endif
1397
1398 #if defined(CONFIG_GPS_RK)
1399 int rk_gps_io_init(void)
1400 {
1401         printk("%s \n", __FUNCTION__);
1402         
1403         gpio_request(RK30_PIN1_PB5, NULL);
1404         gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1405
1406         iomux_set(GPS_RFCLK);//GPS_CLK
1407         iomux_set(GPS_MAG);//GPS_MAG
1408         iomux_set(GPS_SIG);//GPS_SIGN
1409
1410         gpio_request(RK30_PIN1_PA6, NULL);
1411         gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1412
1413         gpio_request(RK30_PIN1_PA5, NULL);
1414         gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW); 
1415
1416         gpio_request(RK30_PIN1_PA7, NULL);
1417         gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);         
1418         return 0;
1419 }
1420 int rk_gps_power_up(void)
1421 {
1422         printk("%s \n", __FUNCTION__);
1423
1424         return 0;
1425 }
1426
1427 int rk_gps_power_down(void)
1428 {
1429         printk("%s \n", __FUNCTION__);
1430
1431         return 0;
1432 }
1433
1434 int rk_gps_reset_set(int level)
1435 {
1436         return 0;
1437 }
1438 int rk_enable_hclk_gps(void)
1439 {
1440         struct clk *gps_aclk = NULL;
1441         gps_aclk = clk_get(NULL, "aclk_gps");
1442         if(gps_aclk) {
1443                 clk_enable(gps_aclk);
1444                 clk_put(gps_aclk);
1445                 printk("%s \n", __FUNCTION__);
1446         }
1447         else
1448                 printk("get gps aclk fail\n");
1449         return 0;
1450 }
1451 int rk_disable_hclk_gps(void)
1452 {
1453         struct clk *gps_aclk = NULL;
1454         gps_aclk = clk_get(NULL, "aclk_gps");
1455         if(gps_aclk) {
1456                 //TO wait long enough until GPS ISR is finished.
1457                 msleep(5);
1458                 clk_disable(gps_aclk);
1459                 clk_put(gps_aclk);
1460                 printk("%s \n", __FUNCTION__);
1461         }       
1462         else
1463                 printk("get gps aclk fail\n");
1464         return 0;
1465 }
1466 struct rk_gps_data rk_gps_info = {
1467         .io_init = rk_gps_io_init,
1468         .power_up = rk_gps_power_up,
1469         .power_down = rk_gps_power_down,
1470         .reset = rk_gps_reset_set,
1471         .enable_hclk_gps = rk_enable_hclk_gps,
1472         .disable_hclk_gps = rk_disable_hclk_gps,
1473         .GpsSign = RK30_PIN1_PB3,
1474         .GpsMag = RK30_PIN1_PB2,        //GPIO index
1475         .GpsClk = RK30_PIN1_PB4,        //GPIO index
1476         .GpsVCCEn = RK30_PIN1_PB5,     //GPIO index
1477         .GpsSpi_CSO = RK30_PIN1_PA4,    //GPIO index
1478         .GpsSpiClk = RK30_PIN1_PA5,     //GPIO index
1479         .GpsSpiMOSI = RK30_PIN1_PA7,      //GPIO index
1480         .GpsIrq = IRQ_GPS,
1481         .GpsSpiEn = 0,
1482         .GpsAdcCh = 2,
1483         .u32GpsPhyAddr = RK30_GPS_PHYS,
1484         .u32GpsPhySize = RK30_GPS_SIZE,
1485 };
1486
1487 struct platform_device rk_device_gps = {
1488         .name = "gps_hv5820b",
1489         .id = -1,
1490         .dev            = {
1491         .platform_data = &rk_gps_info,
1492                 }
1493         };
1494 #endif
1495
1496 #if defined(CONFIG_MT5931_MT6622)
1497 static struct mt6622_platform_data mt6622_platdata = {
1498                     .power_gpio         = { // BT_REG_ON
1499                         .io             = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1500                             .enable         = GPIO_HIGH,
1501                             .iomux          = {
1502                                     .name       = NULL,
1503                                 },
1504                     },
1505
1506                     .reset_gpio         = { // BT_RST
1507                         .io             = RK30_PIN0_PD7,
1508                         .enable         = GPIO_HIGH,
1509                         .iomux          = {
1510                             .name       = NULL,
1511                         },
1512                     },
1513
1514                     .irq_gpio           = {
1515                             .io             = RK30_PIN3_PD2,
1516                             .enable         = GPIO_HIGH,
1517                             .iomux          = {
1518                                     .name       = NULL,
1519                                 },
1520                     }
1521 };
1522
1523 static struct platform_device device_mt6622 = {
1524                     .name   = "mt6622",
1525                         .id     = -1,
1526                         .dev    = {
1527                                .platform_data = &mt6622_platdata,
1528                         },
1529 };      
1530 #endif
1531
1532 static struct platform_device *devices[] __initdata = {
1533 #ifdef CONFIG_ION
1534         &device_ion,
1535 #endif
1536 #ifdef CONFIG_ANDROID_TIMED_GPIO
1537         &rk29_device_vibrator,
1538 #endif
1539 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1540         &rk29_device_gpio_leds,
1541 #endif
1542 #ifdef CONFIG_RK_IRDA
1543         &irda_device,
1544 #endif
1545 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1546         &rk29sdk_wifi_device,
1547 #endif
1548
1549 #if defined(CONFIG_MT6620)
1550     &mt3326_device_gps,
1551 #endif   
1552
1553 #ifdef CONFIG_RK29_SUPPORT_MODEM
1554         &rk30_device_modem,
1555 #endif
1556 #if defined(CONFIG_MU509)
1557         &rk29_device_mu509,
1558 #endif
1559 #if defined(CONFIG_MW100)
1560         &rk29_device_mw100,
1561 #endif
1562 #if defined(CONFIG_MT6229)
1563         &rk29_device_mt6229,
1564 #endif
1565 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1566         &rk30_device_adc_battery,
1567 #endif
1568 #ifdef CONFIG_RFKILL_RK
1569         &device_rfkill_rk,
1570 #endif
1571 #ifdef CONFIG_GPS_RK
1572         &rk_device_gps,
1573 #endif
1574 #if defined(CONFIG_ARCH_RK3188)
1575         &device_mali,
1576 #endif
1577 #ifdef CONFIG_MT5931_MT6622
1578         &device_mt6622,
1579 #endif
1580 };
1581
1582 static int rk_platform_add_display_devices(void)
1583 {
1584         struct platform_device *fb = NULL;  //fb
1585         struct platform_device *lcdc0 = NULL; //lcdc0
1586         struct platform_device *lcdc1 = NULL; //lcdc1
1587         struct platform_device *bl = NULL; //backlight
1588 #ifdef CONFIG_FB_ROCKCHIP
1589         fb = &device_fb;
1590 #endif
1591
1592 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
1593         lcdc0 = &device_lcdc0,
1594 #endif
1595
1596 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
1597         lcdc1 = &device_lcdc1,
1598 #endif
1599
1600 #ifdef CONFIG_BACKLIGHT_RK29_BL
1601         bl = &rk29_device_backlight,
1602 #endif
1603         __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1604
1605         return 0;
1606         
1607 }
1608
1609 // i2c
1610 #ifdef CONFIG_I2C0_RK30
1611 static struct i2c_board_info __initdata i2c0_info[] = {
1612 #if defined (CONFIG_COMPASS_AK8975)
1613         {
1614                 .type          = "ak8975",
1615                 .addr          = 0x0d,
1616                 .flags         = 0,
1617                 .irq           = RK30_PIN3_PD7, 
1618                 .platform_data = &akm8975_info,
1619         },
1620 #endif
1621 #if defined (CONFIG_GYRO_L3G4200D)
1622         {
1623                 .type          = "l3g4200d_gryo",
1624                 .addr          = 0x69,
1625                 .flags         = 0,
1626                 .irq           = L3G4200D_INT_PIN,
1627                 .platform_data = &l3g4200d_info,
1628         },
1629 #endif
1630 #if defined (CONFIG_SND_SOC_RK1000)
1631         {
1632                 .type          = "rk1000_i2c_codec",
1633                 .addr          = 0x60,
1634                 .flags         = 0,
1635         },
1636         {
1637                 .type          = "rk1000_control",
1638                 .addr          = 0x40,
1639                 .flags         = 0,
1640         },
1641 #endif
1642 #if defined (CONFIG_SND_SOC_RT5640) 
1643             {
1644                         .type                   = "rt5640",
1645                         .addr                   = 0x1c,
1646                         .flags                  = 0,
1647                 },
1648 #endif
1649
1650 #ifdef CONFIG_MFD_RK610
1651                 {
1652                         .type                   = "rk610_ctl",
1653                         .addr                   = 0x40,
1654                         .flags                  = 0,
1655                         .platform_data          = &rk610_ctl_pdata,
1656                 },
1657 #ifdef CONFIG_RK610_TVOUT
1658                 {
1659                         .type                   = "rk610_tvout",
1660                         .addr                   = 0x42,
1661                         .flags                  = 0,
1662                 },
1663 #endif
1664 #ifdef CONFIG_HDMI_RK610
1665                 {
1666                         .type                   = "rk610_hdmi",
1667                         .addr                   = 0x46,
1668                         .flags                  = 0,
1669                         .irq                    = INVALID_GPIO,
1670                 },
1671 #endif
1672 #ifdef CONFIG_SND_SOC_RK610
1673                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1674                         .type                   = "rk610_i2c_codec",
1675                         .addr                   = 0x60,
1676                         .flags                  = 0,
1677                         .platform_data          = &rk610_codec_pdata,                                   
1678                 },
1679 #endif
1680 #endif
1681
1682 };
1683 #endif
1684
1685 int __sramdata g_pmic_type =  0;
1686 #ifdef CONFIG_I2C1_RK30
1687 #ifdef CONFIG_MFD_WM831X_I2C
1688 #define PMU_POWER_SLEEP                 RK30_PIN0_PA1 
1689
1690 static struct pmu_info  wm8326_dcdc_info[] = {
1691         {
1692                 .name          = "vdd_core",   //logic
1693                 .min_uv          = 1000000,
1694                 .max_uv         = 1000000,
1695                 .suspend_vol  =  950000,
1696         },
1697         {
1698                 .name          = "vdd_cpu",    //arm
1699                 .min_uv          = 1000000,
1700                 .max_uv         = 1000000,
1701                 .suspend_vol  =  950000,
1702         },
1703         {
1704                 .name          = "dcdc3",   //ddr
1705                 .min_uv          = 1150000,
1706                 .max_uv         = 1150000,
1707                 .suspend_vol  =  1150000,
1708         },
1709         #ifdef CONFIG_MACH_RK3066_SDK
1710         {
1711                 .name          = "dcdc4",   //vcc_io
1712                 .min_uv          = 3300000,
1713                 .max_uv         = 3300000,
1714                 .suspend_vol  =  3000000,
1715         },
1716         #else
1717         {
1718                 .name          = "dcdc4",   //vcc_io
1719                 .min_uv          = 3000000,
1720                 .max_uv         = 3000000,
1721                 .suspend_vol  =  2800000,
1722         },
1723         #endif
1724 };
1725
1726 static struct pmu_info  wm8326_ldo_info[] = {
1727         {
1728                 .name          = "ldo1",   //vcc18_cif
1729                 .min_uv          = 1800000,
1730                 .max_uv         = 1800000,
1731                 .suspend_vol  =  1800000,
1732         },
1733         {
1734                 .name          = "ldo2",    //vccio_wl
1735                 .min_uv          = 1800000,
1736                 .max_uv         = 1800000,
1737                 .suspend_vol  =  1800000,
1738         },
1739         {
1740                 .name          = "ldo3",   //
1741                 .min_uv          = 1100000,
1742                 .max_uv         = 1100000,
1743                 .suspend_vol  =  1100000,
1744         },
1745         {
1746                 .name          = "ldo4",   //vdd11
1747                 .min_uv          = 1000000,
1748                 .max_uv         = 1000000,
1749                 .suspend_vol  =  1000000,
1750         },
1751         {
1752                 .name          = "ldo5",   //vcc25
1753                 .min_uv          = 1800000,
1754                 .max_uv         = 1800000,
1755                 .suspend_vol  =  1800000,
1756         },
1757         {
1758                 .name          = "ldo6",   //vcc33
1759                 .min_uv          = 3300000,
1760                 .max_uv         = 3300000,
1761                 .suspend_vol  =  3300000,
1762         },
1763         {
1764                 .name          = "ldo7",   //vcc28_cif
1765                 .min_uv          = 2800000,
1766                 .max_uv         = 2800000,
1767                 .suspend_vol  =  2800000,
1768         },
1769         {
1770                 .name          = "ldo8",   //vcca33
1771                 .min_uv          = 3300000,
1772                 .max_uv         = 3300000,
1773                 .suspend_vol  =  3300000,
1774         },
1775         {
1776                 .name          = "ldo9",   //vcc_tp
1777                 .min_uv          = 3300000,
1778                 .max_uv         = 3300000,
1779                 .suspend_vol  =  3300000,
1780         },
1781         {
1782                 .name          = "ldo10",   //flash_io
1783                 .min_uv          = 1800000,
1784                 .max_uv         = 1800000,
1785                 .suspend_vol  =  1800000,
1786         },
1787 };
1788
1789 #include "../mach-rk30/board-pmu-wm8326.c"
1790 #endif
1791
1792 #ifdef CONFIG_MFD_TPS65910
1793 #define TPS65910_HOST_IRQ        RK30_PIN0_PB3
1794
1795 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1796
1797 static struct pmu_info  tps65910_dcdc_info[] = {
1798         {
1799                 .name          = "vdd_core",   //logic
1800                 .min_uv          = 1100000,
1801                 .max_uv         = 1100000,
1802         },
1803         {
1804                 .name          = "vdd2",    //ddr
1805                 .min_uv          = 1200000,
1806                 .max_uv         = 1200000,
1807         },
1808         {
1809                 .name          = "vio",   //vcc_io
1810                 .min_uv          = 2500000,
1811                 .max_uv         = 2500000,
1812         },
1813         
1814 };
1815 static  struct pmu_info  tps65910_ldo_info[] = {
1816         {
1817                 .name          = "vpll",   //vdd10
1818                 .min_uv          = 1000000,
1819                 .max_uv         = 1000000,
1820         },
1821         {
1822                 .name          = "vdig1",    //vcc18_cif
1823                 .min_uv          = 1800000,
1824                 .max_uv         = 1800000,
1825         },
1826         {
1827                 .name          = "vdig2",   //vdd_jetta
1828                 .min_uv          = 1200000,
1829                 .max_uv         = 1200000,
1830         },
1831         {
1832                 .name          = "vaux1",   //vcc28_cif
1833                 .min_uv          = 2800000,
1834                 .max_uv         = 2800000,
1835         },
1836         {
1837                 .name          = "vaux2",   //vcca33
1838                 .min_uv          = 3300000,
1839                 .max_uv         = 3300000,
1840         },
1841         {
1842                 .name          = "vaux33",   //vcc_tp
1843                 .min_uv          = 3300000,
1844                 .max_uv         = 3300000,
1845         },
1846         {
1847                 .name          = "vmmc",   //vcc30
1848                 .min_uv          = 3000000,
1849                 .max_uv         = 3000000,
1850         },
1851         {
1852                 .name          = "vdac",   //vcc18
1853                 .min_uv          = 1800000,
1854                 .max_uv         = 1800000,
1855         },
1856  };
1857
1858 #include "../mach-rk30/board-pmu-tps65910.c"
1859 #endif
1860
1861 #ifdef CONFIG_REGULATOR_ACT8846
1862 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1863 #define PMU_VSEL RK30_PIN3_PD3
1864 static struct pmu_info  act8846_dcdc_info[] = {
1865         {
1866                 .name          = "act_dcdc1",   //ddr
1867                 .min_uv          = 1200000,
1868                 .max_uv         = 1200000,
1869                 .suspend_vol  =  1200000,
1870         },
1871         {
1872                 .name          = "vdd_core",    //logic
1873                 .min_uv          = 1000000,
1874                 .max_uv         = 1000000,
1875                 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1876                 .suspend_vol  =  1200000,
1877                 #else
1878                 .suspend_vol  =  900000,
1879                 #endif
1880
1881         },
1882         {
1883                 .name          = "vdd_cpu",   //arm
1884                 .min_uv          = 1000000,
1885                 .max_uv         = 1000000,
1886                 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1887                 .suspend_vol  =  1200000,
1888                 #else
1889                 .suspend_vol  =  900000,
1890                 #endif
1891
1892         },
1893         {
1894                 .name          = "act_dcdc4",   //vccio
1895                 .min_uv          = 3000000,
1896                 .max_uv         = 3000000,
1897                 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1898                 .suspend_vol  =  3000000,
1899                 #else
1900                 .suspend_vol  =  2800000,
1901                 #endif
1902
1903         },
1904         
1905 };
1906 static  struct pmu_info  act8846_ldo_info[] = {
1907         {
1908                 .name          = "act_ldo1",   //vdd11
1909                 .min_uv          = 1000000,
1910                 .max_uv         = 1000000,
1911         },
1912         {
1913                 .name          = "act_ldo2",    //vdd12
1914                 .min_uv          = 1200000,
1915                 .max_uv         = 1200000,
1916         },
1917         {
1918                 .name          = "act_ldo3",   //vcc18_cif
1919                 .min_uv          = 1800000,
1920                 .max_uv         = 1800000,
1921         },
1922         {
1923                 .name          = "act_ldo4",   //vcca33
1924                 .min_uv          = 3300000,
1925                 .max_uv         = 3300000,
1926         },
1927         {
1928                 .name          = "act_ldo5",   //vcctp
1929                 .min_uv          = 3300000,
1930                 .max_uv         = 3300000,
1931         },
1932         {
1933                 .name          = "act_ldo6",   //vcc33
1934                 .min_uv          = 3300000,
1935                 .max_uv         = 3300000,
1936         },
1937         {
1938                 .name          = "act_ldo7",   //vccio_wl
1939                 .min_uv          = 1800000,
1940                 .max_uv         = 1800000,
1941         },
1942         {
1943                 .name          = "act_ldo8",   //vcc28_cif
1944                 .min_uv          = 2800000,
1945                 .max_uv         = 2800000,
1946         },
1947  };
1948
1949 #include "../mach-rk30/board-pmu-act8846.c"
1950 #endif
1951
1952 #ifdef CONFIG_MFD_RK808
1953 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1954 #define RK808_HOST_IRQ        RK30_PIN0_PB3
1955
1956 static struct pmu_info  rk808_dcdc_info[] = {
1957         {
1958                 .name          = "vdd_cpu",   //arm
1959                 .min_uv          = 1000000,
1960                 .max_uv         = 1000000,
1961                 .suspend_vol  =  900000,
1962         },
1963         {
1964                 .name          = "vdd_core",    //logic
1965                 .min_uv          = 1000000,
1966                 .max_uv         = 1000000,
1967                 .suspend_vol  =  900000,
1968         },
1969         {
1970                 .name          = "rk_dcdc3",   //ddr
1971                 .min_uv          = 1200000,
1972                 .max_uv         = 1200000,
1973                 .suspend_vol  =  1200000,
1974         },
1975         {
1976                 .name          = "rk_dcdc4",   //vccio
1977                 .min_uv          = 3300000,
1978                 .max_uv         = 3300000,
1979                 .suspend_vol  =  3000000,
1980         },
1981         
1982 };
1983 static  struct pmu_info  rk808_ldo_info[] = {
1984         {
1985                 .name          = "rk_ldo1",   //vcc33
1986                 .min_uv          = 3300000,
1987                 .max_uv         = 3300000,
1988                 .suspend_vol   = 3300000,
1989         },
1990         {
1991                 .name          = "rk_ldo2",    //vcctp
1992                 .min_uv          = 3300000,
1993                 .max_uv         = 3300000,
1994                  .suspend_vol   = 3300000,
1995
1996         },
1997         {
1998                 .name          = "rk_ldo3",   //vdd10
1999                 .min_uv          = 1000000,
2000                 .max_uv         = 1000000,
2001                  .suspend_vol   = 1000000,
2002         },
2003         {
2004                 .name          = "rk_ldo4",   //vcc18
2005                 .min_uv          = 1800000,
2006                 .max_uv         = 1800000,
2007                  .suspend_vol   = 1800000,
2008         },
2009         {
2010                 .name          = "rk_ldo5",   //vcc28_cif
2011                 .min_uv          = 2800000,
2012                 .max_uv         = 2800000,
2013                  .suspend_vol   = 2800000,
2014         },
2015         {
2016                 .name          = "rk_ldo6",   //vdd12
2017                 .min_uv          = 1200000,
2018                 .max_uv         = 1200000,
2019                  .suspend_vol   = 1200000,
2020         },
2021         {
2022                 .name          = "rk_ldo7",   //vcc18_cif
2023                 .min_uv          = 1800000,
2024                 .max_uv         = 1800000,
2025                  .suspend_vol   = 1800000,
2026         },
2027         {
2028                 .name          = "rk_ldo8",   //vcca_33
2029                 .min_uv          = 3300000,
2030                 .max_uv         = 3300000,
2031                  .suspend_vol   = 3300000,
2032         },
2033  };
2034
2035 #include "board-pmu-rk808.c"
2036 #endif
2037
2038
2039 static struct i2c_board_info __initdata i2c1_info[] = {
2040 #if defined (CONFIG_MFD_WM831X_I2C)
2041         {
2042                 .type          = "wm8326",
2043                 .addr          = 0x34,
2044                 .flags         = 0,
2045                 .irq           = RK30_PIN0_PB3,
2046                 .platform_data = &wm831x_platdata,
2047         },
2048 #endif
2049 #if defined (CONFIG_MFD_TPS65910)
2050         {
2051         .type           = "tps65910",
2052         .addr           = TPS65910_I2C_ID0,
2053         .flags          = 0,
2054         .irq            = TPS65910_HOST_IRQ,
2055         .platform_data = &tps65910_data,
2056         },
2057 #endif
2058
2059 #if defined (CONFIG_REGULATOR_ACT8846)
2060         {
2061                 .type                   = "act8846",
2062                 .addr           = 0x5a, 
2063                 .flags                  = 0,
2064         //      .irq            = ACT8846_HOST_IRQ,
2065                 .platform_data=&act8846_data,
2066         },
2067 #endif
2068 #if defined (CONFIG_MFD_RK808)
2069         {
2070                 .type                   = "rk808",
2071                 .addr           = 0x1b, 
2072                 .flags                  = 0,
2073         //      .irq            = ACT8846_HOST_IRQ,
2074                 .platform_data=&rk808_data,
2075         },
2076 #endif
2077
2078 #if defined (CONFIG_RTC_HYM8563)
2079         {
2080                 .type                   = "rtc_hym8563",
2081                 .addr           = 0x51,
2082                 .flags                  = 0,
2083                 .irq            = RK30_PIN1_PA4,
2084         },
2085 #endif
2086
2087 };
2088 #endif
2089
2090 void __sramfunc board_pmu_suspend(void)
2091 {      
2092         #if defined (CONFIG_MFD_WM831X_I2C)
2093        if(pmic_is_wm8326())
2094        board_pmu_wm8326_suspend();
2095         #endif
2096         #if defined (CONFIG_MFD_TPS65910)
2097        if(pmic_is_tps65910())
2098        board_pmu_tps65910_suspend(); 
2099     #endif   
2100         #if defined (CONFIG_REGULATOR_ACT8846)
2101        if(pmic_is_act8846())
2102        board_pmu_act8846_suspend(); 
2103        #endif   
2104         #if defined (CONFIG_MFD_RK808)
2105        if(pmic_is_rk808())
2106        board_pmu_rk808_suspend();
2107        #endif
2108
2109 }
2110
2111 void __sramfunc board_pmu_resume(void)
2112 {      
2113         #if defined (CONFIG_MFD_WM831X_I2C)
2114        if(pmic_is_wm8326())
2115        board_pmu_wm8326_resume();
2116         #endif
2117         #if defined (CONFIG_MFD_TPS65910)
2118        if(pmic_is_tps65910())
2119        board_pmu_tps65910_resume(); 
2120         #endif
2121         #if defined (CONFIG_REGULATOR_ACT8846)
2122        if(pmic_is_act8846())
2123        board_pmu_act8846_resume(); 
2124        #endif 
2125          #if defined (CONFIG_MFD_RK808)
2126        if(pmic_is_rk808())
2127        board_pmu_rk808_resume();
2128        #endif
2129   
2130 }
2131
2132  int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
2133
2134 #define grf_readl(offset)       readl_relaxed(RK30_GRF_BASE + offset)
2135 #define grf_writel(v, offset)   do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
2136  
2137 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
2138 {
2139 #ifdef CONFIG_RK30_PWM_REGULATOR
2140
2141 //      int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
2142         sram_udelay(10000);
2143         gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
2144         gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
2145         gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
2146         gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
2147
2148         grf_writel((1<<28), GRF_GPIO3D_IOMUX);
2149         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
2150         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
2151         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
2152 #endif 
2153 }
2154 void __sramfunc rk30_pwm_logic_resume_voltage(void)
2155 {
2156 #ifdef CONFIG_RK30_PWM_REGULATOR
2157         grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
2158         grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
2159         grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
2160         grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
2161         sram_udelay(10000);
2162
2163 #endif
2164
2165 }
2166 extern void pwm_suspend_voltage(void);
2167 extern void pwm_resume_voltage(void);
2168 void  rk30_pwm_suspend_voltage_set(void)
2169 {
2170 #ifdef CONFIG_RK30_PWM_REGULATOR
2171         pwm_suspend_voltage();
2172 #endif
2173 }
2174 void  rk30_pwm_resume_voltage_set(void)
2175 {
2176 #ifdef CONFIG_RK30_PWM_REGULATOR
2177         pwm_resume_voltage();
2178 #endif
2179 }
2180
2181
2182 #ifdef CONFIG_I2C2_RK30
2183 static struct i2c_board_info __initdata i2c2_info[] = {
2184 #if defined (CONFIG_LS_CM3217)
2185         {
2186                 .type          = "lightsensor",
2187                 .addr          = 0x10,
2188                 .flags         = 0,
2189                 .platform_data = &cm3217_info,
2190         },
2191 #endif
2192 };
2193 #endif
2194
2195 #ifdef CONFIG_I2C3_RK30
2196 static struct i2c_board_info __initdata i2c3_info[] = {
2197 };
2198 #endif
2199
2200 #ifdef CONFIG_I2C4_RK30
2201 static struct i2c_board_info __initdata i2c4_info[] = {
2202
2203 };
2204 #endif
2205
2206 #ifdef CONFIG_I2C_GPIO_RK30
2207 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
2208 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
2209 static int rk30_i2c_io_init(void)
2210 {
2211         //set iomux (gpio) here
2212         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
2213         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
2214
2215         return 0;
2216 }
2217 struct i2c_gpio_platform_data default_i2c_gpio_data = {
2218        .sda_pin = I2C_SDA_PIN,
2219        .scl_pin = I2C_SCL_PIN,
2220        .udelay = 5, // clk = 500/udelay = 100Khz
2221        .timeout = 100,//msecs_to_jiffies(100),
2222        .bus_num    = 5,
2223        .io_init = rk30_i2c_io_init,
2224 };
2225 static struct i2c_board_info __initdata i2c_gpio_info[] = {
2226 };
2227 #endif
2228
2229 static void __init rk30_i2c_register_board_info(void)
2230 {
2231 #ifdef CONFIG_I2C0_RK30
2232         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
2233 #endif
2234 #ifdef CONFIG_I2C1_RK30
2235         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
2236 #endif
2237 #ifdef CONFIG_I2C2_RK30
2238         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
2239 #endif
2240 #ifdef CONFIG_I2C3_RK30
2241         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
2242 #endif
2243 #ifdef CONFIG_I2C4_RK30
2244         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
2245 #endif
2246 #ifdef CONFIG_I2C_GPIO_RK30
2247         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2248 #endif
2249 }
2250 //end of i2c
2251
2252 //#define POWER_ON_PIN RK30_PIN0_PA0   //power_hold
2253 static void rk30_pm_power_off(void)
2254 {
2255         printk(KERN_ERR "rk30_pm_power_off start...\n");
2256         #if defined(CONFIG_MFD_WM831X)
2257         if(pmic_is_wm8326()){
2258                 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
2259                 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2260          }
2261         #endif
2262
2263         #if defined(CONFIG_REGULATOR_ACT8846)
2264         if(pmic_is_act8846())
2265         {
2266                act8846_device_shutdown();
2267         }
2268         #endif
2269         
2270         #if defined(CONFIG_MFD_TPS65910)        
2271         if(pmic_is_tps65910())
2272         {
2273                 tps65910_device_shutdown();//tps65910 shutdown
2274         }
2275         #endif
2276         
2277          #if defined(CONFIG_MFD_RK808)        
2278         if(pmic_is_rk808())
2279        {
2280                 rk808_device_shutdown();//rk808 shutdown
2281         }
2282         #endif
2283
2284         //gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2285         port_output_off(pwr_on);
2286         while (1);
2287 }
2288
2289
2290 static int __init tp_board_init(void)
2291 {
2292         struct port_config irq_port;
2293         struct port_config rst_port;
2294         int ret = check_tp_param();
2295
2296         if(ret < 0)
2297             return ret;
2298
2299    irq_port = get_port_config(tp_irq);
2300          rst_port = get_port_config(tp_rst);
2301 #if defined (CONFIG_TOUCHSCREEN_GSLX680_RK3168)
2302         if(tp_type == TP_TYPE_GSLX680){          
2303                 gslx680_data.irq_pin = irq_port.gpio;
2304                 gslx680_info.addr = tp_addr; 
2305                 gslx680_data.reset_pin= rst_port.gpio;
2306                 gslx680_data.x_max=tp_xmax;
2307                 gslx680_data.y_max=tp_ymax;
2308                 gslx680_data.firmVer=tp_firmVer;
2309                 i2c_register_board_info(tp_i2c, &gslx680_info, 1);
2310         }
2311 #endif   
2312
2313 #if defined (CONFIG_TOUCHSCREEN_86V_GT811_IIC)
2314         if(tp_type == TP_TYPE_GT811_86V){
2315                 gt811_data.irq_pin = irq_port.gpio;
2316                 gt811_info.addr = tp_addr; 
2317                 gt811_data.reset_pin= rst_port.gpio;
2318                 gt811_data.x_max=tp_xmax;
2319                 gt811_data.y_max=tp_ymax;
2320                 i2c_register_board_info(tp_i2c, &gt811_info, 1);
2321         }
2322 #endif
2323
2324 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
2325         if(tp_type == TP_TYPE_GT8XX){           
2326                 goodix_data.irq_pin = irq_port.gpio;
2327                 goodix_info.addr = tp_addr; 
2328                 goodix_data.reset_pin= rst_port.gpio;
2329                 goodix_data.x_max=tp_xmax;
2330                 goodix_data.y_max=tp_ymax;
2331                 i2c_register_board_info(tp_i2c, &goodix_info, 1);
2332         }
2333 #endif
2334     return 0;
2335 }
2336
2337
2338 static int __init codec_board_init(void)
2339 {
2340         struct port_config spk_port;
2341         struct port_config hp_port;
2342         int ret = check_codec_param();
2343
2344         if(ret < 0)
2345             return ret;
2346
2347         spk_port = get_port_config(spk_ctl);
2348         hp_port = get_port_config(hp_det);
2349
2350 #if defined (CONFIG_SND_RK29_SOC_RT5631)
2351         if(codec_type == CODEC_TYPE_RT5631){
2352                 rt5631_data.spk_pin = spk_port.gpio;
2353                 rt5631_info.addr = codec_addr; 
2354                 rt5631_data.hp_pin= hp_port.gpio;
2355                 i2c_register_board_info(codec_i2c, &rt5631_info, 1);
2356         }
2357 #endif  
2358
2359 #if defined (CONFIG_SND_RK29_SOC_ES8323)
2360         if(codec_type == CODEC_TYPE_ES8323){
2361                 es8323_data.spk_pin = spk_port.gpio;
2362                 es8323_info.addr = codec_addr; 
2363                 es8323_data.hp_pin= hp_port.gpio;
2364                 i2c_register_board_info(codec_i2c, &es8323_info, 1);
2365         }
2366 #endif  
2367
2368 #if defined (CONFIG_MFD_RK616)
2369 if(codec_type == CODEC_TYPE_RK616){
2370                 rk616_pdata.spk_ctl_gpio = spk_port.gpio;
2371                 rk616_info.addr = codec_addr; 
2372                 rk616_pdata.hdmi_irq= get_port_config(codec_hdmi_irq).gpio;
2373                 i2c_register_board_info(codec_i2c, &rk616_info, 1);
2374         }
2375 #endif 
2376         return 0;
2377 }
2378
2379 static int __init chg_board_init(void)
2380 {   
2381         int ret = check_chg_param();        
2382         if(ret < 0)                
2383                 return ret;  
2384 #ifdef CONFIG_BATTERY_RK30_ADC_FAC      
2385         //rk30_adc_battery_platdata.adc_channel = chg_adc;        
2386         if(dc_det != -1){                
2387                 rk30_adc_battery_platdata.dc_det_pin = get_port_config(dc_det).gpio;
2388                 printk("rk30_adc_battery_platdata.dc_det_pin %d %d",rk30_adc_battery_platdata.dc_det_pin,RK30_PIN0_PB2);
2389                 rk30_adc_battery_platdata.dc_det_level = !get_port_config(dc_det).io.active_low;
2390                 } 
2391         else{
2392                         rk30_adc_battery_platdata.dc_det_pin=INVALID_GPIO;
2393                 }
2394         if(bat_low != -1){                
2395                 rk30_adc_battery_platdata.batt_low_pin = get_port_config(bat_low).gpio;
2396                 rk30_adc_battery_platdata.batt_low_level = !get_port_config(bat_low).io.active_low;
2397                 }
2398         else{
2399                         rk30_adc_battery_platdata.batt_low_pin=INVALID_GPIO;
2400                 }
2401         if(chg_ok != -1){                
2402                 rk30_adc_battery_platdata.charge_ok_pin = get_port_config(chg_ok).gpio;
2403                 rk30_adc_battery_platdata.charge_ok_level = !get_port_config(chg_ok).io.active_low;
2404                 }
2405         else{
2406                 rk30_adc_battery_platdata.charge_ok_pin=INVALID_GPIO;
2407                 }       
2408         if(chg_set != -1){                
2409                 rk30_adc_battery_platdata.charge_set_pin = get_port_config(chg_set).gpio; 
2410                 rk30_adc_battery_platdata.charge_set_level = !get_port_config(chg_set).io.active_low;
2411                 } 
2412         else{
2413                 rk30_adc_battery_platdata.charge_set_pin=INVALID_GPIO;
2414                 }
2415         if(usb_det!= -1){
2416                         rk30_adc_battery_platdata.usb_det_pin = get_port_config(chg_set).gpio; 
2417                         rk30_adc_battery_platdata.usb_det_level = !get_port_config(chg_set).io.active_low;
2418                 }
2419         else{
2420                 rk30_adc_battery_platdata.usb_det_pin=INVALID_GPIO;                     
2421                 }
2422
2423         if(ref_vol!= -1){
2424                 rk30_adc_battery_platdata.reference_voltage=ref_vol;
2425                 }
2426         
2427         if(up_res!= -1){
2428                 rk30_adc_battery_platdata.pull_up_res=up_res;
2429                 }
2430         if(down_res!= -1){
2431                 rk30_adc_battery_platdata.pull_down_res=down_res;
2432                 }
2433         if(root_chg!= -1){
2434                 rk30_adc_battery_platdata.is_reboot_charging=root_chg;
2435                 }
2436         if(save_cap!= -1){
2437                 rk30_adc_battery_platdata.save_capacity=save_cap;
2438                 }
2439         if(low_vol!= -1){
2440                 rk30_adc_battery_platdata.low_voltage_protection=low_vol;
2441                 }
2442
2443         for(i=0;i<11;i++)
2444         {
2445                 rk30_adc_battery_platdata.chargeArray[i]=bat_charge[i];
2446                 rk30_adc_battery_platdata.dischargeArray[i]=bat_discharge[i];
2447         }
2448 #endif          
2449         return 0;
2450 }
2451
2452 static int __init gs_board_init(void)
2453
2454         int i;
2455         struct port_config port;        
2456         int ret = check_gs_param();        
2457         if(ret < 0)                
2458                 return ret;        
2459          port = get_port_config(gs_irq);       
2460 //mma7660
2461 #if defined (CONFIG_GS_MMA7660)        
2462         if(gs_type == GS_TYPE_MMA7660){
2463                 
2464                 mma7660_info.irq = port.gpio;                
2465                 mma7660_info.addr = gs_addr;               
2466                 for(i = 0; i < 9; i++)                        
2467                         mma7660_data.orientation[i] = gs_orig[i];               
2468                 i2c_register_board_info(gs_i2c, &mma7660_info, 1);        
2469         }
2470 #endif
2471
2472 #if defined (CONFIG_GS_LIS3DH)
2473         if(gs_type == GS_TYPE_LIS3DH){                
2474                 lis3dh_info.irq = port.gpio;                
2475                 lis3dh_info.addr = gs_addr;                
2476                 for(i = 0; i < 9; i++)                        
2477                         lis3dh_data.orientation[i] = gs_orig[i];                
2478                 i2c_register_board_info(gs_i2c, &lis3dh_info, 1); 
2479         }
2480 #endif
2481
2482 #if defined (CONFIG_GS_MXC6225)
2483         if(gs_type == GS_TYPE_MXC6225){ 
2484                 mxc6225_info.irq = port.gpio;                
2485                 mxc6225_info.addr = gs_addr;                
2486                 for(i = 0; i < 9; i++)                        
2487                         mxc6225_data.orientation[i] = gs_orig[i];               
2488                 i2c_register_board_info(gs_i2c, &mxc6225_info, 1); 
2489         }
2490 #endif
2491
2492 #if defined (CONFIG_GS_DMT10)
2493         if(gs_type == GS_TYPE_DMARAD10){ 
2494                 dmt10_info.irq = port.gpio;                
2495                 dmt10_info.addr = gs_addr;                
2496                 for(i = 0; i < 9; i++)                        
2497                         dmt10_data.orientation[i] = gs_orig[i];         
2498                 i2c_register_board_info(gs_i2c, &dmt10_info, 1); 
2499         }
2500 #endif
2501
2502 #if defined (CONFIG_GS_MMA8452)
2503         if(gs_type == GS_TYPE_MMA8452){ 
2504                 mma8452_info.irq = port.gpio;                
2505                 mma8452_info.addr = gs_addr;                
2506                 for(i = 0; i < 9; i++)                        
2507                         mma8452_data.orientation[i] = gs_orig[i];               
2508                 i2c_register_board_info(gs_i2c, &mma8452_info, 1); 
2509         }
2510 #endif
2511
2512 #if defined (CONFIG_GS_LSM303D)
2513         if(gs_type == GS_TYPE_LSM303D){ 
2514                 lms303d_info.irq = port.gpio;                
2515                 lms303d_info.addr = gs_addr;                
2516                 for(i = 0; i < 9; i++)                        
2517                         lms303d_data.orientation[i] = gs_orig[i];               
2518                 i2c_register_board_info(gs_i2c, &lms303d_info, 1); 
2519         }
2520 #endif
2521
2522
2523         return 0;
2524 }
2525
2526 static int __init bl_board_init(void){       
2527         int ret = check_bl_param();        
2528         if(ret < 0)                
2529                 return ret; 
2530
2531         switch(bl_pwmid)
2532     {
2533         case 0:
2534                         bl_pwm_mode = PWM0;
2535                         break;
2536                 case 1:
2537                         bl_pwm_mode = PWM1;
2538                         break;
2539                 case 2:
2540                         bl_pwm_mode = PWM2;
2541                         break;
2542                 case 3:
2543                         bl_pwm_mode = PWM3;
2544                         break;
2545     }
2546         
2547         rk29_bl_info.pwm_id = bl_pwmid;
2548         rk29_bl_info.brightness_mode=bl_mode;
2549         rk29_bl_info.pre_div=bl_div;
2550         rk29_bl_info.bl_ref = bl_ref;
2551         rk29_bl_info.min_brightness=bl_min;
2552         rk29_bl_info.max_brightness=bl_max;
2553
2554
2555         return 0;
2556 }
2557
2558 static int __init lcd_board_init(void)
2559 {        
2560         return check_lcd_param();
2561 }
2562
2563 static int __init key_board_init(void){        
2564         int i;        
2565         struct port_config port;        
2566         for(i = 0; i < key_val_size; i++){ 
2567                 if(key_val[i] & (1<<31)){                        
2568                         key_button[i].adc_value = key_val[i] & 0xffff;                        
2569                         key_button[i].gpio = INVALID_GPIO;                
2570                 }else{
2571                         port = get_port_config(key_val[i]);
2572                         key_button[i].gpio = port.gpio;                        
2573                         key_button[i].active_low = port.io.active_low;                
2574                 }        
2575         }        
2576         rk29_keys_pdata.nbuttons = key_val_size;        
2577         rk29_keys_pdata.chn = key_adc;        
2578         return 0;
2579 }
2580
2581 static int __init wifi_board_init(void)
2582 {        
2583         return check_wifi_param();
2584 }
2585
2586
2587 static int __init rk_config_init(void)
2588 {
2589         int ret = 0;
2590         ret = lcd_board_init();       
2591         if(ret < 0)                
2592                 INIT_ERR("lcd");
2593
2594         ret = bl_board_init();       
2595         if(ret < 0)                
2596                 INIT_ERR("backlight");
2597         
2598         ret = tp_board_init();
2599         if(ret < 0)
2600                 INIT_ERR("tp");  
2601
2602         ret = gs_board_init();       
2603         if(ret < 0)                
2604                 INIT_ERR("gsensor");
2605         
2606         ret = codec_board_init();
2607         if(ret < 0)
2608                 INIT_ERR("codec"); 
2609
2610         ret = key_board_init();        
2611         if(ret < 0)
2612                 INIT_ERR("key"); 
2613
2614         ret = chg_board_init();
2615         if(ret < 0)
2616                 INIT_ERR("charge"); 
2617
2618         ret = wifi_board_init();
2619         if(ret < 0)
2620                 INIT_ERR("wifi"); 
2621         
2622         return 0;       
2623 }
2624
2625 static void __init machine_rk30_board_init(void)
2626 {
2627         //avs_init();
2628         rk_power_on();
2629         rk_config_init();
2630         pm_power_off = rk30_pm_power_off;
2631         
2632         rk30_i2c_register_board_info();
2633         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2634         platform_add_devices(devices, ARRAY_SIZE(devices));
2635         rk_platform_add_display_devices();
2636         board_usb_detect_init(RK30_PIN0_PA7);
2637
2638 #if defined(CONFIG_WIFI_CONTROL_FUNC)
2639         rk29sdk_wifi_bt_gpio_control_init();
2640 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
2641     rk29sdk_wifi_combo_module_gpio_init();
2642 #endif
2643
2644 #if defined(CONFIG_MT6620)
2645     clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2646 #endif
2647
2648 #if defined(CONFIG_MT5931_MT6622)
2649                 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2650 #endif          
2651 }
2652 #define HD_SCREEN_SIZE 1920UL*1200UL*4*3
2653 static void __init rk30_reserve(void)
2654 {
2655         size_t fbsize=get_fb_size();
2656 #if defined(CONFIG_ARCH_RK3188)
2657         /*if lcd resolution great than or equal to 1920*1200,reserve the ump memory */
2658         if(!(fbsize < ALIGN(HD_SCREEN_SIZE,SZ_1M)))
2659         {
2660                 int ump_mem_phy_size=512UL*1024UL*1024UL; 
2661                 resource_mali[0].start = board_mem_reserve_add("ump buf", ump_mem_phy_size); 
2662                 resource_mali[0].end = resource_mali[0].start + ump_mem_phy_size -1;
2663         }
2664 #endif
2665 #ifdef CONFIG_ION
2666         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2667 #endif
2668 #ifdef CONFIG_FB_ROCKCHIP
2669         resource_fb[0].start = board_mem_reserve_add("fb0 buf", fbsize);
2670         resource_fb[0].end = resource_fb[0].start + fbsize- 1;
2671 #if 0
2672         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2673         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2674 #endif
2675
2676 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2677         resource_fb[2].start = board_mem_reserve_add("fb2 buf",fbsize);
2678         resource_fb[2].end = resource_fb[2].start + fbsize - 1;
2679 #endif
2680 #endif
2681
2682 #ifdef CONFIG_VIDEO_RK29
2683         rk30_camera_request_reserve_mem();
2684 #endif
2685         
2686 #ifdef CONFIG_GPS_RK
2687         //it must be more than 8MB
2688         rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2689 #endif
2690         board_mem_reserved();
2691 }
2692 /******************************** arm dvfs frequency volt table **********************************/
2693 /**
2694  * dvfs_cpu_logic_table: table for arm and logic dvfs 
2695  * @frequency   : arm frequency
2696  * @cpu_volt    : arm voltage depend on frequency
2697  */
2698
2699 #if defined(CONFIG_ARCH_RK3188)
2700 //sdk
2701 static struct cpufreq_frequency_table dvfs_arm_table_volt_level0[] = {
2702         {.frequency = 312 * 1000,       .index = 850 * 1000},
2703         {.frequency = 504 * 1000,       .index = 900 * 1000},
2704         {.frequency = 816 * 1000,       .index = 950 * 1000},
2705         {.frequency = 1008 * 1000,      .index = 1025 * 1000},
2706         {.frequency = 1200 * 1000,      .index = 1100 * 1000},
2707         {.frequency = 1416 * 1000,      .index = 1200 * 1000},
2708         {.frequency = 1608 * 1000,      .index = 1300 * 1000},
2709         {.frequency = CPUFREQ_TABLE_END},
2710 };
2711 //default
2712 static struct cpufreq_frequency_table dvfs_arm_table_volt_level1[] = {
2713         {.frequency = 312 * 1000,       .index = 875 * 1000},
2714         {.frequency = 504 * 1000,       .index = 925 * 1000},
2715         {.frequency = 816 * 1000,       .index = 975 * 1000},
2716         {.frequency = 1008 * 1000,      .index = 1075 * 1000},
2717         {.frequency = 1200 * 1000,      .index = 1150 * 1000},
2718         {.frequency = 1416 * 1000,      .index = 1250 * 1000},
2719         {.frequency = 1608 * 1000,      .index = 1350 * 1000},
2720         {.frequency = CPUFREQ_TABLE_END},
2721 };
2722 // cube 10'
2723 static struct cpufreq_frequency_table dvfs_arm_table_volt_level2[] = {
2724         {.frequency = 312 * 1000,       .index = 900 * 1000},
2725         {.frequency = 504 * 1000,       .index = 925 * 1000},
2726         {.frequency = 816 * 1000,       .index = 1000 * 1000},
2727         {.frequency = 1008 * 1000,      .index = 1075 * 1000},
2728         {.frequency = 1200 * 1000,      .index = 1200 * 1000},
2729         {.frequency = 1416 * 1000,      .index = 1250 * 1000},
2730         {.frequency = 1608 * 1000,      .index = 1350 * 1000},
2731         {.frequency = CPUFREQ_TABLE_END},
2732 };
2733
2734 /******************************** gpu dvfs frequency volt table **********************************/
2735 //sdk
2736 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level0[] = {  
2737         {.frequency = 133 * 1000,       .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2738         {.frequency = 200 * 1000,       .index = 975 * 1000},
2739         {.frequency = 266 * 1000,       .index = 1000 * 1000},
2740         {.frequency = 300 * 1000,       .index = 1050 * 1000},
2741         {.frequency = 400 * 1000,       .index = 1100 * 1000},
2742         {.frequency = 600 * 1000,       .index = 1200 * 1000},
2743         {.frequency = CPUFREQ_TABLE_END},
2744 };
2745 //cube 10'
2746 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level1[] = {  
2747         {.frequency = 133 * 1000,       .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2748         {.frequency = 200 * 1000,       .index = 1000 * 1000},
2749         {.frequency = 266 * 1000,       .index = 1025 * 1000},
2750         {.frequency = 300 * 1000,       .index = 1050 * 1000},
2751         {.frequency = 400 * 1000,       .index = 1100 * 1000},
2752         {.frequency = 600 * 1000,       .index = 1250 * 1000},
2753         {.frequency = CPUFREQ_TABLE_END},
2754 };
2755
2756 /******************************** ddr dvfs frequency volt table **********************************/
2757 static struct cpufreq_frequency_table dvfs_ddr_table_volt_level0[] = {
2758         {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND,    .index = 950 * 1000},
2759         {.frequency = 300 * 1000 + DDR_FREQ_VIDEO,      .index = 1000 * 1000},
2760         {.frequency = 396 * 1000 + DDR_FREQ_NORMAL,     .index = 1100 * 1000},
2761         {.frequency = 460 * 1000 + DDR_FREQ_DUALVIEW,     .index = 1150 * 1000},
2762         {.frequency = CPUFREQ_TABLE_END},
2763 };
2764
2765 //if you board is good for volt quality,select dvfs_arm_table_volt_level0
2766 #define dvfs_arm_table dvfs_arm_table_volt_level1
2767 #define dvfs_gpu_table dvfs_gpu_table_volt_level1
2768 #define dvfs_ddr_table dvfs_ddr_table_volt_level0
2769
2770 #else
2771 //for RK3168 && RK3066B
2772 static struct cpufreq_frequency_table dvfs_arm_table[] = {
2773         {.frequency = 312 * 1000,       .index = 950 * 1000},
2774         {.frequency = 504 * 1000,       .index = 1000 * 1000},
2775         {.frequency = 816 * 1000,       .index = 1050 * 1000},
2776         {.frequency = 1008 * 1000,      .index = 1125 * 1000},
2777         {.frequency = 1200 * 1000,      .index = 1200 * 1000},
2778         //{.frequency = 1416 * 1000,      .index = 1250 * 1000},
2779         //{.frequency = 1608 * 1000,      .index = 1300 * 1000},
2780         {.frequency = CPUFREQ_TABLE_END},
2781 };
2782
2783 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2784         {.frequency = 100 * 1000,       .index = 1000 * 1000},
2785         {.frequency = 200 * 1000,       .index = 1000 * 1000},
2786         {.frequency = 266 * 1000,       .index = 1050 * 1000},
2787         //{.frequency = 300 * 1000,       .index = 1050 * 1000},
2788         {.frequency = 400 * 1000,       .index = 1125 * 1000},
2789         {.frequency = CPUFREQ_TABLE_END},
2790 };
2791
2792 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2793         {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND,    .index = 1000 * 1000},
2794         {.frequency = 300 * 1000 + DDR_FREQ_VIDEO,      .index = 1050 * 1000},
2795         {.frequency = 400 * 1000 + DDR_FREQ_NORMAL,     .index = 1100 * 1000},
2796         {.frequency = CPUFREQ_TABLE_END},
2797 };
2798 #endif
2799 /******************************** arm dvfs frequency volt table end **********************************/
2800 //#define DVFS_CPU_TABLE_SIZE   (ARRAY_SIZE(dvfs_cpu_logic_table))
2801 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2802 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2803
2804 void __init board_clock_init(void)
2805 {
2806         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2807         //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);    
2808         dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2809         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2810         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2811 }
2812
2813 MACHINE_START(RK30, "RK30board")
2814         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
2815         .fixup          = rk30_fixup,
2816         .reserve        = &rk30_reserve,
2817         .map_io         = rk30_map_io,
2818         .init_irq       = rk30_init_irq,
2819         .timer          = &rk30_timer,
2820         .init_machine   = machine_rk30_board_init,
2821 MACHINE_END