diff options
-rw-r--r-- | env/sf.c | 12 | ||||
-rw-r--r-- | include/spi.h | 2 |
2 files changed, 13 insertions, 1 deletions
@@ -38,14 +38,24 @@ static ulong env_new_offset = CONFIG_ENV_OFFSET_REDUND; DECLARE_GLOBAL_DATA_PTR; +__weak int spi_get_env_dev(void) +{ +#ifdef CONFIG_ENV_SPI_BUS + return CONFIG_ENV_SPI_BUS; +#else + return 0; +#endif +} + static int setup_flash_device(struct spi_flash **env_flash) { #if CONFIG_IS_ENABLED(DM_SPI_FLASH) struct udevice *new; int ret; + int dev = spi_get_env_dev(); /* speed and mode will be read from DT */ - ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS, + ret = spi_flash_probe_bus_cs(dev, CONFIG_ENV_SPI_CS, &new); if (ret) { env_set_default("spi_flash_probe_bus_cs() failed", 0); diff --git a/include/spi.h b/include/spi.h index 7e38cc2a2ad..9e9851284c8 100644 --- a/include/spi.h +++ b/include/spi.h @@ -743,4 +743,6 @@ int dm_spi_get_mmap(struct udevice *dev, ulong *map_basep, uint *map_sizep, #define spi_get_ops(dev) ((struct dm_spi_ops *)(dev)->driver->ops) #define spi_emul_get_ops(dev) ((struct dm_spi_emul_ops *)(dev)->driver->ops) +int spi_get_env_dev(void); + #endif /* _SPI_H_ */ |