From 28793493e63e77b717593de46e891c18c20a038a Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Tue, 4 Dec 2012 15:01:01 +0100 Subject: [PATCH] --- yaml --- r: 343130 b: refs/heads/master c: d1e7de3007c6e34c5e6d5e1b707b5aba4a1cd57f h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/mfd/wm5102-tables.c | 3 - trunk/drivers/regulator/Kconfig | 7 - trunk/drivers/regulator/Makefile | 1 - trunk/drivers/regulator/arizona-ldo1.c | 130 +------ trunk/drivers/regulator/arizona-micsupp.c | 2 - trunk/drivers/regulator/as3711-regulator.c | 369 -------------------- trunk/drivers/regulator/core.c | 22 ++ trunk/drivers/regulator/wm831x-dcdc.c | 2 +- trunk/include/linux/mfd/arizona/registers.h | 16 - trunk/include/linux/regulator/consumer.h | 1 + 11 files changed, 28 insertions(+), 527 deletions(-) delete mode 100644 trunk/drivers/regulator/as3711-regulator.c diff --git a/[refs] b/[refs] index 2469b2cff6ea..d24f74d1ac44 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b0e5997ef4300da08b051d2a84ce6cc11b267042 +refs/heads/master: d1e7de3007c6e34c5e6d5e1b707b5aba4a1cd57f diff --git a/trunk/drivers/mfd/wm5102-tables.c b/trunk/drivers/mfd/wm5102-tables.c index b829a5710ddc..01b9255ed631 100644 --- a/trunk/drivers/mfd/wm5102-tables.c +++ b/trunk/drivers/mfd/wm5102-tables.c @@ -775,7 +775,6 @@ static const struct reg_default wm5102_reg_default[] = { { 0x00000154, 0x0000 }, /* R340 - Rate Estimator 3 */ { 0x00000155, 0x0000 }, /* R341 - Rate Estimator 4 */ { 0x00000156, 0x0000 }, /* R342 - Rate Estimator 5 */ - { 0x00000161, 0x0000 }, /* R353 - Dynamic Frequency Scaling 1 */ { 0x00000171, 0x0000 }, /* R369 - FLL1 Control 1 */ { 0x00000172, 0x0008 }, /* R370 - FLL1 Control 2 */ { 0x00000173, 0x0018 }, /* R371 - FLL1 Control 3 */ @@ -1565,7 +1564,6 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg) case ARIZONA_RATE_ESTIMATOR_3: case ARIZONA_RATE_ESTIMATOR_4: case ARIZONA_RATE_ESTIMATOR_5: - case ARIZONA_DYNAMIC_FREQUENCY_SCALING_1: case ARIZONA_FLL1_CONTROL_1: case ARIZONA_FLL1_CONTROL_2: case ARIZONA_FLL1_CONTROL_3: @@ -1598,7 +1596,6 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg) case ARIZONA_FLL2_GPIO_CLOCK: case ARIZONA_MIC_CHARGE_PUMP_1: case ARIZONA_LDO1_CONTROL_1: - case ARIZONA_LDO1_CONTROL_2: case ARIZONA_LDO2_CONTROL_1: case ARIZONA_MIC_BIAS_CTRL_1: case ARIZONA_MIC_BIAS_CTRL_2: diff --git a/trunk/drivers/regulator/Kconfig b/trunk/drivers/regulator/Kconfig index f73d6f5ce6dd..67d47b59a66d 100644 --- a/trunk/drivers/regulator/Kconfig +++ b/trunk/drivers/regulator/Kconfig @@ -450,12 +450,5 @@ config REGULATOR_WM8994 This driver provides support for the voltage regulators on the WM8994 CODEC. -config REGULATOR_AS3711 - tristate "AS3711 PMIC" - depends on MFD_AS3711 - help - This driver provides support for the voltage regulators on the - AS3711 PMIC - endif diff --git a/trunk/drivers/regulator/Makefile b/trunk/drivers/regulator/Makefile index c1557ace9095..e431eed8a878 100644 --- a/trunk/drivers/regulator/Makefile +++ b/trunk/drivers/regulator/Makefile @@ -16,7 +16,6 @@ obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o -obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o obj-$(CONFIG_REGULATOR_DA903X) += da903x.o obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o diff --git a/trunk/drivers/regulator/arizona-ldo1.c b/trunk/drivers/regulator/arizona-ldo1.c index 739faf99b9e2..d184aa35abcb 100644 --- a/trunk/drivers/regulator/arizona-ldo1.c +++ b/trunk/drivers/regulator/arizona-ldo1.c @@ -34,108 +34,6 @@ struct arizona_ldo1 { struct regulator_init_data init_data; }; -static int arizona_ldo1_hc_list_voltage(struct regulator_dev *rdev, - unsigned int selector) -{ - if (selector >= rdev->desc->n_voltages) - return -EINVAL; - - if (selector == rdev->desc->n_voltages - 1) - return 1800000; - else - return rdev->desc->min_uV + (rdev->desc->uV_step * selector); -} - -static int arizona_ldo1_hc_map_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - int sel; - - sel = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step); - if (sel >= rdev->desc->n_voltages) - sel = rdev->desc->n_voltages - 1; - - return sel; -} - -static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev, - unsigned sel) -{ - struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev); - struct regmap *regmap = ldo->arizona->regmap; - unsigned int val; - int ret; - - if (sel == rdev->desc->n_voltages - 1) - val = ARIZONA_LDO1_HI_PWR; - else - val = 0; - - ret = regmap_update_bits(regmap, ARIZONA_LDO1_CONTROL_2, - ARIZONA_LDO1_HI_PWR, val); - if (ret != 0) - return ret; - - ret = regmap_update_bits(regmap, ARIZONA_DYNAMIC_FREQUENCY_SCALING_1, - ARIZONA_SUBSYS_MAX_FREQ, val); - if (ret != 0) - return ret; - - if (val) - return 0; - - val = sel << ARIZONA_LDO1_VSEL_SHIFT; - - return regmap_update_bits(regmap, ARIZONA_LDO1_CONTROL_1, - ARIZONA_LDO1_VSEL_MASK, val); -} - -static int arizona_ldo1_hc_get_voltage_sel(struct regulator_dev *rdev) -{ - struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev); - struct regmap *regmap = ldo->arizona->regmap; - unsigned int val; - int ret; - - ret = regmap_read(regmap, ARIZONA_LDO1_CONTROL_2, &val); - if (ret != 0) - return ret; - - if (val & ARIZONA_LDO1_HI_PWR) - return rdev->desc->n_voltages - 1; - - ret = regmap_read(regmap, ARIZONA_LDO1_CONTROL_1, &val); - if (ret != 0) - return ret; - - return (val & ARIZONA_LDO1_VSEL_MASK) >> ARIZONA_LDO1_VSEL_SHIFT; -} - -static struct regulator_ops arizona_ldo1_hc_ops = { - .list_voltage = arizona_ldo1_hc_list_voltage, - .map_voltage = arizona_ldo1_hc_map_voltage, - .get_voltage_sel = arizona_ldo1_hc_get_voltage_sel, - .set_voltage_sel = arizona_ldo1_hc_set_voltage_sel, - .get_bypass = regulator_get_bypass_regmap, - .set_bypass = regulator_set_bypass_regmap, -}; - -static const struct regulator_desc arizona_ldo1_hc = { - .name = "LDO1", - .supply_name = "LDOVDD", - .type = REGULATOR_VOLTAGE, - .ops = &arizona_ldo1_hc_ops, - - .bypass_reg = ARIZONA_LDO1_CONTROL_1, - .bypass_mask = ARIZONA_LDO1_BYPASS, - .min_uV = 900000, - .uV_step = 50000, - .n_voltages = 8, - .enable_time = 500, - - .owner = THIS_MODULE, -}; - static struct regulator_ops arizona_ldo1_ops = { .list_voltage = regulator_list_voltage_linear, .map_voltage = regulator_map_voltage_linear, @@ -157,22 +55,11 @@ static const struct regulator_desc arizona_ldo1 = { .bypass_mask = ARIZONA_LDO1_BYPASS, .min_uV = 900000, .uV_step = 50000, - .n_voltages = 7, - .enable_time = 500, + .n_voltages = 6, .owner = THIS_MODULE, }; -static const struct regulator_init_data arizona_ldo1_dvfs = { - .constraints = { - .min_uV = 1200000, - .max_uV = 1800000, - .valid_ops_mask = REGULATOR_CHANGE_STATUS | - REGULATOR_CHANGE_VOLTAGE, - }, - .num_consumer_supplies = 1, -}; - static const struct regulator_init_data arizona_ldo1_default = { .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS, @@ -183,7 +70,6 @@ static const struct regulator_init_data arizona_ldo1_default = { static __devinit int arizona_ldo1_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); - const struct regulator_desc *desc; struct regulator_config config = { }; struct arizona_ldo1 *ldo1; int ret; @@ -201,17 +87,7 @@ static __devinit int arizona_ldo1_probe(struct platform_device *pdev) * default init_data for it. This will be overridden with * platform data if provided. */ - switch (arizona->type) { - case WM5102: - desc = &arizona_ldo1_hc; - ldo1->init_data = arizona_ldo1_dvfs; - break; - default: - desc = &arizona_ldo1; - ldo1->init_data = arizona_ldo1_default; - break; - } - + ldo1->init_data = arizona_ldo1_default; ldo1->init_data.consumer_supplies = &ldo1->supply; ldo1->supply.supply = "DCVDD"; ldo1->supply.dev_name = dev_name(arizona->dev); @@ -226,7 +102,7 @@ static __devinit int arizona_ldo1_probe(struct platform_device *pdev) else config.init_data = &ldo1->init_data; - ldo1->regulator = regulator_register(desc, &config); + ldo1->regulator = regulator_register(&arizona_ldo1, &config); if (IS_ERR(ldo1->regulator)) { ret = PTR_ERR(ldo1->regulator); dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n", diff --git a/trunk/drivers/regulator/arizona-micsupp.c b/trunk/drivers/regulator/arizona-micsupp.c index 93d0604e64b4..d9b1f82cc5bd 100644 --- a/trunk/drivers/regulator/arizona-micsupp.c +++ b/trunk/drivers/regulator/arizona-micsupp.c @@ -101,8 +101,6 @@ static const struct regulator_desc arizona_micsupp = { .bypass_reg = ARIZONA_MIC_CHARGE_PUMP_1, .bypass_mask = ARIZONA_CPMIC_BYPASS, - .enable_time = 3000, - .owner = THIS_MODULE, }; diff --git a/trunk/drivers/regulator/as3711-regulator.c b/trunk/drivers/regulator/as3711-regulator.c deleted file mode 100644 index 2f1341db38a0..000000000000 --- a/trunk/drivers/regulator/as3711-regulator.c +++ /dev/null @@ -1,369 +0,0 @@ -/* - * AS3711 PMIC regulator driver, using DCDC Step Down and LDO supplies - * - * Copyright (C) 2012 Renesas Electronics Corporation - * Author: Guennadi Liakhovetski, - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the version 2 of the GNU General Public License as - * published by the Free Software Foundation - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -struct as3711_regulator_info { - struct regulator_desc desc; - unsigned int max_uV; -}; - -struct as3711_regulator { - struct as3711_regulator_info *reg_info; - struct regulator_dev *rdev; -}; - -static int as3711_list_voltage_sd(struct regulator_dev *rdev, - unsigned int selector) -{ - if (selector >= rdev->desc->n_voltages) - return -EINVAL; - - if (!selector) - return 0; - if (selector < 0x41) - return 600000 + selector * 12500; - if (selector < 0x71) - return 1400000 + (selector - 0x40) * 25000; - return 2600000 + (selector - 0x70) * 50000; -} - -static int as3711_list_voltage_aldo(struct regulator_dev *rdev, - unsigned int selector) -{ - if (selector >= rdev->desc->n_voltages) - return -EINVAL; - - if (selector < 0x10) - return 1200000 + selector * 50000; - return 1800000 + (selector - 0x10) * 100000; -} - -static int as3711_list_voltage_dldo(struct regulator_dev *rdev, - unsigned int selector) -{ - if (selector >= rdev->desc->n_voltages || - (selector > 0x10 && selector < 0x20)) - return -EINVAL; - - if (selector < 0x11) - return 900000 + selector * 50000; - return 1750000 + (selector - 0x20) * 50000; -} - -static int as3711_bound_check(struct regulator_dev *rdev, - int *min_uV, int *max_uV) -{ - struct as3711_regulator *reg = rdev_get_drvdata(rdev); - struct as3711_regulator_info *info = reg->reg_info; - - dev_dbg(&rdev->dev, "%s(), %d, %d, %d\n", __func__, - *min_uV, rdev->desc->min_uV, info->max_uV); - - if (*max_uV < *min_uV || - *min_uV > info->max_uV || rdev->desc->min_uV > *max_uV) - return -EINVAL; - - if (rdev->desc->n_voltages == 1) - return 0; - - if (*max_uV > info->max_uV) - *max_uV = info->max_uV; - - if (*min_uV < rdev->desc->min_uV) - *min_uV = rdev->desc->min_uV; - - return *min_uV; -} - -static int as3711_sel_check(int min, int max, int bottom, int step) -{ - int sel, voltage; - - /* Round up min, when dividing: keeps us within the range */ - sel = DIV_ROUND_UP(min - bottom, step); - voltage = sel * step + bottom; - pr_debug("%s(): select %d..%d in %d+N*%d: %d\n", __func__, - min, max, bottom, step, sel); - if (voltage > max) - return -EINVAL; - - return sel; -} - -static int as3711_map_voltage_sd(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - int ret; - - ret = as3711_bound_check(rdev, &min_uV, &max_uV); - if (ret <= 0) - return ret; - - if (min_uV <= 1400000) - return as3711_sel_check(min_uV, max_uV, 600000, 12500); - - if (min_uV <= 2600000) - return as3711_sel_check(min_uV, max_uV, 1400000, 25000) + 0x40; - - return as3711_sel_check(min_uV, max_uV, 2600000, 50000) + 0x70; -} - -/* - * The regulator API supports 4 modes of operataion: FAST, NORMAL, IDLE and - * STANDBY. We map them in the following way to AS3711 SD1-4 DCDC modes: - * FAST: sdX_fast=1 - * NORMAL: low_noise=1 - * IDLE: low_noise=0 - */ - -static int as3711_set_mode_sd(struct regulator_dev *rdev, unsigned int mode) -{ - unsigned int fast_bit = rdev->desc->enable_mask, - low_noise_bit = fast_bit << 4; - u8 val; - - switch (mode) { - case REGULATOR_MODE_FAST: - val = fast_bit | low_noise_bit; - break; - case REGULATOR_MODE_NORMAL: - val = low_noise_bit; - break; - case REGULATOR_MODE_IDLE: - val = 0; - break; - default: - return -EINVAL; - } - - return regmap_update_bits(rdev->regmap, AS3711_SD_CONTROL_1, - low_noise_bit | fast_bit, val); -} - -static unsigned int as3711_get_mode_sd(struct regulator_dev *rdev) -{ - unsigned int fast_bit = rdev->desc->enable_mask, - low_noise_bit = fast_bit << 4, mask = fast_bit | low_noise_bit; - unsigned int val; - int ret = regmap_read(rdev->regmap, AS3711_SD_CONTROL_1, &val); - - if (ret < 0) - return ret; - - if ((val & mask) == mask) - return REGULATOR_MODE_FAST; - - if ((val & mask) == low_noise_bit) - return REGULATOR_MODE_NORMAL; - - if (!(val & mask)) - return REGULATOR_MODE_IDLE; - - return -EINVAL; -} - -static int as3711_map_voltage_aldo(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - int ret; - - ret = as3711_bound_check(rdev, &min_uV, &max_uV); - if (ret <= 0) - return ret; - - if (min_uV <= 1800000) - return as3711_sel_check(min_uV, max_uV, 1200000, 50000); - - return as3711_sel_check(min_uV, max_uV, 1800000, 100000) + 0x10; -} - -static int as3711_map_voltage_dldo(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - int ret; - - ret = as3711_bound_check(rdev, &min_uV, &max_uV); - if (ret <= 0) - return ret; - - if (min_uV <= 1700000) - return as3711_sel_check(min_uV, max_uV, 900000, 50000); - - return as3711_sel_check(min_uV, max_uV, 1750000, 50000) + 0x20; -} - -static struct regulator_ops as3711_sd_ops = { - .is_enabled = regulator_is_enabled_regmap, - .enable = regulator_enable_regmap, - .disable = regulator_disable_regmap, - .get_voltage_sel = regulator_get_voltage_sel_regmap, - .set_voltage_sel = regulator_set_voltage_sel_regmap, - .list_voltage = as3711_list_voltage_sd, - .map_voltage = as3711_map_voltage_sd, - .get_mode = as3711_get_mode_sd, - .set_mode = as3711_set_mode_sd, -}; - -static struct regulator_ops as3711_aldo_ops = { - .is_enabled = regulator_is_enabled_regmap, - .enable = regulator_enable_regmap, - .disable = regulator_disable_regmap, - .get_voltage_sel = regulator_get_voltage_sel_regmap, - .set_voltage_sel = regulator_set_voltage_sel_regmap, - .list_voltage = as3711_list_voltage_aldo, - .map_voltage = as3711_map_voltage_aldo, -}; - -static struct regulator_ops as3711_dldo_ops = { - .is_enabled = regulator_is_enabled_regmap, - .enable = regulator_enable_regmap, - .disable = regulator_disable_regmap, - .get_voltage_sel = regulator_get_voltage_sel_regmap, - .set_voltage_sel = regulator_set_voltage_sel_regmap, - .list_voltage = as3711_list_voltage_dldo, - .map_voltage = as3711_map_voltage_dldo, -}; - -#define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \ - [AS3711_REGULATOR_ ## _id] = { \ - .desc = { \ - .name = "as3711-regulator-" # _id, \ - .id = AS3711_REGULATOR_ ## _id, \ - .n_voltages = (_vmask + 1), \ - .ops = &as3711_ ## _sfx ## _ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - .vsel_reg = AS3711_ ## _id ## _VOLTAGE, \ - .vsel_mask = _vmask << _vshift, \ - .enable_reg = AS3711_ ## _en_reg, \ - .enable_mask = BIT(_en_bit), \ - .min_uV = _min_uV, \ - }, \ - .max_uV = _max_uV, \ -} - -static struct as3711_regulator_info as3711_reg_info[] = { - AS3711_REG(SD_1, SD_CONTROL, 0, 0x7f, 0, 612500, 3350000, sd), - AS3711_REG(SD_2, SD_CONTROL, 1, 0x7f, 0, 612500, 3350000, sd), - AS3711_REG(SD_3, SD_CONTROL, 2, 0x7f, 0, 612500, 3350000, sd), - AS3711_REG(SD_4, SD_CONTROL, 3, 0x7f, 0, 612500, 3350000, sd), - AS3711_REG(LDO_1, LDO_1_VOLTAGE, 7, 0x1f, 0, 1200000, 3300000, aldo), - AS3711_REG(LDO_2, LDO_2_VOLTAGE, 7, 0x1f, 0, 1200000, 3300000, aldo), - AS3711_REG(LDO_3, LDO_3_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo), - AS3711_REG(LDO_4, LDO_4_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo), - AS3711_REG(LDO_5, LDO_5_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo), - AS3711_REG(LDO_6, LDO_6_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo), - AS3711_REG(LDO_7, LDO_7_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo), - AS3711_REG(LDO_8, LDO_8_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo), - /* StepUp output voltage depends on supplying regulator */ -}; - -#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info) - -static int as3711_regulator_probe(struct platform_device *pdev) -{ - struct as3711_regulator_pdata *pdata = dev_get_platdata(&pdev->dev); - struct as3711 *as3711 = dev_get_drvdata(pdev->dev.parent); - struct regulator_init_data *reg_data; - struct regulator_config config = {.dev = &pdev->dev,}; - struct as3711_regulator *reg = NULL; - struct as3711_regulator *regs; - struct regulator_dev *rdev; - struct as3711_regulator_info *ri; - int ret; - int id; - - if (!pdata) - dev_dbg(&pdev->dev, "No platform data...\n"); - - regs = devm_kzalloc(&pdev->dev, AS3711_REGULATOR_NUM * - sizeof(struct as3711_regulator), GFP_KERNEL); - if (!regs) { - dev_err(&pdev->dev, "Memory allocation failed exiting..\n"); - return -ENOMEM; - } - - for (id = 0, ri = as3711_reg_info; id < AS3711_REGULATOR_NUM; ++id, ri++) { - reg_data = pdata ? pdata->init_data[id] : NULL; - - /* No need to register if there is no regulator data */ - if (!ri->desc.name) - continue; - - reg = ®s[id]; - reg->reg_info = ri; - - config.init_data = reg_data; - config.driver_data = reg; - config.regmap = as3711->regmap; - - rdev = regulator_register(&ri->desc, &config); - if (IS_ERR(rdev)) { - dev_err(&pdev->dev, "Failed to register regulator %s\n", - ri->desc.name); - ret = PTR_ERR(rdev); - goto eregreg; - } - reg->rdev = rdev; - } - platform_set_drvdata(pdev, regs); - return 0; - -eregreg: - while (--id >= 0) - regulator_unregister(regs[id].rdev); - - return ret; -} - -static int as3711_regulator_remove(struct platform_device *pdev) -{ - struct as3711_regulator *regs = platform_get_drvdata(pdev); - int id; - - for (id = 0; id < AS3711_REGULATOR_NUM; ++id) - regulator_unregister(regs[id].rdev); - return 0; -} - -static struct platform_driver as3711_regulator_driver = { - .driver = { - .name = "as3711-regulator", - .owner = THIS_MODULE, - }, - .probe = as3711_regulator_probe, - .remove = as3711_regulator_remove, -}; - -static int __init as3711_regulator_init(void) -{ - return platform_driver_register(&as3711_regulator_driver); -} -subsys_initcall(as3711_regulator_init); - -static void __exit as3711_regulator_exit(void) -{ - platform_driver_unregister(&as3711_regulator_driver); -} -module_exit(as3711_regulator_exit); - -MODULE_AUTHOR("Guennadi Liakhovetski "); -MODULE_DESCRIPTION("AS3711 regulator driver"); -MODULE_ALIAS("platform:as3711-regulator"); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/regulator/core.c b/trunk/drivers/regulator/core.c index e872c8be080e..59e08633372a 100644 --- a/trunk/drivers/regulator/core.c +++ b/trunk/drivers/regulator/core.c @@ -1866,6 +1866,28 @@ int regulator_is_enabled(struct regulator *regulator) } EXPORT_SYMBOL_GPL(regulator_is_enabled); +/** + * regulator_can_change_voltage - check if regulator can change voltage + * @regulator: regulator source + * + * Returns positive if the regulator driver backing the source/client + * can change its voltage, false otherwise. Usefull for detecting fixed + * or dummy regulators and disabling voltage change logic in the client + * driver. + */ +int regulator_can_change_voltage(struct regulator *regulator) +{ + struct regulator_dev *rdev = regulator->rdev; + + if (rdev->constraints && + rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE && + rdev->desc->n_voltages > 1) + return 1; + + return 0; +} +EXPORT_SYMBOL_GPL(regulator_can_change_voltage); + /** * regulator_count_voltages - count regulator_list_voltage() selectors * @regulator: regulator source diff --git a/trunk/drivers/regulator/wm831x-dcdc.c b/trunk/drivers/regulator/wm831x-dcdc.c index 416fe0a37f56..782c228a19bd 100644 --- a/trunk/drivers/regulator/wm831x-dcdc.c +++ b/trunk/drivers/regulator/wm831x-dcdc.c @@ -290,7 +290,7 @@ static int wm831x_buckv_set_voltage_sel(struct regulator_dev *rdev, if (vsel > dcdc->dvs_vsel) { ret = wm831x_set_bits(wm831x, dvs_reg, WM831X_DC1_DVS_VSEL_MASK, - vsel); + dcdc->dvs_vsel); if (ret == 0) dcdc->dvs_vsel = vsel; else diff --git a/trunk/include/linux/mfd/arizona/registers.h b/trunk/include/linux/mfd/arizona/registers.h index ba26e99c388d..7671a287dfee 100644 --- a/trunk/include/linux/mfd/arizona/registers.h +++ b/trunk/include/linux/mfd/arizona/registers.h @@ -76,7 +76,6 @@ #define ARIZONA_RATE_ESTIMATOR_3 0x154 #define ARIZONA_RATE_ESTIMATOR_4 0x155 #define ARIZONA_RATE_ESTIMATOR_5 0x156 -#define ARIZONA_DYNAMIC_FREQUENCY_SCALING_1 0x161 #define ARIZONA_FLL1_CONTROL_1 0x171 #define ARIZONA_FLL1_CONTROL_2 0x172 #define ARIZONA_FLL1_CONTROL_3 0x173 @@ -111,7 +110,6 @@ #define ARIZONA_FLL2_GPIO_CLOCK 0x1AA #define ARIZONA_MIC_CHARGE_PUMP_1 0x200 #define ARIZONA_LDO1_CONTROL_1 0x210 -#define ARIZONA_LDO1_CONTROL_2 0x212 #define ARIZONA_LDO2_CONTROL_1 0x213 #define ARIZONA_MIC_BIAS_CTRL_1 0x218 #define ARIZONA_MIC_BIAS_CTRL_2 0x219 @@ -1575,13 +1573,6 @@ #define ARIZONA_SAMPLE_RATE_DETECT_D_SHIFT 0 /* SAMPLE_RATE_DETECT_D - [4:0] */ #define ARIZONA_SAMPLE_RATE_DETECT_D_WIDTH 5 /* SAMPLE_RATE_DETECT_D - [4:0] */ -/* - * R353 (0x161) - Dynamic Frequency Scaling 1 - */ -#define ARIZONA_SUBSYS_MAX_FREQ 0x0001 /* SUBSYS_MAX_FREQ */ -#define ARIZONA_SUBSYS_MAX_FREQ_SHIFT 0 /* SUBSYS_MAX_FREQ */ -#define ARIZONA_SUBSYS_MAX_FREQ_WIDTH 1 /* SUBSYS_MAX_FREQ */ - /* * R369 (0x171) - FLL1 Control 1 */ @@ -1897,13 +1888,6 @@ #define ARIZONA_LDO1_ENA_SHIFT 0 /* LDO1_ENA */ #define ARIZONA_LDO1_ENA_WIDTH 1 /* LDO1_ENA */ -/* - * R530 (0x212) - LDO1 Control 2 - */ -#define ARIZONA_LDO1_HI_PWR 0x0001 /* LDO1_HI_PWR */ -#define ARIZONA_LDO1_HI_PWR_SHIFT 0 /* LDO1_HI_PWR */ -#define ARIZONA_LDO1_HI_PWR_WIDTH 1 /* LDO1_HI_PWR */ - /* * R531 (0x213) - LDO2 Control 1 */ diff --git a/trunk/include/linux/regulator/consumer.h b/trunk/include/linux/regulator/consumer.h index c43cd3556b1f..5d0f7c10bef1 100644 --- a/trunk/include/linux/regulator/consumer.h +++ b/trunk/include/linux/regulator/consumer.h @@ -160,6 +160,7 @@ int regulator_bulk_force_disable(int num_consumers, void regulator_bulk_free(int num_consumers, struct regulator_bulk_data *consumers); +int regulator_can_change_voltage(struct regulator *regulator); int regulator_count_voltages(struct regulator *regulator); int regulator_list_voltage(struct regulator *regulator, unsigned selector); int regulator_is_supported_voltage(struct regulator *regulator,