2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-02-26 22:59:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Google, Inc
|
|
|
|
*
|
|
|
|
* (C) Copyright 2012
|
|
|
|
* Marek Vasut <marex@denx.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2015-12-07 13:23:29 +00:00
|
|
|
#include <command.h>
|
2022-05-08 10:39:26 +00:00
|
|
|
#include <dm/root.h>
|
2015-06-23 21:38:35 +00:00
|
|
|
#include <dm/util.h>
|
2014-11-29 08:01:56 +00:00
|
|
|
|
2022-05-08 10:39:20 +00:00
|
|
|
static int do_dm_dump_driver_compat(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char * const argv[])
|
2014-02-26 22:59:22 +00:00
|
|
|
{
|
2022-05-08 10:39:20 +00:00
|
|
|
dm_dump_driver_compat();
|
2014-02-26 22:59:22 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_dm_dump_devres(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2015-07-25 12:52:38 +00:00
|
|
|
{
|
|
|
|
dm_dump_devres();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_dm_dump_drivers(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2020-01-17 19:48:09 +00:00
|
|
|
{
|
|
|
|
dm_dump_drivers();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-08 10:39:26 +00:00
|
|
|
#if CONFIG_IS_ENABLED(DM_STATS)
|
|
|
|
static int do_dm_dump_mem(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
|
|
|
{
|
|
|
|
struct dm_stats mem;
|
|
|
|
|
|
|
|
dm_get_mem(&mem);
|
|
|
|
dm_dump_mem(&mem);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* DM_STATS */
|
|
|
|
|
2022-05-08 10:39:20 +00:00
|
|
|
static int do_dm_dump_static_driver_info(struct cmd_tbl *cmdtp, int flag,
|
|
|
|
int argc, char * const argv[])
|
2020-03-24 15:17:05 +00:00
|
|
|
{
|
2022-05-08 10:39:20 +00:00
|
|
|
dm_dump_static_driver_info();
|
2020-03-24 15:17:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-08 10:39:20 +00:00
|
|
|
static int do_dm_dump_tree(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2020-03-24 15:17:05 +00:00
|
|
|
{
|
cmd: dm: allow for selecting uclass and device
The output from "dm tree" or "dm uclass" is a bit annoying
if the number of devices available on the system is huge.
(This is especially true on sandbox when I debug some DM code.)
With this patch, we can specify the uclass name or the device
name that we are interested in in order to limit the output.
For instance,
=> dm uclass usb
uclass 121: usb
0 usb@1 @ 0bcff8b0, seq 1
uclass 124: usb
=> dm tree usb:usb@1
Class Index Probed Driver Name
-----------------------------------------------------------
usb 0 [ ] usb_sandbox usb@1
usb_hub 0 [ ] usb_hub `-- hub
usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul
usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0
usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1
usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2
usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3
If you want forward-matching against a uclass or udevice name,
you can specify "-e" option.
=> dm uclass -e usb
uclass 15: usb_emul
0 hub-emul @ 0bcffb00, seq 0
1 flash-stick@0 @ 0bcffc30, seq 1
2 flash-stick@1 @ 0bcffdc0, seq 2
3 flash-stick@2 @ 0bcfff50, seq 3
4 keyb@3 @ 0bd000e0, seq 4
uclass 64: usb_mass_storage
uclass 121: usb
0 usb@1 @ 0bcff8b0, seq 1
uclass 122: usb_dev_generic
uclass 123: usb_hub
0 hub @ 0bcff9b0, seq 0
uclass 124: usb
=> dm tree -e usb
Class Index Probed Driver Name
-----------------------------------------------------------
usb 0 [ ] usb_sandbox usb@1
usb_hub 0 [ ] usb_hub `-- hub
usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul
usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0
usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1
usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2
usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-23 01:49:47 +00:00
|
|
|
bool extended = false, sort = false;
|
|
|
|
char *device = NULL;
|
|
|
|
|
|
|
|
for (; argc > 1; argc--, argv++) {
|
|
|
|
if (argv[1][0] != '-')
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!strcmp(argv[1], "-e")) {
|
|
|
|
extended = true;
|
|
|
|
} else if (!strcmp(argv[1], "-s")) {
|
|
|
|
sort = true;
|
|
|
|
} else {
|
|
|
|
printf("Unknown parameter: %s\n", argv[1]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (argc > 1)
|
|
|
|
device = argv[1];
|
|
|
|
|
|
|
|
dm_dump_tree(device, extended, sort);
|
2022-05-08 10:39:20 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int do_dm_dump_uclass(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
|
|
|
{
|
cmd: dm: allow for selecting uclass and device
The output from "dm tree" or "dm uclass" is a bit annoying
if the number of devices available on the system is huge.
(This is especially true on sandbox when I debug some DM code.)
With this patch, we can specify the uclass name or the device
name that we are interested in in order to limit the output.
For instance,
=> dm uclass usb
uclass 121: usb
0 usb@1 @ 0bcff8b0, seq 1
uclass 124: usb
=> dm tree usb:usb@1
Class Index Probed Driver Name
-----------------------------------------------------------
usb 0 [ ] usb_sandbox usb@1
usb_hub 0 [ ] usb_hub `-- hub
usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul
usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0
usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1
usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2
usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3
If you want forward-matching against a uclass or udevice name,
you can specify "-e" option.
=> dm uclass -e usb
uclass 15: usb_emul
0 hub-emul @ 0bcffb00, seq 0
1 flash-stick@0 @ 0bcffc30, seq 1
2 flash-stick@1 @ 0bcffdc0, seq 2
3 flash-stick@2 @ 0bcfff50, seq 3
4 keyb@3 @ 0bd000e0, seq 4
uclass 64: usb_mass_storage
uclass 121: usb
0 usb@1 @ 0bcff8b0, seq 1
uclass 122: usb_dev_generic
uclass 123: usb_hub
0 hub @ 0bcff9b0, seq 0
uclass 124: usb
=> dm tree -e usb
Class Index Probed Driver Name
-----------------------------------------------------------
usb 0 [ ] usb_sandbox usb@1
usb_hub 0 [ ] usb_hub `-- hub
usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul
usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0
usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1
usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2
usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-23 01:49:47 +00:00
|
|
|
bool extended = false;
|
|
|
|
char *uclass = NULL;
|
|
|
|
|
|
|
|
if (argc > 1) {
|
|
|
|
if (!strcmp(argv[1], "-e")) {
|
|
|
|
extended = true;
|
|
|
|
argc--;
|
|
|
|
argv++;
|
|
|
|
}
|
|
|
|
if (argc > 1)
|
|
|
|
uclass = argv[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
dm_dump_uclass(uclass, extended);
|
2020-03-24 15:17:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-08 10:39:26 +00:00
|
|
|
#if CONFIG_IS_ENABLED(DM_STATS)
|
|
|
|
#define DM_MEM_HELP "dm mem Provide a summary of memory usage\n"
|
|
|
|
#define DM_MEM U_BOOT_SUBCMD_MKENT(mem, 1, 1, do_dm_dump_mem),
|
|
|
|
#else
|
|
|
|
#define DM_MEM_HELP
|
|
|
|
#define DM_MEM
|
|
|
|
#endif
|
|
|
|
|
2023-02-05 22:40:56 +00:00
|
|
|
#if IS_ENABLED(CONFIG_SYS_LONGHELP)
|
2022-05-08 10:01:42 +00:00
|
|
|
static char dm_help_text[] =
|
2022-05-08 10:39:20 +00:00
|
|
|
"compat Dump list of drivers with compatibility strings\n"
|
2020-01-17 19:48:09 +00:00
|
|
|
"dm devres Dump list of device resources for each device\n"
|
2020-03-24 15:17:05 +00:00
|
|
|
"dm drivers Dump list of drivers with uclass and instances\n"
|
2022-05-08 10:39:26 +00:00
|
|
|
DM_MEM_HELP
|
2022-05-08 10:39:20 +00:00
|
|
|
"dm static Dump list of drivers with static platform data\n"
|
cmd: dm: allow for selecting uclass and device
The output from "dm tree" or "dm uclass" is a bit annoying
if the number of devices available on the system is huge.
(This is especially true on sandbox when I debug some DM code.)
With this patch, we can specify the uclass name or the device
name that we are interested in in order to limit the output.
For instance,
=> dm uclass usb
uclass 121: usb
0 usb@1 @ 0bcff8b0, seq 1
uclass 124: usb
=> dm tree usb:usb@1
Class Index Probed Driver Name
-----------------------------------------------------------
usb 0 [ ] usb_sandbox usb@1
usb_hub 0 [ ] usb_hub `-- hub
usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul
usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0
usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1
usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2
usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3
If you want forward-matching against a uclass or udevice name,
you can specify "-e" option.
=> dm uclass -e usb
uclass 15: usb_emul
0 hub-emul @ 0bcffb00, seq 0
1 flash-stick@0 @ 0bcffc30, seq 1
2 flash-stick@1 @ 0bcffdc0, seq 2
3 flash-stick@2 @ 0bcfff50, seq 3
4 keyb@3 @ 0bd000e0, seq 4
uclass 64: usb_mass_storage
uclass 121: usb
0 usb@1 @ 0bcff8b0, seq 1
uclass 122: usb_dev_generic
uclass 123: usb_hub
0 hub @ 0bcff9b0, seq 0
uclass 124: usb
=> dm tree -e usb
Class Index Probed Driver Name
-----------------------------------------------------------
usb 0 [ ] usb_sandbox usb@1
usb_hub 0 [ ] usb_hub `-- hub
usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul
usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0
usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1
usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2
usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-23 01:49:47 +00:00
|
|
|
"dm tree [-s][-e][name] Dump tree of driver model devices (-s=sort)\n"
|
|
|
|
"dm uclass [-e][name] Dump list of instances for each uclass"
|
2022-05-08 10:01:42 +00:00
|
|
|
;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
U_BOOT_CMD_WITH_SUBCMDS(dm, "Driver model low level access", dm_help_text,
|
2022-05-08 10:39:20 +00:00
|
|
|
U_BOOT_SUBCMD_MKENT(compat, 1, 1, do_dm_dump_driver_compat),
|
2022-05-08 10:01:42 +00:00
|
|
|
U_BOOT_SUBCMD_MKENT(devres, 1, 1, do_dm_dump_devres),
|
|
|
|
U_BOOT_SUBCMD_MKENT(drivers, 1, 1, do_dm_dump_drivers),
|
2022-05-08 10:39:26 +00:00
|
|
|
DM_MEM
|
2022-05-08 10:39:20 +00:00
|
|
|
U_BOOT_SUBCMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info),
|
cmd: dm: allow for selecting uclass and device
The output from "dm tree" or "dm uclass" is a bit annoying
if the number of devices available on the system is huge.
(This is especially true on sandbox when I debug some DM code.)
With this patch, we can specify the uclass name or the device
name that we are interested in in order to limit the output.
For instance,
=> dm uclass usb
uclass 121: usb
0 usb@1 @ 0bcff8b0, seq 1
uclass 124: usb
=> dm tree usb:usb@1
Class Index Probed Driver Name
-----------------------------------------------------------
usb 0 [ ] usb_sandbox usb@1
usb_hub 0 [ ] usb_hub `-- hub
usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul
usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0
usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1
usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2
usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3
If you want forward-matching against a uclass or udevice name,
you can specify "-e" option.
=> dm uclass -e usb
uclass 15: usb_emul
0 hub-emul @ 0bcffb00, seq 0
1 flash-stick@0 @ 0bcffc30, seq 1
2 flash-stick@1 @ 0bcffdc0, seq 2
3 flash-stick@2 @ 0bcfff50, seq 3
4 keyb@3 @ 0bd000e0, seq 4
uclass 64: usb_mass_storage
uclass 121: usb
0 usb@1 @ 0bcff8b0, seq 1
uclass 122: usb_dev_generic
uclass 123: usb_hub
0 hub @ 0bcff9b0, seq 0
uclass 124: usb
=> dm tree -e usb
Class Index Probed Driver Name
-----------------------------------------------------------
usb 0 [ ] usb_sandbox usb@1
usb_hub 0 [ ] usb_hub `-- hub
usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul
usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0
usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1
usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2
usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-23 01:49:47 +00:00
|
|
|
U_BOOT_SUBCMD_MKENT(tree, 4, 1, do_dm_dump_tree),
|
|
|
|
U_BOOT_SUBCMD_MKENT(uclass, 3, 1, do_dm_dump_uclass));
|