summaryrefslogtreecommitdiff
path: root/src/soc
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2024-08-23 22:20:01 +0200
committerFelix Held <felix-coreboot@felixheld.de>2024-08-27 11:35:03 +0000
commit5e7ab1a23346684eb06057bb38d3baae4946a537 (patch)
tree58947eb80d82a354c989f0b38b6c5e71fbde1e94 /src/soc
parentc07b80f28bffd0150511fe00eeb8fd58164f137c (diff)
soc/amd/common/psp: add helper functions to retrieve capability bits
Add helper functions to send the PSP commands to query the fTPM and PSP capability bits as well as the HSTI state. All SoCs using any PSP generation support the MBOX_BIOS_CMD_PSP_FTPM_QUERY command and some generation 1 and all generation 2 PSP SoCs support the MBOX_BIOS_CMD_HSTI_QUERY command, so implement those two in the common psp.c. Only PSP generation 2 supports the MBOX_BIOS_CMD_PSP_CAPS_QUERY command, so implement that one in psp_gen2.c. This code is ported and modified from github.com/teslamotors/coreboot/tree/tesla-4.12-amd Document #54267 revision 1.06 was used as reference for the 1st PSP generation and document #55758 revision 2.04 was used for the 2nd PSP generation. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I4e17f994fb332690828c55742262da793e297d99 Reviewed-on: https://review.coreboot.org/c/coreboot/+/84066 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com> Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/amd/common/block/psp/psp.c46
-rw-r--r--src/soc/amd/common/block/psp/psp_def.h17
-rw-r--r--src/soc/amd/common/block/psp/psp_gen2.c23
3 files changed, 86 insertions, 0 deletions
diff --git a/src/soc/amd/common/block/psp/psp.c b/src/soc/amd/common/block/psp/psp.c
index f989a3b007..a8bb20535e 100644
--- a/src/soc/amd/common/block/psp/psp.c
+++ b/src/soc/amd/common/block/psp/psp.c
@@ -55,6 +55,52 @@ void psp_print_cmd_status(int cmd_status, struct mbox_buffer_header *header)
printk(BIOS_DEBUG, "OK\n");
}
+enum cb_err psp_get_ftpm_capabilties(uint32_t *capabilities)
+{
+ int cmd_status;
+ struct mbox_cmd_capability_query_buffer buffer = {
+ .header = {
+ .size = sizeof(buffer)
+ },
+ };
+
+ printk(BIOS_DEBUG, "PSP: Querying fTPM capabilities...");
+
+ cmd_status = send_psp_command(MBOX_BIOS_CMD_PSP_FTPM_QUERY, &buffer);
+
+ /* buffer's status shouldn't change but report it if it does */
+ psp_print_cmd_status(cmd_status, &buffer.header);
+
+ if (!cmd_status)
+ return CB_ERR;
+
+ *capabilities = read32(&buffer.capabilities);
+ return CB_SUCCESS;
+}
+
+enum cb_err psp_get_hsti_state(uint32_t *state)
+{
+ int cmd_status;
+ struct mbox_cmd_hsti_query_buffer buffer = {
+ .header = {
+ .size = sizeof(buffer)
+ },
+ };
+
+ printk(BIOS_DEBUG, "PSP: Querying HSTI state...");
+
+ cmd_status = send_psp_command(MBOX_BIOS_CMD_HSTI_QUERY, &buffer);
+
+ /* buffer's status shouldn't change but report it if it does */
+ psp_print_cmd_status(cmd_status, &buffer.header);
+
+ if (!cmd_status)
+ return CB_ERR;
+
+ *state = read32(&buffer.state);
+ return CB_SUCCESS;
+}
+
/*
* Notify the PSP that the system is completing the boot process. Upon
* receiving this command, the PSP will only honor commands where the buffer
diff --git a/src/soc/amd/common/block/psp/psp_def.h b/src/soc/amd/common/block/psp/psp_def.h
index fa3ce36ca4..3cf2fc9f4b 100644
--- a/src/soc/amd/common/block/psp/psp_def.h
+++ b/src/soc/amd/common/block/psp/psp_def.h
@@ -23,7 +23,9 @@
#define MBOX_BIOS_CMD_CLEAR_S3_STS 0x07
#define MBOX_BIOS_CMD_S3_DATA_INFO 0x08
#define MBOX_BIOS_CMD_NOP 0x09
+#define MBOX_BIOS_CMD_HSTI_QUERY 0x14
#define MBOX_BIOS_CMD_PSB_AUTO_FUSING 0x21
+#define MBOX_BIOS_CMD_PSP_CAPS_QUERY 0x27
#define MBOX_BIOS_CMD_SET_SPL_FUSE 0x2d
#define MBOX_BIOS_CMD_QUERY_SPL_FUSE 0x47
#define MBOX_BIOS_CMD_I2C_TPM_ARBITRATION 0x64
@@ -84,6 +86,18 @@ struct mbox_cmd_sx_info_buffer {
u8 sleep_type;
} __packed __aligned(32);
+/* MBOX_BIOS_CMD_PSP_FTPM_QUERY, MBOX_BIOS_CMD_PSP_CAPS_QUERY */
+struct mbox_cmd_capability_query_buffer {
+ struct mbox_buffer_header header;
+ uint32_t capabilities;
+} __packed __aligned(32);
+
+/* MBOX_BIOS_CMD_HSTI_QUERY */
+struct mbox_cmd_hsti_query_buffer {
+ struct mbox_buffer_header header;
+ uint32_t state;
+} __packed __aligned(32);
+
/* MBOX_BIOS_CMD_SET_SPL_FUSE */
struct mbox_cmd_late_spl_buffer {
struct mbox_buffer_header header;
@@ -132,6 +146,9 @@ void psp_print_cmd_status(int cmd_status, struct mbox_buffer_header *header);
/* This command needs to be implemented by the generation specific code. */
int send_psp_command(u32 command, void *buffer);
+enum cb_err psp_get_ftpm_capabilties(uint32_t *capabilities);
+enum cb_err psp_get_psp_capabilities(uint32_t *capabilities);
+enum cb_err psp_get_hsti_state(uint32_t *state);
enum cb_err soc_read_c2p38(uint32_t *msg_38_value);
void enable_psp_smi(void);
diff --git a/src/soc/amd/common/block/psp/psp_gen2.c b/src/soc/amd/common/block/psp/psp_gen2.c
index bed31c1e8e..a587cda38a 100644
--- a/src/soc/amd/common/block/psp/psp_gen2.c
+++ b/src/soc/amd/common/block/psp/psp_gen2.c
@@ -177,6 +177,29 @@ int send_psp_command(u32 command, void *buffer)
return 0;
}
+enum cb_err psp_get_psp_capabilities(uint32_t *capabilities)
+{
+ int cmd_status;
+ struct mbox_cmd_capability_query_buffer buffer = {
+ .header = {
+ .size = sizeof(buffer)
+ },
+ };
+
+ printk(BIOS_DEBUG, "PSP: Querying PSP capabilities...");
+
+ cmd_status = send_psp_command(MBOX_BIOS_CMD_PSP_CAPS_QUERY, &buffer);
+
+ /* buffer's status shouldn't change but report it if it does */
+ psp_print_cmd_status(cmd_status, &buffer.header);
+
+ if (!cmd_status)
+ return CB_ERR;
+
+ *capabilities = read32(&buffer.capabilities);
+ return CB_SUCCESS;
+}
+
enum cb_err soc_read_c2p38(uint32_t *msg_38_value)
{
const uintptr_t psp_mmio = get_psp_mmio_base();