[PATCH] amd: versal2: detect spi env bus from boot mode
Michal Simek
michal.simek at amd.com
Tue Jun 23 10:01:16 CEST 2026
On 6/10/26 13:05, Suraj Kakade wrote:
> Add spi_get_env_dev() to dynamically detect the correct SPI
> bus based on the actual boot mode at runtime. This ensures
> environment variables are always loaded from the correct SPI
> flash controller regardless of the bus numbering.
>
> For example, on some Versal Gen 2 boards, SPI is disabled in DTS
> leaving bus 0 empty in DM. Only QSPI is enabled at bus 1. The
> default CONFIG_ENV_SPI_BUS=0 causes U-Boot to search for environment
> at bus 0 which does not exist, triggering the warning
> "spi_flash_probe_bus_cs() failed, using default environment".
>
> Signed-off-by: Suraj Kakade <suraj.hanumantkakade at amd.com>
> ---
> board/amd/versal2/board.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/board/amd/versal2/board.c b/board/amd/versal2/board.c
> index 81daba1c5ef..46918436364 100644
> --- a/board/amd/versal2/board.c
> +++ b/board/amd/versal2/board.c
> @@ -476,3 +476,31 @@ enum env_location env_get_location(enum env_operation op, int prio)
> }
> }
> #endif
> +
> +int spi_get_env_dev(void)
> +{
> + struct udevice *dev;
> + const char *name;
> + int bootseq;
> +
> + switch (versal2_get_bootmode()) {
> + case QSPI_MODE_24BIT:
> + case QSPI_MODE_32BIT:
> + name = "spi at f1030000";
> + break;
> + case OSPI_MODE:
> + name = "spi at f1010000";
> + break;
> + default:
> + return -1;
> + }
> +
> + if (uclass_get_device_by_name(UCLASS_SPI, name, &dev)) {
> + debug("SPI driver for %s is not present\n", name);
> + return -1;
> + }
> +
> + bootseq = dev_seq(dev);
> + debug("bootseq %d\n", bootseq);
> + return bootseq;
> +}
Applied.
M
More information about the U-Boot
mailing list