From: Simon Glass Date: Tue, 1 Apr 2025 21:28:10 +0000 (+1300) Subject: tpm: cr50: Support opening the TPM multiple times X-Git-Tag: v2025.07-rc1~64^2 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=275777bc94cf1673b38d4d5438dfb07df7902603;p=pandora-u-boot.git tpm: cr50: Support opening the TPM multiple times The tpm_auto_start() function is used in tests and assumes that it can open the TPM even if it is already open and a locality claimed. The cr50 driver does not use the common TPM2 TIS code so lacks a check for the is_open field of struct tpm_chip and in fact it doesn't use that struct. Add an equivalent check to cr50_i2c_open(). This fixes all init sequences on that TPM -- e.g 'tpm init && tpm init' or 'tpm autostart && tpm init' used to hang Signed-off-by: Simon Glass Reviewed-by: Ilias Apalodimas Signed-off-by: Ilias Apalodimas --- diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c index 08ec179346e..5b2d5ccb146 100644 --- a/drivers/tpm/cr50_i2c.c +++ b/drivers/tpm/cr50_i2c.c @@ -737,9 +737,13 @@ static int cr50_i2c_report_state(struct udevice *dev, char *str, int str_max) static int cr50_i2c_open(struct udevice *dev) { + struct cr50_priv *priv = dev_get_priv(dev); char buf[80]; int ret; + if (priv->locality != -1) + return -EBUSY; + ret = process_reset(dev); if (ret) return log_msg_ret("reset", ret);