ARM: aarch64: lowlevel: Reset SCTLR_EL3 in arm_cpu_lowlevel_init()
Subsystems (2)
PATCH 1/1 ARM: aarch64: lowlevel: Reset SCTLR_EL3 in arm_cpu_lowlevel_init()
There's no guarantee that when arm_cpu_lowlevel_init() runs at EL3, SCTLR will be in a state we expect it to be. Add code to reset it to a known state, so we'd always start form clean slate. This is also matches what we've been doing non 64-bit ARMs.
Real word motivation for this patch is i.MX8MQ whose rev 2.1 silicon appear to have different mask ROM behaviour where it now leaves MMU enabled if no valid boot source is found. Page table it sets up doesn't include DDR range, so trying to bootstrap the device via JTAG/OpenOCD results in an abort.
The value for SCTLR_ELx_FLAGS was taken from Linux kernel.
--- arch/arm/cpu/lowlevel_64.S | 7 +++++++ arch/arm/include/asm/system.h | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+)
arch/arm/cpu/lowlevel_64.S +7 -0
@@ -12,6 +12,13 @@ ENTRY(arm_cpu_lowlevel_init) orr x0, x0, #(1 << 10) /* 64-bit EL2 */ msr scr_el3, x0 msr cptr_el3, xzr + + mrs x0, sctlr_el3 + ldr x1, =SCTLR_ELx_FLAGS + bic x0, x0, x1 + msr sctlr_el3, x0 + isb + b done 2:
arch/arm/include/asm/system.h +20 -0
@@ -1,6 +1,26 @@#ifndef __ASM_ARM_SYSTEM_H#define __ASM_ARM_SYSTEM_H +#include <linux/const.h> + +/* Common SCTLR_ELx flags. */ +#define SCTLR_ELx_DSSBS (_BITUL(44)) +#define SCTLR_ELx_ENIA (_BITUL(31)) +#define SCTLR_ELx_ENIB (_BITUL(30)) +#define SCTLR_ELx_ENDA (_BITUL(27)) +#define SCTLR_ELx_EE (_BITUL(25)) +#define SCTLR_ELx_IESB (_BITUL(21)) +#define SCTLR_ELx_WXN (_BITUL(19)) +#define SCTLR_ELx_ENDB (_BITUL(13)) +#define SCTLR_ELx_I (_BITUL(12)) +#define SCTLR_ELx_SA (_BITUL(3)) +#define SCTLR_ELx_C (_BITUL(2)) +#define SCTLR_ELx_A (_BITUL(1)) +#define SCTLR_ELx_M (_BITUL(0)) + +#define SCTLR_ELx_FLAGS (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \ + SCTLR_ELx_SA | SCTLR_ELx_I | SCTLR_ELx_IESB) +#if __LINUX_ARM_ARCH__ >=7 #define isb () __asm__ __volatile__ ("isb" : : : "memory")#ifdef CONFIG_CPU_64v8
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 11 lines · Andrey Smirnov
There's no guarantee that when
arm_cpu_lowlevel_init()runs at EL3, SCTLR will be in a state we expect it to be. Add code to reset it to a known state, so we'd always start form clean slate. This is also matches what we've been doing non 64-bit ARMs.Real word motivation for this patch is i.MX8MQ whose rev 2.1 silicon appear to have different mask ROM behaviour where it now leaves MMU enabled if no valid boot source is found. Page table it sets up doesn't include DDR range, so trying to bootstrap the device via JTAG/OpenOCD results in an abort.
Quoted 7 lines
The value for
SCTLR_ELx_FLAGSwas taken from Linux kernel.Signed-off-by Andrey Smirnov <[email protected]>--- arch/arm/cpu/lowlevel_64.S | 7 +++++++ arch/arm/include/asm/system.h | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+)
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox