blob: de284c16b0be16e441a8322d9ba103579948a1f1 [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]
Andre Przywara43aa1702025-01-05 21:51:59 +000056//#ifdef CONFIG_MACH_SUN55I_A523
57 mrc p15, 0, lr, cr12, cr12, 5 // ICC_SRE
58 tst lr, #1
59 beq 1f
60 mrc p15, 0, lr, c4, c6, 0 // ICC_PMR
61 str lr, [r0, #20]
62 mrc p15, 0, lr, c12, c12, 7 // ICC_IGRPEN1
63 str lr, [r0, #24]
641:
65//#endif
Andre Przywaraf9872df2025-03-23 11:35:36 +000066
67 ldr r1, =CONFIG_SUNXI_RVBAR_ADDRESS
68 ldr r0, =SUNXI_SRAMC_BASE
69 ldr r0, [r0, #36] // SRAM_VER_REG
70 ands r0, r0, #0xff
71 ldrne r1, =CONFIG_SUNXI_RVBAR_ALTERNATIVE
72#ifdef CONFIG_XPL_BUILD
73 ldr r0, =CONFIG_SPL_TEXT_BASE
Icenowy Zhengbb769d62018-07-21 16:20:22 +080074#else
Andre Przywaraf9872df2025-03-23 11:35:36 +000075 ldr r0, =CONFIG_TEXT_BASE
Icenowy Zhengbb769d62018-07-21 16:20:22 +080076#endif
Andre Przywaraf9872df2025-03-23 11:35:36 +000077 str r0, [r1] // store start address in RVBAR
Andre Przywara46c3d992017-01-02 11:48:36 +000078 dsb sy
79 isb sy
80 mrc 15, 0, r0, cr12, cr0, 2 @ read RMR register
81 orr r0, r0, #3 @ request reset in AArch64
82 mcr 15, 0, r0, cr12, cr0, 2 @ write RMR register
83 isb sy
841: wfi
85 b 1b