regulator: Fixes for -rc1

A bunch of smallish fixes that came up during the merge window as
 things got more testing - even more fixes from Axel, a fix for error
 handling in more complex systems using -EPROBE_DEFER and a couple of
 small fixes for the new dummy regulators.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJPeDhzAAoJEBus8iNuMP3dh3sP/2i2M34Y66HkNGJCbkLgzGsu
 DlwbiNdh+o/uUcALCcyt7tYF06MhsJ4n7fOBRZ+hKr3VMTguHi6B36IKxGrfzBJs
 9XoYQkyO/92g3UjdWQSWKSQfx/qZhw167gmmeL8jQfEQOZZ2MhnCLbbZVsRMFGf6
 PzVDyW0StDWh0uBP6P7UU64pogFfUqSO/guIAqppUI9Ll/ulx0OqY+eov2mQzlmg
 Rqwjt9mF9UMZn4/Br0mQx+iUqqSugtA+2VAAiSx7K8JDjeMPh47S31p/FGCLXrmv
 Lbn2vQGn23RDthdxQlcisY/rJU5WsJbgdjjoppucyYJbYUWzVVMNM0djxtpGIQ7j
 x9X6ZTdG4RuphI5FDku/vKkNS4O/Y0+6bumpqFfXyBoAGOXMKdUmTymCNCogFnOy
 F6vMzrtA27M5HaFaRP3xnMSNU/aBegsgCoEjyQ1b5D1TAKvc5v614cZzyrWaCd+G
 gVE1lDIAo2snraRjZl9LDQwGKOkzEdLXJSzGZ7Pk9n54+QvRBJcYu3l/Wdrn4JES
 jtIprAyWbY4z6n5wuucwwjFZa2UtBukRTV8ZA/jMq+eig3VdN8CSKJCJUQTG+UgV
 fyCNq7WWAhK8rldcjgJhPspEbRazAEnaNwfZUWZAmmnb8bVVRO6pJOl2TiRN0DFt
 8MqdrQtJFusRXgrc+Wlq
 =h5VJ
 -----END PGP SIGNATURE-----

Merge tag 'regulator-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator fixes from Mark Brown:
 "A bunch of smallish fixes that came up during the merge window as
  things got more testing - even more fixes from Axel, a fix for error
  handling in more complex systems using -EPROBE_DEFER and a couple of
  small fixes for the new dummy regulators."

* tag 'regulator-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
  regulator: Remove non-existent parameter from fixed-helper.c kernel doc
  regulator: Fix setting new voltage in s5m8767_set_voltage
  regulator: fix sysfs name collision between dummy and fixed dummy regulator
  regulator: Fix deadlock on removal of regulators with supplies
  regulator: Fix comments in include/linux/regulator/machine.h
  regulator: Only update [LDOx|DCx]_HIB_MODE bits in wm8350_[ldo|dcdc]_set_suspend_disable
  regulator: Fix setting low power mode for wm831x aldo
  regulator: Return microamps in wm8350_isink_get_current
  regulator: wm8350: Fix the logic to choose best current limit setting
  regulator: wm831x-isink: Fix the logic to choose best current limit setting
  regulator: wm831x-dcdc: Fix the logic to choose best current limit setting
  regulator: anatop: patching to device-tree property "reg".
  regulator: Do proper shift to set correct bit for DC[2|5]_HIB_MODE setting
  regulator: Fix restoring pmic.dcdcx_hib_mode settings in wm8350_dcdc_set_suspend_enable
  regulator: Fix unbalanced lock/unlock in mc13892_regulator_probe error path
  regulator: Fix set and get current limit for wm831x_buckv
  regulator: tps6586x: Fix list minimal voltage setting for LDO0
This commit is contained in:
Linus Torvalds 2012-04-04 10:09:30 -07:00
commit 4a1e8ebc5e
12 changed files with 81 additions and 49 deletions

View File

@ -0,0 +1,29 @@
Anatop Voltage regulators
Required properties:
- compatible: Must be "fsl,anatop-regulator"
- anatop-reg-offset: Anatop MFD register offset
- anatop-vol-bit-shift: Bit shift for the register
- anatop-vol-bit-width: Number of bits used in the register
- anatop-min-bit-val: Minimum value of this register
- anatop-min-voltage: Minimum voltage of this regulator
- anatop-max-voltage: Maximum voltage of this regulator
Any property defined as part of the core regulator
binding, defined in regulator.txt, can also be used.
Example:
regulator-vddpu {
compatible = "fsl,anatop-regulator";
regulator-name = "vddpu";
regulator-min-microvolt = <725000>;
regulator-max-microvolt = <1300000>;
regulator-always-on;
anatop-reg-offset = <0x140>;
anatop-vol-bit-shift = <9>;
anatop-vol-bit-width = <5>;
anatop-min-bit-val = <1>;
anatop-min-voltage = <725000>;
anatop-max-voltage = <1300000>;
};

