]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/imx-common/cmd_bmode.c
2 * Copyright (C) 2012 Boundary Devices Inc.
4 * SPDX-License-Identifier: GPL-2.0+
7 #include <linux/errno.h>
9 #include <asm/imx-common/boot_mode.h>
13 static const struct boot_mode
*modes
[2];
15 static const struct boot_mode
*search_modes(char *arg
)
19 for (i
= 0; i
< ARRAY_SIZE(modes
); i
++) {
20 const struct boot_mode
*p
= modes
[i
];
23 if (!strcmp(p
->name
, arg
))
32 static int create_usage(char *dest
)
37 for (i
= 0; i
< ARRAY_SIZE(modes
); i
++) {
38 const struct boot_mode
*p
= modes
[i
];
41 int len
= strlen(p
->name
);
43 memcpy(dest
, p
->name
, len
);
53 memcpy(dest
- 1, " [noreset]", 11); /* include trailing 0 */
58 static int do_boot_mode(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
61 const struct boot_mode
*p
;
62 int reset_requested
= 1;
66 p
= search_modes(argv
[1]);
70 if (strcmp(argv
[2], "noreset"))
75 boot_mode_apply(p
->cfg_val
);
76 if (reset_requested
&& p
->cfg_val
)
77 do_reset(NULL
, 0, 0, NULL
);
82 bmode
, 3, 0, do_boot_mode
,
86 void add_board_boot_modes(const struct boot_mode
*p
)
91 cmd_tbl_t
*entry
= ll_entry_get(cmd_tbl_t
, bmode
, cmd
);
99 modes
[1] = soc_boot_modes
;
100 size
= create_usage(NULL
);