All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] tpm: cr50: Check for valid locality
@ 2020-12-31 16:52 Simon Glass
  2020-12-31 16:52 ` [PATCH 2/5] tpm: cr50: Add a better description and more debug Simon Glass
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Simon Glass @ 2020-12-31 16:52 UTC (permalink / raw)
  To: u-boot

When the Cr50 starts up it doesn't have a valid locality. The driver sets
it to -1 to indicate that. Tracking this allows cr50_i2c_cleanup() to
avoid releasing a locality that was not claimed.

However the helper functions that generate the flags use a u8 type which
cannot support -1, so they return a locality of 0xff.

Fix this by updating the type. With this, 'tpm startup TPM2_SU_CLEAR'
works as expected.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/tpm/cr50_i2c.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c
index ce61b72d222..f53924a8fcb 100644
--- a/drivers/tpm/cr50_i2c.c
+++ b/drivers/tpm/cr50_i2c.c
@@ -183,23 +183,31 @@ static int cr50_i2c_write(struct udevice *dev, u8 addr, const u8 *buffer,
 	return cr50_i2c_wait_tpm_ready(dev);
 }
 
-static inline u8 tpm_access(u8 locality)
+static inline u8 tpm_access(int locality)
 {
+	if (locality == -1)
+		locality = 0;
 	return 0x0 | (locality << 4);
 }
 
-static inline u8 tpm_sts(u8 locality)
+static inline u8 tpm_sts(int locality)
 {
+	if (locality == -1)
+		locality = 0;
 	return 0x1 | (locality << 4);
 }
 
-static inline u8 tpm_data_fifo(u8 locality)
+static inline u8 tpm_data_fifo(int locality)
 {
+	if (locality == -1)
+		locality = 0;
 	return 0x5 | (locality << 4);
 }
 
-static inline u8 tpm_did_vid(u8 locality)
+static inline u8 tpm_did_vid(int locality)
 {
+	if (locality == -1)
+		locality = 0;
 	return 0x6 | (locality << 4);
 }
 
-- 
2.29.2.729.g45daf8777d-goog

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-01-23 17:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31 16:52 [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass
2020-12-31 16:52 ` [PATCH 2/5] tpm: cr50: Add a better description and more debug Simon Glass
2020-12-31 16:52 ` [PATCH 3/5] tpm: cr50: Rename driver to work with of-platdata Simon Glass
2020-12-31 16:52 ` [PATCH 4/5] x86: coral: Update an unused pin to reduce power Simon Glass
2020-12-31 16:52 ` [PATCH 5/5] x86: coral: Enable CONFIG_BOOTARGS_SUBST Simon Glass
2021-01-23 17:27 ` Simon Glass
2021-01-23 17:27 ` [PATCH 4/5] x86: coral: Update an unused pin to reduce power Simon Glass
2021-01-23 17:27 ` [PATCH 3/5] tpm: cr50: Rename driver to work with of-platdata Simon Glass
2021-01-23 17:27 ` [PATCH 2/5] tpm: cr50: Add a better description and more debug Simon Glass
2021-01-23 17:27 ` [PATCH 1/5] tpm: cr50: Check for valid locality Simon Glass

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.