blob: 5c501ec2541b85756b59f8038dd0f89c5c2add0c [file] [log] [blame]
Simon Glass06811952014-02-26 15:59:22 -07001/*
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>
Joe Hershberger0eb25b62015-03-22 17:08:59 -050013#include <mapmem.h>
Simon Glass06811952014-02-26 15:59:22 -070014#include <errno.h>
15#include <asm/io.h>
16#include <dm/root.h>
Simon Glass304fbef2015-06-23 15:38:35 -060017#include <dm/util.h>
Simon Glass06811952014-02-26 15:59:22 -070018
19static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc,
20 char * const argv[])
21{
Simon Glass304fbef2015-06-23 15:38:35 -060022 dm_dump_all();
Masahiro Yamadaa56642c2014-11-29 17:01:56 +090023
24 return 0;
25}
26
Simon Glass06811952014-02-26 15:59:22 -070027static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc,
28 char * const argv[])
29{
Simon Glass304fbef2015-06-23 15:38:35 -060030 dm_dump_uclass();
Simon Glass06811952014-02-26 15:59:22 -070031
32 return 0;
33}
34
Simon Glass06811952014-02-26 15:59:22 -070035static 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, "", ""),
Simon Glass06811952014-02-26 15:59:22 -070038};
39
40static 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
Simon Glass57f54d52015-03-25 12:23:04 -060045 if (argc < 2)
Simon Glass06811952014-02-26 15:59:22 -070046 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
59U_BOOT_CMD(
Simon Glass57f54d52015-03-25 12:23:04 -060060 dm, 3, 1, do_dm,
Simon Glass06811952014-02-26 15:59:22 -070061 "Driver model low level access",
Simon Glassfffa24d2014-07-23 06:55:10 -060062 "tree Dump driver model tree ('*' = activated)\n"
Simon Glassb6a49a72014-06-11 23:29:50 -060063 "dm uclass Dump list of instances for each uclass"
Simon Glass06811952014-02-26 15:59:22 -070064);