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