3 * Copyright (C) 2012 ROCKCHIP, Inc.
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.
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.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.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>
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>
38 #include <mach/board.h>
39 #include <mach/hardware.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 <plat/efuse.h>
50 #include <linux/regulator/rk29-pwm-regulator.h>
51 #if defined(CONFIG_CT36X_TS)
52 #include <linux/ct36x.h>
54 #if defined(CONFIG_MFD_RK610)
55 #include <linux/mfd/rk610_core.h>
58 #if defined(CONFIG_RK_HDMI)
59 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
62 #if defined(CONFIG_SPIM_RK29)
63 #include "../../../drivers/spi/rk29_spim.h"
65 #if defined(CONFIG_MT6229)
66 #include <linux/mt6229.h>
68 #if defined(CONFIG_GPS_RK)
69 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
72 #if defined(CONFIG_MT6620)
73 #include <linux/gps.h>
75 #ifdef CONFIG_RK_REMOTECTL
76 #include <mach/remotectl.h>
79 #include "../mach-rk30/board-rk3168-ds1006h-camera.c"
81 #include <linux/scaler-core.h>
83 static struct rk29_keys_button key_button[] = {
87 .gpio = RK30_PIN0_PA4,
88 .active_low = PRESS_LEV_LOW,
97 .active_low = PRESS_LEV_LOW,
101 .desc = "mode_switch",
104 //.code = KEY_VOLUMEUP,
107 .gpio = INVALID_GPIO,
108 .active_low = PRESS_LEV_LOW,
113 struct rk29_keys_platform_data rk29_keys_pdata = {
114 .buttons = key_button,
115 .nbuttons = ARRAY_SIZE(key_button),
116 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
121 v1.1 : rk610 lvds + rk610 codec + MT5931_MT6622 + light photoresistor + adc/cw2015
122 v1.2 : lvds + rt5631 + M500 + us5151 + adc
124 #define DS1006H_V1_2_SUPPORT 1
125 int get_harware_version()
127 #if DS1006H_V1_2_SUPPORT
133 EXPORT_SYMBOL_GPL(get_harware_version);
135 #if defined(CONFIG_CT36X_TS)
137 #define TOUCH_MODEL 363
138 #define TOUCH_MAX_X 1280
139 #define TOUCH_MAX_y 800
140 #define TOUCH_RESET_PIN RK30_PIN0_PB6
141 #define TOUCH_INT_PIN RK30_PIN1_PB7
143 static struct ct36x_platform_data ct36x_info = {
144 .model = TOUCH_MODEL,
145 .x_max = TOUCH_MAX_X,
146 .y_max = TOUCH_MAX_y,
149 .gpio = TOUCH_RESET_PIN,
153 .gpio = TOUCH_INT_PIN,
156 .orientation = {1, 0, 0, 1},
159 static struct spi_board_info board_spi_devices[] = {
162 /***********************************************************
164 ************************************************************/
165 #ifdef CONFIG_BACKLIGHT_RK29_BL
167 #define PWM_MODE PWM3
168 #define PWM_EFFECT_VALUE 1
170 #define LCD_DISP_ON_PIN
172 #ifdef LCD_DISP_ON_PIN
173 #define BL_EN_PIN RK30_PIN0_PA2
174 #define BL_EN_VALUE GPIO_HIGH
176 static int rk29_backlight_io_init(void)
181 #ifdef LCD_DISP_ON_PIN
182 ret = gpio_request(BL_EN_PIN, NULL);
184 gpio_free(BL_EN_PIN);
187 gpio_direction_output(BL_EN_PIN, 0);
188 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
194 static int rk29_backlight_io_deinit(void)
196 int ret = 0, pwm_gpio;
198 #ifdef LCD_DISP_ON_PIN
199 gpio_free(BL_EN_PIN);
202 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
203 gpio_request(pwm_gpio, NULL);
204 gpio_direction_output(pwm_gpio, GPIO_LOW);
208 static int rk29_backlight_pwm_suspend(void)
210 int ret = 0, pwm_gpio;
212 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
213 if (gpio_request(pwm_gpio, NULL)) {
214 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
217 gpio_direction_output(pwm_gpio, GPIO_LOW);
218 #ifdef LCD_DISP_ON_PIN
219 gpio_direction_output(BL_EN_PIN, 0);
220 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
225 static int rk29_backlight_pwm_resume(void)
227 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
231 #ifdef LCD_DISP_ON_PIN
233 gpio_direction_output(BL_EN_PIN, 1);
234 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
239 static struct rk29_bl_info rk29_bl_info = {
240 .min_brightness = 65,
241 .max_brightness = 150,
242 .brightness_mode =BRIGHTNESS_MODE_CONIC,
243 .pre_div = 30 * 1000, // pwm output clk: 30k;
245 .bl_ref = PWM_EFFECT_VALUE,
246 .io_init = rk29_backlight_io_init,
247 .io_deinit = rk29_backlight_io_deinit,
248 .pwm_suspend = rk29_backlight_pwm_suspend,
249 .pwm_resume = rk29_backlight_pwm_resume,
252 static struct platform_device rk29_device_backlight = {
253 .name = "rk29_backlight",
256 .platform_data = &rk29_bl_info,
261 #ifdef CONFIG_RK_REMOTECTL
263 void rk30_remotectl_iomux(void)
268 struct RKxx_remotectl_platform_data rk30_remotectl_pdata = {
269 .gpio = RK30_PIN0_PA3,
272 .set_iomux = rk30_remotectl_iomux,
275 static struct platform_device rk30_device_remotectl = {
276 .name = "rkxx-remotectl",
279 .platform_data = &rk30_remotectl_pdata,
285 #if defined (CONFIG_GS_MMA8452)
286 #define MMA8452_INT_PIN RK30_PIN0_PB7
288 static int mma8452_init_platform_hw(void)
293 static struct sensor_platform_data mma8452_info = {
294 .type = SENSOR_TYPE_ACCEL,
297 .init_platform_hw = mma8452_init_platform_hw,
298 .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
301 #if defined (CONFIG_GS_LIS3DH)
302 #define LIS3DH_INT_PIN RK30_PIN0_PB7
304 static int lis3dh_init_platform_hw(void)
310 static struct sensor_platform_data lis3dh_info = {
311 .type = SENSOR_TYPE_ACCEL,
314 .init_platform_hw = lis3dh_init_platform_hw,
315 .orientation = {-1, 0, 0, 0, 1, 0, 0, 0, -1},
319 #if defined (CONFIG_COMPASS_AK8963)
320 static struct sensor_platform_data akm8963_info =
322 .type = SENSOR_TYPE_COMPASS,
355 #if defined(CONFIG_LS_PHOTORESISTOR)
356 static struct sensor_platform_data light_photoresistor_info = {
357 .type = SENSOR_TYPE_LIGHT,
360 .poll_delay_ms = 200,
364 #if defined (CONFIG_COMPASS_AK8975)
365 static struct sensor_platform_data akm8975_info =
367 .type = SENSOR_TYPE_COMPASS,
400 #if defined(CONFIG_MT6229)
401 static int mt6229_io_init(void)
404 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
405 k30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
406 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
407 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
408 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
409 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
414 static int mt6229_io_deinit(void)
420 struct rk29_mt6229_data rk29_mt6229_info = {
421 .io_init = mt6229_io_init,
422 .io_deinit = mt6229_io_deinit,
423 .modem_power_en = RK30_PIN0_PC6,
424 .bp_power = RK30_PIN2_PD5,
425 .modem_usb_en = RK30_PIN0_PC7,
426 .modem_uart_en = RK30_PIN2_PD4,
427 .bp_wakeup_ap = RK30_PIN0_PC5,
428 .ap_ready = RK30_PIN0_PC4,
431 struct platform_device rk29_device_mt6229 = {
435 .platform_data = &rk29_mt6229_info,
440 #if defined(CONFIG_GYRO_L3G4200D)
442 #include <linux/l3g4200d.h>
443 #define L3G4200D_INT_PIN RK30_PIN0_PB4
445 static int l3g4200d_init_platform_hw(void)
450 static struct sensor_platform_data l3g4200d_info = {
451 .type = SENSOR_TYPE_GYROSCOPE,
454 .orientation = {1, 0, 0 , 0 , -1, 0, 0, 0, -1},
455 .init_platform_hw = l3g4200d_init_platform_hw,
456 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
463 #ifdef CONFIG_LS_CM3217
464 static struct sensor_platform_data cm3217_info = {
465 .type = SENSOR_TYPE_LIGHT,
467 .poll_delay_ms = 500,
472 #ifdef CONFIG_FB_ROCKCHIP
474 #if DS1006H_V1_2_SUPPORT
475 #define LCD_CS_PIN RK30_PIN0_PB0
477 #define LCD_CS_PIN INVALID_GPIO
479 #define LCD_CS_VALUE GPIO_HIGH
481 #if DS1006H_V1_2_SUPPORT
482 #define LCD_EN_PIN RK30_PIN0_PB1
484 #define LCD_EN_PIN RK30_PIN0_PB0
486 #define LCD_EN_VALUE GPIO_LOW
488 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
492 if(LCD_CS_PIN !=INVALID_GPIO)
494 ret = gpio_request(LCD_CS_PIN, NULL);
497 gpio_free(LCD_CS_PIN);
498 printk(KERN_ERR "request lcd cs pin fail!\n");
503 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
507 if(LCD_EN_PIN !=INVALID_GPIO)
509 ret = gpio_request(LCD_EN_PIN, NULL);
512 gpio_free(LCD_EN_PIN);
513 printk(KERN_ERR "request lcd en pin fail!\n");
518 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
523 static int rk_fb_io_disable(void)
525 if(LCD_CS_PIN !=INVALID_GPIO)
527 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
529 if(LCD_EN_PIN !=INVALID_GPIO)
531 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
535 static int rk_fb_io_enable(void)
537 if(LCD_CS_PIN !=INVALID_GPIO)
539 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
541 if(LCD_EN_PIN !=INVALID_GPIO)
543 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
548 #if defined(CONFIG_LCDC1_RK3188)
549 struct rk29fb_info lcdc1_screen_info = {
550 .prop = EXTEND, //extend display device
552 .set_screen_info = hdmi_init_lcdc,
556 extern void set_vga_lcd_info(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info);
558 #if defined(CONFIG_LCDC0_RK3188)
559 struct rk29fb_info lcdc0_screen_info = {
560 .prop = PRMRY, //primary display device
561 .io_init = rk_fb_io_init,
562 .io_disable = rk_fb_io_disable,
563 .io_enable = rk_fb_io_enable,
564 //.set_screen_info = set_lcd_info,
565 .set_screen_info = set_vga_lcd_info,
570 static struct resource resource_fb[] = {
574 .end = 0,//RK30_FB0_MEM_SIZE - 1,
575 .flags = IORESOURCE_MEM,
578 .name = "ipp buf", //for rotate
580 .end = 0,//RK30_FB0_MEM_SIZE - 1,
581 .flags = IORESOURCE_MEM,
586 .end = 0,//RK30_FB0_MEM_SIZE - 1,
587 .flags = IORESOURCE_MEM,
591 static struct platform_device device_fb = {
594 .num_resources = ARRAY_SIZE(resource_fb),
595 .resource = resource_fb,
599 #if defined(CONFIG_ARCH_RK3188)
600 static struct resource resource_mali[] = {
605 .flags = IORESOURCE_MEM,
610 static struct platform_device device_mali= {
611 .name = "mali400_ump",
613 .num_resources = ARRAY_SIZE(resource_mali),
614 .resource = resource_mali,
618 #if defined(CONFIG_LCDC0_RK3188)
619 static struct resource resource_lcdc0[] = {
622 .start = RK30_LCDC0_PHYS,
623 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
624 .flags = IORESOURCE_MEM,
631 .flags = IORESOURCE_IRQ,
635 static struct platform_device device_lcdc0 = {
638 .num_resources = ARRAY_SIZE(resource_lcdc0),
639 .resource = resource_lcdc0,
641 .platform_data = &lcdc0_screen_info,
645 #if defined(CONFIG_LCDC1_RK3188)
646 static struct resource resource_lcdc1[] = {
649 .start = RK30_LCDC1_PHYS,
650 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
651 .flags = IORESOURCE_MEM,
657 .flags = IORESOURCE_IRQ,
661 static struct platform_device device_lcdc1 = {
664 .num_resources = ARRAY_SIZE(resource_lcdc1),
665 .resource = resource_lcdc1,
667 .platform_data = &lcdc1_screen_info,
672 #if defined(CONFIG_MFD_RK610)
673 #define RK610_RST_PIN RK30_PIN3_PB2
674 static int rk610_power_on_init(void)
677 if(RK610_RST_PIN != INVALID_GPIO)
679 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
682 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
686 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
688 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
690 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
699 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
700 .rk610_power_on_init = rk610_power_on_init,
704 #ifdef CONFIG_SND_SOC_RK610
705 static int rk610_codec_io_init(void)
708 //Must not gpio_request
712 static struct rk610_codec_platform_data rk610_codec_pdata = {
713 .spk_ctl_io = RK30_PIN2_PD7,
714 .io_init = rk610_codec_io_init,
719 #ifdef CONFIG_RK_HDMI
720 #define RK_HDMI_RST_PIN RK30_PIN3_PB2
721 static int rk_hdmi_power_init(void)
725 if(RK_HDMI_RST_PIN != INVALID_GPIO)
727 if (gpio_request(RK_HDMI_RST_PIN, NULL)) {
728 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
731 gpio_direction_output(RK_HDMI_RST_PIN, GPIO_LOW);
732 gpio_set_value(RK_HDMI_RST_PIN, GPIO_LOW);
734 gpio_set_value(RK_HDMI_RST_PIN, GPIO_HIGH);
739 static struct rk_hdmi_platform_data rk_hdmi_pdata = {
740 //.io_init = rk_hdmi_power_init,
744 #define ION_RESERVE_SIZE (80 * SZ_1M)
745 static struct ion_platform_data rk30_ion_pdata = {
749 .type = ION_HEAP_TYPE_CARVEOUT,
750 .id = ION_NOR_HEAP_ID,
752 .size = ION_RESERVE_SIZE,
757 static struct platform_device device_ion = {
758 .name = "ion-rockchip",
761 .platform_data = &rk30_ion_pdata,
766 /**************************************************************************************************
767 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
768 **************************************************************************************************/
769 #ifdef CONFIG_SDMMC_RK29
770 #include "board-rk3188-ac-sdmmc-config.c"
771 #include "../plat-rk/rk-sdmmc-ops.c"
772 #include "../plat-rk/rk-sdmmc-wifi.c"
773 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
775 #ifdef CONFIG_SDMMC0_RK29
776 static int rk29_sdmmc0_cfg_gpio(void)
778 #ifdef CONFIG_SDMMC_RK29_OLD
780 iomux_set(MMC0_CLKOUT);
786 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
788 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
789 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
792 rk29_sdmmc_set_iomux(0, 0xFFFF);
794 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
795 #if SDMMC_USE_NEW_IOMUX_API
796 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
798 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
801 #if SDMMC_USE_NEW_IOMUX_API
802 iomux_set(MMC0_DETN);
804 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
808 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
809 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
810 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
818 #define CONFIG_SDMMC0_USE_DMA
819 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
821 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
822 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
823 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
825 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
826 .io_init = rk29_sdmmc0_cfg_gpio,
828 #if !defined(CONFIG_SDMMC_RK29_OLD)
829 .set_iomux = rk29_sdmmc_set_iomux,
832 .dma_name = "sd_mmc",
833 #ifdef CONFIG_SDMMC0_USE_DMA
839 #if defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
840 .status = rk29sdk_wifi_mmc0_status,
841 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
844 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
845 .power_en = RK29SDK_SD_CARD_PWR_EN,
846 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
848 .power_en = INVALID_GPIO,
849 .power_en_level = GPIO_LOW,
851 .enable_sd_wakeup = 0,
853 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
854 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
855 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
857 .write_prt = INVALID_GPIO,
861 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
862 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
863 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
864 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
866 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
867 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
868 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
870 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
871 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
882 #endif // CONFIG_SDMMC0_RK29
884 #ifdef CONFIG_SDMMC1_RK29
885 #define CONFIG_SDMMC1_USE_DMA
886 static int rk29_sdmmc1_cfg_gpio(void)
888 #if defined(CONFIG_SDMMC_RK29_OLD)
890 iomux_set(MMC1_CLKOUT);
897 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
898 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
899 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
907 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
909 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
910 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
913 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
914 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
915 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
918 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
921 .io_init = rk29_sdmmc1_cfg_gpio,
923 #if !defined(CONFIG_SDMMC_RK29_OLD)
924 .set_iomux = rk29_sdmmc_set_iomux,
928 #ifdef CONFIG_SDMMC1_USE_DMA
934 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
935 .status = rk29sdk_wifi_status,
936 .register_status_notify = rk29sdk_wifi_status_register,
939 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
940 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
941 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
943 .write_prt = INVALID_GPIO,
946 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
947 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
951 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
952 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
953 .io = RK29SDK_SD_CARD_DETECT_N,
958 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
959 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
961 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
962 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
963 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
965 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
966 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
976 .enable_sd_wakeup = 0,
978 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
980 /**************************************************************************************************
981 * the end of setting for SDMMC devices
982 **************************************************************************************************/
984 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
985 static int ac_current = -1;
986 #define CHARING_CURRENT_500MA 0
987 #define CHARING_CURRENT_1000MA 1
989 #define DC_CUR_SET_PIN RK30_PIN0_PB0
990 #define CHARGE_OK_PIN RK30_PIN0_PA6
991 #define DC_DET_PIN RK30_PIN0_PB2
992 static int rk30_battery_adc_io_init(void)
995 printk("charging: set charging current 500ma \n");
996 ac_current = CHARING_CURRENT_500MA;
997 //dc charge detect pin
998 ret = gpio_request(DC_DET_PIN, NULL);
1000 printk("failed to request dc_det gpio\n");
1004 gpio_pull_updown(DC_DET_PIN, 1);//important
1005 ret = gpio_direction_input(DC_DET_PIN);
1007 printk("failed to set gpio dc_det input\n");
1012 ret = gpio_request(CHARGE_OK_PIN, NULL);
1014 printk("failed to request charge_ok gpio\n");
1018 gpio_pull_updown(CHARGE_OK_PIN, 1);//important
1019 ret = gpio_direction_input(CHARGE_OK_PIN);
1021 printk("failed to set gpio charge_ok input\n");
1024 //charge current set pin
1025 ret = gpio_request(DC_CUR_SET_PIN, NULL);
1027 printk("failed to request DC_CUR_SET_PIN gpio\n");
1031 ret = gpio_direction_output(DC_CUR_SET_PIN, GPIO_LOW);//500ma
1033 printk("failed to set gpio DC_CUR_SET_PIN output\n");
1041 static int set_usb_charging_current(int mode)
1044 if ( (ac_current==CHARING_CURRENT_1000MA) && (mode == PC_MODE) ) {
1045 gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW);
1046 ac_current = CHARING_CURRENT_500MA;
1048 else if ((mode == ADAPT_MODE) && (ac_current==CHARING_CURRENT_500MA))
1050 gpio_set_value(DC_CUR_SET_PIN, GPIO_HIGH);
1051 ac_current = CHARING_CURRENT_1000MA;
1055 gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW);
1056 ac_current = CHARING_CURRENT_500MA;
1060 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1061 .dc_det_pin = RK30_PIN0_PB2,
1062 .batt_low_pin = INVALID_GPIO,
1063 .charge_set_pin = INVALID_GPIO,
1064 .charge_ok_pin = RK30_PIN0_PA6,
1065 .usb_det_pin = INVALID_GPIO,
1066 .dc_det_level = GPIO_LOW,
1067 .charge_ok_level = GPIO_HIGH,
1069 .reference_voltage = 1800, // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
1070 .pull_up_res = 200, //divider resistance , pull-up resistor
1071 .pull_down_res = 120, //divider resistance , pull-down resistor
1073 .is_reboot_charging = 1,
1074 .save_capacity = 1 ,
1075 .low_voltage_protection = 3600,
1076 .io_init = rk30_battery_adc_io_init,
1077 .control_usb_charging= set_usb_charging_current,
1080 static struct platform_device rk30_device_adc_battery = {
1081 .name = "rk30-battery",
1084 .platform_data = &rk30_adc_battery_platdata,
1088 #ifdef CONFIG_RK30_PWM_REGULATOR
1089 static int pwm_voltage_map[] = {
1090 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
1093 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1095 .supply = "vdd_cpu",
1099 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1103 .name = "PWM_DCDC1",
1105 .max_uV = 1800000, //0.6-1.8V
1107 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1109 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1110 .consumer_supplies = pwm_dcdc1_consumers,
1114 static struct pwm_platform_data pwm_regulator_info[1] = {
1117 .pwm_gpio = RK30_PIN3_PD4,
1118 .pwm_iomux_pwm = PWM1,
1119 .pwm_iomux_gpio = GPIO3_D4,
1120 .pwm_voltage = 1100000,
1121 .suspend_voltage = 1000000,
1124 .coefficient = 575, //57.5%
1125 .pwm_voltage_map = pwm_voltage_map,
1126 .init_data = &pwm_regulator_init_dcdc[0],
1130 struct platform_device pwm_regulator_device[1] = {
1132 .name = "pwm-voltage-regulator",
1135 .platform_data = &pwm_regulator_info[0],
1141 #ifdef CONFIG_RK29_VMAC
1142 #define PHY_PWR_EN_GPIO INVALID_GPIO
1143 #define PHY_PWR_EN_IOMUX GPIO3_D2
1144 #define PHY_PWR_EN_VALUE GPIO_HIGH
1145 #define RMII_EXT_CLK
1146 #include "../mach-rk30/board-rk31-sdk-vmac.c"
1149 #ifdef CONFIG_RFKILL_RK
1150 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1151 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1152 .type = RFKILL_TYPE_BLUETOOTH,
1154 .poweron_gpio = { // BT_REG_ON
1155 .io = INVALID_GPIO, //RK30_PIN3_PC7,
1156 .enable = GPIO_HIGH,
1158 .name = "bt_poweron",
1163 .reset_gpio = { // BT_RST
1164 .io = RK30_PIN3_PA0, // set io to INVALID_GPIO for disable it
1172 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1173 .io = RK30_PIN3_PB0, // set io to INVALID_GPIO for disable it
1174 .enable = GPIO_HIGH,
1181 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1183 .io = RK30_PIN3_PB1, // set io to INVALID_GPIO for disable it
1184 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1191 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1192 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1202 static struct platform_device device_rfkill_rk = {
1203 .name = "rfkill_rk",
1206 .platform_data = &rfkill_rk_platdata,
1211 #if defined(CONFIG_GPS_RK)
1212 int rk_gps_io_init(void)
1214 printk("%s \n", __FUNCTION__);
1216 rk30_mux_api_set(GPIO1B5_UART3RTSN_NAME, GPIO1B_GPIO1B5);//VCC_EN
1217 gpio_request(RK30_PIN1_PB5, NULL);
1218 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1220 rk30_mux_api_set(GPIO1B4_UART3CTSN_GPSRFCLK_NAME, GPIO1B_GPSRFCLK);//GPS_CLK
1221 rk30_mux_api_set(GPIO1B2_UART3SIN_GPSMAG_NAME, GPIO1B_GPSMAG);//GPS_MAG
1222 rk30_mux_api_set(GPIO1B3_UART3SOUT_GPSSIG_NAME, GPIO1B_GPSSIG);//GPS_SIGN
1224 rk30_mux_api_set(GPIO1A6_UART1CTSN_SPI0CLK_NAME, GPIO1A_GPIO1A6);//SPI_CLK
1225 gpio_request(RK30_PIN1_PA6, NULL);
1226 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1228 rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0TXD_NAME, GPIO1A_GPIO1A5);//SPI_MOSI
1229 gpio_request(RK30_PIN1_PA5, NULL);
1230 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1232 rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0CSN0_NAME, GPIO1A_GPIO1A7);//SPI_CS
1233 gpio_request(RK30_PIN1_PA7, NULL);
1234 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1237 int rk_gps_power_up(void)
1239 printk("%s \n", __FUNCTION__);
1244 int rk_gps_power_down(void)
1246 printk("%s \n", __FUNCTION__);
1251 int rk_gps_reset_set(int level)
1255 int rk_enable_hclk_gps(void)
1257 printk("%s \n", __FUNCTION__);
1258 clk_enable(clk_get(NULL, "hclk_gps"));
1261 int rk_disable_hclk_gps(void)
1263 printk("%s \n", __FUNCTION__);
1264 clk_disable(clk_get(NULL, "hclk_gps"));
1267 struct rk_gps_data rk_gps_info = {
1268 .io_init = rk_gps_io_init,
1269 .power_up = rk_gps_power_up,
1270 .power_down = rk_gps_power_down,
1271 .reset = rk_gps_reset_set,
1272 .enable_hclk_gps = rk_enable_hclk_gps,
1273 .disable_hclk_gps = rk_disable_hclk_gps,
1274 .GpsSign = RK30_PIN1_PB3,
1275 .GpsMag = RK30_PIN1_PB2, //GPIO index
1276 .GpsClk = RK30_PIN1_PB4, //GPIO index
1277 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1278 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1279 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1280 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1284 .u32GpsPhyAddr = RK30_GPS_PHYS,
1285 .u32GpsPhySize = RK30_GPS_SIZE,
1288 struct platform_device rk_device_gps = {
1289 .name = "gps_hv5820b",
1292 .platform_data = &rk_gps_info,
1297 #if defined(CONFIG_MT5931_MT6622)
1298 static struct mt6622_platform_data mt6622_platdata = {
1299 .power_gpio = { // BT_REG_ON
1300 #if DS1006H_V1_2_SUPPORT
1301 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1303 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1305 .enable = GPIO_HIGH,
1311 .reset_gpio = { // BT_RST
1312 #if DS1006H_V1_2_SUPPORT
1313 .io = RK30_PIN3_PD1,
1315 .io = RK30_PIN0_PD7,
1317 .enable = GPIO_HIGH,
1324 #if DS1006H_V1_2_SUPPORT
1325 .io = RK30_PIN0_PA5,
1327 .io = RK30_PIN3_PD2,
1329 .enable = GPIO_HIGH,
1336 static struct platform_device device_mt6622 = {
1340 .platform_data = &mt6622_platdata,
1345 #if defined CONFIG_TCC_BT_DEV
1346 static struct tcc_bt_platform_data tcc_bt_platdata = {
1348 .power_gpio = { // ldoon
1349 .io = RK2928_PIN3_PC0,
1350 .enable = GPIO_HIGH,
1356 .wake_host_gpio = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1357 .io = RK2928_PIN0_PC5, // set io to INVALID_GPIO for disable it
1358 .enable = IRQF_TRIGGER_RISING,// set IRQF_TRIGGER_FALLING for falling, set IRQF_TRIGGER_RISING for rising
1365 static struct platform_device device_tcc_bt = {
1366 .name = "tcc_bt_dev",
1369 .platform_data = &tcc_bt_platdata,
1374 #if defined(CONFIG_AC_USB_SWITCH)
1375 static struct ac_usb_switch_platform_data ac_usb_switch_platdata= {
1376 .usb_switch_pin = RK30_PIN3_PB2,
1377 .pc_state_pin = INVALID_GPIO,
1379 static struct platform_device device_ac_usb_switch = {
1380 .name = "ac_usb_switch",
1383 .platform_data = &ac_usb_switch_platdata,
1388 static struct platform_device *devices[] __initdata = {
1393 #ifdef CONFIG_WIFI_CONTROL_FUNC
1394 &rk29sdk_wifi_device,
1397 #if defined(CONFIG_MT6620)
1401 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1402 &rk30_device_adc_battery,
1404 #ifdef CONFIG_RFKILL_RK
1407 #ifdef CONFIG_GPS_RK
1410 #ifdef CONFIG_MT5931_MT6622
1413 #if defined(CONFIG_MT6229)
1414 &rk29_device_mt6229,
1416 #if defined(CONFIG_ARCH_RK3188)
1420 #ifdef CONFIG_TCC_BT_DEV
1423 #if defined(CONFIG_AC_USB_SWITCH)
1424 &device_ac_usb_switch,
1426 #ifdef CONFIG_RK_REMOTECTL
1427 &rk30_device_remotectl,
1433 static int rk_platform_add_display_devices(void)
1435 struct platform_device *fb = NULL; //fb
1436 struct platform_device *lcdc0 = NULL; //lcdc0
1437 struct platform_device *lcdc1 = NULL; //lcdc1
1438 struct platform_device *bl = NULL; //backlight
1439 #ifdef CONFIG_FB_ROCKCHIP
1443 #if defined(CONFIG_LCDC0_RK3188)
1444 lcdc0 = &device_lcdc0,
1447 #if defined(CONFIG_LCDC1_RK3188)
1448 lcdc1 = &device_lcdc1,
1451 #ifdef CONFIG_BACKLIGHT_RK29_BL
1452 bl = &rk29_device_backlight,
1454 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1461 #ifdef CONFIG_I2C0_RK30
1462 static struct i2c_board_info __initdata i2c0_info[] = {
1463 #if defined (CONFIG_GS_MMA8452)
1465 .type = "gs_mma8452",
1468 .irq = MMA8452_INT_PIN,
1469 .platform_data = &mma8452_info,
1473 #if defined (CONFIG_GS_LIS3DH)
1475 .type = "gs_lis3dh",
1476 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1478 .irq = LIS3DH_INT_PIN,
1479 .platform_data = &lis3dh_info,
1482 #if defined (CONFIG_COMPASS_AK8963)
1487 .irq = RK30_PIN3_PD7,
1488 .platform_data = &akm8963_info,
1492 #if defined (CONFIG_LS_PHOTORESISTOR)
1494 .type = "ls_photoresistor",
1497 .irq = INVALID_GPIO,
1498 .platform_data = &light_photoresistor_info,
1502 #if defined (CONFIG_COMPASS_AK8975)
1507 .irq = RK30_PIN3_PD7,
1508 .platform_data = &akm8975_info,
1509 .irq = RK30_PIN3_PD7,
1510 .platform_data = &akm8975_info,
1513 #if defined (CONFIG_GYRO_L3G4200D)
1515 .type = "l3g4200d_gryo",
1518 .irq = L3G4200D_INT_PIN,
1519 .platform_data = &l3g4200d_info,
1522 #if defined (CONFIG_SND_SOC_RK1000)
1524 .type = "rk1000_i2c_codec",
1529 .type = "rk1000_control",
1534 #if defined (CONFIG_SND_SOC_CX2070X)
1544 int __sramdata g_pmic_type = 0;
1545 #ifdef CONFIG_I2C1_RK30
1546 #ifdef CONFIG_REGULATOR_ACT8846
1547 #define PMU_POWER_SLEEP RK30_PIN0_PD1
1548 #define PMU_VSEL RK30_PIN3_PD3
1549 #define ACT8846_HOST_IRQ RK30_PIN0_PB3
1551 static struct pmu_info act8846_dcdc_info[] = {
1553 .name = "act_dcdc1", //ddr
1556 .suspend_vol = 1200000,
1559 .name = "vdd_core", //logic
1562 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1563 .suspend_vol = 1200000,
1565 .suspend_vol = 900000,
1569 .name = "vdd_cpu", //arm
1572 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1573 .suspend_vol = 1200000,
1575 .suspend_vol = 900000,
1579 .name = "act_dcdc4", //vccio
1582 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1583 .suspend_vol = 3000000,
1585 .suspend_vol = 2800000,
1590 static struct pmu_info act8846_ldo_info[] = {
1592 .name = "act_ldo1", //vdd10
1597 .name = "act_ldo2", //vdd12
1602 .name = "act_ldo3", //vcc18_cif
1607 .name = "act_ldo4", //vcca33
1612 .name = "act_ldo5", //vcctp
1617 .name = "act_ldo6", //vcc_jetta
1622 .name = "act_ldo7", //vcc18
1627 .name = "act_ldo8", //vcc28_cif
1633 #include "../mach-rk30/board-pmu-act8846.c"
1636 #ifdef CONFIG_MFD_WM831X_I2C
1637 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1639 static struct pmu_info wm8326_dcdc_info[] = {
1641 .name = "vdd_core", //logic
1644 .suspend_vol = 950000,
1647 .name = "vdd_cpu", //arm
1650 .suspend_vol = 950000,
1653 .name = "dcdc3", //ddr
1656 .suspend_vol = 1150000,
1658 #ifdef CONFIG_MACH_RK3066_SDK
1660 .name = "dcdc4", //vcc_io
1663 .suspend_vol = 3000000,
1667 .name = "dcdc4", //vcc_io
1670 .suspend_vol = 2800000,
1675 static struct pmu_info wm8326_ldo_info[] = {
1677 .name = "ldo1", //vcc18_cif
1680 .suspend_vol = 1800000,
1683 .name = "ldo2", //vccio_wl
1686 .suspend_vol = 1800000,
1692 .suspend_vol = 1100000,
1695 .name = "ldo4", //vdd11
1698 .suspend_vol = 1000000,
1701 .name = "ldo5", //vcc25
1704 .suspend_vol = 1800000,
1707 .name = "ldo6", //vcc33
1710 .suspend_vol = 3300000,
1713 .name = "ldo7", //vcc28_cif
1716 .suspend_vol = 2800000,
1719 .name = "ldo8", //vcca33
1722 .suspend_vol = 3300000,
1725 .name = "ldo9", //vcc_tp
1728 .suspend_vol = 3300000,
1731 .name = "ldo10", //flash_io
1734 .suspend_vol = 1800000,
1738 #include "../mach-rk30/board-pmu-wm8326.c"
1741 #ifdef CONFIG_MFD_TPS65910
1742 #ifdef CONFIG_ARCH_RK3188
1743 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1745 #define TPS65910_HOST_IRQ RK30_PIN6_PA4
1748 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1750 static struct pmu_info tps65910_dcdc_info[] = {
1752 .name = "vdd_core", //logic
1757 .name = "vdd2", //ddr
1762 .name = "vio", //vcc_io
1768 static struct pmu_info tps65910_ldo_info[] = {
1770 .name = "vpll", //vdd10
1775 .name = "vdig1", //vcc18_cif
1780 .name = "vdig2", //vdd_jetta
1785 .name = "vaux1", //vcc28_cif
1790 .name = "vaux2", //vcca33
1795 .name = "vaux33", //vcc_tp
1800 .name = "vmmc", //vcc30
1805 .name = "vdac", //vcc18
1811 #include "../mach-rk30/board-pmu-tps65910.c"
1814 #if defined(CONFIG_SCALER_TV5735)
1815 struct scaler_output_port tv_oports[] ={
1817 .led_gpio = INVALID_GPIO,
1818 .type = SCALER_OUT_VGA,
1822 struct scaler_input_port tv_iports[] = {
1824 .led_gpio = RK30_PIN0_PD4,
1825 .type = SCALER_IN_RGB,
1828 .led_gpio = RK30_PIN0_PD5,
1829 .type = SCALER_IN_VGA,
1833 struct scaler_platform_data tv5735_data = {
1834 .func_type = SCALER_FUNC_FULL,
1836 .iports = tv_iports,
1837 .iport_size = ARRAY_SIZE(tv_iports),
1839 .oports = tv_oports,
1840 .oport_size = ARRAY_SIZE(tv_oports),
1842 .power_gpio = RK30_PIN2_PD7,
1843 .power_level = GPIO_HIGH,
1844 .vga5v_gpio = RK30_PIN3_PD7,
1845 .vga5v_level = GPIO_HIGH,
1846 .ddc_sel_gpio = RK30_PIN0_PB4,
1847 .ddc_sel_level = GPIO_HIGH, //set default input port
1848 .vga_hsync_gpio= RK30_PIN0_PA1,
1849 .vga_vsync_gpio= RK30_PIN0_PA5,
1853 #if defined(CONFIG_SCALER_TEST)
1854 //the fisrt port is default
1855 struct scaler_output_port tst_oports[] ={
1857 .led_gpio = INVALID_GPIO,
1858 .type = SCALER_OUT_VGA,
1862 //the fisrt port is default
1863 struct scaler_input_port tst_iports[] = {
1866 .led_gpio = RK30_PIN0_PD4,
1867 .type = SCALER_IN_VGA,
1871 .led_gpio = RK30_PIN0_PD5,
1872 .type = SCALER_IN_VGA,
1876 static void test_init_hw(void)
1879 if (!gpio_request(RK30_PIN1_PD6, NULL))
1880 gpio_direction_output(RK30_PIN1_PD6, GPIO_HIGH);
1882 printk("%s: request XNN223_PWN gpio failed\n", __func__);
1885 struct scaler_platform_data test_data = {
1886 .func_type = SCALER_FUNC_SWITCH,
1888 .iports = tst_iports,
1889 .iport_size = ARRAY_SIZE(tst_iports),
1890 .oports = tst_oports,
1891 .oport_size = ARRAY_SIZE(tst_oports),
1893 .power_gpio = RK30_PIN2_PD7,
1894 .power_level = GPIO_HIGH,
1895 .vga5v_gpio = RK30_PIN3_PD7,
1896 .vga5v_level = GPIO_HIGH,
1897 .ddc_sel_gpio = RK30_PIN0_PB4,
1898 .ddc_sel_level = GPIO_HIGH,
1900 .init_hw = test_init_hw,
1904 static struct i2c_board_info __initdata i2c1_info[] = {
1905 #if defined(CONFIG_SCALER_TEST)
1910 .platform_data = &test_data,
1913 #if defined (CONFIG_REGULATOR_ACT8846)
1918 .irq = ACT8846_HOST_IRQ,
1919 .platform_data=&act8846_data,
1922 #if defined (CONFIG_RTC_HYM8563)
1924 .type = "rtc_hym8563",
1927 .irq = RK30_PIN0_PB5,
1930 #if defined (CONFIG_MFD_WM831X_I2C)
1935 .irq = RK30_PIN0_PB3,
1936 .platform_data = &wm831x_platdata,
1939 #if defined (CONFIG_MFD_TPS65910)
1942 .addr = TPS65910_I2C_ID0,
1944 .irq = TPS65910_HOST_IRQ,
1945 .platform_data = &tps65910_data,
1951 void __sramfunc board_pmu_suspend(void)
1953 #if defined (CONFIG_REGULATOR_ACT8846)
1954 if(pmic_is_act8846())
1955 board_pmu_act8846_suspend();
1957 #if defined (CONFIG_MFD_WM831X_I2C)
1958 if(pmic_is_wm8326())
1959 board_pmu_wm8326_suspend();
1961 #if defined (CONFIG_MFD_TPS65910)
1962 if(pmic_is_tps65910())
1963 board_pmu_tps65910_suspend();
1967 void __sramfunc board_pmu_resume(void)
1969 #if defined (CONFIG_REGULATOR_ACT8846)
1970 if(pmic_is_act8846())
1971 board_pmu_act8846_resume();
1973 #if defined (CONFIG_MFD_WM831X_I2C)
1974 if(pmic_is_wm8326())
1975 board_pmu_wm8326_resume();
1977 #if defined (CONFIG_MFD_TPS65910)
1978 if(pmic_is_tps65910())
1979 board_pmu_tps65910_resume();
1983 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1985 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
1986 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1988 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1990 #ifdef CONFIG_RK30_PWM_REGULATOR
1992 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1994 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1995 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1996 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1997 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1999 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
2000 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
2001 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
2002 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
2005 void __sramfunc rk30_pwm_logic_resume_voltage(void)
2007 #ifdef CONFIG_RK30_PWM_REGULATOR
2008 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
2009 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
2010 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
2011 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
2017 extern void pwm_suspend_voltage(void);
2018 extern void pwm_resume_voltage(void);
2019 void rk30_pwm_suspend_voltage_set(void)
2021 #ifdef CONFIG_RK30_PWM_REGULATOR
2022 pwm_suspend_voltage();
2025 void rk30_pwm_resume_voltage_set(void)
2027 #ifdef CONFIG_RK30_PWM_REGULATOR
2028 pwm_resume_voltage();
2033 #ifdef CONFIG_I2C2_RK30
2034 static struct i2c_board_info __initdata i2c2_info[] = {
2035 #if defined(CONFIG_SCALER_TV5735)
2040 .platform_data = &tv5735_data,
2043 #if defined(CONFIG_SCALER_DEVICE_DDC)
2045 .type = "scaler_ddc",
2050 #if defined (CONFIG_CT36X_TS)
2055 .platform_data = &ct36x_info,
2058 #if defined (CONFIG_LS_CM3217)
2060 .type = "lightsensor",
2063 .platform_data = &cm3217_info,
2066 #if defined (CONFIG_LS_US5151)
2074 #if defined(CONFIG_HDMI_CAT66121)
2076 .type = "cat66121_hdmi",
2079 .irq = RK30_PIN2_PD6,
2080 .platform_data = &rk_hdmi_pdata,
2086 #ifdef CONFIG_I2C3_RK30
2087 static struct i2c_board_info __initdata i2c3_info[] = {
2091 #ifdef CONFIG_I2C4_RK30
2092 static struct i2c_board_info __initdata i2c4_info[] = {
2093 #ifdef CONFIG_MFD_RK610
2095 .type = "rk610_ctl",
2098 .platform_data = &rk610_ctl_pdata,
2100 #ifdef CONFIG_RK610_TVOUT
2102 .type = "rk610_tvout",
2107 #ifdef CONFIG_HDMI_RK610
2109 .type = "rk610_hdmi",
2112 .irq = INVALID_GPIO,
2115 #ifdef CONFIG_SND_SOC_RK610
2116 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
2117 .type = "rk610_i2c_codec",
2120 .platform_data = &rk610_codec_pdata,
2125 #if defined (CONFIG_SND_SOC_RT5631)
2136 #ifdef CONFIG_I2C_GPIO_RK30
2137 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
2138 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
2139 static int rk30_i2c_io_init(void)
2141 //set iomux (gpio) here
2142 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
2143 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
2147 struct i2c_gpio_platform_data default_i2c_gpio_data = {
2148 .sda_pin = I2C_SDA_PIN,
2149 .scl_pin = I2C_SCL_PIN,
2150 .udelay = 5, // clk = 500/udelay = 100Khz
2151 .timeout = 100,//msecs_to_jiffies(100),
2153 .io_init = rk30_i2c_io_init,
2155 static struct i2c_board_info __initdata i2c_gpio_info[] = {
2159 static void __init rk30_i2c_register_board_info(void)
2161 #ifdef CONFIG_I2C0_RK30
2162 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
2164 #ifdef CONFIG_I2C1_RK30
2165 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
2167 #ifdef CONFIG_I2C2_RK30
2168 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
2170 #ifdef CONFIG_I2C3_RK30
2171 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
2173 #ifdef CONFIG_I2C4_RK30
2174 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
2176 #ifdef CONFIG_I2C_GPIO_RK30
2177 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2182 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
2183 static void rk30_pm_power_off(void)
2185 printk(KERN_ERR "rk30_pm_power_off start...\n");
2186 #if defined(CONFIG_MFD_WM831X)
2187 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2188 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2190 #if defined(CONFIG_REGULATOR_ACT8846)
2191 if (pmic_is_act8846()) {
2192 printk("enter dcdet===========\n");
2193 if(gpio_get_value (RK30_PIN0_PB2) == GPIO_LOW)
2195 printk("enter restart===========\n");
2196 arm_pm_restart(0, "charge");
2198 /** code here may cause tablet cannot boot when shutdown without charger pluged in
2199 * and then plug in charger. -- Cody Xie
2202 act8846_device_shutdown();
2207 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2211 static void __init machine_rk30_board_init(void)
2214 gpio_request(POWER_ON_PIN, "poweronpin");
2215 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2217 pm_power_off = rk30_pm_power_off;
2219 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2222 rk30_i2c_register_board_info();
2223 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2224 platform_add_devices(devices, ARRAY_SIZE(devices));
2225 rk_platform_add_display_devices();
2226 //board_usb_detect_init(RK30_PIN0_PA7);
2228 #ifdef CONFIG_WIFI_CONTROL_FUNC
2229 rk29sdk_wifi_bt_gpio_control_init();
2232 #if defined(CONFIG_MT6620)
2233 clk_set_rate(clk_get_sys("rk_serial.1", "uart"), 48*1000000);
2236 #if defined(CONFIG_MT5931_MT6622)
2237 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2241 #define HD_SCREEN_SIZE 1920UL*1200UL*4*3
2242 static void __init rk30_reserve(void)
2244 #if defined(CONFIG_ARCH_RK3188)
2245 /*if lcd resolution great than or equal to 1920*1200,reserve the ump memory */
2246 if(!(get_fb_size() < ALIGN(HD_SCREEN_SIZE,SZ_1M)))
2248 int ump_mem_phy_size=512UL*1024UL*1024UL;
2249 resource_mali[0].start = board_mem_reserve_add("ump buf", ump_mem_phy_size);
2250 resource_mali[0].end = resource_mali[0].start + ump_mem_phy_size -1;
2254 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2257 #ifdef CONFIG_FB_ROCKCHIP
2258 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2259 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2261 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2262 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2265 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2266 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2267 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2272 #ifdef CONFIG_VIDEO_RK29
2273 rk30_camera_request_reserve_mem();
2276 #ifdef CONFIG_GPS_RK
2277 //it must be more than 8MB
2278 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2280 board_mem_reserved();
2282 /******************************** arm dvfs frequency volt table **********************************/
2284 * dvfs_cpu_logic_table: table for arm and logic dvfs
2285 * @frequency : arm frequency
2286 * @cpu_volt : arm voltage depend on frequency
2290 static struct cpufreq_frequency_table dvfs_arm_table_volt_level0[] = {
2291 {.frequency = 312 * 1000, .index = 850 * 1000},
2292 {.frequency = 504 * 1000, .index = 900 * 1000},
2293 {.frequency = 816 * 1000, .index = 950 * 1000},
2294 {.frequency = 1008 * 1000, .index = 1025 * 1000},
2295 {.frequency = 1200 * 1000, .index = 1100 * 1000},
2296 {.frequency = 1416 * 1000, .index = 1200 * 1000},
2297 {.frequency = 1608 * 1000, .index = 1300 * 1000},
2298 {.frequency = CPUFREQ_TABLE_END},
2301 static struct cpufreq_frequency_table dvfs_arm_table_volt_level1[] = {
2302 {.frequency = 312 * 1000, .index = 875 * 1000},
2303 {.frequency = 504 * 1000, .index = 925 * 1000},
2304 {.frequency = 816 * 1000, .index = 975 * 1000},
2305 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2306 {.frequency = 1200 * 1000, .index = 1150 * 1000},
2307 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2308 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2309 {.frequency = CPUFREQ_TABLE_END},
2312 static struct cpufreq_frequency_table dvfs_arm_table_volt_level2[] = {
2313 {.frequency = 312 * 1000, .index = 900 * 1000},
2314 {.frequency = 504 * 1000, .index = 925 * 1000},
2315 {.frequency = 816 * 1000, .index = 1000 * 1000},
2316 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2317 {.frequency = 1200 * 1000, .index = 1200 * 1000},
2318 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2319 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2320 {.frequency = CPUFREQ_TABLE_END},
2322 //if you board is good for volt quality,select dvfs_arm_table_volt_level0
2323 #define dvfs_arm_table dvfs_arm_table_volt_level2
2325 /******************************** gpu dvfs frequency volt table **********************************/
2327 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level0[] = {
2328 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2329 {.frequency = 200 * 1000, .index = 975 * 1000},
2330 {.frequency = 266 * 1000, .index = 1000 * 1000},
2331 {.frequency = 300 * 1000, .index = 1050 * 1000},
2332 {.frequency = 400 * 1000, .index = 1100 * 1000},
2333 {.frequency = 600 * 1000, .index = 1200 * 1000},
2334 {.frequency = CPUFREQ_TABLE_END},
2337 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level1[] = {
2338 {.frequency = 133 * 1000, .index = 975 * 1000},
2339 {.frequency = 200 * 1000, .index = 1000 * 1000},
2340 {.frequency = 266 * 1000, .index = 1025 * 1000},
2341 {.frequency = 300 * 1000, .index = 1050 * 1000},
2342 {.frequency = 400 * 1000, .index = 1100 * 1000},
2343 {.frequency = 600 * 1000, .index = 1250 * 1000},
2344 {.frequency = CPUFREQ_TABLE_END},
2347 #define dvfs_gpu_table dvfs_gpu_table_volt_level1
2349 /******************************** ddr dvfs frequency volt table **********************************/
2350 static struct cpufreq_frequency_table dvfs_ddr_table_volt_level0[] = {
2351 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2352 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
2353 //{.frequency = 396 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2354 {.frequency = 666 * 1000 + DDR_FREQ_NORMAL, .index = 1250 * 1000},
2355 {.frequency = 666 * 1000 + DDR_FREQ_DUALVIEW, .index = 1250 * 1000},
2356 //{.frequency = 528 * 1000 + DDR_FREQ_NORMAL, .index = 1200 * 1000},
2357 {.frequency = CPUFREQ_TABLE_END},
2360 static struct cpufreq_frequency_table dvfs_ddr_table_t[] = {
2361 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2362 //{.frequency = 460 * 1000 + DDR_FREQ_NORMAL, .index = 1150 * 1000},
2363 {.frequency = 666 * 1000 + DDR_FREQ_NORMAL, .index = 1250 * 1000},
2364 {.frequency = CPUFREQ_TABLE_END},
2366 #define dvfs_ddr_table dvfs_ddr_table_volt_level0
2368 /******************************** arm dvfs frequency volt table end **********************************/
2372 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2373 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2374 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2375 int get_max_freq(struct cpufreq_frequency_table *table)
2379 for(i=0;table[i].frequency!= CPUFREQ_TABLE_END;i++)
2381 if(temp<table[i].frequency)
2382 temp=table[i].frequency;
2384 printk("get_max_freq=%d\n",temp);
2388 void __init board_clock_init(void)
2390 u32 flags=RK30_CLOCKS_DEFAULT_FLAGS;
2391 #if !defined(CONFIG_ARCH_RK3188)
2392 if(get_max_freq(dvfs_gpu_table)<=(400*1000))
2394 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_GPLL;
2397 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_CPLL;
2399 rk30_clock_data_init(periph_pll_default, codec_pll_default, flags);
2400 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2401 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2402 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2403 #if defined(CONFIG_ARCH_RK3188)
2404 if (rk_pll_flag() == 0)
2405 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2407 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table_t);
2409 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2413 MACHINE_START(RK30, "RK30board")
2414 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2415 .fixup = rk30_fixup,
2416 .reserve = &rk30_reserve,
2417 .map_io = rk30_map_io,
2418 .init_irq = rk30_init_irq,
2419 .timer = &rk30_timer,
2420 .init_machine = machine_rk30_board_init,