]>
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 | ||
06811959 SG |
43 | static cmd_tbl_t test_commands[] = { |
44 | U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""), | |
45 | U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""), | |
40b6f2d0 | 46 | U_BOOT_CMD_MKENT(devres, 1, 1, do_dm_dump_devres, "", ""), |
06811959 SG |
47 | }; |
48 | ||
d6df048b MS |
49 | static __maybe_unused void dm_reloc(void) |
50 | { | |
51 | static int relocated; | |
52 | ||
53 | if (!relocated) { | |
54 | fixup_cmdtable(test_commands, ARRAY_SIZE(test_commands)); | |
55 | relocated = 1; | |
56 | } | |
57 | } | |
58 | ||
06811959 SG |
59 | static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
60 | { | |
61 | cmd_tbl_t *test_cmd; | |
62 | int ret; | |
63 | ||
d6df048b MS |
64 | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
65 | dm_reloc(); | |
66 | #endif | |
67 | ||
57f54d55 | 68 | if (argc < 2) |
06811959 SG |
69 | return CMD_RET_USAGE; |
70 | test_cmd = find_cmd_tbl(argv[1], test_commands, | |
71 | ARRAY_SIZE(test_commands)); | |
72 | argc -= 2; | |
73 | argv += 2; | |
74 | if (!test_cmd || argc > test_cmd->maxargs) | |
75 | return CMD_RET_USAGE; | |
76 | ||
77 | ret = test_cmd->cmd(test_cmd, flag, argc, argv); | |
78 | ||
79 | return cmd_process_error(test_cmd, ret); | |
80 | } | |
81 | ||
82 | U_BOOT_CMD( | |
57f54d55 | 83 | dm, 3, 1, do_dm, |
06811959 | 84 | "Driver model low level access", |
138c8a75 | 85 | "tree Dump driver model tree ('*' = activated)\n" |
40b6f2d0 MY |
86 | "dm uclass Dump list of instances for each uclass\n" |
87 | "dm devres Dump list of device resources for each device" | |
06811959 | 88 | ); |