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