1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2015 Google, Inc
11 #include <dm/uclass-internal.h>
13 static void show_devices(struct udevice *dev, int depth, int last_flag)
16 struct udevice *child;
18 /* print the first 20 characters to not break the tree-format. */
19 printf(" %-10.10s %3d [ %c ] %-20.20s ", dev->uclass->uc_drv->name,
20 dev_get_uclass_index(dev, NULL),
21 dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name);
23 for (i = depth; i >= 0; i--) {
24 is_last = (last_flag >> i) & 1;
38 printf("%s\n", dev->name);
40 list_for_each_entry(child, &dev->child_head, sibling_node) {
41 is_last = list_is_last(&child->sibling_node, &dev->child_head);
42 show_devices(child, depth + 1, (last_flag << 1) | is_last);
46 void dm_dump_all(void)
52 printf(" Class Index Probed Driver Name\n");
53 printf("-----------------------------------------------------------\n");
54 show_devices(root, -1, 0);
59 * dm_display_line() - Display information about a single device
61 * Displays a single line of information with an option prefix
63 * @dev: Device to display
65 static void dm_display_line(struct udevice *dev, int index)
67 printf("%-3i %c %s @ %08lx", index,
68 dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
69 dev->name, (ulong)map_to_sysmem(dev));
70 if (dev_seq(dev) != -1 || dev->req_seq != -1)
71 printf(", seq %d, (req %d)", dev_seq(dev), dev->req_seq);
75 void dm_dump_uclass(void)
81 for (id = 0; id < UCLASS_COUNT; id++) {
85 ret = uclass_get(id, &uc);
89 printf("uclass %d: %s\n", id, uc->uc_drv->name);
90 if (list_empty(&uc->dev_head))
92 uclass_foreach_dev(dev, uc) {
93 dm_display_line(dev, i);
100 void dm_dump_driver_compat(void)
102 struct driver *d = ll_entry_start(struct driver, driver);
103 const int n_ents = ll_entry_count(struct driver, driver);
104 struct driver *entry;
105 const struct udevice_id *match;
107 puts("Driver Compatible\n");
108 puts("--------------------------------\n");
109 for (entry = d; entry < d + n_ents; entry++) {
110 match = entry->of_match;
112 printf("%-20.20s", entry->name);
114 printf(" %s", match->compatible);
119 for (; match && match->compatible; match++)
120 printf("%-20.20s %s\n", "", match->compatible);
124 void dm_dump_drivers(void)
126 struct driver *d = ll_entry_start(struct driver, driver);
127 const int n_ents = ll_entry_count(struct driver, driver);
128 struct driver *entry;
129 struct udevice *udev;
133 puts("Driver uid uclass Devices\n");
134 puts("----------------------------------------------------------\n");
136 for (entry = d; entry < d + n_ents; entry++) {
137 uclass_get(entry->id, &uc);
139 printf("%-25.25s %-3.3d %-20.20s ", entry->name, entry->id,
140 uc ? uc->uc_drv->name : "<no uclass>");
148 uclass_foreach_dev(udev, uc) {
149 if (udev->driver != entry)
152 printf("%-51.51s", "");
154 printf("%-25.25s\n", udev->name);
162 void dm_dump_static_driver_info(void)
164 struct driver_info *drv = ll_entry_start(struct driver_info,
166 const int n_ents = ll_entry_count(struct driver_info, driver_info);
167 struct driver_info *entry;
169 puts("Driver Address\n");
170 puts("---------------------------------\n");
171 for (entry = drv; entry != drv + n_ents; entry++) {
172 printf("%-25.25s @%08lx\n", entry->name,
173 (ulong)map_to_sysmem(entry->plat));