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