diff options
author | Samuel Holland <samuel@sholland.org> | 2021-01-16 01:58:22 -0600 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2021-01-24 17:17:22 -0600 |
commit | dae98b3a986c69517e59e3a1eb08e2b22225cb2d (patch) | |
tree | e8af94fa3c277af1782acea244d71c3e7b6ae611 /plat/allwinner | |
parent | 975d076d4aef260fd9adfbabc6339fe05eed21c1 (diff) | |
download | arm-trusted-firmware-dae98b3a986c69517e59e3a1eb08e2b22225cb2d.tar.gz |
allwinner: psci: Improve system shutdown/reset sequence
- When the SCPI shutdown/reset command returns success, the SCP 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>
Diffstat (limited to 'plat/allwinner')
-rw-r--r-- | plat/allwinner/common/sunxi_pm.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/plat/allwinner/common/sunxi_pm.c b/plat/allwinner/common/sunxi_pm.c index e6e913396..4e1a02882 100644 --- a/plat/allwinner/common/sunxi_pm.c +++ b/plat/allwinner/common/sunxi_pm.c @@ -125,19 +125,20 @@ static void __dead2 sunxi_system_off(void) /* 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(); + } - /* Turn off all secondary CPUs */ - sunxi_cpu_power_off_others(); + ERROR("PSCI: SCPI %s failed: %d\n", "shutdown", ret); + } + /* Attempt to power down the board (may not return) */ sunxi_power_down(); - udelay(1000); - ERROR("PSCI: Cannot turn off system, halting\n"); - wfi(); - panic(); + /* Turn off all CPUs */ + sunxi_cpu_power_off_others(); + sunxi_cpu_power_off_self(); + psci_power_down_wfi(); } static void __dead2 sunxi_system_reset(void) @@ -148,8 +149,11 @@ 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 */ @@ -160,7 +164,6 @@ static void __dead2 sunxi_system_reset(void) mdelay(1000); ERROR("PSCI: System reset failed\n"); - wfi(); panic(); } |