blob: 422007c985b6eb98a7d9d8e8b7e5a415e0ae6eae [file] [log] [blame]
Andre Przywara46c3d992017-01-02 11:48:36 +00001@
2@ ARMv8 RMR reset sequence on Allwinner SoCs.
3@
4@ All 64-bit capable Allwinner SoCs reset in AArch32 (and continue to
5@ exectute the Boot ROM in this state), so we need to switch to AArch64
6@ at some point.
7@ Section G6.2.133 of the ARMv8 ARM describes the Reset Management Register
8@ (RMR), which triggers a warm-reset of a core and can request to switch
9@ into a different execution state (AArch32 or AArch64).
10@ The address at which execution starts after the reset is held in the
11@ RVBAR system register, which is architecturally read-only.
12@ Allwinner provides a writable alias of this register in MMIO space, so
13@ we can easily set the start address of AArch64 code.
14@ This code below switches to AArch64 and starts execution at the specified
15@ start address. It needs to be assembled by an ARM(32) assembler and
16@ the machine code must be inserted as verbatim .word statements into the
17@ beginning of the AArch64 U-Boot code.
18@ To get the encoded bytes, use:
Andre Przywaraf9872df2025-03-23 11:35:36 +000019@ ${CROSS_COMPILE}gcc -c -Iinclude -Iarch/arm/include \
20@ -D__ASSEMBLY__ -DCONFIG_ARM64 \
21@ -o rmr_switch.o arch/arm/mach-sunxi/rmr_switch.S
Andre Przywara46c3d992017-01-02 11:48:36 +000022@ ${CROSS_COMPILE}objdump -d rmr_switch.o
23@
24@ The resulting words should be inserted into the U-Boot file at
25@ arch/arm/include/asm/arch-sunxi/boot0.h.
26@
27@ This file is not build by the U-Boot build system, but provided only as a
28@ reference and to be able to regenerate a (probably fixed) version of this
29@ code found in encoded form in boot0.h.
30
Icenowy Zhengbb769d62018-07-21 16:20:22 +080031#include <config.h>
32
Andre Przywara46c3d992017-01-02 11:48:36 +000033.text
Andre Przywaraf9872df2025-03-23 11:35:36 +000034 b start32 // this is "tst x0, x0" in AArch64
35 .word 0x14000047 // this is "b reset" in AArch64
Andre Przywara46c3d992017-01-02 11:48:36 +000036
Andre Przywaraf9872df2025-03-23 11:35:36 +000037 .space 0x78 // gap distance set by the common
38 // encoding of the first instruction
39fel_stash_addr:
40 .word fel_stash - . // distance to fel_stash buffer
41
42start32:
43 adr r0, fel_stash_addr // absolute location of fel_stash_addr
44 ldr r1, fel_stash_addr // distance to actual fel_stash
45 add r0, r0, r1 // real address of fel_stash
46
47 /* save the current state as needed by the BROM for a later return */
48 str sp, [r0]
49 str lr, [r0, #4]
50 mrs lr, CPSR
51 str lr, [r0, #8]
52 mrc p15, 0, lr, cr1, cr0, 0 // SCTLR
53 str lr, [r0, #12]
54 mrc p15, 0, lr, cr12, cr0, 0 // VBAR
55 str lr, [r0, #16]
56
57 ldr r1, =CONFIG_SUNXI_RVBAR_ADDRESS
58 ldr r0, =SUNXI_SRAMC_BASE
59 ldr r0, [r0, #36] // SRAM_VER_REG
60 ands r0, r0, #0xff
61 ldrne r1, =CONFIG_SUNXI_RVBAR_ALTERNATIVE
62#ifdef CONFIG_XPL_BUILD
63 ldr r0, =CONFIG_SPL_TEXT_BASE
Icenowy Zhengbb769d62018-07-21 16:20:22 +080064#else
Andre Przywaraf9872df2025-03-23 11:35:36 +000065 ldr r0, =CONFIG_TEXT_BASE
Icenowy Zhengbb769d62018-07-21 16:20:22 +080066#endif
Andre Przywaraf9872df2025-03-23 11:35:36 +000067 str r0, [r1] // store start address in RVBAR
Andre Przywara46c3d992017-01-02 11:48:36 +000068 dsb sy
69 isb sy
70 mrc 15, 0, r0, cr12, cr0, 2 @ read RMR register
71 orr r0, r0, #3 @ request reset in AArch64
72 mcr 15, 0, r0, cr12, cr0, 2 @ write RMR register
73 isb sy
741: wfi
75 b 1b