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,
94 .active_low = PRESS_LEV_LOW,
98 .desc = "mode_switch",
99 .code = KEY_MODE_SWITCH,
101 //.code = KEY_VOLUMEUP,
104 .gpio = INVALID_GPIO,
105 .active_low = PRESS_LEV_LOW,
110 struct rk29_keys_platform_data rk29_keys_pdata = {
111 .buttons = key_button,
112 .nbuttons = ARRAY_SIZE(key_button),
113 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
118 v1.1 : rk610 lvds + rk610 codec + MT5931_MT6622 + light photoresistor + adc/cw2015
119 v1.2 : lvds + rt5631 + M500 + us5151 + adc
121 #define DS1006H_V1_2_SUPPORT 1
122 int get_harware_version()
124 #if DS1006H_V1_2_SUPPORT
130 EXPORT_SYMBOL_GPL(get_harware_version);
132 #if defined(CONFIG_CT36X_TS)
134 #define TOUCH_MODEL 363
135 #define TOUCH_MAX_X 1280
136 #define TOUCH_MAX_y 800
137 #define TOUCH_RESET_PIN RK30_PIN0_PB6
138 #define TOUCH_INT_PIN RK30_PIN1_PB7
140 static struct ct36x_platform_data ct36x_info = {
141 .model = TOUCH_MODEL,
142 .x_max = TOUCH_MAX_X,
143 .y_max = TOUCH_MAX_y,
146 .gpio = TOUCH_RESET_PIN,
150 .gpio = TOUCH_INT_PIN,
153 .orientation = {1, 0, 0, 1},
156 static struct spi_board_info board_spi_devices[] = {
159 /***********************************************************
161 ************************************************************/
162 #ifdef CONFIG_BACKLIGHT_RK29_BL
164 #define PWM_MODE PWM3
165 #define PWM_EFFECT_VALUE 1
167 #define LCD_DISP_ON_PIN
169 #ifdef LCD_DISP_ON_PIN
170 #define BL_EN_PIN RK30_PIN0_PA2
171 #define BL_EN_VALUE GPIO_HIGH
173 static int rk29_backlight_io_init(void)
178 #ifdef LCD_DISP_ON_PIN
179 ret = gpio_request(BL_EN_PIN, NULL);
181 gpio_free(BL_EN_PIN);
184 gpio_direction_output(BL_EN_PIN, 0);
185 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
191 static int rk29_backlight_io_deinit(void)
193 int ret = 0, pwm_gpio;
195 #ifdef LCD_DISP_ON_PIN
196 gpio_free(BL_EN_PIN);
199 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
200 gpio_request(pwm_gpio, NULL);
201 gpio_direction_output(pwm_gpio, GPIO_LOW);
205 static int rk29_backlight_pwm_suspend(void)
207 int ret = 0, pwm_gpio;
209 pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
210 if (gpio_request(pwm_gpio, NULL)) {
211 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
214 gpio_direction_output(pwm_gpio, GPIO_LOW);
215 #ifdef LCD_DISP_ON_PIN
216 gpio_direction_output(BL_EN_PIN, 0);
217 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
222 static int rk29_backlight_pwm_resume(void)
224 int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
228 #ifdef LCD_DISP_ON_PIN
230 gpio_direction_output(BL_EN_PIN, 1);
231 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
236 static struct rk29_bl_info rk29_bl_info = {
237 .min_brightness = 65,
238 .max_brightness = 150,
239 .brightness_mode =BRIGHTNESS_MODE_CONIC,
240 .pre_div = 30 * 1000, // pwm output clk: 30k;
242 .bl_ref = PWM_EFFECT_VALUE,
243 .io_init = rk29_backlight_io_init,
244 .io_deinit = rk29_backlight_io_deinit,
245 .pwm_suspend = rk29_backlight_pwm_suspend,
246 .pwm_resume = rk29_backlight_pwm_resume,
249 static struct platform_device rk29_device_backlight = {
250 .name = "rk29_backlight",
253 .platform_data = &rk29_bl_info,
260 #if defined (CONFIG_GS_MMA8452)
261 #define MMA8452_INT_PIN RK30_PIN0_PB7
263 static int mma8452_init_platform_hw(void)
268 static struct sensor_platform_data mma8452_info = {
269 .type = SENSOR_TYPE_ACCEL,
272 .init_platform_hw = mma8452_init_platform_hw,
273 .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
276 #if defined (CONFIG_GS_LIS3DH)
277 #define LIS3DH_INT_PIN RK30_PIN0_PB7
279 static int lis3dh_init_platform_hw(void)
285 static struct sensor_platform_data lis3dh_info = {
286 .type = SENSOR_TYPE_ACCEL,
289 .init_platform_hw = lis3dh_init_platform_hw,
290 .orientation = {-1, 0, 0, 0, 1, 0, 0, 0, -1},
294 #if defined (CONFIG_COMPASS_AK8963)
295 static struct sensor_platform_data akm8963_info =
297 .type = SENSOR_TYPE_COMPASS,
330 #if defined(CONFIG_LS_PHOTORESISTOR)
331 static struct sensor_platform_data light_photoresistor_info = {
332 .type = SENSOR_TYPE_LIGHT,
335 .poll_delay_ms = 200,
339 #if defined (CONFIG_COMPASS_AK8975)
340 static struct sensor_platform_data akm8975_info =
342 .type = SENSOR_TYPE_COMPASS,
375 #if defined(CONFIG_MT6229)
376 static int mt6229_io_init(void)
379 rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6);
380 k30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
381 rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
382 rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
383 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
384 rk30_mux_api_set(GPIO2C1_LCDC1DATA17_SMCBLSN0_HSADCDATA6_NAME, GPIO2C_GPIO2C1);
389 static int mt6229_io_deinit(void)
395 struct rk29_mt6229_data rk29_mt6229_info = {
396 .io_init = mt6229_io_init,
397 .io_deinit = mt6229_io_deinit,
398 .modem_power_en = RK30_PIN0_PC6,
399 .bp_power = RK30_PIN2_PD5,
400 .modem_usb_en = RK30_PIN0_PC7,
401 .modem_uart_en = RK30_PIN2_PD4,
402 .bp_wakeup_ap = RK30_PIN0_PC5,
403 .ap_ready = RK30_PIN0_PC4,
406 struct platform_device rk29_device_mt6229 = {
410 .platform_data = &rk29_mt6229_info,
415 #if defined(CONFIG_GYRO_L3G4200D)
417 #include <linux/l3g4200d.h>
418 #define L3G4200D_INT_PIN RK30_PIN0_PB4
420 static int l3g4200d_init_platform_hw(void)
425 static struct sensor_platform_data l3g4200d_info = {
426 .type = SENSOR_TYPE_GYROSCOPE,
429 .orientation = {1, 0, 0 , 0 , -1, 0, 0, 0, -1},
430 .init_platform_hw = l3g4200d_init_platform_hw,
431 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
438 #ifdef CONFIG_LS_CM3217
439 static struct sensor_platform_data cm3217_info = {
440 .type = SENSOR_TYPE_LIGHT,
442 .poll_delay_ms = 500,
447 #ifdef CONFIG_FB_ROCKCHIP
449 #if DS1006H_V1_2_SUPPORT
450 #define LCD_CS_PIN RK30_PIN0_PB0
452 #define LCD_CS_PIN INVALID_GPIO
454 #define LCD_CS_VALUE GPIO_HIGH
456 #if DS1006H_V1_2_SUPPORT
457 #define LCD_EN_PIN RK30_PIN0_PB1
459 #define LCD_EN_PIN RK30_PIN0_PB0
461 #define LCD_EN_VALUE GPIO_LOW
463 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
467 if(LCD_CS_PIN !=INVALID_GPIO)
469 ret = gpio_request(LCD_CS_PIN, NULL);
472 gpio_free(LCD_CS_PIN);
473 printk(KERN_ERR "request lcd cs pin fail!\n");
478 gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
482 if(LCD_EN_PIN !=INVALID_GPIO)
484 ret = gpio_request(LCD_EN_PIN, NULL);
487 gpio_free(LCD_EN_PIN);
488 printk(KERN_ERR "request lcd en pin fail!\n");
493 gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
498 static int rk_fb_io_disable(void)
500 if(LCD_CS_PIN !=INVALID_GPIO)
502 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
504 if(LCD_EN_PIN !=INVALID_GPIO)
506 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
510 static int rk_fb_io_enable(void)
512 if(LCD_CS_PIN !=INVALID_GPIO)
514 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
516 if(LCD_EN_PIN !=INVALID_GPIO)
518 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
523 #if defined(CONFIG_LCDC1_RK3188)
524 struct rk29fb_info lcdc1_screen_info = {
525 .prop = EXTEND, //extend display device
527 .set_screen_info = hdmi_init_lcdc,
532 #if defined(CONFIG_LCDC0_RK3188)
533 struct rk29fb_info lcdc0_screen_info = {
534 .prop = PRMRY, //primary display device
535 .io_init = rk_fb_io_init,
536 .io_disable = rk_fb_io_disable,
537 .io_enable = rk_fb_io_enable,
538 .set_screen_info = set_lcd_info,
543 static struct resource resource_fb[] = {
547 .end = 0,//RK30_FB0_MEM_SIZE - 1,
548 .flags = IORESOURCE_MEM,
551 .name = "ipp buf", //for rotate
553 .end = 0,//RK30_FB0_MEM_SIZE - 1,
554 .flags = IORESOURCE_MEM,
559 .end = 0,//RK30_FB0_MEM_SIZE - 1,
560 .flags = IORESOURCE_MEM,
564 static struct platform_device device_fb = {
567 .num_resources = ARRAY_SIZE(resource_fb),
568 .resource = resource_fb,
572 #if defined(CONFIG_ARCH_RK3188)
573 static struct resource resource_mali[] = {
578 .flags = IORESOURCE_MEM,
583 static struct platform_device device_mali= {
584 .name = "mali400_ump",
586 .num_resources = ARRAY_SIZE(resource_mali),
587 .resource = resource_mali,
591 #if defined(CONFIG_LCDC0_RK3188)
592 static struct resource resource_lcdc0[] = {
595 .start = RK30_LCDC0_PHYS,
596 .end = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
597 .flags = IORESOURCE_MEM,
604 .flags = IORESOURCE_IRQ,
608 static struct platform_device device_lcdc0 = {
611 .num_resources = ARRAY_SIZE(resource_lcdc0),
612 .resource = resource_lcdc0,
614 .platform_data = &lcdc0_screen_info,
618 #if defined(CONFIG_LCDC1_RK3188)
619 static struct resource resource_lcdc1[] = {
622 .start = RK30_LCDC1_PHYS,
623 .end = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
624 .flags = IORESOURCE_MEM,
630 .flags = IORESOURCE_IRQ,
634 static struct platform_device device_lcdc1 = {
637 .num_resources = ARRAY_SIZE(resource_lcdc1),
638 .resource = resource_lcdc1,
640 .platform_data = &lcdc1_screen_info,
645 #if defined(CONFIG_MFD_RK610)
646 #define RK610_RST_PIN RK30_PIN3_PB2
647 static int rk610_power_on_init(void)
650 if(RK610_RST_PIN != INVALID_GPIO)
652 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
655 printk(KERN_ERR "rk610_control_probe request gpio fail\n");
659 gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
661 gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
663 gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
672 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
673 .rk610_power_on_init = rk610_power_on_init,
677 #ifdef CONFIG_SND_SOC_RK610
678 static int rk610_codec_io_init(void)
681 //Must not gpio_request
685 static struct rk610_codec_platform_data rk610_codec_pdata = {
686 .spk_ctl_io = RK30_PIN2_PD7,
687 .io_init = rk610_codec_io_init,
692 #ifdef CONFIG_RK_HDMI
693 #define RK_HDMI_RST_PIN RK30_PIN3_PB2
694 static int rk_hdmi_power_init(void)
698 if(RK_HDMI_RST_PIN != INVALID_GPIO)
700 if (gpio_request(RK_HDMI_RST_PIN, NULL)) {
701 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
704 gpio_direction_output(RK_HDMI_RST_PIN, GPIO_LOW);
705 gpio_set_value(RK_HDMI_RST_PIN, GPIO_LOW);
707 gpio_set_value(RK_HDMI_RST_PIN, GPIO_HIGH);
712 static struct rk_hdmi_platform_data rk_hdmi_pdata = {
713 //.io_init = rk_hdmi_power_init,
717 #define ION_RESERVE_SIZE (80 * SZ_1M)
718 static struct ion_platform_data rk30_ion_pdata = {
722 .type = ION_HEAP_TYPE_CARVEOUT,
723 .id = ION_NOR_HEAP_ID,
725 .size = ION_RESERVE_SIZE,
730 static struct platform_device device_ion = {
731 .name = "ion-rockchip",
734 .platform_data = &rk30_ion_pdata,
739 /**************************************************************************************************
740 * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
741 **************************************************************************************************/
742 #ifdef CONFIG_SDMMC_RK29
743 #include "board-rk3188-ac-sdmmc-config.c"
744 #include "../plat-rk/rk-sdmmc-ops.c"
745 #include "../plat-rk/rk-sdmmc-wifi.c"
746 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
748 #ifdef CONFIG_SDMMC0_RK29
749 static int rk29_sdmmc0_cfg_gpio(void)
751 #ifdef CONFIG_SDMMC_RK29_OLD
753 iomux_set(MMC0_CLKOUT);
759 iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
761 gpio_request(RK30_PIN3_PA7, "sdmmc-power");
762 gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
765 rk29_sdmmc_set_iomux(0, 0xFFFF);
767 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
768 #if SDMMC_USE_NEW_IOMUX_API
769 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
771 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
774 #if SDMMC_USE_NEW_IOMUX_API
775 iomux_set(MMC0_DETN);
777 rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
781 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
782 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
783 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
791 #define CONFIG_SDMMC0_USE_DMA
792 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
794 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
795 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
796 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
798 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
799 .io_init = rk29_sdmmc0_cfg_gpio,
801 #if !defined(CONFIG_SDMMC_RK29_OLD)
802 .set_iomux = rk29_sdmmc_set_iomux,
805 .dma_name = "sd_mmc",
806 #ifdef CONFIG_SDMMC0_USE_DMA
812 #if defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
813 .status = rk29sdk_wifi_mmc0_status,
814 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
817 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
818 .power_en = RK29SDK_SD_CARD_PWR_EN,
819 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
821 .power_en = INVALID_GPIO,
822 .power_en_level = GPIO_LOW,
824 .enable_sd_wakeup = 0,
826 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
827 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
828 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
830 .write_prt = INVALID_GPIO,
834 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
835 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
836 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
837 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
839 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
840 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
841 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
843 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
844 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
855 #endif // CONFIG_SDMMC0_RK29
857 #ifdef CONFIG_SDMMC1_RK29
858 #define CONFIG_SDMMC1_USE_DMA
859 static int rk29_sdmmc1_cfg_gpio(void)
861 #if defined(CONFIG_SDMMC_RK29_OLD)
863 iomux_set(MMC1_CLKOUT);
870 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
871 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
872 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
880 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
882 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
883 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
886 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
887 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
888 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
891 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
894 .io_init = rk29_sdmmc1_cfg_gpio,
896 #if !defined(CONFIG_SDMMC_RK29_OLD)
897 .set_iomux = rk29_sdmmc_set_iomux,
901 #ifdef CONFIG_SDMMC1_USE_DMA
907 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
908 .status = rk29sdk_wifi_status,
909 .register_status_notify = rk29sdk_wifi_status_register,
912 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
913 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
914 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
916 .write_prt = INVALID_GPIO,
919 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
920 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
924 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
925 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
926 .io = RK29SDK_SD_CARD_DETECT_N,
931 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
932 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
934 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
935 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
936 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
938 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
939 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
949 .enable_sd_wakeup = 0,
951 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
953 /**************************************************************************************************
954 * the end of setting for SDMMC devices
955 **************************************************************************************************/
957 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
958 static int ac_current = -1;
959 #define CHARING_CURRENT_500MA 0
960 #define CHARING_CURRENT_1000MA 1
962 #define DC_CUR_SET_PIN RK30_PIN0_PB0
963 #define CHARGE_OK_PIN RK30_PIN0_PA6
964 #define DC_DET_PIN RK30_PIN0_PB2
965 static int rk30_battery_adc_io_init(void)
968 printk("charging: set charging current 500ma \n");
969 ac_current = CHARING_CURRENT_500MA;
970 //dc charge detect pin
971 ret = gpio_request(DC_DET_PIN, NULL);
973 printk("failed to request dc_det gpio\n");
977 gpio_pull_updown(DC_DET_PIN, 1);//important
978 ret = gpio_direction_input(DC_DET_PIN);
980 printk("failed to set gpio dc_det input\n");
985 ret = gpio_request(CHARGE_OK_PIN, NULL);
987 printk("failed to request charge_ok gpio\n");
991 gpio_pull_updown(CHARGE_OK_PIN, 1);//important
992 ret = gpio_direction_input(CHARGE_OK_PIN);
994 printk("failed to set gpio charge_ok input\n");
997 //charge current set pin
998 ret = gpio_request(DC_CUR_SET_PIN, NULL);
1000 printk("failed to request DC_CUR_SET_PIN gpio\n");
1004 ret = gpio_direction_output(DC_CUR_SET_PIN, GPIO_LOW);//500ma
1006 printk("failed to set gpio DC_CUR_SET_PIN output\n");
1014 static int set_usb_charging_current(int mode)
1017 if ( (ac_current==CHARING_CURRENT_1000MA) && (mode == PC_MODE) ) {
1018 gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW);
1019 ac_current = CHARING_CURRENT_500MA;
1021 else if ((mode == ADAPT_MODE) && (ac_current==CHARING_CURRENT_500MA))
1023 gpio_set_value(DC_CUR_SET_PIN, GPIO_HIGH);
1024 ac_current = CHARING_CURRENT_1000MA;
1028 gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW);
1029 ac_current = CHARING_CURRENT_500MA;
1033 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
1034 .dc_det_pin = RK30_PIN0_PB2,
1035 .batt_low_pin = INVALID_GPIO,
1036 .charge_set_pin = INVALID_GPIO,
1037 .charge_ok_pin = RK30_PIN0_PA6,
1038 .usb_det_pin = INVALID_GPIO,
1039 .dc_det_level = GPIO_LOW,
1040 .charge_ok_level = GPIO_HIGH,
1042 .reference_voltage = 1800, // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
1043 .pull_up_res = 200, //divider resistance , pull-up resistor
1044 .pull_down_res = 120, //divider resistance , pull-down resistor
1046 .is_reboot_charging = 1,
1047 .save_capacity = 1 ,
1048 .low_voltage_protection = 3600,
1049 .io_init = rk30_battery_adc_io_init,
1050 .control_usb_charging= set_usb_charging_current,
1053 static struct platform_device rk30_device_adc_battery = {
1054 .name = "rk30-battery",
1057 .platform_data = &rk30_adc_battery_platdata,
1061 #ifdef CONFIG_RK30_PWM_REGULATOR
1062 static int pwm_voltage_map[] = {
1063 800000,825000,850000, 875000,900000, 925000 ,950000, 975000,1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000,1375000
1066 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1068 .supply = "vdd_cpu",
1072 struct regulator_init_data pwm_regulator_init_dcdc[1] =
1076 .name = "PWM_DCDC1",
1078 .max_uV = 1800000, //0.6-1.8V
1080 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1082 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1083 .consumer_supplies = pwm_dcdc1_consumers,
1087 static struct pwm_platform_data pwm_regulator_info[1] = {
1090 .pwm_gpio = RK30_PIN3_PD4,
1091 .pwm_iomux_pwm = PWM1,
1092 .pwm_iomux_gpio = GPIO3_D4,
1093 .pwm_voltage = 1100000,
1094 .suspend_voltage = 1000000,
1097 .coefficient = 575, //57.5%
1098 .pwm_voltage_map = pwm_voltage_map,
1099 .init_data = &pwm_regulator_init_dcdc[0],
1103 struct platform_device pwm_regulator_device[1] = {
1105 .name = "pwm-voltage-regulator",
1108 .platform_data = &pwm_regulator_info[0],
1114 #ifdef CONFIG_RK29_VMAC
1115 #define PHY_PWR_EN_GPIO INVALID_GPIO
1116 #define PHY_PWR_EN_IOMUX GPIO3_D2
1117 #define PHY_PWR_EN_VALUE GPIO_HIGH
1118 #include "../mach-rk30/board-rk31-sdk-vmac.c"
1121 #ifdef CONFIG_RFKILL_RK
1122 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1123 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1124 .type = RFKILL_TYPE_BLUETOOTH,
1126 .poweron_gpio = { // BT_REG_ON
1127 .io = INVALID_GPIO, //RK30_PIN3_PC7,
1128 .enable = GPIO_HIGH,
1130 .name = "bt_poweron",
1135 .reset_gpio = { // BT_RST
1136 .io = RK30_PIN3_PA0, // set io to INVALID_GPIO for disable it
1144 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
1145 .io = RK30_PIN3_PB0, // set io to INVALID_GPIO for disable it
1146 .enable = GPIO_HIGH,
1153 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1155 .io = RK30_PIN3_PB1, // set io to INVALID_GPIO for disable it
1156 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
1163 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
1164 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1174 static struct platform_device device_rfkill_rk = {
1175 .name = "rfkill_rk",
1178 .platform_data = &rfkill_rk_platdata,
1183 #if defined(CONFIG_GPS_RK)
1184 int rk_gps_io_init(void)
1186 printk("%s \n", __FUNCTION__);
1188 rk30_mux_api_set(GPIO1B5_UART3RTSN_NAME, GPIO1B_GPIO1B5);//VCC_EN
1189 gpio_request(RK30_PIN1_PB5, NULL);
1190 gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1192 rk30_mux_api_set(GPIO1B4_UART3CTSN_GPSRFCLK_NAME, GPIO1B_GPSRFCLK);//GPS_CLK
1193 rk30_mux_api_set(GPIO1B2_UART3SIN_GPSMAG_NAME, GPIO1B_GPSMAG);//GPS_MAG
1194 rk30_mux_api_set(GPIO1B3_UART3SOUT_GPSSIG_NAME, GPIO1B_GPSSIG);//GPS_SIGN
1196 rk30_mux_api_set(GPIO1A6_UART1CTSN_SPI0CLK_NAME, GPIO1A_GPIO1A6);//SPI_CLK
1197 gpio_request(RK30_PIN1_PA6, NULL);
1198 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1200 rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0TXD_NAME, GPIO1A_GPIO1A5);//SPI_MOSI
1201 gpio_request(RK30_PIN1_PA5, NULL);
1202 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1204 rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0CSN0_NAME, GPIO1A_GPIO1A7);//SPI_CS
1205 gpio_request(RK30_PIN1_PA7, NULL);
1206 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1209 int rk_gps_power_up(void)
1211 printk("%s \n", __FUNCTION__);
1216 int rk_gps_power_down(void)
1218 printk("%s \n", __FUNCTION__);
1223 int rk_gps_reset_set(int level)
1227 int rk_enable_hclk_gps(void)
1229 printk("%s \n", __FUNCTION__);
1230 clk_enable(clk_get(NULL, "hclk_gps"));
1233 int rk_disable_hclk_gps(void)
1235 printk("%s \n", __FUNCTION__);
1236 clk_disable(clk_get(NULL, "hclk_gps"));
1239 struct rk_gps_data rk_gps_info = {
1240 .io_init = rk_gps_io_init,
1241 .power_up = rk_gps_power_up,
1242 .power_down = rk_gps_power_down,
1243 .reset = rk_gps_reset_set,
1244 .enable_hclk_gps = rk_enable_hclk_gps,
1245 .disable_hclk_gps = rk_disable_hclk_gps,
1246 .GpsSign = RK30_PIN1_PB3,
1247 .GpsMag = RK30_PIN1_PB2, //GPIO index
1248 .GpsClk = RK30_PIN1_PB4, //GPIO index
1249 .GpsVCCEn = RK30_PIN1_PB5, //GPIO index
1250 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1251 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1252 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1256 .u32GpsPhyAddr = RK30_GPS_PHYS,
1257 .u32GpsPhySize = RK30_GPS_SIZE,
1260 struct platform_device rk_device_gps = {
1261 .name = "gps_hv5820b",
1264 .platform_data = &rk_gps_info,
1269 #if defined(CONFIG_MT5931_MT6622)
1270 static struct mt6622_platform_data mt6622_platdata = {
1271 .power_gpio = { // BT_REG_ON
1272 #if DS1006H_V1_2_SUPPORT
1273 .io = RK30_PIN3_PC7, // set io to INVALID_GPIO for disable it
1275 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
1277 .enable = GPIO_HIGH,
1283 .reset_gpio = { // BT_RST
1284 #if DS1006H_V1_2_SUPPORT
1285 .io = RK30_PIN3_PD1,
1287 .io = RK30_PIN0_PD7,
1289 .enable = GPIO_HIGH,
1296 #if DS1006H_V1_2_SUPPORT
1297 .io = RK30_PIN0_PA5,
1299 .io = RK30_PIN3_PD2,
1301 .enable = GPIO_HIGH,
1308 static struct platform_device device_mt6622 = {
1312 .platform_data = &mt6622_platdata,
1317 #if defined CONFIG_TCC_BT_DEV
1318 static struct tcc_bt_platform_data tcc_bt_platdata = {
1320 .power_gpio = { // ldoon
1321 .io = RK2928_PIN3_PC0,
1322 .enable = GPIO_HIGH,
1328 .wake_host_gpio = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1329 .io = RK2928_PIN0_PC5, // set io to INVALID_GPIO for disable it
1330 .enable = IRQF_TRIGGER_RISING,// set IRQF_TRIGGER_FALLING for falling, set IRQF_TRIGGER_RISING for rising
1337 static struct platform_device device_tcc_bt = {
1338 .name = "tcc_bt_dev",
1341 .platform_data = &tcc_bt_platdata,
1346 #if defined(CONFIG_AC_USB_SWITCH)
1347 static struct ac_usb_switch_platform_data ac_usb_switch_platdata= {
1348 .usb_switch_pin = RK30_PIN3_PB2,
1349 .pc_state_pin = INVALID_GPIO,
1351 static struct platform_device device_ac_usb_switch = {
1352 .name = "ac_usb_switch",
1355 .platform_data = &ac_usb_switch_platdata,
1360 static struct platform_device *devices[] __initdata = {
1365 #ifdef CONFIG_WIFI_CONTROL_FUNC
1366 &rk29sdk_wifi_device,
1369 #if defined(CONFIG_MT6620)
1373 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1374 &rk30_device_adc_battery,
1376 #ifdef CONFIG_RFKILL_RK
1379 #ifdef CONFIG_GPS_RK
1382 #ifdef CONFIG_MT5931_MT6622
1385 #if defined(CONFIG_MT6229)
1386 &rk29_device_mt6229,
1388 #if defined(CONFIG_ARCH_RK3188)
1392 #ifdef CONFIG_TCC_BT_DEV
1395 #if defined(CONFIG_AC_USB_SWITCH)
1396 &device_ac_usb_switch,
1401 static int rk_platform_add_display_devices(void)
1403 struct platform_device *fb = NULL; //fb
1404 struct platform_device *lcdc0 = NULL; //lcdc0
1405 struct platform_device *lcdc1 = NULL; //lcdc1
1406 struct platform_device *bl = NULL; //backlight
1407 #ifdef CONFIG_FB_ROCKCHIP
1411 #if defined(CONFIG_LCDC0_RK3188)
1412 lcdc0 = &device_lcdc0,
1415 #if defined(CONFIG_LCDC1_RK3188)
1416 lcdc1 = &device_lcdc1,
1419 #ifdef CONFIG_BACKLIGHT_RK29_BL
1420 bl = &rk29_device_backlight,
1422 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
1429 #ifdef CONFIG_I2C0_RK30
1430 static struct i2c_board_info __initdata i2c0_info[] = {
1431 #if defined (CONFIG_GS_MMA8452)
1433 .type = "gs_mma8452",
1436 .irq = MMA8452_INT_PIN,
1437 .platform_data = &mma8452_info,
1441 #if defined (CONFIG_GS_LIS3DH)
1443 .type = "gs_lis3dh",
1444 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1446 .irq = LIS3DH_INT_PIN,
1447 .platform_data = &lis3dh_info,
1450 #if defined (CONFIG_COMPASS_AK8963)
1455 .irq = RK30_PIN3_PD7,
1456 .platform_data = &akm8963_info,
1460 #if defined (CONFIG_LS_PHOTORESISTOR)
1462 .type = "ls_photoresistor",
1465 .irq = INVALID_GPIO,
1466 .platform_data = &light_photoresistor_info,
1470 #if defined (CONFIG_COMPASS_AK8975)
1475 .irq = RK30_PIN3_PD7,
1476 .platform_data = &akm8975_info,
1477 .irq = RK30_PIN3_PD7,
1478 .platform_data = &akm8975_info,
1481 #if defined (CONFIG_GYRO_L3G4200D)
1483 .type = "l3g4200d_gryo",
1486 .irq = L3G4200D_INT_PIN,
1487 .platform_data = &l3g4200d_info,
1490 #if defined (CONFIG_SND_SOC_RK1000)
1492 .type = "rk1000_i2c_codec",
1497 .type = "rk1000_control",
1502 #if defined (CONFIG_SND_SOC_CX2070X)
1512 int __sramdata g_pmic_type = 0;
1513 #ifdef CONFIG_I2C1_RK30
1514 #ifdef CONFIG_REGULATOR_ACT8846
1515 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1516 #define PMU_VSEL RK30_PIN3_PD3
1517 #define ACT8846_HOST_IRQ RK30_PIN0_PB3
1519 static struct pmu_info act8846_dcdc_info[] = {
1521 .name = "act_dcdc1", //ddr
1524 .suspend_vol = 1200000,
1527 .name = "vdd_core", //logic
1530 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1531 .suspend_vol = 1200000,
1533 .suspend_vol = 900000,
1537 .name = "vdd_cpu", //arm
1540 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1541 .suspend_vol = 1200000,
1543 .suspend_vol = 900000,
1547 .name = "act_dcdc4", //vccio
1550 #ifdef CONFIG_ACT8846_SUPPORT_RESET
1551 .suspend_vol = 3000000,
1553 .suspend_vol = 2800000,
1558 static struct pmu_info act8846_ldo_info[] = {
1560 .name = "act_ldo1", //vdd10
1565 .name = "act_ldo2", //vdd12
1570 .name = "act_ldo3", //vcc18_cif
1575 .name = "act_ldo4", //vcca33
1580 .name = "act_ldo5", //vcctp
1585 .name = "act_ldo6", //vcc_jetta
1590 .name = "act_ldo7", //vcc18
1595 .name = "act_ldo8", //vcc28_cif
1601 #include "../mach-rk30/board-pmu-act8846.c"
1604 #ifdef CONFIG_MFD_WM831X_I2C
1605 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1607 static struct pmu_info wm8326_dcdc_info[] = {
1609 .name = "vdd_core", //logic
1612 .suspend_vol = 950000,
1615 .name = "vdd_cpu", //arm
1618 .suspend_vol = 950000,
1621 .name = "dcdc3", //ddr
1624 .suspend_vol = 1150000,
1626 #ifdef CONFIG_MACH_RK3066_SDK
1628 .name = "dcdc4", //vcc_io
1631 .suspend_vol = 3000000,
1635 .name = "dcdc4", //vcc_io
1638 .suspend_vol = 2800000,
1643 static struct pmu_info wm8326_ldo_info[] = {
1645 .name = "ldo1", //vcc18_cif
1648 .suspend_vol = 1800000,
1651 .name = "ldo2", //vccio_wl
1654 .suspend_vol = 1800000,
1660 .suspend_vol = 1100000,
1663 .name = "ldo4", //vdd11
1666 .suspend_vol = 1000000,
1669 .name = "ldo5", //vcc25
1672 .suspend_vol = 1800000,
1675 .name = "ldo6", //vcc33
1678 .suspend_vol = 3300000,
1681 .name = "ldo7", //vcc28_cif
1684 .suspend_vol = 2800000,
1687 .name = "ldo8", //vcca33
1690 .suspend_vol = 3300000,
1693 .name = "ldo9", //vcc_tp
1696 .suspend_vol = 3300000,
1699 .name = "ldo10", //flash_io
1702 .suspend_vol = 1800000,
1706 #include "../mach-rk30/board-pmu-wm8326.c"
1709 #ifdef CONFIG_MFD_TPS65910
1710 #ifdef CONFIG_ARCH_RK3188
1711 #define TPS65910_HOST_IRQ RK30_PIN0_PB3
1713 #define TPS65910_HOST_IRQ RK30_PIN6_PA4
1716 #define PMU_POWER_SLEEP RK30_PIN0_PA1
1718 static struct pmu_info tps65910_dcdc_info[] = {
1720 .name = "vdd_core", //logic
1725 .name = "vdd2", //ddr
1730 .name = "vio", //vcc_io
1736 static struct pmu_info tps65910_ldo_info[] = {
1738 .name = "vpll", //vdd10
1743 .name = "vdig1", //vcc18_cif
1748 .name = "vdig2", //vdd_jetta
1753 .name = "vaux1", //vcc28_cif
1758 .name = "vaux2", //vcca33
1763 .name = "vaux33", //vcc_tp
1768 .name = "vmmc", //vcc30
1773 .name = "vdac", //vcc18
1779 #include "../mach-rk30/board-pmu-tps65910.c"
1782 #if defined(CONFIG_SCALER_TEST)
1783 //the fisrt port is default
1784 struct scaler_output_port tst_oports[] ={
1786 .led_gpio = INVALID_GPIO,
1787 .type = SCALER_OUT_VGA,
1791 //the fisrt port is default
1792 struct scaler_input_port tst_iports[] = {
1795 .led_gpio = RK30_PIN0_PD4,
1796 .type = SCALER_IN_VGA,
1800 .led_gpio = RK30_PIN0_PD5,
1801 .type = SCALER_IN_VGA,
1805 struct scaler_platform_data test_data = {
1806 .func_type = SCALER_FUNC_SWITCH,
1808 .iports = tst_iports,
1809 .iport_size = ARRAY_SIZE(tst_iports),
1810 .oports = tst_oports,
1811 .oport_size = ARRAY_SIZE(tst_oports),
1813 .power_gpio = RK30_PIN2_PD7,
1817 static struct i2c_board_info __initdata i2c1_info[] = {
1818 #if defined(CONFIG_SCALER_TEST)
1823 .platform_data = &test_data,
1826 #if defined (CONFIG_REGULATOR_ACT8846)
1831 .irq = ACT8846_HOST_IRQ,
1832 .platform_data=&act8846_data,
1835 #if defined (CONFIG_RTC_HYM8563)
1837 .type = "rtc_hym8563",
1840 .irq = RK30_PIN0_PB5,
1843 #if defined (CONFIG_MFD_WM831X_I2C)
1848 .irq = RK30_PIN0_PB3,
1849 .platform_data = &wm831x_platdata,
1852 #if defined (CONFIG_MFD_TPS65910)
1855 .addr = TPS65910_I2C_ID0,
1857 .irq = TPS65910_HOST_IRQ,
1858 .platform_data = &tps65910_data,
1864 void __sramfunc board_pmu_suspend(void)
1866 #if defined (CONFIG_REGULATOR_ACT8846)
1867 if(pmic_is_act8846())
1868 board_pmu_act8846_suspend();
1870 #if defined (CONFIG_MFD_WM831X_I2C)
1871 if(pmic_is_wm8326())
1872 board_pmu_wm8326_suspend();
1874 #if defined (CONFIG_MFD_TPS65910)
1875 if(pmic_is_tps65910())
1876 board_pmu_tps65910_suspend();
1880 void __sramfunc board_pmu_resume(void)
1882 #if defined (CONFIG_REGULATOR_ACT8846)
1883 if(pmic_is_act8846())
1884 board_pmu_act8846_resume();
1886 #if defined (CONFIG_MFD_WM831X_I2C)
1887 if(pmic_is_wm8326())
1888 board_pmu_wm8326_resume();
1890 #if defined (CONFIG_MFD_TPS65910)
1891 if(pmic_is_tps65910())
1892 board_pmu_tps65910_resume();
1896 int __sramdata gpio3d6_iomux,gpio3d6_do,gpio3d6_dir,gpio3d6_en;
1898 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
1899 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1901 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1903 #ifdef CONFIG_RK30_PWM_REGULATOR
1905 // int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1907 gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
1908 gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
1909 gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
1910 gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
1912 grf_writel((1<<28), GRF_GPIO3D_IOMUX);
1913 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
1914 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
1915 grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
1918 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1920 #ifdef CONFIG_RK30_PWM_REGULATOR
1921 grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
1922 grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
1923 grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
1924 grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
1930 extern void pwm_suspend_voltage(void);
1931 extern void pwm_resume_voltage(void);
1932 void rk30_pwm_suspend_voltage_set(void)
1934 #ifdef CONFIG_RK30_PWM_REGULATOR
1935 pwm_suspend_voltage();
1938 void rk30_pwm_resume_voltage_set(void)
1940 #ifdef CONFIG_RK30_PWM_REGULATOR
1941 pwm_resume_voltage();
1946 #ifdef CONFIG_I2C2_RK30
1947 static struct i2c_board_info __initdata i2c2_info[] = {
1948 #if defined(CONFIG_SCALER_DEVICE)
1955 #if defined (CONFIG_CT36X_TS)
1960 .platform_data = &ct36x_info,
1963 #if defined (CONFIG_LS_CM3217)
1965 .type = "lightsensor",
1968 .platform_data = &cm3217_info,
1971 #if defined (CONFIG_LS_US5151)
1979 #if defined(CONFIG_HDMI_CAT66121)
1981 .type = "cat66121_hdmi",
1984 .irq = RK30_PIN2_PD6,
1985 .platform_data = &rk_hdmi_pdata,
1991 #ifdef CONFIG_I2C3_RK30
1992 static struct i2c_board_info __initdata i2c3_info[] = {
1996 #ifdef CONFIG_I2C4_RK30
1997 static struct i2c_board_info __initdata i2c4_info[] = {
1998 #ifdef CONFIG_MFD_RK610
2000 .type = "rk610_ctl",
2003 .platform_data = &rk610_ctl_pdata,
2005 #ifdef CONFIG_RK610_TVOUT
2007 .type = "rk610_tvout",
2012 #ifdef CONFIG_HDMI_RK610
2014 .type = "rk610_hdmi",
2017 .irq = INVALID_GPIO,
2020 #ifdef CONFIG_SND_SOC_RK610
2021 {//RK610_CODEC addr from 0x60 to 0x80 (0x60~0x80)
2022 .type = "rk610_i2c_codec",
2025 .platform_data = &rk610_codec_pdata,
2030 #if defined (CONFIG_SND_SOC_RT5631)
2041 #ifdef CONFIG_I2C_GPIO_RK30
2042 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
2043 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
2044 static int rk30_i2c_io_init(void)
2046 //set iomux (gpio) here
2047 //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
2048 //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
2052 struct i2c_gpio_platform_data default_i2c_gpio_data = {
2053 .sda_pin = I2C_SDA_PIN,
2054 .scl_pin = I2C_SCL_PIN,
2055 .udelay = 5, // clk = 500/udelay = 100Khz
2056 .timeout = 100,//msecs_to_jiffies(100),
2058 .io_init = rk30_i2c_io_init,
2060 static struct i2c_board_info __initdata i2c_gpio_info[] = {
2064 static void __init rk30_i2c_register_board_info(void)
2066 #ifdef CONFIG_I2C0_RK30
2067 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
2069 #ifdef CONFIG_I2C1_RK30
2070 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
2072 #ifdef CONFIG_I2C2_RK30
2073 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
2075 #ifdef CONFIG_I2C3_RK30
2076 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
2078 #ifdef CONFIG_I2C4_RK30
2079 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
2081 #ifdef CONFIG_I2C_GPIO_RK30
2082 i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
2087 #define POWER_ON_PIN RK30_PIN0_PA0 //power_hold
2088 static void rk30_pm_power_off(void)
2090 printk(KERN_ERR "rk30_pm_power_off start...\n");
2091 #if defined(CONFIG_MFD_WM831X)
2092 wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0
2093 wm831x_device_shutdown(Wm831x);//wm8326 shutdown
2095 #if defined(CONFIG_REGULATOR_ACT8846)
2096 if (pmic_is_act8846()) {
2097 printk("enter dcdet===========\n");
2098 if(gpio_get_value (RK30_PIN0_PB2) == GPIO_LOW)
2100 printk("enter restart===========\n");
2101 arm_pm_restart(0, "charge");
2103 /** code here may cause tablet cannot boot when shutdown without charger pluged in
2104 * and then plug in charger. -- Cody Xie
2107 act8846_device_shutdown();
2112 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
2116 static void __init machine_rk30_board_init(void)
2119 gpio_request(POWER_ON_PIN, "poweronpin");
2120 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2122 pm_power_off = rk30_pm_power_off;
2124 gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
2127 rk30_i2c_register_board_info();
2128 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
2129 platform_add_devices(devices, ARRAY_SIZE(devices));
2130 rk_platform_add_display_devices();
2131 //board_usb_detect_init(RK30_PIN0_PA7);
2133 #ifdef CONFIG_WIFI_CONTROL_FUNC
2134 rk29sdk_wifi_bt_gpio_control_init();
2137 #if defined(CONFIG_MT6620)
2138 clk_set_rate(clk_get_sys("rk_serial.1", "uart"), 48*1000000);
2141 #if defined(CONFIG_MT5931_MT6622)
2142 clk_set_rate(clk_get_sys("rk_serial.0", "uart"), 24*1000000);
2146 #define HD_SCREEN_SIZE 1920UL*1200UL*4*3
2147 static void __init rk30_reserve(void)
2149 #if defined(CONFIG_ARCH_RK3188)
2150 /*if lcd resolution great than or equal to 1920*1200,reserve the ump memory */
2151 if(!(get_fb_size() < ALIGN(HD_SCREEN_SIZE,SZ_1M)))
2153 int ump_mem_phy_size=512UL*1024UL*1024UL;
2154 resource_mali[0].start = board_mem_reserve_add("ump buf", ump_mem_phy_size);
2155 resource_mali[0].end = resource_mali[0].start + ump_mem_phy_size -1;
2159 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
2162 #ifdef CONFIG_FB_ROCKCHIP
2163 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
2164 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
2166 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
2167 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
2170 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
2171 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
2172 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
2177 #ifdef CONFIG_VIDEO_RK29
2178 rk30_camera_request_reserve_mem();
2181 #ifdef CONFIG_GPS_RK
2182 //it must be more than 8MB
2183 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
2185 board_mem_reserved();
2187 /******************************** arm dvfs frequency volt table **********************************/
2189 * dvfs_cpu_logic_table: table for arm and logic dvfs
2190 * @frequency : arm frequency
2191 * @cpu_volt : arm voltage depend on frequency
2195 static struct cpufreq_frequency_table dvfs_arm_table_volt_level0[] = {
2196 {.frequency = 312 * 1000, .index = 850 * 1000},
2197 {.frequency = 504 * 1000, .index = 900 * 1000},
2198 {.frequency = 816 * 1000, .index = 950 * 1000},
2199 {.frequency = 1008 * 1000, .index = 1025 * 1000},
2200 {.frequency = 1200 * 1000, .index = 1100 * 1000},
2201 {.frequency = 1416 * 1000, .index = 1200 * 1000},
2202 {.frequency = 1608 * 1000, .index = 1300 * 1000},
2203 {.frequency = CPUFREQ_TABLE_END},
2206 static struct cpufreq_frequency_table dvfs_arm_table_volt_level1[] = {
2207 {.frequency = 312 * 1000, .index = 875 * 1000},
2208 {.frequency = 504 * 1000, .index = 925 * 1000},
2209 {.frequency = 816 * 1000, .index = 975 * 1000},
2210 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2211 {.frequency = 1200 * 1000, .index = 1150 * 1000},
2212 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2213 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2214 {.frequency = CPUFREQ_TABLE_END},
2217 static struct cpufreq_frequency_table dvfs_arm_table_volt_level2[] = {
2218 {.frequency = 312 * 1000, .index = 900 * 1000},
2219 {.frequency = 504 * 1000, .index = 925 * 1000},
2220 {.frequency = 816 * 1000, .index = 1000 * 1000},
2221 {.frequency = 1008 * 1000, .index = 1075 * 1000},
2222 {.frequency = 1200 * 1000, .index = 1200 * 1000},
2223 {.frequency = 1416 * 1000, .index = 1250 * 1000},
2224 {.frequency = 1608 * 1000, .index = 1350 * 1000},
2225 {.frequency = CPUFREQ_TABLE_END},
2227 //if you board is good for volt quality,select dvfs_arm_table_volt_level0
2228 #define dvfs_arm_table dvfs_arm_table_volt_level2
2230 /******************************** gpu dvfs frequency volt table **********************************/
2232 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level0[] = {
2233 {.frequency = 133 * 1000, .index = 975 * 1000},//the mininum rate is limited 133M for rk3188
2234 {.frequency = 200 * 1000, .index = 975 * 1000},
2235 {.frequency = 266 * 1000, .index = 1000 * 1000},
2236 {.frequency = 300 * 1000, .index = 1050 * 1000},
2237 {.frequency = 400 * 1000, .index = 1100 * 1000},
2238 {.frequency = 600 * 1000, .index = 1200 * 1000},
2239 {.frequency = CPUFREQ_TABLE_END},
2242 static struct cpufreq_frequency_table dvfs_gpu_table_volt_level1[] = {
2243 {.frequency = 133 * 1000, .index = 975 * 1000},
2244 {.frequency = 200 * 1000, .index = 1000 * 1000},
2245 {.frequency = 266 * 1000, .index = 1025 * 1000},
2246 {.frequency = 300 * 1000, .index = 1050 * 1000},
2247 {.frequency = 400 * 1000, .index = 1100 * 1000},
2248 {.frequency = 600 * 1000, .index = 1250 * 1000},
2249 {.frequency = CPUFREQ_TABLE_END},
2252 #define dvfs_gpu_table dvfs_gpu_table_volt_level1
2254 /******************************** ddr dvfs frequency volt table **********************************/
2255 static struct cpufreq_frequency_table dvfs_ddr_table_volt_level0[] = {
2256 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2257 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1000 * 1000},
2258 {.frequency = 396 * 1000 + DDR_FREQ_NORMAL, .index = 1100 * 1000},
2259 {.frequency = 460 * 1000 + DDR_FREQ_DUALVIEW, .index = 1150 * 1000},
2260 //{.frequency = 528 * 1000 + DDR_FREQ_NORMAL, .index = 1200 * 1000},
2261 {.frequency = CPUFREQ_TABLE_END},
2264 static struct cpufreq_frequency_table dvfs_ddr_table_t[] = {
2265 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 950 * 1000},
2266 {.frequency = 460 * 1000 + DDR_FREQ_NORMAL, .index = 1150 * 1000},
2267 {.frequency = CPUFREQ_TABLE_END},
2269 #define dvfs_ddr_table dvfs_ddr_table_volt_level0
2271 /******************************** arm dvfs frequency volt table end **********************************/
2275 //#define DVFS_CPU_TABLE_SIZE (ARRAY_SIZE(dvfs_cpu_logic_table))
2276 //static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
2277 //static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
2278 int get_max_freq(struct cpufreq_frequency_table *table)
2282 for(i=0;table[i].frequency!= CPUFREQ_TABLE_END;i++)
2284 if(temp<table[i].frequency)
2285 temp=table[i].frequency;
2287 printk("get_max_freq=%d\n",temp);
2291 void __init board_clock_init(void)
2293 u32 flags=RK30_CLOCKS_DEFAULT_FLAGS;
2294 #if !defined(CONFIG_ARCH_RK3188)
2295 if(get_max_freq(dvfs_gpu_table)<=(400*1000))
2297 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_GPLL;
2300 flags=RK30_CLOCKS_DEFAULT_FLAGS|CLK_GPU_CPLL;
2302 rk30_clock_data_init(periph_pll_default, codec_pll_default, flags);
2303 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
2304 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
2305 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
2306 #if defined(CONFIG_ARCH_RK3188)
2307 if (rk_pll_flag() == 0)
2308 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2310 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table_t);
2312 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
2316 MACHINE_START(RK30, "RK30board")
2317 .boot_params = PLAT_PHYS_OFFSET + 0x800,
2318 .fixup = rk30_fixup,
2319 .reserve = &rk30_reserve,
2320 .map_io = rk30_map_io,
2321 .init_irq = rk30_init_irq,
2322 .timer = &rk30_timer,
2323 .init_machine = machine_rk30_board_init,