drivers/spi: Allow SoC to provide the SPI flash CS index

On AMD platforms the PSP can boot from different SPI CS lines
and do a recovery boot in case the default CS0 isn't usable.

Allow the SoC to provide the current boot_device CS line by
adding a new weak function.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Change-Id: Ic9ed54b7979405d433f22458265f09701cda842e
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90777
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Patrick Rudolph 2025-09-30 15:11:01 +02:00 committed by Matt DeVillier
commit a12663fd88
3 changed files with 15 additions and 2 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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);