summaryrefslogtreecommitdiff
path: root/cmd/tpm-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/tpm-common.c')
-rw-r--r--cmd/tpm-common.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/cmd/tpm-common.c b/cmd/tpm-common.c
index 6cf9fcc9ac..56443862c2 100644
--- a/cmd/tpm-common.c
+++ b/cmd/tpm-common.c
@@ -273,12 +273,34 @@ int do_tpm_init(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int do_tpm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
cmd_tbl_t *tpm_commands, *cmd;
+ struct tpm_chip_priv *priv;
+ struct udevice *dev;
unsigned int size;
+ int ret;
if (argc < 2)
return CMD_RET_USAGE;
- tpm_commands = get_tpm_commands(&size);
+ ret = get_tpm(&dev);
+ if (ret)
+ return ret;
+
+ priv = dev_get_uclass_priv(dev);
+
+ /* Below getters return NULL if the desired stack is not built */
+ switch (priv->version) {
+ case TPM_V1:
+ tpm_commands = get_tpm1_commands(&size);
+ break;
+ case TPM_V2:
+ tpm_commands = get_tpm2_commands(&size);
+ break;
+ default:
+ tpm_commands = NULL;
+ }
+
+ if (!tpm_commands)
+ return CMD_RET_USAGE;
cmd = find_cmd_tbl(argv[1], tpm_commands, size);
if (!cmd)