]>
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> |
06811959 SG |
11 | #include <dm.h> |
12 | #include <malloc.h> | |
0eb25b61 | 13 | #include <mapmem.h> |
06811959 SG |
14 | #include <errno.h> |
15 | #include <asm/io.h> | |
16 | #include <dm/root.h> | |
304fbef1 | 17 | #include <dm/util.h> |
a56642c7 MY |
18 | |
19 | static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc, | |
20 | char * const argv[]) | |
21 | { | |
304fbef1 | 22 | dm_dump_all(); |
a56642c7 MY |
23 | |
24 | return 0; | |
25 | } | |
26 | ||
06811959 SG |
27 | static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc, |
28 | char * const argv[]) | |
29 | { | |
304fbef1 | 30 | dm_dump_uclass(); |
06811959 SG |
31 | |
32 | return 0; | |
33 | } | |
34 | ||
40b6f2d0 MY |
35 | static int do_dm_dump_devres(cmd_tbl_t *cmdtp, int flag, int argc, |
36 | char * const argv[]) | |
37 | { | |
38 | dm_dump_devres(); | |
39 | ||
40 | return 0; | |
41 | } | |
42 | ||
7b9d60fc | 43 | static int do_dm_dump_drivers(cmd_tbl_t *cmdtp, int flag, int argc, |
97c7ac21 | 44 | char * const argv[]) |
7b9d60fc SA |
45 | { |
46 | dm_dump_drivers(); | |
47 | ||
48 | return 0; | |
49 | } | |
50 | ||
06811959 SG |
51 | static cmd_tbl_t test_commands[] = { |
52 | U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""), | |
53 | U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""), | |
40b6f2d0 | 54 | U_BOOT_CMD_MKENT(devres, 1, 1, do_dm_dump_devres, "", ""), |
7b9d60fc | 55 | U_BOOT_CMD_MKENT(drivers, 1, 1, do_dm_dump_drivers, "", ""), |
06811959 SG |
56 | }; |
57 | ||
d6df048b MS |
58 | static __maybe_unused void dm_reloc(void) |
59 | { | |
60 | static int relocated; | |
61 | ||
62 | if (!relocated) { | |
63 | fixup_cmdtable(test_commands, ARRAY_SIZE(test_commands)); | |
64 | relocated = 1; | |
65 | } | |
66 | } | |
67 | ||
06811959 SG |
68 | static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
69 | { | |
70 | cmd_tbl_t *test_cmd; | |
71 | int ret; | |
72 | ||
d6df048b MS |
73 | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
74 | dm_reloc(); | |
75 | #endif | |
76 | ||
57f54d55 | 77 | if (argc < 2) |
06811959 SG |
78 | return CMD_RET_USAGE; |
79 | test_cmd = find_cmd_tbl(argv[1], test_commands, | |
80 | ARRAY_SIZE(test_commands)); | |
81 | argc -= 2; | |
82 | argv += 2; | |
83 | if (!test_cmd || argc > test_cmd->maxargs) | |
84 | return CMD_RET_USAGE; | |
85 | ||
86 | ret = test_cmd->cmd(test_cmd, flag, argc, argv); | |
87 | ||
88 | return cmd_process_error(test_cmd, ret); | |
89 | } | |
90 | ||
91 | U_BOOT_CMD( | |
57f54d55 | 92 | dm, 3, 1, do_dm, |
06811959 | 93 | "Driver model low level access", |
138c8a75 | 94 | "tree Dump driver model tree ('*' = activated)\n" |
40b6f2d0 | 95 | "dm uclass Dump list of instances for each uclass\n" |
7b9d60fc | 96 | "dm devres Dump list of device resources for each device\n" |
97c7ac21 | 97 | "dm drivers Dump list of drivers and their compatible strings" |
06811959 | 98 | ); |