Martin Roth (martinroth@google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15573
-gerrit
commit 6b228f91985cc1738cab221da70a5b22ad5501ae Author: Vadim Bendebury vbendeb@chromium.org Date: Thu Jun 23 18:17:33 2016 -0700
tpm: report firmware version
Some devices allow to retrieve firmware version by reading the same 4 byte register repeatedly until the entire version string is read.
Let's print out TPM firmware version when available. Just in case something goes wrong limit the version string length to 200 bytes.
CQ-DEPEND=CL:355701 BRANCH=none BUG=chrome-os-partner:54723 TEST=built the new firmware and ran it on Gru, observed the following in the coreboot console log:
Connected to device vid:did:rid of 1ae0:0028:00 Firmware version: cr50_v1.1.4792-7a44484
Change-Id: Ia9f13a5bf1c34292b866f57c0d14470fe6ca9853 Signed-off-by: Martin Roth martinroth@chromium.org Original-Commit-Id: 1f54a30cebe808abf1b09478b47924bb722a0ca6 Original-Change-Id: Idb069dabb80d34a0efdf04c3c40a42ab0c8a3f94 Original-Signed-off-by: Vadim Bendebury vbendeb@chromium.org Original-Reviewed-on: https://chromium-review.googlesource.com/355704 Original-Reviewed-by: Scott Collyer scollyer@chromium.org --- src/drivers/spi/tpm/tpm.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/src/drivers/spi/tpm/tpm.c b/src/drivers/spi/tpm/tpm.c index b02fc5f..1b43bfb 100644 --- a/src/drivers/spi/tpm/tpm.c +++ b/src/drivers/spi/tpm/tpm.c @@ -32,6 +32,7 @@ #define TPM_DATA_FIFO_REG (TPM_LOCALITY_0_SPI_BASE + 0x24) #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)
/* SPI Interface descriptor used by the driver. */ struct tpm_spi_if { @@ -355,6 +356,35 @@ int tpm2_init(struct spi_slave *spi_if) printk(BIOS_INFO, "Connected to device vid:did:rid of %4.4x:%4.4x:%2.2x\n", tpm_info.vendor_id, tpm_info.device_id, tpm_info.revision);
+ /* Let's report device FW version if available. */ + if (tpm_info.vendor_id == 0x1ae0) { + int chunk_count = 0; + char vstr[sizeof(cmd) + 1]; /* room for 4 chars + zero */ + + printk(BIOS_INFO, "Firmware version: "); + + /* + * Does not really matter what's written, this just makes sure + * the version is reported from the beginning. + */ + tpm2_write_reg(TPM_FW_VER, &cmd, sizeof(cmd)); + + /* Print it out in 4 byte chunks. */ + vstr[sizeof(vstr) - 1] = 0; + do { + tpm2_read_reg(TPM_FW_VER, vstr, sizeof(cmd)); + printk(BIOS_INFO, "%s", vstr); + + /* + * While string is not over, and no more than 200 + * characters. + * This is likely result in one extra printk() + * invocation with an empty string, not a big deal. + */ + } while (vstr[0] && (chunk_count++ < (200 / sizeof(cmd)))); + + printk(BIOS_INFO, "\n"); + } return 0; }