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