mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-30 14:16:40 +00:00
Allwinner: atf: fix shutdown sequence
This commit is contained in:
parent
c3d5c939fd
commit
46ce96c954
@ -0,0 +1,82 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Samuel Holland <samuel@sholland.org>
|
||||||
|
Date: Sat, 16 Jan 2021 01:58:22 -0600
|
||||||
|
Subject: [PATCH] allwinner: psci: Improve system shutdown/reset sequence
|
||||||
|
|
||||||
|
- When the SCPI shutdown/reset command returns success, the SCPI
|
||||||
|
implementation is still waiting for the CPU to enter WFI. Do that.
|
||||||
|
- Peform board-level poweroff before CPU poweroff. If there is a PMIC
|
||||||
|
available, it will turn everything off including the CPUs, so doing
|
||||||
|
CPU poweroff first is a waste of cycles.
|
||||||
|
- During poweroff, attempt to turn off the local CPU using the ARISC.
|
||||||
|
This should use slightly less power than just an infinite WFI.
|
||||||
|
- Drop the WFI in the reset failure path. The panic will hang anyway.
|
||||||
|
|
||||||
|
Change-Id: I897efecb3fe4e77a56041b97dd273156ec51ef8e
|
||||||
|
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
||||||
|
---
|
||||||
|
plat/allwinner/common/sunxi_pm.c | 26 ++++++++++++++++----------
|
||||||
|
1 file changed, 16 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/plat/allwinner/common/sunxi_pm.c b/plat/allwinner/common/sunxi_pm.c
|
||||||
|
index 03985f40be55..038f2b7edb2f 100644
|
||||||
|
--- a/plat/allwinner/common/sunxi_pm.c
|
||||||
|
+++ b/plat/allwinner/common/sunxi_pm.c
|
||||||
|
@@ -125,24 +125,29 @@ static void sunxi_pwr_domain_on_finish(const psci_power_state_t *target_state)
|
||||||
|
|
||||||
|
static void __dead2 sunxi_system_off(void)
|
||||||
|
{
|
||||||
|
+ u_register_t mpidr = read_mpidr();
|
||||||
|
+
|
||||||
|
gicv2_cpuif_disable();
|
||||||
|
|
||||||
|
if (scpi_available) {
|
||||||
|
/* Send the power down request to the SCP */
|
||||||
|
uint32_t ret = scpi_sys_power_state(scpi_system_shutdown);
|
||||||
|
|
||||||
|
- if (ret != SCP_OK)
|
||||||
|
- ERROR("PSCI: SCPI %s failed: %d\n", "shutdown", ret);
|
||||||
|
+ if (ret == SCP_OK)
|
||||||
|
+ wfi();
|
||||||
|
+
|
||||||
|
+ ERROR("PSCI: SCPI %s failed: %d\n", "shutdown", ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
- /* Turn off all secondary CPUs */
|
||||||
|
- sunxi_disable_secondary_cpus(read_mpidr());
|
||||||
|
-
|
||||||
|
+ /* Attempt to power down the board (may not return) */
|
||||||
|
sunxi_power_down();
|
||||||
|
|
||||||
|
- udelay(1000);
|
||||||
|
+ /* Turn off all CPUs */
|
||||||
|
+ sunxi_disable_secondary_cpus(mpidr);
|
||||||
|
+ sunxi_cpu_off(mpidr);
|
||||||
|
+ wfi();
|
||||||
|
+
|
||||||
|
ERROR("PSCI: Cannot turn off system, halting\n");
|
||||||
|
- wfi();
|
||||||
|
panic();
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -154,8 +159,10 @@ static void __dead2 sunxi_system_reset(void)
|
||||||
|
/* Send the system reset request to the SCP */
|
||||||
|
uint32_t ret = scpi_sys_power_state(scpi_system_reboot);
|
||||||
|
|
||||||
|
- if (ret != SCP_OK)
|
||||||
|
- ERROR("PSCI: SCPI %s failed: %d\n", "reboot", ret);
|
||||||
|
+ if (ret == SCP_OK)
|
||||||
|
+ wfi();
|
||||||
|
+
|
||||||
|
+ ERROR("PSCI: SCPI %s failed: %d\n", "reboot", ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset the whole system when the watchdog times out */
|
||||||
|
@@ -166,7 +173,6 @@ static void __dead2 sunxi_system_reset(void)
|
||||||
|
mdelay(1000);
|
||||||
|
|
||||||
|
ERROR("PSCI: System reset failed\n");
|
||||||
|
- wfi();
|
||||||
|
panic();
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user