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 */
56 memcpy(dest - 1, "\nbmode - getprisec", 19);
62 __weak int boot_mode_getprisec(void)
67 static int do_boot_mode(struct cmd_tbl *cmdtp, int flag, int argc,
70 const struct boot_mode *p;
71 int reset_requested = 1;
75 if (!strcmp(argv[1], "getprisec"))
76 return boot_mode_getprisec();
77 p = search_modes(argv[1]);
81 if (strcmp(argv[2], "noreset"))
86 boot_mode_apply(p->cfg_val);
87 if (reset_requested && p->cfg_val)
88 do_reset(NULL, 0, 0, NULL);
93 bmode, 3, 0, do_boot_mode,
97 void add_board_boot_modes(const struct boot_mode *p)
102 struct cmd_tbl *entry = ll_entry_get(struct cmd_tbl, bmode, cmd);
110 modes[1] = soc_boot_modes;
111 size = create_usage(NULL);