diff options
author | Felix Held <felix-coreboot@felixheld.de> | 2024-10-29 20:45:44 +0100 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2024-11-05 15:02:59 +0000 |
commit | f48dd169954716562bc88f9ecb25d38d63c18f8d (patch) | |
tree | 26a40277fde0016c9f08db5f2b079938b8b4efc0 /src/soc/amd/common | |
parent | 7571044f9d5cad945310254b20d2eab4f732d605 (diff) |
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
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84920
Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/amd/common')
-rw-r--r-- | src/soc/amd/common/block/psp/psp_smi_flash.c | 21 |
1 files changed, 11 insertions, 10 deletions
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 ca595536c1..abddcdf19a 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 @@ static enum mbox_p2c_status find_psp_spi_flash_device_region(uint64_t target_nv_ 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 @@ enum mbox_p2c_status psp_smi_spi_get_info(struct mbox_default_buffer *buffer) 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 @@ enum mbox_p2c_status psp_smi_spi_read(struct mbox_default_buffer *buffer) 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 @@ enum mbox_p2c_status psp_smi_spi_write(struct mbox_default_buffer *buffer) 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 @@ enum mbox_p2c_status psp_smi_spi_erase(struct mbox_default_buffer *buffer) 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; } |