2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2015-06-23 21:38:35 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Google, Inc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <mapmem.h>
|
|
|
|
#include <dm/root.h>
|
2017-06-22 08:10:11 +00:00
|
|
|
#include <dm/util.h>
|
2018-08-09 14:17:43 +00:00
|
|
|
#include <dm/uclass-internal.h>
|
2015-06-23 21:38:35 +00:00
|
|
|
|
|
|
|
static void show_devices(struct udevice *dev, int depth, int last_flag)
|
|
|
|
{
|
|
|
|
int i, is_last;
|
|
|
|
struct udevice *child;
|
2020-12-19 17:40:10 +00:00
|
|
|
u32 flags = dev_get_flags(dev);
|
2015-06-23 21:38:35 +00:00
|
|
|
|
2018-10-15 09:03:06 +00:00
|
|
|
/* print the first 20 characters to not break the tree-format. */
|
2020-12-23 02:30:22 +00:00
|
|
|
printf(IS_ENABLED(CONFIG_SPL_BUILD) ? " %s %d [ %c ] %s " :
|
|
|
|
" %-10.10s %3d [ %c ] %-20.20s ", dev->uclass->uc_drv->name,
|
2018-08-09 14:17:43 +00:00
|
|
|
dev_get_uclass_index(dev, NULL),
|
2020-12-23 02:30:22 +00:00
|
|
|
flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name);
|
2015-06-23 21:38:35 +00:00
|
|
|
|
|
|
|
for (i = depth; i >= 0; i--) {
|
|
|
|
is_last = (last_flag >> i) & 1;
|
|
|
|
if (i) {
|
|
|
|
if (is_last)
|
|
|
|
printf(" ");
|
|
|
|
else
|
|
|
|
printf("| ");
|
|
|
|
} else {
|
|
|
|
if (is_last)
|
|
|
|
printf("`-- ");
|
|
|
|
else
|
|
|
|
printf("|-- ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%s\n", dev->name);
|
|
|
|
|
|
|
|
list_for_each_entry(child, &dev->child_head, sibling_node) {
|
|
|
|
is_last = list_is_last(&child->sibling_node, &dev->child_head);
|
|
|
|
show_devices(child, depth + 1, (last_flag << 1) | is_last);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void dm_dump_all(void)
|
|
|
|
{
|
|
|
|
struct udevice *root;
|
|
|
|
|
|
|
|
root = dm_root();
|
|
|
|
if (root) {
|
2018-12-06 01:42:52 +00:00
|
|
|
printf(" Class Index Probed Driver Name\n");
|
2018-10-15 09:03:06 +00:00
|
|
|
printf("-----------------------------------------------------------\n");
|
2015-06-23 21:38:35 +00:00
|
|
|
show_devices(root, -1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dm_display_line() - Display information about a single device
|
|
|
|
*
|
|
|
|
* Displays a single line of information with an option prefix
|
|
|
|
*
|
|
|
|
* @dev: Device to display
|
|
|
|
*/
|
2018-08-09 14:17:43 +00:00
|
|
|
static void dm_display_line(struct udevice *dev, int index)
|
2015-06-23 21:38:35 +00:00
|
|
|
{
|
2019-09-30 08:19:13 +00:00
|
|
|
printf("%-3i %c %s @ %08lx", index,
|
2020-12-19 17:40:10 +00:00
|
|
|
dev_get_flags(dev) & DM_FLAG_ACTIVATED ? '*' : ' ',
|
2015-06-23 21:38:35 +00:00
|
|
|
dev->name, (ulong)map_to_sysmem(dev));
|
2020-12-19 17:40:09 +00:00
|
|
|
if (dev->seq_ != -1)
|
2020-12-17 04:20:31 +00:00
|
|
|
printf(", seq %d", dev_seq(dev));
|
2015-06-23 21:38:35 +00:00
|
|
|
puts("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void dm_dump_uclass(void)
|
|
|
|
{
|
|
|
|
struct uclass *uc;
|
|
|
|
int ret;
|
|
|
|
int id;
|
|
|
|
|
|
|
|
for (id = 0; id < UCLASS_COUNT; id++) {
|
|
|
|
struct udevice *dev;
|
2018-08-09 14:17:43 +00:00
|
|
|
int i = 0;
|
2015-06-23 21:38:35 +00:00
|
|
|
|
|
|
|
ret = uclass_get(id, &uc);
|
|
|
|
if (ret)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
printf("uclass %d: %s\n", id, uc->uc_drv->name);
|
|
|
|
if (list_empty(&uc->dev_head))
|
|
|
|
continue;
|
2018-09-28 13:12:55 +00:00
|
|
|
uclass_foreach_dev(dev, uc) {
|
2018-08-09 14:17:43 +00:00
|
|
|
dm_display_line(dev, i);
|
|
|
|
i++;
|
2015-06-23 21:38:35 +00:00
|
|
|
}
|
|
|
|
puts("\n");
|
|
|
|
}
|
|
|
|
}
|
2020-01-17 19:48:09 +00:00
|
|
|
|
2020-03-24 15:17:05 +00:00
|
|
|
void dm_dump_driver_compat(void)
|
2020-01-17 19:48:09 +00:00
|
|
|
{
|
|
|
|
struct driver *d = ll_entry_start(struct driver, driver);
|
|
|
|
const int n_ents = ll_entry_count(struct driver, driver);
|
|
|
|
struct driver *entry;
|
|
|
|
const struct udevice_id *match;
|
|
|
|
|
|
|
|
puts("Driver Compatible\n");
|
|
|
|
puts("--------------------------------\n");
|
|
|
|
for (entry = d; entry < d + n_ents; entry++) {
|
2020-04-05 16:47:41 +00:00
|
|
|
match = entry->of_match;
|
|
|
|
|
|
|
|
printf("%-20.20s", entry->name);
|
|
|
|
if (match) {
|
|
|
|
printf(" %s", match->compatible);
|
|
|
|
match++;
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
for (; match && match->compatible; match++)
|
|
|
|
printf("%-20.20s %s\n", "", match->compatible);
|
2020-01-17 19:48:09 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 15:17:05 +00:00
|
|
|
|
|
|
|
void dm_dump_drivers(void)
|
|
|
|
{
|
|
|
|
struct driver *d = ll_entry_start(struct driver, driver);
|
|
|
|
const int n_ents = ll_entry_count(struct driver, driver);
|
|
|
|
struct driver *entry;
|
|
|
|
struct udevice *udev;
|
|
|
|
struct uclass *uc;
|
2021-05-14 01:39:24 +00:00
|
|
|
int ret;
|
2020-03-24 15:17:05 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
puts("Driver uid uclass Devices\n");
|
|
|
|
puts("----------------------------------------------------------\n");
|
|
|
|
|
|
|
|
for (entry = d; entry < d + n_ents; entry++) {
|
2021-05-14 01:39:24 +00:00
|
|
|
ret = uclass_get(entry->id, &uc);
|
2020-03-24 15:17:05 +00:00
|
|
|
|
|
|
|
printf("%-25.25s %-3.3d %-20.20s ", entry->name, entry->id,
|
2021-05-14 01:39:24 +00:00
|
|
|
!ret ? uc->uc_drv->name : "<no uclass>");
|
2020-03-24 15:17:05 +00:00
|
|
|
|
2021-05-14 01:39:24 +00:00
|
|
|
if (ret) {
|
2020-03-24 15:17:05 +00:00
|
|
|
puts("\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
uclass_foreach_dev(udev, uc) {
|
|
|
|
if (udev->driver != entry)
|
|
|
|
continue;
|
|
|
|
if (i)
|
|
|
|
printf("%-51.51s", "");
|
|
|
|
|
|
|
|
printf("%-25.25s\n", udev->name);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (!i)
|
|
|
|
puts("<none>\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void dm_dump_static_driver_info(void)
|
|
|
|
{
|
|
|
|
struct driver_info *drv = ll_entry_start(struct driver_info,
|
|
|
|
driver_info);
|
|
|
|
const int n_ents = ll_entry_count(struct driver_info, driver_info);
|
|
|
|
struct driver_info *entry;
|
|
|
|
|
|
|
|
puts("Driver Address\n");
|
|
|
|
puts("---------------------------------\n");
|
|
|
|
for (entry = drv; entry != drv + n_ents; entry++) {
|
|
|
|
printf("%-25.25s @%08lx\n", entry->name,
|
2020-12-03 23:55:18 +00:00
|
|
|
(ulong)map_to_sysmem(entry->plat));
|
2020-03-24 15:17:05 +00:00
|
|
|
}
|
|
|
|
}
|