A TPM is only started by U-Boot when measured boot or the EFI TCG2 protocol is used. A plain booti/bootm leaves it uninitialised, so boards work around this with 'tpm autostart' in their environment.
This series adds CONFIG_TPM_AUTOSTART, which starts the TPM from an EVT_LAST_STAGE_INIT handler, adds sandbox tests for it and converts the Xilinx Kria boards, which are the only in-tree user of the environment workaround. The Kria change is build-tested only, I do not have the hardware. Simon, I kept your Reviewed-by on patch 1, since the only code change there is the tpm_autostart_init() split you suggested. Changes in v4: - Move the startup into tpm_autostart_init() and call it from the tests - Rework the tests as suggested by Simon - Add the new spy to test_event_dump.py Changes in v3: - Split into three patches: option + code, tests, Kria conversion - Convert the Xilinx Kria boards as the first user Michael Haener (3): tpm: Add an option to start the TPM during init tpm: Add tests for CONFIG_TPM_AUTOSTART xilinx: Use CONFIG_TPM_AUTOSTART on Kria board/xilinx/zynqmp/zynqmp_kria.env | 4 +-- configs/sandbox_defconfig | 1 + configs/xilinx_zynqmp_kria_defconfig | 1 + doc/usage/measured_boot.rst | 18 +++++++++++ include/tpm_api.h | 10 ++++++ lib/Kconfig | 19 +++++++++++ lib/Makefile | 1 + lib/tpm_autostart.c | 48 ++++++++++++++++++++++++++++ test/dm/tpm.c | 47 +++++++++++++++++++++++++++ test/py/tests/test_event_dump.py | 1 + 10 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 lib/tpm_autostart.c base-commit: 8d7bc8add17bbc69a58dfe0002eea039dd2dc1bc -- 2.55.0
