barebox/arch/arm/mach-omap/boot_order.c
Holger Schurig f1f532084a commands: harmonize in-barebox documentation
This patch does probably too much, but it's hard (and very
cumbersome/time consuming) to break it out. What is does is this:

* each command has one short description, e.g. "list MUX configuration"
* made sure the short descriptions start lowercase
* each command has one usage. That string contains just the
  options, e.g. "[-npn]". It's not part of the long help text.
* that is, it doesn't say "[OPTIONS]" anymore, every usable option
  is listed by character in this (short) option string (the long
  description is in the long help text, as before)
* help texts have been reworked, to make them
  - sometimes smaller
  - sometimes describe the options better
  - more often present themselves in a nicer format
* all long help texts are now created with BUSYBOX_CMD_HELP_
  macros, no more 'static const __maybe_unused char cmd_foobar_help[]'
* made sure the long help texts starts uppercase
* because cmdtp->name and cmdtp->opts together provide the new usage,
  all "Usage: foobar" texts have been removed from the long help texts
* BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this
  is nicer in the source code
* BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself
* made sure no line gets longer than 77 characters
* delibertely renamed cmdtp->usage, so that we can get compile-time
  errors (e.g. in out-of-tree modules that use register_command()
* the 'help' command can now always emit the usage, even without
  compiled long help texts
* 'help -v' gives a list of commands with their short description, this
  is similar like the old "help" command before my patchset
* 'help -a' gives out help of all commands

Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-14 10:03:43 +02:00

85 lines
2.3 KiB
C

/*
* boot_order.c - configure omap warm boot
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <common.h>
#include <command.h>
#include <complete.h>
#include <mach/omap4-silicon.h>
struct bootsrc {
const char *name;
uint32_t sar;
};
const struct bootsrc src_list[] = {
{"xip" , OMAP44XX_SAR_BOOT_XIP },
{"xipwait" , OMAP44XX_SAR_BOOT_XIPWAIT },
{"nand" , OMAP44XX_SAR_BOOT_NAND },
{"onenand" , OMAP44XX_SAR_BOOT_ONENAND },
{"mmc1" , OMAP44XX_SAR_BOOT_MMC1 },
{"mmc2_1" , OMAP44XX_SAR_BOOT_MMC2_1 },
{"mmc2_2" , OMAP44XX_SAR_BOOT_MMC2_2 },
{"uart" , OMAP44XX_SAR_BOOT_UART },
{"usb_1" , OMAP44XX_SAR_BOOT_USB_1 },
{"usb_ulpi", OMAP44XX_SAR_BOOT_USB_ULPI},
{"usb_2" , OMAP44XX_SAR_BOOT_USB_2 },
};
static uint32_t parse_device(char *str)
{
int i;
for (i = 0; i < ARRAY_SIZE(src_list); i++) {
if (strcmp(str, src_list[i].name) == 0)
return src_list[i].sar;
}
printf("Unknown device '%s'\n", str);
return OMAP44XX_SAR_BOOT_VOID;
}
static int cmd_boot_order(int argc, char *argv[])
{
uint32_t device_list[] = {
OMAP44XX_SAR_BOOT_VOID,
OMAP44XX_SAR_BOOT_VOID,
OMAP44XX_SAR_BOOT_VOID,
OMAP44XX_SAR_BOOT_VOID,
};
int i;
if (argc < 2)
return COMMAND_ERROR_USAGE;
for (i = 0; i + 1 < argc && i < ARRAY_SIZE(device_list); i++) {
device_list[i] = parse_device(argv[i + 1]);
if (device_list[i] == OMAP44XX_SAR_BOOT_VOID)
return COMMAND_ERROR_USAGE;
}
omap4_set_warmboot_order(device_list);
return 0;
}
BAREBOX_CMD_HELP_START(boot_order)
BAREBOX_CMD_HELP_TEXT("Set warm boot order of up to four devices. Each device can be one of:")
BAREBOX_CMD_HELP_TEXT("xip xipwait nand onenand mmc1 mmc2_1 mmc2_2 uart usb_1 usb_ulpi usb_2")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(boot_order)
.cmd = cmd_boot_order,
BAREBOX_CMD_DESC("set warm boot order")
BAREBOX_CMD_OPTS("DEVICE...")
BAREBOX_CMD_GROUP(CMD_GRP_BOOT)
BAREBOX_CMD_HELP(cmd_boot_order_help)
BAREBOX_CMD_COMPLETE(empty_complete)
BAREBOX_CMD_END