summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/ab8500.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-04-17 00:50:20 +0800
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-17 15:09:27 +0100
commitb4d12a79295ca216008af7970f208c6051fd408d (patch)
tree4f7f5129e971191046cd49f9411248e480dc8786 /drivers/regulator/ab8500.c
parent7384744d2de1638b5aa9cbe9f743e9067cb6a44a (diff)
regulator: ab8500: Fix set voltage for AB8540_LDO_AUX3
When setting voltage for AB8540_LDO_AUX3, current code only updates one of info->voltage_reg and info->expand_register registers which is wrong. To ensure we set to correct voltage, it always needs to clear or set expand_register.voltage_mask bit of expand_register. The function of the expand register bit is the following (from the user manual): 0: VAUX3 output voltage is determined by Vaux3Sel bit settings in register VldoCVaux3Sel 1: VAUX3 output voltage is set to 3.05V regardless of Vaux3Sel settings in register VldoCVaux3Sel (VldoCVaux3Sel is the register at 0x0421) So when going to 3.05V, set the expand register bit. When leaving 3.05V for another voltage, set the target voltage before clearing the expand register bit. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/ab8500.c')
-rw-r--r--drivers/regulator/ab8500.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 109ce3dcf53..279793e26d9 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -589,39 +589,52 @@ static int ab8540_aux3_regulator_set_voltage_sel(struct regulator_dev *rdev,
{
int ret;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
- u8 regval;
+ u8 regval, regval_expand;
if (info == NULL) {
dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
}
- if (selector >= info->expand_register.voltage_limit) {
- /* Vaux3 bit4 has different layout */
- regval = (u8)selector << info->expand_register.voltage_shift;
- ret = abx500_mask_and_set_register_interruptible(info->dev,
- info->expand_register.voltage_bank,
- info->expand_register.voltage_reg,
- info->expand_register.voltage_mask,
- regval);
- } else {
- /* set the registers for the request */
+ if (selector < info->expand_register.voltage_limit) {
regval = (u8)selector << info->voltage_shift;
ret = abx500_mask_and_set_register_interruptible(info->dev,
- info->voltage_bank, info->voltage_reg,
- info->voltage_mask, regval);
+ info->voltage_bank, info->voltage_reg,
+ info->voltage_mask, regval);
+ if (ret < 0) {
+ dev_err(rdev_get_dev(rdev),
+ "couldn't set voltage reg for regulator\n");
+ return ret;
+ }
+
+ dev_vdbg(rdev_get_dev(rdev),
+ "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
+ info->desc.name, info->voltage_bank, info->voltage_reg,
+ info->voltage_mask, regval);
+
+ regval_expand = 0;
+ } else {
+ regval_expand = info->expand_register.voltage_mask;
}
- if (ret < 0)
+
+ ret = abx500_mask_and_set_register_interruptible(info->dev,
+ info->expand_register.voltage_bank,
+ info->expand_register.voltage_reg,
+ info->expand_register.voltage_mask,
+ regval_expand);
+ if (ret < 0) {
dev_err(rdev_get_dev(rdev),
- "couldn't set voltage reg for regulator\n");
+ "couldn't set expand voltage reg for regulator\n");
+ return ret;
+ }
dev_vdbg(rdev_get_dev(rdev),
- "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
- " 0x%x\n",
- info->desc.name, info->voltage_bank, info->voltage_reg,
- info->voltage_mask, regval);
+ "%s-set_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
+ info->desc.name, info->expand_register.voltage_bank,
+ info->expand_register.voltage_reg,
+ info->expand_register.voltage_mask, regval_expand);
- return ret;
+ return 0;
}
static struct regulator_ops ab8500_regulator_volt_mode_ops = {