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