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;
17 u32 flags = dev_get_flags(dev);
19 /* print the first 20 characters to not break the tree-format. */
20 printf(IS_ENABLED(CONFIG_SPL_BUILD) ? " %s %d [ %c ] %s " :
21 " %-10.10s %3d [ %c ] %-20.20s ", dev->uclass->uc_drv->name,
22 dev_get_uclass_index(dev, NULL),
23 flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name);
25 for (i = depth; i >= 0; i--) {
26 is_last = (last_flag >> i) & 1;
40 printf("%s\n", dev->name);
42 list_for_each_entry(child, &dev->child_head, sibling_node) {
43 is_last = list_is_last(&child->sibling_node, &dev->child_head);
44 show_devices(child, depth + 1, (last_flag << 1) | is_last);
48 void dm_dump_all(void)
54 printf(" Class Index Probed Driver Name\n");
55 printf("-----------------------------------------------------------\n");
56 show_devices(root, -1, 0);
61 * dm_display_line() - Display information about a single device
63 * Displays a single line of information with an option prefix
65 * @dev: Device to display
67 static void dm_display_line(struct udevice *dev, int index)
69 printf("%-3i %c %s @ %08lx", index,
70 dev_get_flags(dev) & DM_FLAG_ACTIVATED ? '*' : ' ',
71 dev->name, (ulong)map_to_sysmem(dev));
73 printf(", seq %d", dev_seq(dev));
77 void dm_dump_uclass(void)
83 for (id = 0; id < UCLASS_COUNT; id++) {
87 ret = uclass_get(id, &uc);
91 printf("uclass %d: %s\n", id, uc->uc_drv->name);
92 if (list_empty(&uc->dev_head))
94 uclass_foreach_dev(dev, uc) {
95 dm_display_line(dev, i);
102 void dm_dump_driver_compat(void)
104 struct driver *d = ll_entry_start(struct driver, driver);
105 const int n_ents = ll_entry_count(struct driver, driver);
106 struct driver *entry;
107 const struct udevice_id *match;
109 puts("Driver Compatible\n");
110 puts("--------------------------------\n");
111 for (entry = d; entry < d + n_ents; entry++) {
112 match = entry->of_match;
114 printf("%-20.20s", entry->name);
116 printf(" %s", match->compatible);
121 for (; match && match->compatible; match++)
122 printf("%-20.20s %s\n", "", match->compatible);
126 void dm_dump_drivers(void)
128 struct driver *d = ll_entry_start(struct driver, driver);
129 const int n_ents = ll_entry_count(struct driver, driver);
130 struct driver *entry;
131 struct udevice *udev;
136 puts("Driver uid uclass Devices\n");
137 puts("----------------------------------------------------------\n");
139 for (entry = d; entry < d + n_ents; entry++) {
140 ret = uclass_get(entry->id, &uc);
142 printf("%-25.25s %-3.3d %-20.20s ", entry->name, entry->id,
143 !ret ? uc->uc_drv->name : "<no uclass>");
151 uclass_foreach_dev(udev, uc) {
152 if (udev->driver != entry)
155 printf("%-51.51s", "");
157 printf("%-25.25s\n", udev->name);
165 void dm_dump_static_driver_info(void)
167 struct driver_info *drv = ll_entry_start(struct driver_info,
169 const int n_ents = ll_entry_count(struct driver_info, driver_info);
170 struct driver_info *entry;
172 puts("Driver Address\n");
173 puts("---------------------------------\n");
174 for (entry = drv; entry != drv + n_ents; entry++) {
175 printf("%-25.25s @%08lx\n", entry->name,
176 (ulong)map_to_sysmem(entry->plat));