summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-versal/cpu.c15
-rw-r--r--arch/arm/mach-versal/include/mach/sys_proto.h4
-rw-r--r--board/xilinx/versal/board.c20
-rw-r--r--drivers/firmware/firmware-zynqmp.c16
4 files changed, 35 insertions, 20 deletions
diff --git a/arch/arm/mach-versal/cpu.c b/arch/arm/mach-versal/cpu.c
index 7ad93982e8d..5cb013d5f2e 100644
--- a/arch/arm/mach-versal/cpu.c
+++ b/arch/arm/mach-versal/cpu.c
@@ -120,6 +120,21 @@ u32 __weak versal_pmc_multi_boot(void)
return versal_multi_boot_reg();
}
+u32 versal_bootmode_reg(void)
+{
+ return readl(&crp_base->boot_mode_usr);
+}
+
+u8 __weak versal_get_bootmode(void)
+{
+ u32 reg = versal_bootmode_reg();
+
+ if (reg >> BOOT_MODE_ALT_SHIFT)
+ reg >>= BOOT_MODE_ALT_SHIFT;
+
+ return reg & BOOT_MODES_MASK;
+}
+
U_BOOT_DRVINFO(soc_xilinx_versal) = {
.name = "soc_xilinx_versal",
};
diff --git a/arch/arm/mach-versal/include/mach/sys_proto.h b/arch/arm/mach-versal/include/mach/sys_proto.h
index d7ab2549658..f8836db5ef0 100644
--- a/arch/arm/mach-versal/include/mach/sys_proto.h
+++ b/arch/arm/mach-versal/include/mach/sys_proto.h
@@ -21,5 +21,9 @@ void mem_map_fill(void);
u32 versal_pmc_multi_boot(void);
/* Direct MMIO read of the multiboot register (EL3 / no-firmware path) */
u32 versal_multi_boot_reg(void);
+/* Overridable bootmode decode: weak MMIO default, firmware override */
+u8 versal_get_bootmode(void);
+/* Direct MMIO read of the bootmode register (EL3 / no-firmware path) */
+u32 versal_bootmode_reg(void);
#endif /* _ASM_ARCH_SYS_PROTO_H */
diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
index 110490b9672..d0c15fed1e9 100644
--- a/board/xilinx/versal/board.c
+++ b/board/xilinx/versal/board.c
@@ -28,7 +28,6 @@
#include <dm/device.h>
#include <dm/uclass.h>
#include <versalpl.h>
-#include <zynqmp_firmware.h>
#include "../common/board.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -40,25 +39,6 @@ static xilinx_desc versalpl = {
};
#endif
-static u8 versal_get_bootmode(void)
-{
- u8 bootmode;
- u32 reg = 0;
-
- if (IS_ENABLED(CONFIG_ZYNQMP_FIRMWARE) && current_el() != 3) {
- reg = zynqmp_pm_get_bootmode_reg();
- } else {
- 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 versal_multi_boot(void)
{
u8 bootmode = versal_get_bootmode();
diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c
index c8943b8d23a..f3ca0b08762 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -337,6 +337,22 @@ u32 versal_pmc_multi_boot(void)
return zynqmp_pm_get_pmc_multi_boot_reg() & PMC_MULTI_BOOT_MASK;
}
+
+u8 versal_get_bootmode(void)
+{
+ u32 reg;
+
+ /* At EL3 the SMC path to firmware is unavailable, read directly */
+ if (current_el() == 3)
+ reg = versal_bootmode_reg();
+ else
+ reg = zynqmp_pm_get_bootmode_reg();
+
+ if (reg >> BOOT_MODE_ALT_SHIFT)
+ reg >>= BOOT_MODE_ALT_SHIFT;
+
+ return reg & BOOT_MODES_MASK;
+}
#endif
#if defined(CONFIG_ARCH_VERSAL2)