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