diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tpm-v1.c | 14 | ||||
-rw-r--r-- | lib/tpm-v2.c | 8 | ||||
-rw-r--r-- | lib/tpm_api.c | 19 |
3 files changed, 30 insertions, 11 deletions
diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c index d0e3ab1b21..60a18ca504 100644 --- a/lib/tpm-v1.c +++ b/lib/tpm-v1.c @@ -69,6 +69,20 @@ u32 tpm1_continue_self_test(struct udevice *dev) return tpm_sendrecv_command(dev, command, NULL, NULL); } +u32 tpm1_auto_start(struct udevice *dev) +{ + u32 rc; + + rc = tpm1_startup(dev, TPM_ST_CLEAR); + /* continue on if the TPM is already inited */ + if (rc && rc != TPM_INVALID_POSTINIT) + return rc; + + rc = tpm1_self_test_full(dev); + + return rc; +} + u32 tpm1_clear_and_reenable(struct udevice *dev) { u32 ret; diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c index 895b093bcb..9ab5b46df1 100644 --- a/lib/tpm-v2.c +++ b/lib/tpm-v2.c @@ -48,14 +48,6 @@ u32 tpm2_auto_start(struct udevice *dev) { u32 rc; - /* - * 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; rc = tpm2_self_test(dev, TPMI_YES); if (rc == TPM2_RC_INITIALIZE) { 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) |