1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright 2021 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
16 #include <dm/uclass-internal.h>
18 static int do_bootmeth_list(struct cmd_tbl *cmdtp, int flag, int argc,
21 struct bootstd_priv *std;
28 if (argc > 1 && *argv[1] == '-') {
29 all = strchr(argv[1], 'a');
34 ret = bootstd_get_priv(&std);
36 printf("Cannot get bootstd (err=%d)\n", ret);
37 return CMD_RET_FAILURE;
40 printf("Order Seq Name Description\n");
41 printf("----- --- ------------------ ------------------\n");
44 * Use the ordering if we have one, so long as we are not trying to list
47 use_order = std->bootmeth_count && !all;
49 dev = std->bootmeth_order[0];
51 ret = uclass_find_first_device(UCLASS_BOOTMETH, &dev);
54 struct bootmeth_uc_plat *ucp = dev_get_uclass_plat(dev);
58 * With the -a flag we may list bootdevs that are not in the
59 * ordering. Find their place in the order
61 if (all && std->bootmeth_count) {
64 /* Find the position of this bootmeth in the order */
66 for (j = 0; j < std->bootmeth_count; j++) {
67 if (std->bootmeth_order[j] == dev)
76 printf(" %3x %-19.19s %s\n", dev_seq(dev), dev->name,
80 dev = std->bootmeth_order[i];
82 uclass_find_next_device(&dev);
84 printf("----- --- ------------------ ------------------\n");
85 printf("(%d bootmeth%s)\n", i, i != 1 ? "s" : "");
90 static int do_bootmeth_order(struct cmd_tbl *cmdtp, int flag, int argc,
95 ret = bootmeth_set_order(argv[1]);
97 printf("Failed (err=%d)\n", ret);
98 return CMD_RET_FAILURE;
100 env_set("bootmeths", argv[1]);
105 #ifdef CONFIG_SYS_LONGHELP
106 static char bootmeth_help_text[] =
107 "list [-a] - list available bootmeths (-a all)\n"
108 "bootmeth order [<bd> ...] - select bootmeth order / subset to use";
111 U_BOOT_CMD_WITH_SUBCMDS(bootmeth, "Boot methods", bootmeth_help_text,
112 U_BOOT_SUBCMD_MKENT(list, 2, 1, do_bootmeth_list),
113 U_BOOT_SUBCMD_MKENT(order, CONFIG_SYS_MAXARGS, 1, do_bootmeth_order));