summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/soc/amd/common/block/include/amdblocks/psp.h3
-rw-r--r--src/soc/amd/common/block/psp/Makefile.inc1
-rw-r--r--src/soc/amd/common/block/psp/psp_def.h18
-rw-r--r--src/soc/amd/common/block/psp/tpm.c26
4 files changed, 48 insertions, 0 deletions
diff --git a/src/soc/amd/common/block/include/amdblocks/psp.h b/src/soc/amd/common/block/include/amdblocks/psp.h
index c9986cae00..abdb762af8 100644
--- a/src/soc/amd/common/block/include/amdblocks/psp.h
+++ b/src/soc/amd/common/block/include/amdblocks/psp.h
@@ -75,4 +75,7 @@ void psp_notify_sx_info(u8 sleep_type);
int psp_load_named_blob(enum psp_blob_type type, const char *name);
+/* Sets the GPIO used for the TPM IRQ */
+void psp_set_tpm_irq_gpio(unsigned int gpio);
+
#endif /* AMD_BLOCK_PSP_H */
diff --git a/src/soc/amd/common/block/psp/Makefile.inc b/src/soc/amd/common/block/psp/Makefile.inc
index 5dd7fdd941..c3b0161514 100644
--- a/src/soc/amd/common/block/psp/Makefile.inc
+++ b/src/soc/amd/common/block/psp/Makefile.inc
@@ -23,6 +23,7 @@ ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_PSP_GEN2),y)
romstage-y += psp_gen2.c
ramstage-y += psp_gen2.c
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-y += psp_smm_gen2.c
diff --git a/src/soc/amd/common/block/psp/psp_def.h b/src/soc/amd/common/block/psp/psp_def.h
index 6dcf5b48dc..1d87878c03 100644
--- a/src/soc/amd/common/block/psp/psp_def.h
+++ b/src/soc/amd/common/block/psp/psp_def.h
@@ -20,6 +20,7 @@
#define MBOX_BIOS_CMD_PSB_AUTO_FUSING 0x21
#define MBOX_BIOS_CMD_SET_SPL_FUSE 0x2d
#define MBOX_BIOS_CMD_QUERY_SPL_FUSE 0x47
+#define MBOX_BIOS_CMD_I2C_TPM_ARBITRATION 0x64
#define MBOX_BIOS_CMD_ABORT 0xfe
/* x86 to PSP commands, v1-only */
@@ -81,6 +82,23 @@ struct mbox_cmd_late_spl_buffer {
uint32_t spl_value;
} __attribute__((packed, aligned(32)));
+struct dtpm_config {
+ uint32_t gpio;
+} __packed;
+
+enum dtpm_request_type {
+ DTPM_REQUEST_ACQUIRE, /* Acquire I2C bus */
+ DTPM_REQUEST_RELEASE, /* Release I2C bus */
+ DTPM_REQUEST_CONFIG, /* Provide DTPM info */
+ DTPM_REQUEST_MAX,
+};
+
+struct mbox_cmd_dtpm_config_buffer {
+ struct mbox_buffer_header header;
+ uint32_t request_type;
+ struct dtpm_config config;
+} __packed __aligned(32);
+
#define PSP_INIT_TIMEOUT 10000 /* 10 seconds */
#define PSP_CMD_TIMEOUT 1000 /* 1 second */
diff --git a/src/soc/amd/common/block/psp/tpm.c b/src/soc/amd/common/block/psp/tpm.c
new file mode 100644
index 0000000000..3fd50ea6be
--- /dev/null
+++ b/src/soc/amd/common/block/psp/tpm.c
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <amdblocks/psp.h>
+#include <console/console.h>
+#include <types.h>
+#include "psp_def.h"
+
+void psp_set_tpm_irq_gpio(unsigned int gpio)
+{
+ int cmd_status;
+ struct mbox_cmd_dtpm_config_buffer buffer = {
+ .header = {
+ .size = sizeof(buffer)
+ },
+ .request_type = DTPM_REQUEST_CONFIG,
+ .config = {
+ .gpio = gpio
+ }
+ };
+
+ printk(BIOS_DEBUG, "PSP: Setting TPM GPIO to %u...", gpio);
+
+ cmd_status = send_psp_command(MBOX_BIOS_CMD_I2C_TPM_ARBITRATION, &buffer);
+
+ psp_print_cmd_status(cmd_status, &buffer.header);
+}