rk:move pmic_type to board.h
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk30 / board-rk30-sdk.c
1 /* arch/arm/mach-rk30/board-rk30-sdk.c
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/regulator/rk29-pwm-regulator.h>
48
49 #if defined(CONFIG_MFD_RK610)
50 #include <linux/mfd/rk610_core.h>
51 #endif
52
53 #if defined(CONFIG_RK_HDMI)
54         #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
55 #endif
56
57 #if defined(CONFIG_SPIM_RK29)
58 #include "../../../drivers/spi/rk29_spim.h"
59 #endif
60 #if defined(CONFIG_MU509)
61 #include <linux/mu509.h>
62 #endif
63 #if defined(CONFIG_MW100)
64 #include <linux/mw100.h>
65 #endif
66 #if defined(CONFIG_MT6229)
67 #include <linux/mt6229.h>
68 #endif
69 #if defined(CONFIG_SEW868)
70 #include <linux/sew868.h>
71 #endif
72 #if defined(CONFIG_ANDROID_TIMED_GPIO)
73 #include "../../../drivers/staging/android/timed_gpio.h"
74 #endif
75
76 #if defined(CONFIG_MT6620)
77 #include <linux/gps.h>
78 #endif
79
80 #ifdef  CONFIG_THREE_FB_BUFFER
81 #define RK30_FB0_MEM_SIZE 12*SZ_1M
82 #else
83 #define RK30_FB0_MEM_SIZE 8*SZ_1M
84 #endif
85
86 #include "board-rk30-sdk-camera.c"
87 #include "board-rk30-sdk-key.c"
88
89 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
90 #define TOUCH_RESET_PIN  RK30_PIN4_PD0
91 #define TOUCH_PWR_PIN    INVALID_GPIO
92 int goodix_init_platform_hw(void)
93 {
94         int ret;
95         
96         rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
97         rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
98         printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
99
100         if (TOUCH_PWR_PIN != INVALID_GPIO) {
101                 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
102                 if (ret != 0) {
103                         gpio_free(TOUCH_PWR_PIN);
104                         printk("goodix power error\n");
105                         return -EIO;
106                 }
107                 gpio_direction_output(TOUCH_PWR_PIN, 0);
108                 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
109                 msleep(100);
110         }
111
112         if (TOUCH_RESET_PIN != INVALID_GPIO) {
113                 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
114                 if (ret != 0) {
115                         gpio_free(TOUCH_RESET_PIN);
116                         printk("goodix gpio_request error\n");
117                         return -EIO;
118                 }
119                 gpio_direction_output(TOUCH_RESET_PIN, 1);
120                 msleep(100);
121                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
122                 //msleep(100);
123                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
124                 //msleep(500);
125         }
126         return 0;
127 }
128
129 struct goodix_platform_data goodix_info = {
130         .model = 8105,
131         .irq_pin = RK30_PIN4_PC2,
132         .rest_pin = TOUCH_RESET_PIN,
133         .init_platform_hw = goodix_init_platform_hw,
134 };
135 #endif
136
137 static struct spi_board_info board_spi_devices[] = {
138 };
139
140 /***********************************************************
141 *       rk30  backlight
142 ************************************************************/
143 #ifdef CONFIG_BACKLIGHT_RK29_BL
144 #define PWM_ID            0
145 #define PWM_MUX_NAME      GPIO0A3_PWM0_NAME
146 #define PWM_MUX_MODE      GPIO0A_PWM0
147 #define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
148 #define PWM_GPIO          RK30_PIN0_PA3
149 #define PWM_EFFECT_VALUE  1
150
151 #define LCD_DISP_ON_PIN
152
153 #ifdef  LCD_DISP_ON_PIN
154 //#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
155 //#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
156
157 #define BL_EN_PIN         RK30_PIN6_PB3
158 #define BL_EN_VALUE       GPIO_HIGH
159 #endif
160 static int rk29_backlight_io_init(void)
161 {
162         int ret = 0;
163         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
164 #ifdef  LCD_DISP_ON_PIN
165         // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
166
167         ret = gpio_request(BL_EN_PIN, NULL);
168         if (ret != 0) {
169                 gpio_free(BL_EN_PIN);
170         }
171
172         gpio_direction_output(BL_EN_PIN, 0);
173         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
174 #endif
175         return ret;
176 }
177
178 static int rk29_backlight_io_deinit(void)
179 {
180         int ret = 0;
181 #ifdef  LCD_DISP_ON_PIN
182         gpio_free(BL_EN_PIN);
183 #endif
184         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
185         return ret;
186 }
187
188 static int rk29_backlight_pwm_suspend(void)
189 {
190         int ret = 0;
191         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
192         if (gpio_request(PWM_GPIO, NULL)) {
193                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
194                 return -1;
195         }
196         gpio_direction_output(PWM_GPIO, GPIO_LOW);
197 #ifdef  LCD_DISP_ON_PIN
198         gpio_direction_output(BL_EN_PIN, 0);
199         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
200 #endif
201         return ret;
202 }
203
204 static int rk29_backlight_pwm_resume(void)
205 {
206         gpio_free(PWM_GPIO);
207         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
208 #ifdef  LCD_DISP_ON_PIN
209         msleep(30);
210         gpio_direction_output(BL_EN_PIN, 1);
211         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
212 #endif
213         return 0;
214 }
215
216 static struct rk29_bl_info rk29_bl_info = {
217         .pwm_id = PWM_ID,
218         .bl_ref = PWM_EFFECT_VALUE,
219         .io_init = rk29_backlight_io_init,
220         .io_deinit = rk29_backlight_io_deinit,
221         .pwm_suspend = rk29_backlight_pwm_suspend,
222         .pwm_resume = rk29_backlight_pwm_resume,
223 };
224
225 static struct platform_device rk29_device_backlight = {
226         .name   = "rk29_backlight",
227         .id     = -1,
228         .dev    = {
229                 .platform_data  = &rk29_bl_info,
230         }
231 };
232
233 #endif
234
235 #ifdef CONFIG_RK29_SUPPORT_MODEM
236
237 #define RK30_MODEM_POWER        RK30_PIN4_PD1
238 #define RK30_MODEM_POWER_IOMUX  rk29_mux_api_set(GPIO4D1_SMCDATA9_TRACEDATA9_NAME, GPIO4D_GPIO4D1)
239
240 static int rk30_modem_io_init(void)
241 {
242     printk("%s\n", __FUNCTION__);
243     RK30_MODEM_POWER_IOMUX;
244
245         return 0;
246 }
247
248 static struct rk29_io_t rk30_modem_io = {
249     .io_addr    = RK30_MODEM_POWER,
250     .enable     = GPIO_HIGH,
251     .disable    = GPIO_LOW,
252     .io_init    = rk30_modem_io_init,
253 };
254
255 static struct platform_device rk30_device_modem = {
256         .name   = "rk30_modem",
257         .id     = -1,
258         .dev    = {
259                 .platform_data  = &rk30_modem_io,
260         }
261 };
262 #endif
263 #if defined(CONFIG_MU509)
264 static int mu509_io_init(void)
265 {
266
267         rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
268         rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
269         rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
270         rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
271         return 0;
272 }
273
274 static int mu509_io_deinit(void)
275 {
276         
277         return 0;
278 }
279  
280 struct rk29_mu509_data rk29_mu509_info = {
281         .io_init = mu509_io_init,
282         .io_deinit = mu509_io_deinit,
283         .modem_power_en = RK30_PIN6_PB2,//RK30_PIN4_PD1,
284         .bp_power = RK30_PIN2_PB6,//RK30_PIN4_PD1,
285         .bp_reset = RK30_PIN4_PD2,
286         .ap_wakeup_bp = RK30_PIN2_PB7,
287         .bp_wakeup_ap = RK30_PIN6_PA0, 
288 };
289 struct platform_device rk29_device_mu509 = {    
290         .name = "mu509",        
291         .id = -1,       
292         .dev            = {
293                 .platform_data = &rk29_mu509_info,
294         }       
295     };
296 #endif
297 #if defined(CONFIG_MW100)
298 static int mw100_io_init(void)
299 {
300          rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
301          rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
302          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
303          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
304         return 0;
305 }
306
307 static int mw100_io_deinit(void)
308 {
309         
310         return 0;
311 }
312  
313 struct rk29_mw100_data rk29_mw100_info = {
314         .io_init = mw100_io_init,
315         .io_deinit = mw100_io_deinit,
316         .modem_power_en = RK30_PIN6_PB2,
317         .bp_power = RK30_PIN2_PB6,
318         .bp_reset = RK30_PIN4_PD2,
319         .ap_wakeup_bp = RK30_PIN2_PB7,
320         .bp_wakeup_ap = RK30_PIN6_PA0,
321 };
322 struct platform_device rk29_device_mw100 = {    
323         .name = "mw100",        
324         .id = -1,       
325         .dev            = {
326                 .platform_data = &rk29_mw100_info,
327         }       
328     };
329 #endif
330 #if defined(CONFIG_MT6229)
331 static int mt6229_io_init(void)
332 {
333          rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
334          rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
335          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
336          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
337          rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
338          rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
339         return 0;
340
341          return 0;
342 }
343
344 static int mt6229_io_deinit(void)
345 {
346         
347         return 0;
348 }
349  
350 struct rk29_mt6229_data rk29_mt6229_info = {
351         .io_init = mt6229_io_init,
352         .io_deinit = mt6229_io_deinit,
353         .modem_power_en = RK30_PIN6_PB2,
354         .bp_power = RK30_PIN2_PB6,
355         .modem_usb_en = RK30_PIN2_PC0,
356         .modem_uart_en = RK30_PIN2_PC1,
357         .bp_wakeup_ap = RK30_PIN6_PA1,
358         .ap_ready = RK30_PIN2_PB7,
359
360 };
361 struct platform_device rk29_device_mt6229 = {   
362         .name = "mt6229",       
363         .id = -1,       
364         .dev            = {
365                 .platform_data = &rk29_mt6229_info,
366         }       
367     };
368 #endif
369 #if defined(CONFIG_SEW868)
370 static int sew868_io_init(void)
371 {
372         rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
373     rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
374         rk30_mux_api_set(GPIO4D4_SMCDATA12_TRACEDATA12_NAME, GPIO4D_GPIO4D4);
375         return 0;
376 }
377 static int sew868_io_deinit(void)
378 {
379         return 0;
380 }
381 struct rk30_sew868_data rk30_sew868_info = {
382         .io_init = sew868_io_init,
383         .io_deinit = sew868_io_deinit,
384         .bp_power = RK30_PIN6_PB2, 
385         .bp_power_active_low = 1,
386         .bp_sys = RK30_PIN2_PB6, 
387         .bp_reset = RK30_PIN4_PD2, 
388         .bp_reset_active_low = 1,
389         .bp_wakeup_ap = RK30_PIN4_PD4, 
390         .ap_wakeup_bp = NULL,
391 };
392
393 struct platform_device rk30_device_sew868 = {   
394         .name = "sew868",       
395         .id = -1,       
396         .dev            = {
397                 .platform_data = &rk30_sew868_info,
398         }       
399     };
400 #endif
401
402 /*MMA8452 gsensor*/
403 #if defined (CONFIG_GS_MMA8452)
404 #define MMA8452_INT_PIN   RK30_PIN4_PC0
405
406 static int mma8452_init_platform_hw(void)
407 {
408         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
409
410         return 0;
411 }
412
413 static struct sensor_platform_data mma8452_info = {
414         .type = SENSOR_TYPE_ACCEL,
415         .irq_enable = 1,
416         .poll_delay_ms = 30,
417         .init_platform_hw = mma8452_init_platform_hw,
418         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
419 };
420 #endif
421 #if defined (CONFIG_GS_LIS3DH)
422 #define LIS3DH_INT_PIN   RK30_PIN4_PC0
423
424 static int lis3dh_init_platform_hw(void)
425 {
426         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
427
428         return 0;
429 }
430
431 static struct sensor_platform_data lis3dh_info = {
432         .type = SENSOR_TYPE_ACCEL,
433         .irq_enable = 1,
434         .poll_delay_ms = 30,
435         .init_platform_hw = lis3dh_init_platform_hw,
436         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
437 };
438 #endif
439 #if defined (CONFIG_GS_KXTIK)
440 #define KXTIK_INT_PIN   RK30_PIN4_PC0
441
442 static int kxtik_init_platform_hw(void)
443 {
444         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
445
446         return 0;
447 }
448
449 static struct sensor_platform_data kxtik_info = {
450         .type = SENSOR_TYPE_ACCEL,
451         .irq_enable = 1,
452         .poll_delay_ms = 30,
453         .init_platform_hw = kxtik_init_platform_hw,
454         .orientation = {0, 1, 0, 0, 0, -1, 1, 0, 0},
455 };
456
457 #endif
458 #if defined (CONFIG_COMPASS_AK8975)
459 static struct sensor_platform_data akm8975_info =
460 {
461         .type = SENSOR_TYPE_COMPASS,
462         .irq_enable = 1,
463         .poll_delay_ms = 30,
464         .m_layout = 
465         {
466                 {
467                         {1, 0, 0},
468                         {0, 1, 0},
469                         {0, 0, 1},
470                 },
471
472                 {
473                         {1, 0, 0},
474                         {0, 1, 0},
475                         {0, 0, 1},
476                 },
477
478                 {
479                         {1, 0, 0},
480                         {0, 1, 0},
481                         {0, 0, 1},
482                 },
483
484                 {
485                         {1, 0, 0},
486                         {0, 1, 0},
487                         {0, 0, 1},
488                 },
489         }
490 };
491
492 #endif
493
494 #if defined(CONFIG_GYRO_L3G4200D)
495
496 #include <linux/l3g4200d.h>
497 #define L3G4200D_INT_PIN  RK30_PIN4_PC3
498
499 static int l3g4200d_init_platform_hw(void)
500 {
501         rk30_mux_api_set(GPIO4C3_SMCDATA3_TRACEDATA3_NAME, GPIO4C_GPIO4C3);
502         
503         return 0;
504 }
505
506 static struct sensor_platform_data l3g4200d_info = {
507         .type = SENSOR_TYPE_GYROSCOPE,
508         .irq_enable = 1,
509         .poll_delay_ms = 30,
510         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
511         .init_platform_hw = l3g4200d_init_platform_hw,
512         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
513         .y_min = 40,
514         .z_min = 20,
515 };
516
517 #endif
518
519 #ifdef CONFIG_LS_CM3217
520 static struct sensor_platform_data cm3217_info = {
521         .type = SENSOR_TYPE_LIGHT,
522         .irq_enable = 0,
523         .poll_delay_ms = 500,
524 };
525
526 #endif
527
528 #if defined(CONFIG_PS_AL3006)
529 static struct sensor_platform_data proximity_al3006_info = {
530         .type = SENSOR_TYPE_PROXIMITY,
531         .irq_enable = 1,
532         .poll_delay_ms = 200,
533 };
534 #endif
535
536 #if defined(CONFIG_PS_STK3171)
537 static struct sensor_platform_data proximity_stk3171_info = {
538         .type = SENSOR_TYPE_PROXIMITY,
539         .irq_enable = 1,
540         .poll_delay_ms = 200,
541 };
542 #endif
543
544
545 #if defined(CONFIG_LS_AL3006)
546 static struct sensor_platform_data light_al3006_info = {
547         .type = SENSOR_TYPE_LIGHT,
548         .irq_enable = 1,
549         .poll_delay_ms = 200,
550 };
551 #endif
552
553 #if defined(CONFIG_LS_STK3171)
554 static struct sensor_platform_data light_stk3171_info = {
555         .type = SENSOR_TYPE_LIGHT,
556         .irq_enable = 1,
557         .poll_delay_ms = 200,
558 };
559 #endif
560 #ifdef CONFIG_FB_ROCKCHIP
561
562 #define LCD_CS_MUX_NAME    GPIO4C7_SMCDATA7_TRACEDATA7_NAME
563 #define LCD_CS_PIN         RK30_PIN4_PC7
564 #define LCD_CS_VALUE       GPIO_HIGH
565
566 #define LCD_EN_MUX_NAME    GPIO4C7_SMCDATA7_TRACEDATA7_NAME
567 #define LCD_EN_PIN         RK30_PIN6_PB4
568 #define LCD_EN_VALUE       GPIO_LOW
569
570 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
571 {
572         int ret = 0;
573         rk30_mux_api_set(LCD_CS_MUX_NAME, GPIO4C_GPIO4C7);
574         ret = gpio_request(LCD_CS_PIN, NULL);
575         if (ret != 0)
576         {
577                 gpio_free(LCD_CS_PIN);
578                 printk(KERN_ERR "request lcd cs pin fail!\n");
579                 return -1;
580         }
581         else
582         {
583                 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
584         }
585         ret = gpio_request(LCD_EN_PIN, NULL);
586         if (ret != 0)
587         {
588                 gpio_free(LCD_EN_PIN);
589                 printk(KERN_ERR "request lcd en pin fail!\n");
590                 return -1;
591         }
592         else
593         {
594                 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
595         }
596         return 0;
597 }
598 static int rk_fb_io_disable(void)
599 {
600         gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE? 0:1);
601         gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE? 0:1);
602         return 0;
603 }
604 static int rk_fb_io_enable(void)
605 {
606         gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
607         gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
608         return 0;
609 }
610
611 #if defined(CONFIG_LCDC0_RK30)
612 struct rk29fb_info lcdc0_screen_info = {
613         .prop      = PRMRY,             //primary display device
614         .io_init   = rk_fb_io_init,
615         .io_disable = rk_fb_io_disable,
616         .io_enable = rk_fb_io_enable,
617         .set_screen_info = set_lcd_info,
618 };
619 #endif
620
621 #if defined(CONFIG_LCDC1_RK30)
622 struct rk29fb_info lcdc1_screen_info = {
623         #if defined(CONFIG_RK_HDMI)
624         .prop           = EXTEND,       //extend display device
625         .lcd_info  = NULL,
626         .set_screen_info = hdmi_init_lcdc,
627         #endif
628 };
629 #endif
630
631 static struct resource resource_fb[] = {
632         [0] = {
633                 .name  = "fb0 buf",
634                 .start = 0,
635                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
636                 .flags = IORESOURCE_MEM,
637         },
638         [1] = {
639                 .name  = "ipp buf",  //for rotate
640                 .start = 0,
641                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
642                 .flags = IORESOURCE_MEM,
643         },
644         [2] = {
645                 .name  = "fb2 buf",
646                 .start = 0,
647                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
648                 .flags = IORESOURCE_MEM,
649         },
650 };
651
652 static struct platform_device device_fb = {
653         .name           = "rk-fb",
654         .id             = -1,
655         .num_resources  = ARRAY_SIZE(resource_fb),
656         .resource       = resource_fb,
657 };
658 #endif
659
660 #if defined(CONFIG_LCDC0_RK30)
661 static struct resource resource_lcdc0[] = {
662         [0] = {
663                 .name  = "lcdc0 reg",
664                 .start = RK30_LCDC0_PHYS,
665                 .end   = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
666                 .flags = IORESOURCE_MEM,
667         },
668         
669         [1] = {
670                 .name  = "lcdc0 irq",
671                 .start = IRQ_LCDC0,
672                 .end   = IRQ_LCDC0,
673                 .flags = IORESOURCE_IRQ,
674         },
675 };
676
677 static struct platform_device device_lcdc0 = {
678         .name             = "rk30-lcdc",
679         .id               = 0,
680         .num_resources    = ARRAY_SIZE(resource_lcdc0),
681         .resource         = resource_lcdc0,
682         .dev            = {
683                 .platform_data = &lcdc0_screen_info,
684         },
685 };
686 #endif
687 #if defined(CONFIG_LCDC1_RK30) 
688 extern struct rk29fb_info lcdc1_screen_info;
689 static struct resource resource_lcdc1[] = {
690         [0] = {
691                 .name  = "lcdc1 reg",
692                 .start = RK30_LCDC1_PHYS,
693                 .end   = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
694                 .flags = IORESOURCE_MEM,
695         },
696         [1] = {
697                 .name  = "lcdc1 irq",
698                 .start = IRQ_LCDC1,
699                 .end   = IRQ_LCDC1,
700                 .flags = IORESOURCE_IRQ,
701         },
702 };
703
704 static struct platform_device device_lcdc1 = {
705         .name             = "rk30-lcdc",
706         .id               = 1,
707         .num_resources    = ARRAY_SIZE(resource_lcdc1),
708         .resource         = resource_lcdc1,
709         .dev            = {
710                 .platform_data = &lcdc1_screen_info,
711         },
712 };
713 #endif
714
715 #if defined(CONFIG_MFD_RK610)
716 #define RK610_RST_PIN_MUX_NAME          GPIO0C6_TRACECLK_SMCADDR2_NAME  
717 #define RK610_RST_PIN_MUX_MODE          GPIO0C_GPIO0C6
718 #define RK610_RST_PIN                   RK30_PIN0_PC6
719 static int rk610_power_on_init(void)
720 {
721         int ret;
722         if(RK610_RST_PIN != INVALID_GPIO)
723         {
724                 rk30_mux_api_set(RK610_RST_PIN_MUX_NAME,RK610_RST_PIN_MUX_MODE);
725                 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
726                 if (ret)
727                 {
728                         printk(KERN_ERR "rk610_control_probe request gpio fail\n");
729                 }
730                 else 
731                 {
732                         gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
733                         msleep(100);
734                         gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
735                         msleep(100);
736                         gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
737                 }
738         }
739
740         return 0;
741         
742 }
743
744
745 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
746         .rk610_power_on_init = rk610_power_on_init,
747 };
748 #endif
749
750 #ifdef CONFIG_ANDROID_TIMED_GPIO
751 static struct timed_gpio timed_gpios[] = {
752         {
753                 .name = "vibrator",
754                 .gpio = RK30_PIN0_PA4,
755                 .max_timeout = 1000,
756                 .active_low = 0,
757                 .adjust_time =20,      //adjust for diff product
758         },
759 };
760
761 static struct timed_gpio_platform_data rk29_vibrator_info = {
762         .num_gpios = 1,
763         .gpios = timed_gpios,
764 };
765
766 static struct platform_device rk29_device_vibrator = {
767         .name = "timed-gpio",
768         .id = -1,
769         .dev = {
770                 .platform_data = &rk29_vibrator_info,
771         },
772
773 };
774 #endif
775
776 #ifdef CONFIG_LEDS_GPIO_PLATFORM
777 static struct gpio_led rk29_leds[] = {
778         {
779                 .name = "button-backlight",
780                 .gpio = RK30_PIN4_PD7,
781                 .default_trigger = "timer",
782                 .active_low = 0,
783                 .retain_state_suspended = 0,
784                 .default_state = LEDS_GPIO_DEFSTATE_OFF,
785         },
786 };
787
788 static struct gpio_led_platform_data rk29_leds_pdata = {
789         .leds = rk29_leds,
790         .num_leds = ARRAY_SIZE(rk29_leds),
791 };
792
793 static struct platform_device rk29_device_gpio_leds = {
794         .name   = "leds-gpio",
795         .id     = -1,
796         .dev    = {
797                 .platform_data  = &rk29_leds_pdata,
798         },
799 };
800 #endif
801
802 #ifdef CONFIG_RK_IRDA
803 #define IRDA_IRQ_PIN           RK30_PIN6_PA1
804
805 static int irda_iomux_init(void)
806 {
807         int ret = 0;
808
809         //irda irq pin
810         ret = gpio_request(IRDA_IRQ_PIN, NULL);
811         if (ret != 0) {
812                 gpio_free(IRDA_IRQ_PIN);
813                 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
814         }
815         gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
816         gpio_direction_input(IRDA_IRQ_PIN);
817
818         return 0;
819 }
820
821 static int irda_iomux_deinit(void)
822 {
823         gpio_free(IRDA_IRQ_PIN);
824         return 0;
825 }
826
827 static struct irda_info rk29_irda_info = {
828         .intr_pin = IRDA_IRQ_PIN,
829         .iomux_init = irda_iomux_init,
830         .iomux_deinit = irda_iomux_deinit,
831         //.irda_pwr_ctl = bu92747guw_power_ctl,
832 };
833
834 static struct platform_device irda_device = {
835 #ifdef CONFIG_RK_IRDA_NET
836         .name = "rk_irda",
837 #else
838         .name = "bu92747_irda",
839 #endif
840         .id = -1,
841         .dev = {
842                 .platform_data = &rk29_irda_info,
843         }
844 };
845 #endif
846
847 #ifdef CONFIG_ION
848 #define ION_RESERVE_SIZE        (80 * SZ_1M)
849 static struct ion_platform_data rk30_ion_pdata = {
850         .nr = 1,
851         .heaps = {
852                 {
853                         .type = ION_HEAP_TYPE_CARVEOUT,
854                         .id = ION_NOR_HEAP_ID,
855                         .name = "norheap",
856                         .size = ION_RESERVE_SIZE,
857                 }
858         },
859 };
860
861 static struct platform_device device_ion = {
862         .name = "ion-rockchip",
863         .id = 0,
864         .dev = {
865                 .platform_data = &rk30_ion_pdata,
866         },
867 };
868 #endif
869
870 /**************************************************************************************************
871  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
872 **************************************************************************************************/
873 #ifdef CONFIG_SDMMC_RK29
874 #include "board-rk30-sdk-sdmmc.c"
875
876 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
877 #define SDMMC0_WRITE_PROTECT_PIN        RK30_PIN3_PB2   //According to your own project to set the value of write-protect-pin.
878 #endif
879
880 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
881 #define SDMMC1_WRITE_PROTECT_PIN        RK30_PIN3_PB3   //According to your own project to set the value of write-protect-pin.
882 #endif
883
884 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK30_PIN6_PB2
885 #define RK29SDK_WIFI_SDIO_CARD_INT         RK30_PIN3_PD2
886
887 #define RK29SDK_SD_CARD_DETECT_N        RK30_PIN3_PB6  //According to your own project to set the value of card-detect-pin.
888 #define RK29SDK_SD_CARD_INSERT_LEVEL    GPIO_LOW         // set the voltage of insert-card. Please pay attention to the default setting.
889 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
890
891 #ifdef CONFIG_SDMMC0_RK29
892 static int rk29_sdmmc0_cfg_gpio(void)
893 {
894 #ifdef CONFIG_SDMMC_RK29_OLD
895         rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
896         rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
897         rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
898         rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
899         rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
900         rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
901
902         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
903
904         rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
905         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
906         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
907
908 #else
909         rk29_sdmmc_set_iomux(0, 0xFFFF);
910
911 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
912      rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
913 #else
914         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0_DETECT_N);
915 #endif  
916
917 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
918         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
919         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
920 #endif
921
922 #endif
923
924         return 0;
925 }
926
927 #define CONFIG_SDMMC0_USE_DMA
928 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
929         .host_ocr_avail =
930             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
931              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
932              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
933         .host_caps =
934             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
935         .io_init = rk29_sdmmc0_cfg_gpio,
936
937 #if !defined(CONFIG_SDMMC_RK29_OLD)
938         .set_iomux = rk29_sdmmc_set_iomux,
939 #endif
940
941         .dma_name = "sd_mmc",
942 #ifdef CONFIG_SDMMC0_USE_DMA
943         .use_dma = 1,
944 #else
945         .use_dma = 0,
946 #endif
947
948 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
949     .status = rk29sdk_wifi_mmc0_status,
950     .register_status_notify = rk29sdk_wifi_mmc0_status_register,
951 #endif
952 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
953     .detect_irq = RK29SDK_SD_CARD_DETECT_N,
954     .insert_card_level = RK29SDK_SD_CARD_INSERT_LEVEL,
955 #else
956         .detect_irq = RK30_PIN3_PB6,    // INVALID_GPIO
957 #endif
958         .enable_sd_wakeup = 0,
959
960 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
961         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
962 #else
963         .write_prt = INVALID_GPIO,
964 #endif
965 };
966 #endif // CONFIG_SDMMC0_RK29
967
968 #ifdef CONFIG_SDMMC1_RK29
969 #define CONFIG_SDMMC1_USE_DMA
970 static int rk29_sdmmc1_cfg_gpio(void)
971 {
972 #if defined(CONFIG_SDMMC_RK29_OLD)
973         rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
974         rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
975         rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
976         rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
977         rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
978         rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
979         //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
980
981 #else
982
983 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
984         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
985         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
986 #endif
987
988 #endif
989
990         return 0;
991 }
992
993 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
994         .host_ocr_avail =
995             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
996              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
997              MMC_VDD_33_34),
998
999 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1000         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1001                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1002 #else
1003         .host_caps =
1004             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1005 #endif
1006
1007         .io_init = rk29_sdmmc1_cfg_gpio,
1008
1009 #if !defined(CONFIG_SDMMC_RK29_OLD)
1010         .set_iomux = rk29_sdmmc_set_iomux,
1011 #endif
1012
1013         .dma_name = "sdio",
1014 #ifdef CONFIG_SDMMC1_USE_DMA
1015         .use_dma = 1,
1016 #else
1017         .use_dma = 0,
1018 #endif
1019
1020 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1021 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1022         .status = rk29sdk_wifi_status,
1023         .register_status_notify = rk29sdk_wifi_status_register,
1024 #endif
1025 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)    
1026         .detect_irq = INVALID_GPIO,//RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1027 #else
1028         //.detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,        
1029 #endif
1030
1031 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1032         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1033 #else
1034         .write_prt = INVALID_GPIO,
1035 #endif
1036
1037 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1038     .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1039 #endif
1040
1041 #else
1042         .detect_irq = INVALID_GPIO,
1043         .enable_sd_wakeup = 0,
1044 #endif
1045
1046 };
1047 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1048
1049 /**************************************************************************************************
1050  * the end of setting for SDMMC devices
1051 **************************************************************************************************/
1052
1053 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1054 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1055         .dc_det_pin      = RK30_PIN6_PA5,
1056         .batt_low_pin    = RK30_PIN6_PA0,
1057         .charge_set_pin  = INVALID_GPIO,
1058         .charge_ok_pin   = RK30_PIN6_PA6,
1059         .dc_det_level    = GPIO_LOW,
1060         .charge_ok_level = GPIO_HIGH,
1061 };
1062
1063 static struct platform_device rk30_device_adc_battery = {
1064         .name   = "rk30-battery",
1065         .id     = -1,
1066         .dev = {
1067                 .platform_data = &rk30_adc_battery_platdata,
1068         },
1069 };
1070 #endif
1071
1072 #ifdef CONFIG_RK30_PWM_REGULATOR
1073 const static int pwm_voltage_map[] = {
1074         1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
1075 };
1076
1077 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1078         {
1079                 .supply = "vdd_core",
1080         }
1081 };
1082
1083 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1084 {
1085         {
1086                 .constraints = {
1087                         .name = "PWM_DCDC1",
1088                         .min_uV = 600000,
1089                         .max_uV = 1800000,      //0.6-1.8V
1090                         .apply_uV = true,
1091                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1092                 },
1093                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1094                 .consumer_supplies = pwm_dcdc1_consumers,
1095         },
1096 };
1097
1098 static struct pwm_platform_data pwm_regulator_info[1] = {
1099         {
1100                 .pwm_id = 3,
1101                 .pwm_gpio = RK30_PIN0_PD7,
1102                 .pwm_iomux_name = GPIO0D7_PWM3_NAME,
1103                 .pwm_iomux_pwm = GPIO0D_PWM3,
1104                 .pwm_iomux_gpio = GPIO0D_GPIO0D6,
1105                 .pwm_voltage = 1100000,
1106                 .suspend_voltage = 1050000,
1107                 .min_uV = 1000000,
1108                 .max_uV = 1400000,
1109                 .coefficient = 455,     //45.5%
1110                 .pwm_voltage_map = pwm_voltage_map,
1111                 .init_data      = &pwm_regulator_init_dcdc[0],
1112         },
1113 };
1114
1115 struct platform_device pwm_regulator_device[1] = {
1116         {
1117                 .name = "pwm-voltage-regulator",
1118                 .id = 0,
1119                 .dev            = {
1120                         .platform_data = &pwm_regulator_info[0],
1121                 }
1122         },
1123 };
1124 #endif
1125
1126 #ifdef CONFIG_RK29_VMAC
1127 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1128 #include "board-rk30-sdk-vmac.c"
1129 #endif
1130
1131 #ifdef CONFIG_RFKILL_RK
1132 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1133 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1134     .type               = RFKILL_TYPE_BLUETOOTH,
1135
1136     .poweron_gpio       = { // BT_REG_ON
1137         .io             = RK30_PIN3_PC7,
1138         .enable         = GPIO_HIGH,
1139         .iomux          = {
1140             .name       = GPIO3C7_SDMMC1WRITEPRT_NAME,
1141             .fgpio      = GPIO3C_GPIO3C7,
1142         },
1143     },
1144
1145     .reset_gpio         = { // BT_RST
1146         .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1147         .enable         = GPIO_LOW,
1148         .iomux          = {
1149             .name       = GPIO3D1_SDMMC1BACKENDPWR_NAME,
1150             .fgpio      = GPIO3D_GPIO3D1,
1151         },
1152     },
1153
1154     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
1155         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1156         .enable         = GPIO_HIGH,
1157         .iomux          = {
1158             .name       = GPIO3C6_SDMMC1DETECTN_NAME,
1159             .fgpio      = GPIO3C_GPIO3C6,
1160         },
1161     },
1162
1163     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1164         .gpio           = {
1165             .io         = RK30_PIN6_PA7, // set io to INVALID_GPIO for disable it
1166             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
1167             .iomux      = {
1168                 .name   = NULL,
1169             },
1170         },
1171     },
1172
1173     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
1174         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1175         .enable         = GPIO_LOW,
1176         .iomux          = {
1177             .name       = GPIO1A3_UART0RTSN_NAME,
1178             .fgpio      = GPIO1A_GPIO1A3,
1179             .fmux       = GPIO1A_UART0_RTS_N,
1180         },
1181     },
1182 };
1183
1184 static struct platform_device device_rfkill_rk = {
1185     .name   = "rfkill_rk",
1186     .id     = -1,
1187     .dev    = {
1188         .platform_data = &rfkill_rk_platdata,
1189     },
1190 };
1191 #endif
1192
1193 static struct platform_device *devices[] __initdata = {
1194 #ifdef CONFIG_FB_ROCKCHIP
1195         &device_fb,
1196 #endif
1197 #if defined(CONFIG_LCDC0_RK30)
1198         &device_lcdc0,
1199 #endif
1200 #if defined(CONFIG_LCDC1_RK30)
1201         &device_lcdc1,
1202 #endif
1203
1204 #ifdef CONFIG_BACKLIGHT_RK29_BL
1205         &rk29_device_backlight,
1206 #endif
1207
1208 #ifdef CONFIG_ION
1209         &device_ion,
1210 #endif
1211 #ifdef CONFIG_ANDROID_TIMED_GPIO
1212         &rk29_device_vibrator,
1213 #endif
1214 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1215         &rk29_device_gpio_leds,
1216 #endif
1217 #ifdef CONFIG_RK_IRDA
1218         &irda_device,
1219 #endif
1220 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1221         &rk29sdk_wifi_device,
1222 #endif
1223
1224 #if defined(CONFIG_MT6620)
1225     &mt3326_device_gps,
1226 #endif   
1227
1228 #ifdef CONFIG_RK29_SUPPORT_MODEM
1229         &rk30_device_modem,
1230 #endif
1231 #if defined(CONFIG_MU509)
1232         &rk29_device_mu509,
1233 #endif
1234 #if defined(CONFIG_MW100)
1235         &rk29_device_mw100,
1236 #endif
1237 #if defined(CONFIG_MT6229)
1238         &rk29_device_mt6229,
1239 #endif
1240 #if defined(CONFIG_SEW868)
1241         &rk30_device_sew868,
1242 #endif
1243 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1244         &rk30_device_adc_battery,
1245 #endif
1246 #ifdef CONFIG_RFKILL_RK
1247         &device_rfkill_rk,
1248 #endif
1249 };
1250
1251 // i2c
1252 #ifdef CONFIG_I2C0_RK30
1253 static struct i2c_board_info __initdata i2c0_info[] = {
1254 #if defined (CONFIG_GS_MMA8452)
1255         {
1256                 .type           = "gs_mma8452",
1257                 .addr           = 0x1d,
1258                 .flags          = 0,
1259                 .irq            = MMA8452_INT_PIN,
1260                 .platform_data = &mma8452_info,
1261         },
1262 #endif
1263 #if defined (CONFIG_GS_LIS3DH)
1264         {
1265                 .type           = "gs_lis3dh",
1266                 .addr           = 0x19,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
1267                 .flags          = 0,
1268                 .irq            = LIS3DH_INT_PIN,
1269                 .platform_data = &lis3dh_info,
1270         },
1271 #endif
1272 #if defined (CONFIG_GS_KXTIK)
1273         {
1274                 .type           = "gs_kxtik",
1275                 .addr           = 0x0F,
1276                 .flags          = 0,
1277                 .irq            = KXTIK_INT_PIN,
1278                 .platform_data = &kxtik_info,
1279         },
1280 #endif
1281 #if defined (CONFIG_COMPASS_AK8975)
1282         {
1283                 .type          = "ak8975",
1284                 .addr          = 0x0d,
1285                 .flags         = 0,
1286                 .irq           = RK30_PIN4_PC1,
1287                 .platform_data = &akm8975_info,
1288         },
1289 #endif
1290 #if defined (CONFIG_GYRO_L3G4200D)
1291         {
1292                 .type          = "l3g4200d_gryo",
1293                 .addr          = 0x69,
1294                 .flags         = 0,
1295                 .irq           = L3G4200D_INT_PIN,
1296                 .platform_data = &l3g4200d_info,
1297         },
1298 #endif
1299 #if defined (CONFIG_LS_AL3006)
1300         {
1301                 .type           = "light_al3006",
1302                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1303                 .flags          = 0,
1304                 .irq            = RK30_PIN6_PA2,        
1305                 .platform_data = &light_al3006_info,
1306         },
1307 #endif
1308 #if defined (CONFIG_LS_STK3171)
1309         {
1310                 .type           = "ls_stk3171",
1311                 .addr           = 0x48,            
1312                 .flags          = 0,
1313                 .irq            = RK30_PIN6_PA2,        
1314                 .platform_data = &light_stk3171_info,
1315         },
1316 #endif
1317
1318
1319 #if defined (CONFIG_PS_AL3006)
1320         {
1321                 .type           = "proximity_al3006",
1322                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1323                 .flags          = 0,
1324                 .irq            = RK30_PIN6_PA2,        
1325                 .platform_data = &proximity_al3006_info,
1326         },
1327 #endif
1328
1329 #if defined (CONFIG_PS_STK3171)
1330         {
1331                 .type           = "ps_stk3171",
1332                 .addr           = 0x48,            
1333                 .flags          = 0,
1334                 .irq            = RK30_PIN6_PA2,        
1335                 .platform_data = &proximity_stk3171_info,
1336         },
1337 #endif
1338 #if defined (CONFIG_SND_SOC_RK1000)
1339         {
1340                 .type          = "rk1000_i2c_codec",
1341                 .addr          = 0x60,
1342                 .flags         = 0,
1343         },
1344         {
1345                 .type          = "rk1000_control",
1346                 .addr          = 0x40,
1347                 .flags         = 0,
1348         },
1349 #endif
1350 #if defined (CONFIG_SND_SOC_RT5631)
1351         {
1352                 .type                   = "rt5631",
1353                 .addr                   = 0x1a,
1354                 .flags                  = 0,
1355         },
1356 #endif
1357
1358 #ifdef CONFIG_MFD_RK610
1359                 {
1360                         .type                   = "rk610_ctl",
1361                         .addr                   = 0x40,
1362                         .flags                  = 0,
1363                         .platform_data          = &rk610_power_on_init,
1364                 },
1365 #ifdef CONFIG_RK610_TVOUT
1366                 {
1367                         .type                   = "rk610_tvout",
1368                         .addr                   = 0x42,
1369                         .flags                  = 0,
1370                 },
1371 #endif
1372 #ifdef CONFIG_RK610_HDMI
1373                 {
1374                         .type                   = "rk610_hdmi",
1375                         .addr                   = 0x46,
1376                         .flags                  = 0,
1377                         .irq                    = RK29_PIN5_PA2,
1378                 },
1379 #endif
1380 #ifdef CONFIG_SND_SOC_RK610
1381                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1382                         .type                   = "rk610_i2c_codec",
1383                         .addr                   = 0x60,
1384                         .flags                  = 0,
1385                 },
1386 #endif
1387 #endif
1388
1389 };
1390 #endif
1391 int __sramdata g_pmic_type =  0;
1392 #ifdef CONFIG_I2C1_RK30
1393 #ifdef CONFIG_MFD_WM831X_I2C
1394 #include "board-rk30-sdk-wm8326.c"
1395 #endif
1396 #ifdef CONFIG_MFD_TPS65910
1397 #define TPS65910_HOST_IRQ        RK30_PIN6_PA4
1398 #include "board-rk30-sdk-tps65910.c"
1399 #endif
1400
1401 static struct i2c_board_info __initdata i2c1_info[] = {
1402 #if defined (CONFIG_MFD_WM831X_I2C)
1403         {
1404                 .type          = "wm8326",
1405                 .addr          = 0x34,
1406                 .flags         = 0,
1407                 .irq           = RK30_PIN6_PA4,
1408                 .platform_data = &wm831x_platdata,
1409         },
1410 #endif
1411 #if defined (CONFIG_MFD_TPS65910)
1412         {
1413         .type           = "tps65910",
1414         .addr           = TPS65910_I2C_ID0,
1415         .flags          = 0,
1416         .irq            = TPS65910_HOST_IRQ,
1417         .platform_data = &tps65910_data,
1418         },
1419 #endif
1420 };
1421 #endif
1422
1423 void __sramfunc board_pmu_suspend(void)
1424 {      
1425         #if defined (CONFIG_MFD_WM831X_I2C)
1426        if(pmic_is_wm8326())
1427        board_pmu_wm8326_suspend();
1428         #endif
1429         #if defined (CONFIG_MFD_TPS65910)
1430        if(pmic_is_tps65910())
1431        board_pmu_tps65910_suspend(); 
1432     #endif   
1433 }
1434
1435 void __sramfunc board_pmu_resume(void)
1436 {      
1437         #if defined (CONFIG_MFD_WM831X_I2C)
1438        if(pmic_is_wm8326())
1439        board_pmu_wm8326_resume();
1440         #endif
1441         #if defined (CONFIG_MFD_TPS65910)
1442        if(pmic_is_tps65910())
1443        board_pmu_tps65910_resume(); 
1444         #endif
1445 }
1446
1447 #ifdef CONFIG_I2C2_RK30
1448 static struct i2c_board_info __initdata i2c2_info[] = {
1449 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1450         {
1451                 .type          = "Goodix-TS",
1452                 .addr          = 0x55,
1453                 .flags         = 0,
1454                 .irq           = RK30_PIN4_PC2,
1455                 .platform_data = &goodix_info,
1456         },
1457 #endif
1458 #if defined (CONFIG_LS_CM3217)
1459         {
1460                 .type          = "light_cm3217",
1461                 .addr          = 0x10,
1462                 .flags         = 0,
1463                 .platform_data = &cm3217_info,
1464         },
1465 #endif
1466 };
1467 #endif
1468
1469 #ifdef CONFIG_I2C3_RK30
1470 static struct i2c_board_info __initdata i2c3_info[] = {
1471 };
1472 #endif
1473
1474 #ifdef CONFIG_I2C4_RK30
1475 static struct i2c_board_info __initdata i2c4_info[] = {
1476 };
1477 #endif
1478
1479 #ifdef CONFIG_I2C_GPIO_RK30
1480 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1481 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1482 static int rk30_i2c_io_init(void)
1483 {
1484         //set iomux (gpio) here
1485         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1486         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1487
1488         return 0;
1489 }
1490 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1491        .sda_pin = I2C_SDA_PIN,
1492        .scl_pin = I2C_SCL_PIN,
1493        .udelay = 5, // clk = 500/udelay = 100Khz
1494        .timeout = 100,//msecs_to_jiffies(100),
1495        .bus_num    = 5,
1496        .io_init = rk30_i2c_io_init,
1497 };
1498 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1499 };
1500 #endif
1501
1502 static void __init rk30_i2c_register_board_info(void)
1503 {
1504 #ifdef CONFIG_I2C0_RK30
1505         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1506 #endif
1507 #ifdef CONFIG_I2C1_RK30
1508         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1509 #endif
1510 #ifdef CONFIG_I2C2_RK30
1511         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1512 #endif
1513 #ifdef CONFIG_I2C3_RK30
1514         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1515 #endif
1516 #ifdef CONFIG_I2C4_RK30
1517         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1518 #endif
1519 #ifdef CONFIG_I2C_GPIO_RK30
1520         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1521 #endif
1522 }
1523 //end of i2c
1524
1525 #define POWER_ON_PIN RK30_PIN6_PB0   //power_hold
1526 static void rk30_pm_power_off(void)
1527 {
1528         printk(KERN_ERR "rk30_pm_power_off start...\n");
1529         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1530         #if defined(CONFIG_MFD_WM831X)  
1531         if(pmic_is_wm8326())
1532         {
1533                 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
1534                 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1535         }
1536         #endif
1537         #if defined(CONFIG_MFD_TPS65910)
1538         if(pmic_is_tps65910())
1539         {
1540                 tps65910_device_shutdown();//tps65910 shutdown
1541         }
1542         #endif
1543
1544         while (1);
1545 }
1546
1547 static void __init machine_rk30_board_init(void)
1548 {
1549         avs_init();
1550         gpio_request(POWER_ON_PIN, "poweronpin");
1551         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1552         
1553         pm_power_off = rk30_pm_power_off;
1554         
1555         rk30_i2c_register_board_info();
1556         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1557         platform_add_devices(devices, ARRAY_SIZE(devices));
1558         board_usb_detect_init(RK30_PIN6_PA3);
1559
1560 #ifdef CONFIG_WIFI_CONTROL_FUNC
1561         rk29sdk_wifi_bt_gpio_control_init();
1562 #endif
1563
1564 #if defined(CONFIG_MT6620)
1565     clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 16*1000000);
1566 #endif
1567 }
1568
1569 static void __init rk30_reserve(void)
1570 {
1571 #ifdef CONFIG_ION
1572         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1573 #endif
1574 #ifdef CONFIG_FB_ROCKCHIP
1575         resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
1576         resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
1577         #if 0
1578         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1579         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1580         resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
1581         resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
1582         #endif
1583 #endif
1584 #ifdef CONFIG_VIDEO_RK29
1585         rk30_camera_request_reserve_mem();
1586 #endif
1587         board_mem_reserved();
1588 }
1589
1590 /**
1591  * dvfs_cpu_logic_table: table for arm and logic dvfs 
1592  * @frequency   : arm frequency
1593  * @cpu_volt    : arm voltage depend on frequency
1594  * @logic_volt  : logic voltage arm requests depend on frequency
1595  * comments     : min arm/logic voltage
1596  */
1597 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
1598         {.frequency = 252 * 1000,       .cpu_volt = 1075 * 1000,        .logic_volt = 1125 * 1000},//0.975V/1.000V
1599         {.frequency = 504 * 1000,       .cpu_volt = 1100 * 1000,        .logic_volt = 1125 * 1000},//0.975V/1.000V
1600         {.frequency = 816 * 1000,       .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},//1.000V/1.025V
1601         {.frequency = 1008 * 1000,      .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},//1.025V/1.050V
1602         {.frequency = 1200 * 1000,      .cpu_volt = 1175 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
1603         {.frequency = 1272 * 1000,      .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},//1.150V/1.100V
1604         {.frequency = 1416 * 1000,      .cpu_volt = 1300 * 1000,        .logic_volt = 1200 * 1000},//1.225V/1.100V
1605         {.frequency = 1512 * 1000,      .cpu_volt = 1350 * 1000,        .logic_volt = 1250 * 1000},//1.300V/1.150V
1606         {.frequency = 1608 * 1000,      .cpu_volt = 1425 * 1000,        .logic_volt = 1300 * 1000},//1.325V/1.175V
1607         {.frequency = CPUFREQ_TABLE_END},
1608 };
1609
1610 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1611         {.frequency = 266 * 1000,       .index = 1050 * 1000},
1612         {.frequency = 400 * 1000,       .index = 1275 * 1000},
1613         {.frequency = CPUFREQ_TABLE_END},
1614 };
1615
1616 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1617         {.frequency = 300 * 1000,       .index = 1050 * 1000},
1618         {.frequency = 400 * 1000,       .index = 1125 * 1000},
1619         {.frequency = CPUFREQ_TABLE_END},
1620 };
1621
1622 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
1623 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1624 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1625
1626 void __init board_clock_init(void)
1627 {
1628         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1629         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1630         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1631         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1632 }
1633
1634 MACHINE_START(RK30, "RK30board")
1635         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
1636         .fixup          = rk30_fixup,
1637         .reserve        = &rk30_reserve,
1638         .map_io         = rk30_map_io,
1639         .init_irq       = rk30_init_irq,
1640         .timer          = &rk30_timer,
1641         .init_machine   = machine_rk30_board_init,
1642 MACHINE_END