diff options
Diffstat (limited to 'src/soc/amd')
-rw-r--r-- | src/soc/amd/common/block/psp/psp_smi_flash.c | 46 |
1 files changed, 46 insertions, 0 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 b987cec170..f1b9d85fbb 100644 --- a/src/soc/amd/common/block/psp/psp_smi_flash.c +++ b/src/soc/amd/common/block/psp/psp_smi_flash.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include <console/console.h> +#include <device/mmio.h> #include <types.h> #include "psp_def.h" @@ -45,30 +46,75 @@ struct mbox_pspv2_cmd_spi_erase { struct pspv2_spi_erase_request req; } __packed; +static bool is_valid_psp_spi_id(u64 target_nv_id) +{ + return target_nv_id == SMI_TARGET_NVRAM || + target_nv_id == SMI_TARGET_RPMC_NVRAM; +} + +static bool is_valid_psp_spi_info(struct mbox_pspv2_cmd_spi_info *cmd_buf) +{ + return is_valid_psp_spi_id(read64(&cmd_buf->req.target_nv_id)); +} + +static bool is_valid_psp_spi_read_write(struct mbox_pspv2_cmd_spi_read_write *cmd_buf) +{ + return is_valid_psp_spi_id(read64(&cmd_buf->req.target_nv_id)); +} + +static bool is_valid_psp_spi_erase(struct mbox_pspv2_cmd_spi_erase *cmd_buf) +{ + return is_valid_psp_spi_id(read64(&cmd_buf->req.target_nv_id)); +} + enum mbox_p2c_status psp_smi_spi_get_info(struct mbox_default_buffer *buffer) { + struct mbox_pspv2_cmd_spi_info *const cmd_buf = + (struct mbox_pspv2_cmd_spi_info *)buffer; + printk(BIOS_SPEW, "PSP: SPI info request\n"); + if (!is_valid_psp_spi_info(cmd_buf)) + return MBOX_PSP_COMMAND_PROCESS_ERROR; + return MBOX_PSP_UNSUPPORTED; } enum mbox_p2c_status psp_smi_spi_read(struct mbox_default_buffer *buffer) { + struct mbox_pspv2_cmd_spi_read_write *const cmd_buf = + (struct mbox_pspv2_cmd_spi_read_write *)buffer; + printk(BIOS_SPEW, "PSP: SPI read request\n"); + if (!is_valid_psp_spi_read_write(cmd_buf)) + return MBOX_PSP_COMMAND_PROCESS_ERROR; + return MBOX_PSP_UNSUPPORTED; } enum mbox_p2c_status psp_smi_spi_write(struct mbox_default_buffer *buffer) { + struct mbox_pspv2_cmd_spi_read_write *const cmd_buf = + (struct mbox_pspv2_cmd_spi_read_write *)buffer; + printk(BIOS_SPEW, "PSP: SPI write request\n"); + if (!is_valid_psp_spi_read_write(cmd_buf)) + return MBOX_PSP_COMMAND_PROCESS_ERROR; + return MBOX_PSP_UNSUPPORTED; } enum mbox_p2c_status psp_smi_spi_erase(struct mbox_default_buffer *buffer) { + struct mbox_pspv2_cmd_spi_erase *const cmd_buf = + (struct mbox_pspv2_cmd_spi_erase *)buffer; + printk(BIOS_SPEW, "PSP: SPI erase request\n"); + if (!is_valid_psp_spi_erase(cmd_buf)) + return MBOX_PSP_COMMAND_PROCESS_ERROR; + return MBOX_PSP_UNSUPPORTED; } |