X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fpower%2Faxp152.c;h=c4b3fe58a665a82aca18806834665fa945e0ae4a;hb=6fe7fe12ccfe4e3f068e6adb624a3092e7e852c9;hp=c60e4d3efb00bf289968184eb4b8a5a3c35e59b2;hpb=6944aff1ca91e8cf2c373193982cbb0417b4d4cc;p=u-boot diff --git a/drivers/power/axp152.c b/drivers/power/axp152.c index c60e4d3efb..c4b3fe58a6 100644 --- a/drivers/power/axp152.c +++ b/drivers/power/axp152.c @@ -5,19 +5,10 @@ * SPDX-License-Identifier: GPL-2.0+ */ #include -#include +#include +#include #include -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 +27,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 +44,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,12 +66,27 @@ 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; if (ver != 0x05) - return -1; + return -EINVAL; + + return 0; +} + +int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + pmic_bus_write(AXP152_SHUTDOWN, AXP152_POWEROFF); + + /* infinite loop during shutdown */ + while (1) {} + /* not reached */ return 0; }