diff options
author | Hans de Goede <hdegoede@redhat.com> | 2015-10-03 16:12:27 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2015-10-20 18:40:27 +0200 |
commit | 30490b528bafb0298f2fb76a3ed15194e220ba1f (patch) | |
tree | 2e2175e6309c2701766d3fd4c3266920fcd99a10 /drivers/power/axp152.c | |
parent | 514b2d9dbbd4408ba46c221990087229cdf9ca0b (diff) | |
download | u-boot-imx-30490b528bafb0298f2fb76a3ed15194e220ba1f.zip u-boot-imx-30490b528bafb0298f2fb76a3ed15194e220ba1f.tar.gz u-boot-imx-30490b528bafb0298f2fb76a3ed15194e220ba1f.tar.bz2 |
sunxi: power: Use pmic_bus functions for axp152 / axp209 driver
Use the generic pmic_bus helpers for the axp152 / axp209 drivers,
rather then having them define their own register read / write
functions.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
Diffstat (limited to 'drivers/power/axp152.c')
-rw-r--r-- | drivers/power/axp152.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/drivers/power/axp152.c b/drivers/power/axp152.c index c60e4d3..2972586 100644 --- a/drivers/power/axp152.c +++ b/drivers/power/axp152.c @@ -5,19 +5,9 @@ * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> -#include <i2c.h> +#include <asm/arch/pmic_bus.h> #include <axp_pmic.h> -static int axp152_write(enum axp152_reg reg, u8 val) -{ - return i2c_write(0x30, reg, 1, &val, 1); -} - -static int axp152_read(enum axp152_reg reg, u8 *val) -{ - return i2c_read(0x30, reg, 1, val, 1); -} - static u8 axp152_mvolt_to_target(int mvolt, int min, int max, int div) { if (mvolt < min) @@ -36,13 +26,13 @@ int axp_set_dcdc2(unsigned int mvolt) target = axp152_mvolt_to_target(mvolt, 700, 2275, 25); /* Do we really need to be this gentle? It has built-in voltage slope */ - while ((rc = axp152_read(AXP152_DCDC2_VOLTAGE, ¤t)) == 0 && + while ((rc = pmic_bus_read(AXP152_DCDC2_VOLTAGE, ¤t)) == 0 && current != target) { if (current < target) current++; else current--; - rc = axp152_write(AXP152_DCDC2_VOLTAGE, current); + rc = pmic_bus_write(AXP152_DCDC2_VOLTAGE, current); if (rc) break; } @@ -53,21 +43,21 @@ int axp_set_dcdc3(unsigned int mvolt) { u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 50); - return axp152_write(AXP152_DCDC3_VOLTAGE, target); + return pmic_bus_write(AXP152_DCDC3_VOLTAGE, target); } int axp_set_dcdc4(unsigned int mvolt) { u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 25); - return axp152_write(AXP152_DCDC4_VOLTAGE, target); + return pmic_bus_write(AXP152_DCDC4_VOLTAGE, target); } int axp_set_aldo2(unsigned int mvolt) { u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 100); - return axp152_write(AXP152_LDO2_VOLTAGE, target); + return pmic_bus_write(AXP152_LDO2_VOLTAGE, target); } int axp_init(void) @@ -75,7 +65,11 @@ int axp_init(void) u8 ver; int rc; - rc = axp152_read(AXP152_CHIP_VERSION, &ver); + rc = pmic_bus_init(); + if (rc) + return rc; + + rc = pmic_bus_read(AXP152_CHIP_VERSION, &ver); if (rc) return rc; |