it66121: update and remove debug log
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk3188 / board-rk3188-ds1006h.c
1 /*
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/rk_fb.h>
44 #include <linux/regulator/machine.h>
45 #include <linux/rfkill-rk.h>
46 #include <linux/sensor-dev.h>
47 #include <linux/mfd/tps65910.h>
48 #include <linux/regulator/act8846.h>
49 #include <linux/regulator/rk29-pwm-regulator.h>
50 #if defined(CONFIG_CT36X_TS)
51 #include <linux/ct36x.h>
52 #endif
53 #if defined(CONFIG_MFD_RK610)
54 #include <linux/mfd/rk610_core.h>
55 #endif
56
57 #if defined(CONFIG_RK_HDMI)
58         #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
59 #endif
60
61 #if defined(CONFIG_SPIM_RK29)
62 #include "../../../drivers/spi/rk29_spim.h"
63 #endif
64 #if defined(CONFIG_GPS_RK)
65 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
66 #endif
67
68 #if defined(CONFIG_MT6620)
69 #include <linux/gps.h>
70 #endif
71
72 #include "../mach-rk30/board-rk3168-ds1006h-camera.c"
73 #include <plat/key.h>
74
75 static struct rk29_keys_button key_button[] = {
76         {
77                 .desc   = "play",
78                 .code   = KEY_POWER,
79                 .gpio   = RK30_PIN0_PA4, 
80                 .active_low = PRESS_LEV_LOW,
81                 .wakeup = 1,
82         },
83         {
84                 .desc   = "esc",
85                 .code   = KEY_BACK,
86                 .adc_value      = 1,
87                 .gpio = INVALID_GPIO,
88                 .active_low = PRESS_LEV_LOW,
89         },
90 };
91 struct rk29_keys_platform_data rk29_keys_pdata = {
92         .buttons        = key_button,
93         .nbuttons       = ARRAY_SIZE(key_button),
94         .chn    = 1,  //chn: 0-7, if do not use ADC,set 'chn' -1
95 };
96
97 #if defined(CONFIG_CT36X_TS)
98
99 #define TOUCH_MODEL             363
100 #define TOUCH_MAX_X             1280
101 #define TOUCH_MAX_y             800
102 #define TOUCH_RESET_PIN         RK30_PIN0_PB6
103 #define TOUCH_INT_PIN           RK30_PIN1_PB7
104
105 static struct ct36x_platform_data ct36x_info = {
106         .model   = TOUCH_MODEL,
107         .x_max   = TOUCH_MAX_X,
108         .y_max   = TOUCH_MAX_y,
109
110         .rst_io = {
111                 .gpio = TOUCH_RESET_PIN,
112                 .active_low = 1,
113         },
114         .irq_io = {
115                 .gpio = TOUCH_INT_PIN,
116                 .active_low = 1,
117         },
118         .orientation = {1, 0, 1, 0},
119 };
120 #endif
121 static struct spi_board_info board_spi_devices[] = {
122 };
123
124 /***********************************************************
125 *       rk30  backlight
126 ************************************************************/
127 #ifdef CONFIG_BACKLIGHT_RK29_BL
128 #define PWM_ID            3
129 #define PWM_MODE          PWM3
130 #define PWM_EFFECT_VALUE  1
131
132 #define LCD_DISP_ON_PIN
133
134 #ifdef  LCD_DISP_ON_PIN
135 #define BL_EN_PIN         RK30_PIN0_PA2
136 #define BL_EN_VALUE       GPIO_HIGH
137 #endif
138 static int rk29_backlight_io_init(void)
139 {
140         int ret = 0;
141
142         iomux_set(PWM_MODE);
143 #ifdef  LCD_DISP_ON_PIN
144         ret = gpio_request(BL_EN_PIN, NULL);
145         if (ret != 0) {
146                 gpio_free(BL_EN_PIN);
147         }
148
149         gpio_direction_output(BL_EN_PIN, 0);
150         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
151 #endif
152
153         return ret;
154 }
155
156 static int rk29_backlight_io_deinit(void)
157 {
158         int ret = 0, pwm_gpio;
159
160 #ifdef  LCD_DISP_ON_PIN
161         gpio_free(BL_EN_PIN);
162 #endif
163
164         pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
165         gpio_request(pwm_gpio, NULL);
166         gpio_direction_output(pwm_gpio, GPIO_LOW);
167         return ret;
168 }
169
170 static int rk29_backlight_pwm_suspend(void)
171 {
172         int ret = 0, pwm_gpio;
173
174         pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
175         if (gpio_request(pwm_gpio, NULL)) {
176                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
177                 return -1;
178         }
179         gpio_direction_output(pwm_gpio, GPIO_LOW);
180 #ifdef  LCD_DISP_ON_PIN
181         gpio_direction_output(BL_EN_PIN, 0);
182         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
183 #endif
184         return ret;
185 }
186
187 static int rk29_backlight_pwm_resume(void)
188 {
189         int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
190
191         gpio_free(pwm_gpio);
192         iomux_set(PWM_MODE);
193 #ifdef  LCD_DISP_ON_PIN
194         msleep(30);
195         gpio_direction_output(BL_EN_PIN, 1);
196         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
197 #endif
198         return 0;
199 }
200
201 static struct rk29_bl_info rk29_bl_info = {
202         .min_brightness = 30,
203         .pre_div = 20 * 1000,  // pwm output clk: 20k;
204         .pwm_id = PWM_ID,
205         .bl_ref = PWM_EFFECT_VALUE,
206         .io_init = rk29_backlight_io_init,
207         .io_deinit = rk29_backlight_io_deinit,
208         .pwm_suspend = rk29_backlight_pwm_suspend,
209         .pwm_resume = rk29_backlight_pwm_resume,
210 };
211
212 static struct platform_device rk29_device_backlight = {
213         .name   = "rk29_backlight",
214         .id     = -1,
215         .dev    = {
216                 .platform_data  = &rk29_bl_info,
217         }
218 };
219
220 #endif
221
222 /*MMA8452 gsensor*/
223 #if defined (CONFIG_GS_MMA8452)
224 #define MMA8452_INT_PIN   RK30_PIN0_PB7
225
226 static int mma8452_init_platform_hw(void)
227 {
228         return 0;
229 }
230
231 static struct sensor_platform_data mma8452_info = {
232         .type = SENSOR_TYPE_ACCEL,
233         .irq_enable = 1,
234         .poll_delay_ms = 30,
235         .init_platform_hw = mma8452_init_platform_hw,
236         .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
237 };
238 #endif
239 #if defined (CONFIG_GS_LIS3DH)
240 #define LIS3DH_INT_PIN   RK30_PIN0_PB7
241
242 static int lis3dh_init_platform_hw(void)
243 {
244
245         return 0;
246 }
247
248 static struct sensor_platform_data lis3dh_info = {
249         .type = SENSOR_TYPE_ACCEL,
250         .irq_enable = 1,
251         .poll_delay_ms = 30,
252         .init_platform_hw = lis3dh_init_platform_hw,
253         .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
254 };
255 #endif
256 #if defined (CONFIG_COMPASS_AK8975)
257 static struct sensor_platform_data akm8975_info =
258 {
259         .type = SENSOR_TYPE_COMPASS,
260         .irq_enable = 1,
261         .poll_delay_ms = 30,
262         .m_layout = 
263         {
264                 {
265                         {1, 0, 0},
266                         {0, 1, 0},
267                         {0, 0, 1},
268                 },
269
270                 {
271                         {1, 0, 0},
272                         {0, 1, 0},
273                         {0, 0, 1},
274                 },
275
276                 {
277                         {1, 0, 0},
278                         {0, 1, 0},
279                         {0, 0, 1},
280                 },
281
282                 {
283                         {1, 0, 0},
284                         {0, 1, 0},
285                         {0, 0, 1},
286                 },
287         }
288 };
289
290 #endif
291
292 #if defined(CONFIG_GYRO_L3G4200D)
293
294 #include <linux/l3g4200d.h>
295 #define L3G4200D_INT_PIN  RK30_PIN0_PB4
296
297 static int l3g4200d_init_platform_hw(void)
298 {
299         return 0;
300 }
301
302 static struct sensor_platform_data l3g4200d_info = {
303         .type = SENSOR_TYPE_GYROSCOPE,
304         .irq_enable = 1,
305         .poll_delay_ms = 30,
306         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
307         .init_platform_hw = l3g4200d_init_platform_hw,
308         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
309         .y_min = 40,
310         .z_min = 20,
311 };
312
313 #endif
314
315 #ifdef CONFIG_LS_CM3217
316 static struct sensor_platform_data cm3217_info = {
317         .type = SENSOR_TYPE_LIGHT,
318         .irq_enable = 0,
319         .poll_delay_ms = 500,
320 };
321
322 #endif
323
324 #ifdef CONFIG_FB_ROCKCHIP
325
326 #define LCD_CS_PIN         INVALID_GPIO
327 #define LCD_CS_VALUE       GPIO_HIGH
328
329 #define LCD_EN_PIN         RK30_PIN0_PB0
330 #define LCD_EN_VALUE       GPIO_LOW
331
332 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
333 {
334         int ret = 0;
335
336         if(LCD_CS_PIN !=INVALID_GPIO)
337         {
338                 ret = gpio_request(LCD_CS_PIN, NULL);
339                 if (ret != 0)
340                 {
341                         gpio_free(LCD_CS_PIN);
342                         printk(KERN_ERR "request lcd cs pin fail!\n");
343                         return -1;
344                 }
345                 else
346                 {
347                         gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
348                 }
349         }
350
351         if(LCD_EN_PIN !=INVALID_GPIO)
352         {
353                 ret = gpio_request(LCD_EN_PIN, NULL);
354                 if (ret != 0)
355                 {
356                         gpio_free(LCD_EN_PIN);
357                         printk(KERN_ERR "request lcd en pin fail!\n");
358                         return -1;
359                 }
360                 else
361                 {
362                         gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
363                 }
364         }
365         return 0;
366 }
367 static int rk_fb_io_disable(void)
368 {
369         if(LCD_CS_PIN !=INVALID_GPIO)
370         {
371                 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
372         }
373         if(LCD_EN_PIN !=INVALID_GPIO)
374         {
375                 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
376         }
377         return 0;
378 }
379 static int rk_fb_io_enable(void)
380 {
381         if(LCD_CS_PIN !=INVALID_GPIO)
382         {
383                 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
384         }
385         if(LCD_EN_PIN !=INVALID_GPIO)
386         {
387                 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
388         }
389         return 0;
390 }
391
392 #if defined(CONFIG_LCDC0_RK3188)
393 struct rk29fb_info lcdc0_screen_info = {
394         .prop           = EXTEND,       //extend display device
395        .lcd_info  = NULL,
396        .set_screen_info = hdmi_init_lcdc,
397
398 };
399 #endif
400
401 #if defined(CONFIG_LCDC1_RK3188)
402 struct rk29fb_info lcdc1_screen_info = {
403         .prop      = PRMRY,             //primary display device
404         .io_init   = rk_fb_io_init,
405         .io_disable = rk_fb_io_disable,
406         .io_enable = rk_fb_io_enable,
407         .set_screen_info = set_lcd_info,
408         
409 };
410 #endif
411
412 static struct resource resource_fb[] = {
413         [0] = {
414                 .name  = "fb0 buf",
415                 .start = 0,
416                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
417                 .flags = IORESOURCE_MEM,
418         },
419         [1] = {
420                 .name  = "ipp buf",  //for rotate
421                 .start = 0,
422                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
423                 .flags = IORESOURCE_MEM,
424         },
425         [2] = {
426                 .name  = "fb2 buf",
427                 .start = 0,
428                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
429                 .flags = IORESOURCE_MEM,
430         },
431 };
432
433 static struct platform_device device_fb = {
434         .name           = "rk-fb",
435         .id             = -1,
436         .num_resources  = ARRAY_SIZE(resource_fb),
437         .resource       = resource_fb,
438 };
439 #endif
440
441 #if defined(CONFIG_LCDC0_RK3188)
442 static struct resource resource_lcdc0[] = {
443         [0] = {
444                 .name  = "lcdc0 reg",
445                 .start = RK30_LCDC0_PHYS,
446                 .end   = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
447                 .flags = IORESOURCE_MEM,
448         },
449         
450         [1] = {
451                 .name  = "lcdc0 irq",
452                 .start = IRQ_LCDC0,
453                 .end   = IRQ_LCDC0,
454                 .flags = IORESOURCE_IRQ,
455         },
456 };
457
458 static struct platform_device device_lcdc0 = {
459         .name             = "rk30-lcdc",
460         .id               = 0,
461         .num_resources    = ARRAY_SIZE(resource_lcdc0),
462         .resource         = resource_lcdc0,
463         .dev            = {
464                 .platform_data = &lcdc0_screen_info,
465         },
466 };
467 #endif
468 #if defined(CONFIG_LCDC1_RK3188) 
469 static struct resource resource_lcdc1[] = {
470         [0] = {
471                 .name  = "lcdc1 reg",
472                 .start = RK30_LCDC1_PHYS,
473                 .end   = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
474                 .flags = IORESOURCE_MEM,
475         },
476         [1] = {
477                 .name  = "lcdc1 irq",
478                 .start = IRQ_LCDC1,
479                 .end   = IRQ_LCDC1,
480                 .flags = IORESOURCE_IRQ,
481         },
482 };
483
484 static struct platform_device device_lcdc1 = {
485         .name             = "rk30-lcdc",
486         .id               = 1,
487         .num_resources    = ARRAY_SIZE(resource_lcdc1),
488         .resource         = resource_lcdc1,
489         .dev            = {
490                 .platform_data = &lcdc1_screen_info,
491         },
492 };
493 #endif
494
495 #if defined(CONFIG_MFD_RK610)
496 #define RK610_RST_PIN                   RK30_PIN3_PB2
497 static int rk610_power_on_init(void)
498 {
499         int ret;
500         if(RK610_RST_PIN != INVALID_GPIO)
501         {
502                 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
503                 if (ret)
504                 {
505                         printk(KERN_ERR "rk610_control_probe request gpio fail\n");
506                 }
507                 else 
508                 {
509                         gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
510                         msleep(100);
511                         gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
512                         msleep(100);
513                         gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
514                 }
515         }
516
517         return 0;
518         
519 }
520
521
522 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
523         .rk610_power_on_init = rk610_power_on_init,
524 };
525 #endif
526
527 #ifdef CONFIG_SND_SOC_RK610
528 static int rk610_codec_io_init(void)
529 {
530 //if need iomux.
531 //Must not gpio_request
532         return 0;
533 }
534
535 static struct rk610_codec_platform_data rk610_codec_pdata = {
536         .spk_ctl_io = RK30_PIN2_PD7,
537         .io_init = rk610_codec_io_init,
538         .boot_depop = 1,
539 };
540 #endif
541
542 #ifdef CONFIG_RK_HDMI
543 #define RK_HDMI_RST_PIN                         RK30_PIN3_PB2
544 static int rk_hdmi_power_init(void)
545 {
546         int ret;
547
548         if(RK_HDMI_RST_PIN != INVALID_GPIO)
549         {
550                 if (gpio_request(RK_HDMI_RST_PIN, NULL)) {
551                         printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
552                         return -1;
553                 }
554                 gpio_direction_output(RK_HDMI_RST_PIN, GPIO_LOW);
555                 gpio_set_value(RK_HDMI_RST_PIN, GPIO_LOW);
556                 msleep(100);
557                 gpio_set_value(RK_HDMI_RST_PIN, GPIO_HIGH);
558                 msleep(50);
559         }
560         return 0;
561 }
562 static struct rk_hdmi_platform_data rk_hdmi_pdata = {
563         .io_init = rk_hdmi_power_init,
564 };
565 #endif
566 #ifdef CONFIG_ION
567 #define ION_RESERVE_SIZE        (80 * SZ_1M)
568 static struct ion_platform_data rk30_ion_pdata = {
569         .nr = 1,
570         .heaps = {
571                 {
572                         .type = ION_HEAP_TYPE_CARVEOUT,
573                         .id = ION_NOR_HEAP_ID,
574                         .name = "norheap",
575                         .size = ION_RESERVE_SIZE,
576                 }
577         },
578 };
579
580 static struct platform_device device_ion = {
581         .name = "ion-rockchip",
582         .id = 0,
583         .dev = {
584                 .platform_data = &rk30_ion_pdata,
585         },
586 };
587 #endif
588
589 /**************************************************************************************************
590  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
591 **************************************************************************************************/
592 #ifdef CONFIG_SDMMC_RK29
593 #include "board-rk3188-ds1006h-sdmmc-config.c"
594 #include "../plat-rk/rk-sdmmc-ops.c"
595 #include "../plat-rk/rk-sdmmc-wifi.c"
596 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
597
598 #ifdef CONFIG_SDMMC0_RK29
599 static int rk29_sdmmc0_cfg_gpio(void)
600 {
601 #ifdef CONFIG_SDMMC_RK29_OLD
602         iomux_set(MMC0_CMD);
603         iomux_set(MMC0_CLKOUT);
604         iomux_set(MMC0_D0);
605         iomux_set(MMC0_D1);
606         iomux_set(MMC0_D2);
607         iomux_set(MMC0_D3);
608
609         iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
610
611         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
612         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
613
614 #else
615         rk29_sdmmc_set_iomux(0, 0xFFFF);
616
617     #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
618         #if SDMMC_USE_NEW_IOMUX_API
619         iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
620         #else
621         rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
622         #endif
623     #else
624         #if SDMMC_USE_NEW_IOMUX_API       
625         iomux_set(MMC0_DETN);
626         #else
627         rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
628         #endif
629     #endif      
630
631 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
632         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
633         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
634 #endif
635
636 #endif
637
638         return 0;
639 }
640
641 #define CONFIG_SDMMC0_USE_DMA
642 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
643         .host_ocr_avail =
644             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
645              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
646              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
647         .host_caps =
648             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
649         .io_init = rk29_sdmmc0_cfg_gpio,
650
651 #if !defined(CONFIG_SDMMC_RK29_OLD)
652         .set_iomux = rk29_sdmmc_set_iomux,
653 #endif
654
655         .dma_name = "sd_mmc",
656 #ifdef CONFIG_SDMMC0_USE_DMA
657         .use_dma = 1,
658 #else
659         .use_dma = 0,
660 #endif
661
662 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
663     .status = rk29sdk_wifi_mmc0_status,
664     .register_status_notify = rk29sdk_wifi_mmc0_status_register,
665 #endif
666
667 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
668     .power_en = RK29SDK_SD_CARD_PWR_EN,
669     .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
670 #else
671     .power_en = INVALID_GPIO,
672     .power_en_level = GPIO_LOW,
673 #endif    
674         .enable_sd_wakeup = 0,
675
676 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
677         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
678         .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
679 #else
680         .write_prt = INVALID_GPIO,
681 #endif
682
683     .det_pin_info = {    
684     #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
685         .io             = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
686         .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
687         #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
688         .iomux          = {
689             .name       = RK29SDK_SD_CARD_DETECT_PIN_NAME,
690             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
691             .fgpio      = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
692             #endif
693             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
694             .fmux       = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
695             #endif
696         },
697         #endif
698     #else
699         .io             = INVALID_GPIO,
700         .enable         = GPIO_LOW,
701     #endif    
702     }, 
703
704 };
705 #endif // CONFIG_SDMMC0_RK29
706
707 #ifdef CONFIG_SDMMC1_RK29
708 #define CONFIG_SDMMC1_USE_DMA
709 static int rk29_sdmmc1_cfg_gpio(void)
710 {
711 #if defined(CONFIG_SDMMC_RK29_OLD)
712         iomux_set(MMC1_CMD);
713         iomux_set(MMC1_CLKOUT);
714         iomux_set(MMC1_D0);
715         iomux_set(MMC1_D1);
716         iomux_set(MMC1_D2);
717         iomux_set(MMC1_D3);
718 #else
719
720 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
721         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
722         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
723 #endif
724
725 #endif
726
727         return 0;
728 }
729
730 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
731         .host_ocr_avail =
732             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
733              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
734              MMC_VDD_33_34),
735
736 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
737         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
738                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
739 #else
740         .host_caps =
741             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
742 #endif
743
744         .io_init = rk29_sdmmc1_cfg_gpio,
745
746 #if !defined(CONFIG_SDMMC_RK29_OLD)
747         .set_iomux = rk29_sdmmc_set_iomux,
748 #endif
749
750         .dma_name = "sdio",
751 #ifdef CONFIG_SDMMC1_USE_DMA
752         .use_dma = 1,
753 #else
754         .use_dma = 0,
755 #endif
756
757 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
758     .status = rk29sdk_wifi_status,
759     .register_status_notify = rk29sdk_wifi_status_register,
760 #endif
761
762 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
763         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
764             .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
765 #else
766         .write_prt = INVALID_GPIO,
767 #endif
768
769     #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
770         .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
771     #endif
772
773     .det_pin_info = {    
774 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
775      #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
776         .io             = RK29SDK_SD_CARD_DETECT_N,
777      #else
778          .io             = INVALID_GPIO,
779      #endif   
780
781         .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
782         #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
783         .iomux          = {
784             .name       = RK29SDK_SD_CARD_DETECT_PIN_NAME,
785             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
786             .fgpio      = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
787             #endif
788             #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
789             .fmux       = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
790             #endif
791         },
792         #endif
793  #else
794         .io             = INVALID_GPIO,
795         .enable         = GPIO_LOW,
796 #endif
797     },
798    
799         .enable_sd_wakeup = 0,
800 };
801 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
802
803 /**************************************************************************************************
804  * the end of setting for SDMMC devices
805 **************************************************************************************************/
806
807 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
808 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
809         .dc_det_pin      = RK30_PIN0_PB2,
810         .batt_low_pin    = INVALID_GPIO, 
811         .charge_set_pin  = INVALID_GPIO,
812         .charge_ok_pin   = RK30_PIN0_PA6,
813          .usb_det_pin = INVALID_GPIO,
814         .dc_det_level    = GPIO_LOW,
815         .charge_ok_level = GPIO_HIGH,
816
817         .reference_voltage = 1800, // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
818        .pull_up_res = 200,     //divider resistance ,  pull-up resistor
819        .pull_down_res = 120, //divider resistance , pull-down resistor
820
821         .is_reboot_charging = 1,
822         .save_capacity   = 1 ,
823         .low_voltage_protection = 3600,    
824 };
825
826 static struct platform_device rk30_device_adc_battery = {
827         .name   = "rk30-battery",
828         .id     = -1,
829         .dev = {
830                 .platform_data = &rk30_adc_battery_platdata,
831         },
832 };
833 #endif
834 #ifdef CONFIG_RK30_PWM_REGULATOR
835 static int pwm_voltage_map[] = {
836         950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
837 };
838
839 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
840         {
841                 .supply = "vdd_cpu",
842         }
843 };
844
845 struct regulator_init_data pwm_regulator_init_dcdc[1] =
846 {
847         {
848                 .constraints = {
849                         .name = "PWM_DCDC1",
850                         .min_uV = 600000,
851                         .max_uV = 1800000,      //0.6-1.8V
852                         .apply_uV = true,
853                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
854                 },
855                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
856                 .consumer_supplies = pwm_dcdc1_consumers,
857         },
858 };
859
860 static struct pwm_platform_data pwm_regulator_info[1] = {
861         {
862                 .pwm_id = 1,
863                 .pwm_gpio = RK30_PIN3_PD4,
864                 .pwm_iomux_pwm = PWM1,
865                 .pwm_iomux_gpio = GPIO3_D4,
866                 .pwm_voltage = 1100000,
867                 .suspend_voltage = 1050000,
868                 .min_uV = 950000,
869                 .max_uV = 1400000,
870                 .coefficient = 455,     //45.5%
871                 .pwm_voltage_map = pwm_voltage_map,
872                 .init_data      = &pwm_regulator_init_dcdc[0],
873         },
874 };
875
876 struct platform_device pwm_regulator_device[1] = {
877         {
878                 .name = "pwm-voltage-regulator",
879                 .id = 0,
880                 .dev            = {
881                         .platform_data = &pwm_regulator_info[0],
882                 }
883         },
884 };
885 #endif
886
887 #ifdef CONFIG_RFKILL_RK
888 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
889 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
890     .type               = RFKILL_TYPE_BLUETOOTH,
891
892     .poweron_gpio       = { // BT_REG_ON
893         .io             = INVALID_GPIO, //RK30_PIN3_PC7,
894         .enable         = GPIO_HIGH,
895         .iomux          = {
896             .name       = "bt_poweron",
897             .fgpio      = GPIO3_C7,
898         },
899     },
900
901     .reset_gpio         = { // BT_RST
902         .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
903         .enable         = GPIO_LOW,
904         .iomux          = {
905             .name       = "bt_reset",
906             .fgpio      = GPIO3_D1,
907        },
908    }, 
909
910     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
911         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
912         .enable         = GPIO_HIGH,
913         .iomux          = {
914             .name       = "bt_wake",
915             .fgpio      = GPIO3_C6,
916         },
917     },
918
919     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
920         .gpio           = {
921             .io         = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
922             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
923             .iomux      = {
924                 .name   = NULL,
925             },
926         },
927     },
928
929     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
930         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
931         .enable         = GPIO_LOW,
932         .iomux          = {
933             .name       = "bt_rts",
934             .fgpio      = GPIO1_A3,
935             .fmux       = UART0_RTSN,
936         },
937     },
938 };
939
940 static struct platform_device device_rfkill_rk = {
941     .name   = "rfkill_rk",
942     .id     = -1,
943     .dev    = {
944         .platform_data = &rfkill_rk_platdata,
945     },
946 };
947 #endif
948
949 #if defined(CONFIG_GPS_RK)
950 int rk_gps_io_init(void)
951 {
952         printk("%s \n", __FUNCTION__);
953         
954         rk30_mux_api_set(GPIO1B5_UART3RTSN_NAME, GPIO1B_GPIO1B5);//VCC_EN
955         gpio_request(RK30_PIN1_PB5, NULL);
956         gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
957
958         rk30_mux_api_set(GPIO1B4_UART3CTSN_GPSRFCLK_NAME, GPIO1B_GPSRFCLK);//GPS_CLK
959         rk30_mux_api_set(GPIO1B2_UART3SIN_GPSMAG_NAME, GPIO1B_GPSMAG);//GPS_MAG
960         rk30_mux_api_set(GPIO1B3_UART3SOUT_GPSSIG_NAME, GPIO1B_GPSSIG);//GPS_SIGN
961
962         rk30_mux_api_set(GPIO1A6_UART1CTSN_SPI0CLK_NAME, GPIO1A_GPIO1A6);//SPI_CLK
963         gpio_request(RK30_PIN1_PA6, NULL);
964         gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
965
966         rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0TXD_NAME, GPIO1A_GPIO1A5);//SPI_MOSI
967         gpio_request(RK30_PIN1_PA5, NULL);
968         gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW); 
969
970         rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0CSN0_NAME, GPIO1A_GPIO1A7);//SPI_CS
971         gpio_request(RK30_PIN1_PA7, NULL);
972         gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);         
973         return 0;
974 }
975 int rk_gps_power_up(void)
976 {
977         printk("%s \n", __FUNCTION__);
978
979         return 0;
980 }
981
982 int rk_gps_power_down(void)
983 {
984         printk("%s \n", __FUNCTION__);
985
986         return 0;
987 }
988
989 int rk_gps_reset_set(int level)
990 {
991         return 0;
992 }
993 int rk_enable_hclk_gps(void)
994 {
995         printk("%s \n", __FUNCTION__);
996         clk_enable(clk_get(NULL, "hclk_gps"));
997         return 0;
998 }
999 int rk_disable_hclk_gps(void)
1000 {
1001         printk("%s \n", __FUNCTION__);
1002         clk_disable(clk_get(NULL, "hclk_gps"));
1003         return 0;
1004 }
1005 struct rk_gps_data rk_gps_info = {
1006         .io_init = rk_gps_io_init,
1007         .power_up = rk_gps_power_up,
1008         .power_down = rk_gps_power_down,
1009         .reset = rk_gps_reset_set,
1010         .enable_hclk_gps = rk_enable_hclk_gps,
1011         .disable_hclk_gps = rk_disable_hclk_gps,
1012         .GpsSign = RK30_PIN1_PB3,
1013         .GpsMag = RK30_PIN1_PB2,        //GPIO index
1014         .GpsClk = RK30_PIN1_PB4,        //GPIO index
1015         .GpsVCCEn = RK30_PIN1_PB5,     //GPIO index
1016         .GpsSpi_CSO = RK30_PIN1_PA4,    //GPIO index
1017         .GpsSpiClk = RK30_PIN1_PA5,     //GPIO index
1018         .GpsSpiMOSI = RK30_PIN1_PA7,      //GPIO index
1019         .GpsIrq = IRQ_GPS,
1020         .GpsSpiEn = 0,
1021         .GpsAdcCh = 2,
1022         .u32GpsPhyAddr = RK30_GPS_PHYS,
1023         .u32GpsPhySize = RK30_GPS_SIZE,
1024 };
1025
1026 struct platform_device rk_device_gps = {
1027         .name = "gps_hv5820b",
1028         .id = -1,
1029         .dev            = {
1030         .platform_data = &rk_gps_info,
1031                 }
1032         };
1033 #endif
1034
1035 #if defined(CONFIG_MT5931_MT6622)
1036 static struct mt6622_platform_data mt6622_platdata = {
1037                     .power_gpio         = { // BT_REG_ON
1038                         .io             = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1039                             .enable         = GPIO_HIGH,
1040                             .iomux          = {
1041                                     .name       = NULL,
1042                                 },
1043                     },
1044
1045                     .reset_gpio         = { // BT_RST
1046                         .io             = RK30_PIN0_PD7,
1047                         .enable         = GPIO_HIGH,
1048                         .iomux          = {
1049                             .name       = NULL,
1050                         },
1051                     },
1052
1053                     .irq_gpio           = {
1054                             .io             = RK30_PIN3_PD2,
1055                             .enable         = GPIO_HIGH,
1056                             .iomux          = {
1057                                     .name       = NULL,
1058                                 },
1059                     }
1060 };
1061
1062 static struct platform_device device_mt6622 = {
1063                     .name   = "mt6622",
1064                         .id     = -1,
1065                         .dev    = {
1066                                .platform_data = &mt6622_platdata,
1067                         },
1068 };      
1069 #endif
1070
1071 static struct platform_device *devices[] __initdata = {
1072
1073 #ifdef CONFIG_ION
1074         &device_ion,
1075 #endif
1076 #ifdef CONFIG_WIFI_CONTROL_FUNC
1077         &rk29sdk_wifi_device,
1078 #endif
1079
1080 #if defined(CONFIG_MT6620)
1081             &mt3326_device_gps,
1082 #endif
1083
1084 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1085         &rk30_device_adc_battery,
1086 #endif
1087 #ifdef CONFIG_RFKILL_RK
1088         &device_rfkill_rk,
1089 #endif
1090 #ifdef CONFIG_GPS_RK
1091         &rk_device_gps,
1092 #endif
1093 #ifdef CONFIG_MT5931_MT6622
1094         &device_mt6622,
1095 #endif
1096 };
1097
1098
1099 static int rk_platform_add_display_devices(void)
1100 {
1101         struct platform_device *fb = NULL;  //fb
1102         struct platform_device *lcdc0 = NULL; //lcdc0
1103         struct platform_device *lcdc1 = NULL; //lcdc1
1104         struct platform_device *bl = NULL; //backlight
1105 #ifdef CONFIG_FB_ROCKCHIP
1106         fb = &device_fb;
1107 #endif
1108
1109 #if defined(CONFIG_LCDC0_RK3188)
1110         lcdc0 = &device_lcdc0,
1111 #endif
1112
1113 #if defined(CONFIG_LCDC1_RK3188)
1114         lcdc1 = &device_lcdc1,
1115 #endif
1116
1117 #ifdef CONFIG_BACKLIGHT_RK29_BL
1118         bl = &rk29_device_backlight,
1119 #endif
1120         __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1121
1122         return 0;
1123         
1124 }
1125
1126 // i2c
1127 #ifdef CONFIG_I2C0_RK30
1128 static struct i2c_board_info __initdata i2c0_info[] = {
1129 #if defined (CONFIG_GS_MMA8452)
1130         {
1131                 .type           = "gs_mma8452",
1132                 .addr           = 0x1d,
1133                 .flags          = 0,
1134                 .irq            = MMA8452_INT_PIN,
1135                 .platform_data = &mma8452_info,
1136         },
1137 #endif
1138 #if defined (CONFIG_LS_US5151)
1139         {    
1140                 .type           = "us5151",
1141                 .addr           = 0x10,
1142                 .flags          = 0, 
1143         },   
1144 #endif
1145 #if defined (CONFIG_GS_LIS3DH)
1146         {
1147                 .type           = "gs_lis3dh",
1148                 .addr           = 0x19,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
1149                 .flags          = 0,
1150                 .irq            = LIS3DH_INT_PIN,
1151                 .platform_data = &lis3dh_info,
1152         },
1153 #endif
1154 #if defined (CONFIG_COMPASS_AK8975)
1155         {
1156                 .type          = "ak8975",
1157                 .addr          = 0x0d,
1158                 .flags         = 0,
1159                 .irq           = RK30_PIN3_PD7, 
1160                 .platform_data = &akm8975_info,
1161                 .irq           = RK30_PIN3_PD7, 
1162                 .platform_data = &akm8975_info,
1163         },
1164 #endif
1165 #if defined (CONFIG_GYRO_L3G4200D)
1166         {
1167                 .type          = "l3g4200d_gryo",
1168                 .addr          = 0x69,
1169                 .flags         = 0,
1170                 .irq           = L3G4200D_INT_PIN,
1171                 .platform_data = &l3g4200d_info,
1172         },
1173 #endif
1174 #if defined (CONFIG_SND_SOC_RK1000)
1175         {
1176                 .type          = "rk1000_i2c_codec",
1177                 .addr          = 0x60,
1178                 .flags         = 0,
1179         },
1180         {
1181                 .type          = "rk1000_control",
1182                 .addr          = 0x40,
1183                 .flags         = 0,
1184         },
1185 #endif
1186 #if defined (CONFIG_SND_SOC_RT5631)
1187         {
1188                 .type                   = "rt5631",
1189                 .addr                   = 0x1a,
1190                 .flags                  = 0,
1191         },
1192 #endif
1193 };
1194 #endif
1195
1196 int __sramdata g_pmic_type =  0;
1197 #ifdef CONFIG_I2C1_RK30
1198 #ifdef CONFIG_REGULATOR_ACT8846
1199 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1200 #define PMU_VSEL RK30_PIN3_PD3
1201 #define ACT8846_HOST_IRQ                RK30_PIN0_PB3
1202
1203 static struct pmu_info  act8846_dcdc_info[] = {
1204         {
1205                 .name          = "act_dcdc1",   //ddr
1206                 .min_uv          = 1200000,
1207                 .max_uv         = 1200000,
1208                 .suspend_vol  =   1200000,
1209         },
1210         {
1211                 .name          = "vdd_core",    //logic
1212                 .min_uv          = 1000000,
1213                 .max_uv         = 1000000,
1214                 .suspend_vol  =  900000,
1215         },
1216         {
1217                 .name          = "vdd_cpu",   //arm
1218                 .min_uv          = 1000000,
1219                 .max_uv         = 1000000,
1220                 .suspend_vol  =  900000,
1221         },
1222         {
1223                 .name          = "act_dcdc4",   //vccio
1224                 .min_uv          = 3000000,
1225                 .max_uv         = 3000000,
1226                 .suspend_vol  =  2800000,
1227         },
1228         
1229 };
1230 static  struct pmu_info  act8846_ldo_info[] = {
1231         {
1232                 .name          = "act_ldo1",   //vdd10
1233                 .min_uv          = 1000000,
1234                 .max_uv         = 1000000,
1235         },
1236         {
1237                 .name          = "act_ldo2",    //vdd12
1238                 .min_uv          = 1200000,
1239                 .max_uv         = 1200000,
1240         },
1241         {
1242                 .name          = "act_ldo3",   //vcc18_cif
1243                 .min_uv          = 1800000,
1244                 .max_uv         = 1800000,
1245         },
1246         {
1247                 .name          = "act_ldo4",   //vcca33
1248                 .min_uv          = 3300000,
1249                 .max_uv         = 3300000,
1250         },
1251         {
1252                 .name          = "act_ldo5",   //vcctp
1253                 .min_uv          = 3300000,
1254                 .max_uv         = 3300000,
1255         },
1256         {
1257                 .name          = "act_ldo6",   //vcc_jetta
1258                 .min_uv          = 3300000,
1259                 .max_uv         = 3300000,
1260         },
1261         {
1262                 .name          = "act_ldo7",   //vcc18
1263                 .min_uv          = 1800000,
1264                 .max_uv         = 1800000,
1265         },
1266         {
1267                 .name          = "act_ldo8",   //vcc28_cif
1268                 .min_uv          = 2800000,
1269                 .max_uv         = 2800000,
1270         },
1271  };
1272
1273 #include "../mach-rk30/board-pmu-act8846.c"
1274 #endif
1275
1276 #ifdef CONFIG_MFD_WM831X_I2C
1277 #define PMU_POWER_SLEEP                 RK30_PIN0_PA1 
1278
1279 static struct pmu_info  wm8326_dcdc_info[] = {
1280         {
1281                 .name          = "vdd_core",   //logic
1282                 .min_uv          = 1000000,
1283                 .max_uv         = 1000000,
1284                 .suspend_vol  =  950000,
1285         },
1286         {
1287                 .name          = "vdd_cpu",    //arm
1288                 .min_uv          = 1000000,
1289                 .max_uv         = 1000000,
1290                 .suspend_vol  =  950000,
1291         },
1292         {
1293                 .name          = "dcdc3",   //ddr
1294                 .min_uv          = 1150000,
1295                 .max_uv         = 1150000,
1296                 .suspend_vol  =  1150000,
1297         },
1298         #ifdef CONFIG_MACH_RK3066_SDK
1299         {
1300                 .name          = "dcdc4",   //vcc_io
1301                 .min_uv          = 3300000,
1302                 .max_uv         = 3300000,
1303                 .suspend_vol  =  3000000,
1304         },
1305         #else
1306         {
1307                 .name          = "dcdc4",   //vcc_io
1308                 .min_uv          = 3000000,
1309                 .max_uv         = 3000000,
1310                 .suspend_vol  =  2800000,
1311         },
1312         #endif
1313 };
1314
1315 static struct pmu_info  wm8326_ldo_info[] = {
1316         {
1317                 .name          = "ldo1",   //vcc18_cif
1318                 .min_uv          = 1800000,
1319                 .max_uv         = 1800000,
1320                 .suspend_vol  =  1800000,
1321         },
1322         {
1323                 .name          = "ldo2",    //vccio_wl
1324                 .min_uv          = 1800000,
1325                 .max_uv         = 1800000,
1326                 .suspend_vol  =  1800000,
1327         },
1328         {
1329                 .name          = "ldo3",   //
1330                 .min_uv          = 1100000,
1331                 .max_uv         = 1100000,
1332                 .suspend_vol  =  1100000,
1333         },
1334         {
1335                 .name          = "ldo4",   //vdd11
1336                 .min_uv          = 1000000,
1337                 .max_uv         = 1000000,
1338                 .suspend_vol  =  1000000,
1339         },
1340         {
1341                 .name          = "ldo5",   //vcc25
1342                 .min_uv          = 1800000,
1343                 .max_uv         = 1800000,
1344                 .suspend_vol  =  1800000,
1345         },
1346         {
1347                 .name          = "ldo6",   //vcc33
1348                 .min_uv          = 3300000,
1349                 .max_uv         = 3300000,
1350                 .suspend_vol  =  3300000,
1351         },
1352         {
1353                 .name          = "ldo7",   //vcc28_cif
1354                 .min_uv          = 2800000,
1355                 .max_uv         = 2800000,
1356                 .suspend_vol  =  2800000,
1357         },
1358         {
1359                 .name          = "ldo8",   //vcca33
1360                 .min_uv          = 3300000,
1361                 .max_uv         = 3300000,
1362                 .suspend_vol  =  3300000,
1363         },
1364         {
1365                 .name          = "ldo9",   //vcc_tp
1366                 .min_uv          = 3300000,
1367                 .max_uv         = 3300000,
1368                 .suspend_vol  =  3300000,
1369         },
1370         {
1371                 .name          = "ldo10",   //flash_io
1372                 .min_uv          = 1800000,
1373                 .max_uv         = 1800000,
1374                 .suspend_vol  =  1800000,
1375         },
1376 };
1377
1378 #include "../mach-rk30/board-pmu-wm8326.c"
1379 #endif
1380
1381 #ifdef CONFIG_MFD_TPS65910
1382 #ifdef CONFIG_ARCH_RK3188
1383 #define TPS65910_HOST_IRQ        RK30_PIN0_PB3
1384 #else
1385 #define TPS65910_HOST_IRQ        RK30_PIN6_PA4
1386 #endif
1387
1388 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1389
1390 static struct pmu_info  tps65910_dcdc_info[] = {
1391         {
1392                 .name          = "vdd_core",   //logic
1393                 .min_uv          = 1100000,
1394                 .max_uv         = 1100000,
1395         },
1396         {
1397                 .name          = "vdd2",    //ddr
1398                 .min_uv          = 1200000,
1399                 .max_uv         = 1200000,
1400         },
1401         {
1402                 .name          = "vio",   //vcc_io
1403                 .min_uv          = 2500000,
1404                 .max_uv         = 2500000,
1405         },
1406         
1407 };
1408 static  struct pmu_info  tps65910_ldo_info[] = {
1409         {
1410                 .name          = "vpll",   //vdd10
1411                 .min_uv          = 1000000,
1412                 .max_uv         = 1000000,
1413         },
1414         {
1415                 .name          = "vdig1",    //vcc18_cif
1416                 .min_uv          = 1800000,
1417                 .max_uv         = 1800000,
1418         },
1419         {
1420                 .name          = "vdig2",   //vdd_jetta
1421                 .min_uv          = 1200000,
1422                 .max_uv         = 1200000,
1423         },
1424         {
1425                 .name          = "vaux1",   //vcc28_cif
1426                 .min_uv          = 2800000,
1427                 .max_uv         = 2800000,
1428         },
1429         {
1430                 .name          = "vaux2",   //vcca33
1431                 .min_uv          = 3300000,
1432                 .max_uv         = 3300000,
1433         },
1434         {
1435                 .name          = "vaux33",   //vcc_tp
1436                 .min_uv          = 3300000,
1437                 .max_uv         = 3300000,
1438         },
1439         {
1440                 .name          = "vmmc",   //vcc30
1441                 .min_uv          = 3000000,
1442                 .max_uv         = 3000000,
1443         },
1444         {
1445                 .name          = "vdac",   //vcc18
1446                 .min_uv          = 1800000,
1447                 .max_uv         = 1800000,
1448         },
1449  };
1450
1451 #include "../mach-rk30/board-pmu-tps65910.c"
1452 #endif
1453
1454 static struct i2c_board_info __initdata i2c1_info[] = {
1455 #if defined (CONFIG_REGULATOR_ACT8846)
1456         {
1457                 .type                   = "act8846",
1458                 .addr           = 0x5a, 
1459                 .flags                  = 0,
1460                 .irq            = ACT8846_HOST_IRQ,
1461                 .platform_data=&act8846_data,
1462         },
1463 #endif
1464 #if defined (CONFIG_RTC_HYM8563)
1465         {
1466                 .type                   = "rtc_hym8563",
1467                 .addr           = 0x51,
1468                 .flags                  = 0,
1469                 .irq            = RK30_PIN0_PB5,
1470         },
1471 #endif
1472 #if defined (CONFIG_MFD_WM831X_I2C)
1473         {
1474                 .type          = "wm8326",
1475                 .addr          = 0x34,
1476                 .flags         = 0,
1477                 .irq           = RK30_PIN0_PB3,
1478                 .platform_data = &wm831x_platdata,
1479         },
1480 #endif
1481 #if defined (CONFIG_MFD_TPS65910)
1482         {
1483         .type           = "tps65910",
1484         .addr           = TPS65910_I2C_ID0,
1485         .flags          = 0,
1486         .irq            = TPS65910_HOST_IRQ,
1487         .platform_data = &tps65910_data,
1488         },
1489 #endif
1490 };
1491 #endif
1492
1493 void __sramfunc board_pmu_suspend(void)
1494 {      
1495         #if defined (CONFIG_REGULATOR_ACT8846)
1496        if(pmic_is_act8846())
1497        board_pmu_act8846_suspend(); 
1498        #endif
1499         #if defined (CONFIG_MFD_WM831X_I2C)
1500        if(pmic_is_wm8326())
1501        board_pmu_wm8326_suspend();
1502         #endif
1503         #if defined (CONFIG_MFD_TPS65910)
1504        if(pmic_is_tps65910())
1505        board_pmu_tps65910_suspend(); 
1506     #endif   
1507 }
1508
1509 void __sramfunc board_pmu_resume(void)
1510 {      
1511         #if defined (CONFIG_REGULATOR_ACT8846)
1512        if(pmic_is_act8846())
1513        board_pmu_act8846_resume(); 
1514        #endif
1515         #if defined (CONFIG_MFD_WM831X_I2C)
1516        if(pmic_is_wm8326())
1517        board_pmu_wm8326_resume();
1518         #endif
1519         #if defined (CONFIG_MFD_TPS65910)
1520        if(pmic_is_tps65910())
1521        board_pmu_tps65910_resume(); 
1522         #endif
1523 }
1524
1525  int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1526
1527 #define grf_readl(offset)       readl_relaxed(RK30_GRF_BASE + offset)
1528 #define grf_writel(v, offset)   do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1529  
1530 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1531 {
1532 #ifdef CONFIG_RK30_PWM_REGULATOR
1533
1534 //      int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1535         sram_udelay(10000);
1536         gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1537         gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1538         gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1539         gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1540
1541         grf_writel((1<<28), GRF_GPIO3D_IOMUX);
1542         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
1543         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
1544         grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
1545 #endif 
1546 }
1547 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1548 {
1549 #ifdef CONFIG_RK30_PWM_REGULATOR
1550         grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
1551         grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
1552         grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
1553         grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
1554         sram_udelay(10000);
1555
1556 #endif
1557
1558 }
1559 extern void pwm_suspend_voltage(void);
1560 extern void pwm_resume_voltage(void);
1561 void  rk30_pwm_suspend_voltage_set(void)
1562 {
1563 #ifdef CONFIG_RK30_PWM_REGULATOR
1564         pwm_suspend_voltage();
1565 #endif
1566 }
1567 void  rk30_pwm_resume_voltage_set(void)
1568 {
1569 #ifdef CONFIG_RK30_PWM_REGULATOR
1570         pwm_resume_voltage();
1571 #endif
1572 }
1573
1574
1575 #ifdef CONFIG_I2C2_RK30
1576 static struct i2c_board_info __initdata i2c2_info[] = {
1577 #if defined (CONFIG_CT36X_TS)
1578         {
1579                 .type          = CT36X_NAME,
1580                 .addr          = 0x01,
1581                 .flags         = 0,
1582                 .platform_data = &ct36x_info,
1583         },
1584 #endif
1585 #if defined (CONFIG_LS_CM3217)
1586         {
1587                 .type          = "lightsensor",
1588                 .addr          = 0x10,
1589                 .flags         = 0,
1590                 .platform_data = &cm3217_info,
1591         },
1592 #endif
1593 #if defined(CONFIG_HDMI_CAT66121)
1594         {
1595                 .type           = "cat66121_hdmi",
1596                 .addr           = 0x4c,
1597                 .flags          = 0,
1598                 .irq            = RK30_PIN2_PD6,
1599                 .platform_data  = &rk_hdmi_pdata,
1600         },
1601 #endif
1602 };
1603 #endif
1604
1605 #ifdef CONFIG_I2C3_RK30
1606 static struct i2c_board_info __initdata i2c3_info[] = {
1607 };
1608 #endif
1609
1610 #ifdef CONFIG_I2C4_RK30
1611 static struct i2c_board_info __initdata i2c4_info[] = {
1612 #ifdef CONFIG_MFD_RK610
1613                 {
1614                         .type                   = "rk610_ctl",
1615                         .addr                   = 0x40,
1616                         .flags                  = 0,
1617                         .platform_data          = &rk610_ctl_pdata,
1618                 },
1619 #ifdef CONFIG_RK610_TVOUT
1620                 {
1621                         .type                   = "rk610_tvout",
1622                         .addr                   = 0x42,
1623                         .flags                  = 0,
1624                 },
1625 #endif
1626 #ifdef CONFIG_HDMI_RK610
1627                 {
1628                         .type                   = "rk610_hdmi",
1629                         .addr                   = 0x46,
1630                         .flags                  = 0,
1631                         .irq                    = INVALID_GPIO,
1632                 },
1633 #endif
1634 #ifdef CONFIG_SND_SOC_RK610
1635                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1636                         .type                   = "rk610_i2c_codec",
1637                         .addr                   = 0x60,
1638                         .flags                  = 0,
1639                         .platform_data          = &rk610_codec_pdata,                   
1640                 },
1641 #endif
1642 #endif
1643
1644 };
1645 #endif
1646
1647 #ifdef CONFIG_I2C_GPIO_RK30
1648 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1649 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1650 static int rk30_i2c_io_init(void)
1651 {
1652         //set iomux (gpio) here
1653         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1654         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1655
1656         return 0;
1657 }
1658 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1659        .sda_pin = I2C_SDA_PIN,
1660        .scl_pin = I2C_SCL_PIN,
1661        .udelay = 5, // clk = 500/udelay = 100Khz
1662        .timeout = 100,//msecs_to_jiffies(100),
1663        .bus_num    = 5,
1664        .io_init = rk30_i2c_io_init,
1665 };
1666 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1667 };
1668 #endif
1669
1670 static void __init rk30_i2c_register_board_info(void)
1671 {
1672 #ifdef CONFIG_I2C0_RK30
1673         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1674 #endif
1675 #ifdef CONFIG_I2C1_RK30
1676         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1677 #endif
1678 #ifdef CONFIG_I2C2_RK30
1679         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1680 #endif
1681 #ifdef CONFIG_I2C3_RK30
1682         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1683 #endif
1684 #ifdef CONFIG_I2C4_RK30
1685         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1686 #endif
1687 #ifdef CONFIG_I2C_GPIO_RK30
1688         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1689 #endif
1690 }
1691 //end of i2c
1692
1693 #define POWER_ON_PIN RK30_PIN0_PA0   //power_hold
1694 static void rk30_pm_power_off(void)
1695 {
1696         printk(KERN_ERR "rk30_pm_power_off start...\n");
1697 #if defined(CONFIG_MFD_WM831X)
1698         wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
1699         wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1700 #endif
1701 #if defined(CONFIG_REGULATOR_ACT8846)
1702        if (pmic_is_act8846()) {
1703                printk("enter dcdet===========\n");
1704                if(gpio_get_value (RK30_PIN0_PB2) == GPIO_LOW)
1705                {
1706                        printk("enter restart===========\n");
1707                        arm_pm_restart(0, NULL);
1708                }
1709                else
1710                 {
1711                         act8846_device_shutdown();
1712                 }
1713        }
1714 #endif
1715         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1716         while (1);
1717 }
1718
1719 static void __init machine_rk30_board_init(void)
1720 {
1721         //avs_init();
1722         gpio_request(POWER_ON_PIN, "poweronpin");
1723         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1724         
1725         pm_power_off = rk30_pm_power_off;
1726         
1727         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1728
1729
1730         rk30_i2c_register_board_info();
1731         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1732         platform_add_devices(devices, ARRAY_SIZE(devices));
1733         rk_platform_add_display_devices();
1734         board_usb_detect_init(RK30_PIN0_PA7);
1735
1736 #ifdef CONFIG_WIFI_CONTROL_FUNC
1737         rk29sdk_wifi_bt_gpio_control_init();
1738 #endif
1739
1740 #if defined(CONFIG_MT6620)
1741             clk_set_rate(clk_get_sys("rk_serial.1", "uart"), 48*1000000);
1742 #endif
1743
1744 #if defined(CONFIG_MT5931_MT6622)
1745                 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
1746 #endif          
1747 }
1748
1749 static void __init rk30_reserve(void)
1750 {
1751 #ifdef CONFIG_ION
1752         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1753 #endif
1754
1755 #ifdef CONFIG_FB_ROCKCHIP
1756         resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
1757         resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
1758 #if 0
1759         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1760         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1761 #endif
1762
1763 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
1764         resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
1765         resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
1766 #endif
1767 #endif
1768
1769
1770 #ifdef CONFIG_VIDEO_RK29
1771         rk30_camera_request_reserve_mem();
1772 #endif
1773         
1774 #ifdef CONFIG_GPS_RK
1775         //it must be more than 8MB
1776         rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
1777 #endif
1778         board_mem_reserved();
1779 }
1780
1781 /**
1782  * dvfs_cpu_logic_table: table for arm and logic dvfs 
1783  * @frequency   : arm frequency
1784  * @cpu_volt    : arm voltage depend on frequency
1785  * @logic_volt  : logic voltage arm requests depend on frequency
1786  * comments     : min arm/logic voltage
1787  */
1788 static struct cpufreq_frequency_table dvfs_arm_table[] = {
1789 #if 0
1790         {.frequency = 312 * 1000,       .index = 850 * 1000},
1791         {.frequency = 504 * 1000,       .index = 900 * 1000},
1792         {.frequency = 816 * 1000,       .index = 950 * 1000},
1793         {.frequency = 1008 * 1000,      .index = 1025 * 1000},
1794         {.frequency = 1200 * 1000,      .index = 1100 * 1000},
1795         {.frequency = 1416 * 1000,      .index = 1200 * 1000},
1796         //{.frequency = 1608 * 1000,      .index = 1300 * 1000},
1797 #else
1798         {.frequency = 312 * 1000,       .index = 800 * 1000},
1799         {.frequency = 504 * 1000,       .index = 850 * 1000},
1800         {.frequency = 816 * 1000,       .index = 950 * 1000},
1801         {.frequency = 1008 * 1000,      .index = 1000 * 1000},
1802         {.frequency = 1200 * 1000,      .index = 1075 * 1000},
1803         {.frequency = 1416 * 1000,      .index = 1175 * 1000},
1804         {.frequency = 1608 * 1000,      .index = 1275 * 1000},
1805
1806 #endif
1807         {.frequency = CPUFREQ_TABLE_END},
1808 };
1809
1810 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1811         {.frequency = 100 * 1000,       .index = 950 * 1000},
1812         {.frequency = 200 * 1000,       .index = 975 * 1000},
1813         {.frequency = 266 * 1000,       .index = 1000 * 1000},
1814         {.frequency = 300 * 1000,       .index = 1050 * 1000},
1815         {.frequency = 400 * 1000,       .index = 1100 * 1000},
1816         //{.frequency = 600 * 1000,     .index = 1200 * 1000},
1817         {.frequency = CPUFREQ_TABLE_END},
1818 };
1819
1820 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1821         //{.frequency = 200 * 1000 + DDR_FREQ_SUSPEND,    .index = 950 * 1000},
1822         //{.frequency = 300 * 1000 + DDR_FREQ_VIDEO,      .index = 1000 * 1000},
1823         {.frequency = 400 * 1000 + DDR_FREQ_NORMAL,     .index = 1100 * 1000},
1824         {.frequency = CPUFREQ_TABLE_END},
1825 };
1826
1827 //#define DVFS_CPU_TABLE_SIZE   (ARRAY_SIZE(dvfs_cpu_logic_table))
1828 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1829 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1830
1831 void __init board_clock_init(void)
1832 {
1833         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1834         //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1835         dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
1836         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1837         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1838 }
1839
1840 MACHINE_START(RK30, "RK30board")
1841         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
1842         .fixup          = rk30_fixup,
1843         .reserve        = &rk30_reserve,
1844         .map_io         = rk30_map_io,
1845         .init_irq       = rk30_init_irq,
1846         .timer          = &rk30_timer,
1847         .init_machine   = machine_rk30_board_init,
1848 MACHINE_END