3 * Henrik Nordstrom <henrik@henriknordstrom.net>
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <asm/arch/pmic_bus.h>
12 static u8 axp152_mvolt_to_target(int mvolt, int min, int max, int div)
19 return (mvolt - min) / div;
22 int axp_set_dcdc2(unsigned int mvolt)
27 target = axp152_mvolt_to_target(mvolt, 700, 2275, 25);
29 /* Do we really need to be this gentle? It has built-in voltage slope */
30 while ((rc = pmic_bus_read(AXP152_DCDC2_VOLTAGE, ¤t)) == 0 &&
36 rc = pmic_bus_write(AXP152_DCDC2_VOLTAGE, current);
43 int axp_set_dcdc3(unsigned int mvolt)
45 u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 50);
47 return pmic_bus_write(AXP152_DCDC3_VOLTAGE, target);
50 int axp_set_dcdc4(unsigned int mvolt)
52 u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 25);
54 return pmic_bus_write(AXP152_DCDC4_VOLTAGE, target);
57 int axp_set_aldo2(unsigned int mvolt)
59 u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 100);
61 return pmic_bus_write(AXP152_LDO2_VOLTAGE, target);
73 rc = pmic_bus_read(AXP152_CHIP_VERSION, &ver);
83 int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
85 pmic_bus_write(AXP152_SHUTDOWN, AXP152_POWEROFF);
87 /* infinite loop during shutdown */