u32 tpm2_enable_nvcommits(struct udevice *dev, uint vendor_cmd,
uint vendor_subcmd);
+/**
+ * tpm2_auto_start() - start up the TPM and perform selftests.
+ * If a testable function has not been tested and is
+ * requested the TPM2 will return TPM_RC_NEEDS_TEST.
+ *
+ * @param dev TPM device
+ * Return: TPM2_RC_TESTING, if TPM2 self-test is in progress.
+ * TPM2_RC_SUCCESS, if testing of all functions is complete without
+ * functional failures.
+ * TPM2_RC_FAILURE, if any test failed.
+ * TPM2_RC_INITIALIZE, if the TPM has not gone through the Startup
+ * sequence
+
+ */
+u32 tpm2_auto_start(struct udevice *dev);
+
#endif /* __TPM_V2_H */
return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2;
}
+/**
+ * tpm_auto_start() - start up the TPM and perform selftests
+ *
+ * @param dev TPM device
+ * Return: return code of the operation (0 = success)
+ */
+u32 tpm_auto_start(struct udevice *dev);
+
#endif /* __TPM_API_H */
return tpm_sendrecv_command(dev, command_v2, NULL, NULL);
}
+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) {
+ rc = tpm2_startup(dev, TPM2_SU_CLEAR);
+ if (rc)
+ return rc;
+
+ rc = tpm2_self_test(dev, TPMI_YES);
+ }
+
+ return rc;
+}
+
u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw,
const ssize_t pw_sz)
{
}
}
+u32 tpm_auto_start(struct udevice *dev)
+{
+ if (tpm_is_v2(dev))
+ return tpm2_auto_start(dev);
+
+ return -ENOSYS;
+}
+
u32 tpm_resume(struct udevice *dev)
{
if (tpm_is_v1(dev))