How to use CONFIG_RK29_SDIO_IRQ_FROM_GPIO for your new wifi-module.
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk30 / board-rk3168m-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 "board-rk3168-tb-camera.c"
83
84 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
85 #define TOUCH_RESET_PIN  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_PIN1_PB7,
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            3
136 #define PWM_MODE          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_PA2
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, 0, 1, 0, -1, 0},
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_PB0
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_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-rk3168m-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         #ifdef USE_SDIO_INT_LEVEL
1011         .sdio_INT_level = RK30SDK_WIFI_GPIO_WIFI_INT_B_ENABLE_VALUE,
1012         #endif
1013     #endif
1014
1015     .det_pin_info = {    
1016 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1017      #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
1018         .io             = RK29SDK_SD_CARD_DETECT_N,
1019      #else
1020          .io             = INVALID_GPIO,
1021      #endif   
1022
1023         .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
1024         #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1025         .iomux          = {
1026             .name       = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1027             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1028             .fgpio      = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1029             #endif
1030             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1031             .fmux       = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1032             #endif
1033         },
1034         #endif
1035  #else
1036         .io             = INVALID_GPIO,
1037         .enable         = GPIO_LOW,
1038 #endif
1039     },
1040    
1041         .enable_sd_wakeup = 0,
1042 };
1043 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1044
1045 /**************************************************************************************************
1046  * the end of setting for SDMMC devices
1047 **************************************************************************************************/
1048
1049 #ifdef CONFIG_BATTERY_RK30_ADC
1050 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1051         .dc_det_pin      = RK30_PIN0_PB2,
1052         .batt_low_pin    = RK30_PIN0_PB1, 
1053         .charge_set_pin  = INVALID_GPIO,
1054         .charge_ok_pin   = RK30_PIN0_PA6,
1055         .dc_det_level    = GPIO_LOW,
1056         .charge_ok_level = GPIO_HIGH,
1057 };
1058
1059 static struct platform_device rk30_device_adc_battery = {
1060         .name   = "rk30-battery",
1061         .id     = -1,
1062         .dev = {
1063                 .platform_data = &rk30_adc_battery_platdata,
1064         },
1065 };
1066 #endif
1067 #ifdef CONFIG_RK30_PWM_REGULATOR
1068 static int pwm_voltage_map[] = {
1069         800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
1070 };
1071 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1072         {
1073                 .supply = "vdd_cpu",
1074         }
1075 };
1076
1077 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1078 {
1079         {
1080                 .constraints = {
1081                         .name = "PWM_DCDC1",
1082                         .min_uV = 600000,
1083                         .max_uV = 1800000,      //0.6-1.8V
1084                         .apply_uV = true,
1085                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1086                 },
1087                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1088                 .consumer_supplies = pwm_dcdc1_consumers,
1089         },
1090 };
1091
1092 static struct pwm_platform_data pwm_regulator_info[1] = {
1093         {
1094                 .pwm_id = 1,
1095                 .pwm_gpio = RK30_PIN3_PD4,
1096                 .pwm_iomux_pwm = PWM1,
1097                 .pwm_iomux_gpio = GPIO3_D4,
1098                 .pwm_voltage = 1100000,
1099                 .suspend_voltage = 1000000,
1100                 .min_uV = 800000,
1101                 .max_uV = 1375000,
1102                 .coefficient = 575,     //57.5%
1103                 .pwm_voltage_map = pwm_voltage_map,
1104                 .init_data      = &pwm_regulator_init_dcdc[0],
1105         },
1106 };
1107
1108 struct platform_device pwm_regulator_device[1] = {
1109         {
1110                 .name = "pwm-voltage-regulator",
1111                 .id = 0,
1112                 .dev            = {
1113                         .platform_data = &pwm_regulator_info[0],
1114                 }
1115         },
1116 };
1117 #endif
1118
1119 #ifdef CONFIG_RK29_VMAC
1120 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1121 #include "board-rk30-sdk-vmac.c"
1122 #endif
1123
1124 #ifdef CONFIG_RFKILL_RK
1125 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1126 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1127     .type               = RFKILL_TYPE_BLUETOOTH,
1128
1129     .poweron_gpio       = { // BT_REG_ON
1130         .io             = INVALID_GPIO, //RK30_PIN3_PC7,
1131         .enable         = GPIO_HIGH,
1132         .iomux          = {
1133             .name       = "bt_poweron",
1134             .fgpio      = GPIO3_C7,
1135         },
1136     },
1137
1138     .reset_gpio         = { // BT_RST
1139         .io             = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1140         .enable         = GPIO_LOW,
1141         .iomux          = {
1142             .name       = "bt_reset",
1143             .fgpio      = GPIO3_C7,
1144        },
1145    }, 
1146
1147     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
1148         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1149         .enable         = GPIO_HIGH,
1150         .iomux          = {
1151             .name       = "bt_wake",
1152             .fgpio      = GPIO3_C6,
1153         },
1154     },
1155
1156     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1157         .gpio           = {
1158             .io         = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1159             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
1160             .iomux      = {
1161                 .name   = NULL,
1162             },
1163         },
1164     },
1165
1166     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
1167         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1168         .enable         = GPIO_LOW,
1169         .iomux          = {
1170             .name       = "bt_rts",
1171             .fgpio      = GPIO1_A3,
1172             .fmux       = UART0_RTSN,
1173         },
1174     },
1175 };
1176
1177 static struct platform_device device_rfkill_rk = {
1178     .name   = "rfkill_rk",
1179     .id     = -1,
1180     .dev    = {
1181         .platform_data = &rfkill_rk_platdata,
1182     },
1183 };
1184 #endif
1185
1186 #if defined(CONFIG_GPS_RK)
1187 int rk_gps_io_init(void)
1188 {
1189         printk("%s \n", __FUNCTION__);
1190         
1191         gpio_request(RK30_PIN1_PB5, NULL);
1192         gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1193
1194         iomux_set(GPS_RFCLK);//GPS_CLK
1195         iomux_set(GPS_MAG);//GPS_MAG
1196         iomux_set(GPS_SIG);//GPS_SIGN
1197
1198         gpio_request(RK30_PIN1_PA6, NULL);
1199         gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1200
1201         gpio_request(RK30_PIN1_PA5, NULL);
1202         gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW); 
1203
1204         gpio_request(RK30_PIN1_PA7, NULL);
1205         gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);         
1206         return 0;
1207 }
1208 int rk_gps_power_up(void)
1209 {
1210         printk("%s \n", __FUNCTION__);
1211
1212         return 0;
1213 }
1214
1215 int rk_gps_power_down(void)
1216 {
1217         printk("%s \n", __FUNCTION__);
1218
1219         return 0;
1220 }
1221
1222 int rk_gps_reset_set(int level)
1223 {
1224         return 0;
1225 }
1226 int rk_enable_hclk_gps(void)
1227 {
1228         struct clk *gps_aclk = NULL;
1229         gps_aclk = clk_get(NULL, "aclk_gps");
1230         if(gps_aclk) {
1231                 clk_enable(gps_aclk);
1232                 clk_put(gps_aclk);
1233                 printk("%s \n", __FUNCTION__);
1234         }
1235         else
1236                 printk("get gps aclk fail\n");
1237         return 0;
1238 }
1239 int rk_disable_hclk_gps(void)
1240 {
1241         struct clk *gps_aclk = NULL;
1242         gps_aclk = clk_get(NULL, "aclk_gps");
1243         if(gps_aclk) {
1244                 //TO wait long enough until GPS ISR is finished.
1245                 msleep(5);
1246                 clk_disable(gps_aclk);
1247                 clk_put(gps_aclk);
1248                 printk("%s \n", __FUNCTION__);
1249         }       
1250         else
1251                 printk("get gps aclk fail\n");
1252         return 0;
1253 }
1254 struct rk_gps_data rk_gps_info = {
1255         .io_init = rk_gps_io_init,
1256         .power_up = rk_gps_power_up,
1257         .power_down = rk_gps_power_down,
1258         .reset = rk_gps_reset_set,
1259         .enable_hclk_gps = rk_enable_hclk_gps,
1260         .disable_hclk_gps = rk_disable_hclk_gps,
1261         .GpsSign = RK30_PIN1_PB3,
1262         .GpsMag = RK30_PIN1_PB2,        //GPIO index
1263         .GpsClk = RK30_PIN1_PB4,        //GPIO index
1264         .GpsVCCEn = RK30_PIN1_PB5,     //GPIO index
1265         .GpsSpi_CSO = RK30_PIN1_PA4,    //GPIO index
1266         .GpsSpiClk = RK30_PIN1_PA5,     //GPIO index
1267         .GpsSpiMOSI = RK30_PIN1_PA7,      //GPIO index
1268         .GpsIrq = IRQ_GPS,
1269         .GpsSpiEn = 0,
1270         .GpsAdcCh = 2,
1271         .u32GpsPhyAddr = RK30_GPS_PHYS,
1272         .u32GpsPhySize = RK30_GPS_SIZE,
1273 };
1274
1275 struct platform_device rk_device_gps = {
1276         .name = "gps_hv5820b",
1277         .id = -1,
1278         .dev            = {
1279         .platform_data = &rk_gps_info,
1280                 }
1281         };
1282 #endif
1283
1284 #if defined(CONFIG_MT5931_MT6622)
1285 static struct mt6622_platform_data mt6622_platdata = {
1286                     .power_gpio         = { // BT_REG_ON
1287                         .io             = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1288                             .enable         = GPIO_HIGH,
1289                             .iomux          = {
1290                                     .name       = NULL,
1291                                 },
1292                     },
1293
1294                     .reset_gpio         = { // BT_RST
1295                         .io             = RK30_PIN0_PD7,
1296                         .enable         = GPIO_HIGH,
1297                         .iomux          = {
1298                             .name       = NULL,
1299                         },
1300                     },
1301
1302                     .irq_gpio           = {
1303                             .io             = RK30_PIN3_PD2,
1304                             .enable         = GPIO_HIGH,
1305                             .iomux          = {
1306                                     .name       = NULL,
1307                                 },
1308                     }
1309 };
1310
1311 static struct platform_device device_mt6622 = {
1312                     .name   = "mt6622",
1313                         .id     = -1,
1314                         .dev    = {
1315                                .platform_data = &mt6622_platdata,
1316                         },
1317 };      
1318 #endif
1319
1320 static struct platform_device *devices[] __initdata = {
1321 #ifdef CONFIG_ION
1322         &device_ion,
1323 #endif
1324 #ifdef CONFIG_ANDROID_TIMED_GPIO
1325         &rk29_device_vibrator,
1326 #endif
1327 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1328         &rk29_device_gpio_leds,
1329 #endif
1330 #ifdef CONFIG_RK_IRDA
1331         &irda_device,
1332 #endif
1333 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1334         &rk29sdk_wifi_device,
1335 #endif
1336
1337 #if defined(CONFIG_MT6620)
1338     &mt3326_device_gps,
1339 #endif   
1340
1341 #ifdef CONFIG_RK29_SUPPORT_MODEM
1342         &rk30_device_modem,
1343 #endif
1344 #if defined(CONFIG_MU509)
1345         &rk29_device_mu509,
1346 #endif
1347 #if defined(CONFIG_MW100)
1348         &rk29_device_mw100,
1349 #endif
1350 #if defined(CONFIG_MT6229)
1351         &rk29_device_mt6229,
1352 #endif
1353 #ifdef CONFIG_BATTERY_RK30_ADC
1354         &rk30_device_adc_battery,
1355 #endif
1356 #ifdef CONFIG_RFKILL_RK
1357         &device_rfkill_rk,
1358 #endif
1359 #ifdef CONFIG_GPS_RK
1360         &rk_device_gps,
1361 #endif
1362
1363 #ifdef CONFIG_MT5931_MT6622
1364         &device_mt6622,
1365 #endif
1366 };
1367
1368 static int rk_platform_add_display_devices(void)
1369 {
1370         struct platform_device *fb = NULL;  //fb
1371         struct platform_device *lcdc0 = NULL; //lcdc0
1372         struct platform_device *lcdc1 = NULL; //lcdc1
1373         struct platform_device *bl = NULL; //backlight
1374 #ifdef CONFIG_FB_ROCKCHIP
1375         fb = &device_fb;
1376 #endif
1377
1378 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
1379         lcdc0 = &device_lcdc0,
1380 #endif
1381
1382 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
1383         lcdc1 = &device_lcdc1,
1384 #endif
1385
1386 #ifdef CONFIG_BACKLIGHT_RK29_BL
1387         bl = &rk29_device_backlight,
1388 #endif
1389         __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1390
1391         return 0;
1392         
1393 }
1394
1395 // i2c
1396 #ifdef CONFIG_I2C0_RK30
1397 static struct i2c_board_info __initdata i2c0_info[] = {
1398 #if defined (CONFIG_GS_MMA8452)
1399         {
1400                 .type           = "gs_mma8452",
1401                 .addr           = 0x1d,
1402                 .flags          = 0,
1403                 .irq            = MMA8452_INT_PIN,
1404                 .platform_data = &mma8452_info,
1405         },
1406 #endif
1407 #if defined (CONFIG_GS_LIS3DH)
1408         {
1409                 .type           = "gs_lis3dh",
1410                 .addr           = 0x19,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
1411                 .flags          = 0,
1412                 .irq            = LIS3DH_INT_PIN,
1413                 .platform_data = &lis3dh_info,
1414         },
1415 #endif
1416 #if defined (CONFIG_COMPASS_AK8975)
1417         {
1418                 .type          = "ak8975",
1419                 .addr          = 0x0d,
1420                 .flags         = 0,
1421                 .irq           = RK30_PIN3_PD7, 
1422                 .platform_data = &akm8975_info,
1423         },
1424 #endif
1425 #if defined (CONFIG_GYRO_L3G4200D)
1426         {
1427                 .type          = "l3g4200d_gryo",
1428                 .addr          = 0x69,
1429                 .flags         = 0,
1430                 .irq           = L3G4200D_INT_PIN,
1431                 .platform_data = &l3g4200d_info,
1432         },
1433 #endif
1434 #if defined (CONFIG_SND_SOC_RK1000)
1435         {
1436                 .type          = "rk1000_i2c_codec",
1437                 .addr          = 0x60,
1438                 .flags         = 0,
1439         },
1440         {
1441                 .type          = "rk1000_control",
1442                 .addr          = 0x40,
1443                 .flags         = 0,
1444         },
1445 #endif
1446 #if defined (CONFIG_SND_SOC_RT5631)
1447         {
1448                 .type                   = "rt5631",
1449                 .addr                   = 0x1a,
1450                 .flags                  = 0,
1451         },
1452 #endif
1453
1454
1455 };
1456 #endif
1457
1458 int __sramdata g_pmic_type =  0;
1459 #ifdef CONFIG_I2C1_RK30
1460 #ifdef CONFIG_MFD_WM831X_I2C
1461 #define PMU_POWER_SLEEP                 RK30_PIN0_PA1 
1462
1463 static struct pmu_info  wm8326_dcdc_info[] = {
1464         {
1465                 .name          = "vdd_core",   //logic
1466                 .min_uv          = 1000000,
1467                 .max_uv         = 1000000,
1468                 .suspend_vol  =  950000,
1469         },
1470         {
1471                 .name          = "vdd_cpu",    //arm
1472                 .min_uv          = 1000000,
1473                 .max_uv         = 1000000,
1474                 .suspend_vol  =  950000,
1475         },
1476         {
1477                 .name          = "dcdc3",   //ddr
1478                 .min_uv          = 1150000,
1479                 .max_uv         = 1150000,
1480                 .suspend_vol  =  1150000,
1481         },
1482         #ifdef CONFIG_MACH_RK3066_SDK
1483         {
1484                 .name          = "dcdc4",   //vcc_io
1485                 .min_uv          = 3300000,
1486                 .max_uv         = 3300000,
1487                 .suspend_vol  =  3000000,
1488         },
1489         #else
1490         {
1491                 .name          = "dcdc4",   //vcc_io
1492                 .min_uv          = 3000000,
1493                 .max_uv         = 3000000,
1494                 .suspend_vol  =  2800000,
1495         },
1496         #endif
1497 };
1498
1499 static struct pmu_info  wm8326_ldo_info[] = {
1500         {
1501                 .name          = "ldo1",   //vcc18_cif
1502                 .min_uv          = 1800000,
1503                 .max_uv         = 1800000,
1504                 .suspend_vol  =  1800000,
1505         },
1506         {
1507                 .name          = "ldo2",    //vccio_wl
1508                 .min_uv          = 1800000,
1509                 .max_uv         = 1800000,
1510                 .suspend_vol  =  1800000,
1511         },
1512         {
1513                 .name          = "ldo3",   //
1514                 .min_uv          = 1100000,
1515                 .max_uv         = 1100000,
1516                 .suspend_vol  =  1100000,
1517         },
1518         {
1519                 .name          = "ldo4",   //vdd11
1520                 .min_uv          = 1000000,
1521                 .max_uv         = 1000000,
1522                 .suspend_vol  =  1000000,
1523         },
1524         {
1525                 .name          = "ldo5",   //vcc25
1526                 .min_uv          = 1800000,
1527                 .max_uv         = 1800000,
1528                 .suspend_vol  =  1800000,
1529         },
1530         {
1531                 .name          = "ldo6",   //vcc33
1532                 .min_uv          = 3300000,
1533                 .max_uv         = 3300000,
1534                 .suspend_vol  =  3300000,
1535         },
1536         {
1537                 .name          = "ldo7",   //vcc28_cif
1538                 .min_uv          = 2800000,
1539                 .max_uv         = 2800000,
1540                 .suspend_vol  =  2800000,
1541         },
1542         {
1543                 .name          = "ldo8",   //vcca33
1544                 .min_uv          = 3300000,
1545                 .max_uv         = 3300000,
1546                 .suspend_vol  =  3300000,
1547         },
1548         {
1549                 .name          = "ldo9",   //vcc_tp
1550                 .min_uv          = 3300000,
1551                 .max_uv         = 3300000,
1552                 .suspend_vol  =  3300000,
1553         },
1554         {
1555                 .name          = "ldo10",   //flash_io
1556                 .min_uv          = 1800000,
1557                 .max_uv         = 1800000,
1558                 .suspend_vol  =  1800000,
1559         },
1560 };
1561
1562 #include "board-pmu-wm8326.c"
1563 #endif
1564
1565 #ifdef CONFIG_MFD_TPS65910
1566 #define TPS65910_HOST_IRQ        RK30_PIN0_PB3
1567
1568 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1569
1570 static struct pmu_info  tps65910_dcdc_info[] = {
1571         {
1572                 .name          = "vdd_core",   //logic
1573                 .min_uv          = 1100000,
1574                 .max_uv         = 1100000,
1575         },
1576         {
1577                 .name          = "vdd2",    //ddr
1578                 .min_uv          = 1200000,
1579                 .max_uv         = 1200000,
1580         },
1581         {
1582                 .name          = "vio",   //vcc_io
1583                 .min_uv          = 2500000,
1584                 .max_uv         = 2500000,
1585         },
1586         
1587 };
1588 static  struct pmu_info  tps65910_ldo_info[] = {
1589         {
1590                 .name          = "vpll",   //vdd10
1591                 .min_uv          = 1000000,
1592                 .max_uv         = 1000000,
1593         },
1594         {
1595                 .name          = "vdig1",    //vcc18_cif
1596                 .min_uv          = 1800000,
1597                 .max_uv         = 1800000,
1598         },
1599         {
1600                 .name          = "vdig2",   //vdd_jetta
1601                 .min_uv          = 1200000,
1602                 .max_uv         = 1200000,
1603         },
1604         {
1605                 .name          = "vaux1",   //vcc28_cif
1606                 .min_uv          = 2800000,
1607                 .max_uv         = 2800000,
1608         },
1609         {
1610                 .name          = "vaux2",   //vcca33
1611                 .min_uv          = 3300000,
1612                 .max_uv         = 3300000,
1613         },
1614         {
1615                 .name          = "vaux33",   //vcc_tp
1616                 .min_uv          = 3300000,
1617                 .max_uv         = 3300000,
1618         },
1619         {
1620                 .name          = "vmmc",   //vcc30
1621                 .min_uv          = 3000000,
1622                 .max_uv         = 3000000,
1623         },
1624         {
1625                 .name          = "vdac",   //vcc18
1626                 .min_uv          = 1800000,
1627                 .max_uv         = 1800000,
1628         },
1629  };
1630
1631 #include "board-pmu-tps65910.c"
1632 #endif
1633
1634 #ifdef CONFIG_REGULATOR_ACT8846
1635 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1636 #define PMU_VSEL RK30_PIN3_PD3
1637 static struct pmu_info  act8846_dcdc_info[] = {
1638         {
1639                 .name          = "act_dcdc1",   //ddr
1640                 .min_uv          = 1200000,
1641                 .max_uv         = 1200000,
1642                 .suspend_vol  =  1200000,
1643         },
1644         {
1645                 .name          = "vdd_core",    //logic
1646                 .min_uv          = 1000000,
1647                 .max_uv         = 1000000,
1648                 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1649                 .suspend_vol  =  1200000,
1650                 #else
1651                 .suspend_vol  =  900000,
1652                 #endif
1653
1654         },
1655         {
1656                 .name          = "vdd_cpu",   //arm
1657                 .min_uv          = 1000000,
1658                 .max_uv         = 1000000,
1659                 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1660                 .suspend_vol  =  1200000,
1661                 #else
1662                 .suspend_vol  =  900000,
1663                 #endif
1664
1665         },
1666         {
1667                 .name          = "act_dcdc4",   //vccio
1668                 .min_uv          = 3000000,
1669                 .max_uv         = 3000000,
1670                 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1671                 .suspend_vol  =  3000000,
1672                 #else
1673                 .suspend_vol  =  2800000,
1674                 #endif
1675
1676         },
1677         
1678 };
1679 static  struct pmu_info  act8846_ldo_info[] = {
1680         {
1681                 .name          = "act_ldo1",   //vdd11
1682                 .min_uv          = 1000000,
1683                 .max_uv         = 1000000,
1684         },
1685         {
1686                 .name          = "act_ldo2",    //vdd12
1687                 .min_uv          = 1200000,
1688                 .max_uv         = 1200000,
1689         },
1690         {
1691                 .name          = "act_ldo3",   //vcc18_cif
1692                 .min_uv          = 1800000,
1693                 .max_uv         = 1800000,
1694         },
1695         {
1696                 .name          = "act_ldo4",   //vcca33
1697                 .min_uv          = 3300000,
1698                 .max_uv         = 3300000,
1699         },
1700         {
1701                 .name          = "act_ldo5",   //vcctp
1702                 .min_uv          = 3300000,
1703                 .max_uv         = 3300000,
1704         },
1705         {
1706                 .name          = "act_ldo6",   //vcc33
1707                 .min_uv          = 3300000,
1708                 .max_uv         = 3300000,
1709         },
1710         {
1711                 .name          = "act_ldo7",   //vccio_wl
1712                 .min_uv          = 1800000,
1713                 .max_uv         = 1800000,
1714         },
1715         {
1716                 .name          = "act_ldo8",   //vcc28_cif
1717                 .min_uv          = 2800000,
1718                 .max_uv         = 2800000,
1719         },
1720  };
1721
1722 #include "board-pmu-act8846.c"
1723 #endif
1724
1725
1726 static struct i2c_board_info __initdata i2c1_info[] = {
1727 #if defined (CONFIG_MFD_WM831X_I2C)
1728         {
1729                 .type          = "wm8326",
1730                 .addr          = 0x34,
1731                 .flags         = 0,
1732                 .irq           = RK30_PIN0_PB3,
1733                 .platform_data = &wm831x_platdata,
1734         },
1735 #endif
1736 #if defined (CONFIG_MFD_TPS65910)
1737         {
1738         .type           = "tps65910",
1739         .addr           = TPS65910_I2C_ID0,
1740         .flags          = 0,
1741         .irq            = TPS65910_HOST_IRQ,
1742         .platform_data = &tps65910_data,
1743         },
1744 #endif
1745
1746 #if defined (CONFIG_REGULATOR_ACT8846)
1747         {
1748                 .type                   = "act8846",
1749                 .addr           = 0x5a, 
1750                 .flags                  = 0,
1751         //      .irq            = ACT8846_HOST_IRQ,
1752                 .platform_data=&act8846_data,
1753         },
1754 #endif
1755 #if defined (CONFIG_RTC_HYM8563)
1756         {
1757                 .type                   = "rtc_hym8563",
1758                 .addr           = 0x51,
1759                 .flags                  = 0,
1760                 .irq            = RK30_PIN1_PA4,
1761         },
1762 #endif
1763
1764 };
1765 #endif
1766
1767 void __sramfunc board_pmu_suspend(void)
1768 {      
1769         #if defined (CONFIG_MFD_WM831X_I2C)
1770        if(pmic_is_wm8326())
1771        board_pmu_wm8326_suspend();
1772         #endif
1773         #if defined (CONFIG_MFD_TPS65910)
1774        if(pmic_is_tps65910())
1775        board_pmu_tps65910_suspend(); 
1776     #endif   
1777         #if defined (CONFIG_REGULATOR_ACT8846)
1778        if(pmic_is_act8846())
1779        board_pmu_act8846_suspend(); 
1780        #endif   
1781
1782 }
1783
1784 void __sramfunc board_pmu_resume(void)
1785 {      
1786         #if defined (CONFIG_MFD_WM831X_I2C)
1787        if(pmic_is_wm8326())
1788        board_pmu_wm8326_resume();
1789         #endif
1790         #if defined (CONFIG_MFD_TPS65910)
1791        if(pmic_is_tps65910())
1792        board_pmu_tps65910_resume(); 
1793         #endif
1794         #if defined (CONFIG_REGULATOR_ACT8846)
1795        if(pmic_is_act8846())
1796        board_pmu_act8846_resume(); 
1797        #endif   
1798 }
1799
1800  int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1801
1802 #define grf_readl(offset)       readl_relaxed(RK30_GRF_BASE + offset)
1803 #define grf_writel(v, offset)   do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1804  
1805 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1806 {
1807 #ifdef CONFIG_RK30_PWM_REGULATOR
1808
1809 //      int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1810         sram_udelay(10000);
1811         gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1812         gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1813         gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1814         gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1815
1816         grf_writel((1<<28), GRF_GPIO3D_IOMUX);
1817         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
1818         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
1819         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
1820 #endif 
1821 }
1822 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1823 {
1824 #ifdef CONFIG_RK30_PWM_REGULATOR
1825         grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
1826         grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
1827         grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
1828         grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
1829         sram_udelay(10000);
1830
1831 #endif
1832
1833 }
1834 extern void pwm_suspend_voltage(void);
1835 extern void pwm_resume_voltage(void);
1836 void  rk30_pwm_suspend_voltage_set(void)
1837 {
1838 #ifdef CONFIG_RK30_PWM_REGULATOR
1839         pwm_suspend_voltage();
1840 #endif
1841 }
1842 void  rk30_pwm_resume_voltage_set(void)
1843 {
1844 #ifdef CONFIG_RK30_PWM_REGULATOR
1845         pwm_resume_voltage();
1846 #endif
1847 }
1848
1849
1850 #ifdef CONFIG_I2C2_RK30
1851 static struct i2c_board_info __initdata i2c2_info[] = {
1852 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1853         {
1854                 .type          = "Goodix-TS",
1855                 .addr          = 0x55,
1856                 .flags         = 0,
1857                 .irq           = RK30_PIN1_PB7,
1858                 .platform_data = &goodix_info,
1859         },
1860 #endif
1861 #if defined (CONFIG_LS_CM3217)
1862         {
1863                 .type          = "lightsensor",
1864                 .addr          = 0x10,
1865                 .flags         = 0,
1866                 .platform_data = &cm3217_info,
1867         },
1868 #endif
1869 };
1870 #endif
1871
1872 #ifdef CONFIG_I2C3_RK30
1873 static struct i2c_board_info __initdata i2c3_info[] = {
1874 };
1875 #endif
1876
1877 #ifdef CONFIG_I2C4_RK30
1878 static struct i2c_board_info __initdata i2c4_info[] = {
1879 #ifdef CONFIG_MFD_RK610
1880                 {
1881                         .type                   = "rk610_ctl",
1882                         .addr                   = 0x40,
1883                         .flags                  = 0,
1884                         .platform_data          = &rk610_ctl_pdata,
1885                 },
1886 #ifdef CONFIG_RK610_TVOUT
1887                 {
1888                         .type                   = "rk610_tvout",
1889                         .addr                   = 0x42,
1890                         .flags                  = 0,
1891                 },
1892 #endif
1893 #ifdef CONFIG_HDMI_RK610
1894                 {
1895                         .type                   = "rk610_hdmi",
1896                         .addr                   = 0x46,
1897                         .flags                  = 0,
1898                         .irq                    = INVALID_GPIO,
1899                 },
1900 #endif
1901 #ifdef CONFIG_SND_SOC_RK610
1902                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1903                         .type                   = "rk610_i2c_codec",
1904                         .addr                   = 0x60,
1905                         .flags                  = 0,
1906                         .platform_data          = &rk610_codec_pdata,                                   
1907                 },
1908 #endif
1909 #endif
1910
1911 };
1912 #endif
1913
1914 #ifdef CONFIG_I2C_GPIO_RK30
1915 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1916 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1917 static int rk30_i2c_io_init(void)
1918 {
1919         //set iomux (gpio) here
1920         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1921         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1922
1923         return 0;
1924 }
1925 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1926        .sda_pin = I2C_SDA_PIN,
1927        .scl_pin = I2C_SCL_PIN,
1928        .udelay = 5, // clk = 500/udelay = 100Khz
1929        .timeout = 100,//msecs_to_jiffies(100),
1930        .bus_num    = 5,
1931        .io_init = rk30_i2c_io_init,
1932 };
1933 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1934 };
1935 #endif
1936
1937 static void __init rk30_i2c_register_board_info(void)
1938 {
1939 #ifdef CONFIG_I2C0_RK30
1940         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1941 #endif
1942 #ifdef CONFIG_I2C1_RK30
1943         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1944 #endif
1945 #ifdef CONFIG_I2C2_RK30
1946         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1947 #endif
1948 #ifdef CONFIG_I2C3_RK30
1949         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1950 #endif
1951 #ifdef CONFIG_I2C4_RK30
1952         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1953 #endif
1954 #ifdef CONFIG_I2C_GPIO_RK30
1955         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1956 #endif
1957 }
1958 //end of i2c
1959
1960 // ========== Begin of rk3168 top board keypad defination ============
1961
1962 #include <plat/key.h>
1963
1964 static struct rk29_keys_button key_button[] = {
1965         {
1966                 .desc   = "vol-",
1967                 .code   = KEY_VOLUMEDOWN,
1968                 .adc_value      = 747,
1969                 .gpio   = INVALID_GPIO,
1970                 .active_low = PRESS_LEV_LOW,
1971         },
1972         {
1973                 .desc   = "play",
1974                 .code   = KEY_POWER,
1975                 .gpio   = RK30_PIN0_PA4,
1976                 .active_low = PRESS_LEV_LOW,
1977                 .wakeup = 1,
1978         },
1979         {
1980                 .desc   = "vol+",
1981                 .code   = KEY_VOLUMEUP,
1982                 .adc_value      = 559,//133
1983                 .gpio = INVALID_GPIO,
1984                 .active_low = PRESS_LEV_LOW,
1985         },
1986         {
1987                 .desc   = "menu",
1988                 .code   = EV_MENU,
1989                 .adc_value      = 1,
1990                 .gpio = INVALID_GPIO,
1991                 .active_low = PRESS_LEV_LOW,
1992         },
1993         {
1994                 .desc   = "home",
1995                 .code   = KEY_HOME,
1996                 .adc_value      = 355,//550
1997                 .gpio = INVALID_GPIO,
1998                 .active_low = PRESS_LEV_LOW,
1999         },
2000         {
2001                 .desc   = "esc",
2002                 .code   = KEY_BACK,
2003                 .adc_value      = 171,//333
2004                 .gpio = INVALID_GPIO,
2005                 .active_low = PRESS_LEV_LOW,
2006         },
2007         {
2008                 .desc   = "camera",
2009                 .code   = KEY_CAMERA,
2010                 .adc_value      = 742,
2011                 .gpio = INVALID_GPIO,
2012                 .active_low = PRESS_LEV_LOW,
2013         },
2014 };
2015 struct rk29_keys_platform_data rk29_keys_pdata = {
2016         .buttons        = key_button,
2017         .nbuttons       = ARRAY_SIZE(key_button),
2018         .chn    = 1,  //chn: 0-7, if do not use ADC,set 'chn' -1
2019 };
2020
2021 // =========== End of rk3168 top board keypad defination  =============
2022
2023
2024 #define POWER_ON_PIN RK30_PIN0_PA0   //power_hold
2025 static void rk30_pm_power_off(void)
2026 {
2027         printk(KERN_ERR "rk30_pm_power_off start...\n");
2028         #if defined(CONFIG_MFD_WM831X)
2029         if(pmic_is_wm8326()){
2030                 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
2031                 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2032          }
2033         #endif
2034
2035         #if defined(CONFIG_REGULATOR_ACT8846)
2036         if(pmic_is_act8846())
2037         {
2038                act8846_device_shutdown();
2039         }
2040         #endif
2041         
2042         #if defined(CONFIG_MFD_TPS65910)        
2043         if(pmic_is_tps65910())
2044         {
2045                 tps65910_device_shutdown();//tps65910 shutdown
2046         }
2047         #endif
2048
2049         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2050         while (1);
2051 }
2052
2053 static void __init machine_rk30_board_init(void)
2054 {
2055         //avs_init();
2056         gpio_request(POWER_ON_PIN, "poweronpin");
2057         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2058         
2059         pm_power_off = rk30_pm_power_off;
2060         
2061         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2062
2063
2064         rk30_i2c_register_board_info();
2065         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2066         platform_add_devices(devices, ARRAY_SIZE(devices));
2067         rk_platform_add_display_devices();
2068         board_usb_detect_init(RK30_PIN0_PA7);
2069
2070 #if defined(CONFIG_WIFI_CONTROL_FUNC)
2071         rk29sdk_wifi_bt_gpio_control_init();
2072 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
2073     rk29sdk_wifi_combo_module_gpio_init();
2074 #endif
2075
2076 #if defined(CONFIG_MT6620)
2077     clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2078 #endif
2079
2080 #if defined(CONFIG_MT5931_MT6622)
2081                 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2082 #endif          
2083 }
2084
2085 static void __init rk30_reserve(void)
2086 {
2087 #ifdef CONFIG_ION
2088         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2089 #endif
2090 #ifdef CONFIG_FB_ROCKCHIP
2091         resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2092         resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2093 #if 0
2094         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2095         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2096 #endif
2097
2098 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2099         resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2100         resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2101 #endif
2102 #endif
2103
2104 #ifdef CONFIG_VIDEO_RK29
2105         rk30_camera_request_reserve_mem();
2106 #endif
2107         
2108 #ifdef CONFIG_GPS_RK
2109         //it must be more than 8MB
2110         rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2111 #endif
2112         board_mem_reserved();
2113 }
2114
2115 /**
2116  * dvfs_cpu_logic_table: table for arm and logic dvfs 
2117  * @frequency   : arm frequency
2118  * @cpu_volt    : arm voltage depend on frequency
2119  */
2120 static struct cpufreq_frequency_table dvfs_arm_table[] = {
2121         {.frequency = 312 * 1000,       .index = 850 * 1000},
2122         {.frequency = 504 * 1000,       .index = 900 * 1000},
2123         {.frequency = 816 * 1000,       .index = 950 * 1000},
2124         {.frequency = 1008 * 1000,      .index = 1025 * 1000},
2125         {.frequency = 1200 * 1000,      .index = 1100 * 1000},
2126         {.frequency = 1416 * 1000,      .index = 1200 * 1000},
2127         {.frequency = 1608 * 1000,      .index = 1300 * 1000},
2128         {.frequency = CPUFREQ_TABLE_END},
2129 };
2130
2131 static struct cpufreq_frequency_table dvfs_gpu_table[] = {      
2132 #if defined(CONFIG_ARCH_RK3188)
2133         {.frequency = 133 * 1000,       .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2134 #elif defined(CONFIG_ARCH_RK3066B)
2135         {.frequency = 100 * 1000,       .index = 950 * 1000},//the minimum rate is no limit for rk3168 rk3066B
2136 #endif
2137
2138         {.frequency = 200 * 1000,       .index = 975 * 1000},
2139         {.frequency = 266 * 1000,       .index = 1000 * 1000},
2140         {.frequency = 300 * 1000,       .index = 1050 * 1000},
2141         {.frequency = 400 * 1000,       .index = 1100 * 1000},
2142         {.frequency = 600 * 1000,       .index = 1200 * 1000},
2143         {.frequency = CPUFREQ_TABLE_END},
2144 };
2145
2146 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2147 #if defined(CONFIG_ARCH_RK3188)
2148         {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND,    .index = 950 * 1000},
2149         {.frequency = 300 * 1000 + DDR_FREQ_VIDEO,      .index = 1000 * 1000},
2150 #endif
2151         {.frequency = 396 * 1000 + DDR_FREQ_NORMAL,     .index = 1100 * 1000},
2152         {.frequency = CPUFREQ_TABLE_END},
2153 };
2154
2155 //#define DVFS_CPU_TABLE_SIZE   (ARRAY_SIZE(dvfs_cpu_logic_table))
2156 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2157 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2158
2159 void __init board_clock_init(void)
2160 {
2161         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2162         //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);    
2163         dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2164         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2165         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2166 }
2167
2168 MACHINE_START(RK30, "RK30board")
2169         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
2170         .fixup          = rk30_fixup,
2171         .reserve        = &rk30_reserve,
2172         .map_io         = rk30_map_io,
2173         .init_irq       = rk30_init_irq,
2174         .timer          = &rk30_timer,
2175         .init_machine   = machine_rk30_board_init,
2176 MACHINE_END