sunxi: Add arm64 FEL support
authorAndre Przywara <andre.przywara@arm.com>
Tue, 23 Aug 2016 21:19:30 +0000 (22:19 +0100)
committerAndre Przywara <andre.przywara@arm.com>
Mon, 11 Jan 2021 23:19:34 +0000 (23:19 +0000)
commit0e4d5db4e0379da9ca4eee00dbca9773d8718e8e
treee98ce2b0f5e746d517d494556e489beacc1744d5
parent00f8e9c2da2a4aaeb762652e4f029d796eec3c86
sunxi: Add arm64 FEL support

So far we did not support the BootROM based FEL USB debug mode on the
64-bit builds for Allwinner SoCs: The BootROM is using AArch32, but the
SPL runs in AArch64.
Returning back to AArch32 was not working as expected, since the RMR
reset into 32-bit mode always starts execution in the BootROM, but not
in the FEL routine.

After some debug and research and with help via IRC, the CPU hotplug
mechanism emerged as a solution: If a certain R_CPUCFG register contains
some magic, the BootROM will immediately branch to an address stored in
some other register. This works well for our purposes.

Enable the FEL feature by providing early AArch32 code to first save the
FEL state, *before* initially entering AArch64.
If we eventually determine that we should return to FEL, we reset back
into AArch32, and use the CPU hotplug mechanism to run some small
AArch32 code snippet that restores the initially saved FEL state.

That allows the normal AArch64 SPL build to be loaded via the sunxi-fel
tool, with it returning into FEL mode, so that other payloads can be
transferred via FEL as well.

Tested on A64, H5 and H6.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Icenowy Zheng <icenowy@aosc.io>
Acked-by: Jagan Teki <jagan@amarulasolutions.com>
Tested-by: Priit Laes <plaes@plaes.org> (on Olimex A64-Olinuxino)
arch/arm/cpu/armv8/Makefile
arch/arm/cpu/armv8/fel_utils.S [new file with mode: 0644]
arch/arm/include/asm/arch-sunxi/boot0.h
include/configs/sunxi-common.h