<p>Shelley Chen has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/22370">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">drivers/spi/tpm: Poll TPM_VALID bit until valid<br><br>In case the TPM is doing a long crypto operation the initial probe<br>could be very delayed.  Rather than end up in recovery make the delay<br>long enough to accommodate the (current) long crypto times.<br><br>Mirroring changes done on i2c side in CL:756918<br><br>BUG=b:65867313<br>BRANCH=None<br>TEST=Make sure fizz boots up<br><br>Change-Id: Ie944bfb6fe33d6e9ee794439165716ab624be491<br>---<br>M src/drivers/spi/tpm/tpm.c<br>1 file changed, 11 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/70/22370/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/drivers/spi/tpm/tpm.c b/src/drivers/spi/tpm/tpm.c<br>index 58bf842..8d654dd 100644<br>--- a/src/drivers/spi/tpm/tpm.c<br>+++ b/src/drivers/spi/tpm/tpm.c<br>@@ -37,6 +37,8 @@<br> #define TPM_RID_REG       (TPM_LOCALITY_0_SPI_BASE + 0xf04)<br> #define TPM_FW_VER        (TPM_LOCALITY_0_SPI_BASE + 0xf90)<br> <br>+#define CR50_TIMEOUT_INIT_MS 30000 /* Very long timeout for TPM init */<br>+<br> /* SPI slave structure for TPM device. */<br> static struct spi_slave g_spi_slave CAR_GLOBAL;<br> <br>@@ -342,6 +344,8 @@<br> static int tpm2_claim_locality(void)<br> {<br>  uint8_t access;<br>+      struct stopwatch sw;<br>+ long sw_run_duration = CR50_TIMEOUT_INIT_MS;<br> <br>       access = tpm2_read_access_reg();<br>      /*<br>@@ -353,6 +357,13 @@<br>              access = tpm2_read_access_reg();<br>      }<br> <br>+ /*<br>+    * If cr50 is doing a long crypto operation, it can take up to<br>+        * 30 seconds to get a valid status value back<br>+        */<br>+  stopwatch_init_msecs_expire(&sw, sw_run_duration);<br>+       while (!stopwatch_expired(&sw) && access != TPM_ACCESS_VALID)<br>+            access = tpm2_read_access_reg();<br>      if (access != TPM_ACCESS_VALID) {<br>             printk(BIOS_ERR, "Invalid reset status: %#x\n", access);<br>            return 0;<br></pre><p>To view, visit <a href="https://review.coreboot.org/22370">change 22370</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/22370"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ie944bfb6fe33d6e9ee794439165716ab624be491 </div>
<div style="display:none"> Gerrit-Change-Number: 22370 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Shelley Chen <shchen@google.com> </div>