]> git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/core/dump.c
ARM: OMAP5: set mmc clock frequency to 192MHz
[people/ms/u-boot.git] / drivers / core / dump.c
1 /*
2 * Copyright (c) 2015 Google, Inc
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7 #include <common.h>
8 #include <dm.h>
9 #include <mapmem.h>
10 #include <dm/root.h>
11 #include <dm/util.h>
12
13 static void show_devices(struct udevice *dev, int depth, int last_flag)
14 {
15 int i, is_last;
16 struct udevice *child;
17
18 /* print the first 11 characters to not break the tree-format. */
19 printf(" %-10.10s [ %c ] %-10.10s ", dev->uclass->uc_drv->name,
20 dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name);
21
22 for (i = depth; i >= 0; i--) {
23 is_last = (last_flag >> i) & 1;
24 if (i) {
25 if (is_last)
26 printf(" ");
27 else
28 printf("| ");
29 } else {
30 if (is_last)
31 printf("`-- ");
32 else
33 printf("|-- ");
34 }
35 }
36
37 printf("%s\n", dev->name);
38
39 list_for_each_entry(child, &dev->child_head, sibling_node) {
40 is_last = list_is_last(&child->sibling_node, &dev->child_head);
41 show_devices(child, depth + 1, (last_flag << 1) | is_last);
42 }
43 }
44
45 void dm_dump_all(void)
46 {
47 struct udevice *root;
48
49 root = dm_root();
50 if (root) {
51 printf(" Class Probed Driver Name\n");
52 printf("----------------------------------------\n");
53 show_devices(root, -1, 0);
54 }
55 }
56
57 /**
58 * dm_display_line() - Display information about a single device
59 *
60 * Displays a single line of information with an option prefix
61 *
62 * @dev: Device to display
63 */
64 static void dm_display_line(struct udevice *dev)
65 {
66 printf("- %c %s @ %08lx",
67 dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
68 dev->name, (ulong)map_to_sysmem(dev));
69 if (dev->seq != -1 || dev->req_seq != -1)
70 printf(", seq %d, (req %d)", dev->seq, dev->req_seq);
71 puts("\n");
72 }
73
74 void dm_dump_uclass(void)
75 {
76 struct uclass *uc;
77 int ret;
78 int id;
79
80 for (id = 0; id < UCLASS_COUNT; id++) {
81 struct udevice *dev;
82
83 ret = uclass_get(id, &uc);
84 if (ret)
85 continue;
86
87 printf("uclass %d: %s\n", id, uc->uc_drv->name);
88 if (list_empty(&uc->dev_head))
89 continue;
90 list_for_each_entry(dev, &uc->dev_head, uclass_node) {
91 dm_display_line(dev);
92 }
93 puts("\n");
94 }
95 }