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