summaryrefslogtreecommitdiffstats
path: root/src/drivers/spi
diff options
context:
space:
mode:
authorSergii Dmytruk <sergii.dmytruk@3mdeb.com>2022-10-30 17:18:33 +0200
committerFelix Held <felix-coreboot@felixheld.de>2022-12-21 14:48:59 +0000
commitdf853501f854f8e6cfc989b0881026331940cf30 (patch)
treef8d802d6be0dc3fe99711cc9ce3545d4c281dd8b /src/drivers/spi
parentd43154486d27323f64334203e9bc8baf08af6845 (diff)
downloadcoreboot-df853501f854f8e6cfc989b0881026331940cf30.tar.gz
coreboot-df853501f854f8e6cfc989b0881026331940cf30.tar.bz2
coreboot-df853501f854f8e6cfc989b0881026331940cf30.zip
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> Reviewed-on: https://review.coreboot.org/c/coreboot/+/69022 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers/spi')
-rw-r--r--src/drivers/spi/tpm/tpm.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/drivers/spi/tpm/tpm.c b/src/drivers/spi/tpm/tpm.c
index 68f9588d53ef..976a8d894e80 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 @@ static const uint32_t supported_did_vids[] = {
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,20 @@ int tpm2_init(struct spi_slave *spi_if)
printk(BIOS_INFO, " done!\n");
+ /* Google TPMs haven't always been 100% accurate in reflecting the spec (particularly
+ * on older versions) and are always TPM 2.0. */
+ if (!CONFIG(TPM_GOOGLE)) {
+ 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())
/*