aboutsummaryrefslogtreecommitdiff
path: root/lib/tpm_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tpm_api.c')
-rw-r--r--lib/tpm_api.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/tpm_api.c b/lib/tpm_api.c
index 5b2c11a277..3ef5e81179 100644
--- a/lib/tpm_api.c
+++ b/lib/tpm_api.c
@@ -37,10 +37,23 @@ u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode)
u32 tpm_auto_start(struct udevice *dev)
{
- if (tpm_is_v2(dev))
- return tpm2_auto_start(dev);
+ u32 rc;
- return -ENOSYS;
+ /*
+ * the tpm_init() will return -EBUSY if the init has already happened
+ * The selftest and startup code can run multiple times with no side
+ * effects
+ */
+ rc = tpm_init(dev);
+ if (rc && rc != -EBUSY)
+ return rc;
+
+ if (tpm_is_v1(dev))
+ return tpm1_auto_start(dev);
+ else if (tpm_is_v2(dev))
+ return tpm2_auto_start(dev);
+ else
+ return -ENOSYS;
}
u32 tpm_resume(struct udevice *dev)