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