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>
---
src/hw/tpm_drivers.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c
index 13ad821..da8bb63 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))
--
2.14.3
_______________________________________________
SeaBIOS mailing list
SeaBIOS@seabios.org
https://mail.coreboot.org/mailman/listinfo/seabios
On Tue, Feb 27, 2018 at 02:17:10PM -0500, Stephen Douthit wrote: > 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> > --- > src/hw/tpm_drivers.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c > index 13ad821..da8bb63 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; > + Thanks. I was about to commit this when I noticed the above. In the case where tis_wait_access() fails due to a timeout, shouldn't tis_probe() return an error indicator instead of success? -Kevin _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios
On 03/02/2018 11:05 AM, Kevin O'Connor wrote: > On Tue, Feb 27, 2018 at 02:17:10PM -0500, Stephen Douthit wrote: >> 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> >> --- >> src/hw/tpm_drivers.c | 13 ++++++++++++- >> 1 file changed, 12 insertions(+), 1 deletion(-) >> >> diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c >> index 13ad821..da8bb63 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; >> + > > Thanks. I was about to commit this when I noticed the above. In the > case where tis_wait_access() fails due to a timeout, shouldn't > tis_probe() return an error indicator instead of success? tis_probe() returns 0 for no device, '1' for device present. Take a look at the usage in tpmhw_probe(), or the comment on tis_probe() itself. Thanks, Steve _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios
On Fri, Mar 02, 2018 at 11:27:46AM -0500, Stephen Douthit wrote: > On 03/02/2018 11:05 AM, Kevin O'Connor wrote: > > On Tue, Feb 27, 2018 at 02:17:10PM -0500, Stephen Douthit wrote: > > > 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> > > > --- > > > src/hw/tpm_drivers.c | 13 ++++++++++++- > > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > > > diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c > > > index 13ad821..da8bb63 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; > > > + > > > > Thanks. I was about to commit this when I noticed the above. In the > > case where tis_wait_access() fails due to a timeout, shouldn't > > tis_probe() return an error indicator instead of success? > > tis_probe() returns 0 for no device, '1' for device present. > > Take a look at the usage in tpmhw_probe(), or the comment on > tis_probe() itself. Okay, thanks for clarifying. -Kevin _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios
On 02/27/2018 02:17 PM, Stephen Douthit wrote: > 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> > --- > src/hw/tpm_drivers.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c > index 13ad821..da8bb63 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)) _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios
© 2016 - 2025 Red Hat, Inc.