]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
tpm: Wait for tpmRegValidSts flag on CRB interface before probing
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Mon, 19 Mar 2018 16:00:27 +0000 (12:00 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 21 Mar 2018 14:34:53 +0000 (10:34 -0400)
Wait for the tpmRegValidSts flag on the TPM_LOC_STATE_x register to
be set; we expect the locAssigned flag to not be set.

Real hardware seems to set the tpmRegValidSts flag without for
example requesting access to a locality.

Tested-by: Stephen Douthit <stephend@silicom-usa.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
src/hw/tpm_drivers.c

index ed58bf58849096f0e62a3b61fe9ead886c1b13f6..7e6a96a41c2149fd70b6e890c79789ebb9b1a2bf 100644 (file)
@@ -374,12 +374,22 @@ static u32 tis_waitrespready(enum tpmDurationType to_t)
     return rc;
 }
 
+#define CRB_STATE_VALID_STS 0b10000000
+#define CRB_STATE_LOC_ASSIGNED 0x00000010
+#define CRB_STATE_READY_MASK (CRB_STATE_VALID_STS | CRB_STATE_LOC_ASSIGNED)
+
 /* if device is not there, return '0', '1' otherwise */
 static u32 crb_probe(void)
 {
     if (!CONFIG_TCGBIOS)
         return 0;
 
+    /* Wait for the interface to report it's ready */
+    u32 rc = crb_wait_reg(0, CRB_REG_LOC_STATE, TIS2_DEFAULT_TIMEOUT_D,
+                          CRB_STATE_READY_MASK, CRB_STATE_VALID_STS);
+    if (rc)
+        return 0;
+
     u32 ifaceid = readl(CRB_REG(0, CRB_REG_INTF_ID));
 
     if ((ifaceid & 0xf) != 0xf) {