phonepad:update mt6229 for new module
[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_HDMI_RK30)
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_HDMI_RK30)
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 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
888
889 #ifdef CONFIG_SDMMC0_RK29
890 static int rk29_sdmmc0_cfg_gpio(void)
891 {
892 #ifdef CONFIG_SDMMC_RK29_OLD
893         rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
894         rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
895         rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
896         rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
897         rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
898         rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
899
900         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
901
902         rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
903         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
904         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
905
906 #else
907         rk29_sdmmc_set_iomux(0, 0xFFFF);
908
909         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0_DETECT_N);
910
911 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
912         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
913         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
914 #endif
915
916 #endif
917
918         return 0;
919 }
920
921 #define CONFIG_SDMMC0_USE_DMA
922 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
923         .host_ocr_avail =
924             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
925              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
926              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
927         .host_caps =
928             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
929         .io_init = rk29_sdmmc0_cfg_gpio,
930
931 #if !defined(CONFIG_SDMMC_RK29_OLD)
932         .set_iomux = rk29_sdmmc_set_iomux,
933 #endif
934
935         .dma_name = "sd_mmc",
936 #ifdef CONFIG_SDMMC0_USE_DMA
937         .use_dma = 1,
938 #else
939         .use_dma = 0,
940 #endif
941
942 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
943     .status = rk29sdk_wifi_mmc0_status,
944     .register_status_notify = rk29sdk_wifi_mmc0_status_register,
945 #endif
946
947         .detect_irq = RK30_PIN3_PB6,    // INVALID_GPIO
948         .enable_sd_wakeup = 0,
949
950 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
951         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
952 #else
953         .write_prt = INVALID_GPIO,
954 #endif
955 };
956 #endif // CONFIG_SDMMC0_RK29
957
958 #ifdef CONFIG_SDMMC1_RK29
959 #define CONFIG_SDMMC1_USE_DMA
960 static int rk29_sdmmc1_cfg_gpio(void)
961 {
962 #if defined(CONFIG_SDMMC_RK29_OLD)
963         rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
964         rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
965         rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
966         rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
967         rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
968         rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
969         //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
970
971 #else
972
973 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
974         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
975         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
976 #endif
977
978 #endif
979
980         return 0;
981 }
982
983 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
984         .host_ocr_avail =
985             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
986              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
987              MMC_VDD_33_34),
988
989 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
990         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
991                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
992 #else
993         .host_caps =
994             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
995 #endif
996
997         .io_init = rk29_sdmmc1_cfg_gpio,
998
999 #if !defined(CONFIG_SDMMC_RK29_OLD)
1000         .set_iomux = rk29_sdmmc_set_iomux,
1001 #endif
1002
1003         .dma_name = "sdio",
1004 #ifdef CONFIG_SDMMC1_USE_DMA
1005         .use_dma = 1,
1006 #else
1007         .use_dma = 0,
1008 #endif
1009
1010 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1011 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1012         .status = rk29sdk_wifi_status,
1013         .register_status_notify = rk29sdk_wifi_status_register,
1014 #endif
1015 #if 0
1016         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1017 #endif
1018
1019 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1020         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1021 #else
1022         .write_prt = INVALID_GPIO,
1023 #endif
1024
1025 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1026     .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1027 #endif
1028
1029 #else
1030         .detect_irq = INVALID_GPIO,
1031         .enable_sd_wakeup = 0,
1032 #endif
1033
1034 };
1035 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1036
1037 /**************************************************************************************************
1038  * the end of setting for SDMMC devices
1039 **************************************************************************************************/
1040
1041 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1042 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1043         .dc_det_pin      = RK30_PIN6_PA5,
1044         .batt_low_pin    = RK30_PIN6_PA0,
1045         .charge_set_pin  = INVALID_GPIO,
1046         .charge_ok_pin   = RK30_PIN6_PA6,
1047         .dc_det_level    = GPIO_LOW,
1048         .charge_ok_level = GPIO_HIGH,
1049 };
1050
1051 static struct platform_device rk30_device_adc_battery = {
1052         .name   = "rk30-battery",
1053         .id     = -1,
1054         .dev = {
1055                 .platform_data = &rk30_adc_battery_platdata,
1056         },
1057 };
1058 #endif
1059
1060 #ifdef CONFIG_RK30_PWM_REGULATOR
1061 const static int pwm_voltage_map[] = {
1062         1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
1063 };
1064
1065 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1066         {
1067                 .supply = "vdd_core",
1068         }
1069 };
1070
1071 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1072 {
1073         {
1074                 .constraints = {
1075                         .name = "PWM_DCDC1",
1076                         .min_uV = 600000,
1077                         .max_uV = 1800000,      //0.6-1.8V
1078                         .apply_uV = true,
1079                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1080                 },
1081                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1082                 .consumer_supplies = pwm_dcdc1_consumers,
1083         },
1084 };
1085
1086 static struct pwm_platform_data pwm_regulator_info[1] = {
1087         {
1088                 .pwm_id = 3,
1089                 .pwm_gpio = RK30_PIN0_PD7,
1090                 .pwm_iomux_name = GPIO0D7_PWM3_NAME,
1091                 .pwm_iomux_pwm = GPIO0D_PWM3,
1092                 .pwm_iomux_gpio = GPIO0D_GPIO0D6,
1093                 .pwm_voltage = 1100000,
1094                 .suspend_voltage = 1050000,
1095                 .min_uV = 1000000,
1096                 .max_uV = 1400000,
1097                 .coefficient = 455,     //45.5%
1098                 .pwm_voltage_map = pwm_voltage_map,
1099                 .init_data      = &pwm_regulator_init_dcdc[0],
1100         },
1101 };
1102
1103 struct platform_device pwm_regulator_device[1] = {
1104         {
1105                 .name = "pwm-voltage-regulator",
1106                 .id = 0,
1107                 .dev            = {
1108                         .platform_data = &pwm_regulator_info[0],
1109                 }
1110         },
1111 };
1112 #endif
1113
1114 #ifdef CONFIG_RK29_VMAC
1115 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1116 #include "board-rk30-sdk-vmac.c"
1117 #endif
1118
1119 #ifdef CONFIG_RFKILL_RK
1120 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1121 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1122     .type               = RFKILL_TYPE_BLUETOOTH,
1123
1124     .poweron_gpio       = { // BT_REG_ON
1125         .io             = RK30_PIN3_PC7,
1126         .enable         = GPIO_HIGH,
1127         .iomux          = {
1128             .name       = GPIO3C7_SDMMC1WRITEPRT_NAME,
1129             .fgpio      = GPIO3C_GPIO3C7,
1130         },
1131     },
1132
1133     .reset_gpio         = { // BT_RST
1134         .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1135         .enable         = GPIO_LOW,
1136         .iomux          = {
1137             .name       = GPIO3D1_SDMMC1BACKENDPWR_NAME,
1138             .fgpio      = GPIO3D_GPIO3D1,
1139         },
1140     },
1141
1142     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
1143         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1144         .enable         = GPIO_HIGH,
1145         .iomux          = {
1146             .name       = GPIO3C6_SDMMC1DETECTN_NAME,
1147             .fgpio      = GPIO3C_GPIO3C6,
1148         },
1149     },
1150
1151     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1152         .gpio           = {
1153             .io         = RK30_PIN6_PA7, // set io to INVALID_GPIO for disable it
1154             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
1155             .iomux      = {
1156                 .name   = NULL,
1157             },
1158         },
1159     },
1160
1161     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
1162         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1163         .enable         = GPIO_LOW,
1164         .iomux          = {
1165             .name       = GPIO1A3_UART0RTSN_NAME,
1166             .fgpio      = GPIO1A_GPIO1A3,
1167             .fmux       = GPIO1A_UART0_RTS_N,
1168         },
1169     },
1170 };
1171
1172 static struct platform_device device_rfkill_rk = {
1173     .name   = "rfkill_rk",
1174     .id     = -1,
1175     .dev    = {
1176         .platform_data = &rfkill_rk_platdata,
1177     },
1178 };
1179 #endif
1180
1181 static struct platform_device *devices[] __initdata = {
1182 #ifdef CONFIG_FB_ROCKCHIP
1183         &device_fb,
1184 #endif
1185 #if defined(CONFIG_LCDC0_RK30)
1186         &device_lcdc0,
1187 #endif
1188 #if defined(CONFIG_LCDC1_RK30)
1189         &device_lcdc1,
1190 #endif
1191
1192 #ifdef CONFIG_BACKLIGHT_RK29_BL
1193         &rk29_device_backlight,
1194 #endif
1195
1196 #ifdef CONFIG_ION
1197         &device_ion,
1198 #endif
1199 #ifdef CONFIG_ANDROID_TIMED_GPIO
1200         &rk29_device_vibrator,
1201 #endif
1202 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1203         &rk29_device_gpio_leds,
1204 #endif
1205 #ifdef CONFIG_RK_IRDA
1206         &irda_device,
1207 #endif
1208 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1209         &rk29sdk_wifi_device,
1210 #endif
1211
1212 #if defined(CONFIG_MT6620)
1213     &mt3326_device_gps,
1214 #endif   
1215
1216 #ifdef CONFIG_RK29_SUPPORT_MODEM
1217         &rk30_device_modem,
1218 #endif
1219 #if defined(CONFIG_MU509)
1220         &rk29_device_mu509,
1221 #endif
1222 #if defined(CONFIG_MW100)
1223         &rk29_device_mw100,
1224 #endif
1225 #if defined(CONFIG_MT6229)
1226         &rk29_device_mt6229,
1227 #endif
1228 #if defined(CONFIG_SEW868)
1229         &rk30_device_sew868,
1230 #endif
1231 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1232         &rk30_device_adc_battery,
1233 #endif
1234 #ifdef CONFIG_RFKILL_RK
1235         &device_rfkill_rk,
1236 #endif
1237 };
1238
1239 // i2c
1240 #ifdef CONFIG_I2C0_RK30
1241 static struct i2c_board_info __initdata i2c0_info[] = {
1242 #if defined (CONFIG_GS_MMA8452)
1243         {
1244                 .type           = "gs_mma8452",
1245                 .addr           = 0x1d,
1246                 .flags          = 0,
1247                 .irq            = MMA8452_INT_PIN,
1248                 .platform_data = &mma8452_info,
1249         },
1250 #endif
1251 #if defined (CONFIG_GS_LIS3DH)
1252         {
1253                 .type           = "gs_lis3dh",
1254                 .addr           = 0x19,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
1255                 .flags          = 0,
1256                 .irq            = LIS3DH_INT_PIN,
1257                 .platform_data = &lis3dh_info,
1258         },
1259 #endif
1260 #if defined (CONFIG_GS_KXTIK)
1261         {
1262                 .type           = "gs_kxtik",
1263                 .addr           = 0x0F,
1264                 .flags          = 0,
1265                 .irq            = KXTIK_INT_PIN,
1266                 .platform_data = &kxtik_info,
1267         },
1268 #endif
1269 #if defined (CONFIG_COMPASS_AK8975)
1270         {
1271                 .type          = "ak8975",
1272                 .addr          = 0x0d,
1273                 .flags         = 0,
1274                 .irq           = RK30_PIN4_PC1,
1275                 .platform_data = &akm8975_info,
1276         },
1277 #endif
1278 #if defined (CONFIG_GYRO_L3G4200D)
1279         {
1280                 .type          = "l3g4200d_gryo",
1281                 .addr          = 0x69,
1282                 .flags         = 0,
1283                 .irq           = L3G4200D_INT_PIN,
1284                 .platform_data = &l3g4200d_info,
1285         },
1286 #endif
1287 #if defined (CONFIG_LS_AL3006)
1288         {
1289                 .type           = "light_al3006",
1290                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1291                 .flags          = 0,
1292                 .irq            = RK30_PIN6_PA2,        
1293                 .platform_data = &light_al3006_info,
1294         },
1295 #endif
1296 #if defined (CONFIG_LS_STK3171)
1297         {
1298                 .type           = "ls_stk3171",
1299                 .addr           = 0x48,            
1300                 .flags          = 0,
1301                 .irq            = RK30_PIN6_PA2,        
1302                 .platform_data = &light_stk3171_info,
1303         },
1304 #endif
1305
1306
1307 #if defined (CONFIG_PS_AL3006)
1308         {
1309                 .type           = "proximity_al3006",
1310                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1311                 .flags          = 0,
1312                 .irq            = RK30_PIN6_PA2,        
1313                 .platform_data = &proximity_al3006_info,
1314         },
1315 #endif
1316
1317 #if defined (CONFIG_PS_STK3171)
1318         {
1319                 .type           = "ps_stk3171",
1320                 .addr           = 0x48,            
1321                 .flags          = 0,
1322                 .irq            = RK30_PIN6_PA2,        
1323                 .platform_data = &proximity_stk3171_info,
1324         },
1325 #endif
1326 #if defined (CONFIG_SND_SOC_RK1000)
1327         {
1328                 .type          = "rk1000_i2c_codec",
1329                 .addr          = 0x60,
1330                 .flags         = 0,
1331         },
1332         {
1333                 .type          = "rk1000_control",
1334                 .addr          = 0x40,
1335                 .flags         = 0,
1336         },
1337 #endif
1338 #if defined (CONFIG_SND_SOC_RT5631)
1339         {
1340                 .type                   = "rt5631",
1341                 .addr                   = 0x1a,
1342                 .flags                  = 0,
1343         },
1344 #endif
1345
1346 #ifdef CONFIG_MFD_RK610
1347                 {
1348                         .type                   = "rk610_ctl",
1349                         .addr                   = 0x40,
1350                         .flags                  = 0,
1351                         .platform_data          = &rk610_power_on_init,
1352                 },
1353 #ifdef CONFIG_RK610_TVOUT
1354                 {
1355                         .type                   = "rk610_tvout",
1356                         .addr                   = 0x42,
1357                         .flags                  = 0,
1358                 },
1359 #endif
1360 #ifdef CONFIG_RK610_HDMI
1361                 {
1362                         .type                   = "rk610_hdmi",
1363                         .addr                   = 0x46,
1364                         .flags                  = 0,
1365                         .irq                    = RK29_PIN5_PA2,
1366                 },
1367 #endif
1368 #ifdef CONFIG_SND_SOC_RK610
1369                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1370                         .type                   = "rk610_i2c_codec",
1371                         .addr                   = 0x60,
1372                         .flags                  = 0,
1373                 },
1374 #endif
1375 #endif
1376
1377 };
1378 #endif
1379 #define PMIC_TYPE_WM8326        1
1380 #define PMIC_TYPE_TPS65910      2
1381 int __sramdata g_pmic_type =  0;
1382 #ifdef CONFIG_I2C1_RK30
1383 #ifdef CONFIG_MFD_WM831X_I2C
1384 #include "board-rk30-sdk-wm8326.c"
1385 #endif
1386 #ifdef CONFIG_MFD_TPS65910
1387 #define TPS65910_HOST_IRQ        RK30_PIN6_PA4
1388 #include "board-rk30-sdk-tps65910.c"
1389 #endif
1390
1391 static struct i2c_board_info __initdata i2c1_info[] = {
1392 #if defined (CONFIG_MFD_WM831X_I2C)
1393         {
1394                 .type          = "wm8326",
1395                 .addr          = 0x34,
1396                 .flags         = 0,
1397                 .irq           = RK30_PIN6_PA4,
1398                 .platform_data = &wm831x_platdata,
1399         },
1400 #endif
1401 #if defined (CONFIG_MFD_TPS65910)
1402         {
1403         .type           = "tps65910",
1404         .addr           = TPS65910_I2C_ID0,
1405         .flags          = 0,
1406         .irq            = TPS65910_HOST_IRQ,
1407         .platform_data = &tps65910_data,
1408         },
1409 #endif
1410 };
1411 #endif
1412
1413 void __sramfunc board_pmu_suspend(void)
1414 {      
1415         #if defined (CONFIG_MFD_WM831X_I2C)
1416        if(g_pmic_type == PMIC_TYPE_WM8326)
1417        board_pmu_wm8326_suspend();
1418         #endif
1419         #if defined (CONFIG_MFD_TPS65910)
1420        if(g_pmic_type == PMIC_TYPE_TPS65910)
1421        board_pmu_tps65910_suspend(); 
1422     #endif   
1423 }
1424
1425 void __sramfunc board_pmu_resume(void)
1426 {      
1427         #if defined (CONFIG_MFD_WM831X_I2C)
1428        if(g_pmic_type == PMIC_TYPE_WM8326)
1429        board_pmu_wm8326_resume();
1430         #endif
1431         #if defined (CONFIG_MFD_TPS65910)
1432        if(g_pmic_type == PMIC_TYPE_TPS65910)
1433        board_pmu_tps65910_resume(); 
1434         #endif
1435 }
1436
1437 #ifdef CONFIG_I2C2_RK30
1438 static struct i2c_board_info __initdata i2c2_info[] = {
1439 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1440         {
1441                 .type          = "Goodix-TS",
1442                 .addr          = 0x55,
1443                 .flags         = 0,
1444                 .irq           = RK30_PIN4_PC2,
1445                 .platform_data = &goodix_info,
1446         },
1447 #endif
1448 #if defined (CONFIG_LS_CM3217)
1449         {
1450                 .type          = "light_cm3217",
1451                 .addr          = 0x10,
1452                 .flags         = 0,
1453                 .platform_data = &cm3217_info,
1454         },
1455 #endif
1456 };
1457 #endif
1458
1459 #ifdef CONFIG_I2C3_RK30
1460 static struct i2c_board_info __initdata i2c3_info[] = {
1461 };
1462 #endif
1463
1464 #ifdef CONFIG_I2C4_RK30
1465 static struct i2c_board_info __initdata i2c4_info[] = {
1466 };
1467 #endif
1468
1469 #ifdef CONFIG_I2C_GPIO_RK30
1470 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1471 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1472 static int rk30_i2c_io_init(void)
1473 {
1474         //set iomux (gpio) here
1475         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1476         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1477
1478         return 0;
1479 }
1480 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1481        .sda_pin = I2C_SDA_PIN,
1482        .scl_pin = I2C_SCL_PIN,
1483        .udelay = 5, // clk = 500/udelay = 100Khz
1484        .timeout = 100,//msecs_to_jiffies(100),
1485        .bus_num    = 5,
1486        .io_init = rk30_i2c_io_init,
1487 };
1488 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1489 };
1490 #endif
1491
1492 static void __init rk30_i2c_register_board_info(void)
1493 {
1494 #ifdef CONFIG_I2C0_RK30
1495         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1496 #endif
1497 #ifdef CONFIG_I2C1_RK30
1498         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1499 #endif
1500 #ifdef CONFIG_I2C2_RK30
1501         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1502 #endif
1503 #ifdef CONFIG_I2C3_RK30
1504         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1505 #endif
1506 #ifdef CONFIG_I2C4_RK30
1507         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1508 #endif
1509 #ifdef CONFIG_I2C_GPIO_RK30
1510         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1511 #endif
1512 }
1513 //end of i2c
1514
1515 #define POWER_ON_PIN RK30_PIN6_PB0   //power_hold
1516 static void rk30_pm_power_off(void)
1517 {
1518         printk(KERN_ERR "rk30_pm_power_off start...\n");
1519         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1520         #if defined(CONFIG_MFD_WM831X)  
1521         if(g_pmic_type == PMIC_TYPE_WM8326)
1522         {
1523                 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
1524                 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1525         }
1526         #endif
1527         #if defined(CONFIG_MFD_TPS65910)
1528         if(g_pmic_type == PMIC_TYPE_TPS65910)
1529         {
1530                 tps65910_device_shutdown();//tps65910 shutdown
1531         }
1532         #endif
1533
1534         while (1);
1535 }
1536
1537 static void __init machine_rk30_board_init(void)
1538 {
1539         avs_init();
1540         gpio_request(POWER_ON_PIN, "poweronpin");
1541         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1542         
1543         pm_power_off = rk30_pm_power_off;
1544         
1545         rk30_i2c_register_board_info();
1546         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1547         platform_add_devices(devices, ARRAY_SIZE(devices));
1548         board_usb_detect_init(RK30_PIN6_PA3);
1549
1550 #ifdef CONFIG_WIFI_CONTROL_FUNC
1551         rk29sdk_wifi_bt_gpio_control_init();
1552 #endif
1553
1554 #if defined(CONFIG_MT6620)
1555     clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 16*1000000);
1556 #endif
1557 }
1558
1559 static void __init rk30_reserve(void)
1560 {
1561 #ifdef CONFIG_ION
1562         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1563 #endif
1564 #ifdef CONFIG_FB_ROCKCHIP
1565         resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
1566         resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
1567         #if 0
1568         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1569         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1570         resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
1571         resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
1572         #endif
1573 #endif
1574 #ifdef CONFIG_VIDEO_RK29
1575         rk30_camera_request_reserve_mem();
1576 #endif
1577         board_mem_reserved();
1578 }
1579
1580 /**
1581  * dvfs_cpu_logic_table: table for arm and logic dvfs 
1582  * @frequency   : arm frequency
1583  * @cpu_volt    : arm voltage depend on frequency
1584  * @logic_volt  : logic voltage arm requests depend on frequency
1585  * comments     : min arm/logic voltage
1586  */
1587 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
1588         {.frequency = 252 * 1000,       .cpu_volt = 1075 * 1000,        .logic_volt = 1125 * 1000},//0.975V/1.000V
1589         {.frequency = 504 * 1000,       .cpu_volt = 1100 * 1000,        .logic_volt = 1125 * 1000},//0.975V/1.000V
1590         {.frequency = 816 * 1000,       .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},//1.000V/1.025V
1591         {.frequency = 1008 * 1000,      .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},//1.025V/1.050V
1592         {.frequency = 1200 * 1000,      .cpu_volt = 1175 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
1593         {.frequency = 1272 * 1000,      .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},//1.150V/1.100V
1594         {.frequency = 1416 * 1000,      .cpu_volt = 1300 * 1000,        .logic_volt = 1200 * 1000},//1.225V/1.100V
1595         {.frequency = 1512 * 1000,      .cpu_volt = 1350 * 1000,        .logic_volt = 1250 * 1000},//1.300V/1.150V
1596         {.frequency = 1608 * 1000,      .cpu_volt = 1425 * 1000,        .logic_volt = 1300 * 1000},//1.325V/1.175V
1597         {.frequency = CPUFREQ_TABLE_END},
1598 };
1599
1600 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1601         {.frequency = 266 * 1000,       .index = 1050 * 1000},
1602         {.frequency = 400 * 1000,       .index = 1275 * 1000},
1603         {.frequency = CPUFREQ_TABLE_END},
1604 };
1605
1606 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1607         {.frequency = 300 * 1000,       .index = 1050 * 1000},
1608         {.frequency = 400 * 1000,       .index = 1125 * 1000},
1609         {.frequency = CPUFREQ_TABLE_END},
1610 };
1611
1612 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
1613 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1614 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1615
1616 void __init board_clock_init(void)
1617 {
1618         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1619         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1620         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1621         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1622 }
1623
1624 MACHINE_START(RK30, "RK30board")
1625         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
1626         .fixup          = rk30_fixup,
1627         .reserve        = &rk30_reserve,
1628         .map_io         = rk30_map_io,
1629         .init_irq       = rk30_init_irq,
1630         .timer          = &rk30_timer,
1631         .init_machine   = machine_rk30_board_init,
1632 MACHINE_END