[PATCH 14/18] arm64: versal-net: Deduplicate SPI bootmode handling
Michal Simek
michal.simek at amd.com
Tue Jun 23 14:53:39 CEST 2026
spi_get_env_dev() and boot_targets_setup() both decoded the QSPI/OSPI
boot modes into a SPI device sequence number with identical
uclass_get_device_by_name() lookups.
Factor that logic into a single spi_get_bootseq() helper that takes the
bootmode and returns the device sequence. spi_get_env_dev() becomes a
thin wrapper around it, and boot_targets_setup() calls it for the
QSPI/OSPI cases instead of open-coding the lookups. Passing the bootmode
in avoids reading the bootmode register twice in boot_targets_setup().
No functional change.
Signed-off-by: Michal Simek <michal.simek at amd.com>
---
board/xilinx/versal-net/board.c | 38 +++++++++------------------------
1 file changed, 10 insertions(+), 28 deletions(-)
diff --git a/board/xilinx/versal-net/board.c b/board/xilinx/versal-net/board.c
index bb099c1e7ca5..5ad8c8d6426a 100644
--- a/board/xilinx/versal-net/board.c
+++ b/board/xilinx/versal-net/board.c
@@ -68,12 +68,12 @@ int board_early_init_r(void)
return 0;
}
-int spi_get_env_dev(void)
+static int spi_get_bootseq(u8 bootmode)
{
struct udevice *dev;
int bootseq = -1;
- switch (versal_net_get_bootmode()) {
+ switch (bootmode) {
case QSPI_MODE_24BIT:
puts("QSPI_MODE_24\n");
if (uclass_get_device_by_name(UCLASS_SPI,
@@ -109,6 +109,11 @@ int spi_get_env_dev(void)
return bootseq;
}
+int spi_get_env_dev(void)
+{
+ return spi_get_bootseq(versal_net_get_bootmode());
+}
+
static int boot_targets_setup(void)
{
u8 bootmode;
@@ -133,34 +138,11 @@ static int boot_targets_setup(void)
mode = "jtag pxe dhcp";
break;
case QSPI_MODE_24BIT:
- puts("QSPI_MODE_24\n");
- if (uclass_get_device_by_name(UCLASS_SPI,
- "spi at f1030000", &dev)) {
- debug("QSPI driver for QSPI device is not present\n");
- break;
- }
- mode = "xspi";
- bootseq = dev_seq(dev);
- break;
case QSPI_MODE_32BIT:
- puts("QSPI_MODE_32\n");
- if (uclass_get_device_by_name(UCLASS_SPI,
- "spi at f1030000", &dev)) {
- debug("QSPI driver for QSPI device is not present\n");
- break;
- }
- mode = "xspi";
- bootseq = dev_seq(dev);
- break;
case OSPI_MODE:
- puts("OSPI_MODE\n");
- if (uclass_get_device_by_name(UCLASS_SPI,
- "spi at f1010000", &dev)) {
- debug("OSPI driver for OSPI device is not present\n");
- break;
- }
- mode = "xspi";
- bootseq = dev_seq(dev);
+ bootseq = spi_get_bootseq(bootmode);
+ if (bootseq >= 0)
+ mode = "xspi";
break;
case EMMC_MODE:
puts("EMMC_MODE\n");
--
2.43.0
More information about the U-Boot
mailing list