payloads: Propagate SPI flash address mode flag to libpayload

This commit extends libpayload's understanding of SPI flash devices by
adding a flags field to both struct cb_spi_flash and struct
sysinfo_t.spi_flash.

The new CB_SPI_FLASH_FLAG_IN_4BYTE_ADDR_MODE flag will be populated
from the coreboot table's lb_spi_flash entry. This allows payloads to
reliably determine if the SPI flash is currently configured for 4-byte
addressing, enabling more robust flash operations without needing to
re-probe or re-enforce the mode.

Note: `erase_cmd` type was changed from uint32_t to uint8_t. This is
because only the lowest byte of the original uint32_t was ever used.
The change ensures proper sizing, maintains compatibility with older
coreboot tables, and makes the remaining space available for new fields.

BUG=b:417900125
TEST=Able to build google/bluey.

Change-Id: I101a50f899e82e9412024a049a9df59c5813313a
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88182
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Subrata Banik 2025-06-24 10:28:00 +00:00
commit 61d74dc8f7
3 changed files with 18 additions and 2 deletions

View file

@ -306,7 +306,15 @@ struct cb_spi_flash {
uint32_t size;
uint32_t flash_size;
uint32_t sector_size;
uint32_t erase_cmd;
/*
* Note: `erase_cmd` was previously a uint32_t. It's now uint8_t because only
* the lowest byte was used, ensuring backward compatibility with older coreboot
* tables and allowing reuse of the remaining bytes.
*/
uint8_t erase_cmd;
#define CB_SPI_FLASH_FLAG_IN_4BYTE_ADDR_MODE (1 << 0)
uint8_t flags;
uint16_t reserved;
/*
* Number of mmap windows used by the platform to decode addresses between SPI flash
* space and host address space. This determines the number of entries in mmap_table.

View file

@ -135,7 +135,14 @@ struct sysinfo_t {
struct {
uint32_t size;
uint32_t sector_size;
uint32_t erase_cmd;
/*
* Note: `erase_cmd` was previously a uint32_t. It's now uint8_t because only
* the lowest byte was used, ensuring backward compatibility with older coreboot
* tables and allowing reuse of the remaining bytes.
*/
uint8_t erase_cmd;
uint8_t flags;
uint16_t reserved;
uint32_t mmap_window_count;
struct flash_mmap_window mmap_table[SYSINFO_MAX_MMAP_WINDOWS];
} spi_flash;

View file

@ -177,6 +177,7 @@ static void cb_parse_spi_flash(void *ptr, struct sysinfo_t *info)
info->spi_flash.size = flash->flash_size;
info->spi_flash.sector_size = flash->sector_size;
info->spi_flash.erase_cmd = flash->erase_cmd;
info->spi_flash.flags = flash->flags;
if (flash->mmap_count == 0)
return;