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
Reviewed-on: https://review.coreboot.org/c/coreboot/+/63624
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
This commit is contained in:
Subrata Banik 2022-04-13 19:18:34 +05:30
parent 6b888adcff
commit a26bb7878b
2 changed files with 14 additions and 0 deletions

View File

@ -161,6 +161,18 @@ static int exec_sync_hwseq_xfer(struct fast_spi_flash_ctx *ctx,
return wait_for_hwseq_xfer(ctx, flash_addr);
}
int fast_spi_cycle_in_progress(void)
{
BOILERPLATE_CREATE_CTX(ctx);
int ret = wait_for_hwseq_spi_cycle_complete(ctx);
if (ret != SUCCESS)
printk(BIOS_ERR, "SPI Transaction Timeout (Exceeded %d ms) due to prior"
" operation is pending\n", SPIBAR_HWSEQ_XFER_TIMEOUT_MS);
return ret;
}
/*
* Ensure read/write xfer len is not greater than SPIBAR_FDATA_FIFO_SIZE and
* that the operation does not cross page boundary.

View File

@ -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.
*/