Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84920?usp=email )
Change subject: soc/amd/common/psp_smi_flash: refactor SPI controller busy check ......................................................................
soc/amd/common/psp_smi_flash: refactor SPI controller busy check
Since the functions that call 'spi_controller_available' end up checking if the SPI controller is busy, refactor the function into 'spi_controller_busy' to simplify the logic on the caller's side. Also move printing of the notice that the SPI controller is busy to 'spi_controller_busy' to not have that duplicated in caller.
Signed-off-by: Felix Held felix-coreboot@felixheld.de Change-Id: Ibc21ab6eacf07c4adffdb4658142c2f9dfcbf2a1 --- M src/soc/amd/common/block/psp/psp_smi_flash.c 1 file changed, 11 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/20/84920/1
diff --git a/src/soc/amd/common/block/psp/psp_smi_flash.c b/src/soc/amd/common/block/psp/psp_smi_flash.c index ca59553..abddcdf 100644 --- a/src/soc/amd/common/block/psp/psp_smi_flash.c +++ b/src/soc/amd/common/block/psp/psp_smi_flash.c @@ -92,9 +92,14 @@ return MBOX_PSP_SUCCESS; }
-static bool spi_controller_available(void) +static bool spi_controller_busy(void) { - return !(spi_read8(SPI_MISC_CNTRL) & SPI_SEMAPHORE_DRIVER_LOCKED); + const bool busy = (spi_read8(SPI_MISC_CNTRL) & SPI_SEMAPHORE_DRIVER_LOCKED); + + if (busy) + printk(BIOS_NOTICE, "PSP: SPI controller busy\n"); + + return busy; }
enum mbox_p2c_status psp_smi_spi_get_info(struct mbox_default_buffer *buffer) @@ -113,8 +118,7 @@ if (!is_valid_psp_spi_info(cmd_buf)) return MBOX_PSP_COMMAND_PROCESS_ERROR;
- if (!spi_controller_available()) { - printk(BIOS_NOTICE, "PSP: SPI controller busy\n"); + if (spi_controller_busy()) { return MBOX_PSP_SPI_BUSY; }
@@ -156,8 +160,7 @@ if (!is_valid_psp_spi_read_write(cmd_buf)) return MBOX_PSP_COMMAND_PROCESS_ERROR;
- if (!spi_controller_available()) { - printk(BIOS_NOTICE, "PSP: SPI controller busy\n"); + if (spi_controller_busy()) { return MBOX_PSP_SPI_BUSY; }
@@ -205,8 +208,7 @@ if (!is_valid_psp_spi_read_write(cmd_buf)) return MBOX_PSP_COMMAND_PROCESS_ERROR;
- if (!spi_controller_available()) { - printk(BIOS_NOTICE, "PSP: SPI controller busy\n"); + if (spi_controller_busy()) { return MBOX_PSP_SPI_BUSY; }
@@ -253,8 +255,7 @@ if (!is_valid_psp_spi_erase(cmd_buf)) return MBOX_PSP_COMMAND_PROCESS_ERROR;
- if (!spi_controller_available()) { - printk(BIOS_NOTICE, "PSP: SPI controller busy\n"); + if (spi_controller_busy()) { return MBOX_PSP_SPI_BUSY; }