command: Remove the cmd_tbl_t typedef
[oweals/u-boot.git] / drivers / power / axp818.c
index 3ac05ffefe0120e0e82d7c20e96ed660c5cd0732..0531707c8aa710f61d93a562c801b35d317d4ce5 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * AXP818 driver based on AXP221 driver
  *
@@ -7,11 +8,10 @@
  * Based on axp221.c
  * (C) Copyright 2014 Hans de Goede <hdegoede@redhat.com>
  * (C) Copyright 2013 Oliver Schinagl <oliver@schinagl.nl>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <command.h>
 #include <errno.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/pmic_bus.h>
@@ -162,7 +162,7 @@ int axp_set_dldo(int dldo_num, unsigned int mvolt)
        cfg = axp818_mvolt_to_cfg(mvolt, 700, 3300, 100);
        if (dldo_num == 2 && mvolt > 3300)
                cfg += 1 + axp818_mvolt_to_cfg(mvolt, 3400, 4200, 200);
-       ret = pmic_bus_write(AXP818_ELDO1_CTRL + (dldo_num - 1), cfg);
+       ret = pmic_bus_write(AXP818_DLDO1_CTRL + (dldo_num - 1), cfg);
        if (ret)
                return ret;
 
@@ -225,6 +225,16 @@ int axp_set_fldo(int fldo_num, unsigned int mvolt)
                                AXP818_OUTPUT_CTRL3_FLDO1_EN << (fldo_num - 1));
 }
 
+int axp_set_sw(bool on)
+{
+       if (on)
+               return pmic_bus_setbits(AXP818_OUTPUT_CTRL2,
+                                       AXP818_OUTPUT_CTRL2_SW_EN);
+
+       return pmic_bus_clrbits(AXP818_OUTPUT_CTRL2,
+                               AXP818_OUTPUT_CTRL2_SW_EN);
+}
+
 int axp_init(void)
 {
        u8 axp_chip_id;
@@ -245,3 +255,14 @@ int axp_init(void)
 
        return 0;
 }
+
+int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+       pmic_bus_write(AXP818_SHUTDOWN, AXP818_SHUTDOWN_POWEROFF);
+
+       /* infinite loop during shutdown */
+       while (1) {}
+
+       /* not reached */
+       return 0;
+}