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>
76 #include "../mach-rk30/board-rk3168-ds1006h-camera.c"
79 static struct rk29_keys_button key_button[] = {
83 .gpio = RK30_PIN0_PA4,
84 .active_low = PRESS_LEV_LOW,
92 .active_low = PRESS_LEV_LOW,
95 struct rk29_keys_platform_data rk29_keys_pdata = {
96 .buttons = key_button,
97 .nbuttons = ARRAY_SIZE(key_button),
98 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
103 v1.1 : rk610 lvds + rk610 codec + MT5931_MT6622 + light photoresistor + adc/cw2015
104 v1.2 : lvds + rt5631 + M500 + us5151 + adc
106 #define DS1006H_V1_2_SUPPORT 1
107 int get_harware_version()
109 #if DS1006H_V1_2_SUPPORT
115 EXPORT_SYMBOL_GPL(get_harware_version);
117 #if defined(CONFIG_CT36X_TS)
119 #define TOUCH_MODEL 363
120 #define TOUCH_MAX_X 1280
121 #define TOUCH_MAX_y 800
122 #define TOUCH_RESET_PIN RK30_PIN0_PB6
123 #define TOUCH_INT_PIN RK30_PIN1_PB7
125 static struct ct36x_platform_data ct36x_info = {
126 .model = TOUCH_MODEL,
127 .x_max = TOUCH_MAX_X,
128 .y_max = TOUCH_MAX_y,
131 .gpio = TOUCH_RESET_PIN,
135 .gpio = TOUCH_INT_PIN,
138 .orientation = {1, 0, 0, 1},
141 static struct spi_board_info board_spi_devices[] = {
144 /***********************************************************
146 ************************************************************/
147 #ifdef CONFIG_BACKLIGHT_RK29_BL
149 #define PWM_MODE PWM3
150 #define PWM_EFFECT_VALUE 1
152 #define LCD_DISP_ON_PIN
154 #ifdef LCD_DISP_ON_PIN
155 #define BL_EN_PIN RK30_PIN0_PA2
156 #define BL_EN_VALUE GPIO_HIGH
158 static int rk29_backlight_io_init(void)
163 #ifdef LCD_DISP_ON_PIN
164 ret = gpio_request(BL_EN_PIN, NULL);
166 gpio_free(BL_EN_PIN);
169 gpio_direction_output(BL_EN_PIN, 0);
170 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
176 static int rk29_backlight_io_deinit(void)
178 int ret = 0, pwm_gpio;
180 #ifdef LCD_DISP_ON_PIN
181 gpio_free(BL_EN_PIN);
184 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
185 gpio_request(pwm_gpio, NULL);
186 gpio_direction_output(pwm_gpio, GPIO_LOW);
190 static int rk29_backlight_pwm_suspend(void)
192 int ret = 0, pwm_gpio;
194 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
195 if (gpio_request(pwm_gpio, NULL)) {
196 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
199 gpio_direction_output(pwm_gpio, GPIO_LOW);
200 #ifdef LCD_DISP_ON_PIN
201 gpio_direction_output(BL_EN_PIN, 0);
202 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
207 static int rk29_backlight_pwm_resume(void)
209 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
213 #ifdef LCD_DISP_ON_PIN
215 gpio_direction_output(BL_EN_PIN, 1);
216 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
221 static struct rk29_bl_info rk29_bl_info = {
222 .min_brightness = 65,
223 .max_brightness = 150,
224 .brightness_mode =BRIGHTNESS_MODE_CONIC,
225 .pre_div = 30 * 1000, // pwm output clk: 30k;
227 .bl_ref = PWM_EFFECT_VALUE,
228 .io_init = rk29_backlight_io_init,
229 .io_deinit = rk29_backlight_io_deinit,
230 .pwm_suspend = rk29_backlight_pwm_suspend,
231 .pwm_resume = rk29_backlight_pwm_resume,
234 static struct platform_device rk29_device_backlight = {
235 .name = "rk29_backlight",
238 .platform_data = &rk29_bl_info,
245 #if defined (CONFIG_GS_MMA8452)
246 #define MMA8452_INT_PIN RK30_PIN0_PB7
248 static int mma8452_init_platform_hw(void)
253 static struct sensor_platform_data mma8452_info = {
254 .type = SENSOR_TYPE_ACCEL,
257 .init_platform_hw = mma8452_init_platform_hw,
258 .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
261 #if defined (CONFIG_GS_LIS3DH)
262 #define LIS3DH_INT_PIN RK30_PIN0_PB7
264 static int lis3dh_init_platform_hw(void)
270 static struct sensor_platform_data lis3dh_info = {
271 .type = SENSOR_TYPE_ACCEL,
274 .init_platform_hw = lis3dh_init_platform_hw,
275 .orientation = {-1, 0, 0, 0, 1, 0, 0, 0, -1},
279 #if defined (CONFIG_COMPASS_AK8963)
280 static struct sensor_platform_data akm8963_info =
282 .type = SENSOR_TYPE_COMPASS,
315 #if defined(CONFIG_LS_PHOTORESISTOR)
316 static struct sensor_platform_data light_photoresistor_info = {
317 .type = SENSOR_TYPE_LIGHT,
320 .poll_delay_ms = 200,
324 #if defined (CONFIG_COMPASS_AK8975)
325 static struct sensor_platform_data akm8975_info =
327 .type = SENSOR_TYPE_COMPASS,
360 #if defined(CONFIG_MT6229)
361 static int mt6229_io_init(void)
364 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
365 k30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
366 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
367 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
368 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
369 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
374 static int mt6229_io_deinit(void)
380 struct rk29_mt6229_data rk29_mt6229_info = {
381 .io_init = mt6229_io_init,
382 .io_deinit = mt6229_io_deinit,
383 .modem_power_en = RK30_PIN0_PC6,
384 .bp_power = RK30_PIN2_PD5,
385 .modem_usb_en = RK30_PIN0_PC7,
386 .modem_uart_en = RK30_PIN2_PD4,
387 .bp_wakeup_ap = RK30_PIN0_PC5,
388 .ap_ready = RK30_PIN0_PC4,
391 struct platform_device rk29_device_mt6229 = {
395 .platform_data = &rk29_mt6229_info,
400 #if defined(CONFIG_GYRO_L3G4200D)
402 #include <linux/l3g4200d.h>
403 #define L3G4200D_INT_PIN RK30_PIN0_PB4
405 static int l3g4200d_init_platform_hw(void)
410 static struct sensor_platform_data l3g4200d_info = {
411 .type = SENSOR_TYPE_GYROSCOPE,
414 .orientation = {1, 0, 0 , 0 , -1, 0, 0, 0, -1},
415 .init_platform_hw = l3g4200d_init_platform_hw,
416 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
423 #ifdef CONFIG_LS_CM3217
424 static struct sensor_platform_data cm3217_info = {
425 .type = SENSOR_TYPE_LIGHT,
427 .poll_delay_ms = 500,
432 #ifdef CONFIG_FB_ROCKCHIP
434 #if DS1006H_V1_2_SUPPORT
435 #define LCD_CS_PIN RK30_PIN0_PB0
437 #define LCD_CS_PIN INVALID_GPIO
439 #define LCD_CS_VALUE GPIO_HIGH
441 #if DS1006H_V1_2_SUPPORT
442 #define LCD_EN_PIN RK30_PIN0_PB1
444 #define LCD_EN_PIN RK30_PIN0_PB0
446 #define LCD_EN_VALUE GPIO_LOW
448 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
452 if(LCD_CS_PIN !=INVALID_GPIO)
454 ret = gpio_request(LCD_CS_PIN, NULL);
457 gpio_free(LCD_CS_PIN);
458 printk(KERN_ERR "request lcd cs pin fail!\n");
463 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
467 if(LCD_EN_PIN !=INVALID_GPIO)
469 ret = gpio_request(LCD_EN_PIN, NULL);
472 gpio_free(LCD_EN_PIN);
473 printk(KERN_ERR "request lcd en pin fail!\n");
478 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
483 static int rk_fb_io_disable(void)
485 if(LCD_CS_PIN !=INVALID_GPIO)
487 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
489 if(LCD_EN_PIN !=INVALID_GPIO)
491 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
495 static int rk_fb_io_enable(void)
497 if(LCD_CS_PIN !=INVALID_GPIO)
499 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
501 if(LCD_EN_PIN !=INVALID_GPIO)
503 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
508 #if defined(CONFIG_LCDC0_RK3188)
509 struct rk29fb_info lcdc0_screen_info = {
510 .prop = EXTEND, //extend display device
512 .set_screen_info = hdmi_init_lcdc,
517 #if defined(CONFIG_LCDC1_RK3188)
518 struct rk29fb_info lcdc1_screen_info = {
519 .prop = PRMRY, //primary display device
520 .io_init = rk_fb_io_init,
521 .io_disable = rk_fb_io_disable,
522 .io_enable = rk_fb_io_enable,
523 .set_screen_info = set_lcd_info,
528 static struct resource resource_fb[] = {
532 .end = 0,//RK30_FB0_MEM_SIZE - 1,
533 .flags = IORESOURCE_MEM,
536 .name = "ipp buf", //for rotate
538 .end = 0,//RK30_FB0_MEM_SIZE - 1,
539 .flags = IORESOURCE_MEM,
544 .end = 0,//RK30_FB0_MEM_SIZE - 1,
545 .flags = IORESOURCE_MEM,
549 static struct platform_device device_fb = {
552 .num_resources = ARRAY_SIZE(resource_fb),
553 .resource = resource_fb,
557 #if defined(CONFIG_ARCH_RK3188)
558 static struct resource resource_mali[] = {
563 .flags = IORESOURCE_MEM,
568 static struct platform_device device_mali= {
569 .name = "mali400_ump",
571 .num_resources = ARRAY_SIZE(resource_mali),
572 .resource = resource_mali,
576 #if defined(CONFIG_LCDC0_RK3188)
577 static struct resource resource_lcdc0[] = {
580 .start = RK30_LCDC0_PHYS,
581 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
582 .flags = IORESOURCE_MEM,
589 .flags = IORESOURCE_IRQ,
593 static struct platform_device device_lcdc0 = {
596 .num_resources = ARRAY_SIZE(resource_lcdc0),
597 .resource = resource_lcdc0,
599 .platform_data = &lcdc0_screen_info,
603 #if defined(CONFIG_LCDC1_RK3188)
604 static struct resource resource_lcdc1[] = {
607 .start = RK30_LCDC1_PHYS,
608 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
609 .flags = IORESOURCE_MEM,
615 .flags = IORESOURCE_IRQ,
619 static struct platform_device device_lcdc1 = {
622 .num_resources = ARRAY_SIZE(resource_lcdc1),
623 .resource = resource_lcdc1,
625 .platform_data = &lcdc1_screen_info,
630 #if defined(CONFIG_MFD_RK610)
631 #define RK610_RST_PIN RK30_PIN3_PB2
632 static int rk610_power_on_init(void)
635 if(RK610_RST_PIN != INVALID_GPIO)
637 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
640 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
644 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
646 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
648 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
657 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
658 .rk610_power_on_init = rk610_power_on_init,
662 #ifdef CONFIG_SND_SOC_RK610
663 static int rk610_codec_io_init(void)
666 //Must not gpio_request
670 static struct rk610_codec_platform_data rk610_codec_pdata = {
671 .spk_ctl_io = RK30_PIN2_PD7,
672 .io_init = rk610_codec_io_init,
677 #ifdef CONFIG_RK_HDMI
678 #define RK_HDMI_RST_PIN RK30_PIN3_PB2
679 static int rk_hdmi_power_init(void)
683 if(RK_HDMI_RST_PIN != INVALID_GPIO)
685 if (gpio_request(RK_HDMI_RST_PIN, NULL)) {
686 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
689 gpio_direction_output(RK_HDMI_RST_PIN, GPIO_LOW);
690 gpio_set_value(RK_HDMI_RST_PIN, GPIO_LOW);
692 gpio_set_value(RK_HDMI_RST_PIN, GPIO_HIGH);
697 static struct rk_hdmi_platform_data rk_hdmi_pdata = {
698 //.io_init = rk_hdmi_power_init,
702 #define ION_RESERVE_SIZE (80 * SZ_1M)
703 static struct ion_platform_data rk30_ion_pdata = {
707 .type = ION_HEAP_TYPE_CARVEOUT,
708 .id = ION_NOR_HEAP_ID,
710 .size = ION_RESERVE_SIZE,
715 static struct platform_device device_ion = {
716 .name = "ion-rockchip",
719 .platform_data = &rk30_ion_pdata,
724 /**************************************************************************************************
725 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
726 **************************************************************************************************/
727 #ifdef CONFIG_SDMMC_RK29
728 #include "board-rk3188-ac-sdmmc-config.c"
729 #include "../plat-rk/rk-sdmmc-ops.c"
730 #include "../plat-rk/rk-sdmmc-wifi.c"
731 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
733 #ifdef CONFIG_SDMMC0_RK29
734 static int rk29_sdmmc0_cfg_gpio(void)
736 #ifdef CONFIG_SDMMC_RK29_OLD
738 iomux_set(MMC0_CLKOUT);
744 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
746 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
747 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
750 rk29_sdmmc_set_iomux(0, 0xFFFF);
752 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
753 #if SDMMC_USE_NEW_IOMUX_API
754 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
756 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
759 #if SDMMC_USE_NEW_IOMUX_API
760 iomux_set(MMC0_DETN);
762 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
766 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
767 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
768 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
776 #define CONFIG_SDMMC0_USE_DMA
777 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
779 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
780 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
781 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
783 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
784 .io_init = rk29_sdmmc0_cfg_gpio,
786 #if !defined(CONFIG_SDMMC_RK29_OLD)
787 .set_iomux = rk29_sdmmc_set_iomux,
790 .dma_name = "sd_mmc",
791 #ifdef CONFIG_SDMMC0_USE_DMA
797 #if defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
798 .status = rk29sdk_wifi_mmc0_status,
799 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
802 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
803 .power_en = RK29SDK_SD_CARD_PWR_EN,
804 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
806 .power_en = INVALID_GPIO,
807 .power_en_level = GPIO_LOW,
809 .enable_sd_wakeup = 0,
811 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
812 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
813 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
815 .write_prt = INVALID_GPIO,
819 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
820 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
821 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
822 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
824 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
825 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
826 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
828 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
829 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
840 #endif // CONFIG_SDMMC0_RK29
842 #ifdef CONFIG_SDMMC1_RK29
843 #define CONFIG_SDMMC1_USE_DMA
844 static int rk29_sdmmc1_cfg_gpio(void)
846 #if defined(CONFIG_SDMMC_RK29_OLD)
848 iomux_set(MMC1_CLKOUT);
855 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
856 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
857 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
865 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
867 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
868 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
871 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
872 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
873 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
876 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
879 .io_init = rk29_sdmmc1_cfg_gpio,
881 #if !defined(CONFIG_SDMMC_RK29_OLD)
882 .set_iomux = rk29_sdmmc_set_iomux,
886 #ifdef CONFIG_SDMMC1_USE_DMA
892 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
893 .status = rk29sdk_wifi_status,
894 .register_status_notify = rk29sdk_wifi_status_register,
897 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
898 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
899 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
901 .write_prt = INVALID_GPIO,
904 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
905 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
909 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
910 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
911 .io = RK29SDK_SD_CARD_DETECT_N,
916 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
917 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
919 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
920 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
921 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
923 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
924 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
934 .enable_sd_wakeup = 0,
936 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
938 /**************************************************************************************************
939 * the end of setting for SDMMC devices
940 **************************************************************************************************/
942 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
943 static int ac_current = -1;
944 #define CHARING_CURRENT_500MA 0
945 #define CHARING_CURRENT_1000MA 1
947 #define DC_CUR_SET_PIN RK30_PIN0_PB0
948 #define CHARGE_OK_PIN RK30_PIN0_PA6
949 #define DC_DET_PIN RK30_PIN0_PB2
950 static int rk30_battery_adc_io_init(void)
953 printk("charging: set charging current 500ma \n");
954 ac_current = CHARING_CURRENT_500MA;
955 //dc charge detect pin
956 ret = gpio_request(DC_DET_PIN, NULL);
958 printk("failed to request dc_det gpio\n");
962 gpio_pull_updown(DC_DET_PIN, 1);//important
963 ret = gpio_direction_input(DC_DET_PIN);
965 printk("failed to set gpio dc_det input\n");
970 ret = gpio_request(CHARGE_OK_PIN, NULL);
972 printk("failed to request charge_ok gpio\n");
976 gpio_pull_updown(CHARGE_OK_PIN, 1);//important
977 ret = gpio_direction_input(CHARGE_OK_PIN);
979 printk("failed to set gpio charge_ok input\n");
982 //charge current set pin
983 ret = gpio_request(DC_CUR_SET_PIN, NULL);
985 printk("failed to request DC_CUR_SET_PIN gpio\n");
989 ret = gpio_direction_output(DC_CUR_SET_PIN, GPIO_LOW);//500ma
991 printk("failed to set gpio DC_CUR_SET_PIN output\n");
999 static int set_usb_charging_current(int mode)
1002 if ( (ac_current==CHARING_CURRENT_1000MA) && (mode == PC_MODE) ) {
1003 gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW);
1004 ac_current = CHARING_CURRENT_500MA;
1006 else if ((mode == ADAPT_MODE) && (ac_current==CHARING_CURRENT_500MA))
1008 gpio_set_value(DC_CUR_SET_PIN, GPIO_HIGH);
1009 ac_current = CHARING_CURRENT_1000MA;
1013 gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW);
1014 ac_current = CHARING_CURRENT_500MA;
1018 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1019 .dc_det_pin = RK30_PIN0_PB2,
1020 .batt_low_pin = INVALID_GPIO,
1021 .charge_set_pin = INVALID_GPIO,
1022 .charge_ok_pin = RK30_PIN0_PA6,
1023 .usb_det_pin = INVALID_GPIO,
1024 .dc_det_level = GPIO_LOW,
1025 .charge_ok_level = GPIO_HIGH,
1027 .reference_voltage = 1800, // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
1028 .pull_up_res = 200, //divider resistance , pull-up resistor
1029 .pull_down_res = 120, //divider resistance , pull-down resistor
1031 .is_reboot_charging = 1,
1032 .save_capacity = 1 ,
1033 .low_voltage_protection = 3600,
1034 .io_init = rk30_battery_adc_io_init,
1035 .control_usb_charging= set_usb_charging_current,
1038 static struct platform_device rk30_device_adc_battery = {
1039 .name = "rk30-battery",
1042 .platform_data = &rk30_adc_battery_platdata,
1046 #ifdef CONFIG_RK30_PWM_REGULATOR
1047 static int pwm_voltage_map[] = {
1048 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
1051 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1053 .supply = "vdd_cpu",
1057 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1061 .name = "PWM_DCDC1",
1063 .max_uV = 1800000, //0.6-1.8V
1065 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1067 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1068 .consumer_supplies = pwm_dcdc1_consumers,
1072 static struct pwm_platform_data pwm_regulator_info[1] = {
1075 .pwm_gpio = RK30_PIN3_PD4,
1076 .pwm_iomux_pwm = PWM1,
1077 .pwm_iomux_gpio = GPIO3_D4,
1078 .pwm_voltage = 1100000,
1079 .suspend_voltage = 1000000,
1082 .coefficient = 575, //57.5%
1083 .pwm_voltage_map = pwm_voltage_map,
1084 .init_data = &pwm_regulator_init_dcdc[0],
1088 struct platform_device pwm_regulator_device[1] = {
1090 .name = "pwm-voltage-regulator",
1093 .platform_data = &pwm_regulator_info[0],
1099 #ifdef CONFIG_RK29_VMAC
1100 #define PHY_PWR_EN_GPIO RK30_PIN0_PC0
1101 #define PHY_PWR_EN_VALUE GPIO_HIGH
1102 #include "../mach-rk30/board-rk31-sdk-vmac.c"
1105 #ifdef CONFIG_RFKILL_RK
1106 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1107 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1108 .type = RFKILL_TYPE_BLUETOOTH,
1110 .poweron_gpio = { // BT_REG_ON
1111 .io = INVALID_GPIO, //RK30_PIN3_PC7,
1112 .enable = GPIO_HIGH,
1114 .name = "bt_poweron",
1119 .reset_gpio = { // BT_RST
1120 .io = RK30_PIN3_PA0, // set io to INVALID_GPIO for disable it
1128 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1129 .io = RK30_PIN3_PB0, // set io to INVALID_GPIO for disable it
1130 .enable = GPIO_HIGH,
1137 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1139 .io = RK30_PIN3_PB1, // set io to INVALID_GPIO for disable it
1140 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1147 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1148 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1158 static struct platform_device device_rfkill_rk = {
1159 .name = "rfkill_rk",
1162 .platform_data = &rfkill_rk_platdata,
1167 #if defined(CONFIG_GPS_RK)
1168 int rk_gps_io_init(void)
1170 printk("%s \n", __FUNCTION__);
1172 rk30_mux_api_set(GPIO1B5_UART3RTSN_NAME, GPIO1B_GPIO1B5);//VCC_EN
1173 gpio_request(RK30_PIN1_PB5, NULL);
1174 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1176 rk30_mux_api_set(GPIO1B4_UART3CTSN_GPSRFCLK_NAME, GPIO1B_GPSRFCLK);//GPS_CLK
1177 rk30_mux_api_set(GPIO1B2_UART3SIN_GPSMAG_NAME, GPIO1B_GPSMAG);//GPS_MAG
1178 rk30_mux_api_set(GPIO1B3_UART3SOUT_GPSSIG_NAME, GPIO1B_GPSSIG);//GPS_SIGN
1180 rk30_mux_api_set(GPIO1A6_UART1CTSN_SPI0CLK_NAME, GPIO1A_GPIO1A6);//SPI_CLK
1181 gpio_request(RK30_PIN1_PA6, NULL);
1182 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1184 rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0TXD_NAME, GPIO1A_GPIO1A5);//SPI_MOSI
1185 gpio_request(RK30_PIN1_PA5, NULL);
1186 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1188 rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0CSN0_NAME, GPIO1A_GPIO1A7);//SPI_CS
1189 gpio_request(RK30_PIN1_PA7, NULL);
1190 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1193 int rk_gps_power_up(void)
1195 printk("%s \n", __FUNCTION__);
1200 int rk_gps_power_down(void)
1202 printk("%s \n", __FUNCTION__);
1207 int rk_gps_reset_set(int level)
1211 int rk_enable_hclk_gps(void)
1213 printk("%s \n", __FUNCTION__);
1214 clk_enable(clk_get(NULL, "hclk_gps"));
1217 int rk_disable_hclk_gps(void)
1219 printk("%s \n", __FUNCTION__);
1220 clk_disable(clk_get(NULL, "hclk_gps"));
1223 struct rk_gps_data rk_gps_info = {
1224 .io_init = rk_gps_io_init,
1225 .power_up = rk_gps_power_up,
1226 .power_down = rk_gps_power_down,
1227 .reset = rk_gps_reset_set,
1228 .enable_hclk_gps = rk_enable_hclk_gps,
1229 .disable_hclk_gps = rk_disable_hclk_gps,
1230 .GpsSign = RK30_PIN1_PB3,
1231 .GpsMag = RK30_PIN1_PB2, //GPIO index
1232 .GpsClk = RK30_PIN1_PB4, //GPIO index
1233 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1234 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1235 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1236 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1240 .u32GpsPhyAddr = RK30_GPS_PHYS,
1241 .u32GpsPhySize = RK30_GPS_SIZE,
1244 struct platform_device rk_device_gps = {
1245 .name = "gps_hv5820b",
1248 .platform_data = &rk_gps_info,
1253 #if defined(CONFIG_MT5931_MT6622)
1254 static struct mt6622_platform_data mt6622_platdata = {
1255 .power_gpio = { // BT_REG_ON
1256 #if DS1006H_V1_2_SUPPORT
1257 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1259 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1261 .enable = GPIO_HIGH,
1267 .reset_gpio = { // BT_RST
1268 #if DS1006H_V1_2_SUPPORT
1269 .io = RK30_PIN3_PD1,
1271 .io = RK30_PIN0_PD7,
1273 .enable = GPIO_HIGH,
1280 #if DS1006H_V1_2_SUPPORT
1281 .io = RK30_PIN0_PA5,
1283 .io = RK30_PIN3_PD2,
1285 .enable = GPIO_HIGH,
1292 static struct platform_device device_mt6622 = {
1296 .platform_data = &mt6622_platdata,
1301 #if defined CONFIG_TCC_BT_DEV
1302 static struct tcc_bt_platform_data tcc_bt_platdata = {
1304 .power_gpio = { // ldoon
1305 .io = RK2928_PIN3_PC0,
1306 .enable = GPIO_HIGH,
1312 .wake_host_gpio = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1313 .io = RK2928_PIN0_PC5, // set io to INVALID_GPIO for disable it
1314 .enable = IRQF_TRIGGER_RISING,// set IRQF_TRIGGER_FALLING for falling, set IRQF_TRIGGER_RISING for rising
1321 static struct platform_device device_tcc_bt = {
1322 .name = "tcc_bt_dev",
1325 .platform_data = &tcc_bt_platdata,
1331 static struct platform_device *devices[] __initdata = {
1336 #ifdef CONFIG_WIFI_CONTROL_FUNC
1337 &rk29sdk_wifi_device,
1340 #if defined(CONFIG_MT6620)
1344 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1345 &rk30_device_adc_battery,
1347 #ifdef CONFIG_RFKILL_RK
1350 #ifdef CONFIG_GPS_RK
1353 #ifdef CONFIG_MT5931_MT6622
1356 #if defined(CONFIG_MT6229)
1357 &rk29_device_mt6229,
1359 #if defined(CONFIG_ARCH_RK3188)
1363 #ifdef CONFIG_TCC_BT_DEV
1369 static int rk_platform_add_display_devices(void)
1371 struct platform_device *fb = NULL; //fb
1372 struct platform_device *lcdc0 = NULL; //lcdc0
1373 struct platform_device *lcdc1 = NULL; //lcdc1
1374 struct platform_device *bl = NULL; //backlight
1375 #ifdef CONFIG_FB_ROCKCHIP
1379 #if defined(CONFIG_LCDC0_RK3188)
1380 lcdc0 = &device_lcdc0,
1383 #if defined(CONFIG_LCDC1_RK3188)
1384 lcdc1 = &device_lcdc1,
1387 #ifdef CONFIG_BACKLIGHT_RK29_BL
1388 bl = &rk29_device_backlight,
1390 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1397 #ifdef CONFIG_I2C0_RK30
1398 static struct i2c_board_info __initdata i2c0_info[] = {
1399 #if defined (CONFIG_GS_MMA8452)
1401 .type = "gs_mma8452",
1404 .irq = MMA8452_INT_PIN,
1405 .platform_data = &mma8452_info,
1409 #if defined (CONFIG_GS_LIS3DH)
1411 .type = "gs_lis3dh",
1412 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1414 .irq = LIS3DH_INT_PIN,
1415 .platform_data = &lis3dh_info,
1418 #if defined (CONFIG_COMPASS_AK8963)
1423 .irq = RK30_PIN3_PD7,
1424 .platform_data = &akm8963_info,
1428 #if defined (CONFIG_LS_PHOTORESISTOR)
1430 .type = "ls_photoresistor",
1433 .irq = INVALID_GPIO,
1434 .platform_data = &light_photoresistor_info,
1438 #if defined (CONFIG_COMPASS_AK8975)
1443 .irq = RK30_PIN3_PD7,
1444 .platform_data = &akm8975_info,
1445 .irq = RK30_PIN3_PD7,
1446 .platform_data = &akm8975_info,
1449 #if defined (CONFIG_GYRO_L3G4200D)
1451 .type = "l3g4200d_gryo",
1454 .irq = L3G4200D_INT_PIN,
1455 .platform_data = &l3g4200d_info,
1458 #if defined (CONFIG_SND_SOC_RK1000)
1460 .type = "rk1000_i2c_codec",
1465 .type = "rk1000_control",
1470 #if defined (CONFIG_SND_SOC_CX2070X)
1480 int __sramdata g_pmic_type = 0;
1481 #ifdef CONFIG_I2C1_RK30
1482 #ifdef CONFIG_REGULATOR_ACT8846
1483 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1484 #define PMU_VSEL RK30_PIN3_PD3
1485 #define ACT8846_HOST_IRQ RK30_PIN0_PB3
1487 static struct pmu_info act8846_dcdc_info[] = {
1489 .name = "act_dcdc1", //ddr
1492 .suspend_vol = 1200000,
1495 .name = "vdd_core", //logic
1498 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1499 .suspend_vol = 1200000,
1501 .suspend_vol = 900000,
1505 .name = "vdd_cpu", //arm
1508 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1509 .suspend_vol = 1200000,
1511 .suspend_vol = 900000,
1515 .name = "act_dcdc4", //vccio
1518 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1519 .suspend_vol = 3000000,
1521 .suspend_vol = 2800000,
1526 static struct pmu_info act8846_ldo_info[] = {
1528 .name = "act_ldo1", //vdd10
1533 .name = "act_ldo2", //vdd12
1538 .name = "act_ldo3", //vcc18_cif
1543 .name = "act_ldo4", //vcca33
1548 .name = "act_ldo5", //vcctp
1553 .name = "act_ldo6", //vcc_jetta
1558 .name = "act_ldo7", //vcc18
1563 .name = "act_ldo8", //vcc28_cif
1569 #include "../mach-rk30/board-pmu-act8846.c"
1572 #ifdef CONFIG_MFD_WM831X_I2C
1573 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1575 static struct pmu_info wm8326_dcdc_info[] = {
1577 .name = "vdd_core", //logic
1580 .suspend_vol = 950000,
1583 .name = "vdd_cpu", //arm
1586 .suspend_vol = 950000,
1589 .name = "dcdc3", //ddr
1592 .suspend_vol = 1150000,
1594 #ifdef CONFIG_MACH_RK3066_SDK
1596 .name = "dcdc4", //vcc_io
1599 .suspend_vol = 3000000,
1603 .name = "dcdc4", //vcc_io
1606 .suspend_vol = 2800000,
1611 static struct pmu_info wm8326_ldo_info[] = {
1613 .name = "ldo1", //vcc18_cif
1616 .suspend_vol = 1800000,
1619 .name = "ldo2", //vccio_wl
1622 .suspend_vol = 1800000,
1628 .suspend_vol = 1100000,
1631 .name = "ldo4", //vdd11
1634 .suspend_vol = 1000000,
1637 .name = "ldo5", //vcc25
1640 .suspend_vol = 1800000,
1643 .name = "ldo6", //vcc33
1646 .suspend_vol = 3300000,
1649 .name = "ldo7", //vcc28_cif
1652 .suspend_vol = 2800000,
1655 .name = "ldo8", //vcca33
1658 .suspend_vol = 3300000,
1661 .name = "ldo9", //vcc_tp
1664 .suspend_vol = 3300000,
1667 .name = "ldo10", //flash_io
1670 .suspend_vol = 1800000,
1674 #include "../mach-rk30/board-pmu-wm8326.c"
1677 #ifdef CONFIG_MFD_TPS65910
1678 #ifdef CONFIG_ARCH_RK3188
1679 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1681 #define TPS65910_HOST_IRQ RK30_PIN6_PA4
1684 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1686 static struct pmu_info tps65910_dcdc_info[] = {
1688 .name = "vdd_core", //logic
1693 .name = "vdd2", //ddr
1698 .name = "vio", //vcc_io
1704 static struct pmu_info tps65910_ldo_info[] = {
1706 .name = "vpll", //vdd10
1711 .name = "vdig1", //vcc18_cif
1716 .name = "vdig2", //vdd_jetta
1721 .name = "vaux1", //vcc28_cif
1726 .name = "vaux2", //vcca33
1731 .name = "vaux33", //vcc_tp
1736 .name = "vmmc", //vcc30
1741 .name = "vdac", //vcc18
1747 #include "../mach-rk30/board-pmu-tps65910.c"
1750 static struct i2c_board_info __initdata i2c1_info[] = {
1751 #if defined (CONFIG_REGULATOR_ACT8846)
1756 .irq = ACT8846_HOST_IRQ,
1757 .platform_data=&act8846_data,
1760 #if defined (CONFIG_RTC_HYM8563)
1762 .type = "rtc_hym8563",
1765 .irq = RK30_PIN0_PB5,
1768 #if defined (CONFIG_MFD_WM831X_I2C)
1773 .irq = RK30_PIN0_PB3,
1774 .platform_data = &wm831x_platdata,
1777 #if defined (CONFIG_MFD_TPS65910)
1780 .addr = TPS65910_I2C_ID0,
1782 .irq = TPS65910_HOST_IRQ,
1783 .platform_data = &tps65910_data,
1789 void __sramfunc board_pmu_suspend(void)
1791 #if defined (CONFIG_REGULATOR_ACT8846)
1792 if(pmic_is_act8846())
1793 board_pmu_act8846_suspend();
1795 #if defined (CONFIG_MFD_WM831X_I2C)
1796 if(pmic_is_wm8326())
1797 board_pmu_wm8326_suspend();
1799 #if defined (CONFIG_MFD_TPS65910)
1800 if(pmic_is_tps65910())
1801 board_pmu_tps65910_suspend();
1805 void __sramfunc board_pmu_resume(void)
1807 #if defined (CONFIG_REGULATOR_ACT8846)
1808 if(pmic_is_act8846())
1809 board_pmu_act8846_resume();
1811 #if defined (CONFIG_MFD_WM831X_I2C)
1812 if(pmic_is_wm8326())
1813 board_pmu_wm8326_resume();
1815 #if defined (CONFIG_MFD_TPS65910)
1816 if(pmic_is_tps65910())
1817 board_pmu_tps65910_resume();
1821 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1823 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
1824 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1826 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1828 #ifdef CONFIG_RK30_PWM_REGULATOR
1830 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1832 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1833 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1834 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1835 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1837 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
1838 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
1839 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
1840 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
1843 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1845 #ifdef CONFIG_RK30_PWM_REGULATOR
1846 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
1847 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
1848 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
1849 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
1855 extern void pwm_suspend_voltage(void);
1856 extern void pwm_resume_voltage(void);
1857 void rk30_pwm_suspend_voltage_set(void)
1859 #ifdef CONFIG_RK30_PWM_REGULATOR
1860 pwm_suspend_voltage();
1863 void rk30_pwm_resume_voltage_set(void)
1865 #ifdef CONFIG_RK30_PWM_REGULATOR
1866 pwm_resume_voltage();
1871 #ifdef CONFIG_I2C2_RK30
1872 static struct i2c_board_info __initdata i2c2_info[] = {
1873 #if defined (CONFIG_CT36X_TS)
1878 .platform_data = &ct36x_info,
1881 #if defined (CONFIG_LS_CM3217)
1883 .type = "lightsensor",
1886 .platform_data = &cm3217_info,
1889 #if defined (CONFIG_LS_US5151)
1897 #if defined(CONFIG_HDMI_CAT66121)
1899 .type = "cat66121_hdmi",
1902 .irq = RK30_PIN2_PD6,
1903 .platform_data = &rk_hdmi_pdata,
1909 #ifdef CONFIG_I2C3_RK30
1910 static struct i2c_board_info __initdata i2c3_info[] = {
1914 #ifdef CONFIG_I2C4_RK30
1915 static struct i2c_board_info __initdata i2c4_info[] = {
1916 #ifdef CONFIG_MFD_RK610
1918 .type = "rk610_ctl",
1921 .platform_data = &rk610_ctl_pdata,
1923 #ifdef CONFIG_RK610_TVOUT
1925 .type = "rk610_tvout",
1930 #ifdef CONFIG_HDMI_RK610
1932 .type = "rk610_hdmi",
1935 .irq = INVALID_GPIO,
1938 #ifdef CONFIG_SND_SOC_RK610
1939 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1940 .type = "rk610_i2c_codec",
1943 .platform_data = &rk610_codec_pdata,
1948 #if defined (CONFIG_SND_SOC_RT5631)
1959 #ifdef CONFIG_I2C_GPIO_RK30
1960 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1961 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1962 static int rk30_i2c_io_init(void)
1964 //set iomux (gpio) here
1965 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1966 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1970 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1971 .sda_pin = I2C_SDA_PIN,
1972 .scl_pin = I2C_SCL_PIN,
1973 .udelay = 5, // clk = 500/udelay = 100Khz
1974 .timeout = 100,//msecs_to_jiffies(100),
1976 .io_init = rk30_i2c_io_init,
1978 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1982 static void __init rk30_i2c_register_board_info(void)
1984 #ifdef CONFIG_I2C0_RK30
1985 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1987 #ifdef CONFIG_I2C1_RK30
1988 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1990 #ifdef CONFIG_I2C2_RK30
1991 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1993 #ifdef CONFIG_I2C3_RK30
1994 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1996 #ifdef CONFIG_I2C4_RK30
1997 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1999 #ifdef CONFIG_I2C_GPIO_RK30
2000 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2005 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
2006 static void rk30_pm_power_off(void)
2008 printk(KERN_ERR "rk30_pm_power_off start...\n");
2009 #if defined(CONFIG_MFD_WM831X)
2010 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2011 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2013 #if defined(CONFIG_REGULATOR_ACT8846)
2014 if (pmic_is_act8846()) {
2015 printk("enter dcdet===========\n");
2016 if(gpio_get_value (RK30_PIN0_PB2) == GPIO_LOW)
2018 printk("enter restart===========\n");
2019 arm_pm_restart(0, "charge");
2021 /** code here may cause tablet cannot boot when shutdown without charger pluged in
2022 * and then plug in charger. -- Cody Xie
2025 act8846_device_shutdown();
2030 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2034 static void __init machine_rk30_board_init(void)
2037 gpio_request(POWER_ON_PIN, "poweronpin");
2038 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2040 pm_power_off = rk30_pm_power_off;
2042 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2045 rk30_i2c_register_board_info();
2046 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2047 platform_add_devices(devices, ARRAY_SIZE(devices));
2048 rk_platform_add_display_devices();
2049 //board_usb_detect_init(RK30_PIN0_PA7);
2051 #ifdef CONFIG_WIFI_CONTROL_FUNC
2052 rk29sdk_wifi_bt_gpio_control_init();
2055 #if defined(CONFIG_MT6620)
2056 clk_set_rate(clk_get_sys("rk_serial.1", "uart"), 48*1000000);
2059 #if defined(CONFIG_MT5931_MT6622)
2060 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2064 #define HD_SCREEN_SIZE 1920UL*1200UL*4*3
2065 static void __init rk30_reserve(void)
2067 #if defined(CONFIG_ARCH_RK3188)
2068 /*if lcd resolution great than or equal to 1920*1200,reserve the ump memory */
2069 if(!(get_fb_size() < ALIGN(HD_SCREEN_SIZE,SZ_1M)))
2071 int ump_mem_phy_size=512UL*1024UL*1024UL;
2072 resource_mali[0].start = board_mem_reserve_add("ump buf", ump_mem_phy_size);
2073 resource_mali[0].end = resource_mali[0].start + ump_mem_phy_size -1;
2077 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2080 #ifdef CONFIG_FB_ROCKCHIP
2081 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2082 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2084 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2085 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2088 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2089 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2090 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2095 #ifdef CONFIG_VIDEO_RK29
2096 rk30_camera_request_reserve_mem();
2099 #ifdef CONFIG_GPS_RK
2100 //it must be more than 8MB
2101 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2103 board_mem_reserved();
2105 /******************************** arm dvfs frequency volt table **********************************/
2107 * dvfs_cpu_logic_table: table for arm and logic dvfs
2108 * @frequency : arm frequency
2109 * @cpu_volt : arm voltage depend on frequency
2113 static struct cpufreq_frequency_table dvfs_arm_table_volt_level0[] = {
2114 {.frequency = 312 * 1000, .index = 850 * 1000},
2115 {.frequency = 504 * 1000, .index = 900 * 1000},
2116 {.frequency = 816 * 1000, .index = 950 * 1000},
2117 {.frequency = 1008 * 1000, .index = 1025 * 1000},
2118 {.frequency = 1200 * 1000, .index = 1100 * 1000},
2119 {.frequency = 1416 * 1000, .index = 1200 * 1000},
2120 {.frequency = 1608 * 1000, .index = 1300 * 1000},
2121 {.frequency = CPUFREQ_TABLE_END},
2124 static struct cpufreq_frequency_table dvfs_arm_table_volt_level1[] = {
2125 {.frequency = 312 * 1000, .index = 875 * 1000},
2126 {.frequency = 504 * 1000, .index = 925 * 1000},
2127 {.frequency = 816 * 1000, .index = 975 * 1000},
2128 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2129 {.frequency = 1200 * 1000, .index = 1150 * 1000},
2130 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2131 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2132 {.frequency = CPUFREQ_TABLE_END},
2135 static struct cpufreq_frequency_table dvfs_arm_table_volt_level2[] = {
2136 {.frequency = 312 * 1000, .index = 900 * 1000},
2137 {.frequency = 504 * 1000, .index = 925 * 1000},
2138 {.frequency = 816 * 1000, .index = 1000 * 1000},
2139 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2140 {.frequency = 1200 * 1000, .index = 1200 * 1000},
2141 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2142 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2143 {.frequency = CPUFREQ_TABLE_END},
2145 //if you board is good for volt quality,select dvfs_arm_table_volt_level0
2146 #define dvfs_arm_table dvfs_arm_table_volt_level2
2148 /******************************** gpu dvfs frequency volt table **********************************/
2150 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level0[] = {
2151 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2152 {.frequency = 200 * 1000, .index = 975 * 1000},
2153 {.frequency = 266 * 1000, .index = 1000 * 1000},
2154 {.frequency = 300 * 1000, .index = 1050 * 1000},
2155 {.frequency = 400 * 1000, .index = 1100 * 1000},
2156 {.frequency = 600 * 1000, .index = 1200 * 1000},
2157 {.frequency = CPUFREQ_TABLE_END},
2160 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level1[] = {
2161 {.frequency = 133 * 1000, .index = 975 * 1000},
2162 {.frequency = 200 * 1000, .index = 1000 * 1000},
2163 {.frequency = 266 * 1000, .index = 1025 * 1000},
2164 {.frequency = 300 * 1000, .index = 1050 * 1000},
2165 {.frequency = 400 * 1000, .index = 1100 * 1000},
2166 {.frequency = 600 * 1000, .index = 1250 * 1000},
2167 {.frequency = CPUFREQ_TABLE_END},
2170 #define dvfs_gpu_table dvfs_gpu_table_volt_level1
2172 /******************************** ddr dvfs frequency volt table **********************************/
2173 static struct cpufreq_frequency_table dvfs_ddr_table_volt_level0[] = {
2174 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2175 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
2176 {.frequency = 396 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2177 {.frequency = 460 * 1000 + DDR_FREQ_DUALVIEW, .index = 1150 * 1000},
2178 //{.frequency = 528 * 1000 + DDR_FREQ_NORMAL, .index = 1200 * 1000},
2179 {.frequency = CPUFREQ_TABLE_END},
2182 static struct cpufreq_frequency_table dvfs_ddr_table_t[] = {
2183 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2184 {.frequency = 460 * 1000 + DDR_FREQ_NORMAL, .index = 1150 * 1000},
2185 {.frequency = CPUFREQ_TABLE_END},
2187 #define dvfs_ddr_table dvfs_ddr_table_volt_level0
2189 /******************************** arm dvfs frequency volt table end **********************************/
2193 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2194 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2195 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2196 int get_max_freq(struct cpufreq_frequency_table *table)
2200 for(i=0;table[i].frequency!= CPUFREQ_TABLE_END;i++)
2202 if(temp<table[i].frequency)
2203 temp=table[i].frequency;
2205 printk("get_max_freq=%d\n",temp);
2209 void __init board_clock_init(void)
2211 u32 flags=RK30_CLOCKS_DEFAULT_FLAGS;
2212 #if !defined(CONFIG_ARCH_RK3188)
2213 if(get_max_freq(dvfs_gpu_table)<=(400*1000))
2215 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_GPLL;
2218 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_CPLL;
2220 rk30_clock_data_init(periph_pll_default, codec_pll_default, flags);
2221 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2222 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2223 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2224 #if defined(CONFIG_ARCH_RK3188)
2225 if (rk_pll_flag() == 0)
2226 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2228 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table_t);
2230 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2234 MACHINE_START(RK30, "RK30board")
2235 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2236 .fixup = rk30_fixup,
2237 .reserve = &rk30_reserve,
2238 .map_io = rk30_map_io,
2239 .init_irq = rk30_init_irq,
2240 .timer = &rk30_timer,
2241 .init_machine = machine_rk30_board_init,