Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/83756?usp=email )
(
3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: soc/amd/common/psp: add and call PSP SMI SPI access function stubs ......................................................................
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 felix-coreboot@felixheld.de Signed-off-by: Ritul Guru ritul.bits@gmail.com Change-Id: Iedbc9d41eb0d4e8d81eeba9c01281161eb839991 Reviewed-on: https://review.coreboot.org/c/coreboot/+/83756 Reviewed-by: Martin Roth martin.roth@amd.corp-partner.google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/soc/amd/common/block/psp/Makefile.mk M src/soc/amd/common/block/psp/psp_def.h M src/soc/amd/common/block/psp/psp_smi.c A src/soc/amd/common/block/psp/psp_smi_flash.c 4 files changed, 58 insertions(+), 0 deletions(-)
Approvals: Martin Roth: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/src/soc/amd/common/block/psp/Makefile.mk b/src/soc/amd/common/block/psp/Makefile.mk index c16a73b..b72343c 100644 --- a/src/soc/amd/common/block/psp/Makefile.mk +++ b/src/soc/amd/common/block/psp/Makefile.mk @@ -5,6 +5,7 @@ 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 d58aa0b..c2b2fca 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 @@
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 e6cc1dc..66e84d1 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 <types.h> #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 @@ { 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 @@ 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 0000000..54edf14 --- /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 <console/console.h> +#include <types.h> +#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; +}