]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm64: versal-net: Move bootmode decoding out of board code
authorMichal Simek <michal.simek@amd.com>
Tue, 23 Jun 2026 12:53:37 +0000 (14:53 +0200)
committerMichal Simek <michal.simek@amd.com>
Wed, 8 Jul 2026 06:55:51 +0000 (08:55 +0200)
versal_net_get_bootmode() open-coded the
IS_ENABLED(CONFIG_ZYNQMP_FIRMWARE) selection between the firmware call
zynqmp_pm_get_bootmode_reg() and a direct readl() in board code. Like
the Versal change, move the whole function behind an overridable hook so
generic board code stays free of firmware specifics and is ready for
SCMI.

The weak versal_net_get_bootmode() in arch/arm/mach-versal-net does the
plain MMIO read via versal_net_bootmode_reg() and decodes it (used at EL3
and without firmware). When CONFIG_ZYNQMP_FIRMWARE is enabled,
firmware-zynqmp.c provides a strong definition that reads the register
through the firmware call, falling back to the direct read at EL3 where
the SMC path to firmware is unavailable. This preserves the existing
firmware-based bootmode behaviour while removing the firmware interface
from board code; the now unused zynqmp_firmware.h include is dropped.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://patch.msgid.link/be67e9c6d0bc36840a46594413886d2003967c64.1782219202.git.michal.simek@amd.com
arch/arm/mach-versal-net/cpu.c
arch/arm/mach-versal-net/include/mach/sys_proto.h
board/xilinx/versal-net/board.c
drivers/firmware/firmware-zynqmp.c

index 2974d89f90285ae73f37ed190d17322fc46188db..7df7c49ac711352efd876c957c8e20404c3d04b1 100644 (file)
@@ -136,6 +136,21 @@ void versal_net_timer_setup(void)
        debug("timer 0x%llx\n", get_ticks());
 }
 
+u32 versal_net_bootmode_reg(void)
+{
+       return readl(&crp_base->boot_mode_usr);
+}
+
+u8 __weak versal_net_get_bootmode(void)
+{
+       u32 reg = versal_net_bootmode_reg();
+
+       if (reg >> BOOT_MODE_ALT_SHIFT)
+               reg >>= BOOT_MODE_ALT_SHIFT;
+
+       return reg & BOOT_MODES_MASK;
+}
+
 static u32 platform_id, platform_version;
 
 char *soc_name_decode(void)
index 33253ca88bfedbfdc4751ffb4757472d4c469bac..4907dae1108fcc696bc9cef378b7965ad8e6aa89 100644 (file)
@@ -9,3 +9,7 @@
 void mem_map_fill(void);
 /* EL3 clock/timer register setup, called from board_early_init_r() */
 void versal_net_timer_setup(void);
+/* Overridable bootmode decode: weak MMIO default, firmware override */
+u8 versal_net_get_bootmode(void);
+/* Direct MMIO read of the bootmode register (EL3 / no-firmware path) */
+u32 versal_net_bootmode_reg(void);
index 3c69edc22606734d32d7ba0f99094229ca6b1c68..bb099c1e7ca5dd2be806e9ff065a76947a8053fa 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/arch/sys_proto.h>
 #include <dm/device.h>
 #include <dm/uclass.h>
-#include <zynqmp_firmware.h>
 #include <versalpl.h>
 #include "../common/board.h"
 
@@ -69,25 +68,6 @@ int board_early_init_r(void)
        return 0;
 }
 
-static u8 versal_net_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;
-}
-
 int spi_get_env_dev(void)
 {
        struct udevice *dev;
index f3ca0b08762c3f4dece4a3bb29364c76465e8b23..4c4f4c19ae4b109374ba432720447640c1fd8d9e 100644 (file)
@@ -355,6 +355,24 @@ u8 versal_get_bootmode(void)
 }
 #endif
 
+#if defined(CONFIG_ARCH_VERSAL_NET)
+u8 versal_net_get_bootmode(void)
+{
+       u32 reg;
+
+       /* At EL3 the SMC path to firmware is unavailable, read directly */
+       if (current_el() == 3)
+               reg = versal_net_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)
 u32 versal2_pmc_multi_boot(void)
 {