2 * Copyright (C) 2012 Boundary Devices Inc.
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 #include <asm/errno.h>
25 #include <asm/imx-common/boot_mode.h>
28 static const struct boot_mode *modes[2];
30 static const struct boot_mode *search_modes(char *arg)
34 for (i = 0; i < ARRAY_SIZE(modes); i++) {
35 const struct boot_mode *p = modes[i];
38 if (!strcmp(p->name, arg))
47 static int create_usage(char *dest)
52 for (i = 0; i < ARRAY_SIZE(modes); i++) {
53 const struct boot_mode *p = modes[i];
56 int len = strlen(p->name);
58 memcpy(dest, p->name, len);
68 memcpy(dest - 1, " [noreset]", 11); /* include trailing 0 */
73 static int do_boot_mode(cmd_tbl_t *cmdtp, int flag, int argc,
76 const struct boot_mode *p;
77 int reset_requested = 1;
81 p = search_modes(argv[1]);
85 if (strcmp(argv[2], "noreset"))
90 boot_mode_apply(p->cfg_val);
91 if (reset_requested && p->cfg_val)
92 do_reset(NULL, 0, 0, NULL);
97 bmode, 3, 0, do_boot_mode,
101 void add_board_boot_modes(const struct boot_mode *p)
106 if (__u_boot_cmd_bmode.usage) {
107 free(__u_boot_cmd_bmode.usage);
108 __u_boot_cmd_bmode.usage = NULL;
112 modes[1] = soc_boot_modes;
113 size = create_usage(NULL);
117 __u_boot_cmd_bmode.usage = dest;