summaryrefslogtreecommitdiff
path: root/plat/allwinner
diff options
context:
space:
mode:
authorIcenowy Zheng <icenowy@aosc.io>2018-07-22 21:52:50 +0800
committerIcenowy Zheng <icenowy@aosc.io>2018-09-07 23:20:17 +0800
commit5069c1cfef76cc86e6ad15bdd75b9330c3181e76 (patch)
tree36be7f1ac094359bd22f0bd384f2cd9fab90b1e5 /plat/allwinner
parent6d37282807c8540319777cb50f411a2e56607438 (diff)
allwinner: implement system power down on H6 w/ AXP805
The AXP805 PMIC used with H6 is capable of shutting down the system. Add support for using it to shut down the system power. The original placeholder power off code is moved to A64 code, as it's still TODO to implement PMIC operations for A64. Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Diffstat (limited to 'plat/allwinner')
-rw-r--r--plat/allwinner/common/sunxi_pm.c4
-rw-r--r--plat/allwinner/common/sunxi_private.h2
-rw-r--r--plat/allwinner/sun50i_a64/sunxi_power.c8
-rw-r--r--plat/allwinner/sun50i_h6/sunxi_power.c22
4 files changed, 33 insertions, 3 deletions
diff --git a/plat/allwinner/common/sunxi_pm.c b/plat/allwinner/common/sunxi_pm.c
index 2a1f2231..e4bb5822 100644
--- a/plat/allwinner/common/sunxi_pm.c
+++ b/plat/allwinner/common/sunxi_pm.c
@@ -54,9 +54,7 @@ static void __dead2 sunxi_system_off(void)
/* Turn off all secondary CPUs */
sunxi_disable_secondary_cpus(plat_my_core_pos());
- ERROR("PSCI: Full shutdown not implemented, halting\n");
- wfi();
- panic();
+ sunxi_power_down();
}
static void __dead2 sunxi_system_reset(void)
diff --git a/plat/allwinner/common/sunxi_private.h b/plat/allwinner/common/sunxi_private.h
index 49a5c50d..20fa23e6 100644
--- a/plat/allwinner/common/sunxi_private.h
+++ b/plat/allwinner/common/sunxi_private.h
@@ -17,4 +17,6 @@ uint16_t sunxi_read_soc_id(void);
void sunxi_pmic_setup(void);
void sunxi_security_setup(void);
+void __dead2 sunxi_power_down(void);
+
#endif /* __SUNXI_PRIVATE_H__ */
diff --git a/plat/allwinner/sun50i_a64/sunxi_power.c b/plat/allwinner/sun50i_a64/sunxi_power.c
index 50eaa6b9..c1907d6d 100644
--- a/plat/allwinner/sun50i_a64/sunxi_power.c
+++ b/plat/allwinner/sun50i_a64/sunxi_power.c
@@ -5,6 +5,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <arch_helpers.h>
#include <debug.h>
int sunxi_pmic_setup(void)
@@ -14,3 +15,10 @@ int sunxi_pmic_setup(void)
return 0;
}
+
+void __dead2 sunxi_power_down(void)
+{
+ ERROR("PSCI: Full shutdown not implemented, halting\n");
+ wfi();
+ panic();
+}
diff --git a/plat/allwinner/sun50i_h6/sunxi_power.c b/plat/allwinner/sun50i_h6/sunxi_power.c
index 3638a199..f109ccec 100644
--- a/plat/allwinner/sun50i_h6/sunxi_power.c
+++ b/plat/allwinner/sun50i_h6/sunxi_power.c
@@ -5,6 +5,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <arch_helpers.h>
#include <debug.h>
#include <delay_timer.h>
#include <errno.h>
@@ -119,3 +120,24 @@ int sunxi_pmic_setup(void)
return 0;
}
+
+void __dead2 sunxi_power_down(void)
+{
+ uint8_t val;
+
+ switch (pmic) {
+ case AXP805:
+ val = 0x26; /* Default value for REG 32H */
+ axp_i2c_read(AXP805_ADDR, 0x32, &val);
+ val |= 0x80;
+ axp_i2c_write(AXP805_ADDR, 0x32, val);
+ break;
+ default:
+ break;
+ }
+
+ udelay(1000);
+ ERROR("PSCI: Cannot communicate with PMIC, halting\n");
+ wfi();
+ panic();
+}