1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Boundary Devices Inc.
6 #include <linux/errno.h>
8 #include <asm/mach-imx/boot_mode.h>
12 static const struct boot_mode *modes[2];
14 static const struct boot_mode *search_modes(char *arg)
18 for (i = 0; i < ARRAY_SIZE(modes); i++) {
19 const struct boot_mode *p = modes[i];
22 if (!strcmp(p->name, arg))
31 static int create_usage(char *dest)
36 for (i = 0; i < ARRAY_SIZE(modes); i++) {
37 const struct boot_mode *p = modes[i];
40 int len = strlen(p->name);
42 memcpy(dest, p->name, len);
52 memcpy(dest - 1, " [noreset]", 11); /* include trailing 0 */
57 static int do_boot_mode(cmd_tbl_t *cmdtp, int flag, int argc,
60 const struct boot_mode *p;
61 int reset_requested = 1;
65 p = search_modes(argv[1]);
69 if (strcmp(argv[2], "noreset"))
74 boot_mode_apply(p->cfg_val);
75 if (reset_requested && p->cfg_val)
76 do_reset(NULL, 0, 0, NULL);
81 bmode, 3, 0, do_boot_mode,
85 void add_board_boot_modes(const struct boot_mode *p)
90 cmd_tbl_t *entry = ll_entry_get(cmd_tbl_t, bmode, cmd);
98 modes[1] = soc_boot_modes;
99 size = create_usage(NULL);