[PATCH 03/18] arm64: versal2: Move bootmode decoding out of board code
Michal Simek
michal.simek at amd.com
Tue Jun 23 14:53:28 CEST 2026
versal2_get_bootmode() lived in board code and accessed the CRP boot
mode register with a direct readl(). To keep generic board code free of
SoC register details and ready for firmware/SCMI based access, move the
whole function, including the alt-shift and mask decoding, into
arch/arm/mach-versal2 as a __weak default.
Board code now simply calls versal2_get_bootmode(). When a firmware
based implementation is available and tested it can provide a strong
definition that overrides the weak one at link time; until then only the
weak MMIO version is built.
Signed-off-by: Michal Simek <michal.simek at amd.com>
---
arch/arm/mach-versal2/cpu.c | 15 +++++++++++++++
arch/arm/mach-versal2/include/mach/sys_proto.h | 2 ++
board/amd/versal2/board.c | 15 ---------------
3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/arch/arm/mach-versal2/cpu.c b/arch/arm/mach-versal2/cpu.c
index 0c7a5040cffb..c278dc3d3be5 100644
--- a/arch/arm/mach-versal2/cpu.c
+++ b/arch/arm/mach-versal2/cpu.c
@@ -138,6 +138,21 @@ u32 __weak versal2_pmc_multi_boot(void)
return versal2_multi_boot_reg();
}
+u8 __weak versal2_get_bootmode(void)
+{
+ u8 bootmode;
+ u32 reg;
+
+ reg = readl(&crp_base->boot_mode_usr);
+
+ if (reg >> BOOT_MODE_ALT_SHIFT)
+ reg >>= BOOT_MODE_ALT_SHIFT;
+
+ bootmode = reg & BOOT_MODES_MASK;
+
+ return bootmode;
+}
+
U_BOOT_DRVINFO(soc_amd_versal2) = {
.name = "soc_amd_versal2",
};
diff --git a/arch/arm/mach-versal2/include/mach/sys_proto.h b/arch/arm/mach-versal2/include/mach/sys_proto.h
index e0576754836a..b3118c208e8f 100644
--- a/arch/arm/mach-versal2/include/mach/sys_proto.h
+++ b/arch/arm/mach-versal2/include/mach/sys_proto.h
@@ -17,5 +17,7 @@ void fill_bd_mem_info(void);
u32 versal2_pmc_multi_boot(void);
/* Direct MMIO read of the multiboot register (EL3 / no-firmware path) */
u32 versal2_multi_boot_reg(void);
+/* Weak bootmode decode (MMIO default); a firmware/SCMI build may override */
+u8 versal2_get_bootmode(void);
#endif /* _ASM_ARCH_SYS_PROTO_H */
diff --git a/board/amd/versal2/board.c b/board/amd/versal2/board.c
index 06d144db4f02..c4e88440d64e 100644
--- a/board/amd/versal2/board.c
+++ b/board/amd/versal2/board.c
@@ -176,21 +176,6 @@ int board_early_init_r(void)
return 0;
}
-static u8 versal2_get_bootmode(void)
-{
- u8 bootmode;
- u32 reg = 0;
-
- reg = readl(&crp_base->boot_mode_usr);
-
- if (reg >> BOOT_MODE_ALT_SHIFT)
- reg >>= BOOT_MODE_ALT_SHIFT;
-
- bootmode = reg & BOOT_MODES_MASK;
-
- return bootmode;
-}
-
static u32 versal2_multi_boot(void)
{
u8 bootmode = versal2_get_bootmode();
--
2.43.0
More information about the U-Boot
mailing list