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