diff options
-rw-r--r-- | src/soc/amd/common/block/psp/psp.c | 46 | ||||
-rw-r--r-- | src/soc/amd/common/block/psp/psp_def.h | 17 | ||||
-rw-r--r-- | src/soc/amd/common/block/psp/psp_gen2.c | 23 |
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(); |