diff options
| author | Michal Simek <[email protected]> | 2026-06-23 14:53:39 +0200 |
|---|---|---|
| committer | Michal Simek <[email protected]> | 2026-07-08 08:55:51 +0200 |
| commit | fb3801be128c9d0bf34a1797141a972b0759cb25 (patch) | |
| tree | af4c8b7a3a43d35f91f418b229108b13703c30c0 | |
| parent | 4b62fc1b7e9e6ead90bbc5a5c9e82b8ee03fbfef (diff) | |
arm64: versal-net: Deduplicate SPI bootmode handling
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 <[email protected]>
Link: https://patch.msgid.link/f98037220a20c441f0ea964f94647948bc035997.1782219202.git.michal.simek@amd.com
| -rw-r--r-- | board/xilinx/versal-net/board.c | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/board/xilinx/versal-net/board.c b/board/xilinx/versal-net/board.c index bb099c1e7ca..5ad8c8d6426 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@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@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@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"); |
