diff options
author | Simon Glass <sjg@chromium.org> | 2015-08-22 18:31:32 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-08-31 07:57:28 -0600 |
commit | c8a8c51039d83149a93fccb6e325bfdb8f63fa66 (patch) | |
tree | 800d397e9b950d551f895f419c7afc892055fdac /common | |
parent | f255d31f9063e50b56208fff439b63039cfd7ac6 (diff) | |
download | u-boot-imx-c8a8c51039d83149a93fccb6e325bfdb8f63fa66.zip u-boot-imx-c8a8c51039d83149a93fccb6e325bfdb8f63fa66.tar.gz u-boot-imx-c8a8c51039d83149a93fccb6e325bfdb8f63fa66.tar.bz2 |
dm: tpm: Convert the TPM command and library to driver model
Add driver model support to the TPM command and the TPM library. Both
support only a single TPM at present.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Christophe Ricard<christophe-h.ricard@st.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_tpm.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/common/cmd_tpm.c b/common/cmd_tpm.c index 0294952..bad2006 100644 --- a/common/cmd_tpm.c +++ b/common/cmd_tpm.c @@ -6,6 +6,7 @@ #include <common.h> #include <command.h> +#include <dm.h> #include <malloc.h> #include <tpm.h> #include <asm/unaligned.h> @@ -438,6 +439,21 @@ TPM_COMMAND_NO_ARG(tpm_force_clear) TPM_COMMAND_NO_ARG(tpm_physical_enable) TPM_COMMAND_NO_ARG(tpm_physical_disable) +#ifdef CONFIG_DM_TPM +static int get_tpm(struct udevice **devp) +{ + int rc; + + rc = uclass_first_device(UCLASS_TPM, devp); + if (rc) { + printf("Could not find TPM (ret=%d)\n", rc); + return CMD_RET_FAILURE; + } + + return 0; +} +#endif + static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -452,7 +468,17 @@ static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag, return CMD_RET_FAILURE; } +#ifdef CONFIG_DM_TPM + struct udevice *dev; + + rc = get_tpm(&dev); + if (rc) + return rc; + + rc = tpm_xfer(dev, command, count, response, &response_length); +#else rc = tis_sendrecv(command, count, response, &response_length); +#endif free(command); if (!rc) { puts("tpm response:\n"); |