]> git.ipfire.org Git - people/ms/u-boot.git/blob - test/dm/cmd_dm.c
Merge git://git.denx.de/u-boot-marvell
[people/ms/u-boot.git] / test / dm / cmd_dm.c
1 /*
2 * Copyright (c) 2013 Google, Inc
3 *
4 * (C) Copyright 2012
5 * Marek Vasut <marex@denx.de>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9
10 #include <common.h>
11 #include <dm.h>
12 #include <malloc.h>
13 #include <mapmem.h>
14 #include <errno.h>
15 #include <asm/io.h>
16 #include <dm/root.h>
17 #include <dm/util.h>
18
19 static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc,
20 char * const argv[])
21 {
22 dm_dump_all();
23
24 return 0;
25 }
26
27 static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc,
28 char * const argv[])
29 {
30 dm_dump_uclass();
31
32 return 0;
33 }
34
35 static cmd_tbl_t test_commands[] = {
36 U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""),
37 U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""),
38 };
39
40 static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
41 {
42 cmd_tbl_t *test_cmd;
43 int ret;
44
45 if (argc < 2)
46 return CMD_RET_USAGE;
47 test_cmd = find_cmd_tbl(argv[1], test_commands,
48 ARRAY_SIZE(test_commands));
49 argc -= 2;
50 argv += 2;
51 if (!test_cmd || argc > test_cmd->maxargs)
52 return CMD_RET_USAGE;
53
54 ret = test_cmd->cmd(test_cmd, flag, argc, argv);
55
56 return cmd_process_error(test_cmd, ret);
57 }
58
59 U_BOOT_CMD(
60 dm, 3, 1, do_dm,
61 "Driver model low level access",
62 "tree Dump driver model tree ('*' = activated)\n"
63 "dm uclass Dump list of instances for each uclass"
64 );