summaryrefslogtreecommitdiff
path: root/test/tpm_test/ftdi_spi_tpm.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/tpm_test/ftdi_spi_tpm.c')
-rw-r--r--test/tpm_test/ftdi_spi_tpm.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/tpm_test/ftdi_spi_tpm.c b/test/tpm_test/ftdi_spi_tpm.c
index 713a8d7ac9..752e80bed4 100644
--- a/test/tpm_test/ftdi_spi_tpm.c
+++ b/test/tpm_test/ftdi_spi_tpm.c
@@ -75,6 +75,19 @@ void FtdiStop(void)
mpsse_ = NULL;
}
+/*
+ * If the TPM is asleep we may need to poke it once to wake it up. Just assert
+ * the CS briefly without sending any data, then wait a bit to be sure it's
+ * awake.
+ */
+static void FtdiSpiPoke(void)
+{
+ Start(mpsse_);
+ usleep(1000);
+ Stop(mpsse_);
+ usleep(60000);
+}
+
static void StartTransaction(int read_write, size_t bytes, unsigned addr)
{
struct SpiFrameHeader header;
@@ -210,6 +223,8 @@ int FtdiSpiInit(uint32_t freq, int enable_debug)
/* Just in case, make sure bootsrap is not triggered. */
PinLow(mpsse_, GPIOL0);
+ FtdiSpiPoke();
+
FtdiReadReg(TPM_DID_VID_REG, sizeof(did_vid), &did_vid);
vid = did_vid & 0xffff;