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_RK3028
55 #include "../../../sound/soc/codecs/rk3028_codec.h"
58 #if defined(CONFIG_RK_HDMI)
59 #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
62 #include "board-rk3026-tb-camera.c"
64 /***********************************************************
66 ************************************************************/
68 #define POWER_ON_PIN RK30_PIN1_PA1 //PWR_HOLD
71 #define TOUCH_RST_PIN RK30_PIN3_PC3
72 #define TOUCH_RST_VALUE GPIO_HIGH
73 #define TOUCH_PWR_PIN RK30_PIN2_PD0
74 #define TOUCH_PWR_VALUE GPIO_LOW
75 #define TOUCH_INT_PIN RK30_PIN3_PC7
78 #define LCD_DISP_ON_PIN
79 #define BL_PWM 0 // (0 ~ 2)
80 #define PWM_EFFECT_VALUE 1
81 #define BL_EN_PIN RK30_PIN3_PC5
82 #define BL_EN_VALUE GPIO_HIGH
85 #define LCD_EN_PIN RK30_PIN3_PD2
86 #define LCD_EN_VALUE GPIO_HIGH
87 #define LCD_CS_PIN INVALID_GPIO
88 #define LCD_CS_VALUE GPIO_HIGH
91 #define GS_INT_PIN RK30_PIN3_PD1
94 //Reference to board-rk3028a-tb-sdmmc-config.c
97 //#define RK31XX_MAINBOARD_V1 //if mainboard is RK31XX_MAINBOARD_V1.0
98 #define PLAY_ON_PIN RK30_PIN0_PD1 //wakeup key
101 #define REG_PWM 1 // (0 ~ 2)
104 #define PMU_INT_PIN RK30_PIN3_PC6
105 #define PMU_SLEEP_PIN RK30_PIN0_PD0
108 #define ION_RESERVE_SIZE (80 * SZ_1M)
110 static int pwm_mode[] = {PWM0, PWM1, PWM2};
111 static inline int rk_gpio_request(int gpio, int direction, int value, const char *label)
114 unsigned long flags = 0;
116 if(!gpio_is_valid(gpio))
119 if(direction == GPIOF_DIR_IN)
121 else if(value == GPIO_LOW)
122 flags = GPIOF_OUT_INIT_LOW;
124 flags = GPIOF_OUT_INIT_HIGH;
126 ret = gpio_request_one(gpio, flags, label);
128 pr_err("Failed to request '%s'\n", label);
133 static struct spi_board_info board_spi_devices[] = {
136 /***********************************************************
138 ************************************************************/
139 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
140 static int goodix_init_platform_hw(void)
144 ret = rk_gpio_request(TOUCH_PWR_PIN, GPIOF_DIR_OUT, TOUCH_PWR_VALUE, "touch_pwr");
149 ret = rk_gpio_request(TOUCH_RST_PIN, GPIOF_DIR_OUT, TOUCH_RST_VALUE, "touch_rst");
157 struct goodix_platform_data goodix_info = {
159 .irq_pin = TOUCH_INT_PIN,
160 .rest_pin = TOUCH_RST_PIN,
161 .init_platform_hw = goodix_init_platform_hw,
165 /***********************************************************
167 ************************************************************/
168 #ifdef CONFIG_BACKLIGHT_RK29_BL
169 static int rk29_backlight_io_init(void)
173 iomux_set(pwm_mode[BL_PWM]);
174 #ifdef LCD_DISP_ON_PIN
175 ret = rk_gpio_request(BL_EN_PIN, GPIOF_DIR_OUT, BL_EN_VALUE, "bl_en");
182 static int rk29_backlight_io_deinit(void)
185 #ifdef LCD_DISP_ON_PIN
186 gpio_free(BL_EN_PIN);
188 pwm_gpio = iomux_mode_to_gpio(pwm_mode[BL_PWM]);
189 return rk_gpio_request(BL_EN_PIN, GPIOF_DIR_OUT, GPIO_LOW, "BL_PWM");
192 static int rk29_backlight_pwm_suspend(void)
194 int ret, pwm_gpio = iomux_mode_to_gpio(pwm_mode[BL_PWM]);
196 ret = rk_gpio_request(pwm_gpio, GPIOF_DIR_OUT, GPIO_LOW, "BL_PWM");
199 #ifdef LCD_DISP_ON_PIN
200 gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
205 static int rk29_backlight_pwm_resume(void)
207 int pwm_gpio = iomux_mode_to_gpio(pwm_mode[BL_PWM]);
210 iomux_set(pwm_mode[BL_PWM]);
211 #ifdef LCD_DISP_ON_PIN
213 gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
218 static struct rk29_bl_info rk29_bl_info = {
222 .brightness_mode = BRIGHTNESS_MODE_CONIC,
223 .bl_ref = PWM_EFFECT_VALUE,
224 .io_init = rk29_backlight_io_init,
225 .io_deinit = rk29_backlight_io_deinit,
226 .pwm_suspend = rk29_backlight_pwm_suspend,
227 .pwm_resume = rk29_backlight_pwm_resume,
230 static struct platform_device rk29_device_backlight = {
231 .name = "rk29_backlight",
234 .platform_data = &rk29_bl_info,
239 /***********************************************************
241 ************************************************************/
242 #ifdef CONFIG_FB_ROCKCHIP
243 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
247 ret = rk_gpio_request(LCD_CS_PIN, GPIOF_DIR_OUT, LCD_CS_VALUE, "lcd_cs");
251 return rk_gpio_request(LCD_EN_PIN, GPIOF_DIR_OUT, LCD_EN_VALUE, "lcd_en");
254 static int rk_fb_io_disable(void)
256 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
257 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
262 static int rk_fb_io_enable(void)
264 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
265 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
270 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
271 struct rk29fb_info lcdc0_screen_info = {
272 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC0) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
273 .prop = EXTEND, //extend display device
277 .set_screen_info = hdmi_init_lcdc,
279 .prop = PRMRY, //primary display device
280 .io_init = rk_fb_io_init,
281 .io_disable = rk_fb_io_disable,
282 .io_enable = rk_fb_io_enable,
283 .set_screen_info = set_lcd_info,
288 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
289 struct rk29fb_info lcdc1_screen_info = {
290 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC1) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
291 .prop = EXTEND, //extend display device
295 .set_screen_info = hdmi_init_lcdc,
297 .prop = PRMRY, //primary display device
298 .io_init = rk_fb_io_init,
299 .io_disable = rk_fb_io_disable,
300 .io_enable = rk_fb_io_enable,
301 .set_screen_info = set_lcd_info,
306 static struct resource resource_fb[] = {
310 .end = 0,//RK30_FB0_MEM_SIZE - 1,
311 .flags = IORESOURCE_MEM,
314 .name = "ipp buf", //for rotate
316 .end = 0,//RK30_FB0_MEM_SIZE - 1,
317 .flags = IORESOURCE_MEM,
322 .end = 0,//RK30_FB0_MEM_SIZE - 1,
323 .flags = IORESOURCE_MEM,
327 static struct platform_device device_fb = {
330 .num_resources = ARRAY_SIZE(resource_fb),
331 .resource = resource_fb,
335 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
336 static struct resource resource_lcdc0[] = {
339 .start = RK3026_LCDC0_PHYS,
340 .end = RK3026_LCDC0_PHYS + RK3026_LCDC0_SIZE - 1,
341 .flags = IORESOURCE_MEM,
348 .flags = IORESOURCE_IRQ,
352 static struct platform_device device_lcdc0 = {
355 .num_resources = ARRAY_SIZE(resource_lcdc0),
356 .resource = resource_lcdc0,
358 .platform_data = &lcdc0_screen_info,
363 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
364 static struct resource resource_lcdc1[] = {
367 .start = RK3026_LCDC1_PHYS,
368 .end = RK3026_LCDC1_PHYS + RK3026_LCDC1_SIZE - 1,
369 .flags = IORESOURCE_MEM,
375 .flags = IORESOURCE_IRQ,
379 static struct platform_device device_lcdc1 = {
382 .num_resources = ARRAY_SIZE(resource_lcdc1),
383 .resource = resource_lcdc1,
385 .platform_data = &lcdc1_screen_info,
390 static int rk_platform_add_display_devices(void)
392 struct platform_device *fb = NULL; //fb
393 struct platform_device *lcdc0 = NULL; //lcdc0
394 struct platform_device *lcdc1 = NULL; //lcdc1
395 struct platform_device *bl = NULL; //backlight
396 #ifdef CONFIG_FB_ROCKCHIP
400 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
401 lcdc0 = &device_lcdc0,
404 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
405 lcdc1 = &device_lcdc1,
408 #ifdef CONFIG_BACKLIGHT_RK29_BL
409 bl = &rk29_device_backlight,
411 __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
417 /***********************************************************
419 ************************************************************/
420 #if defined (CONFIG_GS_MMA8452)
421 static int mma8452_init_platform_hw(void)
426 static struct sensor_platform_data mma8452_info = {
427 .type = SENSOR_TYPE_ACCEL,
430 .init_platform_hw = mma8452_init_platform_hw,
431 .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
435 /***********************************************************
437 ************************************************************/
438 #include <plat/key.h>
440 static struct rk29_keys_button key_button[] = {
445 .active_low = PRESS_LEV_LOW,
448 /* disable adc keyboard,
449 * because rk280a adc reference voltage is 3.3V, but
450 * rk30xx mainbord key's supply voltage is 2.5V and
451 * rk31xx mainbord key's supply voltage is 1.8V.
454 #ifdef RK31XX_MAINBOARD_V1
457 .code = KEY_VOLUMEDOWN,
459 .gpio = INVALID_GPIO,
460 .active_low = PRESS_LEV_LOW,
466 .active_low = PRESS_LEV_LOW,
471 .code = KEY_VOLUMEUP,
473 .gpio = INVALID_GPIO,
474 .active_low = PRESS_LEV_LOW,
480 .gpio = INVALID_GPIO,
481 .active_low = PRESS_LEV_LOW,
487 .gpio = INVALID_GPIO,
488 .active_low = PRESS_LEV_LOW,
494 .gpio = INVALID_GPIO,
495 .active_low = PRESS_LEV_LOW,
500 .code = KEY_VOLUMEDOWN,
502 .gpio = INVALID_GPIO,
503 .active_low = PRESS_LEV_LOW,
509 .active_low = PRESS_LEV_LOW,
514 .code = KEY_VOLUMEUP,
516 .gpio = INVALID_GPIO,
517 .active_low = PRESS_LEV_LOW,
523 .gpio = INVALID_GPIO,
524 .active_low = PRESS_LEV_LOW,
530 .gpio = INVALID_GPIO,
531 .active_low = PRESS_LEV_LOW,
537 .gpio = INVALID_GPIO,
538 .active_low = PRESS_LEV_LOW,
544 .gpio = INVALID_GPIO,
545 .active_low = PRESS_LEV_LOW,
551 struct rk29_keys_platform_data rk29_keys_pdata = {
552 .buttons = key_button,
553 .nbuttons = ARRAY_SIZE(key_button),
554 .chn = 1, //chn: 0-7, if do not use ADC,set 'chn' -1
557 /***********************************************************
559 ************************************************************/
560 #ifdef CONFIG_SDMMC_RK29
561 #include "board-rk3028a-tb-sdmmc-config.c"
562 #include "../plat-rk/rk-sdmmc-ops.c"
563 #include "../plat-rk/rk-sdmmc-wifi.c"
564 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
566 #ifdef CONFIG_SDMMC0_RK29
567 #define CONFIG_SDMMC0_USE_DMA
568 static int rk29_sdmmc0_cfg_gpio(void)
570 rk29_sdmmc_set_iomux(0, 0xFFFF);
571 #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
572 iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
574 iomux_set(MMC0_DETN);
577 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
578 gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
579 gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
584 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
586 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
587 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
588 MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
590 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
591 .io_init = rk29_sdmmc0_cfg_gpio,
593 .set_iomux = rk29_sdmmc_set_iomux,
595 .dma_name = "sd_mmc",
596 #ifdef CONFIG_SDMMC0_USE_DMA
602 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
603 .status = rk29sdk_wifi_mmc0_status,
604 .register_status_notify = rk29sdk_wifi_mmc0_status_register,
607 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
608 .power_en = RK29SDK_SD_CARD_PWR_EN,
609 .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
611 .power_en = INVALID_GPIO,
612 .power_en_level = GPIO_LOW,
614 .enable_sd_wakeup = 0,
616 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
617 .write_prt = SDMMC0_WRITE_PROTECT_PIN,
618 .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
620 .write_prt = INVALID_GPIO,
624 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
625 .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
626 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
634 #endif // CONFIG_SDMMC0_RK29
636 #ifdef CONFIG_SDMMC1_RK29
637 #define CONFIG_SDMMC1_USE_DMA
638 static int rk29_sdmmc1_cfg_gpio(void)
640 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
641 gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
642 gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
647 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
649 (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
650 MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
653 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
654 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
655 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
658 (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
661 .io_init = rk29_sdmmc1_cfg_gpio,
663 .set_iomux = rk29_sdmmc_set_iomux,
666 #ifdef CONFIG_SDMMC1_USE_DMA
672 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
673 .status = rk29sdk_wifi_status,
674 .register_status_notify = rk29sdk_wifi_status_register,
677 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
678 .write_prt = SDMMC1_WRITE_PROTECT_PIN,
679 .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
681 .write_prt = INVALID_GPIO,
684 #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
685 .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
689 #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
690 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
691 .io = RK29SDK_SD_CARD_DETECT_N,
696 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
702 .enable_sd_wakeup = 0,
704 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
706 /***********************************************************
708 ************************************************************/
709 #ifdef CONFIG_RFKILL_RK
710 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
711 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
712 .type = RFKILL_TYPE_BLUETOOTH,
714 .poweron_gpio = { // BT_REG_ON
715 .io = INVALID_GPIO, //RK30_PIN3_PC7,
718 .name = "bt_poweron",
723 .reset_gpio = { // BT_RST
724 .io = RK30_PIN3_PD5, // set io to INVALID_GPIO for disable it
732 .wake_gpio = { // BT_WAKE, use to control bt's sleep and wakeup
733 .io = RK30_PIN0_PC6, // set io to INVALID_GPIO for disable it
741 .wake_host_irq = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
743 .io = RK30_PIN0_PC5, // set io to INVALID_GPIO for disable it
744 .enable = GPIO_LOW, // set GPIO_LOW for falling, set 0 for rising
746 .name = "bt_wake_host",
752 .rts_gpio = { // UART_RTS, enable or disable BT's data coming
753 .io = RK30_PIN0_PC3, // set io to INVALID_GPIO for disable it
763 static struct platform_device device_rfkill_rk = {
767 .platform_data = &rfkill_rk_platdata,
772 /***********************************************************
774 ************************************************************/
776 static struct ion_platform_data rk30_ion_pdata = {
780 .type = ION_HEAP_TYPE_CARVEOUT,
781 .id = ION_NOR_HEAP_ID,
783 .size = ION_RESERVE_SIZE,
788 static struct platform_device device_ion = {
789 .name = "ion-rockchip",
792 .platform_data = &rk30_ion_pdata,
797 #ifdef CONFIG_SND_SOC_RK3028
798 struct rk3028_codec_pdata rk3028_codec_pdata_info={
799 .spk_ctl_gpio = INVALID_GPIO,
800 .hp_ctl_gpio = RK2928_PIN3_PD4,
803 static struct resource resources_acodec[] = {
805 .start = RK2928_ACODEC_PHYS,
806 .end = RK2928_ACODEC_PHYS + RK2928_ACODEC_SIZE - 1,
807 .flags = IORESOURCE_MEM,
811 static struct platform_device rk3028_codec = {
812 .name = "rk3028-codec",
814 .resource = resources_acodec,
816 .platform_data = &rk3028_codec_pdata_info,
821 /***********************************************************
823 ************************************************************/
824 #ifdef CONFIG_RK30_PWM_REGULATOR
825 static int pwm_voltage_map[] = {
826 800000, 825000, 850000, 875000, 900000, 925000 ,
827 950000, 975000, 1000000, 1025000, 1050000, 1075000,
828 1100000, 1125000, 1150000, 1175000, 1200000, 1225000,
829 1250000, 1275000, 1300000, 1325000, 1350000, 1375000
832 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
834 .supply = "vdd_core",
838 struct regulator_init_data pwm_regulator_init_dcdc[1] = {
843 .max_uV = 1800000, //0.6-1.8V
845 .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
847 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
848 .consumer_supplies = pwm_dcdc1_consumers,
852 static struct pwm_platform_data pwm_regulator_info[1] = {
855 .pwm_voltage = 1200000,
856 .suspend_voltage = 1050000,
859 .coefficient = 504, //50.4%
860 .pwm_voltage_map = pwm_voltage_map,
861 .init_data = &pwm_regulator_init_dcdc[0],
864 struct platform_device pwm_regulator_device[1] = {
866 .name = "pwm-voltage-regulator",
869 .platform_data = &pwm_regulator_info[0],
874 static void pwm_regulator_init(void)
876 pwm_regulator_info[0].pwm_gpio = iomux_mode_to_gpio(pwm_mode[REG_PWM]);
877 pwm_regulator_info[0].pwm_iomux_pwm = pwm_mode[REG_PWM];
878 pwm_regulator_info[0].pwm_iomux_gpio = iomux_switch_gpio_mode(pwm_mode[REG_PWM]);
882 int __sramdata pwm_iomux, pwm_do, pwm_dir, pwm_en;
883 #define grf_readl(offset) readl_relaxed(RK30_GRF_BASE + offset)
884 #define grf_writel(v, offset) do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
886 #define GPIO0_D2_OFFSET 10
887 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
889 #ifdef CONFIG_RK30_PWM_REGULATOR
891 /* pwm0: GPIO0_D2, pwm1: GPIO0_D3, pwm2: GPIO0_D4 */
892 int off = GPIO0_D2_OFFSET + REG_PWM;
895 pwm_iomux = grf_readl(GRF_GPIO0D_IOMUX);
896 pwm_dir = grf_readl(GRF_GPIO0H_DIR);
897 pwm_do = grf_readl(GRF_GPIO0H_DO);
898 pwm__en = grf_readl(GRF_GPIO0H_EN);
900 grf_writel((1<<(2 * off), GRF_GPIO0D_IOMUX);
901 grf_writel((1<<(16 + off))|(1<<off), GRF_GPIO0H_DIR);
902 grf_writel((1<<(16 + off))|(1<<off), GRF_GPIO0H_DO);
907 void __sramfunc rk30_pwm_logic_resume_voltage(void)
909 #ifdef CONFIG_RK30_PWM_REGULATOR
911 /* pwm0: GPIO0_D2, pwm1: GPIO0_D3, pwm2: GPIO0_D4 */
912 int off = GPIO0_D2_OFFSET + REG_PWM;
914 grf_writel((1<<(2 * off))|pwm_iomux, GRF_GPIO0D_IOMUX);
915 grf_writel(((1<<(16 + off))|pwm_dir), GRF_GPIO0L_DIR);
916 grf_writel(((1<<(16 + off))|pwm_do), GRF_GPIO0L_DO);
917 grf_writel(((1<<(16 + off))|pwm_en), GRF_GPIO0L_EN);
922 extern void pwm_suspend_voltage(void);
923 extern void pwm_resume_voltage(void);
925 void rk30_pwm_suspend_voltage_set(void)
927 #ifdef CONFIG_RK30_PWM_REGULATOR
928 pwm_suspend_voltage();
932 void rk30_pwm_resume_voltage_set(void)
934 #ifdef CONFIG_RK30_PWM_REGULATOR
935 pwm_resume_voltage();
939 /***********************************************************
941 ************************************************************/
942 int __sramdata g_pmic_type = 0;
944 #ifdef CONFIG_MFD_TPS65910
945 #define TPS65910_HOST_IRQ PMU_INT_PIN
946 #define PMU_POWER_SLEEP PMU_SLEEP_PIN
947 static struct pmu_info tps65910_dcdc_info[] = {
965 static struct pmu_info tps65910_ldo_info[] = {
967 .name = "vpll", //vcc25
972 .name = "vdig1", //vcc18_cif
978 .name = "vdig2", //vdd11
983 .name = "vaux1", //vcc28_cif
988 .name = "vaux2", //vcca33
993 .name = "vaux33", //vcc_tp
998 .name = "vmmc", //vccio_wl
1008 #include "../mach-rk30/board-pmu-tps65910.c"
1011 void __sramfunc board_pmu_suspend(void)
1013 #if defined (CONFIG_MFD_TPS65910)
1014 if(pmic_is_tps65910())
1015 board_pmu_tps65910_suspend();
1019 void __sramfunc board_pmu_resume(void)
1021 #if defined (CONFIG_MFD_TPS65910)
1022 if(pmic_is_tps65910())
1023 board_pmu_tps65910_resume();
1027 /***********************************************************
1029 ************************************************************/
1030 #ifdef CONFIG_I2C0_RK30
1031 static struct i2c_board_info __initdata i2c0_info[] = {
1032 #if defined (CONFIG_GS_MMA8452)
1034 .type = "gs_mma8452",
1038 .platform_data = &mma8452_info,
1044 #ifdef CONFIG_I2C1_RK30
1045 static struct i2c_board_info __initdata i2c1_info[] = {
1046 #if defined (CONFIG_MFD_TPS65910)
1049 .addr = TPS65910_I2C_ID0,
1051 .irq = TPS65910_HOST_IRQ,
1052 .platform_data = &tps65910_data,
1058 #ifdef CONFIG_I2C2_RK30
1059 static struct i2c_board_info __initdata i2c2_info[] = {
1060 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1062 .type = "Goodix-TS",
1065 .irq = TOUCH_INT_PIN,
1066 .platform_data = &goodix_info,
1072 #ifdef CONFIG_I2C3_RK30
1073 static struct i2c_board_info __initdata i2c3_info[] = {
1077 #ifdef CONFIG_I2C_GPIO_RK30
1078 #define I2C_SDA_PIN INVALID_GPIO// RK30_PIN2_PD6 //set sda_pin here
1079 #define I2C_SCL_PIN INVALID_GPIO//RK30_PIN2_PD7 //set scl_pin here
1080 static int rk30_i2c_io_init(void)
1085 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1086 .sda_pin = I2C_SDA_PIN,
1087 .scl_pin = I2C_SCL_PIN,
1088 .udelay = 5, // clk = 500/udelay = 100Khz
1089 .timeout = 100,//msecs_to_jiffies(100),
1091 .io_init = rk30_i2c_io_init,
1094 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1098 static void __init rk30_i2c_register_board_info(void)
1100 #ifdef CONFIG_I2C0_RK30
1101 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1103 #ifdef CONFIG_I2C1_RK30
1104 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1106 #ifdef CONFIG_I2C2_RK30
1107 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1109 #ifdef CONFIG_I2C3_RK30
1110 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1112 #ifdef CONFIG_I2C_GPIO_RK30
1113 i2c_register_board_info(4, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1117 /***********************************************************
1119 ************************************************************/
1120 static struct platform_device *devices[] __initdata = {
1124 #ifdef CONFIG_WIFI_CONTROL_FUNC
1125 &rk29sdk_wifi_device,
1127 #ifdef CONFIG_RFKILL_RK
1130 #ifdef CONFIG_SND_SOC_RK3028
1135 static void rk30_pm_power_off(void)
1137 #if defined(CONFIG_MFD_TPS65910)
1138 tps65910_device_shutdown();//tps65910 shutdown
1140 gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1144 static void __init machine_rk30_board_init(void)
1146 #ifdef CONFIG_RK30_PWM_REGULATOR
1147 pwm_regulator_init();
1150 pm_power_off = rk30_pm_power_off;
1151 rk_gpio_request(POWER_ON_PIN, GPIOF_DIR_OUT, GPIO_HIGH, "system power on");
1152 rk30_i2c_register_board_info();
1153 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1154 platform_add_devices(devices, ARRAY_SIZE(devices));
1155 rk_platform_add_display_devices();
1156 #if defined(CONFIG_WIFI_CONTROL_FUNC)
1157 rk29sdk_wifi_bt_gpio_control_init();
1158 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1159 rk29sdk_wifi_combo_module_gpio_init();
1163 static void __init rk30_reserve(void)
1166 #ifdef CONFIG_FB_ROCKCHIP
1167 resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
1168 resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
1170 resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1171 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1174 #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
1175 resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
1176 resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
1181 rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1183 board_mem_reserved();
1186 /***********************************************************
1188 ************************************************************/
1189 static struct cpufreq_frequency_table dvfs_arm_table[] = {
1190 {.frequency = 312 * 1000, .index = 1200 * 1000},
1191 {.frequency = 504 * 1000, .index = 1200 * 1000},
1192 {.frequency = 816 * 1000, .index = 1200 * 1000},
1193 //{.frequency = 1008 * 1000, .index = 1200 * 1000},
1194 //{.frequency = 1200 * 1000, .index = 1200 * 1000},
1195 //{.frequency = 1416 * 1000, .index = 1200 * 1000},
1196 //{.frequency = 1608 * 1000, .index = 1200 * 1000},
1197 {.frequency = CPUFREQ_TABLE_END},
1200 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1201 {.frequency = 100 * 1000, .index = 1200 * 1000},
1202 {.frequency = 200 * 1000, .index = 1200 * 1000},
1203 {.frequency = 266 * 1000, .index = 1200 * 1000},
1204 {.frequency = 300 * 1000, .index = 1200 * 1000},
1205 {.frequency = 400 * 1000, .index = 1200 * 1000},
1206 {.frequency = CPUFREQ_TABLE_END},
1209 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1210 {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1200 * 1000},
1211 {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1200 * 1000},
1212 {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1200 * 1000},
1213 {.frequency = CPUFREQ_TABLE_END},
1216 void __init board_clock_init(void)
1218 rk2928_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1219 //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1220 dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
1221 dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1222 dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1225 /************************ end *****************************/
1226 MACHINE_START(RK30, "RK30board")
1227 .boot_params = PLAT_PHYS_OFFSET + 0x800,
1228 .fixup = rk2928_fixup,
1229 .reserve = &rk30_reserve,
1230 .map_io = rk2928_map_io,
1231 .init_irq = rk2928_init_irq,
1232 .timer = &rk2928_timer,
1233 .init_machine = machine_rk30_board_init,