All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Kapl <rka@sysgo.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] tpm: wait for valid status
Date: Thu, 16 May 2019 18:32:48 +0200	[thread overview]
Message-ID: <20190516163248.10763-1-rka@sysgo.com> (raw)

The TPM specification says that the EXPECT_DATA bit is not valid until
the VALID bit is set. Wait for that bit to be set. Fixes problems with
Ifineon SPI TPM.

Signed-off-by: Roman Kapl <rka@sysgo.com>
---
 drivers/tpm/tpm2_tis_spi.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/tpm/tpm2_tis_spi.c b/drivers/tpm/tpm2_tis_spi.c
index 8878130bd7..7186c179d1 100644
--- a/drivers/tpm/tpm2_tis_spi.c
+++ b/drivers/tpm/tpm2_tis_spi.c
@@ -295,6 +295,14 @@ static int tpm_tis_spi_wait_for_stat(struct udevice *dev, u8 mask,
 	return -ETIMEDOUT;
 }
 
+static u8 tpm_tis_spi_valid_status(struct udevice *dev, u8 *status)
+{
+	struct tpm_chip *chip = dev_get_priv(dev);
+
+	return tpm_tis_spi_wait_for_stat(dev, TPM_STS_VALID,
+		chip->timeout_c, status);
+}
+
 static int tpm_tis_spi_get_burstcount(struct udevice *dev)
 {
 	struct tpm_chip *chip = dev_get_priv(dev);
@@ -455,7 +463,7 @@ static int tpm_tis_spi_send(struct udevice *dev, const u8 *buf, size_t len)
 		i += size;
 	}
 
-	ret = tpm_tis_spi_status(dev, &status);
+	ret = tpm_tis_spi_valid_status(dev, &status);
 	if (ret)
 		goto out_err;
 
@@ -469,7 +477,7 @@ static int tpm_tis_spi_send(struct udevice *dev, const u8 *buf, size_t len)
 	if (ret)
 		goto out_err;
 
-	ret = tpm_tis_spi_status(dev, &status);
+	ret = tpm_tis_spi_valid_status(dev, &status);
 	if (ret)
 		goto out_err;
 
-- 
2.20.1.390.gb5101f9297

             reply	other threads:[~2019-05-16 16:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16 16:32 Roman Kapl [this message]
2019-07-11 22:06 ` [U-Boot] [PATCH] tpm: wait for valid status Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190516163248.10763-1-rka@sysgo.com \
    --to=rka@sysgo.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.