From 322bef5abec8eade9fa8e450494066cbcb189c22 Mon Sep 17 00:00:00 2001 From: "lw@rock-chips.com" Date: Tue, 17 Apr 2012 11:08:26 +0800 Subject: [PATCH] rk30_phone:add discrete dcdc driver support --- arch/arm/mach-rk30/board-rk30-phone-key.c | 62 ++------------ arch/arm/mach-rk30/board-rk30-phone-wm831x.c | 17 ++++ arch/arm/mach-rk30/board-rk30-phone.c | 90 +++++++++++++++++++- drivers/regulator/Kconfig | 5 ++ drivers/regulator/Makefile | 2 + 5 files changed, 120 insertions(+), 56 deletions(-) diff --git a/arch/arm/mach-rk30/board-rk30-phone-key.c b/arch/arm/mach-rk30/board-rk30-phone-key.c index ab2bc3b322c1..46ef9165f0ee 100755 --- a/arch/arm/mach-rk30/board-rk30-phone-key.c +++ b/arch/arm/mach-rk30/board-rk30-phone-key.c @@ -8,52 +8,43 @@ #define PRESS_LEV_HIGH 0 static struct rk29_keys_button key_button[] = { -#if 0 { .desc = "menu", .code = EV_MENU, - .gpio = RK30_PIN6_PA0, + .gpio = RK30_PIN0_PD0, .active_low = PRESS_LEV_LOW, }, { .desc = "vol+", .code = KEY_VOLUMEUP, - .gpio = RK30_PIN6_PA1, + .gpio = RK30_PIN4_PC4, .active_low = PRESS_LEV_LOW, }, -#endif { .desc = "vol-", .code = KEY_VOLUMEDOWN, .gpio = RK30_PIN4_PC5, .active_low = PRESS_LEV_LOW, }, -#if 0 { .desc = "home", .code = KEY_HOME, - .gpio = RK30_PIN6_PA3, + .gpio = RK30_PIN0_PD2, .active_low = PRESS_LEV_LOW, }, { .desc = "search", .code = KEY_SEARCH, - .gpio = RK30_PIN6_PA4, + .gpio = RK30_PIN0_PD1, .active_low = PRESS_LEV_LOW, }, { .desc = "esc", .code = KEY_BACK, - .gpio = RK30_PIN6_PA5, + .gpio = RK30_PIN0_PD3, .active_low = PRESS_LEV_LOW, }, - { - .desc = "sensor", - .code = KEY_CAMERA, - .gpio = RK30_PIN6_PA6, - .active_low = PRESS_LEV_LOW, - }, -#endif +#if 0 { .desc = "play", .code = KEY_POWER, @@ -62,52 +53,13 @@ static struct rk29_keys_button key_button[] = { //.code_long_press = EV_ENCALL, .wakeup = 1, }, -#if 1 - { - .desc = "vol+", - .code = KEY_VOLUMEUP, - .adc_value = 1, - .gpio = INVALID_GPIO, - .active_low = PRESS_LEV_LOW, - }, -#if 0 - { - .desc = "vol-", - .code = KEY_VOLUMEUP, - .adc_value = 249, - .gpio = INVALID_GPIO, - .active_low = PRESS_LEV_LOW, - }, #endif - { - .desc = "menu", - .code = EV_MENU, - .adc_value = 155, - .gpio = INVALID_GPIO, - .active_low = PRESS_LEV_LOW, - }, - { - .desc = "home", - .code = KEY_HOME, - .adc_value = 630, - .gpio = INVALID_GPIO, - .active_low = PRESS_LEV_LOW, - }, - { - .desc = "esc", - .code = KEY_BACK, - .adc_value = 386, - .gpio = INVALID_GPIO, - .active_low = PRESS_LEV_LOW, - }, { .desc = "camera", .code = KEY_CAMERA, - .adc_value = 827, - .gpio = INVALID_GPIO, + .gpio = RK30_PIN0_PD4, .active_low = PRESS_LEV_LOW, }, -#endif }; struct rk29_keys_platform_data rk29_keys_pdata = { .buttons = key_button, diff --git a/arch/arm/mach-rk30/board-rk30-phone-wm831x.c b/arch/arm/mach-rk30/board-rk30-phone-wm831x.c index 22aaed0eb53d..20f4e7b68a2b 100755 --- a/arch/arm/mach-rk30/board-rk30-phone-wm831x.c +++ b/arch/arm/mach-rk30/board-rk30-phone-wm831x.c @@ -212,6 +212,23 @@ int wm831x_post_init(struct wm831x *Wm831x) regulator_put(ldo); udelay(100); #endif + +//discrete dcdc device +#ifdef CONFIG_RK30_PWM_REGULATOR + dcdc = regulator_get(NULL, "vdd_core"); // vdd_log + regulator_set_voltage(dcdc, 1200000, 1200000); + regulator_enable(dcdc); + printk("%s set vdd_core=%dmV end\n", __func__, regulator_get_voltage(dcdc)); + regulator_put(dcdc); + udelay(100); + + dcdc = regulator_get(NULL, "vdd_cpu"); // vdd_arm + regulator_set_voltage(dcdc, 1200000, 1200000); + regulator_enable(dcdc); + printk("%s set vdd_cpu=%dmV end\n", __func__, regulator_get_voltage(dcdc)); + regulator_put(dcdc); + udelay(100); +#endif printk("wm831x_post_init end"); return 0; } diff --git a/arch/arm/mach-rk30/board-rk30-phone.c b/arch/arm/mach-rk30/board-rk30-phone.c index d4ee353c2341..6887f5aca86a 100755 --- a/arch/arm/mach-rk30/board-rk30-phone.c +++ b/arch/arm/mach-rk30/board-rk30-phone.c @@ -43,6 +43,7 @@ #include #include #include "../../../drivers/headset_observe/rk_headset.h" +#include #if defined(CONFIG_SPIM_RK29) #include "../../../drivers/spi/rk29_spim.h" @@ -670,6 +671,88 @@ struct platform_device rk_device_headset = { }; #endif +#if CONFIG_RK30_PWM_REGULATOR +static struct regulator_consumer_supply pwm_dcdc1_consumers[] = { + { + .supply = "vdd_core", + } +}; + +static struct regulator_consumer_supply pwm_dcdc2_consumers[] = { + { + .supply = "vdd_cpu", + } +}; + +struct regulator_init_data pwm_regulator_init_dcdc[2] = +{ + { + .constraints = { + .name = "PWM_DCDC1", + .min_uV = 600000, + .max_uV = 1800000, //0.6-1.8V + .apply_uV = true, + .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE, + }, + .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers), + .consumer_supplies = pwm_dcdc1_consumers, + }, + { + .constraints = { + .name = "PWM_DCDC2", + .min_uV = 600000, + .max_uV = 1800000, //0.6-1.8V + .apply_uV = true, + .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE, + }, + .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc2_consumers), + .consumer_supplies = pwm_dcdc2_consumers, + }, +}; + +static struct pwm_platform_data pwm_regulator_info[2] = { + { + .pwm_id = 0, + .pwm_gpio = RK30_PIN0_PA3, + .pwm_iomux_name = GPIO0A3_PWM0_NAME, + .pwm_iomux_pwm = GPIO0A_PWM0, + .pwm_iomux_gpio = GPIO0A_GPIO0A3, + .pwm_voltage = 1100000, + .init_data = &pwm_regulator_init_dcdc[0], + }, + { + .pwm_id = 2, + .pwm_gpio = RK30_PIN0_PD6, + .pwm_iomux_name = GPIO0D6_PWM2_NAME, + .pwm_iomux_pwm = GPIO0D_PWM2, + .pwm_iomux_gpio = GPIO0D_GPIO0D6, + .pwm_voltage = 1100000, + .init_data = &pwm_regulator_init_dcdc[1], + }, + +}; + + +struct platform_device pwm_regulator_device[2] = { + { + .name = "pwm-voltage-regulator", + .id = 0, + .dev = { + .platform_data = &pwm_regulator_info[0], + } + }, + { + .name = "pwm-voltage-regulator", + .id = 1, + .dev = { + .platform_data = &pwm_regulator_info[1], + } + }, + +}; + + +#endif /*********************************************************** * rk30 backlight @@ -1444,6 +1527,10 @@ struct platform_device rk29_device_tdsc8800 = { static struct platform_device *devices[] __initdata = { +#ifdef CONFIG_RK30_PWM_REGULATOR + &pwm_regulator_device[0], + &pwm_regulator_device[1], +#endif #ifdef CONFIG_BACKLIGHT_RK29_BL &rk29_device_backlight, #endif @@ -1479,8 +1566,9 @@ static struct platform_device *devices[] __initdata = { &rk_device_headset, #endif #ifdef CONFIG_TDSC8800 - &rk29_device_tdsc8800 + &rk29_device_tdsc8800, #endif + }; // i2c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index bc147414a6b9..90c87c9797c5 100755 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -270,6 +270,11 @@ config RK29_PWM_REGULATOR help Say Y to enable support for the voltage regulators charge on the RK2918. +config RK30_PWM_REGULATOR + tristate "rk30 pwm voltage regulator for discrete dcdc or ldo" + help + Say Y to enable support for the voltage regulators control on the RK30 . + config REGULATOR_88PM8607 bool "Marvell 88PM8607 Power regulators" depends on MFD_88PM860X=y diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 5b98d6cd9803..68db7129f878 100755 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -38,6 +38,8 @@ obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o obj-$(CONFIG_RK2818_REGULATOR_LP8725) += rk2818_lp8725.o obj-$(CONFIG_RK2818_REGULATOR_CHARGE) += charge-regulator.o obj-$(CONFIG_RK29_PWM_REGULATOR) += rk29-pwm-regulator.o +obj-$(CONFIG_RK30_PWM_REGULATOR) += rk30-pwm-regulator.o + obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o -- 2.34.1