From: Chee Hong Ang <[email protected]>

SPL checks for magic word in system manager's scratch register
to find out whether the system has performed L2 reset. If L2
reset was performed, SPL put all slave CPUs (CPU1-3) into WFI
mode. Master CPU (CPU0) requests warm reset via RMR_EL3 system
register and put itself into WFI mode. Firmware will get the
warm reset request from HPS and perform the warm reset sequence
to reboot all the HPS cores.

Signed-off-by: Chee Hong Ang <[email protected]>
Signed-off-by: Jit Loon Lim <[email protected]>
---
 arch/arm/mach-socfpga/lowlevel_init_soc64.S | 24 +++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/mach-socfpga/lowlevel_init_soc64.S 
b/arch/arm/mach-socfpga/lowlevel_init_soc64.S
index 875927cc4d..1fd0a50b3a 100644
--- a/arch/arm/mach-socfpga/lowlevel_init_soc64.S
+++ b/arch/arm/mach-socfpga/lowlevel_init_soc64.S
@@ -12,6 +12,30 @@
 ENTRY(lowlevel_init)
        mov     x29, lr                 /* Save LR */
 
+#ifdef CONFIG_SPL_BUILD
+       /* Check for L2 reset magic word */
+       ldr     x4, =L2_RESET_DONE_REG
+       ldr     x5, [x4]
+       ldr     x1, =L2_RESET_DONE_STATUS
+       cmp     x1, x5
+       /* No L2 reset, skip warm reset */
+       b.ne    skipwarmreset
+       /* L2 reset completed */
+       str     xzr, [x4]
+       /* Put all slaves CPUs into WFI mode */
+       branch_if_slave x0, put_cpu_in_wfi
+       /* Master CPU (CPU0) request for warm reset */
+       mrs     x1, rmr_el3
+       orr     x1, x1, #0x02
+       msr     rmr_el3, x1
+       isb
+       dsb     sy
+put_cpu_in_wfi:
+       wfi
+       b       put_cpu_in_wfi
+skipwarmreset:
+#endif
+
 #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)
 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_ATF)
 wait_for_atf:
-- 
2.26.2

Reply via email to