blob: 979cd36061ed445a66bb81a3a178f37800489e4f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassc267cf72014-02-26 15:59:22 -07002/*
3 * Copyright (c) 2013 Google, Inc
4 *
5 * (C) Copyright 2012
6 * Marek Vasut <marex@denx.de>
Simon Glassc267cf72014-02-26 15:59:22 -07007 */
8
9#include <common.h>
Tom Rini23415e52015-12-07 08:23:29 -050010#include <command.h>
Simon Glassc8b5e222022-05-08 04:39:26 -060011#include <dm/root.h>
Simon Glassd9f9a892015-06-23 15:38:35 -060012#include <dm/util.h>
Simon Glassc267cf72014-02-26 15:59:22 -070013
Simon Glasse9daa5d2022-05-08 04:39:20 -060014static int do_dm_dump_driver_compat(struct cmd_tbl *cmdtp, int flag, int argc,
15 char * const argv[])
Simon Glassc267cf72014-02-26 15:59:22 -070016{
Simon Glasse9daa5d2022-05-08 04:39:20 -060017 dm_dump_driver_compat();
Simon Glassc267cf72014-02-26 15:59:22 -070018
19 return 0;
20}
21
Simon Glassed38aef2020-05-10 11:40:03 -060022static int do_dm_dump_devres(struct cmd_tbl *cmdtp, int flag, int argc,
23 char *const argv[])
Masahiro Yamadaf929c0b2015-07-25 21:52:38 +090024{
25 dm_dump_devres();
26
27 return 0;
28}
29
Simon Glassed38aef2020-05-10 11:40:03 -060030static int do_dm_dump_drivers(struct cmd_tbl *cmdtp, int flag, int argc,
31 char *const argv[])
Sean Anderson02827572020-01-17 14:48:09 -050032{
33 dm_dump_drivers();
34
35 return 0;
36}
37
Simon Glassc8b5e222022-05-08 04:39:26 -060038#if CONFIG_IS_ENABLED(DM_STATS)
39static int do_dm_dump_mem(struct cmd_tbl *cmdtp, int flag, int argc,
40 char *const argv[])
41{
42 struct dm_stats mem;
43
44 dm_get_mem(&mem);
45 dm_dump_mem(&mem);
46
47 return 0;
48}
49#endif /* DM_STATS */
50
Simon Glasse9daa5d2022-05-08 04:39:20 -060051static int do_dm_dump_static_driver_info(struct cmd_tbl *cmdtp, int flag,
52 int argc, char * const argv[])
Niel Fourie39832fb2020-03-24 16:17:05 +010053{
Simon Glasse9daa5d2022-05-08 04:39:20 -060054 dm_dump_static_driver_info();
Niel Fourie39832fb2020-03-24 16:17:05 +010055
56 return 0;
57}
58
Simon Glasse9daa5d2022-05-08 04:39:20 -060059static int do_dm_dump_tree(struct cmd_tbl *cmdtp, int flag, int argc,
60 char *const argv[])
Niel Fourie39832fb2020-03-24 16:17:05 +010061{
Simon Glasse5314c12023-01-17 10:47:12 -070062 bool sort;
63
64 sort = argc > 1 && !strcmp(argv[1], "-s");
65
66 dm_dump_tree(sort);
Niel Fourie39832fb2020-03-24 16:17:05 +010067
68 return 0;
69}
70
Simon Glasse9daa5d2022-05-08 04:39:20 -060071static int do_dm_dump_uclass(struct cmd_tbl *cmdtp, int flag, int argc,
72 char *const argv[])
73{
74 dm_dump_uclass();
75
76 return 0;
77}
78
Simon Glassc8b5e222022-05-08 04:39:26 -060079#if CONFIG_IS_ENABLED(DM_STATS)
80#define DM_MEM_HELP "dm mem Provide a summary of memory usage\n"
81#define DM_MEM U_BOOT_SUBCMD_MKENT(mem, 1, 1, do_dm_dump_mem),
82#else
83#define DM_MEM_HELP
84#define DM_MEM
85#endif
86
Ovidiu Panaite4c5b792022-05-08 13:01:42 +030087#if CONFIG_IS_ENABLED(SYS_LONGHELP)
88static char dm_help_text[] =
Simon Glasse9daa5d2022-05-08 04:39:20 -060089 "compat Dump list of drivers with compatibility strings\n"
Sean Anderson02827572020-01-17 14:48:09 -050090 "dm devres Dump list of device resources for each device\n"
Niel Fourie39832fb2020-03-24 16:17:05 +010091 "dm drivers Dump list of drivers with uclass and instances\n"
Simon Glassc8b5e222022-05-08 04:39:26 -060092 DM_MEM_HELP
Simon Glasse9daa5d2022-05-08 04:39:20 -060093 "dm static Dump list of drivers with static platform data\n"
Simon Glasse5314c12023-01-17 10:47:12 -070094 "dm tree [-s] Dump tree of driver model devices (-s=sort)\n"
Simon Glasse9daa5d2022-05-08 04:39:20 -060095 "dm uclass Dump list of instances for each uclass"
Ovidiu Panaite4c5b792022-05-08 13:01:42 +030096 ;
97#endif
98
99U_BOOT_CMD_WITH_SUBCMDS(dm, "Driver model low level access", dm_help_text,
Simon Glasse9daa5d2022-05-08 04:39:20 -0600100 U_BOOT_SUBCMD_MKENT(compat, 1, 1, do_dm_dump_driver_compat),
Ovidiu Panaite4c5b792022-05-08 13:01:42 +0300101 U_BOOT_SUBCMD_MKENT(devres, 1, 1, do_dm_dump_devres),
102 U_BOOT_SUBCMD_MKENT(drivers, 1, 1, do_dm_dump_drivers),
Simon Glassc8b5e222022-05-08 04:39:26 -0600103 DM_MEM
Simon Glasse9daa5d2022-05-08 04:39:20 -0600104 U_BOOT_SUBCMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info),
Simon Glasse5314c12023-01-17 10:47:12 -0700105 U_BOOT_SUBCMD_MKENT(tree, 2, 1, do_dm_dump_tree),
Simon Glasse9daa5d2022-05-08 04:39:20 -0600106 U_BOOT_SUBCMD_MKENT(uclass, 1, 1, do_dm_dump_uclass));