ARM64: DTS: Add rk3399-firefly uart4 device, node as /dev/ttyS1
[firefly-linux-kernel-4.4.55.git] / board-rk3108-tb.c
1 /*
2  *
3  * Copyright (C) 2012 ROCKCHIP, Inc.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
20 #include <linux/io.h>
21 #include <linux/delay.h>
22 #include <linux/i2c.h>
23 #include <linux/skbuff.h>
24 #include <linux/spi/spi.h>
25 #include <linux/mmc/host.h>
26 #include <linux/ion.h>
27 #include <linux/cpufreq.h>
28 #include <linux/clk.h>
29 #include <mach/dvfs.h>
30
31 #include <asm/setup.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/flash.h>
36 #include <asm/hardware/gic.h>
37
38 #include <mach/board.h>
39 #include <mach/hardware.h>
40 #include <mach/io.h>
41 #include <mach/gpio.h>
42 #include <mach/iomux.h>
43 #include <linux/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/rk29-pwm-regulator.h>
49
50 #if defined(CONFIG_MFD_RK610)
51 #include <linux/mfd/rk610_core.h>
52 #endif
53
54 #if defined(CONFIG_RK_HDMI)
55         #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
56 #endif
57
58 #if defined(CONFIG_SPIM_RK29)
59 #include "../../../drivers/spi/rk29_spim.h"
60 #endif
61 #if defined(CONFIG_GPS_RK)
62 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
63 #endif
64
65 #if defined(CONFIG_MU509)
66 #include <linux/mu509.h>
67 #endif
68 #if defined(CONFIG_MW100)
69 #include <linux/mw100.h>
70 #endif
71 #if defined(CONFIG_MT6229)
72 #include <linux/mt6229.h>
73 #endif
74 #if defined(CONFIG_ANDROID_TIMED_GPIO)
75 #include "../../../drivers/staging/android/timed_gpio.h"
76 #endif
77
78 #ifdef  CONFIG_THREE_FB_BUFFER
79 #define RK30_FB0_MEM_SIZE 12*SZ_1M
80 #else
81 #define RK30_FB0_MEM_SIZE 8*SZ_1M
82 #endif
83
84 #include "board-rk3066b-sdk-camera.c"
85 #include "board-rk3066b-sdk-key.c"
86
87 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
88 #define TOUCH_RESET_PIN  RK30_PIN2_PC0
89 #define TOUCH_PWR_PIN    RK30_PIN2_PB4
90 static int goodix_init_platform_hw(void)
91 {
92         int ret;
93         
94         if (TOUCH_PWR_PIN != INVALID_GPIO) {
95                 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
96                 if (ret != 0) {
97                         gpio_free(TOUCH_PWR_PIN);
98                         printk("goodix power error\n");
99                         return -EIO;
100                 }
101                 gpio_direction_output(TOUCH_PWR_PIN, 0);
102                 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
103                 msleep(100);
104         }
105
106         if (TOUCH_RESET_PIN != INVALID_GPIO) {
107                 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
108                 if (ret != 0) {
109                         gpio_free(TOUCH_RESET_PIN);
110                         printk("goodix gpio_request error\n");
111                         return -EIO;
112                 }
113                 gpio_direction_output(TOUCH_RESET_PIN, 1);
114                 msleep(100);
115                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
116                 //msleep(100);
117                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
118                 //msleep(500);
119         }
120         return 0;
121 }
122
123 struct goodix_platform_data goodix_info = {
124         .model = 8105,
125         .irq_pin = RK30_PIN0_PD4,
126         .rest_pin = TOUCH_RESET_PIN,
127         .init_platform_hw = goodix_init_platform_hw,
128 };
129 #endif
130
131 static struct spi_board_info board_spi_devices[] = {
132 };
133
134 /***********************************************************
135 *       rk30  backlight
136 ************************************************************/
137 #ifdef CONFIG_BACKLIGHT_RK29_BL
138 #define PWM_ID            2
139 #define PWM_MODE          PWM2
140 #define PWM_EFFECT_VALUE  1
141
142 #define LCD_DISP_ON_PIN
143
144 #ifdef  LCD_DISP_ON_PIN
145 #define BL_EN_PIN         RK30_PIN0_PA2
146 #define BL_EN_VALUE       GPIO_HIGH
147 #endif
148 static int rk29_backlight_io_init(void)
149 {
150         int ret = 0;
151
152         iomux_set(PWM_MODE);
153 #ifdef  LCD_DISP_ON_PIN
154         ret = gpio_request(BL_EN_PIN, "bl_en");
155         if (ret == 0) {
156                 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
157         }
158 #endif
159         return ret;
160 }
161
162 static int rk29_backlight_io_deinit(void)
163 {
164         int ret = 0, pwm_gpio;
165 #ifdef  LCD_DISP_ON_PIN
166         gpio_free(BL_EN_PIN);
167 #endif
168         pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
169         gpio_request(pwm_gpio, "bl_pwm");
170         gpio_direction_output(pwm_gpio, GPIO_LOW);
171         return ret;
172 }
173
174 static int rk29_backlight_pwm_suspend(void)
175 {
176         int ret, pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
177
178         ret = gpio_request(pwm_gpio, "bl_pwm");
179         if (ret) {
180                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
181                 return ret;
182         }
183         gpio_direction_output(pwm_gpio, GPIO_LOW);
184 #ifdef  LCD_DISP_ON_PIN
185         gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
186 #endif
187         return ret;
188 }
189
190 static int rk29_backlight_pwm_resume(void)
191 {
192         int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
193
194         gpio_free(pwm_gpio);
195         iomux_set(PWM_MODE);
196 #ifdef  LCD_DISP_ON_PIN
197         msleep(30);
198         gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
199 #endif
200         return 0;
201 }
202
203 static struct rk29_bl_info rk29_bl_info = {
204         .pwm_id = PWM_ID,
205         .bl_ref = PWM_EFFECT_VALUE,
206         .io_init = rk29_backlight_io_init,
207         .io_deinit = rk29_backlight_io_deinit,
208         .pwm_suspend = rk29_backlight_pwm_suspend,
209         .pwm_resume = rk29_backlight_pwm_resume,
210 };
211
212 static struct platform_device rk29_device_backlight = {
213         .name   = "rk29_backlight",
214         .id     = -1,
215         .dev    = {
216                 .platform_data  = &rk29_bl_info,
217         }
218 };
219
220 #endif
221
222 #ifdef CONFIG_RK29_SUPPORT_MODEM
223
224 #define RK30_MODEM_POWER        RK30_PIN2_PB0
225 #define RK30_MODEM_POWER_IOMUX  rk29_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0)
226
227 static int rk30_modem_io_init(void)
228 {
229     printk("%s\n", __FUNCTION__);
230     RK30_MODEM_POWER_IOMUX;
231
232         return 0;
233 }
234
235 static struct rk29_io_t rk30_modem_io = {
236     .io_addr    = RK30_MODEM_POWER,
237     .enable     = GPIO_HIGH,
238     .disable    = GPIO_LOW,
239     .io_init    = rk30_modem_io_init,
240 };
241
242 static struct platform_device rk30_device_modem = {
243         .name   = "rk30_modem",
244         .id     = -1,
245         .dev    = {
246                 .platform_data  = &rk30_modem_io,
247         }
248 };
249 #endif
250 #if defined(CONFIG_MU509)
251 static int mu509_io_init(void)
252 {
253
254         rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
255        rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
256         rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
257         rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
258         return 0;
259 }
260
261 static int mu509_io_deinit(void)
262 {
263         
264         return 0;
265 }
266  
267 struct rk29_mu509_data rk29_mu509_info = {
268         .io_init = mu509_io_init,
269         .io_deinit = mu509_io_deinit,
270         .modem_power_en = RK30_PIN2_PB0,
271         .bp_power = RK30_PIN2_PB0,
272         .bp_reset = RK30_PIN2_PD1,
273         .ap_wakeup_bp = RK30_PIN2_PB7,
274         .bp_wakeup_ap = RK30_PIN6_PA0, 
275 };
276 struct platform_device rk29_device_mu509 = {    
277         .name = "mu509",        
278         .id = -1,       
279         .dev            = {
280                 .platform_data = &rk29_mu509_info,
281         }       
282     };
283 #endif
284 #if defined(CONFIG_MW100)
285 static int mw100_io_init(void)
286 {
287          rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
288          rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
289          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
290          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
291         return 0;
292 }
293
294 static int mw100_io_deinit(void)
295 {
296         
297         return 0;
298 }
299  
300 struct rk29_mw100_data rk29_mw100_info = {
301         .io_init = mw100_io_init,
302         .io_deinit = mw100_io_deinit,
303         .modem_power_en = RK30_PIN6_PB0,
304         .bp_power = RK30_PIN2_PB0,
305         .bp_reset = RK30_PIN2_PD1,
306         .ap_wakeup_bp = RK30_PIN2_PB7,
307         .bp_wakeup_ap = RK30_PIN6_PA0,
308 };
309 struct platform_device rk29_device_mw100 = {    
310         .name = "mw100",        
311         .id = -1,       
312         .dev            = {
313                 .platform_data = &rk29_mw100_info,
314         }       
315     };
316 #endif
317 #if defined(CONFIG_MT6229)
318 static int mt6229_io_init(void)
319 {
320          rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
321          rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
322          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
323          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
324         return 0;
325 }
326
327 static int mt6229_io_deinit(void)
328 {
329         
330         return 0;
331 }
332  
333 struct rk29_mt6229_data rk29_mt6229_info = {
334         .io_init = mt6229_io_init,
335         .io_deinit = mt6229_io_deinit,
336         .modem_power_en = RK30_PIN2_PB0,
337         .bp_power = RK30_PIN2_PB0,//RK30_PIN2_PB6,
338         .bp_reset = RK30_PIN2_PD1,
339         .ap_wakeup_bp = RK30_PIN2_PC0,
340         .bp_wakeup_ap = RK30_PIN6_PA0,
341 };
342 struct platform_device rk29_device_mt6229 = {   
343         .name = "mt6229",       
344         .id = -1,       
345         .dev            = {
346                 .platform_data = &rk29_mt6229_info,
347         }       
348     };
349 #endif
350
351 /*MMA8452 gsensor*/
352 #if defined (CONFIG_GS_MMA8452)
353 #define MMA8452_INT_PIN   RK30_PIN3_PD7
354
355 static int mma8452_init_platform_hw(void)
356 {
357         return 0;
358 }
359
360 static struct sensor_platform_data mma8452_info = {
361         .type = SENSOR_TYPE_ACCEL,
362         .irq_enable = 1,
363         .poll_delay_ms = 30,
364         .init_platform_hw = mma8452_init_platform_hw,
365         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
366 };
367 #endif
368 #if defined (CONFIG_GS_LIS3DH)
369 #define LIS3DH_INT_PIN   RK30_PIN3_PD7
370
371 static int lis3dh_init_platform_hw(void)
372 {
373
374         return 0;
375 }
376
377 static struct sensor_platform_data lis3dh_info = {
378         .type = SENSOR_TYPE_ACCEL,
379         .irq_enable = 1,
380         .poll_delay_ms = 30,
381         .init_platform_hw = lis3dh_init_platform_hw,
382         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
383 };
384 #endif
385 #if defined (CONFIG_COMPASS_AK8975)
386 static struct sensor_platform_data akm8975_info =
387 {
388         .type = SENSOR_TYPE_COMPASS,
389         .irq_enable = 1,
390         .poll_delay_ms = 30,
391         .m_layout = 
392         {
393                 {
394                         {1, 0, 0},
395                         {0, 1, 0},
396                         {0, 0, 1},
397                 },
398
399                 {
400                         {1, 0, 0},
401                         {0, 1, 0},
402                         {0, 0, 1},
403                 },
404
405                 {
406                         {1, 0, 0},
407                         {0, 1, 0},
408                         {0, 0, 1},
409                 },
410
411                 {
412                         {1, 0, 0},
413                         {0, 1, 0},
414                         {0, 0, 1},
415                 },
416         }
417 };
418
419 #endif
420
421 #if defined(CONFIG_GYRO_L3G4200D)
422
423 #include <linux/l3g4200d.h>
424 #define L3G4200D_INT_PIN  RK30_PIN0_PB4
425
426 static int l3g4200d_init_platform_hw(void)
427 {
428         return 0;
429 }
430
431 static struct sensor_platform_data l3g4200d_info = {
432         .type = SENSOR_TYPE_GYROSCOPE,
433         .irq_enable = 1,
434         .poll_delay_ms = 30,
435         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
436         .init_platform_hw = l3g4200d_init_platform_hw,
437         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
438         .y_min = 40,
439         .z_min = 20,
440 };
441
442 #endif
443
444 #ifdef CONFIG_LS_CM3217
445 static struct sensor_platform_data cm3217_info = {
446         .type = SENSOR_TYPE_LIGHT,
447         .irq_enable = 0,
448         .poll_delay_ms = 500,
449 };
450
451 #endif
452
453 #ifdef CONFIG_FB_ROCKCHIP
454
455 #define LCD_CS_PIN         INVALID_GPIO
456 #define LCD_CS_VALUE       GPIO_HIGH
457
458 #define LCD_EN_PIN         RK30_PIN0_PB0
459 #define LCD_EN_VALUE       GPIO_HIGH
460
461 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
462 {
463         int ret = 0;
464
465         if(LCD_CS_PIN !=INVALID_GPIO)
466         {
467                 ret = gpio_request(LCD_CS_PIN, NULL);
468                 if (ret != 0)
469                 {
470                         gpio_free(LCD_CS_PIN);
471                         printk(KERN_ERR "request lcd cs pin fail!\n");
472                         return -1;
473                 }
474                 else
475                 {
476                         gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
477                 }
478         }
479
480         if(LCD_EN_PIN !=INVALID_GPIO)
481         {
482                 ret = gpio_request(LCD_EN_PIN, NULL);
483                 if (ret != 0)
484                 {
485                         gpio_free(LCD_EN_PIN);
486                         printk(KERN_ERR "request lcd en pin fail!\n");
487                         return -1;
488                 }
489                 else
490                 {
491                         gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
492                 }
493         }
494         return 0;
495 }
496 static int rk_fb_io_disable(void)
497 {
498         if(LCD_CS_PIN !=INVALID_GPIO)
499         {
500                 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
501         }
502         if(LCD_EN_PIN !=INVALID_GPIO)
503         {
504                 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
505         }
506         return 0;
507 }
508 static int rk_fb_io_enable(void)
509 {
510         if(LCD_CS_PIN !=INVALID_GPIO)
511         {
512                 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
513         }
514         if(LCD_EN_PIN !=INVALID_GPIO)
515         {
516                 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
517         }
518         return 0;
519 }
520
521 #if defined(CONFIG_LCDC0_RK3066B)
522 struct rk29fb_info lcdc0_screen_info = {
523         .prop      = PRMRY,             //primary display device
524         .io_init   = rk_fb_io_init,
525         .io_disable = rk_fb_io_disable,
526         .io_enable = rk_fb_io_enable,
527         .set_screen_info = set_lcd_info,
528 };
529 #endif
530
531 #if defined(CONFIG_LCDC1_RK3066B)
532 struct rk29fb_info lcdc1_screen_info = {
533         #if defined(CONFIG_RK_HDMI)
534         .prop           = EXTEND,       //extend display device
535         .lcd_info  = NULL,
536         .set_screen_info = hdmi_init_lcdc,
537         #endif
538 };
539 #endif
540
541 static struct resource resource_fb[] = {
542         [0] = {
543                 .name  = "fb0 buf",
544                 .start = 0,
545                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
546                 .flags = IORESOURCE_MEM,
547         },
548         [1] = {
549                 .name  = "ipp buf",  //for rotate
550                 .start = 0,
551                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
552                 .flags = IORESOURCE_MEM,
553         },
554         [2] = {
555                 .name  = "fb2 buf",
556                 .start = 0,
557                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
558                 .flags = IORESOURCE_MEM,
559         },
560 };
561
562 static struct platform_device device_fb = {
563         .name           = "rk-fb",
564         .id             = -1,
565         .num_resources  = ARRAY_SIZE(resource_fb),
566         .resource       = resource_fb,
567 };
568 #endif
569
570 #if defined(CONFIG_LCDC0_RK3066B)
571 static struct resource resource_lcdc0[] = {
572         [0] = {
573                 .name  = "lcdc0 reg",
574                 .start = RK30_LCDC0_PHYS,
575                 .end   = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
576                 .flags = IORESOURCE_MEM,
577         },
578         
579         [1] = {
580                 .name  = "lcdc0 irq",
581                 .start = IRQ_LCDC0,
582                 .end   = IRQ_LCDC0,
583                 .flags = IORESOURCE_IRQ,
584         },
585 };
586
587 static struct platform_device device_lcdc0 = {
588         .name             = "rk30-lcdc",
589         .id               = 0,
590         .num_resources    = ARRAY_SIZE(resource_lcdc0),
591         .resource         = resource_lcdc0,
592         .dev            = {
593                 .platform_data = &lcdc0_screen_info,
594         },
595 };
596 #endif
597 #if defined(CONFIG_LCDC1_RK3066B) 
598 static struct resource resource_lcdc1[] = {
599         [0] = {
600                 .name  = "lcdc1 reg",
601                 .start = RK30_LCDC1_PHYS,
602                 .end   = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
603                 .flags = IORESOURCE_MEM,
604         },
605         [1] = {
606                 .name  = "lcdc1 irq",
607                 .start = IRQ_LCDC1,
608                 .end   = IRQ_LCDC1,
609                 .flags = IORESOURCE_IRQ,
610         },
611 };
612
613 static struct platform_device device_lcdc1 = {
614         .name             = "rk30-lcdc",
615         .id               = 1,
616         .num_resources    = ARRAY_SIZE(resource_lcdc1),
617         .resource         = resource_lcdc1,
618         .dev            = {
619                 .platform_data = &lcdc1_screen_info,
620         },
621 };
622 #endif
623
624 #if defined(CONFIG_MFD_RK610)
625 #if 1
626 #define RK610_RST_PIN_MUX_NAME          GPIO2C5_LCDC1DATA21_SMCADDR5_NAME 
627 #define RK610_RST_PIN_MUX_MODE          GPIO2C_GPIO2C5
628 #define RK610_RST_PIN                   RK30_PIN2_PC5
629 #else
630 #define RK610_RST_PIN_MUX_NAME          GPIO2D6_SMCCSN1_NAME 
631 #define RK610_RST_PIN_MUX_MODE          GPIO2D_GPIO2D6
632 #define RK610_RST_PIN                   RK30_PIN2_PD6
633
634 #endif
635 static int rk610_power_on_init(void)
636 {
637         int ret;
638         if(RK610_RST_PIN != INVALID_GPIO)
639         {
640                 rk30_mux_api_set(RK610_RST_PIN_MUX_NAME,RK610_RST_PIN_MUX_MODE);
641                 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
642                 if (ret)
643                 {
644                         printk(KERN_ERR "rk610_control_probe request gpio fail\n");
645                 }
646                 else 
647                 {
648                         gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
649                         msleep(100);
650                         gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
651                         msleep(100);
652                         gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
653                 }
654         }
655
656         return 0;
657         
658 }
659
660
661 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
662         .rk610_power_on_init = rk610_power_on_init,
663 };
664 #endif
665
666 #ifdef CONFIG_SND_SOC_RK610
667 static int rk610_codec_io_init(void)
668 {
669 //if need iomux.
670 //Must not gpio_request
671         return 0;
672 }
673
674 static struct rk610_codec_platform_data rk610_codec_pdata = {
675         .spk_ctl_io = RK30_PIN4_PC6,
676         .io_init = rk610_codec_io_init,
677 };
678 #endif
679
680 #ifdef CONFIG_ANDROID_TIMED_GPIO
681 static struct timed_gpio timed_gpios[] = {
682         {
683                 .name = "vibrator",
684                 .gpio = RK30_PIN3_PD3,
685                 .max_timeout = 1000,
686                 .active_low = 0,
687                 .adjust_time =20,      //adjust for diff product
688         },
689 };
690
691 static struct timed_gpio_platform_data rk29_vibrator_info = {
692         .num_gpios = 1,
693         .gpios = timed_gpios,
694 };
695
696 static struct platform_device rk29_device_vibrator = {
697         .name = "timed-gpio",
698         .id = -1,
699         .dev = {
700                 .platform_data = &rk29_vibrator_info,
701         },
702
703 };
704 #endif
705
706 #ifdef CONFIG_LEDS_GPIO_PLATFORM
707 static struct gpio_led rk29_leds[] = {
708         {
709                 .name = "button-backlight",
710                 .gpio = RK30_PIN2_PB3,
711                 .default_trigger = "timer",
712                 .active_low = 0,
713                 .retain_state_suspended = 0,
714                 .default_state = LEDS_GPIO_DEFSTATE_OFF,
715         },
716 };
717
718 static struct gpio_led_platform_data rk29_leds_pdata = {
719         .leds = rk29_leds,
720         .num_leds = ARRAY_SIZE(rk29_leds),
721 };
722
723 static struct platform_device rk29_device_gpio_leds = {
724         .name   = "leds-gpio",
725         .id     = -1,
726         .dev    = {
727                 .platform_data  = &rk29_leds_pdata,
728         },
729 };
730 #endif
731
732 #ifdef CONFIG_RK_IRDA
733 #define IRDA_IRQ_PIN           RK30_PIN0_PA3
734
735 static int irda_iomux_init(void)
736 {
737         int ret = 0;
738
739         //irda irq pin
740         ret = gpio_request(IRDA_IRQ_PIN, NULL);
741         if (ret != 0) {
742                 gpio_free(IRDA_IRQ_PIN);
743                 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
744         }
745         gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
746         gpio_direction_input(IRDA_IRQ_PIN);
747
748         return 0;
749 }
750
751 static int irda_iomux_deinit(void)
752 {
753         gpio_free(IRDA_IRQ_PIN);
754         return 0;
755 }
756
757 static struct irda_info rk29_irda_info = {
758         .intr_pin = IRDA_IRQ_PIN,
759         .iomux_init = irda_iomux_init,
760         .iomux_deinit = irda_iomux_deinit,
761         //.irda_pwr_ctl = bu92747guw_power_ctl,
762 };
763
764 static struct platform_device irda_device = {
765 #ifdef CONFIG_RK_IRDA_NET
766         .name = "rk_irda",
767 #else
768         .name = "bu92747_irda",
769 #endif
770         .id = -1,
771         .dev = {
772                 .platform_data = &rk29_irda_info,
773         }
774 };
775 #endif
776
777 #ifdef CONFIG_ION
778 #define ION_RESERVE_SIZE        (80 * SZ_1M)
779 static struct ion_platform_data rk30_ion_pdata = {
780         .nr = 1,
781         .heaps = {
782                 {
783                         .type = ION_HEAP_TYPE_CARVEOUT,
784                         .id = ION_NOR_HEAP_ID,
785                         .name = "norheap",
786                         .size = ION_RESERVE_SIZE,
787                 }
788         },
789 };
790
791 static struct platform_device device_ion = {
792         .name = "ion-rockchip",
793         .id = 0,
794         .dev = {
795                 .platform_data = &rk30_ion_pdata,
796         },
797 };
798 #endif
799
800 /**************************************************************************************************
801  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
802 **************************************************************************************************/
803 #ifdef CONFIG_SDMMC_RK29
804 #include "board-rk30-sdk-sdmmc.c"
805
806 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
807 #define SDMMC0_WRITE_PROTECT_PIN        RK30_PIN3_PB7   //According to your own project to set the value of write-protect-pin.
808 #endif
809
810 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
811 #define SDMMC1_WRITE_PROTECT_PIN        RK30_PIN3_PC7   //According to your own project to set the value of write-protect-pin.
812 #endif
813
814 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK30_PIN6_PB2
815
816 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
817
818 #ifdef CONFIG_SDMMC0_RK29
819 static int rk29_sdmmc0_cfg_gpio(void)
820 {
821 #ifdef CONFIG_SDMMC_RK29_OLD
822         rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
823         rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
824         rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
825         rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
826         rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
827         rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
828
829         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
830
831         rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
832         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
833         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
834
835 #else
836         rk29_sdmmc_set_iomux(0, 0xFFFF);
837
838     #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
839         iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
840     #else
841         iomux_set(MMC0_DETN);
842     #endif      
843
844 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
845         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
846         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
847 #endif
848
849 #endif
850
851         return 0;
852 }
853
854 #define CONFIG_SDMMC0_USE_DMA
855 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
856         .host_ocr_avail =
857             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
858              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
859              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
860         .host_caps =
861             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
862         .io_init = rk29_sdmmc0_cfg_gpio,
863
864 #if !defined(CONFIG_SDMMC_RK29_OLD)
865         .set_iomux = rk29_sdmmc_set_iomux,
866 #endif
867
868         .dma_name = "sd_mmc",
869 #ifdef CONFIG_SDMMC0_USE_DMA
870         .use_dma = 1,
871 #else
872         .use_dma = 0,
873 #endif
874         .detect_irq = RK30_PIN3_PB6,    // INVALID_GPIO
875         .enable_sd_wakeup = 0,
876
877 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
878         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
879 #else
880         .write_prt = INVALID_GPIO,
881 #endif
882 };
883 #endif // CONFIG_SDMMC0_RK29
884
885 #ifdef CONFIG_SDMMC1_RK29
886 #define CONFIG_SDMMC1_USE_DMA
887 static int rk29_sdmmc1_cfg_gpio(void)
888 {
889 #if defined(CONFIG_SDMMC_RK29_OLD)
890         rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
891         rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
892         rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
893         rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
894         rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
895         rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
896         //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
897
898 #else
899
900 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
901         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
902         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
903 #endif
904
905 #endif
906
907         return 0;
908 }
909
910 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
911         .host_ocr_avail =
912             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
913              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
914              MMC_VDD_33_34),
915
916 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
917         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
918                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
919 #else
920         .host_caps =
921             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
922 #endif
923
924         .io_init = rk29_sdmmc1_cfg_gpio,
925
926 #if !defined(CONFIG_SDMMC_RK29_OLD)
927         .set_iomux = rk29_sdmmc_set_iomux,
928 #endif
929
930         .dma_name = "sdio",
931 #ifdef CONFIG_SDMMC1_USE_DMA
932         .use_dma = 1,
933 #else
934         .use_dma = 0,
935 #endif
936
937 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
938 #ifdef CONFIG_WIFI_CONTROL_FUNC
939         .status = rk29sdk_wifi_status,
940         .register_status_notify = rk29sdk_wifi_status_register,
941 #endif
942 #if 0
943         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
944 #endif
945
946 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
947         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
948 #else
949         .write_prt = INVALID_GPIO,
950 #endif
951
952 #else
953         .detect_irq = INVALID_GPIO,
954         .enable_sd_wakeup = 0,
955 #endif
956
957 };
958 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
959
960 /**************************************************************************************************
961  * the end of setting for SDMMC devices
962 **************************************************************************************************/
963
964 #ifdef CONFIG_BATTERY_RK30_ADC
965 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
966         .dc_det_pin      = RK30_PIN0_PB2,
967         .batt_low_pin    = RK30_PIN0_PB1, 
968         .charge_set_pin  = INVALID_GPIO,
969         .charge_ok_pin   = RK30_PIN0_PA6,
970         .dc_det_level    = GPIO_LOW,
971         .charge_ok_level = GPIO_HIGH,
972 };
973
974 static struct platform_device rk30_device_adc_battery = {
975         .name   = "rk30-battery",
976         .id     = -1,
977         .dev = {
978                 .platform_data = &rk30_adc_battery_platdata,
979         },
980 };
981 #endif
982 #ifdef CONFIG_RK30_PWM_REGULATOR
983 const static int pwm_voltage_map[] = {
984         950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
985 };
986
987 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
988         {
989                 .supply = "vdd_core",
990         }
991 };
992
993 struct regulator_init_data pwm_regulator_init_dcdc[1] =
994 {
995         {
996                 .constraints = {
997                         .name = "PWM_DCDC1",
998                         .min_uV = 600000,
999                         .max_uV = 1800000,      //0.6-1.8V
1000                         .apply_uV = true,
1001                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1002                 },
1003                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1004                 .consumer_supplies = pwm_dcdc1_consumers,
1005         },
1006 };
1007
1008 static struct pwm_platform_data pwm_regulator_info[1] = {
1009         {
1010                 .pwm_id = 3,
1011                 .pwm_gpio = RK30_PIN3_PD6,
1012                 .pwm_iomux_pwm = PWM3,
1013                 .pwm_iomux_gpio = GPIO3_D6,
1014                 .pwm_voltage = 1100000,
1015                 .suspend_voltage = 1050000,
1016                 .min_uV = 950000,
1017                 .max_uV = 1400000,
1018                 .coefficient = 455,     //45.5%
1019                 .pwm_voltage_map = pwm_voltage_map,
1020                 .init_data      = &pwm_regulator_init_dcdc[0],
1021         },
1022 };
1023
1024 struct platform_device pwm_regulator_device[1] = {
1025         {
1026                 .name = "pwm-voltage-regulator",
1027                 .id = 0,
1028                 .dev            = {
1029                         .platform_data = &pwm_regulator_info[0],
1030                 }
1031         },
1032 };
1033 #endif
1034
1035 #ifdef CONFIG_RK29_VMAC
1036 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1037 #include "board-rk30-sdk-vmac.c"
1038 #endif
1039
1040 #ifdef CONFIG_RFKILL_RK
1041 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1042 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1043     .type               = RFKILL_TYPE_BLUETOOTH,
1044
1045     .poweron_gpio       = { // BT_REG_ON
1046         .io             = INVALID_GPIO, //RK30_PIN3_PC7,
1047         .enable         = GPIO_HIGH,
1048         .iomux          = {
1049             .name       = "bt_poweron",
1050             .fgpio      = GPIO3_C7,
1051         },
1052     },
1053
1054     .reset_gpio         = { // BT_RST
1055         .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1056         .enable         = GPIO_LOW,
1057         .iomux          = {
1058             .name       = "bt_reset",
1059             .fgpio      = GPIO3_D1,
1060        },
1061    }, 
1062
1063     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
1064         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1065         .enable         = GPIO_HIGH,
1066         .iomux          = {
1067             .name       = "bt_wake",
1068             .fgpio      = GPIO3_C6,
1069         },
1070     },
1071
1072     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1073         .gpio           = {
1074             .io         = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1075             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
1076             .iomux      = {
1077                 .name   = NULL,
1078             },
1079         },
1080     },
1081
1082     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
1083         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1084         .enable         = GPIO_LOW,
1085         .iomux          = {
1086             .name       = "bt_rts",
1087             .fgpio      = GPIO1_A3,
1088             .fmux       = UART0_RTSN,
1089         },
1090     },
1091 };
1092
1093 static struct platform_device device_rfkill_rk = {
1094     .name   = "rfkill_rk",
1095     .id     = -1,
1096     .dev    = {
1097         .platform_data = &rfkill_rk_platdata,
1098     },
1099 };
1100 #endif
1101
1102 #if defined(CONFIG_GPS_RK)
1103 int rk_gps_io_init(void)
1104 {
1105         printk("%s \n", __FUNCTION__);
1106         
1107         rk30_mux_api_set(GPIO1B5_UART3RTSN_NAME, GPIO1B_GPIO1B5);//VCC_EN
1108         gpio_request(RK30_PIN1_PB5, NULL);
1109         gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1110
1111         rk30_mux_api_set(GPIO1B4_UART3CTSN_GPSRFCLK_NAME, GPIO1B_GPSRFCLK);//GPS_CLK
1112         rk30_mux_api_set(GPIO1B2_UART3SIN_GPSMAG_NAME, GPIO1B_GPSMAG);//GPS_MAG
1113         rk30_mux_api_set(GPIO1B3_UART3SOUT_GPSSIG_NAME, GPIO1B_GPSSIG);//GPS_SIGN
1114
1115         rk30_mux_api_set(GPIO1A6_UART1CTSN_SPI0CLK_NAME, GPIO1A_GPIO1A6);//SPI_CLK
1116         gpio_request(RK30_PIN1_PA6, NULL);
1117         gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1118
1119         rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0TXD_NAME, GPIO1A_GPIO1A5);//SPI_MOSI
1120         gpio_request(RK30_PIN1_PA5, NULL);
1121         gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW); 
1122
1123         rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0CSN0_NAME, GPIO1A_GPIO1A7);//SPI_CS
1124         gpio_request(RK30_PIN1_PA7, NULL);
1125         gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);         
1126         return 0;
1127 }
1128 int rk_gps_power_up(void)
1129 {
1130         printk("%s \n", __FUNCTION__);
1131
1132         return 0;
1133 }
1134
1135 int rk_gps_power_down(void)
1136 {
1137         printk("%s \n", __FUNCTION__);
1138
1139         return 0;
1140 }
1141
1142 int rk_gps_reset_set(int level)
1143 {
1144         return 0;
1145 }
1146 int rk_enable_hclk_gps(void)
1147 {
1148         printk("%s \n", __FUNCTION__);
1149         clk_enable(clk_get(NULL, "hclk_gps"));
1150         return 0;
1151 }
1152 int rk_disable_hclk_gps(void)
1153 {
1154         printk("%s \n", __FUNCTION__);
1155         clk_disable(clk_get(NULL, "hclk_gps"));
1156         return 0;
1157 }
1158 struct rk_gps_data rk_gps_info = {
1159         .io_init = rk_gps_io_init,
1160         .power_up = rk_gps_power_up,
1161         .power_down = rk_gps_power_down,
1162         .reset = rk_gps_reset_set,
1163         .enable_hclk_gps = rk_enable_hclk_gps,
1164         .disable_hclk_gps = rk_disable_hclk_gps,
1165         .GpsSign = RK30_PIN1_PB3,
1166         .GpsMag = RK30_PIN1_PB2,        //GPIO index
1167         .GpsClk = RK30_PIN1_PB4,        //GPIO index
1168         .GpsVCCEn = RK30_PIN1_PB5,     //GPIO index
1169         .GpsSpi_CSO = RK30_PIN1_PA4,    //GPIO index
1170         .GpsSpiClk = RK30_PIN1_PA5,     //GPIO index
1171         .GpsSpiMOSI = RK30_PIN1_PA7,      //GPIO index
1172         .GpsIrq = IRQ_GPS,
1173         .GpsSpiEn = 0,
1174         .GpsAdcCh = 2,
1175         .u32GpsPhyAddr = RK30_GPS_PHYS,
1176         .u32GpsPhySize = RK30_GPS_SIZE,
1177 };
1178
1179 struct platform_device rk_device_gps = {
1180         .name = "gps_hv5820b",
1181         .id = -1,
1182         .dev            = {
1183         .platform_data = &rk_gps_info,
1184                 }
1185         };
1186 #endif
1187
1188
1189 static struct platform_device *devices[] __initdata = {
1190 #ifdef CONFIG_FB_ROCKCHIP
1191         &device_fb,
1192 #endif
1193 #if defined(CONFIG_LCDC0_RK3066B)
1194         &device_lcdc0,
1195 #endif
1196 #if defined(CONFIG_LCDC1_RK3066B)
1197         &device_lcdc1,
1198 #endif
1199
1200 #ifdef CONFIG_BACKLIGHT_RK29_BL
1201         &rk29_device_backlight,
1202 #endif
1203
1204 #ifdef CONFIG_ION
1205         &device_ion,
1206 #endif
1207 #ifdef CONFIG_ANDROID_TIMED_GPIO
1208         &rk29_device_vibrator,
1209 #endif
1210 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1211         &rk29_device_gpio_leds,
1212 #endif
1213 #ifdef CONFIG_RK_IRDA
1214         &irda_device,
1215 #endif
1216 #ifdef CONFIG_WIFI_CONTROL_FUNC
1217         &rk29sdk_wifi_device,
1218 #endif
1219 #ifdef CONFIG_RK29_SUPPORT_MODEM
1220         &rk30_device_modem,
1221 #endif
1222 #if defined(CONFIG_MU509)
1223         &rk29_device_mu509,
1224 #endif
1225 #if defined(CONFIG_MW100)
1226         &rk29_device_mw100,
1227 #endif
1228 #if defined(CONFIG_MT6229)
1229         &rk29_device_mt6229,
1230 #endif
1231 #ifdef CONFIG_BATTERY_RK30_ADC
1232         &rk30_device_adc_battery,
1233 #endif
1234 #ifdef CONFIG_RFKILL_RK
1235         &device_rfkill_rk,
1236 #endif
1237 #ifdef CONFIG_GPS_RK
1238         &rk_device_gps,
1239 #endif
1240
1241 };
1242
1243 // i2c
1244 #ifdef CONFIG_I2C0_RK30
1245 static struct i2c_board_info __initdata i2c0_info[] = {
1246 #if defined (CONFIG_GS_MMA8452)
1247         {
1248                 .type           = "gs_mma8452",
1249                 .addr           = 0x1d,
1250                 .flags          = 0,
1251                 .irq            = MMA8452_INT_PIN,
1252                 .platform_data = &mma8452_info,
1253         },
1254 #endif
1255 #if defined (CONFIG_GS_LIS3DH)
1256         {
1257                 .type           = "gs_lis3dh",
1258                 .addr           = 0x19,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
1259                 .flags          = 0,
1260                 .irq            = LIS3DH_INT_PIN,
1261                 .platform_data = &lis3dh_info,
1262         },
1263 #endif
1264 #if defined (CONFIG_COMPASS_AK8975)
1265         {
1266                 .type          = "ak8975",
1267                 .addr          = 0x0d,
1268                 .flags         = 0,
1269                 .irq           = RK30_PIN0_PD5,
1270                 .platform_data = &akm8975_info,
1271         },
1272 #endif
1273 #if defined (CONFIG_GYRO_L3G4200D)
1274         {
1275                 .type          = "l3g4200d_gryo",
1276                 .addr          = 0x69,
1277                 .flags         = 0,
1278                 .irq           = L3G4200D_INT_PIN,
1279                 .platform_data = &l3g4200d_info,
1280         },
1281 #endif
1282 #if defined (CONFIG_SND_SOC_RK1000)
1283         {
1284                 .type          = "rk1000_i2c_codec",
1285                 .addr          = 0x60,
1286                 .flags         = 0,
1287         },
1288         {
1289                 .type          = "rk1000_control",
1290                 .addr          = 0x40,
1291                 .flags         = 0,
1292         },
1293 #endif
1294 #if defined (CONFIG_SND_SOC_RT5631)
1295         {
1296                 .type                   = "rt5631",
1297                 .addr                   = 0x1a,
1298                 .flags                  = 0,
1299         },
1300 #endif
1301
1302 #ifdef CONFIG_MFD_RK610
1303                 {
1304                         .type                   = "rk610_ctl",
1305                         .addr                   = 0x40,
1306                         .flags                  = 0,
1307                         .platform_data          = &rk610_ctl_pdata,
1308                 },
1309 #ifdef CONFIG_RK610_TVOUT
1310                 {
1311                         .type                   = "rk610_tvout",
1312                         .addr                   = 0x42,
1313                         .flags                  = 0,
1314                 },
1315 #endif
1316 #ifdef CONFIG_HDMI_RK610
1317                 {
1318                         .type                   = "rk610_hdmi",
1319                         .addr                   = 0x46,
1320                         .flags                  = 0,
1321                         .irq                    = INVALID_GPIO,
1322                 },
1323 #endif
1324 #ifdef CONFIG_SND_SOC_RK610
1325                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1326                         .type                   = "rk610_i2c_codec",
1327                         .addr                   = 0x60,
1328                         .flags                  = 0,
1329                         .platform_data          = &rk610_codec_pdata,                           
1330                 },
1331 #endif
1332 #endif
1333
1334 };
1335 #endif
1336
1337 int __sramdata g_pmic_type =  0;
1338 #ifdef CONFIG_I2C1_RK30
1339 #ifdef CONFIG_MFD_WM831X_I2C
1340 #define PMU_POWER_SLEEP                 RK30_PIN0_PA1 
1341
1342 static struct pmu_info  wm8326_dcdc_info[] = {
1343         {
1344                 .name          = "vdd_core",   //logic
1345                 .min_uv          = 1000000,
1346                 .max_uv         = 1000000,
1347                 .suspend_vol  =  950000,
1348         },
1349         {
1350                 .name          = "vdd_cpu",    //arm
1351                 .min_uv          = 1000000,
1352                 .max_uv         = 1000000,
1353                 .suspend_vol  =  950000,
1354         },
1355         {
1356                 .name          = "dcdc3",   //ddr
1357                 .min_uv          = 1150000,
1358                 .max_uv         = 1150000,
1359                 .suspend_vol  =  1150000,
1360         },
1361         #ifdef CONFIG_MACH_RK3066_SDK
1362         {
1363                 .name          = "dcdc4",   //vcc_io
1364                 .min_uv          = 3300000,
1365                 .max_uv         = 3300000,
1366                 .suspend_vol  =  3000000,
1367         },
1368         #else
1369         {
1370                 .name          = "dcdc4",   //vcc_io
1371                 .min_uv          = 3000000,
1372                 .max_uv         = 3000000,
1373                 .suspend_vol  =  2800000,
1374         },
1375         #endif
1376 };
1377
1378 static struct pmu_info  wm8326_ldo_info[] = {
1379         {
1380                 .name          = "ldo1",   //vcc18_cif
1381                 .min_uv          = 1800000,
1382                 .max_uv         = 1800000,
1383                 .suspend_vol  =  1800000,
1384         },
1385         {
1386                 .name          = "ldo2",    //vccio_wl
1387                 .min_uv          = 1800000,
1388                 .max_uv         = 1800000,
1389                 .suspend_vol  =  1800000,
1390         },
1391         {
1392                 .name          = "ldo3",   //
1393                 .min_uv          = 1100000,
1394                 .max_uv         = 1100000,
1395                 .suspend_vol  =  1100000,
1396         },
1397         {
1398                 .name          = "ldo4",   //vdd11
1399                 .min_uv          = 1000000,
1400                 .max_uv         = 1000000,
1401                 .suspend_vol  =  1000000,
1402         },
1403         {
1404                 .name          = "ldo5",   //vcc25
1405                 .min_uv          = 1800000,
1406                 .max_uv         = 1800000,
1407                 .suspend_vol  =  1800000,
1408         },
1409         {
1410                 .name          = "ldo6",   //vcc33
1411                 .min_uv          = 3300000,
1412                 .max_uv         = 3300000,
1413                 .suspend_vol  =  3300000,
1414         },
1415         {
1416                 .name          = "ldo7",   //vcc28_cif
1417                 .min_uv          = 2800000,
1418                 .max_uv         = 2800000,
1419                 .suspend_vol  =  2800000,
1420         },
1421         {
1422                 .name          = "ldo8",   //vcca33
1423                 .min_uv          = 3300000,
1424                 .max_uv         = 3300000,
1425                 .suspend_vol  =  3300000,
1426         },
1427         {
1428                 .name          = "ldo9",   //vcc_tp
1429                 .min_uv          = 3300000,
1430                 .max_uv         = 3300000,
1431                 .suspend_vol  =  3300000,
1432         },
1433         {
1434                 .name          = "ldo10",   //flash_io
1435                 .min_uv          = 1800000,
1436                 .max_uv         = 1800000,
1437                 .suspend_vol  =  1800000,
1438         },
1439 };
1440
1441 #include "board-pmu-wm8326.c"
1442 #endif
1443
1444 #ifdef CONFIG_MFD_TPS65910
1445 #ifdef CONFIG_ARCH_RK3066B
1446 #define TPS65910_HOST_IRQ        RK30_PIN0_PB3
1447 #else
1448 #define TPS65910_HOST_IRQ        RK30_PIN6_PA4
1449 #endif
1450
1451 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1452
1453 static struct pmu_info  tps65910_dcdc_info[] = {
1454         {
1455                 .name          = "vdd_cpu",   //arm
1456                 .min_uv          = 1000000,
1457                 .max_uv         = 1000000,
1458         },
1459         {
1460                 .name          = "vdd2",    //ddr
1461                 .min_uv          = 1200000,
1462                 .max_uv         = 1200000,
1463         },
1464         {
1465                 .name          = "vio",   //vcc_io
1466                 .min_uv          = 3000000,
1467                 .max_uv         = 3000000,
1468         },
1469         
1470 };
1471 static  struct pmu_info  tps65910_ldo_info[] = {
1472         {
1473                 .name          = "vpll",   //vcc25
1474                 .min_uv          = 2500000,
1475                 .max_uv         = 2500000,
1476         },
1477         {
1478                 .name          = "vdig1",    //vcc18_cif
1479                 .min_uv          = 1800000,
1480                 .max_uv         = 1800000,
1481         },
1482         {
1483                 .name          = "vdig2",   //vdd11
1484                 .min_uv          = 1000000,
1485                 .max_uv         = 1000000,
1486         },
1487         {
1488                 .name          = "vaux1",   //vcc25_hdmi
1489                 .min_uv          = 2500000,
1490                 .max_uv         = 2500000,
1491         },
1492         {
1493                 .name          = "vaux2",   //vcca33
1494                 .min_uv          = 3300000,
1495                 .max_uv         = 3300000,
1496         },
1497         {
1498                 .name          = "vaux33",   //vcc_tp
1499                 .min_uv          = 3300000,
1500                 .max_uv         = 3300000,
1501         },
1502         {
1503                 .name          = "vmmc",   //vcc28_cif
1504                 .min_uv          = 2800000,
1505                 .max_uv         = 2800000,
1506         },
1507         {
1508                 .name          = "vdac",   //vccio_wl
1509                 .min_uv          = 1800000,
1510                 .max_uv         = 1800000,
1511         },
1512  };
1513
1514 #include "board-pmu-tps65910.c"
1515 #endif
1516
1517 static struct i2c_board_info __initdata i2c1_info[] = {
1518 #if defined (CONFIG_MFD_WM831X_I2C)
1519         {
1520                 .type          = "wm8326",
1521                 .addr          = 0x34,
1522                 .flags         = 0,
1523                 .irq           = RK30_PIN0_PB3,
1524                 .platform_data = &wm831x_platdata,
1525         },
1526 #endif
1527 #if defined (CONFIG_MFD_TPS65910)
1528         {
1529         .type           = "tps65910",
1530         .addr           = TPS65910_I2C_ID0,
1531         .flags          = 0,
1532         .irq            = TPS65910_HOST_IRQ,
1533         .platform_data = &tps65910_data,
1534         },
1535 #endif
1536 };
1537 #endif
1538
1539 void __sramfunc board_pmu_suspend(void)
1540 {      
1541         #if defined (CONFIG_MFD_WM831X_I2C)
1542        if(pmic_is_wm8326())
1543        board_pmu_wm8326_suspend();
1544         #endif
1545         #if defined (CONFIG_MFD_TPS65910)
1546        if(pmic_is_tps65910())
1547        board_pmu_tps65910_suspend(); 
1548     #endif   
1549 }
1550
1551 void __sramfunc board_pmu_resume(void)
1552 {      
1553         #if defined (CONFIG_MFD_WM831X_I2C)
1554        if(pmic_is_wm8326())
1555        board_pmu_wm8326_resume();
1556         #endif
1557         #if defined (CONFIG_MFD_TPS65910)
1558        if(pmic_is_tps65910())
1559        board_pmu_tps65910_resume(); 
1560         #endif
1561 }
1562
1563  int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1564
1565 #define grf_readl(offset)       readl_relaxed(RK30_GRF_BASE + offset)
1566 #define grf_writel(v, offset)   do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1567  
1568 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1569 {
1570 #ifdef CONFIG_RK30_PWM_REGULATOR
1571
1572 //      int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1573         sram_udelay(10000);
1574         gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1575         gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1576         gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1577         gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1578
1579         grf_writel((1<<28), GRF_GPIO3D_IOMUX);
1580         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
1581         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
1582         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
1583 #endif 
1584 }
1585 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1586 {
1587 #ifdef CONFIG_RK30_PWM_REGULATOR
1588         grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
1589         grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
1590         grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
1591         grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
1592         sram_udelay(10000);
1593
1594 #endif
1595
1596 }
1597 extern void pwm_suspend_voltage(void);
1598 extern void pwm_resume_voltage(void);
1599 void  rk30_pwm_suspend_voltage_set(void)
1600 {
1601 #ifdef CONFIG_RK30_PWM_REGULATOR
1602         pwm_suspend_voltage();
1603 #endif
1604 }
1605 void  rk30_pwm_resume_voltage_set(void)
1606 {
1607 #ifdef CONFIG_RK30_PWM_REGULATOR
1608         pwm_resume_voltage();
1609 #endif
1610 }
1611
1612
1613 #ifdef CONFIG_I2C2_RK30
1614 static struct i2c_board_info __initdata i2c2_info[] = {
1615 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1616         {
1617                 .type          = "Goodix-TS",
1618                 .addr          = 0x55,
1619                 .flags         = 0,
1620                 .irq           = RK30_PIN0_PD4,
1621                 .platform_data = &goodix_info,
1622         },
1623 #endif
1624 #if defined (CONFIG_LS_CM3217)
1625         {
1626                 .type          = "lightsensor",
1627                 .addr          = 0x10,
1628                 .flags         = 0,
1629                 .platform_data = &cm3217_info,
1630         },
1631 #endif
1632 };
1633 #endif
1634
1635 #ifdef CONFIG_I2C3_RK30
1636 static struct i2c_board_info __initdata i2c3_info[] = {
1637 };
1638 #endif
1639
1640 #ifdef CONFIG_I2C4_RK30
1641 static struct i2c_board_info __initdata i2c4_info[] = {
1642 };
1643 #endif
1644
1645 #ifdef CONFIG_I2C_GPIO_RK30
1646 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1647 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1648 static int rk30_i2c_io_init(void)
1649 {
1650         //set iomux (gpio) here
1651         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1652         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1653
1654         return 0;
1655 }
1656 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1657        .sda_pin = I2C_SDA_PIN,
1658        .scl_pin = I2C_SCL_PIN,
1659        .udelay = 5, // clk = 500/udelay = 100Khz
1660        .timeout = 100,//msecs_to_jiffies(100),
1661        .bus_num    = 5,
1662        .io_init = rk30_i2c_io_init,
1663 };
1664 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1665 };
1666 #endif
1667
1668 static void __init rk30_i2c_register_board_info(void)
1669 {
1670 #ifdef CONFIG_I2C0_RK30
1671         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1672 #endif
1673 #ifdef CONFIG_I2C1_RK30
1674         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1675 #endif
1676 #ifdef CONFIG_I2C2_RK30
1677         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1678 #endif
1679 #ifdef CONFIG_I2C3_RK30
1680         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1681 #endif
1682 #ifdef CONFIG_I2C4_RK30
1683         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1684 #endif
1685 #ifdef CONFIG_I2C_GPIO_RK30
1686         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1687 #endif
1688 }
1689 //end of i2c
1690
1691 #define POWER_ON_PIN RK30_PIN0_PA0   //power_hold
1692 static void rk30_pm_power_off(void)
1693 {
1694         printk(KERN_ERR "rk30_pm_power_off start...\n");
1695         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1696 #if defined(CONFIG_MFD_WM831X)
1697         wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
1698         wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1699 #endif
1700         while (1);
1701 }
1702
1703 static void __init machine_rk30_board_init(void)
1704 {
1705         //avs_init();
1706         gpio_request(POWER_ON_PIN, "poweronpin");
1707         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1708         
1709         pm_power_off = rk30_pm_power_off;
1710         
1711         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1712
1713         //test
1714         iomux_set(GPIO2_A2);
1715         gpio_request(RK30_PIN2_PA1, NULL);
1716         gpio_direction_output(RK30_PIN2_PA1, GPIO_HIGH);
1717
1718         rk30_i2c_register_board_info();
1719         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1720         platform_add_devices(devices, ARRAY_SIZE(devices));
1721         board_usb_detect_init(RK30_PIN0_PA7);
1722
1723 #ifdef CONFIG_WIFI_CONTROL_FUNC
1724         rk29sdk_wifi_bt_gpio_control_init();
1725 #endif
1726 }
1727
1728 static void __init rk30_reserve(void)
1729 {
1730 #ifdef CONFIG_ION
1731         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1732 #endif
1733 #ifdef CONFIG_FB_ROCKCHIP
1734         resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
1735         resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
1736         #if 0
1737         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1738         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1739         resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
1740         resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
1741         #endif
1742 #endif
1743 #ifdef CONFIG_VIDEO_RK29
1744         rk30_camera_request_reserve_mem();
1745 #endif
1746         
1747 #ifdef CONFIG_GPS_RK
1748         //it must be more than 8MB
1749         rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
1750 #endif
1751         board_mem_reserved();
1752 }
1753
1754 /**
1755  * dvfs_cpu_logic_table: table for arm and logic dvfs 
1756  * @frequency   : arm frequency
1757  * @cpu_volt    : arm voltage depend on frequency
1758  * @logic_volt  : logic voltage arm requests depend on frequency
1759  * comments     : min arm/logic voltage
1760  */
1761 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
1762         {.frequency = 312 * 1000,       .cpu_volt = 850 * 1000,         .logic_volt = 1000 * 1000},
1763         {.frequency = 504 * 1000,       .cpu_volt = 900 * 1000,         .logic_volt = 1000 * 1000},
1764         {.frequency = 816 * 1000,       .cpu_volt = 950 * 1000,         .logic_volt = 1000 * 1000},
1765         {.frequency = 1008 * 1000,      .cpu_volt = 1025 * 1000,        .logic_volt = 1000 * 1000},
1766         {.frequency = 1200 * 1000,      .cpu_volt = 1100 * 1000,        .logic_volt = 1050 * 1000},
1767         {.frequency = 1416 * 1000,      .cpu_volt = 1200 * 1000,        .logic_volt = 1150 * 1000},
1768         {.frequency = 1608 * 1000,      .cpu_volt = 1300 * 1000,        .logic_volt = 1250 * 1000},
1769         {.frequency = CPUFREQ_TABLE_END},
1770 };
1771
1772 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1773         {.frequency = 100 * 1000,       .index = 900 * 1000},
1774         {.frequency = 200 * 1000,       .index = 900 * 1000},
1775         {.frequency = 266 * 1000,       .index = 900 * 1000},
1776         {.frequency = 300 * 1000,       .index = 900 * 1000},
1777         {.frequency = 400 * 1000,       .index = 950 * 1000},
1778         {.frequency = 600 * 1000,       .index = 1100 * 1000},
1779         {.frequency = CPUFREQ_TABLE_END},
1780 };
1781
1782 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1783         {.frequency = 300 * 1000,       .index = 900 * 1000},
1784         {.frequency = 400 * 1000,       .index = 950 * 1000},
1785         {.frequency = CPUFREQ_TABLE_END},
1786 };
1787 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
1788 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1789 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1790
1791 void __init board_clock_init(void)
1792 {
1793         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1794         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1795         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1796         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1797 }
1798
1799 MACHINE_START(RK30, "RK30board")
1800         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
1801         .fixup          = rk30_fixup,
1802         .reserve        = &rk30_reserve,
1803         .map_io         = rk30_map_io,
1804         .init_irq       = rk30_init_irq,
1805         .timer          = &rk30_timer,
1806         .init_machine   = machine_rk30_board_init,
1807 MACHINE_END