androidComputer: changed for display
[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/regulator/machine.h>
44 #include <linux/rfkill-rk.h>
45 #include <linux/sensor-dev.h>
46 #include <linux/regulator/rk29-pwm-regulator.h>
47
48 #include "../../../drivers/headset_observe/rk_headset.h"
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_MT6229)
64 #include <linux/mt6229.h>
65 #endif
66 #if defined(CONFIG_MW100)
67 #include <linux/mw100.h>
68 #endif
69 #if defined (CONFIG_BP_AUTO)
70 #include <linux/bp-auto.h>
71 #endif
72 #if defined(CONFIG_SEW868)
73 #include <linux/sew868.h>
74 #endif
75 #if defined(CONFIG_ANDROID_TIMED_GPIO)
76 #include "../../../drivers/staging/android/timed_gpio.h"
77 #endif
78
79 /* Android Parameter */
80 static int ap_mdm = 0;
81 module_param(ap_mdm, int, 0644);
82 static int ap_has_alsa = 0;
83 module_param(ap_has_alsa, int, 0644);
84 static int ap_data_only = 2;
85 module_param(ap_data_only, int, 0644);
86 static int ap_has_earphone = 0;
87 module_param(ap_has_earphone, int, 0644);
88
89 #if defined(CONFIG_MT6620)
90 #include <linux/gps.h>
91 #endif
92
93 #if defined(CONFIG_DP501)   //for display port transmitter dp501
94 #include<linux/dp501.h>
95 #endif
96
97 #include "board-rk30-sdk-camera.c"
98
99 #include <plat/key.h>
100 static struct rk29_keys_button key_button[] = {
101         {
102                 .desc   = "vol-",
103                 .code   = KEY_VOLUMEDOWN,
104                 .gpio   = RK30_PIN4_PC5,
105                 .active_low = PRESS_LEV_LOW,
106         },
107         {
108                 .desc   = "play",
109                 .code   = KEY_POWER,
110                 .gpio   = RK30_PIN6_PA2,
111                 .active_low = PRESS_LEV_LOW,
112                 //.code_long_press = EV_ENCALL,
113                 .wakeup = 1,
114         },
115         {
116                 .desc   = "vol+",
117                 .code   = KEY_VOLUMEUP,
118                 .adc_value      = 1,
119                 .gpio = INVALID_GPIO,
120                 .active_low = PRESS_LEV_LOW,
121         },
122 #ifndef RK3000_SDK
123         {
124                 .desc   = "menu",
125                 .code   = EV_MENU,
126                 .adc_value      = 135,
127                 .gpio = INVALID_GPIO,
128                 .active_low = PRESS_LEV_LOW,
129         },
130         {
131                 .desc   = "home",
132                 .code   = KEY_HOME,
133                 .adc_value      = 550,
134                 .gpio = INVALID_GPIO,
135                 .active_low = PRESS_LEV_LOW,
136         },
137         {
138                 .desc   = "esc",
139                 .code   = KEY_BACK,
140                 .adc_value      = 334,
141                 .gpio = INVALID_GPIO,
142                 .active_low = PRESS_LEV_LOW,
143         },
144         {
145                 .desc   = "camera",
146                 .code   = KEY_CAMERA,
147                 .adc_value      = 743,
148                 .gpio = INVALID_GPIO,
149                 .active_low = PRESS_LEV_LOW,
150         },
151 #else
152         {
153                 .desc   = "menu",
154                 .code   = EV_MENU,
155                 .adc_value      = 155,
156                 .gpio = INVALID_GPIO,
157                 .active_low = PRESS_LEV_LOW,
158         },
159         {
160                 .desc   = "home",
161                 .code   = KEY_HOME,
162                 .adc_value      = 630,
163                 .gpio = INVALID_GPIO,
164                 .active_low = PRESS_LEV_LOW,
165         },
166         {
167                 .desc   = "esc",
168                 .code   = KEY_BACK,
169                 .adc_value      = 386,
170                 .gpio = INVALID_GPIO,
171                 .active_low = PRESS_LEV_LOW,
172         },
173         {
174                 .desc   = "camera",
175                 .code   = KEY_CAMERA,
176                 .adc_value      = 827,
177                 .gpio = INVALID_GPIO,
178                 .active_low = PRESS_LEV_LOW,
179         },
180 #endif
181 };
182
183 struct rk29_keys_platform_data rk29_keys_pdata = {
184         .buttons        = key_button,
185         .nbuttons       = ARRAY_SIZE(key_button),
186         .chn    = 1,  //chn: 0-7, if do not use ADC,set 'chn' -1
187 };
188
189 #if defined (CONFIG_RK_HEADSET_DET) || defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
190
191 static int rk_headset_io_init(int gpio)
192 {
193                 int ret;
194                 ret = gpio_request(gpio, "headset_input");
195                 if(ret) 
196                         return ret;
197
198                 rk30_mux_api_set(GPIO0C7_TRACECTL_SMCADDR3_NAME, GPIO0C_GPIO0C7);
199                 gpio_pull_updown(gpio, PullDisable);
200                 gpio_direction_input(gpio);
201                 mdelay(50);
202                 return 0;
203 };
204
205 struct rk_headset_pdata rk_headset_info = {
206                 .Headset_gpio           = RK30_PIN0_PC7,
207                 .headset_in_type = HEADSET_IN_LOW,
208                 .Hook_adc_chn = 2,
209                 .hook_key_code = KEY_MEDIA,
210                 .headset_io_init = rk_headset_io_init, 
211 };
212
213 struct platform_device rk_device_headset = {
214                 .name   = "rk_headsetdet",
215                 .id     = 0,
216                 .dev    = {
217                             .platform_data = &rk_headset_info,
218                 }
219 };
220 #endif
221 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
222 #define TOUCH_RESET_PIN  RK30_PIN4_PD0
223 #define TOUCH_PWR_PIN    INVALID_GPIO
224 int goodix_init_platform_hw(void)
225 {
226         int ret;
227         
228         rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
229         rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
230         printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
231
232         if (TOUCH_PWR_PIN != INVALID_GPIO) {
233                 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
234                 if (ret != 0) {
235                         gpio_free(TOUCH_PWR_PIN);
236                         printk("goodix power error\n");
237                         return -EIO;
238                 }
239                 gpio_direction_output(TOUCH_PWR_PIN, 0);
240                 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
241                 msleep(100);
242         }
243
244         if (TOUCH_RESET_PIN != INVALID_GPIO) {
245                 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
246                 if (ret != 0) {
247                         gpio_free(TOUCH_RESET_PIN);
248                         printk("goodix gpio_request error\n");
249                         return -EIO;
250                 }
251                 gpio_direction_output(TOUCH_RESET_PIN, 1);
252                 msleep(100);
253                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
254                 //msleep(100);
255                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
256                 //msleep(500);
257         }
258         return 0;
259 }
260
261 struct goodix_platform_data goodix_info = {
262         .model = 8105,
263         .irq_pin = RK30_PIN4_PC2,
264         .rest_pin = TOUCH_RESET_PIN,
265         .init_platform_hw = goodix_init_platform_hw,
266 };
267 #endif
268
269 static struct spi_board_info board_spi_devices[] = {
270 };
271
272 /***********************************************************
273 *       rk30  backlight
274 ************************************************************/
275 #ifdef CONFIG_BACKLIGHT_RK29_BL
276 #define PWM_ID            0
277 #define PWM_MUX_NAME      GPIO0A3_PWM0_NAME
278 #define PWM_MUX_MODE      GPIO0A_PWM0
279 #define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
280 #define PWM_GPIO         RK30_PIN0_PA3
281 #define PWM_EFFECT_VALUE  1
282
283 #define LCD_DISP_ON_PIN
284
285 #ifdef  LCD_DISP_ON_PIN
286 //#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
287 //#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
288
289 #define BL_EN_PIN         RK30_PIN6_PB3
290 #define BL_EN_VALUE       GPIO_HIGH
291 #endif
292 static int rk29_backlight_io_init(void)
293 {
294         int ret = 0;
295         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
296 #ifdef  LCD_DISP_ON_PIN
297         // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
298
299         ret = gpio_request(BL_EN_PIN, NULL);
300         if (ret != 0) {
301                 gpio_free(BL_EN_PIN);
302         }
303
304         gpio_direction_output(BL_EN_PIN, 0);
305         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
306 #endif
307         return ret;
308 }
309
310 static int rk29_backlight_io_deinit(void)
311 {
312         int ret = 0;
313 #ifdef  LCD_DISP_ON_PIN
314         gpio_free(BL_EN_PIN);
315 #endif
316         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
317         return ret;
318 }
319
320 static int rk29_backlight_pwm_suspend(void)
321 {
322         int ret = 0;
323         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
324         if (gpio_request(PWM_GPIO, NULL)) {
325                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
326                 return -1;
327         }
328         gpio_direction_input(PWM_GPIO);
329 #ifdef  LCD_DISP_ON_PIN
330         gpio_direction_output(BL_EN_PIN, 0);
331         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
332 #endif
333         return ret;
334 }
335
336 static int rk29_backlight_pwm_resume(void)
337 {
338         gpio_free(PWM_GPIO);
339         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
340 #ifdef  LCD_DISP_ON_PIN
341         msleep(30);
342         gpio_direction_output(BL_EN_PIN, 1);
343         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
344 #endif
345         return 0;
346 }
347
348 static struct rk29_bl_info rk29_bl_info = {
349         .pwm_id = PWM_ID,
350         .bl_ref = PWM_EFFECT_VALUE,
351         .io_init = rk29_backlight_io_init,
352         .io_deinit = rk29_backlight_io_deinit,
353         .pwm_suspend = rk29_backlight_pwm_suspend,
354         .pwm_resume = rk29_backlight_pwm_resume,
355 };
356
357 static struct platform_device rk29_device_backlight = {
358         .name   = "rk29_backlight",
359         .id     = -1,
360         .dev    = {
361                 .platform_data  = &rk29_bl_info,
362         }
363 };
364
365 #endif
366
367 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
368
369 #define DIFFERENTIAL 1
370 #define SINGLE_END 0
371 #define TWO_SPK 2
372 #define ONE_SPK 1
373
374 enum {
375         SPK_AMPLIFY_ZERO_POINT_FIVE_WATT=1,
376         SPK_AMPLIFY_ZERO_POINT_SIX_WATT,
377         SPK_AMPLIFY_ZERO_POINT_EIGHT_WATT,
378         SPK_AMPLIFY_ONE_WATT,
379 };
380
381 enum {
382         LR_NORMAL,
383         LR_SWAP,
384         LEFT_COPY_TO_RIGHT,
385         RIGHT_COPY_LEFT,
386 };
387
388 static int rt3261_io_init(int gpio, char *iomux_name, int iomux_mode)
389 {
390         gpio_request(gpio,NULL);
391         rk30_mux_api_set(iomux_name, iomux_mode);
392         gpio_direction_output(gpio,1);
393         
394 };
395
396 static struct rt3261_platform_data rt3261_info = {
397         .codec_en_gpio                  = RK30_PIN4_PD7,
398         .codec_en_gpio_info             = {GPIO4D7_SMCDATA15_TRACEDATA15_NAME,GPIO4D_GPIO4D7},
399         .io_init                        = rt3261_io_init,
400         .spk_num                        = TWO_SPK,
401         .modem_input_mode               = DIFFERENTIAL,
402         .lout_to_modem_mode             = DIFFERENTIAL,
403         .spk_amplify                    = SPK_AMPLIFY_ZERO_POINT_SIX_WATT,
404         .playback_if1_data_control      = LR_NORMAL,
405         .playback_if2_data_control      = LR_NORMAL,
406 };
407 #endif
408
409 #if defined(CONFIG_BP_AUTO)
410 static int bp_io_init(void)
411 {
412          rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
413          rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
414          rk30_mux_api_set(GPIO4C6_SMCDATA6_TRACEDATA6_NAME, GPIO4C_GPIO4C6);
415          rk30_mux_api_set(GPIO4C4_SMCDATA4_TRACEDATA4_NAME, GPIO4C_GPIO4C4);
416          //rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
417          //rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
418         return 0;
419 }
420
421 static int bp_io_deinit(void)
422 {
423         
424         return 0;
425 }
426 static int bp_id_get(void)
427 {       
428         return ap_mdm;   //internally 3G modem ID, defined in  include\linux\Bp-auto.h
429 }
430
431 struct bp_platform_data bp_auto_info = {
432         .init_platform_hw       = bp_io_init,   
433         .exit_platform_hw       = bp_io_deinit,
434         .get_bp_id              = bp_id_get,
435         .bp_power               = RK30_PIN6_PB2,        // 3g_power
436         .bp_en                  = RK30_PIN2_PB6,        // 3g_en
437         .bp_reset                       = RK30_PIN4_PD2,
438         .bp_usb_en              = BP_UNKNOW_DATA,       //W_disable
439         .bp_uart_en             = BP_UNKNOW_DATA,       //EINT9
440         .bp_wakeup_ap   = RK30_PIN4_PC6,        //
441         .ap_wakeup_bp   = RK30_PIN4_PC4,
442         .ap_ready               = BP_UNKNOW_DATA,       //
443         .bp_ready               = BP_UNKNOW_DATA,
444         .gpio_valid             = 1,            //if 1:gpio is define in bp_auto_info,if 0:is not use gpio in bp_auto_info
445 };
446
447 struct platform_device device_bp_auto = {       
448         .name = "bp-auto",      
449         .id = -1,       
450         .dev            = {
451                 .platform_data = &bp_auto_info,
452         }       
453     };
454 #endif
455 #ifdef CONFIG_RK29_SUPPORT_MODEM
456
457 #define RK30_MODEM_POWER        RK30_PIN4_PD1
458 #define RK30_MODEM_POWER_IOMUX  rk29_mux_api_set(GPIO4D1_SMCDATA9_TRACEDATA9_NAME, GPIO4D_GPIO4D1)
459
460 static int rk30_modem_io_init(void)
461 {
462     printk("%s\n", __FUNCTION__);
463     RK30_MODEM_POWER_IOMUX;
464
465         return 0;
466 }
467
468 static struct rk29_io_t rk30_modem_io = {
469     .io_addr    = RK30_MODEM_POWER,
470     .enable     = GPIO_HIGH,
471     .disable    = GPIO_LOW,
472     .io_init    = rk30_modem_io_init,
473 };
474
475 static struct platform_device rk30_device_modem = {
476         .name   = "rk30_modem",
477         .id     = -1,
478         .dev    = {
479                 .platform_data  = &rk30_modem_io,
480         }
481 };
482 #endif
483 #if defined(CONFIG_MU509)
484 static int mu509_io_init(void)
485 {
486
487         rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
488         rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
489         rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
490         rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
491         return 0;
492 }
493
494 static int mu509_io_deinit(void)
495 {
496         
497         return 0;
498 }
499  
500 struct rk29_mu509_data rk29_mu509_info = {
501         .io_init = mu509_io_init,
502         .io_deinit = mu509_io_deinit,
503         .modem_power_en = RK30_PIN6_PB2,//RK30_PIN4_PD1,
504         .bp_power = RK30_PIN2_PB6,//RK30_PIN4_PD1,
505         .bp_reset = RK30_PIN4_PD2,
506         .ap_wakeup_bp = RK30_PIN2_PB7,
507         .bp_wakeup_ap = RK30_PIN6_PA0, 
508 };
509 struct platform_device rk29_device_mu509 = {    
510         .name = "mu509",        
511         .id = -1,       
512         .dev            = {
513                 .platform_data = &rk29_mu509_info,
514         }       
515     };
516 #endif
517 #if defined(CONFIG_MW100)
518 static int mw100_io_init(void)
519 {
520          rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
521          rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
522          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
523          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
524         return 0;
525 }
526
527 static int mw100_io_deinit(void)
528 {
529         
530         return 0;
531 }
532  
533 struct rk29_mw100_data rk29_mw100_info = {
534         .io_init = mw100_io_init,
535         .io_deinit = mw100_io_deinit,
536         .modem_power_en = RK30_PIN6_PB2,
537         .bp_power = RK30_PIN2_PB6,
538         .bp_reset = RK30_PIN4_PD2,
539         .ap_wakeup_bp = RK30_PIN2_PB7,
540         .bp_wakeup_ap = RK30_PIN6_PA0,
541 };
542 struct platform_device rk29_device_mw100 = {    
543         .name = "mw100",        
544         .id = -1,       
545         .dev            = {
546                 .platform_data = &rk29_mw100_info,
547         }       
548     };
549 #endif
550 #if defined(CONFIG_MT6229)
551 static int mt6229_io_init(void)
552 {
553          rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
554          rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
555          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
556          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
557          rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
558          rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
559         return 0;
560
561          return 0;
562 }
563
564 static int mt6229_io_deinit(void)
565 {
566         
567         return 0;
568 }
569  
570 struct rk29_mt6229_data rk29_mt6229_info = {
571         .io_init = mt6229_io_init,
572         .io_deinit = mt6229_io_deinit,
573         .modem_power_en = RK30_PIN6_PB2,
574         .bp_power = RK30_PIN2_PB6,
575         .modem_usb_en = RK30_PIN2_PC0,
576         .modem_uart_en = RK30_PIN2_PC1,
577         .bp_wakeup_ap = RK30_PIN6_PA1,
578         .ap_ready = RK30_PIN2_PB7,
579
580 };
581 struct platform_device rk29_device_mt6229 = {   
582         .name = "mt6229",       
583         .id = -1,       
584         .dev            = {
585                 .platform_data = &rk29_mt6229_info,
586         }       
587     };
588 #endif
589 #if defined(CONFIG_SEW868)
590 static int sew868_io_init(void)
591 {
592         rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
593     rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
594         rk30_mux_api_set(GPIO4D4_SMCDATA12_TRACEDATA12_NAME, GPIO4D_GPIO4D4);
595         return 0;
596 }
597 static int sew868_io_deinit(void)
598 {
599         return 0;
600 }
601 struct rk30_sew868_data rk30_sew868_info = {
602         .io_init = sew868_io_init,
603         .io_deinit = sew868_io_deinit,
604         .bp_power = RK30_PIN6_PB2, 
605         .bp_power_active_low = 1,
606         .bp_sys = RK30_PIN2_PB6, 
607         .bp_reset = RK30_PIN4_PD2, 
608         .bp_reset_active_low = 1,
609         .bp_wakeup_ap = RK30_PIN4_PD4, 
610         .ap_wakeup_bp = NULL,
611 };
612
613 struct platform_device rk30_device_sew868 = {   
614         .name = "sew868",       
615         .id = -1,       
616         .dev            = {
617                 .platform_data = &rk30_sew868_info,
618         }       
619     };
620 #endif
621
622 /*MMA8452 gsensor*/
623 #if defined (CONFIG_GS_MMA8452)
624 #define MMA8452_INT_PIN   RK30_PIN4_PC0
625
626 static int mma8452_init_platform_hw(void)
627 {
628         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
629
630         return 0;
631 }
632
633 static struct sensor_platform_data mma8452_info = {
634         .type = SENSOR_TYPE_ACCEL,
635         .irq_enable = 1,
636         .poll_delay_ms = 30,
637         .init_platform_hw = mma8452_init_platform_hw,
638         .orientation = {-1, 0, 0, 0,-1, 0, 0, 0, 1},
639 };
640 #endif
641 #if defined (CONFIG_GS_LIS3DH)
642 #define LIS3DH_INT_PIN   RK30_PIN4_PC0
643
644 static int lis3dh_init_platform_hw(void)
645 {
646         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
647
648         return 0;
649 }
650
651 static struct sensor_platform_data lis3dh_info = {
652         .type = SENSOR_TYPE_ACCEL,
653         .irq_enable = 1,
654         .poll_delay_ms = 30,
655         .init_platform_hw = lis3dh_init_platform_hw,
656         .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
657 };
658 #endif
659 #if defined (CONFIG_GS_KXTIK)
660 #define KXTIK_INT_PIN   RK30_PIN4_PC0
661
662 static int kxtik_init_platform_hw(void)
663 {
664         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
665
666         return 0;
667 }
668
669 static struct sensor_platform_data kxtik_info = {
670         .type = SENSOR_TYPE_ACCEL,
671         .irq_enable = 1,
672         .poll_delay_ms = 30,
673         .init_platform_hw = kxtik_init_platform_hw,
674         .orientation = {0, 1, 0, 0, 0, -1, 1, 0, 0},
675 };
676
677 #endif
678 #if defined (CONFIG_COMPASS_AK8975)
679 static struct sensor_platform_data akm8975_info =
680 {
681         .type = SENSOR_TYPE_COMPASS,
682         .irq_enable = 1,
683         .poll_delay_ms = 30,
684         .m_layout = 
685         {
686                 {
687                         {1, 0, 0},
688                         {0, 1, 0},
689                         {0, 0, 1},
690                 },
691
692                 {
693                         {1, 0, 0},
694                         {0, 1, 0},
695                         {0, 0, 1},
696                 },
697
698                 {
699                         {1, 0, 0},
700                         {0, 1, 0},
701                         {0, 0, 1},
702                 },
703
704                 {
705                         {1, 0, 0},
706                         {0, 1, 0},
707                         {0, 0, 1},
708                 },
709         }
710 };
711
712 #endif
713
714 #if defined(CONFIG_GYRO_L3G4200D)
715
716 #include <linux/l3g4200d.h>
717 #define L3G4200D_INT_PIN  RK30_PIN4_PC3
718
719 static int l3g4200d_init_platform_hw(void)
720 {
721         rk30_mux_api_set(GPIO4C3_SMCDATA3_TRACEDATA3_NAME, GPIO4C_GPIO4C3);
722         
723         return 0;
724 }
725
726 static struct sensor_platform_data l3g4200d_info = {
727         .type = SENSOR_TYPE_GYROSCOPE,
728         .irq_enable = 1,
729         .poll_delay_ms = 30,
730         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
731         .init_platform_hw = l3g4200d_init_platform_hw,
732         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
733         .y_min = 40,
734         .z_min = 20,
735 };
736
737 #endif
738
739 #ifdef CONFIG_LS_CM3217
740 static struct sensor_platform_data cm3217_info = {
741         .type = SENSOR_TYPE_LIGHT,
742         .irq_enable = 0,
743         .poll_delay_ms = 500,
744 };
745
746 #endif
747
748 #if defined(CONFIG_PS_AL3006)
749 static struct sensor_platform_data proximity_al3006_info = {
750         .type = SENSOR_TYPE_PROXIMITY,
751         .irq_enable = 1,
752         .poll_delay_ms = 200,
753 };
754 #endif
755
756 #if defined(CONFIG_PS_STK3171)
757 static struct sensor_platform_data proximity_stk3171_info = {
758         .type = SENSOR_TYPE_PROXIMITY,
759         .irq_enable = 1,
760         .poll_delay_ms = 200,
761 };
762 #endif
763
764
765 #if defined(CONFIG_LS_AL3006)
766 static struct sensor_platform_data light_al3006_info = {
767         .type = SENSOR_TYPE_LIGHT,
768         .irq_enable = 1,
769         .poll_delay_ms = 200,
770 };
771 #endif
772
773 #if defined(CONFIG_LS_STK3171)
774 static struct sensor_platform_data light_stk3171_info = {
775         .type = SENSOR_TYPE_LIGHT,
776         .irq_enable = 1,
777         .poll_delay_ms = 200,
778 };
779 #endif
780 #ifdef CONFIG_FB_ROCKCHIP
781
782 #define LCD_CS_PIN         RK30_PIN4_PC7
783 #define LCD_CS_VALUE       GPIO_HIGH
784
785 #define LCD_EN_PIN         RK30_PIN6_PB4
786 #define LCD_EN_VALUE       GPIO_LOW
787
788 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
789 {
790         int ret = 0;
791
792         if(LCD_CS_PIN != INVALID_GPIO)
793         {
794                 ret = gpio_request(LCD_CS_PIN, NULL);
795                 if (ret != 0)
796                 {
797                         gpio_free(LCD_CS_PIN);
798                         printk(KERN_ERR "request lcd cs pin fail!\n");
799                         return -1;
800                 }
801                 else
802                 {
803                         gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
804                 }
805         }
806
807         if(LCD_EN_PIN != INVALID_GPIO)
808         {
809                 ret = gpio_request(LCD_EN_PIN, NULL);
810                 if (ret != 0)
811                 {
812                         gpio_free(LCD_EN_PIN);
813                         printk(KERN_ERR "request lcd en pin fail!\n");
814                         return -1;
815                 }
816                 else
817                 {
818                         gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
819                 }
820         }
821         return 0;
822 }
823 static int rk_fb_io_disable(void)
824 {
825         if(LCD_CS_PIN != INVALID_GPIO)
826         {
827                 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
828         }
829
830         if(LCD_EN_PIN != INVALID_GPIO)
831         {
832                 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
833         }
834         return 0;
835 }
836 static int rk_fb_io_enable(void)
837 {
838         if(LCD_CS_PIN != INVALID_GPIO)
839         {
840                 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
841         }
842         if(LCD_EN_PIN != INVALID_GPIO)
843         {
844                 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
845         }
846         return 0;
847 }
848
849 #if defined(CONFIG_LCDC0_RK30)
850 struct rk29fb_info lcdc0_screen_info = {
851 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC0) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
852                 .prop      = EXTEND,    //extend display device
853                 .io_init    = NULL,
854                 .io_disable = NULL,
855                 .io_enable = NULL,
856                 .set_screen_info = hdmi_init_lcdc,
857 #else
858                 .prop      = PRMRY,             //primary display device
859                 .io_init   = rk_fb_io_init,
860                 .io_disable = rk_fb_io_disable,
861                 .io_enable = rk_fb_io_enable,
862                 .set_screen_info = set_lcd_info,
863 #endif
864
865 };
866 #endif
867
868 #if defined(CONFIG_LCDC1_RK30)
869 struct rk29fb_info lcdc1_screen_info = {
870 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC1) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
871                 .prop      = EXTEND,    //extend display device
872                 .io_init    = NULL,
873                 .io_disable = NULL,
874                 .io_enable = NULL,
875                 .set_screen_info = hdmi_init_lcdc,
876 #else
877                 .prop      = PRMRY,             //primary display device
878                 .io_init   = rk_fb_io_init,
879                 .io_disable = rk_fb_io_disable,
880                 .io_enable = rk_fb_io_enable,
881                 .set_screen_info = set_lcd_info,
882 #endif
883
884 };
885 #endif
886
887 static struct resource resource_fb[] = {
888         [0] = {
889                 .name  = "fb0 buf",
890                 .start = 0,
891                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
892                 .flags = IORESOURCE_MEM,
893         },
894         [1] = {
895                 .name  = "ipp buf",  //for rotate
896                 .start = 0,
897                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
898                 .flags = IORESOURCE_MEM,
899         },
900         [2] = {
901                 .name  = "fb2 buf",
902                 .start = 0,
903                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
904                 .flags = IORESOURCE_MEM,
905         },
906 };
907
908 static struct platform_device device_fb = {
909         .name           = "rk-fb",
910         .id             = -1,
911         .num_resources  = ARRAY_SIZE(resource_fb),
912         .resource       = resource_fb,
913 };
914 #endif
915
916 #if defined(CONFIG_LCDC0_RK30)
917 static struct resource resource_lcdc0[] = {
918         [0] = {
919                 .name  = "lcdc0 reg",
920                 .start = RK30_LCDC0_PHYS,
921                 .end   = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
922                 .flags = IORESOURCE_MEM,
923         },
924         
925         [1] = {
926                 .name  = "lcdc0 irq",
927                 .start = IRQ_LCDC0,
928                 .end   = IRQ_LCDC0,
929                 .flags = IORESOURCE_IRQ,
930         },
931 };
932
933 static struct platform_device device_lcdc0 = {
934         .name             = "rk30-lcdc",
935         .id               = 0,
936         .num_resources    = ARRAY_SIZE(resource_lcdc0),
937         .resource         = resource_lcdc0,
938         .dev            = {
939                 .platform_data = &lcdc0_screen_info,
940         },
941 };
942 #endif
943 #if defined(CONFIG_LCDC1_RK30) 
944 extern struct rk29fb_info lcdc1_screen_info;
945 static struct resource resource_lcdc1[] = {
946         [0] = {
947                 .name  = "lcdc1 reg",
948                 .start = RK30_LCDC1_PHYS,
949                 .end   = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
950                 .flags = IORESOURCE_MEM,
951         },
952         [1] = {
953                 .name  = "lcdc1 irq",
954                 .start = IRQ_LCDC1,
955                 .end   = IRQ_LCDC1,
956                 .flags = IORESOURCE_IRQ,
957         },
958 };
959
960 static struct platform_device device_lcdc1 = {
961         .name             = "rk30-lcdc",
962         .id               = 1,
963         .num_resources    = ARRAY_SIZE(resource_lcdc1),
964         .resource         = resource_lcdc1,
965         .dev            = {
966                 .platform_data = &lcdc1_screen_info,
967         },
968 };
969 #endif
970
971 #if defined(CONFIG_DP501)
972         #define DVDD33_EN_PIN           RK30_PIN6_PB4
973         #define DVDD33_EN_VALUE         GPIO_LOW
974
975         #define DVDD12_EN_PIN           RK30_PIN4_PC7
976         #define DVDD12_EN_VALUE         GPIO_HIGH
977
978         #define EDP_RST_PIN             RK30_PIN2_PC4
979         static int rk_edp_power_ctl(void)
980         {
981                 int ret;
982                 ret = gpio_request(DVDD33_EN_PIN, "dvdd33_en_pin");
983                 if (ret != 0)
984                 {
985                         gpio_free(DVDD33_EN_PIN);
986                         printk(KERN_ERR "request dvdd33 en pin fail!\n");
987                         return -1;
988                 }
989                 else
990                 {
991                         gpio_direction_output(DVDD33_EN_PIN, DVDD33_EN_VALUE);
992                 }
993
994                 ret = gpio_request(DVDD12_EN_PIN, "dvdd18_en_pin");
995                 if (ret != 0)
996                 {
997                         gpio_free(DVDD12_EN_PIN);
998                         printk(KERN_ERR "request dvdd18 en pin fail!\n");
999                         return -1;
1000                 }
1001                 else
1002                 {
1003                         gpio_direction_output(DVDD12_EN_PIN, DVDD12_EN_VALUE);
1004                 }
1005
1006                 ret = gpio_request(EDP_RST_PIN, "edp_rst_pin");
1007                 if (ret != 0)
1008                 {
1009                         gpio_free(EDP_RST_PIN);
1010                         printk(KERN_ERR "request rst pin fail!\n");
1011                         return -1;
1012                 }
1013                 else
1014                 {       
1015                         gpio_direction_output(EDP_RST_PIN, GPIO_LOW);
1016                         msleep(10);
1017                         gpio_direction_output(EDP_RST_PIN, GPIO_HIGH);
1018                 }
1019                 return 0;
1020
1021         }
1022         static struct dp501_platform_data dp501_platform_data = {
1023                 .power_ctl      = rk_edp_power_ctl,
1024                 .dvdd33_en_pin  = DVDD33_EN_PIN,
1025                 .dvdd33_en_val  = DVDD33_EN_VALUE,
1026                 .dvdd18_en_pin  = DVDD12_EN_PIN,
1027                 .dvdd18_en_val  = DVDD12_EN_VALUE,
1028                 .edp_rst_pin    = EDP_RST_PIN,
1029         };
1030 #endif
1031
1032 #if defined(CONFIG_MFD_RK610)
1033 #define RK610_RST_PIN_MUX_NAME          GPIO0C6_TRACECLK_SMCADDR2_NAME  
1034 #define RK610_RST_PIN_MUX_MODE          GPIO0C_GPIO0C6
1035 #define RK610_RST_PIN                   RK30_PIN0_PC6
1036 static int rk610_power_on_init(void)
1037 {
1038         int ret;
1039         if(RK610_RST_PIN != INVALID_GPIO)
1040         {
1041                 rk30_mux_api_set(RK610_RST_PIN_MUX_NAME,RK610_RST_PIN_MUX_MODE);
1042                 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
1043                 if (ret)
1044                 {
1045                         printk(KERN_ERR "rk610_control_probe request gpio fail\n");
1046                 }
1047                 else 
1048                 {
1049                         gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
1050                         msleep(100);
1051                         gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
1052                         msleep(100);
1053                         gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
1054                 }
1055         }
1056
1057         return 0;
1058         
1059 }
1060
1061
1062 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
1063         .rk610_power_on_init = rk610_power_on_init,
1064 };
1065 #endif
1066 #ifdef CONFIG_SND_SOC_RK610
1067 static int rk610_codec_io_init(void)
1068 {
1069 //if need iomux.
1070 //Must not gpio_request
1071         return 0;
1072 }
1073
1074 static struct rk610_codec_platform_data rk610_codec_pdata = {
1075         .spk_ctl_io = RK30_PIN4_PC6,
1076         .io_init = rk610_codec_io_init,
1077 };
1078 #endif
1079 #ifdef CONFIG_ANDROID_TIMED_GPIO
1080 static struct timed_gpio timed_gpios[] = {
1081         {
1082                 .name = "vibrator",
1083                 .gpio = RK30_PIN0_PA4,
1084                 .max_timeout = 1000,
1085                 .active_low = 0,
1086                 .adjust_time =20,      //adjust for diff product
1087         },
1088 };
1089
1090 static struct timed_gpio_platform_data rk29_vibrator_info = {
1091         .num_gpios = 1,
1092         .gpios = timed_gpios,
1093 };
1094
1095 static struct platform_device rk29_device_vibrator = {
1096         .name = "timed-gpio",
1097         .id = -1,
1098         .dev = {
1099                 .platform_data = &rk29_vibrator_info,
1100         },
1101
1102 };
1103 #endif
1104
1105 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1106 static struct gpio_led rk29_leds[] = {
1107         {
1108                 .name = "button-backlight",
1109                 .gpio = RK30_PIN4_PD7,
1110                 .default_trigger = "timer",
1111                 .active_low = 0,
1112                 .retain_state_suspended = 0,
1113                 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1114         },
1115 };
1116
1117 static struct gpio_led_platform_data rk29_leds_pdata = {
1118         .leds = rk29_leds,
1119         .num_leds = ARRAY_SIZE(rk29_leds),
1120 };
1121
1122 static struct platform_device rk29_device_gpio_leds = {
1123         .name   = "leds-gpio",
1124         .id     = -1,
1125         .dev    = {
1126                 .platform_data  = &rk29_leds_pdata,
1127         },
1128 };
1129 #endif
1130
1131 #ifdef CONFIG_RK_IRDA
1132 #define IRDA_IRQ_PIN           RK30_PIN6_PA1
1133
1134 static int irda_iomux_init(void)
1135 {
1136         int ret = 0;
1137
1138         //irda irq pin
1139         ret = gpio_request(IRDA_IRQ_PIN, NULL);
1140         if (ret != 0) {
1141                 gpio_free(IRDA_IRQ_PIN);
1142                 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1143         }
1144         gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
1145         gpio_direction_input(IRDA_IRQ_PIN);
1146
1147         return 0;
1148 }
1149
1150 static int irda_iomux_deinit(void)
1151 {
1152         gpio_free(IRDA_IRQ_PIN);
1153         return 0;
1154 }
1155
1156 static struct irda_info rk29_irda_info = {
1157         .intr_pin = IRDA_IRQ_PIN,
1158         .iomux_init = irda_iomux_init,
1159         .iomux_deinit = irda_iomux_deinit,
1160         //.irda_pwr_ctl = bu92747guw_power_ctl,
1161 };
1162
1163 static struct platform_device irda_device = {
1164 #ifdef CONFIG_RK_IRDA_NET
1165         .name = "rk_irda",
1166 #else
1167         .name = "bu92747_irda",
1168 #endif
1169         .id = -1,
1170         .dev = {
1171                 .platform_data = &rk29_irda_info,
1172         }
1173 };
1174 #endif
1175
1176 #ifdef CONFIG_ION
1177 #define ION_RESERVE_SIZE        (80 * SZ_1M)
1178 static struct ion_platform_data rk30_ion_pdata = {
1179         .nr = 1,
1180         .heaps = {
1181                 {
1182                         .type = ION_HEAP_TYPE_CARVEOUT,
1183                         .id = ION_NOR_HEAP_ID,
1184                         .name = "norheap",
1185                         .size = ION_RESERVE_SIZE,
1186                 }
1187         },
1188 };
1189
1190 static struct platform_device device_ion = {
1191         .name = "ion-rockchip",
1192         .id = 0,
1193         .dev = {
1194                 .platform_data = &rk30_ion_pdata,
1195         },
1196 };
1197 #endif
1198
1199 /**************************************************************************************************
1200  * SDMMC devices,  include the module of SD,MMC,and SDIO.noted by xbw at 2012-03-05
1201 **************************************************************************************************/
1202 #ifdef CONFIG_SDMMC_RK29
1203 #include "board-rk30-sdk-sdmmc.c"
1204 #endif
1205
1206 #ifdef CONFIG_SDMMC0_RK29
1207 static int rk29_sdmmc0_cfg_gpio(void)
1208 {
1209 #ifdef CONFIG_SDMMC_RK29_OLD
1210         rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
1211         rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
1212         rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
1213         rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
1214         rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
1215         rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
1216
1217         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
1218
1219         rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
1220         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
1221         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
1222
1223 #else
1224             rk29_sdmmc_set_iomux(0, 0xFFFF);
1225
1226     #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
1227         rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
1228     #else
1229             rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
1230     #endif      
1231
1232     #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1233             gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1234             gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1235     #endif
1236
1237 #endif
1238
1239         return 0;
1240 }
1241
1242 #define CONFIG_SDMMC0_USE_DMA
1243 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1244         .host_ocr_avail =
1245             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1246              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1247              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1248         .host_caps =
1249             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1250         .io_init = rk29_sdmmc0_cfg_gpio,
1251
1252 #if !defined(CONFIG_SDMMC_RK29_OLD)
1253         .set_iomux = rk29_sdmmc_set_iomux,
1254 #endif
1255
1256         .dma_name = "sd_mmc",
1257 #ifdef CONFIG_SDMMC0_USE_DMA
1258         .use_dma = 1,
1259 #else
1260         .use_dma = 0,
1261 #endif
1262
1263 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
1264     .status = rk29sdk_wifi_mmc0_status,
1265     .register_status_notify = rk29sdk_wifi_mmc0_status_register,
1266 #endif
1267
1268 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
1269     .power_en = RK29SDK_SD_CARD_PWR_EN,
1270     .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
1271 #else
1272     .power_en = INVALID_GPIO,
1273     .power_en_level = GPIO_LOW,
1274 #endif    
1275         .enable_sd_wakeup = 0,
1276
1277 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1278         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1279         .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
1280 #else
1281         .write_prt = INVALID_GPIO,
1282 #endif
1283
1284     .det_pin_info = {    
1285     #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
1286         .io             = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
1287         .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
1288         #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1289         .iomux          = {
1290             .name       = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1291             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1292             .fgpio      = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1293             #endif
1294             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1295             .fmux       = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1296             #endif
1297         },
1298         #endif
1299     #else
1300         .io             = INVALID_GPIO,
1301         .enable         = GPIO_LOW,
1302     #endif    
1303     }, 
1304
1305 };
1306 #endif // CONFIG_SDMMC0_RK29
1307
1308 #ifdef CONFIG_SDMMC1_RK29
1309 #define CONFIG_SDMMC1_USE_DMA
1310 static int rk29_sdmmc1_cfg_gpio(void)
1311 {
1312 #if defined(CONFIG_SDMMC_RK29_OLD)
1313         rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
1314         rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
1315         rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
1316         rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
1317         rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
1318         rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
1319 #else
1320
1321 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1322         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1323         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1324 #endif
1325
1326 #endif
1327
1328         return 0;
1329 }
1330
1331 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1332         .host_ocr_avail =
1333             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1334              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1335              MMC_VDD_33_34),
1336
1337 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1338         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1339                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1340 #else
1341         .host_caps =
1342             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1343 #endif
1344
1345         .io_init = rk29_sdmmc1_cfg_gpio,
1346
1347 #if !defined(CONFIG_SDMMC_RK29_OLD)
1348         .set_iomux = rk29_sdmmc_set_iomux,
1349 #endif
1350
1351         .dma_name = "sdio",
1352 #ifdef CONFIG_SDMMC1_USE_DMA
1353         .use_dma = 1,
1354 #else
1355         .use_dma = 0,
1356 #endif
1357
1358 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1359     .status = rk29sdk_wifi_status,
1360     .register_status_notify = rk29sdk_wifi_status_register,
1361 #endif
1362
1363     #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1364         .write_prt = SDMMC1_WRITE_PROTECT_PIN,          
1365             .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1366     #else
1367         .write_prt = INVALID_GPIO,
1368     #endif
1369
1370     #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1371         .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1372     #endif
1373
1374     .det_pin_info = {    
1375 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1376      #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
1377         .io             = RK29SDK_SD_CARD_DETECT_N,
1378      #else
1379          .io             = INVALID_GPIO,
1380      #endif   
1381
1382         .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
1383         #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
1384         .iomux          = {
1385             .name       = RK29SDK_SD_CARD_DETECT_PIN_NAME,
1386             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
1387             .fgpio      = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
1388             #endif
1389             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
1390             .fmux       = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
1391             #endif
1392         },
1393         #endif
1394  #else
1395         .io             = INVALID_GPIO,
1396         .enable         = GPIO_LOW,
1397 #endif
1398     },
1399    
1400         .enable_sd_wakeup = 0,
1401 };
1402 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1403
1404 /**************************************************************************************************
1405  * the end of setting for SDMMC devices
1406 **************************************************************************************************/
1407
1408 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1409 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1410         .dc_det_pin      = RK30_PIN6_PA5,
1411         .batt_low_pin    = RK30_PIN6_PA0,
1412         .charge_set_pin  = INVALID_GPIO,
1413         .charge_ok_pin   = RK30_PIN6_PA6,
1414         .dc_det_level    = GPIO_LOW,
1415         .charge_ok_level = GPIO_HIGH,
1416 };
1417
1418 static struct platform_device rk30_device_adc_battery = {
1419         .name   = "rk30-battery",
1420         .id     = -1,
1421         .dev = {
1422                 .platform_data = &rk30_adc_battery_platdata,
1423         },
1424 };
1425 #endif
1426
1427 #ifdef CONFIG_RK30_PWM_REGULATOR
1428 const static int pwm_voltage_map[] = {
1429         950000,975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
1430 };
1431
1432 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1433         {
1434                 .supply = "vdd_core",
1435         }
1436 };
1437
1438 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1439 {
1440         {
1441                 .constraints = {
1442                         .name = "PWM_DCDC1",
1443                         .min_uV = 600000,
1444                         .max_uV = 1800000,      //0.6-1.8V
1445                         .apply_uV = true,
1446                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1447                 },
1448                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1449                 .consumer_supplies = pwm_dcdc1_consumers,
1450         },
1451 };
1452
1453 static struct pwm_platform_data pwm_regulator_info[1] = {
1454         {
1455                 .pwm_id = 3,
1456                 .pwm_gpio = RK30_PIN0_PD7,
1457                 .pwm_iomux_name = GPIO0D7_PWM3_NAME,
1458                 .pwm_iomux_pwm = GPIO0D_PWM3,
1459                 .pwm_iomux_gpio = GPIO0D_GPIO0D6,
1460                 .pwm_voltage = 1100000,
1461                 .suspend_voltage = 1050000,
1462                 .min_uV = 950000,
1463                 .max_uV = 1400000,
1464                 .coefficient = 455,     //45.5%
1465                 .pwm_voltage_map = pwm_voltage_map,
1466                 .init_data      = &pwm_regulator_init_dcdc[0],
1467         },
1468 };
1469
1470 struct platform_device pwm_regulator_device[1] = {
1471         {
1472                 .name = "pwm-voltage-regulator",
1473                 .id = 0,
1474                 .dev            = {
1475                         .platform_data = &pwm_regulator_info[0],
1476                 }
1477         },
1478 };
1479 #endif
1480
1481 #ifdef CONFIG_RK29_VMAC
1482 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1483 #include "board-rk30-sdk-vmac.c"
1484 #endif
1485
1486 #ifdef CONFIG_RFKILL_RK
1487 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1488 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1489     .type               = RFKILL_TYPE_BLUETOOTH,
1490
1491     .poweron_gpio       = { // BT_REG_ON
1492         .io             = RK30_PIN3_PC7,
1493         .enable         = GPIO_HIGH,
1494         .iomux          = {
1495             .name       = GPIO3C7_SDMMC1WRITEPRT_NAME,
1496             .fgpio      = GPIO3C_GPIO3C7,
1497         },
1498     },
1499
1500     .reset_gpio         = { // BT_RST
1501         .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1502         .enable         = GPIO_LOW,
1503         .iomux          = {
1504             .name       = GPIO3D1_SDMMC1BACKENDPWR_NAME,
1505             .fgpio      = GPIO3D_GPIO3D1,
1506         },
1507     },
1508
1509     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
1510         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1511         .enable         = GPIO_HIGH,
1512         .iomux          = {
1513             .name       = GPIO3C6_SDMMC1DETECTN_NAME,
1514             .fgpio      = GPIO3C_GPIO3C6,
1515         },
1516     },
1517
1518     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1519         .gpio           = {
1520             .io         = RK30_PIN6_PA7, // set io to INVALID_GPIO for disable it
1521             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
1522             .iomux      = {
1523                 .name   = NULL,
1524             },
1525         },
1526     },
1527
1528     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
1529         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1530         .enable         = GPIO_LOW,
1531         .iomux          = {
1532             .name       = GPIO1A3_UART0RTSN_NAME,
1533             .fgpio      = GPIO1A_GPIO1A3,
1534             .fmux       = GPIO1A_UART0_RTS_N,
1535         },
1536     },
1537 };
1538
1539 static struct platform_device device_rfkill_rk = {
1540     .name   = "rfkill_rk",
1541     .id     = -1,
1542     .dev    = {
1543         .platform_data = &rfkill_rk_platdata,
1544     },
1545 };
1546 #endif
1547
1548 #if defined(CONFIG_MT5931_MT6622)
1549 static struct mt6622_platform_data mt6622_platdata = {
1550     .power_gpio         = { // BT_REG_ON
1551         .io             = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1552         .enable         = GPIO_HIGH,
1553         .iomux          = {
1554             .name       = NULL,
1555         },
1556     },
1557
1558     .reset_gpio         = { // BT_RST
1559         .io             = RK30_PIN3_PD1,
1560         .enable         = GPIO_LOW,
1561         .iomux          = {
1562             .name       = NULL,
1563         },
1564     },
1565
1566     .irq_gpio           = {
1567         .io             = RK30_PIN6_PA7,
1568         .enable         = GPIO_HIGH,
1569         .iomux          = {
1570             .name       = NULL,
1571         },
1572     }
1573 };
1574
1575 static struct platform_device device_mt6622 = {
1576     .name   = "mt6622",
1577     .id     = -1,
1578     .dev    = {
1579         .platform_data = &mt6622_platdata,
1580     },
1581 };
1582 #endif
1583
1584 static struct platform_device *devices[] __initdata = {
1585 #ifdef CONFIG_ION
1586         &device_ion,
1587 #endif
1588 #ifdef CONFIG_ANDROID_TIMED_GPIO
1589         &rk29_device_vibrator,
1590 #endif
1591 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1592         &rk29_device_gpio_leds,
1593 #endif
1594 #ifdef CONFIG_RK_IRDA
1595         &irda_device,
1596 #endif
1597 #if defined(CONFIG_WIFI_CONTROL_FUNC)||defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1598         &rk29sdk_wifi_device,
1599 #endif
1600
1601 #if defined(CONFIG_MT6620)
1602     &mt3326_device_gps,
1603 #endif   
1604
1605 #ifdef CONFIG_RK29_SUPPORT_MODEM
1606         &rk30_device_modem,
1607 #endif
1608 #if defined(CONFIG_MU509)
1609   &rk29_device_mu509,
1610  #endif
1611 #if defined(CONFIG_MW100)
1612  &rk29_device_mw100,
1613 #endif
1614 #if defined(CONFIG_MT6229)
1615 &rk29_device_mt6229,
1616 #endif
1617 #if defined(CONFIG_SEW868)
1618 &rk30_device_sew868,
1619 #endif
1620 #if defined (CONFIG_RK_HEADSET_DET) ||  defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
1621         &rk_device_headset,
1622 #endif
1623
1624 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
1625         &rk30_device_adc_battery,
1626 #endif
1627 #ifdef CONFIG_RFKILL_RK
1628         &device_rfkill_rk,
1629 #endif
1630 #ifdef CONFIG_MT5931_MT6622
1631         &device_mt6622,
1632 #endif
1633 #if defined(CONFIG_BP_AUTO)
1634         &device_bp_auto,
1635 #endif
1636 };
1637
1638
1639 static int rk_platform_add_display_devices(void)
1640 {
1641         struct platform_device *fb = NULL;  //fb
1642         struct platform_device *lcdc0 = NULL; //lcdc0
1643         struct platform_device *lcdc1 = NULL; //lcdc1
1644         struct platform_device *bl = NULL; //backlight
1645 #ifdef CONFIG_FB_ROCKCHIP
1646         fb = &device_fb;
1647 #endif
1648
1649 #if defined(CONFIG_LCDC0_RK30)
1650         lcdc0 = &device_lcdc0,
1651 #endif
1652
1653 #if defined(CONFIG_LCDC1_RK30)
1654         lcdc1 = &device_lcdc1,
1655 #endif
1656
1657 #ifdef CONFIG_BACKLIGHT_RK29_BL
1658         bl = &rk29_device_backlight,
1659 #endif
1660         __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1661
1662         return 0;
1663         
1664 }
1665 // i2c
1666 #ifdef CONFIG_I2C0_RK30
1667 static struct i2c_board_info __initdata i2c0_info[] = {
1668 #if defined (CONFIG_GS_MMA8452)
1669         {
1670                 .type           = "gs_mma8452",
1671                 .addr           = 0x1d,
1672                 .flags          = 0,
1673                 .irq            = MMA8452_INT_PIN,
1674                 .platform_data = &mma8452_info,
1675         },
1676 #endif
1677 #if defined (CONFIG_GS_LIS3DH)
1678         {
1679                 .type           = "gs_lis3dh",
1680                 .addr           = 0x19,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
1681                 .flags          = 0,
1682                 .irq            = LIS3DH_INT_PIN,
1683                 .platform_data = &lis3dh_info,
1684         },
1685 #endif
1686 #if defined (CONFIG_GS_KXTIK)
1687         {
1688                 .type           = "gs_kxtik",
1689                 .addr           = 0x0F,
1690                 .flags          = 0,
1691                 .irq            = KXTIK_INT_PIN,
1692                 .platform_data = &kxtik_info,
1693         },
1694 #endif
1695 #if defined (CONFIG_COMPASS_AK8975)
1696         {
1697                 .type          = "ak8975",
1698                 .addr          = 0x0d,
1699                 .flags         = 0,
1700                 .irq           = RK30_PIN4_PC1,
1701                 .platform_data = &akm8975_info,
1702         },
1703 #endif
1704 #if defined (CONFIG_GYRO_L3G4200D)
1705         {
1706                 .type          = "l3g4200d_gryo",
1707                 .addr          = 0x69,
1708                 .flags         = 0,
1709                 .irq           = L3G4200D_INT_PIN,
1710                 .platform_data = &l3g4200d_info,
1711         },
1712 #endif
1713 #if defined (CONFIG_LS_AL3006)
1714         {
1715                 .type           = "light_al3006",
1716                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1717                 .flags          = 0,
1718                 .irq            = RK30_PIN6_PA2,        
1719                 .platform_data = &light_al3006_info,
1720         },
1721 #endif
1722 #if defined (CONFIG_LS_STK3171)
1723         {
1724                 .type           = "ls_stk3171",
1725                 .addr           = 0x48,            
1726                 .flags          = 0,
1727                 .irq            = RK30_PIN6_PA2,        
1728                 .platform_data = &light_stk3171_info,
1729         },
1730 #endif
1731
1732
1733 #if defined (CONFIG_PS_AL3006)
1734         {
1735                 .type           = "proximity_al3006",
1736                 .addr           = 0x1c,             //sel = 0; if sel =1, then addr = 0x1D
1737                 .flags          = 0,
1738                 .irq            = RK30_PIN6_PA2,        
1739                 .platform_data = &proximity_al3006_info,
1740         },
1741 #endif
1742
1743 #if defined (CONFIG_PS_STK3171)
1744         {
1745                 .type           = "ps_stk3171",
1746                 .addr           = 0x48,            
1747                 .flags          = 0,
1748                 .irq            = RK30_PIN6_PA2,        
1749                 .platform_data = &proximity_stk3171_info,
1750         },
1751 #endif
1752 #if defined (CONFIG_SND_SOC_RK1000)
1753         {
1754                 .type          = "rk1000_i2c_codec",
1755                 .addr          = 0x60,
1756                 .flags         = 0,
1757         },
1758         {
1759                 .type          = "rk1000_control",
1760                 .addr          = 0x40,
1761                 .flags         = 0,
1762         },
1763 #endif
1764 #if defined (CONFIG_SND_SOC_RT5631) || defined (CONFIG_SND_SOC_RT5631_PHONE)
1765         {
1766                 .type                   = "rt5631",
1767                 .addr                   = 0x1a,
1768                 .flags                  = 0,
1769         },
1770 #endif
1771 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
1772         {
1773                 .type                   = "rt3261",
1774                 .addr                   = 0x1c,
1775                 .flags                  = 0,
1776                                 .platform_data          = &rt3261_info,
1777         },
1778 #endif
1779
1780 #ifdef CONFIG_MFD_RK610
1781                 {
1782                         .type                   = "rk610_ctl",
1783                         .addr                   = 0x40,
1784                         .flags                  = 0,
1785                         .platform_data          = &rk610_ctl_pdata,
1786                 },
1787 #ifdef CONFIG_RK610_TVOUT
1788                 {
1789                         .type                   = "rk610_tvout",
1790                         .addr                   = 0x42,
1791                         .flags                  = 0,
1792                 },
1793 #endif
1794 #ifdef CONFIG_HDMI_RK610
1795                 {
1796                         .type                   = "rk610_hdmi",
1797                         .addr                   = 0x46,
1798                         .flags                  = 0,
1799                         .irq                    = INVALID_GPIO,
1800                 },
1801 #endif
1802 #ifdef CONFIG_SND_SOC_RK610
1803                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1804                         .type                   = "rk610_i2c_codec",
1805                         .addr                   = 0x60,
1806                         .flags                  = 0,
1807                         .platform_data          = &rk610_codec_pdata,                                   
1808                 },
1809 #endif
1810 #endif
1811
1812 };
1813 #endif
1814 int __sramdata g_pmic_type =  0;
1815 #ifdef CONFIG_I2C1_RK30
1816 #ifdef CONFIG_MFD_WM831X_I2C
1817 #include "board-rk30-sdk-wm8326.c"
1818 #endif
1819 #ifdef CONFIG_MFD_TPS65910
1820 #define TPS65910_HOST_IRQ        RK30_PIN6_PA4
1821 #include "board-rk30-sdk-tps65910.c"
1822 #endif
1823
1824 static struct i2c_board_info __initdata i2c1_info[] = {
1825 #if defined (CONFIG_MFD_WM831X_I2C)
1826         {
1827                 .type          = "wm8326",
1828                 .addr          = 0x34,
1829                 .flags         = 0,
1830                 .irq           = RK30_PIN6_PA4,
1831                 .platform_data = &wm831x_platdata,
1832         },
1833 #endif
1834 #if defined (CONFIG_MFD_TPS65910)
1835         {
1836         .type           = "tps65910",
1837         .addr           = TPS65910_I2C_ID0,
1838         .flags          = 0,
1839         .irq            = TPS65910_HOST_IRQ,
1840         .platform_data = &tps65910_data,
1841         },
1842 #endif
1843 };
1844 #endif
1845
1846 void __sramfunc board_pmu_suspend(void)
1847 {      
1848         #if defined (CONFIG_MFD_WM831X_I2C)
1849        if(pmic_is_wm8326())
1850        board_pmu_wm8326_suspend();
1851         #endif
1852         #if defined (CONFIG_MFD_TPS65910)
1853        if(pmic_is_tps65910())
1854        board_pmu_tps65910_suspend(); 
1855     #endif   
1856 }
1857
1858 void __sramfunc board_pmu_resume(void)
1859 {      
1860         #if defined (CONFIG_MFD_WM831X_I2C)
1861        if(pmic_is_wm8326())
1862        board_pmu_wm8326_resume();
1863         #endif
1864         #if defined (CONFIG_MFD_TPS65910)
1865        if(pmic_is_tps65910())
1866        board_pmu_tps65910_resume(); 
1867         #endif
1868 }
1869
1870 #ifdef CONFIG_I2C2_RK30
1871 static struct i2c_board_info __initdata i2c2_info[] = {
1872 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1873         {
1874                 .type          = "Goodix-TS",
1875                 .addr          = 0x55,
1876                 .flags         = 0,
1877                 .irq           = RK30_PIN4_PC2,
1878                 .platform_data = &goodix_info,
1879         },
1880 #endif
1881 #if defined (CONFIG_LS_CM3217)
1882         {
1883                 .type          = "light_cm3217",
1884                 .addr          = 0x10,
1885                 .flags         = 0,
1886                 .platform_data = &cm3217_info,
1887         },
1888 #endif
1889
1890 #if defined(CONFIG_DP501)
1891         {
1892                 .type = "dp501",
1893                 .addr = 0x30,
1894                 .flags = 0,
1895                 .platform_data = &dp501_platform_data,
1896         },
1897 #endif
1898 };
1899 #endif
1900
1901 #ifdef CONFIG_I2C3_RK30
1902 static struct i2c_board_info __initdata i2c3_info[] = {
1903 };
1904 #endif
1905
1906 #ifdef CONFIG_I2C4_RK30
1907 static struct i2c_board_info __initdata i2c4_info[] = {
1908 };
1909 #endif
1910
1911 #ifdef CONFIG_I2C_GPIO_RK30
1912 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1913 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1914 static int rk30_i2c_io_init(void)
1915 {
1916         //set iomux (gpio) here
1917         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1918         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1919
1920         return 0;
1921 }
1922 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1923        .sda_pin = I2C_SDA_PIN,
1924        .scl_pin = I2C_SCL_PIN,
1925        .udelay = 5, // clk = 500/udelay = 100Khz
1926        .timeout = 100,//msecs_to_jiffies(100),
1927        .bus_num    = 5,
1928        .io_init = rk30_i2c_io_init,
1929 };
1930 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1931 };
1932 #endif
1933
1934 static void __init rk30_i2c_register_board_info(void)
1935 {
1936 #ifdef CONFIG_I2C0_RK30
1937         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1938 #endif
1939 #ifdef CONFIG_I2C1_RK30
1940         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1941 #endif
1942 #ifdef CONFIG_I2C2_RK30
1943         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1944 #endif
1945 #ifdef CONFIG_I2C3_RK30
1946         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1947 #endif
1948 #ifdef CONFIG_I2C4_RK30
1949         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1950 #endif
1951 #ifdef CONFIG_I2C_GPIO_RK30
1952         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1953 #endif
1954 }
1955 //end of i2c
1956
1957 #define POWER_ON_PIN RK30_PIN6_PB0   //power_hold
1958 static void rk30_pm_power_off(void)
1959 {
1960         printk(KERN_ERR "rk30_pm_power_off start...\n");
1961         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1962         #if defined(CONFIG_MFD_WM831X)  
1963         if(pmic_is_wm8326())
1964         {
1965                 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
1966                 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1967         }
1968         #endif
1969         #if defined(CONFIG_MFD_TPS65910)
1970         if(pmic_is_tps65910())
1971         {
1972                 tps65910_device_shutdown();//tps65910 shutdown
1973         }
1974         #endif
1975
1976         while (1);
1977 }
1978
1979 static void __init machine_rk30_board_init(void)
1980 {
1981         avs_init();
1982         gpio_request(POWER_ON_PIN, "poweronpin");
1983         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1984         
1985         pm_power_off = rk30_pm_power_off;
1986         
1987         rk30_i2c_register_board_info();
1988         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1989         platform_add_devices(devices, ARRAY_SIZE(devices));
1990         rk_platform_add_display_devices();
1991         board_usb_detect_init(RK30_PIN6_PA3);
1992
1993 #if defined(CONFIG_WIFI_CONTROL_FUNC)
1994         rk29sdk_wifi_bt_gpio_control_init();
1995 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1996     rk29sdk_wifi_combo_module_gpio_init();
1997 #endif
1998
1999 #if defined(CONFIG_MT6620)
2000     clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 48*1000000);
2001 #endif
2002 #if defined(CONFIG_MT5931_MT6622)
2003     clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2004 #endif
2005 #if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
2006         //add for codec_en 
2007         gpio_request(RK30_PIN4_PD7, "codec_en");
2008         rk30_mux_api_set(GPIO4D7_SMCDATA15_TRACEDATA15_NAME, GPIO4D_GPIO4D7);
2009         gpio_direction_output(RK30_PIN4_PD7, GPIO_HIGH);
2010 #endif
2011 }
2012
2013 static void __init rk30_reserve(void)
2014 {
2015 #ifdef CONFIG_ION
2016         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2017 #endif
2018 #ifdef CONFIG_FB_ROCKCHIP
2019         resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2020         resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2021 #if 0
2022         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2023         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2024 #endif
2025
2026 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2027         resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2028         resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2029 #endif
2030 #endif
2031 #ifdef CONFIG_VIDEO_RK29
2032         rk30_camera_request_reserve_mem();
2033 #endif
2034         board_mem_reserved();
2035 }
2036
2037 /**
2038  * dvfs_cpu_logic_table: table for arm and logic dvfs 
2039  * @frequency   : arm frequency
2040  * @cpu_volt    : arm voltage depend on frequency
2041  * @logic_volt  : logic voltage arm requests depend on frequency
2042  * comments     : min arm/logic voltage
2043  */
2044 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
2045         {.frequency = 252 * 1000,       .cpu_volt = 1075 * 1000,        .logic_volt = 1125 * 1000},//0.975V/1.000V
2046         {.frequency = 504 * 1000,       .cpu_volt = 1100 * 1000,        .logic_volt = 1125 * 1000},//0.975V/1.000V
2047         {.frequency = 816 * 1000,       .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},//1.000V/1.025V
2048         {.frequency = 1008 * 1000,      .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},//1.025V/1.050V
2049         {.frequency = 1200 * 1000,      .cpu_volt = 1175 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
2050         {.frequency = 1272 * 1000,      .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},//1.150V/1.100V
2051         {.frequency = 1416 * 1000,      .cpu_volt = 1300 * 1000,        .logic_volt = 1200 * 1000},//1.225V/1.100V
2052         {.frequency = 1512 * 1000,      .cpu_volt = 1350 * 1000,        .logic_volt = 1250 * 1000},//1.300V/1.150V
2053         {.frequency = 1608 * 1000,      .cpu_volt = 1425 * 1000,        .logic_volt = 1300 * 1000},//1.325V/1.175V
2054         {.frequency = CPUFREQ_TABLE_END},
2055 };
2056
2057 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
2058         {.frequency = 266 * 1000,       .index = 1050 * 1000},
2059         {.frequency = 400 * 1000,       .index = 1275 * 1000},
2060         {.frequency = CPUFREQ_TABLE_END},
2061 };
2062
2063 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
2064     {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1050 * 1000},
2065         {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1050 * 1000},
2066         {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1125 * 1000},
2067         {.frequency = CPUFREQ_TABLE_END},
2068 };
2069
2070 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
2071 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2072 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2073
2074 void __init board_clock_init(void)
2075 {
2076         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
2077         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2078         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2079         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2080 }
2081
2082 MACHINE_START(RK30, "RK30board")
2083         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
2084         .fixup          = rk30_fixup,
2085         .reserve        = &rk30_reserve,
2086         .map_io         = rk30_map_io,
2087         .init_irq       = rk30_init_irq,
2088         .timer          = &rk30_timer,
2089         .init_machine   = machine_rk30_board_init,
2090 MACHINE_END