From 8cfb73c777e2123189021c26929bc9faa75867d8 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Mon, 5 Aug 2024 23:49:47 +0200 Subject: soc/amd/common/psp_smi_flash: add spi_controller_available The SPI_SEMAPHORE_DRIVER_LOCKED bit in the SPI_MISC_CNTRL register doesn't affect the hardware, but it re-used by AMD as a semaphore to synchronize the access to the SPI controller between SMM and non-SMM software like an OS-level driver. Since it doesn't affect the hardware, it's marked as reserved in the PPRs. Add the 'spi_controller_available' helper function to check this bit to see if some software or driver outside of SMM is currently using the SPI flash controller to avoid interfering with that operation. This patch is a slightly reworked version of parts of CB:65523. Test=When selecting SOC_AMD_COMMON_BLOCK_PSP_SMI, Mandolin still builds Signed-off-by: Felix Held Signed-off-by: Ritul Guru Change-Id: I49218e03a5dd555b2b2d34eaad86673e9fc908c3 Reviewed-on: https://review.coreboot.org/c/coreboot/+/83775 Reviewed-by: Martin Roth Tested-by: build bot (Jenkins) --- src/soc/amd/common/block/include/amdblocks/spi.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/soc/amd/common/block/include') diff --git a/src/soc/amd/common/block/include/amdblocks/spi.h b/src/soc/amd/common/block/include/amdblocks/spi.h index babe6356f3..eafc2c2f3b 100644 --- a/src/soc/amd/common/block/include/amdblocks/spi.h +++ b/src/soc/amd/common/block/include/amdblocks/spi.h @@ -77,6 +77,9 @@ enum spi100_speed { #define SPI_FIFO_DEPTH (SPI_FIFO_LAST_BYTE - SPI_FIFO + 1) #define SPI_MISC_CNTRL 0xfc +/* AMD has re-purposed this unused SPI controller register bit as a semaphore to synchronize + access to the SPI controller between SMM and non-SMM software/OS driver. */ +#define SPI_SEMAPHORE_DRIVER_LOCKED BIT(4) struct spi_config { /* -- cgit v1.2.3