Fred Reitberger has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/76093?usp=email )
Change subject: drivers/spi_flash: Add option to always exit 4-byte address mode ......................................................................
drivers/spi_flash: Add option to always exit 4-byte address mode
Add Kconfig option to always send the Exit 4-Byte Address Mode (E9h) command before the first access to the SPI flash in all stages. This is useful for mainboards that do not access SPI flash in bootblock yet still need to exit 4-byte addressing mode in romstage or ramstage.
Signed-off-by: Fred Reitberger reitbergerfred@gmail.com Change-Id: I3a62bfa44a0a5645c1bb80b32d0b9f92075c66bf --- M src/drivers/spi/Kconfig M src/drivers/spi/spi_flash.c 2 files changed, 15 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/93/76093/1
diff --git a/src/drivers/spi/Kconfig b/src/drivers/spi/Kconfig index 8c251d7..e5ea447 100644 --- a/src/drivers/spi/Kconfig +++ b/src/drivers/spi/Kconfig @@ -173,6 +173,15 @@ On flashes that don't support 4-byte addressing mode or where it is already disabled, this command should be a no-op.
+config SPI_FLASH_EXIT_4_BYTE_ADDR_MODE_ALWAYS + bool + default n + depends on SPI_FLASH_EXIT_4_BYTE_ADDR_MODE + help + This will send an Exit 4-Byte Address Mode (E9h) command before the first + access to the SPI flash in all stages. Otherwise, this command is only + sent in the initial stage (Bootblock or Verstage when before bootblock). + config SPI_FLASH_FORCE_4_BYTE_ADDR_MODE bool default n diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 5182684..cf74bf9 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -18,6 +18,9 @@ #define ADDR_MOD 0 #endif
+#define SPI_FLASH_EXIT_4BYTE_STAGE \ + (ENV_INITIAL_STAGE || CONFIG(SPI_FLASH_EXIT_4_BYTE_ADDR_MODE_ALWAYS)) + static void spi_flash_addr(u32 addr, u8 *cmd) { /* cmd[0] is actual command */ @@ -548,8 +551,10 @@ CONFIG_ROM_SIZE); }
- if (CONFIG(SPI_FLASH_EXIT_4_BYTE_ADDR_MODE) && ENV_INITIAL_STAGE) + if (CONFIG(SPI_FLASH_EXIT_4_BYTE_ADDR_MODE) && SPI_FLASH_EXIT_4BYTE_STAGE) { + printk(BIOS_DEBUG, "SF: Exiting 4-byte addressing mode\n"); spi_flash_cmd(&flash->spi, CMD_EXIT_4BYTE_ADDR_MODE, NULL, 0); + }
return 0; }