aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/ab8500.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-04-16 12:50:20 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-17 10:09:27 -0400
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 109ce3dcf533..279793e26d94 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,
589{ 589{
590 int ret; 590 int ret;
591 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 591 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
592 u8 regval; 592 u8 regval, regval_expand;
593 593
594 if (info == NULL) { 594 if (info == NULL) {
595 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); 595 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
596 return -EINVAL; 596 return -EINVAL;
597 } 597 }
598 598
599 if (selector >= info->expand_register.voltage_limit) { 599 if (selector < info->expand_register.voltage_limit) {
600 /* Vaux3 bit4 has different layout */
601 regval = (u8)selector << info->expand_register.voltage_shift;
602 ret = abx500_mask_and_set_register_interruptible(info->dev,
603 info->expand_register.voltage_bank,
604 info->expand_register.voltage_reg,
605 info->expand_register.voltage_mask,
606 regval);
607 } else {
608 /* set the registers for the request */
609 regval = (u8)selector << info->voltage_shift; 600 regval = (u8)selector << info->voltage_shift;
610 ret = abx500_mask_and_set_register_interruptible(info->dev, 601 ret = abx500_mask_and_set_register_interruptible(info->dev,
611 info->voltage_bank, info->voltage_reg, 602 info->voltage_bank, info->voltage_reg,
612 info->voltage_mask, regval); 603 info->voltage_mask, regval);
604 if (ret < 0) {
605 dev_err(rdev_get_dev(rdev),
606 "couldn't set voltage reg for regulator\n");
607 return ret;
608 }
609
610 dev_vdbg(rdev_get_dev(rdev),
611 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
612 info->desc.name, info->voltage_bank, info->voltage_reg,
613 info->voltage_mask, regval);
614
615 regval_expand = 0;
616 } else {
617 regval_expand = info->expand_register.voltage_mask;
613 } 618 }
614 if (ret < 0) 619
620 ret = abx500_mask_and_set_register_interruptible(info->dev,
621 info->expand_register.voltage_bank,
622 info->expand_register.voltage_reg,
623 info->expand_register.voltage_mask,
624 regval_expand);
625 if (ret < 0) {
615 dev_err(rdev_get_dev(rdev), 626 dev_err(rdev_get_dev(rdev),
616 "couldn't set voltage reg for regulator\n"); 627 "couldn't set expand voltage reg for regulator\n");
628 return ret;
629 }
617 630
618 dev_vdbg(rdev_get_dev(rdev), 631 dev_vdbg(rdev_get_dev(rdev),
619 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," 632 "%s-set_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
620 " 0x%x\n", 633 info->desc.name, info->expand_register.voltage_bank,
621 info->desc.name, info->voltage_bank, info->voltage_reg, 634 info->expand_register.voltage_reg,
622 info->voltage_mask, regval); 635 info->expand_register.voltage_mask, regval_expand);
623 636
624 return ret; 637 return 0;
625} 638}
626 639
627static struct regulator_ops ab8500_regulator_volt_mode_ops = { 640static struct regulator_ops ab8500_regulator_volt_mode_ops = {