2 * Copyright (C) 2013 ROCKCHIP, Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/input.h>
20 #include <linux/delay.h>
21 #include <linux/i2c.h>
22 #include <linux/skbuff.h>
23 #include <linux/spi/spi.h>
24 #include <linux/mmc/host.h>
25 #include <linux/ion.h>
26 #include <linux/cpufreq.h>
27 #include <linux/clk.h>
28 #include <linux/rk_fb.h>
29 #include <linux/regulator/machine.h>
30 #include <linux/rfkill-rk.h>
31 #include <linux/sensor-dev.h>
32 #include <linux/mfd/tps65910.h>
33 #include <linux/regulator/act8846.h>
34 #include <linux/regulator/rk29-pwm-regulator.h>
36 #include <asm/setup.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/map.h>
40 #include <asm/mach/flash.h>
41 #include <asm/hardware/gic.h>
43 #include <mach/dvfs.h>
44 #include <mach/board.h>
45 #include <mach/hardware.h>
47 #include <mach/gpio.h>
48 #include <mach/iomux.h>
50 #if defined(CONFIG_SPIM_RK29)
51 #include "../../../drivers/spi/rk29_spim.h"
54 #ifdef CONFIG_SND_SOC_RK3026
55 #include "../../../sound/soc/codecs/rk3026_codec.h"
58 #if defined(CONFIG_RK_HDMI)
59 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
62 #if defined(CONFIG_GPS_RK)
63 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
65 #include "board-rk3028a-86v-camera.c"
67 /***********************************************************
69 ************************************************************/
71 #define POWER_ON_PIN RK30_PIN1_PA1 //PWR_HOLD
74 #define TOUCH_RST_PIN RK30_PIN3_PC3
75 #define TOUCH_RST_VALUE GPIO_HIGH
76 #define TOUCH_PWR_PIN RK30_PIN2_PD0
77 #define TOUCH_PWR_VALUE GPIO_LOW
78 #define TOUCH_INT_PIN RK30_PIN3_PC7
81 #define LCD_DISP_ON_PIN
82 #define BL_PWM 0 // (0 ~ 2)
83 #define PWM_EFFECT_VALUE 0
84 #define BL_EN_PIN RK30_PIN3_PC5
85 #define BL_EN_VALUE GPIO_HIGH
88 #define LCD_EN_PIN RK30_PIN3_PD2
89 #define LCD_EN_VALUE GPIO_LOW
90 #define LCD_CS_PIN INVALID_GPIO
91 #define LCD_CS_VALUE GPIO_LOW
94 #define GS_INT_PIN RK30_PIN3_PD1
97 //Reference to board-rk3028a-tb-sdmmc-config.c
100 //#define RK31XX_MAINBOARD_V1 //if mainboard is RK31XX_MAINBOARD_V1.0
101 #define PLAY_ON_PIN RK30_PIN0_PD1 //wakeup key
104 #define REG_PWM 1 // (0 ~ 2)
107 #define PMU_INT_PIN RK30_PIN3_PC6
108 #define PMU_SLEEP_PIN RK30_PIN3_PC4
111 #define ION_RESERVE_SIZE (80 * SZ_1M)
113 static int pwm_mode[] = {PWM0, PWM1, PWM2};
114 static inline int rk_gpio_request(int gpio, int direction, int value, const char *label)
117 unsigned long flags = 0;
119 if(!gpio_is_valid(gpio))
122 if(direction == GPIOF_DIR_IN)
124 else if(value == GPIO_LOW)
125 flags = GPIOF_OUT_INIT_LOW;
127 flags = GPIOF_OUT_INIT_HIGH;
129 ret = gpio_request_one(gpio, flags, label);
131 pr_err("Failed to request '%s'\n", label);
136 static struct spi_board_info board_spi_devices[] = {
139 /***********************************************************
141 ************************************************************/
142 #if defined(CONFIG_TOUCHSCREEN_GSLX680_RK3028)
143 //#define TOUCH_RESET_PIN RK30_PIN0_PC1
144 //#define TOUCH_EN_PIN NULL
145 //#define TOUCH_INT_PIN RK30_PIN0_PB4
147 int gslx680_init_platform_hw(void)
150 if(gpio_request(TOUCH_RST_PIN,NULL) != 0){
151 gpio_free(TOUCH_RST_PIN);
152 printk("gslx680_init_platform_hw gpio_request error\n");
155 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
156 gpio_free(TOUCH_INT_PIN);
157 printk("gslx680_init_platform_hw gpio_request error\n");
160 gpio_direction_output(TOUCH_RST_PIN, TOUCH_RST_VALUE);
162 gpio_set_value(TOUCH_RST_PIN,!TOUCH_RST_VALUE);
164 gpio_set_value(TOUCH_RST_PIN,TOUCH_RST_VALUE);
170 struct ts_hw_data gslx680_info = {
171 .reset_gpio = TOUCH_RST_PIN,
172 .touch_en_gpio = TOUCH_INT_PIN,
173 .init_platform_hw = gslx680_init_platform_hw,
178 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
179 static int goodix_init_platform_hw(void)
183 ret = rk_gpio_request(TOUCH_PWR_PIN, GPIOF_DIR_OUT, TOUCH_PWR_VALUE, "touch_pwr");
188 ret = rk_gpio_request(TOUCH_RST_PIN, GPIOF_DIR_OUT, TOUCH_RST_VALUE, "touch_rst");
196 struct goodix_platform_data goodix_info = {
198 .irq_pin = TOUCH_INT_PIN,
199 .rest_pin = TOUCH_RST_PIN,
200 .init_platform_hw = goodix_init_platform_hw,
204 /***********************************************************
206 ************************************************************/
207 #ifdef CONFIG_BACKLIGHT_RK29_BL
208 static int rk29_backlight_io_init(void)
212 iomux_set(pwm_mode[BL_PWM]);
214 #ifdef LCD_DISP_ON_PIN
215 ret = rk_gpio_request(BL_EN_PIN, GPIOF_DIR_OUT, BL_EN_VALUE, "bl_en");
222 static int rk29_backlight_io_deinit(void)
225 #ifdef LCD_DISP_ON_PIN
226 gpio_free(BL_EN_PIN);
228 pwm_gpio = iomux_mode_to_gpio(pwm_mode[BL_PWM]);
229 return rk_gpio_request(BL_EN_PIN, GPIOF_DIR_OUT, GPIO_LOW, "BL_PWM");
232 static int rk29_backlight_pwm_suspend(void)
234 int ret, pwm_gpio = iomux_mode_to_gpio(pwm_mode[BL_PWM]);
236 ret = rk_gpio_request(pwm_gpio, GPIOF_DIR_OUT, GPIO_LOW, "BL_PWM");
239 #ifdef LCD_DISP_ON_PIN
240 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
245 static int rk29_backlight_pwm_resume(void)
247 int pwm_gpio = iomux_mode_to_gpio(pwm_mode[BL_PWM]);
250 iomux_set(pwm_mode[BL_PWM]);
251 #ifdef LCD_DISP_ON_PIN
253 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
258 static struct rk29_bl_info rk29_bl_info = {
262 .brightness_mode = BRIGHTNESS_MODE_CONIC,
263 .bl_ref = PWM_EFFECT_VALUE,
264 .io_init = rk29_backlight_io_init,
265 .io_deinit = rk29_backlight_io_deinit,
266 .pwm_suspend = rk29_backlight_pwm_suspend,
267 .pwm_resume = rk29_backlight_pwm_resume,
270 static struct platform_device rk29_device_backlight = {
271 .name = "rk29_backlight",
274 .platform_data = &rk29_bl_info,
279 /***********************************************************
281 ************************************************************/
282 #ifdef CONFIG_FB_ROCKCHIP
283 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
287 ret = rk_gpio_request(LCD_CS_PIN, GPIOF_DIR_OUT, LCD_CS_VALUE, "lcd_cs");
291 return rk_gpio_request(LCD_EN_PIN, GPIOF_DIR_OUT, LCD_EN_VALUE, "lcd_en");
294 static int rk_fb_io_disable(void)
296 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
297 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
302 static int rk_fb_io_enable(void)
304 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
305 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
310 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
311 struct rk29fb_info lcdc0_screen_info = {
312 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC0) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
313 .prop = EXTEND, //extend display device
317 .set_screen_info = hdmi_init_lcdc,
319 .prop = PRMRY, //primary display device
320 .io_init = rk_fb_io_init,
321 .io_disable = rk_fb_io_disable,
322 .io_enable = rk_fb_io_enable,
323 .set_screen_info = set_lcd_info,
328 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
329 struct rk29fb_info lcdc1_screen_info = {
330 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC1) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
331 .prop = EXTEND, //extend display device
335 .set_screen_info = hdmi_init_lcdc,
337 .prop = PRMRY, //primary display device
338 .io_init = rk_fb_io_init,
339 .io_disable = rk_fb_io_disable,
340 .io_enable = rk_fb_io_enable,
341 .set_screen_info = set_lcd_info,
346 static struct resource resource_fb[] = {
350 .end = 0,//RK30_FB0_MEM_SIZE - 1,
351 .flags = IORESOURCE_MEM,
354 .name = "ipp buf", //for rotate
356 .end = 0,//RK30_FB0_MEM_SIZE - 1,
357 .flags = IORESOURCE_MEM,
362 .end = 0,//RK30_FB0_MEM_SIZE - 1,
363 .flags = IORESOURCE_MEM,
367 static struct platform_device device_fb = {
370 .num_resources = ARRAY_SIZE(resource_fb),
371 .resource = resource_fb,
375 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
376 static struct resource resource_lcdc0[] = {
379 .start = RK3026_LCDC0_PHYS,
380 .end = RK3026_LCDC0_PHYS + RK3026_LCDC0_SIZE - 1,
381 .flags = IORESOURCE_MEM,
388 .flags = IORESOURCE_IRQ,
392 static struct platform_device device_lcdc0 = {
395 .num_resources = ARRAY_SIZE(resource_lcdc0),
396 .resource = resource_lcdc0,
398 .platform_data = &lcdc0_screen_info,
403 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
404 static struct resource resource_lcdc1[] = {
407 .start = RK3026_LCDC1_PHYS,
408 .end = RK3026_LCDC1_PHYS + RK3026_LCDC1_SIZE - 1,
409 .flags = IORESOURCE_MEM,
415 .flags = IORESOURCE_IRQ,
419 static struct platform_device device_lcdc1 = {
422 .num_resources = ARRAY_SIZE(resource_lcdc1),
423 .resource = resource_lcdc1,
425 .platform_data = &lcdc1_screen_info,
430 static int rk_platform_add_display_devices(void)
432 struct platform_device *fb = NULL; //fb
433 struct platform_device *lcdc0 = NULL; //lcdc0
434 struct platform_device *lcdc1 = NULL; //lcdc1
435 struct platform_device *bl = NULL; //backlight
436 #ifdef CONFIG_FB_ROCKCHIP
440 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
441 lcdc0 = &device_lcdc0,
444 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
445 lcdc1 = &device_lcdc1,
448 #ifdef CONFIG_BACKLIGHT_RK29_BL
449 bl = &rk29_device_backlight,
451 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
457 /***********************************************************
459 ************************************************************/
461 #if defined (CONFIG_GS_MMA8452)
462 #define MMA8452_INT_PIN GS_INT_PIN
463 static int mma8452_init_platform_hw(void)
468 static struct sensor_platform_data mma8452_info = {
469 .type = SENSOR_TYPE_ACCEL,
472 .init_platform_hw = mma8452_init_platform_hw,
473 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
478 #if defined (CONFIG_GS_LSM303D)
479 #define LSM303D_INT_PIN GS_INT_PIN
480 static int lms303d_init_platform_hw(void)
485 static struct sensor_platform_data lms303d_info = {
486 .type = SENSOR_TYPE_ACCEL,
489 .init_platform_hw = lms303d_init_platform_hw,
490 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
496 #if defined (CONFIG_GS_MMA7660)
497 #define MMA7660_INT_PIN GS_INT_PIN
499 static int mma7660_init_platform_hw(void)
501 //rk30_mux_api_set(GPIO1B2_SPI_RXD_UART1_SIN_NAME, GPIO1B_GPIO1B2);
506 static struct sensor_platform_data mma7660_info = {
507 .type = SENSOR_TYPE_ACCEL,
510 .init_platform_hw = mma7660_init_platform_hw,
511 #ifndef CONFIG_MFD_RK616
512 #ifdef CONFIG_TOUCHSCREEN_GSLX680_RK3168
513 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
515 .orientation = {0, -1, 0, -1, 0, 0, 0, 0, -1},
518 .orientation = {1, 0, 0, 0, -1, 0, 0, 0, -1},
524 #if defined (CONFIG_GS_MXC6225)
525 #define MXC6225_INT_PIN GS_INT_PIN
527 static int mxc6225_init_platform_hw(void)
532 static struct sensor_platform_data mxc6225_info = {
533 .type = SENSOR_TYPE_ACCEL,
536 .init_platform_hw = mxc6225_init_platform_hw,
537 .orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 0},
540 #if defined (CONFIG_GS_LIS3DH)
541 #define LIS3DH_INT_PIN GS_INT_PIN
543 static int lis3dh_init_platform_hw(void)
549 static struct sensor_platform_data lis3dh_info = {
550 .type = SENSOR_TYPE_ACCEL,
553 .init_platform_hw = lis3dh_init_platform_hw,
554 .orientation = {1, 0, 0, 0, 1, 0, 0, 0, 1},
558 #if defined (CONFIG_COMPASS_AK8975)
559 static struct sensor_platform_data akm8975_info =
561 .type = SENSOR_TYPE_COMPASS,
594 #if defined (CONFIG_COMPASS_AK8963)
595 static struct sensor_platform_data akm8963_info =
597 .type = SENSOR_TYPE_COMPASS,
631 #if defined(CONFIG_GYRO_L3G4200D)
633 #include <linux/l3g4200d.h>
634 #define L3G4200D_INT_PIN RK30_PIN0_PB4
636 static int l3g4200d_init_platform_hw(void)
641 static struct sensor_platform_data l3g4200d_info = {
642 .type = SENSOR_TYPE_GYROSCOPE,
645 .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
646 .init_platform_hw = l3g4200d_init_platform_hw,
647 .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
654 #ifdef CONFIG_LS_CM3217
655 static struct sensor_platform_data cm3217_info = {
656 .type = SENSOR_TYPE_LIGHT,
658 .poll_delay_ms = 500,
663 /***********************************************************
665 ************************************************************/
666 #include <plat/key.h>
668 static struct rk29_keys_button key_button[] = {
673 .active_low = PRESS_LEV_LOW,
676 /* disable adc keyboard,
677 * because rk280a adc reference voltage is 3.3V, but
678 * rk30xx mainbord key's supply voltage is 2.5V and
679 * rk31xx mainbord key's supply voltage is 1.8V.
684 .code = KEY_VOLUMEUP,
685 .gpio = INVALID_GPIO,
687 .active_low = PRESS_LEV_LOW,
691 .code = KEY_VOLUMEDOWN,
692 .gpio = INVALID_GPIO,
694 .active_low = PRESS_LEV_LOW,
700 .gpio = INVALID_GPIO,
701 .active_low = PRESS_LEV_LOW,
706 .gpio = INVALID_GPIO,
707 .active_low = PRESS_LEV_LOW,
713 .gpio = INVALID_GPIO,
714 .active_low = PRESS_LEV_LOW,
720 .gpio = INVALID_GPIO,
721 .active_low = PRESS_LEV_LOW,
726 struct rk29_keys_platform_data rk29_keys_pdata = {
727 .buttons = key_button,
728 .nbuttons = ARRAY_SIZE(key_button),
729 .chn = 3, //chn: 0-7, if do not use ADC,set 'chn' -1
732 /***********************************************************
734 ************************************************************/
735 #ifdef CONFIG_SDMMC_RK29
736 #include "board-rk3028a-86v-sdmmc-config.c"
737 #include "../plat-rk/rk-sdmmc-ops.c"
738 #include "../plat-rk/rk-sdmmc-wifi.c"
739 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
741 #ifdef CONFIG_SDMMC0_RK29
742 #define CONFIG_SDMMC0_USE_DMA
743 static int rk29_sdmmc0_cfg_gpio(void)
745 rk29_sdmmc_set_iomux(0, 0xFFFF);
746 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
747 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
749 iomux_set(MMC0_DETN);
752 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
753 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
754 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
759 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
761 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
762 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
763 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
765 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
766 .io_init = rk29_sdmmc0_cfg_gpio,
768 .set_iomux = rk29_sdmmc_set_iomux,
770 .dma_name = "sd_mmc",
771 #ifdef CONFIG_SDMMC0_USE_DMA
777 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
778 .status = rk29sdk_wifi_mmc0_status,
779 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
782 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
783 .power_en = RK29SDK_SD_CARD_PWR_EN,
784 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
786 .power_en = INVALID_GPIO,
787 .power_en_level = GPIO_LOW,
789 .enable_sd_wakeup = 0,
791 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
792 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
793 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
795 .write_prt = INVALID_GPIO,
799 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
800 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
801 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
809 #endif // CONFIG_SDMMC0_RK29
811 #ifdef CONFIG_SDMMC1_RK29
812 #define CONFIG_SDMMC1_USE_DMA
813 static int rk29_sdmmc1_cfg_gpio(void)
815 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
816 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
817 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
822 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
824 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
825 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
828 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
829 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
830 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
833 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
836 .io_init = rk29_sdmmc1_cfg_gpio,
838 .set_iomux = rk29_sdmmc_set_iomux,
841 #ifdef CONFIG_SDMMC1_USE_DMA
847 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
848 .status = rk29sdk_wifi_status,
849 .register_status_notify = rk29sdk_wifi_status_register,
852 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
853 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
854 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
856 .write_prt = INVALID_GPIO,
859 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
860 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
864 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
865 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
866 .io = RK29SDK_SD_CARD_DETECT_N,
871 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
877 .enable_sd_wakeup = 0,
879 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
881 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
882 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
883 .dc_det_pin = RK30_PIN1_PB4,
884 .batt_low_pin = INVALID_GPIO,
885 .charge_set_pin = INVALID_GPIO,
886 .charge_ok_pin = RK30_PIN1_PA0,
887 .usb_det_pin = INVALID_GPIO,
888 .dc_det_level = GPIO_LOW,
889 .charge_ok_level = GPIO_HIGH,
891 .reference_voltage = 3300, // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
892 .pull_up_res = 200, //divider resistance , pull-up resistor
893 .pull_down_res = 120, //divider resistance , pull-down resistor
895 .is_reboot_charging = 1,
897 .low_voltage_protection = 3600,
900 static struct platform_device rk30_device_adc_battery = {
901 .name = "rk30-battery",
904 .platform_data = &rk30_adc_battery_platdata,
910 /***********************************************************
912 ************************************************************/
913 #ifdef CONFIG_RFKILL_RK
914 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
915 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
916 .type = RFKILL_TYPE_BLUETOOTH,
918 .poweron_gpio = { // BT_REG_ON
919 .io = INVALID_GPIO, //RK30_PIN3_PC7,
922 .name = "bt_poweron",
927 .reset_gpio = { // BT_RST
928 .io = RK30_PIN1_PB3, // set io to INVALID_GPIO for disable it
936 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
937 .io = RK30_PIN1_PB2, // set io to INVALID_GPIO for disable it
945 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
947 .io = RK30_PIN0_PA4, // set io to INVALID_GPIO for disable it
948 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
950 .name = "bt_wake_host",
956 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
957 .io = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
967 static struct platform_device device_rfkill_rk = {
971 .platform_data = &rfkill_rk_platdata,
976 /***********************************************************
978 ************************************************************/
980 static struct ion_platform_data rk30_ion_pdata = {
984 .type = ION_HEAP_TYPE_CARVEOUT,
985 .id = ION_NOR_HEAP_ID,
987 .size = ION_RESERVE_SIZE,
992 static struct platform_device device_ion = {
993 .name = "ion-rockchip",
996 .platform_data = &rk30_ion_pdata,
1001 /***********************************************************
1003 ************************************************************/
1004 #ifdef CONFIG_RK30_PWM_REGULATOR
1005 static int pwm_voltage_map[] = {
1006 800000, 825000, 850000, 875000, 900000, 925000 ,
1007 950000, 975000, 1000000, 1025000, 1050000, 1075000,
1008 1100000, 1125000, 1150000, 1175000, 1200000, 1225000,
1009 1250000, 1275000, 1300000, 1325000, 1350000, 1375000
1012 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1014 .supply = "vdd_core",
1018 struct regulator_init_data pwm_regulator_init_dcdc[1] = {
1021 .name = "PWM_DCDC1",
1023 .max_uV = 1800000, //0.6-1.8V
1025 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1027 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1028 .consumer_supplies = pwm_dcdc1_consumers,
1032 static struct pwm_platform_data pwm_regulator_info[1] = {
1035 .pwm_voltage = 1200000,
1036 .suspend_voltage = 1050000,
1039 .coefficient = 504, //50.4%
1040 .pwm_voltage_map = pwm_voltage_map,
1041 .init_data = &pwm_regulator_init_dcdc[0],
1044 struct platform_device pwm_regulator_device[1] = {
1046 .name = "pwm-voltage-regulator",
1049 .platform_data = &pwm_regulator_info[0],
1054 static void pwm_regulator_init(void)
1056 pwm_regulator_info[0].pwm_gpio = iomux_mode_to_gpio(pwm_mode[REG_PWM]);
1057 pwm_regulator_info[0].pwm_iomux_pwm = pwm_mode[REG_PWM];
1058 pwm_regulator_info[0].pwm_iomux_gpio = iomux_switch_gpio_mode(pwm_mode[REG_PWM]);
1062 int __sramdata pwm_iomux, pwm_do, pwm_dir, pwm_en;
1063 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
1064 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1066 #define GPIO0_D2_OFFSET 10
1067 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1069 #ifdef CONFIG_RK30_PWM_REGULATOR
1071 /* pwm0: GPIO0_D2, pwm1: GPIO0_D3, pwm2: GPIO0_D4 */
1072 int off = GPIO0_D2_OFFSET + REG_PWM;
1075 pwm_iomux = grf_readl(GRF_GPIO0D_IOMUX);
1076 pwm_dir = grf_readl(GRF_GPIO0H_DIR);
1077 pwm_do = grf_readl(GRF_GPIO0H_DO);
1078 pwm__en = grf_readl(GRF_GPIO0H_EN);
1080 grf_writel((1<<(2 * off), GRF_GPIO0D_IOMUX);
1081 grf_writel((1<<(16 + off))|(1<<off), GRF_GPIO0H_DIR);
1082 grf_writel((1<<(16 + off))|(1<<off), GRF_GPIO0H_DO);
1087 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1089 #ifdef CONFIG_RK30_PWM_REGULATOR
1091 /* pwm0: GPIO0_D2, pwm1: GPIO0_D3, pwm2: GPIO0_D4 */
1092 int off = GPIO0_D2_OFFSET + REG_PWM;
1094 grf_writel((1<<(2 * off))|pwm_iomux, GRF_GPIO0D_IOMUX);
1095 grf_writel(((1<<(16 + off))|pwm_dir), GRF_GPIO0L_DIR);
1096 grf_writel(((1<<(16 + off))|pwm_do), GRF_GPIO0L_DO);
1097 grf_writel(((1<<(16 + off))|pwm_en), GRF_GPIO0L_EN);
1102 extern void pwm_suspend_voltage(void);
1103 extern void pwm_resume_voltage(void);
1105 void rk30_pwm_suspend_voltage_set(void)
1107 #ifdef CONFIG_RK30_PWM_REGULATOR
1108 pwm_suspend_voltage();
1112 void rk30_pwm_resume_voltage_set(void)
1114 #ifdef CONFIG_RK30_PWM_REGULATOR
1115 pwm_resume_voltage();
1119 /***********************************************************
1121 ************************************************************/
1122 int __sramdata g_pmic_type = 0;
1124 #ifdef CONFIG_MFD_TPS65910
1125 #define TPS65910_HOST_IRQ PMU_INT_PIN
1126 #define PMU_POWER_SLEEP PMU_SLEEP_PIN
1127 static struct pmu_info tps65910_dcdc_info[] = {
1129 .name = "vdd_core", //logic
1134 .name = "vdd_cpu", //arm
1139 .name = "vio", //vcc_io
1145 static struct pmu_info tps65910_ldo_info[] = {
1147 .name = "vpll", //vdd10
1152 .name = "vdig1", //vcc18_cif
1153 .min_uv = 2800000,//1800000,
1154 .max_uv = 2800000,//1800000,
1157 .name = "vdig2", //vdd11
1162 .name = "vaux1", //vcc28_cif
1167 .name = "vaux2", //vcc33
1172 .name = "vaux33", //vcc_tp
1177 .name = "vmmc", //vcca30
1187 #include "../mach-rk30/board-pmu-tps65910.c"
1190 void __sramfunc board_pmu_suspend(void)
1192 #if defined (CONFIG_MFD_TPS65910)
1193 if(pmic_is_tps65910())
1194 board_pmu_tps65910_suspend();
1198 void __sramfunc board_pmu_resume(void)
1200 #if defined (CONFIG_MFD_TPS65910)
1201 if(pmic_is_tps65910())
1202 board_pmu_tps65910_resume();
1206 #ifdef CONFIG_SND_SOC_RK3026
1207 struct rk3026_codec_pdata rk3026_codec_pdata_info={
1208 .spk_ctl_gpio = RK2928_PIN3_PD4,
1209 .hp_ctl_gpio = RK2928_PIN3_PD4,
1212 static struct resource resources_acodec[] = {
1214 .start = RK2928_ACODEC_PHYS,
1215 .end = RK2928_ACODEC_PHYS + RK2928_ACODEC_SIZE - 1,
1216 .flags = IORESOURCE_MEM,
1220 static struct platform_device rk3026_codec = {
1221 .name = "rk3026-codec",
1223 .resource = resources_acodec,
1225 .platform_data = &rk3026_codec_pdata_info,
1229 #if defined(CONFIG_GPS_RK)
1230 #define GPS_OSCEN_PIN RK2928_PIN1_PB0
1231 #define GPS_RXEN_PIN RK2928_PIN1_PB0
1233 static int rk_gps_io_init(void)
1235 printk("%s \n", __FUNCTION__);
1237 gpio_request(GPS_OSCEN_PIN, NULL);
1238 gpio_direction_output(GPS_OSCEN_PIN, GPIO_LOW);
1240 iomux_set(GPS_CLK);//GPS_CLK
1241 iomux_set(GPS_MAG);//GPS_MAG
1242 iomux_set(GPS_SIGN);//GPS_SIGN
1244 gpio_request(RK30_PIN1_PA6, NULL);
1245 gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1247 gpio_request(RK30_PIN1_PA5, NULL);
1248 gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW);
1250 gpio_request(RK30_PIN1_PA7, NULL);
1251 gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);
1255 static int rk_gps_power_up(void)
1257 printk("%s \n", __FUNCTION__);
1262 static int rk_gps_power_down(void)
1264 printk("%s \n", __FUNCTION__);
1269 static int rk_gps_reset_set(int level)
1273 static int rk_enable_hclk_gps(void)
1275 struct clk *gps_aclk = NULL;
1276 gps_aclk = clk_get(NULL, "aclk_gps");
1278 clk_enable(gps_aclk);
1280 printk("%s \n", __FUNCTION__);
1283 printk("get gps aclk fail\n");
1286 static int rk_disable_hclk_gps(void)
1288 struct clk *gps_aclk = NULL;
1289 gps_aclk = clk_get(NULL, "aclk_gps");
1291 //TO wait long enough until GPS ISR is finished.
1293 clk_disable(gps_aclk);
1295 printk("%s \n", __FUNCTION__);
1298 printk("get gps aclk fail\n");
1301 static struct rk_gps_data rk_gps_info = {
1302 .io_init = rk_gps_io_init,
1303 .power_up = rk_gps_power_up,
1304 .power_down = rk_gps_power_down,
1305 .reset = rk_gps_reset_set,
1306 .enable_hclk_gps = rk_enable_hclk_gps,
1307 .disable_hclk_gps = rk_disable_hclk_gps,
1308 .GpsSign = RK2928_PIN1_PA5,
1309 .GpsMag = RK2928_PIN1_PA4, //GPIO index
1310 .GpsClk = RK2928_PIN1_PA2, //GPIO index
1311 .GpsVCCEn = GPS_OSCEN_PIN, //GPIO index
1313 .GpsSpi_CSO = RK30_PIN1_PA4, //GPIO index
1314 .GpsSpiClk = RK30_PIN1_PA5, //GPIO index
1315 .GpsSpiMOSI = RK30_PIN1_PA7, //GPIO index
1320 .u32GpsPhyAddr = RK2928_GPS_PHYS,
1321 .u32GpsPhySize = RK2928_GPS_SIZE,
1324 static struct platform_device rk_device_gps = {
1325 .name = "gps_hv5820b",
1328 .platform_data = &rk_gps_info,
1334 /***********************************************************
1336 ************************************************************/
1337 #ifdef CONFIG_I2C0_RK30
1338 static struct i2c_board_info __initdata i2c0_info[] = {
1339 #if defined (CONFIG_MFD_TPS65910)
1342 .addr = TPS65910_I2C_ID0,
1344 .irq = TPS65910_HOST_IRQ,
1345 .platform_data = &tps65910_data,
1352 #ifdef CONFIG_I2C1_RK30
1353 static struct i2c_board_info __initdata i2c1_info[] = {
1354 #if defined (CONFIG_GS_MXC6225)
1356 .type = "gs_mxc6225",
1359 .irq = MXC6225_INT_PIN,
1360 .platform_data = &mxc6225_info,
1363 #if defined (CONFIG_GS_MMA7660)
1365 .type = "gs_mma7660",//gs_mma7660
1368 .irq = MMA7660_INT_PIN,
1369 .platform_data = &mma7660_info,
1372 #if defined (CONFIG_GS_MMA8452)
1374 .type = "gs_mma8452",
1377 .irq = MMA8452_INT_PIN,
1378 .platform_data = &mma8452_info,
1381 #if defined (CONFIG_GS_LIS3DH)
1383 .type = "gs_lis3dh",
1384 .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1386 .irq = LIS3DH_INT_PIN,
1387 .platform_data = &lis3dh_info,
1390 #if defined (CONFIG_GS_LSM303D)
1392 .type = "gs_lsm303d",
1393 .addr = 0x1d, //0x19(SA0-->VCC), 0x18(SA0-->GND)
1395 .irq = LSM303D_INT_PIN,
1396 .platform_data = &lms303d_info,
1399 #if defined (CONFIG_COMPASS_AK8975)
1404 .irq = RK30_PIN3_PD7,
1405 .platform_data = &akm8975_info,
1406 .irq = RK30_PIN3_PD7,
1407 .platform_data = &akm8975_info,
1410 #if defined (CONFIG_COMPASS_AK8963)
1415 .irq = RK30_PIN3_PD7,
1416 .platform_data = &akm8963_info,
1419 #if defined (CONFIG_GYRO_L3G4200D)
1421 .type = "l3g4200d_gryo",
1424 .irq = L3G4200D_INT_PIN,
1425 .platform_data = &l3g4200d_info,
1432 #ifdef CONFIG_I2C2_RK30
1433 static struct i2c_board_info __initdata i2c2_info[] = {
1434 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1436 .type = "Goodix-TS",
1439 .irq = TOUCH_INT_PIN,
1440 .platform_data = &goodix_info,
1443 #if defined (CONFIG_TOUCHSCREEN_GSLX680_RK3028)
1448 .platform_data =&gslx680_info,
1455 #ifdef CONFIG_I2C3_RK30
1456 static struct i2c_board_info __initdata i2c3_info[] = {
1460 #ifdef CONFIG_I2C_GPIO_RK30
1461 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1462 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1463 static int rk30_i2c_io_init(void)
1468 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1469 .sda_pin = I2C_SDA_PIN,
1470 .scl_pin = I2C_SCL_PIN,
1471 .udelay = 5, // clk = 500/udelay = 100Khz
1472 .timeout = 100,//msecs_to_jiffies(100),
1474 .io_init = rk30_i2c_io_init,
1477 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1481 static void __init rk30_i2c_register_board_info(void)
1483 #ifdef CONFIG_I2C0_RK30
1484 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1486 #ifdef CONFIG_I2C1_RK30
1487 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1489 #ifdef CONFIG_I2C2_RK30
1490 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1492 #ifdef CONFIG_I2C3_RK30
1493 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1495 #ifdef CONFIG_I2C_GPIO_RK30
1496 i2c_register_board_info(4, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1500 /***********************************************************
1502 ************************************************************/
1503 static struct platform_device *devices[] __initdata = {
1507 #ifdef CONFIG_WIFI_CONTROL_FUNC
1508 &rk29sdk_wifi_device,
1510 #ifdef CONFIG_RFKILL_RK
1513 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1514 &rk30_device_adc_battery,
1516 #ifdef CONFIG_SND_SOC_RK3026
1519 #ifdef CONFIG_GPS_RK
1524 static void rk30_pm_power_off(void)
1526 #if defined(CONFIG_MFD_TPS65910)
1527 tps65910_device_shutdown();//tps65910 shutdown
1529 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1533 static void __init machine_rk30_board_init(void)
1535 #ifdef CONFIG_RK30_PWM_REGULATOR
1536 pwm_regulator_init();
1539 pm_power_off = rk30_pm_power_off;
1540 rk_gpio_request(POWER_ON_PIN, GPIOF_DIR_OUT, GPIO_HIGH, "system power on");
1541 rk30_i2c_register_board_info();
1542 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1543 platform_add_devices(devices, ARRAY_SIZE(devices));
1544 rk_platform_add_display_devices();
1545 #if defined(CONFIG_WIFI_CONTROL_FUNC)
1546 rk29sdk_wifi_bt_gpio_control_init();
1547 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1548 rk29sdk_wifi_combo_module_gpio_init();
1552 static void __init rk30_reserve(void)
1555 #ifdef CONFIG_FB_ROCKCHIP
1556 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
1557 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
1559 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1560 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1563 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
1564 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
1565 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
1570 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1573 #ifdef CONFIG_VIDEO_RK29
1574 rk30_camera_request_reserve_mem();
1576 #ifdef CONFIG_GPS_RK
1577 //it must be more than 8MB
1578 rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
1580 board_mem_reserved();
1583 /***********************************************************
1585 ************************************************************/
1586 static struct cpufreq_frequency_table dvfs_arm_table[] = {
1587 {.frequency = 312 * 1000, .index = 1100 * 1000},
1588 {.frequency = 504 * 1000, .index = 1100 * 1000},
1589 {.frequency = 816 * 1000, .index = 1150 * 1000},
1590 {.frequency = 1008 * 1000, .index = 1200 * 1000},
1591 //{.frequency = 1200 * 1000, .index = 1300 * 1000},
1592 //{.frequency = 1416 * 1000, .index = 1200 * 1000},
1593 //{.frequency = 1608 * 1000, .index = 1200 * 1000},
1594 {.frequency = CPUFREQ_TABLE_END},
1597 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1598 //{.frequency = 100 * 1000, .index = 1200 * 1000},
1599 {.frequency = 200 * 1000, .index = 1200 * 1000},
1600 //{.frequency = 266 * 1000, .index = 1200 * 1000},
1601 //{.frequency = 300 * 1000, .index = 1200 * 1000},
1602 //{.frequency = 400 * 1000, .index = 1200 * 1000},
1603 {.frequency = CPUFREQ_TABLE_END},
1606 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1607 //{.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1200 * 1000},
1608 //{.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1200 * 1000},
1609 {.frequency = 360 * 1000 + DDR_FREQ_NORMAL, .index = 1200 * 1000},
1610 {.frequency = CPUFREQ_TABLE_END},
1613 void __init board_clock_init(void)
1615 rk2928_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1616 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1617 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
1618 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1619 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1622 /************************ end *****************************/
1623 MACHINE_START(RK30, "RK30board")
1624 .boot_params = PLAT_PHYS_OFFSET + 0x800,
1625 .fixup = rk2928_fixup,
1626 .reserve = &rk30_reserve,
1627 .map_io = rk2928_map_io,
1628 .init_irq = rk2928_init_irq,
1629 .timer = &rk2928_timer,
1630 .init_machine = machine_rk30_board_init,