summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2016-05-02 10:28:10 +0800
committerHans de Goede <hdegoede@redhat.com>2016-05-25 17:52:39 +0200
commitaa23f539c88418333fb5300051642bc9b99d17b2 (patch)
tree8265b80f4c8d8a57f0a98f5836d3a61056381f7f /drivers/power
parent5af116b560d8a6e0b11d6239b5a8f783f9ac6fd1 (diff)
downloadu-boot-imx-aa23f539c88418333fb5300051642bc9b99d17b2.zip
u-boot-imx-aa23f539c88418333fb5300051642bc9b99d17b2.tar.gz
u-boot-imx-aa23f539c88418333fb5300051642bc9b99d17b2.tar.bz2
power: axp221: Remove switch case to simplify axp_set_eldo
The ELDO enable bits and registers are contiguous for axp221. Instead of a switch case testing against the index, just use the index to shift the bit or register offset. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/axp221.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c
index cb1f88b..727ab09 100644
--- a/drivers/power/axp221.c
+++ b/drivers/power/axp221.c
@@ -191,33 +191,20 @@ int axp_set_eldo(int eldo_num, unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
- u8 addr, bits;
-
- switch (eldo_num) {
- case 3:
- addr = AXP221_ELDO3_CTRL;
- bits = AXP221_OUTPUT_CTRL2_ELDO3_EN;
- break;
- case 2:
- addr = AXP221_ELDO2_CTRL;
- bits = AXP221_OUTPUT_CTRL2_ELDO2_EN;
- break;
- case 1:
- addr = AXP221_ELDO1_CTRL;
- bits = AXP221_OUTPUT_CTRL2_ELDO1_EN;
- break;
- default:
+
+ if (eldo_num < 1 || eldo_num > 3)
return -EINVAL;
- }
if (mvolt == 0)
- return pmic_bus_clrbits(AXP221_OUTPUT_CTRL2, bits);
+ return pmic_bus_clrbits(AXP221_OUTPUT_CTRL2,
+ AXP221_OUTPUT_CTRL2_ELDO1_EN << (eldo_num - 1));
- ret = pmic_bus_write(addr, cfg);
+ ret = pmic_bus_write(AXP221_ELDO1_CTRL + (eldo_num - 1), cfg);
if (ret)
return ret;
- return pmic_bus_setbits(AXP221_OUTPUT_CTRL2, bits);
+ return pmic_bus_setbits(AXP221_OUTPUT_CTRL2,
+ AXP221_OUTPUT_CTRL2_ELDO1_EN << (eldo_num - 1));
}
int axp_init(void)