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"
78 #include <linux/scaler-core.h>
80 static struct rk29_keys_button key_button[] = {
84 .gpio = RK30_PIN0_PA4,
85 .active_low = PRESS_LEV_LOW,
93 .active_low = PRESS_LEV_LOW,
96 struct rk29_keys_platform_data rk29_keys_pdata = {
97 .buttons = key_button,
98 .nbuttons = ARRAY_SIZE(key_button),
99 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
104 v1.1 : rk610 lvds + rk610 codec + MT5931_MT6622 + light photoresistor + adc/cw2015
105 v1.2 : lvds + rt5631 + M500 + us5151 + adc
107 #define DS1006H_V1_2_SUPPORT 1
108 int get_harware_version()
110 #if DS1006H_V1_2_SUPPORT
116 EXPORT_SYMBOL_GPL(get_harware_version);
118 #if defined(CONFIG_CT36X_TS)
120 #define TOUCH_MODEL 363
121 #define TOUCH_MAX_X 1280
122 #define TOUCH_MAX_y 800
123 #define TOUCH_RESET_PIN RK30_PIN0_PB6
124 #define TOUCH_INT_PIN RK30_PIN1_PB7
126 static struct ct36x_platform_data ct36x_info = {
127 .model = TOUCH_MODEL,
128 .x_max = TOUCH_MAX_X,
129 .y_max = TOUCH_MAX_y,
132 .gpio = TOUCH_RESET_PIN,
136 .gpio = TOUCH_INT_PIN,
139 .orientation = {1, 0, 0, 1},
142 static struct spi_board_info board_spi_devices[] = {
145 /***********************************************************
147 ************************************************************/
148 #ifdef CONFIG_BACKLIGHT_RK29_BL
150 #define PWM_MODE PWM3
151 #define PWM_EFFECT_VALUE 1
153 #define LCD_DISP_ON_PIN
155 #ifdef LCD_DISP_ON_PIN
156 #define BL_EN_PIN RK30_PIN0_PA2
157 #define BL_EN_VALUE GPIO_HIGH
159 static int rk29_backlight_io_init(void)
164 #ifdef LCD_DISP_ON_PIN
165 ret = gpio_request(BL_EN_PIN, NULL);
167 gpio_free(BL_EN_PIN);
170 gpio_direction_output(BL_EN_PIN, 0);
171 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
177 static int rk29_backlight_io_deinit(void)
179 int ret = 0, pwm_gpio;
181 #ifdef LCD_DISP_ON_PIN
182 gpio_free(BL_EN_PIN);
185 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
186 gpio_request(pwm_gpio, NULL);
187 gpio_direction_output(pwm_gpio, GPIO_LOW);
191 static int rk29_backlight_pwm_suspend(void)
193 int ret = 0, pwm_gpio;
195 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
196 if (gpio_request(pwm_gpio, NULL)) {
197 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
200 gpio_direction_output(pwm_gpio, GPIO_LOW);
201 #ifdef LCD_DISP_ON_PIN
202 gpio_direction_output(BL_EN_PIN, 0);
203 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
208 static int rk29_backlight_pwm_resume(void)
210 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
214 #ifdef LCD_DISP_ON_PIN
216 gpio_direction_output(BL_EN_PIN, 1);
217 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
222 static struct rk29_bl_info rk29_bl_info = {
223 .min_brightness = 65,
224 .max_brightness = 150,
225 .brightness_mode =BRIGHTNESS_MODE_CONIC,
226 .pre_div = 30 * 1000, // pwm output clk: 30k;
228 .bl_ref = PWM_EFFECT_VALUE,
229 .io_init = rk29_backlight_io_init,
230 .io_deinit = rk29_backlight_io_deinit,
231 .pwm_suspend = rk29_backlight_pwm_suspend,
232 .pwm_resume = rk29_backlight_pwm_resume,
235 static struct platform_device rk29_device_backlight = {
236 .name = "rk29_backlight",
239 .platform_data = &rk29_bl_info,
246 #if defined (CONFIG_GS_MMA8452)
247 #define MMA8452_INT_PIN RK30_PIN0_PB7
249 static int mma8452_init_platform_hw(void)
254 static struct sensor_platform_data mma8452_info = {
255 .type = SENSOR_TYPE_ACCEL,
258 .init_platform_hw = mma8452_init_platform_hw,
259 .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
262 #if defined (CONFIG_GS_LIS3DH)
263 #define LIS3DH_INT_PIN RK30_PIN0_PB7
265 static int lis3dh_init_platform_hw(void)
271 static struct sensor_platform_data lis3dh_info = {
272 .type = SENSOR_TYPE_ACCEL,
275 .init_platform_hw = lis3dh_init_platform_hw,
276 .orientation = {-1, 0, 0, 0, 1, 0, 0, 0, -1},
280 #if defined (CONFIG_COMPASS_AK8963)
281 static struct sensor_platform_data akm8963_info =
283 .type = SENSOR_TYPE_COMPASS,
316 #if defined(CONFIG_LS_PHOTORESISTOR)
317 static struct sensor_platform_data light_photoresistor_info = {
318 .type = SENSOR_TYPE_LIGHT,
321 .poll_delay_ms = 200,
325 #if defined (CONFIG_COMPASS_AK8975)
326 static struct sensor_platform_data akm8975_info =
328 .type = SENSOR_TYPE_COMPASS,
361 #if defined(CONFIG_MT6229)
362 static int mt6229_io_init(void)
365 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
366 k30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
367 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
368 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
369 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
370 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
375 static int mt6229_io_deinit(void)
381 struct rk29_mt6229_data rk29_mt6229_info = {
382 .io_init = mt6229_io_init,
383 .io_deinit = mt6229_io_deinit,
384 .modem_power_en = RK30_PIN0_PC6,
385 .bp_power = RK30_PIN2_PD5,
386 .modem_usb_en = RK30_PIN0_PC7,
387 .modem_uart_en = RK30_PIN2_PD4,
388 .bp_wakeup_ap = RK30_PIN0_PC5,
389 .ap_ready = RK30_PIN0_PC4,
392 struct platform_device rk29_device_mt6229 = {
396 .platform_data = &rk29_mt6229_info,
401 #if defined(CONFIG_GYRO_L3G4200D)
403 #include <linux/l3g4200d.h>
404 #define L3G4200D_INT_PIN RK30_PIN0_PB4
406 static int l3g4200d_init_platform_hw(void)
411 static struct sensor_platform_data l3g4200d_info = {
412 .type = SENSOR_TYPE_GYROSCOPE,
415 .orientation = {1, 0, 0 , 0 , -1, 0, 0, 0, -1},
416 .init_platform_hw = l3g4200d_init_platform_hw,
417 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
424 #ifdef CONFIG_LS_CM3217
425 static struct sensor_platform_data cm3217_info = {
426 .type = SENSOR_TYPE_LIGHT,
428 .poll_delay_ms = 500,
433 #ifdef CONFIG_FB_ROCKCHIP
435 #if DS1006H_V1_2_SUPPORT
436 #define LCD_CS_PIN RK30_PIN0_PB0
438 #define LCD_CS_PIN INVALID_GPIO
440 #define LCD_CS_VALUE GPIO_HIGH
442 #if DS1006H_V1_2_SUPPORT
443 #define LCD_EN_PIN RK30_PIN0_PB1
445 #define LCD_EN_PIN RK30_PIN0_PB0
447 #define LCD_EN_VALUE GPIO_LOW
449 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
453 if(LCD_CS_PIN !=INVALID_GPIO)
455 ret = gpio_request(LCD_CS_PIN, NULL);
458 gpio_free(LCD_CS_PIN);
459 printk(KERN_ERR "request lcd cs pin fail!\n");
464 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
468 if(LCD_EN_PIN !=INVALID_GPIO)
470 ret = gpio_request(LCD_EN_PIN, NULL);
473 gpio_free(LCD_EN_PIN);
474 printk(KERN_ERR "request lcd en pin fail!\n");
479 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
484 static int rk_fb_io_disable(void)
486 if(LCD_CS_PIN !=INVALID_GPIO)
488 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
490 if(LCD_EN_PIN !=INVALID_GPIO)
492 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
496 static int rk_fb_io_enable(void)
498 if(LCD_CS_PIN !=INVALID_GPIO)
500 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
502 if(LCD_EN_PIN !=INVALID_GPIO)
504 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
509 #if defined(CONFIG_LCDC1_RK3188)
510 struct rk29fb_info lcdc1_screen_info = {
511 .prop = EXTEND, //extend display device
513 .set_screen_info = hdmi_init_lcdc,
518 #if defined(CONFIG_LCDC0_RK3188)
519 struct rk29fb_info lcdc0_screen_info = {
520 .prop = PRMRY, //primary display device
521 .io_init = rk_fb_io_init,
522 .io_disable = rk_fb_io_disable,
523 .io_enable = rk_fb_io_enable,
524 .set_screen_info = set_lcd_info,
529 static struct resource resource_fb[] = {
533 .end = 0,//RK30_FB0_MEM_SIZE - 1,
534 .flags = IORESOURCE_MEM,
537 .name = "ipp buf", //for rotate
539 .end = 0,//RK30_FB0_MEM_SIZE - 1,
540 .flags = IORESOURCE_MEM,
545 .end = 0,//RK30_FB0_MEM_SIZE - 1,
546 .flags = IORESOURCE_MEM,
550 static struct platform_device device_fb = {
553 .num_resources = ARRAY_SIZE(resource_fb),
554 .resource = resource_fb,
558 #if defined(CONFIG_ARCH_RK3188)
559 static struct resource resource_mali[] = {
564 .flags = IORESOURCE_MEM,
569 static struct platform_device device_mali= {
570 .name = "mali400_ump",
572 .num_resources = ARRAY_SIZE(resource_mali),
573 .resource = resource_mali,
577 #if defined(CONFIG_LCDC0_RK3188)
578 static struct resource resource_lcdc0[] = {
581 .start = RK30_LCDC0_PHYS,
582 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
583 .flags = IORESOURCE_MEM,
590 .flags = IORESOURCE_IRQ,
594 static struct platform_device device_lcdc0 = {
597 .num_resources = ARRAY_SIZE(resource_lcdc0),
598 .resource = resource_lcdc0,
600 .platform_data = &lcdc0_screen_info,
604 #if defined(CONFIG_LCDC1_RK3188)
605 static struct resource resource_lcdc1[] = {
608 .start = RK30_LCDC1_PHYS,
609 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
610 .flags = IORESOURCE_MEM,
616 .flags = IORESOURCE_IRQ,
620 static struct platform_device device_lcdc1 = {
623 .num_resources = ARRAY_SIZE(resource_lcdc1),
624 .resource = resource_lcdc1,
626 .platform_data = &lcdc1_screen_info,
631 #if defined(CONFIG_MFD_RK610)
632 #define RK610_RST_PIN RK30_PIN3_PB2
633 static int rk610_power_on_init(void)
636 if(RK610_RST_PIN != INVALID_GPIO)
638 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
641 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
645 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
647 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
649 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
658 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
659 .rk610_power_on_init = rk610_power_on_init,
663 #ifdef CONFIG_SND_SOC_RK610
664 static int rk610_codec_io_init(void)
667 //Must not gpio_request
671 static struct rk610_codec_platform_data rk610_codec_pdata = {
672 .spk_ctl_io = RK30_PIN2_PD7,
673 .io_init = rk610_codec_io_init,
678 #ifdef CONFIG_RK_HDMI
679 #define RK_HDMI_RST_PIN RK30_PIN3_PB2
680 static int rk_hdmi_power_init(void)
684 if(RK_HDMI_RST_PIN != INVALID_GPIO)
686 if (gpio_request(RK_HDMI_RST_PIN, NULL)) {
687 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
690 gpio_direction_output(RK_HDMI_RST_PIN, GPIO_LOW);
691 gpio_set_value(RK_HDMI_RST_PIN, GPIO_LOW);
693 gpio_set_value(RK_HDMI_RST_PIN, GPIO_HIGH);
698 static struct rk_hdmi_platform_data rk_hdmi_pdata = {
699 //.io_init = rk_hdmi_power_init,
703 #define ION_RESERVE_SIZE (80 * SZ_1M)
704 static struct ion_platform_data rk30_ion_pdata = {
708 .type = ION_HEAP_TYPE_CARVEOUT,
709 .id = ION_NOR_HEAP_ID,
711 .size = ION_RESERVE_SIZE,
716 static struct platform_device device_ion = {
717 .name = "ion-rockchip",
720 .platform_data = &rk30_ion_pdata,
725 /**************************************************************************************************
726 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
727 **************************************************************************************************/
728 #ifdef CONFIG_SDMMC_RK29
729 #include "board-rk3188-ac-sdmmc-config.c"
730 #include "../plat-rk/rk-sdmmc-ops.c"
731 #include "../plat-rk/rk-sdmmc-wifi.c"
732 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
734 #ifdef CONFIG_SDMMC0_RK29
735 static int rk29_sdmmc0_cfg_gpio(void)
737 #ifdef CONFIG_SDMMC_RK29_OLD
739 iomux_set(MMC0_CLKOUT);
745 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
747 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
748 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
751 rk29_sdmmc_set_iomux(0, 0xFFFF);
753 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
754 #if SDMMC_USE_NEW_IOMUX_API
755 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
757 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
760 #if SDMMC_USE_NEW_IOMUX_API
761 iomux_set(MMC0_DETN);
763 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
767 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
768 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
769 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
777 #define CONFIG_SDMMC0_USE_DMA
778 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
780 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
781 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
782 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
784 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
785 .io_init = rk29_sdmmc0_cfg_gpio,
787 #if !defined(CONFIG_SDMMC_RK29_OLD)
788 .set_iomux = rk29_sdmmc_set_iomux,
791 .dma_name = "sd_mmc",
792 #ifdef CONFIG_SDMMC0_USE_DMA
798 #if defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
799 .status = rk29sdk_wifi_mmc0_status,
800 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
803 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
804 .power_en = RK29SDK_SD_CARD_PWR_EN,
805 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
807 .power_en = INVALID_GPIO,
808 .power_en_level = GPIO_LOW,
810 .enable_sd_wakeup = 0,
812 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
813 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
814 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
816 .write_prt = INVALID_GPIO,
820 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
821 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
822 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
823 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
825 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
826 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
827 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
829 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
830 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
841 #endif // CONFIG_SDMMC0_RK29
843 #ifdef CONFIG_SDMMC1_RK29
844 #define CONFIG_SDMMC1_USE_DMA
845 static int rk29_sdmmc1_cfg_gpio(void)
847 #if defined(CONFIG_SDMMC_RK29_OLD)
849 iomux_set(MMC1_CLKOUT);
856 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
857 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
858 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
866 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
868 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
869 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
872 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
873 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
874 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
877 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
880 .io_init = rk29_sdmmc1_cfg_gpio,
882 #if !defined(CONFIG_SDMMC_RK29_OLD)
883 .set_iomux = rk29_sdmmc_set_iomux,
887 #ifdef CONFIG_SDMMC1_USE_DMA
893 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
894 .status = rk29sdk_wifi_status,
895 .register_status_notify = rk29sdk_wifi_status_register,
898 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
899 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
900 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
902 .write_prt = INVALID_GPIO,
905 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
906 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
910 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
911 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
912 .io = RK29SDK_SD_CARD_DETECT_N,
917 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
918 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
920 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
921 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
922 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
924 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
925 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
935 .enable_sd_wakeup = 0,
937 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
939 /**************************************************************************************************
940 * the end of setting for SDMMC devices
941 **************************************************************************************************/
943 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
944 static int ac_current = -1;
945 #define CHARING_CURRENT_500MA 0
946 #define CHARING_CURRENT_1000MA 1
948 #define DC_CUR_SET_PIN RK30_PIN0_PB0
949 #define CHARGE_OK_PIN RK30_PIN0_PA6
950 #define DC_DET_PIN RK30_PIN0_PB2
951 static int rk30_battery_adc_io_init(void)
954 printk("charging: set charging current 500ma \n");
955 ac_current = CHARING_CURRENT_500MA;
956 //dc charge detect pin
957 ret = gpio_request(DC_DET_PIN, NULL);
959 printk("failed to request dc_det gpio\n");
963 gpio_pull_updown(DC_DET_PIN, 1);//important
964 ret = gpio_direction_input(DC_DET_PIN);
966 printk("failed to set gpio dc_det input\n");
971 ret = gpio_request(CHARGE_OK_PIN, NULL);
973 printk("failed to request charge_ok gpio\n");
977 gpio_pull_updown(CHARGE_OK_PIN, 1);//important
978 ret = gpio_direction_input(CHARGE_OK_PIN);
980 printk("failed to set gpio charge_ok input\n");
983 //charge current set pin
984 ret = gpio_request(DC_CUR_SET_PIN, NULL);
986 printk("failed to request DC_CUR_SET_PIN gpio\n");
990 ret = gpio_direction_output(DC_CUR_SET_PIN, GPIO_LOW);//500ma
992 printk("failed to set gpio DC_CUR_SET_PIN output\n");
1000 static int set_usb_charging_current(int mode)
1003 if ( (ac_current==CHARING_CURRENT_1000MA) && (mode == PC_MODE) ) {
1004 gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW);
1005 ac_current = CHARING_CURRENT_500MA;
1007 else if ((mode == ADAPT_MODE) && (ac_current==CHARING_CURRENT_500MA))
1009 gpio_set_value(DC_CUR_SET_PIN, GPIO_HIGH);
1010 ac_current = CHARING_CURRENT_1000MA;
1014 gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW);
1015 ac_current = CHARING_CURRENT_500MA;
1019 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1020 .dc_det_pin = RK30_PIN0_PB2,
1021 .batt_low_pin = INVALID_GPIO,
1022 .charge_set_pin = INVALID_GPIO,
1023 .charge_ok_pin = RK30_PIN0_PA6,
1024 .usb_det_pin = INVALID_GPIO,
1025 .dc_det_level = GPIO_LOW,
1026 .charge_ok_level = GPIO_HIGH,
1028 .reference_voltage = 1800, // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
1029 .pull_up_res = 200, //divider resistance , pull-up resistor
1030 .pull_down_res = 120, //divider resistance , pull-down resistor
1032 .is_reboot_charging = 1,
1033 .save_capacity = 1 ,
1034 .low_voltage_protection = 3600,
1035 .io_init = rk30_battery_adc_io_init,
1036 .control_usb_charging= set_usb_charging_current,
1039 static struct platform_device rk30_device_adc_battery = {
1040 .name = "rk30-battery",
1043 .platform_data = &rk30_adc_battery_platdata,
1047 #ifdef CONFIG_RK30_PWM_REGULATOR
1048 static int pwm_voltage_map[] = {
1049 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
1052 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1054 .supply = "vdd_cpu",
1058 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1062 .name = "PWM_DCDC1",
1064 .max_uV = 1800000, //0.6-1.8V
1066 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1068 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1069 .consumer_supplies = pwm_dcdc1_consumers,
1073 static struct pwm_platform_data pwm_regulator_info[1] = {
1076 .pwm_gpio = RK30_PIN3_PD4,
1077 .pwm_iomux_pwm = PWM1,
1078 .pwm_iomux_gpio = GPIO3_D4,
1079 .pwm_voltage = 1100000,
1080 .suspend_voltage = 1000000,
1083 .coefficient = 575, //57.5%
1084 .pwm_voltage_map = pwm_voltage_map,
1085 .init_data = &pwm_regulator_init_dcdc[0],
1089 struct platform_device pwm_regulator_device[1] = {
1091 .name = "pwm-voltage-regulator",
1094 .platform_data = &pwm_regulator_info[0],
1100 #ifdef CONFIG_RK29_VMAC
1101 #define PHY_PWR_EN_GPIO INVALID_GPIO
1102 #define PHY_PWR_EN_IOMUX GPIO3_D2
1103 #define PHY_PWR_EN_VALUE GPIO_HIGH
1104 #include "../mach-rk30/board-rk31-sdk-vmac.c"
1107 #ifdef CONFIG_RFKILL_RK
1108 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1109 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1110 .type = RFKILL_TYPE_BLUETOOTH,
1112 .poweron_gpio = { // BT_REG_ON
1113 .io = INVALID_GPIO, //RK30_PIN3_PC7,
1114 .enable = GPIO_HIGH,
1116 .name = "bt_poweron",
1121 .reset_gpio = { // BT_RST
1122 .io = RK30_PIN3_PA0, // set io to INVALID_GPIO for disable it
1130 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1131 .io = RK30_PIN3_PB0, // set io to INVALID_GPIO for disable it
1132 .enable = GPIO_HIGH,
1139 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1141 .io = RK30_PIN3_PB1, // set io to INVALID_GPIO for disable it
1142 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1149 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1150 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1160 static struct platform_device device_rfkill_rk = {
1161 .name = "rfkill_rk",
1164 .platform_data = &rfkill_rk_platdata,
1169 #if defined(CONFIG_GPS_RK)
1170 int rk_gps_io_init(void)
1172 printk("%s \n", __FUNCTION__);
1174 rk30_mux_api_set(GPIO1B5_UART3RTSN_NAME, GPIO1B_GPIO1B5);//VCC_EN
1175 gpio_request(RK30_PIN1_PB5, NULL);
1176 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1178 rk30_mux_api_set(GPIO1B4_UART3CTSN_GPSRFCLK_NAME, GPIO1B_GPSRFCLK);//GPS_CLK
1179 rk30_mux_api_set(GPIO1B2_UART3SIN_GPSMAG_NAME, GPIO1B_GPSMAG);//GPS_MAG
1180 rk30_mux_api_set(GPIO1B3_UART3SOUT_GPSSIG_NAME, GPIO1B_GPSSIG);//GPS_SIGN
1182 rk30_mux_api_set(GPIO1A6_UART1CTSN_SPI0CLK_NAME, GPIO1A_GPIO1A6);//SPI_CLK
1183 gpio_request(RK30_PIN1_PA6, NULL);
1184 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1186 rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0TXD_NAME, GPIO1A_GPIO1A5);//SPI_MOSI
1187 gpio_request(RK30_PIN1_PA5, NULL);
1188 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1190 rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0CSN0_NAME, GPIO1A_GPIO1A7);//SPI_CS
1191 gpio_request(RK30_PIN1_PA7, NULL);
1192 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1195 int rk_gps_power_up(void)
1197 printk("%s \n", __FUNCTION__);
1202 int rk_gps_power_down(void)
1204 printk("%s \n", __FUNCTION__);
1209 int rk_gps_reset_set(int level)
1213 int rk_enable_hclk_gps(void)
1215 printk("%s \n", __FUNCTION__);
1216 clk_enable(clk_get(NULL, "hclk_gps"));
1219 int rk_disable_hclk_gps(void)
1221 printk("%s \n", __FUNCTION__);
1222 clk_disable(clk_get(NULL, "hclk_gps"));
1225 struct rk_gps_data rk_gps_info = {
1226 .io_init = rk_gps_io_init,
1227 .power_up = rk_gps_power_up,
1228 .power_down = rk_gps_power_down,
1229 .reset = rk_gps_reset_set,
1230 .enable_hclk_gps = rk_enable_hclk_gps,
1231 .disable_hclk_gps = rk_disable_hclk_gps,
1232 .GpsSign = RK30_PIN1_PB3,
1233 .GpsMag = RK30_PIN1_PB2, //GPIO index
1234 .GpsClk = RK30_PIN1_PB4, //GPIO index
1235 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1236 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1237 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1238 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1242 .u32GpsPhyAddr = RK30_GPS_PHYS,
1243 .u32GpsPhySize = RK30_GPS_SIZE,
1246 struct platform_device rk_device_gps = {
1247 .name = "gps_hv5820b",
1250 .platform_data = &rk_gps_info,
1255 #if defined(CONFIG_MT5931_MT6622)
1256 static struct mt6622_platform_data mt6622_platdata = {
1257 .power_gpio = { // BT_REG_ON
1258 #if DS1006H_V1_2_SUPPORT
1259 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1261 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1263 .enable = GPIO_HIGH,
1269 .reset_gpio = { // BT_RST
1270 #if DS1006H_V1_2_SUPPORT
1271 .io = RK30_PIN3_PD1,
1273 .io = RK30_PIN0_PD7,
1275 .enable = GPIO_HIGH,
1282 #if DS1006H_V1_2_SUPPORT
1283 .io = RK30_PIN0_PA5,
1285 .io = RK30_PIN3_PD2,
1287 .enable = GPIO_HIGH,
1294 static struct platform_device device_mt6622 = {
1298 .platform_data = &mt6622_platdata,
1303 #if defined CONFIG_TCC_BT_DEV
1304 static struct tcc_bt_platform_data tcc_bt_platdata = {
1306 .power_gpio = { // ldoon
1307 .io = RK2928_PIN3_PC0,
1308 .enable = GPIO_HIGH,
1314 .wake_host_gpio = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1315 .io = RK2928_PIN0_PC5, // set io to INVALID_GPIO for disable it
1316 .enable = IRQF_TRIGGER_RISING,// set IRQF_TRIGGER_FALLING for falling, set IRQF_TRIGGER_RISING for rising
1323 static struct platform_device device_tcc_bt = {
1324 .name = "tcc_bt_dev",
1327 .platform_data = &tcc_bt_platdata,
1333 static struct platform_device *devices[] __initdata = {
1338 #ifdef CONFIG_WIFI_CONTROL_FUNC
1339 &rk29sdk_wifi_device,
1342 #if defined(CONFIG_MT6620)
1346 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1347 &rk30_device_adc_battery,
1349 #ifdef CONFIG_RFKILL_RK
1352 #ifdef CONFIG_GPS_RK
1355 #ifdef CONFIG_MT5931_MT6622
1358 #if defined(CONFIG_MT6229)
1359 &rk29_device_mt6229,
1361 #if defined(CONFIG_ARCH_RK3188)
1365 #ifdef CONFIG_TCC_BT_DEV
1371 static int rk_platform_add_display_devices(void)
1373 struct platform_device *fb = NULL; //fb
1374 struct platform_device *lcdc0 = NULL; //lcdc0
1375 struct platform_device *lcdc1 = NULL; //lcdc1
1376 struct platform_device *bl = NULL; //backlight
1377 #ifdef CONFIG_FB_ROCKCHIP
1381 #if defined(CONFIG_LCDC0_RK3188)
1382 lcdc0 = &device_lcdc0,
1385 #if defined(CONFIG_LCDC1_RK3188)
1386 lcdc1 = &device_lcdc1,
1389 #ifdef CONFIG_BACKLIGHT_RK29_BL
1390 bl = &rk29_device_backlight,
1392 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1399 #ifdef CONFIG_I2C0_RK30
1400 static struct i2c_board_info __initdata i2c0_info[] = {
1401 #if defined (CONFIG_GS_MMA8452)
1403 .type = "gs_mma8452",
1406 .irq = MMA8452_INT_PIN,
1407 .platform_data = &mma8452_info,
1411 #if defined (CONFIG_GS_LIS3DH)
1413 .type = "gs_lis3dh",
1414 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1416 .irq = LIS3DH_INT_PIN,
1417 .platform_data = &lis3dh_info,
1420 #if defined (CONFIG_COMPASS_AK8963)
1425 .irq = RK30_PIN3_PD7,
1426 .platform_data = &akm8963_info,
1430 #if defined (CONFIG_LS_PHOTORESISTOR)
1432 .type = "ls_photoresistor",
1435 .irq = INVALID_GPIO,
1436 .platform_data = &light_photoresistor_info,
1440 #if defined (CONFIG_COMPASS_AK8975)
1445 .irq = RK30_PIN3_PD7,
1446 .platform_data = &akm8975_info,
1447 .irq = RK30_PIN3_PD7,
1448 .platform_data = &akm8975_info,
1451 #if defined (CONFIG_GYRO_L3G4200D)
1453 .type = "l3g4200d_gryo",
1456 .irq = L3G4200D_INT_PIN,
1457 .platform_data = &l3g4200d_info,
1460 #if defined (CONFIG_SND_SOC_RK1000)
1462 .type = "rk1000_i2c_codec",
1467 .type = "rk1000_control",
1472 #if defined (CONFIG_SND_SOC_CX2070X)
1482 int __sramdata g_pmic_type = 0;
1483 #ifdef CONFIG_I2C1_RK30
1484 #ifdef CONFIG_REGULATOR_ACT8846
1485 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1486 #define PMU_VSEL RK30_PIN3_PD3
1487 #define ACT8846_HOST_IRQ RK30_PIN0_PB3
1489 static struct pmu_info act8846_dcdc_info[] = {
1491 .name = "act_dcdc1", //ddr
1494 .suspend_vol = 1200000,
1497 .name = "vdd_core", //logic
1500 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1501 .suspend_vol = 1200000,
1503 .suspend_vol = 900000,
1507 .name = "vdd_cpu", //arm
1510 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1511 .suspend_vol = 1200000,
1513 .suspend_vol = 900000,
1517 .name = "act_dcdc4", //vccio
1520 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1521 .suspend_vol = 3000000,
1523 .suspend_vol = 2800000,
1528 static struct pmu_info act8846_ldo_info[] = {
1530 .name = "act_ldo1", //vdd10
1535 .name = "act_ldo2", //vdd12
1540 .name = "act_ldo3", //vcc18_cif
1545 .name = "act_ldo4", //vcca33
1550 .name = "act_ldo5", //vcctp
1555 .name = "act_ldo6", //vcc_jetta
1560 .name = "act_ldo7", //vcc18
1565 .name = "act_ldo8", //vcc28_cif
1571 #include "../mach-rk30/board-pmu-act8846.c"
1574 #ifdef CONFIG_MFD_WM831X_I2C
1575 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1577 static struct pmu_info wm8326_dcdc_info[] = {
1579 .name = "vdd_core", //logic
1582 .suspend_vol = 950000,
1585 .name = "vdd_cpu", //arm
1588 .suspend_vol = 950000,
1591 .name = "dcdc3", //ddr
1594 .suspend_vol = 1150000,
1596 #ifdef CONFIG_MACH_RK3066_SDK
1598 .name = "dcdc4", //vcc_io
1601 .suspend_vol = 3000000,
1605 .name = "dcdc4", //vcc_io
1608 .suspend_vol = 2800000,
1613 static struct pmu_info wm8326_ldo_info[] = {
1615 .name = "ldo1", //vcc18_cif
1618 .suspend_vol = 1800000,
1621 .name = "ldo2", //vccio_wl
1624 .suspend_vol = 1800000,
1630 .suspend_vol = 1100000,
1633 .name = "ldo4", //vdd11
1636 .suspend_vol = 1000000,
1639 .name = "ldo5", //vcc25
1642 .suspend_vol = 1800000,
1645 .name = "ldo6", //vcc33
1648 .suspend_vol = 3300000,
1651 .name = "ldo7", //vcc28_cif
1654 .suspend_vol = 2800000,
1657 .name = "ldo8", //vcca33
1660 .suspend_vol = 3300000,
1663 .name = "ldo9", //vcc_tp
1666 .suspend_vol = 3300000,
1669 .name = "ldo10", //flash_io
1672 .suspend_vol = 1800000,
1676 #include "../mach-rk30/board-pmu-wm8326.c"
1679 #ifdef CONFIG_MFD_TPS65910
1680 #ifdef CONFIG_ARCH_RK3188
1681 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1683 #define TPS65910_HOST_IRQ RK30_PIN6_PA4
1686 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1688 static struct pmu_info tps65910_dcdc_info[] = {
1690 .name = "vdd_core", //logic
1695 .name = "vdd2", //ddr
1700 .name = "vio", //vcc_io
1706 static struct pmu_info tps65910_ldo_info[] = {
1708 .name = "vpll", //vdd10
1713 .name = "vdig1", //vcc18_cif
1718 .name = "vdig2", //vdd_jetta
1723 .name = "vaux1", //vcc28_cif
1728 .name = "vaux2", //vcca33
1733 .name = "vaux33", //vcc_tp
1738 .name = "vmmc", //vcc30
1743 .name = "vdac", //vcc18
1749 #include "../mach-rk30/board-pmu-tps65910.c"
1752 #if defined(CONFIG_SCALER_TEST)
1753 //the fisrt port is default
1754 struct scaler_output_port tst_oports[] ={
1756 .led_gpio = INVALID_GPIO,
1757 .type = SCALER_OUT_VGA,
1761 //the fisrt port is default
1762 struct scaler_input_port tst_iports[] = {
1765 .led_gpio = RK30_PIN0_PD4,
1766 .type = SCALER_IN_VGA,
1770 .led_gpio = RK30_PIN0_PD5,
1771 .type = SCALER_IN_VGA,
1775 struct scaler_platform_data test_data = {
1776 .func_type = SCALER_FUNC_SWITCH,
1778 .iports = tst_iports,
1779 .iport_size = ARRAY_SIZE(tst_iports),
1780 .oports = tst_oports,
1781 .oport_size = ARRAY_SIZE(tst_oports),
1783 .power_gpio = RK30_PIN2_PD7,
1787 static struct i2c_board_info __initdata i2c1_info[] = {
1788 #if defined(CONFIG_SCALER_TEST)
1793 .platform_data = &test_data,
1796 #if defined (CONFIG_REGULATOR_ACT8846)
1801 .irq = ACT8846_HOST_IRQ,
1802 .platform_data=&act8846_data,
1805 #if defined (CONFIG_RTC_HYM8563)
1807 .type = "rtc_hym8563",
1810 .irq = RK30_PIN0_PB5,
1813 #if defined (CONFIG_MFD_WM831X_I2C)
1818 .irq = RK30_PIN0_PB3,
1819 .platform_data = &wm831x_platdata,
1822 #if defined (CONFIG_MFD_TPS65910)
1825 .addr = TPS65910_I2C_ID0,
1827 .irq = TPS65910_HOST_IRQ,
1828 .platform_data = &tps65910_data,
1834 void __sramfunc board_pmu_suspend(void)
1836 #if defined (CONFIG_REGULATOR_ACT8846)
1837 if(pmic_is_act8846())
1838 board_pmu_act8846_suspend();
1840 #if defined (CONFIG_MFD_WM831X_I2C)
1841 if(pmic_is_wm8326())
1842 board_pmu_wm8326_suspend();
1844 #if defined (CONFIG_MFD_TPS65910)
1845 if(pmic_is_tps65910())
1846 board_pmu_tps65910_suspend();
1850 void __sramfunc board_pmu_resume(void)
1852 #if defined (CONFIG_REGULATOR_ACT8846)
1853 if(pmic_is_act8846())
1854 board_pmu_act8846_resume();
1856 #if defined (CONFIG_MFD_WM831X_I2C)
1857 if(pmic_is_wm8326())
1858 board_pmu_wm8326_resume();
1860 #if defined (CONFIG_MFD_TPS65910)
1861 if(pmic_is_tps65910())
1862 board_pmu_tps65910_resume();
1866 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1868 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
1869 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1871 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1873 #ifdef CONFIG_RK30_PWM_REGULATOR
1875 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1877 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1878 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1879 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1880 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1882 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
1883 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
1884 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
1885 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
1888 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1890 #ifdef CONFIG_RK30_PWM_REGULATOR
1891 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
1892 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
1893 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
1894 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
1900 extern void pwm_suspend_voltage(void);
1901 extern void pwm_resume_voltage(void);
1902 void rk30_pwm_suspend_voltage_set(void)
1904 #ifdef CONFIG_RK30_PWM_REGULATOR
1905 pwm_suspend_voltage();
1908 void rk30_pwm_resume_voltage_set(void)
1910 #ifdef CONFIG_RK30_PWM_REGULATOR
1911 pwm_resume_voltage();
1916 #ifdef CONFIG_I2C2_RK30
1917 static struct i2c_board_info __initdata i2c2_info[] = {
1918 #if defined(CONFIG_SCALER_DEVICE)
1925 #if defined (CONFIG_CT36X_TS)
1930 .platform_data = &ct36x_info,
1933 #if defined (CONFIG_LS_CM3217)
1935 .type = "lightsensor",
1938 .platform_data = &cm3217_info,
1941 #if defined (CONFIG_LS_US5151)
1949 #if defined(CONFIG_HDMI_CAT66121)
1951 .type = "cat66121_hdmi",
1954 .irq = RK30_PIN2_PD6,
1955 .platform_data = &rk_hdmi_pdata,
1961 #ifdef CONFIG_I2C3_RK30
1962 static struct i2c_board_info __initdata i2c3_info[] = {
1966 #ifdef CONFIG_I2C4_RK30
1967 static struct i2c_board_info __initdata i2c4_info[] = {
1968 #ifdef CONFIG_MFD_RK610
1970 .type = "rk610_ctl",
1973 .platform_data = &rk610_ctl_pdata,
1975 #ifdef CONFIG_RK610_TVOUT
1977 .type = "rk610_tvout",
1982 #ifdef CONFIG_HDMI_RK610
1984 .type = "rk610_hdmi",
1987 .irq = INVALID_GPIO,
1990 #ifdef CONFIG_SND_SOC_RK610
1991 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
1992 .type = "rk610_i2c_codec",
1995 .platform_data = &rk610_codec_pdata,
2000 #if defined (CONFIG_SND_SOC_RT5631)
2011 #ifdef CONFIG_I2C_GPIO_RK30
2012 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
2013 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
2014 static int rk30_i2c_io_init(void)
2016 //set iomux (gpio) here
2017 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
2018 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
2022 struct i2c_gpio_platform_data default_i2c_gpio_data = {
2023 .sda_pin = I2C_SDA_PIN,
2024 .scl_pin = I2C_SCL_PIN,
2025 .udelay = 5, // clk = 500/udelay = 100Khz
2026 .timeout = 100,//msecs_to_jiffies(100),
2028 .io_init = rk30_i2c_io_init,
2030 static struct i2c_board_info __initdata i2c_gpio_info[] = {
2034 static void __init rk30_i2c_register_board_info(void)
2036 #ifdef CONFIG_I2C0_RK30
2037 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
2039 #ifdef CONFIG_I2C1_RK30
2040 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
2042 #ifdef CONFIG_I2C2_RK30
2043 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
2045 #ifdef CONFIG_I2C3_RK30
2046 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
2048 #ifdef CONFIG_I2C4_RK30
2049 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
2051 #ifdef CONFIG_I2C_GPIO_RK30
2052 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2057 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
2058 static void rk30_pm_power_off(void)
2060 printk(KERN_ERR "rk30_pm_power_off start...\n");
2061 #if defined(CONFIG_MFD_WM831X)
2062 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2063 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2065 #if defined(CONFIG_REGULATOR_ACT8846)
2066 if (pmic_is_act8846()) {
2067 printk("enter dcdet===========\n");
2068 if(gpio_get_value (RK30_PIN0_PB2) == GPIO_LOW)
2070 printk("enter restart===========\n");
2071 arm_pm_restart(0, "charge");
2073 /** code here may cause tablet cannot boot when shutdown without charger pluged in
2074 * and then plug in charger. -- Cody Xie
2077 act8846_device_shutdown();
2082 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2086 static void __init machine_rk30_board_init(void)
2089 gpio_request(POWER_ON_PIN, "poweronpin");
2090 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2092 pm_power_off = rk30_pm_power_off;
2094 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2097 rk30_i2c_register_board_info();
2098 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2099 platform_add_devices(devices, ARRAY_SIZE(devices));
2100 rk_platform_add_display_devices();
2101 //board_usb_detect_init(RK30_PIN0_PA7);
2103 #ifdef CONFIG_WIFI_CONTROL_FUNC
2104 rk29sdk_wifi_bt_gpio_control_init();
2107 #if defined(CONFIG_MT6620)
2108 clk_set_rate(clk_get_sys("rk_serial.1", "uart"), 48*1000000);
2111 #if defined(CONFIG_MT5931_MT6622)
2112 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2116 #define HD_SCREEN_SIZE 1920UL*1200UL*4*3
2117 static void __init rk30_reserve(void)
2119 #if defined(CONFIG_ARCH_RK3188)
2120 /*if lcd resolution great than or equal to 1920*1200,reserve the ump memory */
2121 if(!(get_fb_size() < ALIGN(HD_SCREEN_SIZE,SZ_1M)))
2123 int ump_mem_phy_size=512UL*1024UL*1024UL;
2124 resource_mali[0].start = board_mem_reserve_add("ump buf", ump_mem_phy_size);
2125 resource_mali[0].end = resource_mali[0].start + ump_mem_phy_size -1;
2129 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2132 #ifdef CONFIG_FB_ROCKCHIP
2133 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2134 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2136 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2137 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2140 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2141 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2142 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2147 #ifdef CONFIG_VIDEO_RK29
2148 rk30_camera_request_reserve_mem();
2151 #ifdef CONFIG_GPS_RK
2152 //it must be more than 8MB
2153 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2155 board_mem_reserved();
2157 /******************************** arm dvfs frequency volt table **********************************/
2159 * dvfs_cpu_logic_table: table for arm and logic dvfs
2160 * @frequency : arm frequency
2161 * @cpu_volt : arm voltage depend on frequency
2165 static struct cpufreq_frequency_table dvfs_arm_table_volt_level0[] = {
2166 {.frequency = 312 * 1000, .index = 850 * 1000},
2167 {.frequency = 504 * 1000, .index = 900 * 1000},
2168 {.frequency = 816 * 1000, .index = 950 * 1000},
2169 {.frequency = 1008 * 1000, .index = 1025 * 1000},
2170 {.frequency = 1200 * 1000, .index = 1100 * 1000},
2171 {.frequency = 1416 * 1000, .index = 1200 * 1000},
2172 {.frequency = 1608 * 1000, .index = 1300 * 1000},
2173 {.frequency = CPUFREQ_TABLE_END},
2176 static struct cpufreq_frequency_table dvfs_arm_table_volt_level1[] = {
2177 {.frequency = 312 * 1000, .index = 875 * 1000},
2178 {.frequency = 504 * 1000, .index = 925 * 1000},
2179 {.frequency = 816 * 1000, .index = 975 * 1000},
2180 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2181 {.frequency = 1200 * 1000, .index = 1150 * 1000},
2182 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2183 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2184 {.frequency = CPUFREQ_TABLE_END},
2187 static struct cpufreq_frequency_table dvfs_arm_table_volt_level2[] = {
2188 {.frequency = 312 * 1000, .index = 900 * 1000},
2189 {.frequency = 504 * 1000, .index = 925 * 1000},
2190 {.frequency = 816 * 1000, .index = 1000 * 1000},
2191 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2192 {.frequency = 1200 * 1000, .index = 1200 * 1000},
2193 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2194 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2195 {.frequency = CPUFREQ_TABLE_END},
2197 //if you board is good for volt quality,select dvfs_arm_table_volt_level0
2198 #define dvfs_arm_table dvfs_arm_table_volt_level2
2200 /******************************** gpu dvfs frequency volt table **********************************/
2202 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level0[] = {
2203 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2204 {.frequency = 200 * 1000, .index = 975 * 1000},
2205 {.frequency = 266 * 1000, .index = 1000 * 1000},
2206 {.frequency = 300 * 1000, .index = 1050 * 1000},
2207 {.frequency = 400 * 1000, .index = 1100 * 1000},
2208 {.frequency = 600 * 1000, .index = 1200 * 1000},
2209 {.frequency = CPUFREQ_TABLE_END},
2212 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level1[] = {
2213 {.frequency = 133 * 1000, .index = 975 * 1000},
2214 {.frequency = 200 * 1000, .index = 1000 * 1000},
2215 {.frequency = 266 * 1000, .index = 1025 * 1000},
2216 {.frequency = 300 * 1000, .index = 1050 * 1000},
2217 {.frequency = 400 * 1000, .index = 1100 * 1000},
2218 {.frequency = 600 * 1000, .index = 1250 * 1000},
2219 {.frequency = CPUFREQ_TABLE_END},
2222 #define dvfs_gpu_table dvfs_gpu_table_volt_level1
2224 /******************************** ddr dvfs frequency volt table **********************************/
2225 static struct cpufreq_frequency_table dvfs_ddr_table_volt_level0[] = {
2226 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2227 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
2228 {.frequency = 396 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2229 {.frequency = 460 * 1000 + DDR_FREQ_DUALVIEW, .index = 1150 * 1000},
2230 //{.frequency = 528 * 1000 + DDR_FREQ_NORMAL, .index = 1200 * 1000},
2231 {.frequency = CPUFREQ_TABLE_END},
2234 static struct cpufreq_frequency_table dvfs_ddr_table_t[] = {
2235 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2236 {.frequency = 460 * 1000 + DDR_FREQ_NORMAL, .index = 1150 * 1000},
2237 {.frequency = CPUFREQ_TABLE_END},
2239 #define dvfs_ddr_table dvfs_ddr_table_volt_level0
2241 /******************************** arm dvfs frequency volt table end **********************************/
2245 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2246 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2247 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2248 int get_max_freq(struct cpufreq_frequency_table *table)
2252 for(i=0;table[i].frequency!= CPUFREQ_TABLE_END;i++)
2254 if(temp<table[i].frequency)
2255 temp=table[i].frequency;
2257 printk("get_max_freq=%d\n",temp);
2261 void __init board_clock_init(void)
2263 u32 flags=RK30_CLOCKS_DEFAULT_FLAGS;
2264 #if !defined(CONFIG_ARCH_RK3188)
2265 if(get_max_freq(dvfs_gpu_table)<=(400*1000))
2267 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_GPLL;
2270 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_CPLL;
2272 rk30_clock_data_init(periph_pll_default, codec_pll_default, flags);
2273 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2274 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2275 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2276 #if defined(CONFIG_ARCH_RK3188)
2277 if (rk_pll_flag() == 0)
2278 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2280 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table_t);
2282 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2286 MACHINE_START(RK30, "RK30board")
2287 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2288 .fixup = rk30_fixup,
2289 .reserve = &rk30_reserve,
2290 .map_io = rk30_map_io,
2291 .init_irq = rk30_init_irq,
2292 .timer = &rk30_timer,
2293 .init_machine = machine_rk30_board_init,