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)
This commit is contained in:
parent
52ab30b13b
commit
e0668e4e1f
|
@ -39,3 +39,8 @@ config DRIVER_I2C_TPM_ACPI
|
||||||
bool "Generate I2C TPM ACPI device"
|
bool "Generate I2C TPM ACPI device"
|
||||||
default y if ARCH_X86 && I2C_TPM
|
default y if ARCH_X86 && I2C_TPM
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
config DRIVER_TPM_DISPLAY_TIS_BYTES
|
||||||
|
bool "TPM: Display the TIS transactions to I2C TPM chip"
|
||||||
|
default n
|
||||||
|
depends on I2C_TPM
|
||||||
|
|
|
@ -17,9 +17,11 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <commonlib/endian.h>
|
||||||
#include <delay.h>
|
#include <delay.h>
|
||||||
#include <device/i2c.h>
|
#include <device/i2c.h>
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
|
#include <lib.h>
|
||||||
#include <tpm.h>
|
#include <tpm.h>
|
||||||
#include "tpm.h"
|
#include "tpm.h"
|
||||||
#include <timer.h>
|
#include <timer.h>
|
||||||
|
@ -144,11 +146,19 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size,
|
||||||
{
|
{
|
||||||
uint8_t buf[TPM_BUFSIZE];
|
uint8_t buf[TPM_BUFSIZE];
|
||||||
|
|
||||||
|
ASSERT(sbuf_size >= 10);
|
||||||
if (sizeof(buf) < sbuf_size)
|
if (sizeof(buf) < sbuf_size)
|
||||||
return -1;
|
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);
|
int len = tpm_transmit(buf, sbuf_size);
|
||||||
|
|
||||||
if (len < 10) {
|
if (len < 10) {
|
||||||
|
@ -164,5 +174,13 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size,
|
||||||
memcpy(recvbuf, buf, len);
|
memcpy(recvbuf, buf, len);
|
||||||
*rbuf_len = 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue