summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/soc/amd/common/block/psp/Makefile.mk1
-rw-r--r--src/soc/amd/common/block/psp/psp_smi_flash.c95
-rw-r--r--src/soc/amd/common/block/psp/psp_smi_flash.h56
-rw-r--r--src/soc/amd/common/block/psp/psp_smi_flash_gen2.c58
4 files changed, 116 insertions, 94 deletions
diff --git a/src/soc/amd/common/block/psp/Makefile.mk b/src/soc/amd/common/block/psp/Makefile.mk
index b72343c365..20e55e80cb 100644
--- a/src/soc/amd/common/block/psp/Makefile.mk
+++ b/src/soc/amd/common/block/psp/Makefile.mk
@@ -29,6 +29,7 @@ ramstage-$(CONFIG_PSP_PLATFORM_SECURE_BOOT) += psb.c
ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_I2C3_TPM_SHARED_WITH_PSP) += tpm.c
smm-y += psp_gen2.c
+smm-$(CONFIG_SOC_AMD_COMMON_BLOCK_PSP_SMI) += psp_smi_flash_gen2.c
smm-y += psp_smm_gen2.c
ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_PSP_SPL) += spl_fuse.c
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 405fc29ef7..8a622961c5 100644
--- a/src/soc/amd/common/block/psp/psp_smi_flash.c
+++ b/src/soc/amd/common/block/psp/psp_smi_flash.c
@@ -9,100 +9,7 @@
#include <spi_flash.h>
#include <types.h>
#include "psp_def.h"
-
-enum psp_spi_id_type {
- SMI_TARGET_NVRAM = 0,
- SMI_TARGET_RPMC_NVRAM = 5,
-};
-
-struct pspv2_spi_info_request {
- u64 target_nv_id;
- u64 lba;
- u64 block_size;
- u64 num_blocks;
-} __packed;
-
-struct mbox_pspv2_cmd_spi_info {
- struct mbox_buffer_header header;
- struct pspv2_spi_info_request req;
-} __packed;
-
-struct pspv2_spi_read_write_request {
- u64 target_nv_id;
- u64 lba;
- u64 offset;
- u64 num_bytes;
- u8 buffer[];
-} __packed;
-
-struct mbox_pspv2_cmd_spi_read_write {
- struct mbox_buffer_header header;
- struct pspv2_spi_read_write_request req;
-} __packed;
-
-struct pspv2_spi_erase_request {
- u64 target_nv_id;
- u64 lba;
- u64 num_blocks;
-} __packed;
-
-struct mbox_pspv2_cmd_spi_erase {
- struct mbox_buffer_header header;
- 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));
-}
-
-static u64 get_psp_spi_info_id(struct mbox_pspv2_cmd_spi_info *cmd_buf)
-{
- return read64(&cmd_buf->req.target_nv_id);
-}
-
-static void set_psp_spi_info(struct mbox_pspv2_cmd_spi_info *cmd_buf,
- u64 lba, u64 block_size, u64 num_blocks)
-{
- write64(&cmd_buf->req.lba, lba);
- write64(&cmd_buf->req.block_size, block_size);
- write64(&cmd_buf->req.num_blocks, num_blocks);
-}
-
-static void get_psp_spi_read_write(struct mbox_pspv2_cmd_spi_read_write *cmd_buf,
- u64 *target_nv_id, u64 *lba, u64 *offset,
- u64 *num_bytes, u8 **data)
-{
- *target_nv_id = read64(&cmd_buf->req.target_nv_id);
- *lba = read64(&cmd_buf->req.lba);
- *offset = read64(&cmd_buf->req.offset);
- *num_bytes = read64(&cmd_buf->req.num_bytes);
- *data = cmd_buf->req.buffer;
-}
-
-static void get_psp_spi_erase(struct mbox_pspv2_cmd_spi_erase *cmd_buf,
- u64 *target_nv_id, u64 *lba, u64 *num_blocks)
-{
- *target_nv_id = read64(&cmd_buf->req.target_nv_id);
- *lba = read64(&cmd_buf->req.lba);
- *num_blocks = read64(&cmd_buf->req.num_blocks);
-}
+#include "psp_smi_flash.h"
static bool is_valid_rw_byte_count(struct mbox_pspv2_cmd_spi_read_write *cmd_buf,
u64 num_bytes)
diff --git a/src/soc/amd/common/block/psp/psp_smi_flash.h b/src/soc/amd/common/block/psp/psp_smi_flash.h
new file mode 100644
index 0000000000..077cc3b72c
--- /dev/null
+++ b/src/soc/amd/common/block/psp/psp_smi_flash.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <types.h>
+#include "psp_def.h"
+
+enum psp_spi_id_type {
+ SMI_TARGET_NVRAM = 0,
+ SMI_TARGET_RPMC_NVRAM = 5,
+};
+
+struct pspv2_spi_info_request {
+ u64 target_nv_id;
+ u64 lba;
+ u64 block_size;
+ u64 num_blocks;
+} __packed;
+
+struct mbox_pspv2_cmd_spi_info {
+ struct mbox_buffer_header header;
+ struct pspv2_spi_info_request req;
+} __packed;
+
+struct pspv2_spi_read_write_request {
+ u64 target_nv_id;
+ u64 lba;
+ u64 offset;
+ u64 num_bytes;
+ u8 buffer[];
+} __packed;
+
+struct mbox_pspv2_cmd_spi_read_write {
+ struct mbox_buffer_header header;
+ struct pspv2_spi_read_write_request req;
+} __packed;
+
+struct pspv2_spi_erase_request {
+ u64 target_nv_id;
+ u64 lba;
+ u64 num_blocks;
+} __packed;
+
+struct mbox_pspv2_cmd_spi_erase {
+ struct mbox_buffer_header header;
+ struct pspv2_spi_erase_request req;
+} __packed;
+
+bool is_valid_psp_spi_info(struct mbox_pspv2_cmd_spi_info *cmd_buf);
+bool is_valid_psp_spi_read_write(struct mbox_pspv2_cmd_spi_read_write *cmd_buf);
+bool is_valid_psp_spi_erase(struct mbox_pspv2_cmd_spi_erase *cmd_buf);
+u64 get_psp_spi_info_id(struct mbox_pspv2_cmd_spi_info *cmd_buf);
+void set_psp_spi_info(struct mbox_pspv2_cmd_spi_info *cmd_buf, u64 lba, u64 block_size,
+ u64 num_blocks);
+void get_psp_spi_read_write(struct mbox_pspv2_cmd_spi_read_write *cmd_buf, u64 *target_nv_id,
+ u64 *lba, u64 *offset, u64 *num_bytes, u8 **data);
+void get_psp_spi_erase(struct mbox_pspv2_cmd_spi_erase *cmd_buf, u64 *target_nv_id, u64 *lba,
+ u64 *num_blocks);
diff --git a/src/soc/amd/common/block/psp/psp_smi_flash_gen2.c b/src/soc/amd/common/block/psp/psp_smi_flash_gen2.c
new file mode 100644
index 0000000000..99ea0303d5
--- /dev/null
+++ b/src/soc/amd/common/block/psp/psp_smi_flash_gen2.c
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <device/mmio.h>
+#include <types.h>
+#include "psp_def.h"
+#include "psp_smi_flash.h"
+
+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;
+}
+
+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));
+}
+
+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));
+}
+
+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));
+}
+
+u64 get_psp_spi_info_id(struct mbox_pspv2_cmd_spi_info *cmd_buf)
+{
+ return read64(&cmd_buf->req.target_nv_id);
+}
+
+void set_psp_spi_info(struct mbox_pspv2_cmd_spi_info *cmd_buf, u64 lba, u64 block_size,
+ u64 num_blocks)
+{
+ write64(&cmd_buf->req.lba, lba);
+ write64(&cmd_buf->req.block_size, block_size);
+ write64(&cmd_buf->req.num_blocks, num_blocks);
+}
+
+void get_psp_spi_read_write(struct mbox_pspv2_cmd_spi_read_write *cmd_buf, u64 *target_nv_id,
+ u64 *lba, u64 *offset, u64 *num_bytes, u8 **data)
+{
+ *target_nv_id = read64(&cmd_buf->req.target_nv_id);
+ *lba = read64(&cmd_buf->req.lba);
+ *offset = read64(&cmd_buf->req.offset);
+ *num_bytes = read64(&cmd_buf->req.num_bytes);
+ *data = cmd_buf->req.buffer;
+}
+
+void get_psp_spi_erase(struct mbox_pspv2_cmd_spi_erase *cmd_buf, u64 *target_nv_id, u64 *lba,
+ u64 *num_blocks)
+{
+ *target_nv_id = read64(&cmd_buf->req.target_nv_id);
+ *lba = read64(&cmd_buf->req.lba);
+ *num_blocks = read64(&cmd_buf->req.num_blocks);
+}