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>
This commit is contained in:
parent
7571044f9d
commit
f48dd16995
1 changed files with 11 additions and 10 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue