1 // SPDX-License-Identifier: GPL-2.0+
8 #include <asm/arch/pmic_bus.h>
11 static u8 axp152_mvolt_to_target(int mvolt, int min, int max, int div)
18 return (mvolt - min) / div;
21 int axp_set_dcdc2(unsigned int mvolt)
26 target = axp152_mvolt_to_target(mvolt, 700, 2275, 25);
28 /* Do we really need to be this gentle? It has built-in voltage slope */
29 while ((rc = pmic_bus_read(AXP152_DCDC2_VOLTAGE, ¤t)) == 0 &&
35 rc = pmic_bus_write(AXP152_DCDC2_VOLTAGE, current);
42 int axp_set_dcdc3(unsigned int mvolt)
44 u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 50);
46 return pmic_bus_write(AXP152_DCDC3_VOLTAGE, target);
49 int axp_set_dcdc4(unsigned int mvolt)
51 u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 25);
53 return pmic_bus_write(AXP152_DCDC4_VOLTAGE, target);
56 int axp_set_aldo2(unsigned int mvolt)
58 u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 100);
60 return pmic_bus_write(AXP152_LDO2_VOLTAGE, target);
72 rc = pmic_bus_read(AXP152_CHIP_VERSION, &ver);
82 #if !IS_ENABLED(CONFIG_SYSRESET_CMD_POWEROFF)
83 int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
85 pmic_bus_write(AXP152_SHUTDOWN, AXP152_POWEROFF);
87 /* infinite loop during shutdown */