summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-02-11 10:58:41 -0500
committerTom Rini <trini@konsulko.com>2020-02-11 10:58:41 -0500
commit9a8942b53d57149754e0dfc975e0d92d1afd4087 (patch)
treede55e5352f3a8a79c413c0b8cb533428e5476841 /cmd
parentae347120eed8204b1fdf018ddf79131964e57016 (diff)
parent21d651fb29cf268b1a5f64d080e3d352ee32c87f (diff)
Merge tag 'dm-pull-6feb20' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
sandbox conversion to SDL2 TPM TEE driver Various minor sandbox video enhancements New driver model core utility functions
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bootefi.c1
-rw-r--r--cmd/dm.c12
-rw-r--r--cmd/gpio.c2
-rw-r--r--cmd/gpt.c1
-rw-r--r--cmd/host.c1
-rw-r--r--cmd/mtd.c2
-rw-r--r--cmd/rng.c1
-rw-r--r--cmd/tpm-common.c78
-rw-r--r--cmd/tpm-user-utils.h1
-rw-r--r--cmd/tpm-v1.c3
-rw-r--r--cmd/tpm-v2.c3
-rw-r--r--cmd/ubi.c2
-rw-r--r--cmd/usb_mass_storage.c1
-rw-r--r--cmd/ximg.c1
14 files changed, 104 insertions, 5 deletions
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 56bdff33c64..d347bd5ec06 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -13,6 +13,7 @@
#include <efi_selftest.h>
#include <env.h>
#include <errno.h>
+#include <malloc.h>
#include <linux/libfdt.h>
#include <linux/libfdt_env.h>
#include <mapmem.h>
diff --git a/cmd/dm.c b/cmd/dm.c
index 7b271db0bbe..108707c298a 100644
--- a/cmd/dm.c
+++ b/cmd/dm.c
@@ -40,10 +40,19 @@ static int do_dm_dump_devres(cmd_tbl_t *cmdtp, int flag, int argc,
return 0;
}
+static int do_dm_dump_drivers(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ dm_dump_drivers();
+
+ return 0;
+}
+
static cmd_tbl_t test_commands[] = {
U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""),
U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""),
U_BOOT_CMD_MKENT(devres, 1, 1, do_dm_dump_devres, "", ""),
+ U_BOOT_CMD_MKENT(drivers, 1, 1, do_dm_dump_drivers, "", ""),
};
static __maybe_unused void dm_reloc(void)
@@ -84,5 +93,6 @@ U_BOOT_CMD(
"Driver model low level access",
"tree Dump driver model tree ('*' = activated)\n"
"dm uclass Dump list of instances for each uclass\n"
- "dm devres Dump list of device resources for each device"
+ "dm devres Dump list of device resources for each device\n"
+ "dm drivers Dump list of drivers and their compatible strings\n"
);
diff --git a/cmd/gpio.c b/cmd/gpio.c
index 67eef83c951..16c2cebb3d4 100644
--- a/cmd/gpio.c
+++ b/cmd/gpio.c
@@ -10,7 +10,9 @@
#include <command.h>
#include <errno.h>
#include <dm.h>
+#include <malloc.h>
#include <asm/gpio.h>
+#include <linux/err.h>
__weak int name_to_gpio(const char *name)
{
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 964702bad43..efaf1bcecb2 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -20,6 +20,7 @@
#include <div64.h>
#include <memalign.h>
#include <linux/compat.h>
+#include <linux/err.h>
#include <linux/sizes.h>
#include <stdlib.h>
diff --git a/cmd/host.c b/cmd/host.c
index 98c4d2a099e..eefc4f255ef 100644
--- a/cmd/host.c
+++ b/cmd/host.c
@@ -8,6 +8,7 @@
#include <fs.h>
#include <part.h>
#include <sandboxblockdev.h>
+#include <dm/device_compat.h>
#include <linux/errno.h>
static int host_curr_device = -1;
diff --git a/cmd/mtd.c b/cmd/mtd.c
index a559b5a4a35..f407c5e4450 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -14,6 +14,8 @@
#include <malloc.h>
#include <mapmem.h>
#include <mtd.h>
+#include <dm/devres.h>
+#include <linux/err.h>
#include <linux/ctype.h>
diff --git a/cmd/rng.c b/cmd/rng.c
index 36ca7a101c1..76367fed94b 100644
--- a/cmd/rng.c
+++ b/cmd/rng.c
@@ -8,6 +8,7 @@
#include <command.h>
#include <dm.h>
#include <hexdump.h>
+#include <malloc.h>
#include <rng.h>
static int do_rng(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
diff --git a/cmd/tpm-common.c b/cmd/tpm-common.c
index 38900fb1590..30142552290 100644
--- a/cmd/tpm-common.c
+++ b/cmd/tpm-common.c
@@ -7,11 +7,14 @@
#include <command.h>
#include <dm.h>
#include <env.h>
+#include <malloc.h>
#include <asm/unaligned.h>
#include <linux/string.h>
#include <tpm-common.h>
#include "tpm-user-utils.h"
+static struct udevice *tpm_dev;
+
/**
* Print a byte string in hexdecimal format, 16-bytes per line.
*
@@ -231,19 +234,86 @@ int type_string_write_vars(const char *type_str, u8 *data,
return 0;
}
+static int tpm_show_device(void)
+{
+ struct udevice *dev;
+ char buf[80];
+ int n = 0, rc;
+
+ for_each_tpm_device(dev) {
+ rc = tpm_get_desc(dev, buf, sizeof(buf));
+ if (rc < 0)
+ printf("device %d: can't get info\n", n);
+ else
+ printf("device %d: %s\n", n, buf);
+
+ n++;
+ };
+
+ return 0;
+}
+
+static int tpm_set_device(unsigned long num)
+{
+ struct udevice *dev;
+ unsigned long n = 0;
+ int rc = CMD_RET_FAILURE;
+
+ for_each_tpm_device(dev) {
+ if (n == num) {
+ rc = 0;
+ break;
+ }
+
+ n++;
+ }
+
+ if (!rc)
+ tpm_dev = dev;
+
+ return rc;
+}
+
int get_tpm(struct udevice **devp)
{
int rc;
- rc = uclass_first_device_err(UCLASS_TPM, devp);
- if (rc) {
- printf("Could not find TPM (ret=%d)\n", rc);
- return CMD_RET_FAILURE;
+ /*
+ * To keep a backward compatibility with previous code,
+ * if a tpm device is not explicitly set, we set the first one.
+ */
+ if (!tpm_dev) {
+ rc = tpm_set_device(0);
+ if (rc) {
+ printf("Couldn't set TPM 0 (rc = %d)\n", rc);
+ return CMD_RET_FAILURE;
+ }
}
+ if (devp)
+ *devp = tpm_dev;
+
return 0;
}
+int do_tpm_device(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+ unsigned long num;
+ int rc;
+
+ if (argc == 2) {
+ num = simple_strtoul(argv[1], NULL, 10);
+
+ rc = tpm_set_device(num);
+ if (rc)
+ printf("Couldn't set TPM %lu (rc = %d)\n", num, rc);
+ } else {
+ rc = tpm_show_device();
+ }
+
+ return rc;
+}
+
int do_tpm_info(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
struct udevice *dev;
diff --git a/cmd/tpm-user-utils.h b/cmd/tpm-user-utils.h
index 8ce98617843..a851d9c4af2 100644
--- a/cmd/tpm-user-utils.h
+++ b/cmd/tpm-user-utils.h
@@ -17,6 +17,7 @@ int type_string_pack(const char *type_str, char * const values[], u8 *data);
int type_string_write_vars(const char *type_str, u8 *data, char * const vars[]);
int get_tpm(struct udevice **devp);
+int do_tpm_device(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
int do_tpm_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
int do_tpm_info(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[]);
diff --git a/cmd/tpm-v1.c b/cmd/tpm-v1.c
index 2807331524a..bc34e0654f9 100644
--- a/cmd/tpm-v1.c
+++ b/cmd/tpm-v1.c
@@ -645,6 +645,7 @@ TPM_COMMAND_NO_ARG(tpm_physical_enable)
TPM_COMMAND_NO_ARG(tpm_physical_disable)
static cmd_tbl_t tpm1_commands[] = {
+ U_BOOT_CMD_MKENT(device, 0, 1, do_tpm_device, "", ""),
U_BOOT_CMD_MKENT(info, 0, 1, do_tpm_info, "", ""),
U_BOOT_CMD_MKENT(init, 0, 1, do_tpm_init, "", ""),
U_BOOT_CMD_MKENT(startup, 0, 1,
@@ -721,6 +722,8 @@ U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm,
"cmd args...\n"
" - Issue TPM command <cmd> with arguments <args...>.\n"
"Admin Startup and State Commands:\n"
+" device [num device]\n"
+" - Show all devices or set the specified device\n"
" info - Show information about the TPM\n"
" init\n"
" - Put TPM into a state where it waits for 'startup' command.\n"
diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c
index 459a955d290..0cd39821bff 100644
--- a/cmd/tpm-v2.c
+++ b/cmd/tpm-v2.c
@@ -354,6 +354,7 @@ static int do_tpm_pcr_setauthvalue(cmd_tbl_t *cmdtp, int flag,
}
static cmd_tbl_t tpm2_commands[] = {
+ U_BOOT_CMD_MKENT(device, 0, 1, do_tpm_device, "", ""),
U_BOOT_CMD_MKENT(info, 0, 1, do_tpm_info, "", ""),
U_BOOT_CMD_MKENT(init, 0, 1, do_tpm_init, "", ""),
U_BOOT_CMD_MKENT(startup, 0, 1, do_tpm2_startup, "", ""),
@@ -381,6 +382,8 @@ cmd_tbl_t *get_tpm2_commands(unsigned int *size)
U_BOOT_CMD(tpm2, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a TPMv2.x command",
"<command> [<arguments>]\n"
"\n"
+"device [num device]\n"
+" Show all devices or set the specified device\n"
"info\n"
" Show information about the TPM.\n"
"init\n"
diff --git a/cmd/ubi.c b/cmd/ubi.c
index 22ba5b1a2ce..cecf251fdb9 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -15,10 +15,12 @@
#include <command.h>
#include <env.h>
#include <exports.h>
+#include <malloc.h>
#include <memalign.h>
#include <mtd.h>
#include <nand.h>
#include <onenand_uboot.h>
+#include <dm/devres.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/err.h>
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index 570cf3aa508..c5c6899787c 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -11,6 +11,7 @@
#include <command.h>
#include <console.h>
#include <g_dnl.h>
+#include <malloc.h>
#include <part.h>
#include <usb.h>
#include <usb_mass_storage.h>
diff --git a/cmd/ximg.c b/cmd/ximg.c
index dccd1143a7a..770f6a3eede 100644
--- a/cmd/ximg.c
+++ b/cmd/ximg.c
@@ -17,6 +17,7 @@
#include <env.h>
#include <gzip.h>
#include <image.h>
+#include <malloc.h>
#include <mapmem.h>
#include <watchdog.h>
#if defined(CONFIG_BZIP2)