diff --git a/src/drivers/spi/boot_device_rw_nommap.c b/src/drivers/spi/boot_device_rw_nommap.c index 58efc87fe9..86581600d1 100644 --- a/src/drivers/spi/boot_device_rw_nommap.c +++ b/src/drivers/spi/boot_device_rw_nommap.c @@ -8,6 +8,11 @@ static struct spi_flash sfg; static bool sfg_init_done; +__weak int boot_device_spi_cs(void) +{ + return 0; /* Default to chip select 0 */ +} + static ssize_t spi_readat(const struct region_device *rd, void *b, size_t offset, size_t size) { @@ -47,7 +52,7 @@ static const struct region_device spi_rw = static void boot_device_rw_init(void) { const int bus = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS; - const int cs = 0; + const int cs = boot_device_spi_cs(); if (sfg_init_done == true) return; diff --git a/src/drivers/spi/cbfs_spi.c b/src/drivers/spi/cbfs_spi.c index 15a18b72e4..5f3b5ca40a 100644 --- a/src/drivers/spi/cbfs_spi.c +++ b/src/drivers/spi/cbfs_spi.c @@ -17,6 +17,11 @@ static struct spi_flash spi_flash_info; static bool spi_flash_init_done; +__weak int boot_device_spi_cs(void) +{ + return 0; /* Default to chip select 0 */ +} + /* * SPI speed logging for big transfers available with BIOS_DEBUG. The format is: * @@ -82,7 +87,7 @@ static struct mmap_helper_region_device mdev = void boot_device_init(void) { int bus = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS; - int cs = 0; + int cs = boot_device_spi_cs(); if (spi_flash_init_done == true) return; diff --git a/src/include/boot_device.h b/src/include/boot_device.h index 883f37c8c8..1a44aefc03 100644 --- a/src/include/boot_device.h +++ b/src/include/boot_device.h @@ -27,6 +27,9 @@ enum bootdev_prot_type { * most likely not to work so don't rely on such semantics. */ +/* Return the chip select index used for probing the SPI flash. */ +int boot_device_spi_cs(void); + /* Return the region_device for the read-only boot device. This is the root device for all CBFS boot devices. */ const struct region_device *boot_device_ro(void);