View File

@ -138,9 +138,10 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev)
rdesc->type = REGULATOR_VOLTAGE;
rdesc->owner = THIS_MODULE;
sreg->mfd = anatopmfd;
ret = of_property_read_u32(np, "reg", &sreg->control_reg);
ret = of_property_read_u32(np, "anatop-reg-offset",
&sreg->control_reg);
if (ret) {
dev_err(dev, "no reg property set\n");
dev_err(dev, "no anatop-reg-offset property set\n");
goto anatop_probe_end;
}
ret = of_property_read_u32(np, "anatop-vol-bit-width",

View File

@ -2992,14 +2992,14 @@ void regulator_unregister(struct regulator_dev *rdev)
if (rdev == NULL)
return;
if (rdev->supply)
regulator_put(rdev->supply);
mutex_lock(&regulator_list_mutex);
debugfs_remove_recursive(rdev->debugfs);
flush_work_sync(&rdev->disable_work.work);
WARN_ON(rdev->open_count);
unset_regulator_supplies(rdev);
list_del(&rdev->list);
if (rdev->supply)
regulator_put(rdev->supply);
kfree(rdev->constraints);
device_unregister(&rdev->dev);
mutex_unlock(&regulator_list_mutex);

View File

@ -18,7 +18,6 @@ static void regulator_fixed_release(struct device *dev)
/**
* regulator_register_fixed - register a no-op fixed regulator
* @name: supply name
* @id: platform device id
* @supplies: consumers for this regulator
* @num_supplies: number of consumers
@ -32,7 +31,7 @@ struct platform_device *regulator_register_fixed(int id,
if (!data)
return NULL;
data->cfg.supply_name = "dummy";
data->cfg.supply_name = "fixed-dummy";
data->cfg.microvolts = 0;
data->cfg.gpio = -EINVAL;
data->cfg.enabled_at_boot = 1;

View File

@ -552,7 +552,7 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
mc13xxx_lock(mc13892);
ret = mc13xxx_reg_read(mc13892, MC13892_REVISION, &val);
if (ret)
goto err_free;
goto err_unlock;
/* enable switch auto mode */
if ((val & 0x0000FFFF) == 0x45d0) {
@ -562,7 +562,7 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
MC13892_SWITCHERS4_SW1MODE_AUTO |
MC13892_SWITCHERS4_SW2MODE_AUTO);
if (ret)
goto err_free;
goto err_unlock;
ret = mc13xxx_reg_rmw(mc13892, MC13892_SWITCHERS5,
MC13892_SWITCHERS5_SW3MODE_M |
@ -570,7 +570,7 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
MC13892_SWITCHERS5_SW3MODE_AUTO |
MC13892_SWITCHERS5_SW4MODE_AUTO);
if (ret)
goto err_free;
goto err_unlock;
}
mc13xxx_unlock(mc13892);
@ -612,10 +612,10 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
err:
while (--i >= 0)
regulator_unregister(priv->regulators[i]);
return ret;
err_free:
err_unlock:
mc13xxx_unlock(mc13892);
return ret;
}

View File

