diff options
author | Lee Leahy <leroy.p.leahy@intel.com> | 2017-01-08 11:38:14 -0800 |
---|---|---|
committer | Lee Leahy <leroy.p.leahy@intel.com> | 2017-03-16 00:04:31 +0100 |
commit | e0668e4e1f3b2f47e474f870bb5d72a488e43504 (patch) | |
tree | e4d16752f2b30310caaf55e57575e6870a1035bd | |
parent | 52ab30b13b867c1f3cd5aa5d9eb3e24d430c49d5 (diff) |
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 <leroy.p.leahy@intel.com>
Reviewed-on: https://review.coreboot.org/18799
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins)
-rw-r--r-- | src/drivers/i2c/tpm/Kconfig | 5 | ||||
-rw-r--r-- | src/drivers/i2c/tpm/tis.c | 20 |
2 files changed, 24 insertions, 1 deletions
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 <stdint.h> #include <string.h> #include <assert.h> +#include <commonlib/endian.h> #include <delay.h> #include <device/i2c.h> #include <endian.h> +#include <lib.h> #include <tpm.h> #include "tpm.h" #include <timer.h> @@ -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; } |