From e0668e4e1f3b2f47e474f870bb5d72a488e43504 Mon Sep 17 00:00:00 2001 From: Lee Leahy Date: Sun, 8 Jan 2017 11:38:14 -0800 Subject: drivers/i2c/tpm: Add TPM (TIS) debugging support Add debugging support for the TIS transactions for the I2C TPM chips. TEST=Build and run on reef Change-Id: Ibc7e26fca781316d625f4da080f34749f18e4f9b Signed-off-by: Lee Leahy Reviewed-on: https://review.coreboot.org/18799 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/drivers/i2c/tpm/Kconfig | 5 +++++ src/drivers/i2c/tpm/tis.c | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/i2c/tpm/Kconfig b/src/drivers/i2c/tpm/Kconfig index 89e4621b77..d35eb754b4 100644 --- a/src/drivers/i2c/tpm/Kconfig +++ b/src/drivers/i2c/tpm/Kconfig @@ -39,3 +39,8 @@ config DRIVER_I2C_TPM_ACPI bool "Generate I2C TPM ACPI device" default y if ARCH_X86 && I2C_TPM default n + +config DRIVER_TPM_DISPLAY_TIS_BYTES + bool "TPM: Display the TIS transactions to I2C TPM chip" + default n + depends on I2C_TPM diff --git a/src/drivers/i2c/tpm/tis.c b/src/drivers/i2c/tpm/tis.c index a0d05409ef..6bb0e969e9 100644 --- a/src/drivers/i2c/tpm/tis.c +++ b/src/drivers/i2c/tpm/tis.c @@ -17,9 +17,11 @@ #include #include #include +#include #include #include #include +#include #include #include "tpm.h" #include @@ -144,11 +146,19 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, { uint8_t buf[TPM_BUFSIZE]; + ASSERT(sbuf_size >= 10); if (sizeof(buf) < sbuf_size) return -1; - memcpy(buf, sendbuf, sbuf_size); + /* Display the TPM command */ + if (IS_ENABLED(CONFIG_DRIVER_TPM_DISPLAY_TIS_BYTES)) { + printk(BIOS_DEBUG, "TPM Command: 0x%08x\n", + read_at_be32(sendbuf, sizeof(uint16_t) + + sizeof(uint32_t))); + hexdump(sendbuf, sbuf_size); + } + memcpy(buf, sendbuf, sbuf_size); int len = tpm_transmit(buf, sbuf_size); if (len < 10) { @@ -164,5 +174,13 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, memcpy(recvbuf, buf, len); *rbuf_len = len; + /* Display the TPM response */ + if (IS_ENABLED(CONFIG_DRIVER_TPM_DISPLAY_TIS_BYTES)) { + printk(BIOS_DEBUG, "TPM Response: 0x%08x\n", + read_at_be32(recvbuf, sizeof(uint16_t) + + sizeof(uint32_t))); + hexdump(recvbuf, *rbuf_len); + } + return 0; } -- cgit v1.2.3