aboutsummaryrefslogtreecommitdiff
path: root/drivers/tpm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-12-31 09:52:12 -0700
committerSimon Glass <sjg@chromium.org>2021-01-30 14:25:41 -0700
commit6208975e237c9549cab50756c6291d3ecde953b7 (patch)
treeddf7f0c146cb7db26451e4ec01c58835a900093b /drivers/tpm
parent472a716b8fdfd88a27cb675e4ea8e12cb4f79fc3 (diff)
downloadu-boot-6208975e237c9549cab50756c6291d3ecde953b7.zip
u-boot-6208975e237c9549cab50756c6291d3ecde953b7.tar.gz
u-boot-6208975e237c9549cab50756c6291d3ecde953b7.tar.bz2
tpm: cr50: Check for valid locality
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>
Diffstat (limited to 'drivers/tpm')
-rw-r--r--drivers/tpm/cr50_i2c.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c
index ce61b72..f53924a 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);
}