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 int pre_reloc, remained; 18 19 /* print the first 11 characters to not break the tree-format. */ 20 printf(" %-10.10s [ %c ] %-25.25s ", dev->uclass->uc_drv->name, 21 dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name); 22 23 for (i = depth; i >= 0; i--) { 24 is_last = (last_flag >> i) & 1; 25 if (i) { 26 if (is_last) 27 printf(" "); 28 else 29 printf("| "); 30 } else { 31 if (is_last) 32 printf("`-- "); 33 else 34 printf("|-- "); 35 } 36 } 37 38 pre_reloc = dev_read_bool(dev, "u-boot,dm-pre-reloc") || 39 dev_read_bool(dev, "u-boot,dm-spl"); 40 if (pre_reloc) 41 remained = !list_empty(&dev->uclass_node); 42 else 43 remained = 0; 44 45 printf("%s %s%s\n", dev->name, pre_reloc ? "*" : "", remained ? "*" : ""); 46 47 list_for_each_entry(child, &dev->child_head, sibling_node) { 48 is_last = list_is_last(&child->sibling_node, &dev->child_head); 49 show_devices(child, depth + 1, (last_flag << 1) | is_last); 50 } 51 } 52 53 void dm_dump_all(void) 54 { 55 struct udevice *root; 56 57 root = dm_root(); 58 if (root) { 59 printf(" Class Probed Driver Name\n"); 60 printf("----------------------------------------------------------\n"); 61 show_devices(root, -1, 0); 62 } 63 } 64 65 /** 66 * dm_display_line() - Display information about a single device 67 * 68 * Displays a single line of information with an option prefix 69 * 70 * @dev: Device to display 71 */ 72 static void dm_display_line(struct udevice *dev) 73 { 74 printf(" %c [ %c ] %s @ %08lx", 75 dev_read_bool(dev, "u-boot,dm-pre-pre_reloc") || 76 dev_read_bool(dev, "u-boot,dm-spl") ? '*' : ' ', 77 dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', 78 dev->name, (ulong)map_to_sysmem(dev)); 79 if (dev->seq != -1 || dev->req_seq != -1) 80 printf(", seq %d, (req %d)", dev->seq, dev->req_seq); 81 puts("\n"); 82 } 83 84 void dm_dump_uclass(void) 85 { 86 struct uclass *uc; 87 int ret; 88 int id; 89 90 for (id = 0; id < UCLASS_COUNT; id++) { 91 struct udevice *dev; 92 93 ret = uclass_get(id, &uc); 94 if (ret) 95 continue; 96 97 printf("uclass %d: %s\n", id, uc->uc_drv->name); 98 if (list_empty(&uc->dev_head)) 99 continue; 100 list_for_each_entry(dev, &uc->dev_head, uclass_node) { 101 dm_display_line(dev); 102 } 103 puts("\n"); 104 } 105 } 106