@ -311,8 +311,7 @@ static int s5m8767_set_voltage(struct regulator_dev *rdev,
struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
const struct s5m_voltage_desc *desc;
int reg_id = rdev_get_id(rdev);
int reg, mask, ret;
int i;
int sel, reg, mask, ret;
u8 val;
switch (reg_id) {
@ -333,19 +332,20 @@ static int s5m8767_set_voltage(struct regulator_dev *rdev,
desc = reg_voltage_map[reg_id];
i = s5m8767_convert_voltage_to_sel(desc, min_uV, max_uV);
if (i < 0)
return i;
sel = s5m8767_convert_voltage_to_sel(desc, min_uV, max_uV);
if (sel < 0)
return sel;
ret = s5m8767_get_voltage_register(rdev, &reg);
if (ret)
return ret;
s5m_reg_read(s5m8767->iodev, reg, &val);
val = val & mask;
val &= ~mask;
val |= sel;
ret = s5m_reg_write(s5m8767->iodev, reg, val);
*selector = i;
*selector = sel;
return ret;
}

View File

@ -79,6 +79,11 @@ static int tps6586x_ldo_list_voltage(struct regulator_dev *rdev,
unsigned selector)
{
struct tps6586x_regulator *info = rdev_get_drvdata(rdev);
int rid = rdev_get_id(rdev);
/* LDO0 has minimal voltage 1.2V rather than 1.25V */
if ((rid == TPS6586X_ID_LDO_0) && (selector == 0))
return (info->voltages[0] - 50) * 1000;
return info->voltages[selector] * 1000;
}

View File

@ -380,13 +380,15 @@ static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev,
int i;
for (i = 0; i < ARRAY_SIZE(wm831x_dcdc_ilim); i++) {
if (max_uA <= wm831x_dcdc_ilim[i])
if ((min_uA <= wm831x_dcdc_ilim[i]) &&
(wm831x_dcdc_ilim[i] <= max_uA))
break;
}
if (i == ARRAY_SIZE(wm831x_dcdc_ilim))
return -EINVAL;
return wm831x_set_bits(wm831x, reg, WM831X_DC1_HC_THR_MASK, i);
return wm831x_set_bits(wm831x, reg, WM831X_DC1_HC_THR_MASK,
i << WM831X_DC1_HC_THR_SHIFT);
}
static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)
@ -400,7 +402,8 @@ static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)
if (val < 0)
return val;
return wm831x_dcdc_ilim[val & WM831X_DC1_HC_THR_MASK];
val = (val & WM831X_DC1_HC_THR_MASK) >> WM831X_DC1_HC_THR_SHIFT;
return wm831x_dcdc_ilim[val];
}
static struct regulator_ops wm831x_buckv_ops = {

View File

@ -101,7 +101,7 @@ static int wm831x_isink_set_current(struct regulator_dev *rdev,
for (i = 0; i < ARRAY_SIZE(wm831x_isinkv_values); i++) {
int val = wm831x_isinkv_values[i];
if (min_uA >= val && val <= max_uA) {
if (min_uA <= val && val <= max_uA) {
ret = wm831x_set_bits(wm831x, isink->reg,
WM831X_CS1_ISEL_MASK, i);
return ret;

View File

@ -506,22 +506,19 @@ static int wm831x_aldo_set_mode(struct regulator_dev *rdev,
{
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
struct wm831x *wm831x = ldo->wm831x;
int ctrl_reg = ldo->base + WM831X_LDO_CONTROL;
int on_reg = ldo->base + WM831X_LDO_ON_CONTROL;
int ret;
switch (mode) {
case REGULATOR_MODE_NORMAL:
ret = wm831x_set_bits(wm831x, on_reg,
WM831X_LDO7_ON_MODE, 0);
ret = wm831x_set_bits(wm831x, on_reg, WM831X_LDO7_ON_MODE, 0);
if (ret < 0)
return ret;
break;
case REGULATOR_MODE_IDLE:
ret = wm831x_set_bits(wm831x, ctrl_reg,
WM831X_LDO7_ON_MODE,
ret = wm831x_set_bits(wm831x, on_reg, WM831X_LDO7_ON_MODE,
WM831X_LDO7_ON_MODE);
if (ret < 0)
return ret;

View File

@ -99,7 +99,7 @@ static int get_isink_val(int min_uA, int max_uA, u16 *setting)
{
int i;
for (i = ARRAY_SIZE(isink_cur) - 1; i >= 0; i--) {
for (i = 0; i < ARRAY_SIZE(isink_cur); i++) {
if (min_uA <= isink_cur[i] && max_uA >= isink_cur[i]) {
*setting = i;
return 0;
@ -186,7 +186,7 @@ static int wm8350_isink_get_current(struct regulator_dev *rdev)
return 0;
}
return DIV_ROUND_CLOSEST(isink_cur[val], 100);
return isink_cur[val];
}
/* turn on ISINK followed by DCDC */
@ -495,25 +495,25 @@ static int wm8350_dcdc_set_suspend_enable(struct regulator_dev *rdev)
val = wm8350_reg_read(wm8350, WM8350_DCDC1_LOW_POWER)
& ~WM8350_DCDC_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC1_LOW_POWER,
wm8350->pmic.dcdc1_hib_mode);
val | wm8350->pmic.dcdc1_hib_mode);
break;
case WM8350_DCDC_3:
val = wm8350_reg_read(wm8350, WM8350_DCDC3_LOW_POWER)
& ~WM8350_DCDC_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC3_LOW_POWER,
wm8350->pmic.dcdc3_hib_mode);
val | wm8350->pmic.dcdc3_hib_mode);
break;
case WM8350_DCDC_4:
val = wm8350_reg_read(wm8350, WM8350_DCDC4_LOW_POWER)
& ~WM8350_DCDC_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC4_LOW_POWER,
wm8350->pmic.dcdc4_hib_mode);
val | wm8350->pmic.dcdc4_hib_mode);
break;
case WM8350_DCDC_6:
val = wm8350_reg_read(wm8350, WM8350_DCDC6_LOW_POWER)
& ~WM8350_DCDC_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC6_LOW_POWER,
wm8350->pmic.dcdc6_hib_mode);
val | wm8350->pmic.dcdc6_hib_mode);
break;
case WM8350_DCDC_2:
case WM8350_DCDC_5:
@ -535,25 +535,25 @@ static int wm8350_dcdc_set_suspend_disable(struct regulator_dev *rdev)
val = wm8350_reg_read(wm8350, WM8350_DCDC1_LOW_POWER);
wm8350->pmic.dcdc1_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC1_LOW_POWER,
WM8350_DCDC_HIB_MODE_DIS);
val | WM8350_DCDC_HIB_MODE_DIS);
break;
case WM8350_DCDC_3:
val = wm8350_reg_read(wm8350, WM8350_DCDC3_LOW_POWER);
wm8350->pmic.dcdc3_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC3_LOW_POWER,
WM8350_DCDC_HIB_MODE_DIS);
val | WM8350_DCDC_HIB_MODE_DIS);
break;
case WM8350_DCDC_4:
val = wm8350_reg_read(wm8350, WM8350_DCDC4_LOW_POWER);
wm8350->pmic.dcdc4_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC4_LOW_POWER,
WM8350_DCDC_HIB_MODE_DIS);
val | WM8350_DCDC_HIB_MODE_DIS);
break;
case WM8350_DCDC_6:
val = wm8350_reg_read(wm8350, WM8350_DCDC6_LOW_POWER);
wm8350->pmic.dcdc6_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC6_LOW_POWER,
WM8350_DCDC_HIB_MODE_DIS);
val | WM8350_DCDC_HIB_MODE_DIS);
break;
case WM8350_DCDC_2:
case WM8350_DCDC_5:
@ -575,13 +575,13 @@ static int wm8350_dcdc25_set_suspend_enable(struct regulator_dev *rdev)
val = wm8350_reg_read(wm8350, WM8350_DCDC2_CONTROL)
& ~WM8350_DC2_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC2_CONTROL, val |
WM8350_DC2_HIB_MODE_ACTIVE);
(WM8350_DC2_HIB_MODE_ACTIVE << WM8350_DC2_HIB_MODE_SHIFT));
break;
case WM8350_DCDC_5:
val = wm8350_reg_read(wm8350, WM8350_DCDC5_CONTROL)
& ~WM8350_DC2_HIB_MODE_MASK;
& ~WM8350_DC5_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC5_CONTROL, val |
WM8350_DC5_HIB_MODE_ACTIVE);
(WM8350_DC5_HIB_MODE_ACTIVE << WM8350_DC5_HIB_MODE_SHIFT));
break;
default:
return -EINVAL;
@ -600,13 +600,13 @@ static int wm8350_dcdc25_set_suspend_disable(struct regulator_dev *rdev)
val = wm8350_reg_read(wm8350, WM8350_DCDC2_CONTROL)
& ~WM8350_DC2_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC2_CONTROL, val |
WM8350_DC2_HIB_MODE_DISABLE);
(WM8350_DC2_HIB_MODE_DISABLE << WM8350_DC2_HIB_MODE_SHIFT));
break;
case WM8350_DCDC_5:
val = wm8350_reg_read(wm8350, WM8350_DCDC5_CONTROL)
& ~WM8350_DC2_HIB_MODE_MASK;
& ~WM8350_DC5_HIB_MODE_MASK;
wm8350_reg_write(wm8350, WM8350_DCDC5_CONTROL, val |
WM8350_DC2_HIB_MODE_DISABLE);
(WM8350_DC5_HIB_MODE_DISABLE << WM8350_DC5_HIB_MODE_SHIFT));
break;
default:
return -EINVAL;
@ -749,7 +749,7 @@ static int wm8350_ldo_set_suspend_disable(struct regulator_dev *rdev)
/* all LDOs have same mV bits */
val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_HIB_MODE_MASK;
wm8350_reg_write(wm8350, volt_reg, WM8350_LDO1_HIB_MODE_DIS);
wm8350_reg_write(wm8350, volt_reg, val | WM8350_LDO1_HIB_MODE_DIS);
return 0;
}

View File

@ -71,7 +71,7 @@ struct regulator_state {
* @uV_offset: Offset applied to voltages from consumer to compensate for
* voltage drops.
*
* @min_uA: Smallest consumers consumers may set.
* @min_uA: Smallest current consumers may set.
* @max_uA: Largest current consumers may set.
*
* @valid_modes_mask: Mask of modes which may be configured by consumers.
@ -134,10 +134,8 @@ struct regulation_constraints {
/**
* struct regulator_consumer_supply - supply -> device mapping
*
* This maps a supply name to a device. Only one of dev or dev_name
* can be specified. Use of dev_name allows support for buses which
* make struct device available late such as I2C and is the preferred
* form.
* This maps a supply name to a device. Use of dev_name allows support for
* buses which make struct device available late such as I2C.
*
* @dev_name: Result of dev_name() for the consumer.
* @supply: Name for the supply.