Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/63624 )
Change subject: soc/intel/cmn/fast_spi: Add API to check if SPI Cycle In Progress ......................................................................
soc/intel/cmn/fast_spi: Add API to check if SPI Cycle In Progress
This patch creates a helper function to check if any SPI transaction is pending.
As per Intel PCH BIOS spec section 3.6 Flash Security Recommendation, it's important to ensure there is no pending SPI transaction before setting SPI lock bits.
BUG=b:211954778 TEST=Able to build google/brya with this patch and no error msg seen due to `SPI transaction is pending`.
Signed-off-by: Subrata Banik subratabanik@google.com Change-Id: Ibd3f67ae60bfcb3610cd0950b057da97ff74b5b9 --- M src/soc/intel/common/block/fast_spi/fast_spi_flash.c M src/soc/intel/common/block/include/intelblocks/fast_spi.h 2 files changed, 13 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/24/63624/1
diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c index 269db63..155bc9e 100644 --- a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c +++ b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c @@ -161,6 +161,17 @@ return wait_for_hwseq_xfer(ctx, flash_addr); }
+int fast_spi_cycle_in_progress(void) +{ + BOILERPLATE_CREATE_CTX(ctx); + + enum errors ret = wait_for_hwseq_spi_cycle_complete(ctx); + if (ret != SUCCESS) + printk(BIOS_ERR, "SPI transaction is pending\n"); + + return ret; +} + /* * Ensure read/write xfer len is not greater than SPIBAR_FDATA_FIFO_SIZE and * that the operation does not cross page boundary. diff --git a/src/soc/intel/common/block/include/intelblocks/fast_spi.h b/src/soc/intel/common/block/include/intelblocks/fast_spi.h index a903ea83..eb3f2aa 100644 --- a/src/soc/intel/common/block/include/intelblocks/fast_spi.h +++ b/src/soc/intel/common/block/include/intelblocks/fast_spi.h @@ -5,6 +5,8 @@
#include <types.h>
+/* Check if SPI transaction is pending */ +int fast_spi_cycle_in_progress(void); /* * Disable the BIOS write protect and Enable Prefetching and Caching. */