Attention is currently required from: Michał Żygowski, Julius Werner, Krystian Hebel.
Hello Michał Żygowski, Julius Werner, Krystian Hebel,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/69022
to review the following change.
Change subject: drivers/spi/tpm: verify device supports TPM2 ......................................................................
drivers/spi/tpm: verify device supports TPM2
This is to handle the situation when device ID is the same for TPM1 and TPM2 versions of a device.
Change-Id: Ib2840a21b3be8928d39570281f86a0e26b38b5f9 Ticket: https://ticket.coreboot.org/issues/433 Signed-off-by: Sergii Dmytruk sergii.dmytruk@3mdeb.com --- M src/drivers/spi/tpm/tpm.c 1 file changed, 25 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/22/69022/1
diff --git a/src/drivers/spi/tpm/tpm.c b/src/drivers/spi/tpm/tpm.c index 68f9588..8b390f0 100644 --- a/src/drivers/spi/tpm/tpm.c +++ b/src/drivers/spi/tpm/tpm.c @@ -28,6 +28,7 @@ #define TPM_ACCESS_REG (TPM_LOCALITY_0_SPI_BASE + 0) #define TPM_STS_REG (TPM_LOCALITY_0_SPI_BASE + 0x18) #define TPM_DATA_FIFO_REG (TPM_LOCALITY_0_SPI_BASE + 0x24) +#define TPM_INTF_ID_REG (TPM_LOCALITY_0_SPI_BASE + 0x30) #define TPM_DID_VID_REG (TPM_LOCALITY_0_SPI_BASE + 0xf00) #define TPM_RID_REG (TPM_LOCALITY_0_SPI_BASE + 0xf04) #define TPM_FW_VER (TPM_LOCALITY_0_SPI_BASE + 0xf90) @@ -412,7 +413,7 @@
int tpm2_init(struct spi_slave *spi_if) { - uint32_t did_vid, status; + uint32_t did_vid, status, intf_id; uint8_t cmd; int retries;
@@ -454,6 +455,15 @@
printk(BIOS_INFO, " done!\n");
+ if (tpm2_read_reg(TPM_INTF_ID_REG, &intf_id, sizeof(intf_id)) != CB_SUCCESS) { + printk(BIOS_ERR, "\n%s: Failed to read interface ID register\n", __func__); + return -1; + } + if ((be32toh(intf_id) & 0xF) == 0xF) { + printk(BIOS_DEBUG, "\n%s: Not a TPM2 device\n", __func__); + return -1; + } + // FIXME: Move this to tpm_setup() if (tpm_first_access_this_boot()) /*