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