drivers/spi: Refactor 4-byte addressing mode handling in SPI flash

This commit refactors the logic for entering and exiting 4-byte
addressing mode in the SPI flash driver.

Changes include:
 - Renaming SPI_FLASH_EXIT_4BYTE_STAGE to SPI_FIRST_STAGE to better
   reflect its broader applicability to initial boot stages.
 - Applying SPI_FIRST_STAGE to both the force 4-byte address mode
   and exit 4-byte address mode configurations, ensuring these
   operations are only attempted during the appropriate early boot
   phases.
 - Renaming CMD_FORCE_4BYTE_ADDR_MODE to CMD_ENTER_4BYTE_ADDR_MODE for
   consistency and clearer semantics, as 0xb7 is typically used to enter
   this mode.

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

Change-Id: I79e2c7bbd222fd0d76072860bdf3feba7e7d587d
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88203
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Subrata Banik 2025-06-26 06:36:08 +00:00
commit a01c368a8a
2 changed files with 6 additions and 6 deletions

View file

@ -18,7 +18,7 @@
#define ADDR_MOD 0
#endif
#define SPI_FLASH_EXIT_4BYTE_STAGE \
#define SPI_FIRST_STAGE \
(ENV_INITIAL_STAGE || CONFIG(BOOT_DEVICE_MEMORY_MAPPED))
static void spi_flash_addr(u32 addr, u8 *cmd)
@ -564,12 +564,12 @@ int spi_flash_probe(unsigned int bus, unsigned int cs, struct spi_flash *flash)
CONFIG_ROM_SIZE);
}
if (CONFIG(SPI_FLASH_FORCE_4_BYTE_ADDR_MODE)) {
printk(BIOS_DEBUG, "SF: Force 4-byte addressing mode\n");
spi_flash_cmd(&flash->spi, CMD_FORCE_4BYTE_ADDR_MODE, NULL, 0);
if (CONFIG(SPI_FLASH_FORCE_4_BYTE_ADDR_MODE) && SPI_FIRST_STAGE) {
printk(BIOS_DEBUG, "SF: Entering 4-byte addressing mode\n");
spi_flash_cmd(&flash->spi, CMD_ENTER_4BYTE_ADDR_MODE, NULL, 0);
}
if (CONFIG(SPI_FLASH_EXIT_4_BYTE_ADDR_MODE) && SPI_FLASH_EXIT_4BYTE_STAGE) {
if (CONFIG(SPI_FLASH_EXIT_4_BYTE_ADDR_MODE) && SPI_FIRST_STAGE) {
printk(BIOS_DEBUG, "SF: Exiting 4-byte addressing mode\n");
spi_flash_cmd(&flash->spi, CMD_EXIT_4BYTE_ADDR_MODE, NULL, 0);
}

View file

@ -22,7 +22,7 @@
#define CMD_READ_STATUS 0x05
#define CMD_WRITE_ENABLE 0x06
#define CMD_FORCE_4BYTE_ADDR_MODE 0xb7
#define CMD_ENTER_4BYTE_ADDR_MODE 0xb7
#define CMD_BLOCK_ERASE 0xD8