tpm: use 4 byte quantities when retrieving firmware version

The CR50 device is capable of reporting its firmware version in 4 byte
quantities, but the recently introduced code retrieves the version one
byte at a time.

With this fix the version is retrieved in 4 byte chunks.

BRANCH=none
BUG=none

TEST=the version is still reported properly, as reported by the AP
     firmware console log:

  localhost ~ # grep cr50 /sys/firmware/log
  Firmware version: cr50_v1.1.4804-c64cf24
  localhost ~ #

Change-Id: I04116881a30001e35e989e51ec1567263f9149a6
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/356542
Reviewed-by: Andrey Pronin <apronin@chromium.org>
diff --git a/src/drivers/spi/tpm/tpm.c b/src/drivers/spi/tpm/tpm.c
index 1b43bfb..4de62d9 100644
--- a/src/drivers/spi/tpm/tpm.c
+++ b/src/drivers/spi/tpm/tpm.c
@@ -359,7 +359,8 @@
 	/* 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 */
+		uint32_t chunk = 0;
+		char vstr[sizeof(chunk) + 1];	/* room for 4 chars + zero */
 
 		printk(BIOS_INFO, "Firmware version: ");
 
@@ -367,12 +368,12 @@
 		 * 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));
+		tpm2_write_reg(TPM_FW_VER, &chunk, sizeof(chunk));
 
 		/* Print it out in 4 byte chunks. */
 		vstr[sizeof(vstr) - 1] = 0;
 		do {
-			tpm2_read_reg(TPM_FW_VER, vstr, sizeof(cmd));
+			tpm2_read_reg(TPM_FW_VER, vstr, sizeof(chunk));
 			printk(BIOS_INFO, "%s", vstr);
 
 			/*
@@ -381,7 +382,7 @@
 			 * 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))));
+		} while (vstr[0] && (chunk_count++ < (200 / sizeof(chunk))));
 
 		printk(BIOS_INFO, "\n");
 	}