#include <dm/test.h>
#include <dm/uclass-internal.h>
-static int display_succ(struct device *in, char *buf)
+/**
+ * dm_display_line() - Display information about a single device
+ *
+ * Displays a single line of information with an option prefix
+ *
+ * @dev: Device to display
+ * @buf: Prefix to display at the start of the line
+ */
+static void dm_display_line(struct udevice *dev, char *buf)
+{
+ printf("%s- %c %s @ %08lx", buf,
+ dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
+ dev->name, (ulong)map_to_sysmem(dev));
+ if (dev->req_seq != -1)
+ printf(", %d", dev->req_seq);
+ puts("\n");
+}
+
+static int display_succ(struct udevice *in, char *buf)
{
int len;
int ip = 0;
char local[16];
- struct device *pos, *n, *prev = NULL;
+ struct udevice *pos, *n, *prev = NULL;
- printf("%s- %s @ %08x", buf, in->name, map_to_sysmem(in));
- if (in->flags & DM_FLAG_ACTIVATED)
- puts(" - activated");
- puts("\n");
+ dm_display_line(in, buf);
if (list_empty(&in->child_head))
return 0;
return 0;
}
-static int dm_dump(struct device *dev)
+static int dm_dump(struct udevice *dev)
{
if (!dev)
return -EINVAL;
static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
- struct device *root;
+ struct udevice *root;
root = dm_root();
- printf("ROOT %08x\n", map_to_sysmem(root));
+ printf("ROOT %08lx\n", (ulong)map_to_sysmem(root));
return dm_dump(root);
}
int id;
for (id = 0; id < UCLASS_COUNT; id++) {
- struct device *dev;
+ struct udevice *dev;
ret = uclass_get(id, &uc);
if (ret)
continue;
printf("uclass %d: %s\n", id, uc->uc_drv->name);
- for (ret = uclass_first_device(id, &dev);
- dev;
- ret = uclass_next_device(&dev)) {
- printf(" %s @ %08x:\n", dev->name,
- map_to_sysmem(dev));
+ if (list_empty(&uc->dev_head))
+ continue;
+ list_for_each_entry(dev, &uc->dev_head, uclass_node) {
+ dm_display_line(dev, "");
}
puts("\n");
}
return 0;
}
+#ifdef CONFIG_DM_TEST
static int do_dm_test(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
return dm_test_main();
}
+#define TEST_HELP "\ndm test Run tests"
+#else
+#define TEST_HELP
+#endif
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, "", ""),
+#ifdef CONFIG_DM_TEST
U_BOOT_CMD_MKENT(test, 1, 1, do_dm_test, "", ""),
+#endif
};
static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
U_BOOT_CMD(
dm, 2, 1, do_dm,
"Driver model low level access",
- "tree Dump driver model tree\n"
- "dm uclass Dump list of instances for each uclass\n"
- "dm test Run tests"
+ "tree Dump driver model tree ('*' = activated)\n"
+ "dm uclass Dump list of instances for each uclass"
+ TEST_HELP
);