At present if an application wants to be written so it can work with both TPMv1.2 and TPM2 it must use two different APIs. This is inconvenient since it requires adding code to deal with the mismatch between the two. It would be better to have a common API that all boards could share.
This series provides a simple API the covers some basic features and implements them for both TPM standards. Changes in v2: - Add comments for the offset value - Add definition of TPM2_RC_NV_DEFINED return code Simon Glass (11): tpm: Don't include cr50 in TPL/SPL tpm: Use logging in the uclass tpm: Add debugging of request in tpm_sendrecv_command() tpm: Add an API that can support v1.2 and v2 tpm: Switch TPMv1 over to use the new API tpm: Add a basic API implementation for TPMv2 tpm: Reduce duplication in a few functions tpm: Add an implementation of define_space tpm: Add TPM2 support for read/write values tpm: Add TPM2 support for write_lock tpm: Allow disabling platform hierarchy with TPM2 board/gdsys/a38x/controlcenterdc.c | 4 +- board/gdsys/a38x/hre.c | 28 +-- board/gdsys/a38x/keyprogram.c | 8 +- board/gdsys/mpc8308/gazerbeam.c | 4 +- board/gdsys/p1022/controlcenterd-id.c | 36 +-- cmd/tpm-v1.c | 25 +- cmd/tpm_test.c | 40 ++-- drivers/tpm/Makefile | 2 +- drivers/tpm/cr50_i2c.c | 4 +- drivers/tpm/tpm-uclass.c | 8 +- include/tpm-common.h | 3 + include/tpm-v1.h | 76 +++--- include/tpm-v2.h | 81 +++++++ include/tpm_api.h | 322 ++++++++++++++++++++++++++ lib/Makefile | 1 + lib/tpm-common.c | 11 +- lib/tpm-v1.c | 115 +++++---- lib/tpm-v2.c | 199 +++++++++++++++- lib/tpm_api.c | 285 +++++++++++++++++++++++ 19 files changed, 1069 insertions(+), 183 deletions(-) create mode 100644 include/tpm_api.h create mode 100644 lib/tpm_api.c -- 2.30.0.296.g2bfb1c46d8-goog