]> git.sur5r.net Git - u-boot/blobdiff - drivers/power/axp209.c
SPDX: Convert all of our single license tags to Linux Kernel style
[u-boot] / drivers / power / axp209.c
index 71aa000daab759b459a4215c71091bcc09b75f16..6de5ec6825804e309e4a70616553488bdb004166 100644 (file)
@@ -1,11 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2012
  * Henrik Nordstrom <henrik@henriknordstrom.net>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <command.h>
 #include <asm/arch/pmic_bus.h>
 #include <axp_pmic.h>
 
@@ -157,7 +157,7 @@ int axp_init(void)
        ver &= 0x0f;
 
        if (ver != 0x1)
-               return -1;
+               return -EINVAL;
 
        /* Mask all interrupts */
        for (i = AXP209_IRQ_ENABLE1; i <= AXP209_IRQ_ENABLE5; i++) {
@@ -166,5 +166,32 @@ int axp_init(void)
                        return rc;
        }
 
+       /*
+        * Turn off LDOIO regulators / tri-state GPIO pins, when rebooting
+        * from android these are sometimes on.
+        */
+       rc = pmic_bus_write(AXP_GPIO0_CTRL, AXP_GPIO_CTRL_INPUT);
+       if (rc)
+               return rc;
+
+       rc = pmic_bus_write(AXP_GPIO1_CTRL, AXP_GPIO_CTRL_INPUT);
+       if (rc)
+               return rc;
+
+       rc = pmic_bus_write(AXP_GPIO2_CTRL, AXP_GPIO_CTRL_INPUT);
+       if (rc)
+               return rc;
+
+       return 0;
+}
+
+int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       pmic_bus_write(AXP209_SHUTDOWN, AXP209_POWEROFF);
+
+       /* infinite loop during shutdown */
+       while (1) {}
+
+       /* not reached */
        return 0;
 }