]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
06811959 SG |
2 | /* |
3 | * Copyright (c) 2013 Google, Inc | |
4 | * | |
5 | * (C) Copyright 2012 | |
6 | * Marek Vasut <[email protected]> | |
06811959 SG |
7 | */ |
8 | ||
9 | #include <common.h> | |
cbb2df20 | 10 | #include <command.h> |
2cb4ddb9 | 11 | #include <dm/root.h> |
304fbef1 | 12 | #include <dm/util.h> |
a56642c7 | 13 | |
dee2f5ae SG |
14 | static int do_dm_dump_driver_compat(struct cmd_tbl *cmdtp, int flag, int argc, |
15 | char * const argv[]) | |
06811959 | 16 | { |
dee2f5ae | 17 | dm_dump_driver_compat(); |
06811959 SG |
18 | |
19 | return 0; | |
20 | } | |
21 | ||
09140113 SG |
22 | static int do_dm_dump_devres(struct cmd_tbl *cmdtp, int flag, int argc, |
23 | char *const argv[]) | |
40b6f2d0 MY |
24 | { |
25 | dm_dump_devres(); | |
26 | ||
27 | return 0; | |
28 | } | |
29 | ||
09140113 SG |
30 | static int do_dm_dump_drivers(struct cmd_tbl *cmdtp, int flag, int argc, |
31 | char *const argv[]) | |
7b9d60fc SA |
32 | { |
33 | dm_dump_drivers(); | |
34 | ||
35 | return 0; | |
36 | } | |
37 | ||
2cb4ddb9 SG |
38 | #if CONFIG_IS_ENABLED(DM_STATS) |
39 | static 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 | ||
dee2f5ae SG |
51 | static int do_dm_dump_static_driver_info(struct cmd_tbl *cmdtp, int flag, |
52 | int argc, char * const argv[]) | |
2e488368 | 53 | { |
dee2f5ae | 54 | dm_dump_static_driver_info(); |
2e488368 NF |
55 | |
56 | return 0; | |
57 | } | |
58 | ||
dee2f5ae SG |
59 | static int do_dm_dump_tree(struct cmd_tbl *cmdtp, int flag, int argc, |
60 | char *const argv[]) | |
2e488368 | 61 | { |
36e45f69 AT |
62 | bool extended = false, sort = false; |
63 | char *device = NULL; | |
64 | ||
65 | for (; argc > 1; argc--, argv++) { | |
66 | if (argv[1][0] != '-') | |
67 | break; | |
68 | ||
69 | if (!strcmp(argv[1], "-e")) { | |
70 | extended = true; | |
71 | } else if (!strcmp(argv[1], "-s")) { | |
72 | sort = true; | |
73 | } else { | |
74 | printf("Unknown parameter: %s\n", argv[1]); | |
75 | return 0; | |
76 | } | |
77 | } | |
78 | if (argc > 1) | |
79 | device = argv[1]; | |
80 | ||
81 | dm_dump_tree(device, extended, sort); | |
dee2f5ae SG |
82 | |
83 | return 0; | |
84 | } | |
85 | ||
86 | static int do_dm_dump_uclass(struct cmd_tbl *cmdtp, int flag, int argc, | |
87 | char *const argv[]) | |
88 | { | |
36e45f69 AT |
89 | bool extended = false; |
90 | char *uclass = NULL; | |
91 | ||
92 | if (argc > 1) { | |
93 | if (!strcmp(argv[1], "-e")) { | |
94 | extended = true; | |
95 | argc--; | |
96 | argv++; | |
97 | } | |
98 | if (argc > 1) | |
99 | uclass = argv[1]; | |
100 | } | |
101 | ||
102 | dm_dump_uclass(uclass, extended); | |
2e488368 NF |
103 | |
104 | return 0; | |
105 | } | |
106 | ||
2cb4ddb9 SG |
107 | #if CONFIG_IS_ENABLED(DM_STATS) |
108 | #define DM_MEM_HELP "dm mem Provide a summary of memory usage\n" | |
109 | #define DM_MEM U_BOOT_SUBCMD_MKENT(mem, 1, 1, do_dm_dump_mem), | |
110 | #else | |
111 | #define DM_MEM_HELP | |
112 | #define DM_MEM | |
113 | #endif | |
114 | ||
3616218b | 115 | U_BOOT_LONGHELP(dm, |
dee2f5ae | 116 | "compat Dump list of drivers with compatibility strings\n" |
7b9d60fc | 117 | "dm devres Dump list of device resources for each device\n" |
2e488368 | 118 | "dm drivers Dump list of drivers with uclass and instances\n" |
2cb4ddb9 | 119 | DM_MEM_HELP |
dee2f5ae | 120 | "dm static Dump list of drivers with static platform data\n" |
36e45f69 | 121 | "dm tree [-s][-e][name] Dump tree of driver model devices (-s=sort)\n" |
3616218b | 122 | "dm uclass [-e][name] Dump list of instances for each uclass"); |
7f0836a1 OP |
123 | |
124 | U_BOOT_CMD_WITH_SUBCMDS(dm, "Driver model low level access", dm_help_text, | |
dee2f5ae | 125 | U_BOOT_SUBCMD_MKENT(compat, 1, 1, do_dm_dump_driver_compat), |
7f0836a1 OP |
126 | U_BOOT_SUBCMD_MKENT(devres, 1, 1, do_dm_dump_devres), |
127 | U_BOOT_SUBCMD_MKENT(drivers, 1, 1, do_dm_dump_drivers), | |
2cb4ddb9 | 128 | DM_MEM |
dee2f5ae | 129 | U_BOOT_SUBCMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info), |
36e45f69 AT |
130 | U_BOOT_SUBCMD_MKENT(tree, 4, 1, do_dm_dump_tree), |
131 | U_BOOT_SUBCMD_MKENT(uclass, 3, 1, do_dm_dump_uclass)); |