diff options
author | Stephen Douthit <stephend@silicom-usa.com> | 2018-02-27 14:17:10 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-03-02 10:59:24 -0500 |
commit | 96060ad1c38a3e90125aa4676b30828be126a4d5 (patch) | |
tree | 17f8135c232b59513047096835f554d42d813122 | |
parent | 559b3e2ba43c80ac02a67903d57ae1acad5dfff1 (diff) | |
download | seabios-96060ad1c38a3e90125aa4676b30828be126a4d5.tar.gz |
tpm: Wait for interface startup when probing
This is based on wait_startup() from the Linux tpm_tis driver.
Signed-off-by: Stephen Douthit <stephend@silicom-usa.com>
Tested-by: Stephen Douthit <stephend@silicom-usa.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
-rw-r--r-- | src/hw/tpm_drivers.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c index 13ad821d..da8bb634 100644 --- a/src/hw/tpm_drivers.c +++ b/src/hw/tpm_drivers.c @@ -86,6 +86,11 @@ static u32 wait_reg8(u8* reg, u32 time, u8 mask, u8 expect) return rc; } +static u32 tis_wait_access(u8 locty, u32 time, u8 mask, u8 expect) +{ + return wait_reg8(TIS_REG(locty, TIS_REG_ACCESS), time, mask, expect); +} + static u32 tis_wait_sts(u8 locty, u32 time, u8 mask, u8 expect) { return wait_reg8(TIS_REG(locty, TIS_REG_STS), time, mask, expect); @@ -102,7 +107,13 @@ static u32 tis_probe(void) if (!CONFIG_TCGBIOS) return 0; - u32 rc = 0; + /* Wait for the interface to report it's ready */ + u32 rc = tis_wait_access(0, TIS_DEFAULT_TIMEOUT_A, + TIS_ACCESS_TPM_REG_VALID_STS, + TIS_ACCESS_TPM_REG_VALID_STS); + if (rc) + return 0; + u32 didvid = readl(TIS_REG(0, TIS_REG_DID_VID)); if ((didvid != 0) && (didvid != 0xffffffff)) |