From 4ea3bfd1bc4d24237814ec6ded444a7b94fa606c Mon Sep 17 00:00:00 2001 From: Felix Held Date: Fri, 2 Aug 2024 02:48:13 +0200 Subject: soc/amd/common/psp: add and call PSP SMI SPI access function stubs Add stub functions for the SPI flash access from the PSP SMI handler and call them for the corresponding P2C mailbox commands. Parts of this patch are taken from CB:65523. Document #55758 Rev. 2.04 was used as a reference. Test=When selecting SOC_AMD_COMMON_BLOCK_PSP_SMI, Mandolin still builds Signed-off-by: Felix Held Signed-off-by: Ritul Guru Change-Id: Iedbc9d41eb0d4e8d81eeba9c01281161eb839991 Reviewed-on: https://review.coreboot.org/c/coreboot/+/83756 Reviewed-by: Martin Roth Tested-by: build bot (Jenkins) --- src/soc/amd/common/block/psp/Makefile.mk | 1 + src/soc/amd/common/block/psp/psp_def.h | 5 +++++ src/soc/amd/common/block/psp/psp_smi.c | 19 ++++++++++++++++ src/soc/amd/common/block/psp/psp_smi_flash.c | 33 ++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 src/soc/amd/common/block/psp/psp_smi_flash.c (limited to 'src') diff --git a/src/soc/amd/common/block/psp/Makefile.mk b/src/soc/amd/common/block/psp/Makefile.mk index c16a73b698..b72343c365 100644 --- a/src/soc/amd/common/block/psp/Makefile.mk +++ b/src/soc/amd/common/block/psp/Makefile.mk @@ -5,6 +5,7 @@ romstage-y += psp.c ramstage-y += psp.c smm-y += psp.c smm-$(CONFIG_SOC_AMD_COMMON_BLOCK_PSP_SMI) += psp_smi.c +smm-$(CONFIG_SOC_AMD_COMMON_BLOCK_PSP_SMI) += psp_smi_flash.c smm-y += psp_smm.c bootblock-y += psp_efs.c diff --git a/src/soc/amd/common/block/psp/psp_def.h b/src/soc/amd/common/block/psp/psp_def.h index d58aa0b82e..c2b2fca8d8 100644 --- a/src/soc/amd/common/block/psp/psp_def.h +++ b/src/soc/amd/common/block/psp/psp_def.h @@ -133,4 +133,9 @@ enum cb_err soc_read_c2p38(uint32_t *msg_38_value); void enable_psp_smi(void); +enum mbox_p2c_status psp_smi_spi_get_info(struct mbox_default_buffer *buffer); +enum mbox_p2c_status psp_smi_spi_read(struct mbox_default_buffer *buffer); +enum mbox_p2c_status psp_smi_spi_write(struct mbox_default_buffer *buffer); +enum mbox_p2c_status psp_smi_spi_erase(struct mbox_default_buffer *buffer); + #endif /* __AMD_PSP_DEF_H__ */ diff --git a/src/soc/amd/common/block/psp/psp_smi.c b/src/soc/amd/common/block/psp/psp_smi.c index e6cc1dc96c..66e84d13a6 100644 --- a/src/soc/amd/common/block/psp/psp_smi.c +++ b/src/soc/amd/common/block/psp/psp_smi.c @@ -8,6 +8,12 @@ #include #include "psp_def.h" +/* PSP to x86 commands */ +#define MBOX_PSP_CMD_SPI_INFO 0x83 +#define MBOX_PSP_CMD_SPI_READ 0x84 +#define MBOX_PSP_CMD_SPI_WRITE 0x85 +#define MBOX_PSP_CMD_SPI_ERASE 0x86 + extern struct { u8 buffer[P2C_BUFFER_MAXSIZE]; } __aligned(32) p2c_buffer; @@ -126,6 +132,7 @@ static void handle_psp_command(void) { enum mbox_p2c_status status; u32 cmd; + struct mbox_default_buffer *const buffer = get_psp_command_buffer(); status = check_psp_command(); if (status != MBOX_PSP_SUCCESS) @@ -134,6 +141,18 @@ static void handle_psp_command(void) cmd = get_psp_command(); switch (cmd) { + case MBOX_PSP_CMD_SPI_INFO: + status = psp_smi_spi_get_info(buffer); + break; + case MBOX_PSP_CMD_SPI_READ: + status = psp_smi_spi_read(buffer); + break; + case MBOX_PSP_CMD_SPI_WRITE: + status = psp_smi_spi_write(buffer); + break; + case MBOX_PSP_CMD_SPI_ERASE: + status = psp_smi_spi_erase(buffer); + break; default: printk(BIOS_ERR, "PSP: Unknown command %d\n", cmd); status = MBOX_PSP_UNSUPPORTED; diff --git a/src/soc/amd/common/block/psp/psp_smi_flash.c b/src/soc/amd/common/block/psp/psp_smi_flash.c new file mode 100644 index 0000000000..54edf1446b --- /dev/null +++ b/src/soc/amd/common/block/psp/psp_smi_flash.c @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include "psp_def.h" + +enum mbox_p2c_status psp_smi_spi_get_info(struct mbox_default_buffer *buffer) +{ + printk(BIOS_SPEW, "PSP: SPI info request\n"); + + return MBOX_PSP_UNSUPPORTED; +} + +enum mbox_p2c_status psp_smi_spi_read(struct mbox_default_buffer *buffer) +{ + printk(BIOS_SPEW, "PSP: SPI read request\n"); + + return MBOX_PSP_UNSUPPORTED; +} + +enum mbox_p2c_status psp_smi_spi_write(struct mbox_default_buffer *buffer) +{ + printk(BIOS_SPEW, "PSP: SPI write request\n"); + + return MBOX_PSP_UNSUPPORTED; +} + +enum mbox_p2c_status psp_smi_spi_erase(struct mbox_default_buffer *buffer) +{ + printk(BIOS_SPEW, "PSP: SPI erase request\n"); + + return MBOX_PSP_UNSUPPORTED; +} -- cgit v1.2.3