summaryrefslogtreecommitdiff
path: root/src/soc/amd/common/block/psp/psp.c
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/amd/common/block/psp/psp.c
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/amd/common/block/psp/psp.c')
-rw-r--r--src/soc/amd/common/block/psp/psp.c46
1 files changed, 46 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