Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 0681195 | 2014-02-26 15:59:22 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013 Google, Inc |
| 4 | * |
| 5 | * (C) Copyright 2012 |
| 6 | * Marek Vasut <marex@denx.de> |
Simon Glass | 0681195 | 2014-02-26 15:59:22 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Tom Rini | cbb2df2 | 2015-12-07 08:23:29 -0500 | [diff] [blame] | 10 | #include <command.h> |
Simon Glass | 2cb4ddb | 2022-05-08 04:39:26 -0600 | [diff] [blame] | 11 | #include <dm/root.h> |
Simon Glass | 304fbef | 2015-06-23 15:38:35 -0600 | [diff] [blame] | 12 | #include <dm/util.h> |
Simon Glass | 0681195 | 2014-02-26 15:59:22 -0700 | [diff] [blame] | 13 | |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 14 | static int do_dm_dump_driver_compat(struct cmd_tbl *cmdtp, int flag, int argc, |
| 15 | char * const argv[]) |
Simon Glass | 0681195 | 2014-02-26 15:59:22 -0700 | [diff] [blame] | 16 | { |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 17 | dm_dump_driver_compat(); |
Simon Glass | 0681195 | 2014-02-26 15:59:22 -0700 | [diff] [blame] | 18 | |
| 19 | return 0; |
| 20 | } |
| 21 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 22 | static int do_dm_dump_devres(struct cmd_tbl *cmdtp, int flag, int argc, |
| 23 | char *const argv[]) |
Masahiro Yamada | 40b6f2d | 2015-07-25 21:52:38 +0900 | [diff] [blame] | 24 | { |
| 25 | dm_dump_devres(); |
| 26 | |
| 27 | return 0; |
| 28 | } |
| 29 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 30 | static int do_dm_dump_drivers(struct cmd_tbl *cmdtp, int flag, int argc, |
| 31 | char *const argv[]) |
Sean Anderson | 7b9d60f | 2020-01-17 14:48:09 -0500 | [diff] [blame] | 32 | { |
| 33 | dm_dump_drivers(); |
| 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |
Simon Glass | 2cb4ddb | 2022-05-08 04:39:26 -0600 | [diff] [blame] | 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 | |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 51 | static int do_dm_dump_static_driver_info(struct cmd_tbl *cmdtp, int flag, |
| 52 | int argc, char * const argv[]) |
Niel Fourie | 2e48836 | 2020-03-24 16:17:05 +0100 | [diff] [blame] | 53 | { |
| 54 | dm_dump_static_driver_info(); |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 59 | static int do_dm_dump_tree(struct cmd_tbl *cmdtp, int flag, int argc, |
| 60 | char *const argv[]) |
| 61 | { |
Simon Glass | 3d01254 | 2023-01-17 10:47:12 -0700 | [diff] [blame] | 62 | bool sort; |
| 63 | |
| 64 | sort = argc > 1 && !strcmp(argv[1], "-s"); |
| 65 | |
| 66 | dm_dump_tree(sort); |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 67 | |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | static int do_dm_dump_uclass(struct cmd_tbl *cmdtp, int flag, int argc, |
| 72 | char *const argv[]) |
| 73 | { |
| 74 | dm_dump_uclass(); |
| 75 | |
| 76 | return 0; |
| 77 | } |
| 78 | |
Simon Glass | 2cb4ddb | 2022-05-08 04:39:26 -0600 | [diff] [blame] | 79 | #if CONFIG_IS_ENABLED(DM_STATS) |
| 80 | #define DM_MEM_HELP "dm mem Provide a summary of memory usage\n" |
| 81 | #define DM_MEM U_BOOT_SUBCMD_MKENT(mem, 1, 1, do_dm_dump_mem), |
| 82 | #else |
| 83 | #define DM_MEM_HELP |
| 84 | #define DM_MEM |
| 85 | #endif |
| 86 | |
Simon Glass | 5b4d810 | 2023-02-05 15:40:56 -0700 | [diff] [blame] | 87 | #if IS_ENABLED(CONFIG_SYS_LONGHELP) |
Ovidiu Panait | 7f0836a | 2022-05-08 13:01:42 +0300 | [diff] [blame] | 88 | static char dm_help_text[] = |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 89 | "compat Dump list of drivers with compatibility strings\n" |
Sean Anderson | 7b9d60f | 2020-01-17 14:48:09 -0500 | [diff] [blame] | 90 | "dm devres Dump list of device resources for each device\n" |
Niel Fourie | 2e48836 | 2020-03-24 16:17:05 +0100 | [diff] [blame] | 91 | "dm drivers Dump list of drivers with uclass and instances\n" |
Simon Glass | 2cb4ddb | 2022-05-08 04:39:26 -0600 | [diff] [blame] | 92 | DM_MEM_HELP |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 93 | "dm static Dump list of drivers with static platform data\n" |
Simon Glass | 3d01254 | 2023-01-17 10:47:12 -0700 | [diff] [blame] | 94 | "dm tree [-s] Dump tree of driver model devices (-s=sort)\n" |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 95 | "dm uclass Dump list of instances for each uclass" |
Ovidiu Panait | 7f0836a | 2022-05-08 13:01:42 +0300 | [diff] [blame] | 96 | ; |
| 97 | #endif |
| 98 | |
| 99 | U_BOOT_CMD_WITH_SUBCMDS(dm, "Driver model low level access", dm_help_text, |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 100 | U_BOOT_SUBCMD_MKENT(compat, 1, 1, do_dm_dump_driver_compat), |
Ovidiu Panait | 7f0836a | 2022-05-08 13:01:42 +0300 | [diff] [blame] | 101 | U_BOOT_SUBCMD_MKENT(devres, 1, 1, do_dm_dump_devres), |
| 102 | U_BOOT_SUBCMD_MKENT(drivers, 1, 1, do_dm_dump_drivers), |
Simon Glass | 2cb4ddb | 2022-05-08 04:39:26 -0600 | [diff] [blame] | 103 | DM_MEM |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 104 | U_BOOT_SUBCMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info), |
Simon Glass | 3d01254 | 2023-01-17 10:47:12 -0700 | [diff] [blame] | 105 | U_BOOT_SUBCMD_MKENT(tree, 2, 1, do_dm_dump_tree), |
Simon Glass | dee2f5a | 2022-05-08 04:39:20 -0600 | [diff] [blame] | 106 | U_BOOT_SUBCMD_MKENT(uclass, 1, 1, do_dm_dump_uclass)); |