mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
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: Idb069dabb80d34a0efdf04c3c40a42ab0c8a3f94 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/355704 Reviewed-by: Scott Collyer <scollyer@chromium.org>
This commit is contained in:
parent
be1194b095
commit
1f54a30ceb
1 changed files with 30 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue