summaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-10-17 09:09:55 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-10-27 11:13:29 +0200
commit1c33083a1542db3ea596481781170123f0d0510f (patch)
tree343fb3b2c38f2567604c6b2da06e6f342af207e6 /commands
parent21dda946e7aa86246bf7ca22fb1a1609407c4bb9 (diff)
downloadbarebox-1c33083a1542db3ea596481781170123f0d0510f.tar.gz
restart: add reset -w for warm bootrom reset
We currently support reboot mode communication with BootROMs of the i.MX6Q/DL, i.MX8MM and STM32MP15x. For each of these, the user must take care to use the correct reset as the highest priority reset often clears the non-volatile register mapped by the syscon holding the reboot mode. As we only have one BootROM, we can improve usability by adding a global flag that describes whether a restart handler is suitable for use after a bootrom reboot mode write. Add a flag bit describing this and allow populating it from the device tree as well as from drivers. Existing i.MX/STM32 drivers will be moved onto this in follow-up commits. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221017071000.1458292-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/reset.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/commands/reset.c b/commands/reset.c
index fe54e2f9b4..88e677afab 100644
--- a/commands/reset.c
+++ b/commands/reset.c
@@ -12,12 +12,12 @@
static int cmd_reset(int argc, char *argv[])
{
struct restart_handler *rst;
- int opt, shutdown_flag;
+ int opt, shutdown_flag, flags = 0;
const char *name = NULL;
shutdown_flag = 1;
- while ((opt = getopt(argc, argv, "flr:")) > 0) {
+ while ((opt = getopt(argc, argv, "flwr:")) > 0) {
switch (opt) {
case 'f':
shutdown_flag = 0;
@@ -25,6 +25,9 @@ static int cmd_reset(int argc, char *argv[])
case 'l':
restart_handlers_print();
return 0;
+ case 'w':
+ flags |= RESTART_FLAG_WARM_BOOTROM;
+ break;
case 'r':
name = optarg;
break;
@@ -33,9 +36,9 @@ static int cmd_reset(int argc, char *argv[])
}
}
- rst = restart_handler_get_by_name(name);
- if (!rst && name) {
- printf("reset '%s' does not exist\n", name);
+ rst = restart_handler_get_by_name(name, flags);
+ if (!rst && (name || flags)) {
+ printf("No matching restart handler found\n");
return COMMAND_ERROR;
}
@@ -57,13 +60,14 @@ BAREBOX_CMD_HELP_START(reset)
BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT("-f", "force RESET, don't call shutdown")
BAREBOX_CMD_HELP_OPT("-l", "list reset handlers")
+BAREBOX_CMD_HELP_OPT("-w", "only consider warm BootROM reboot-mode-preserving resets")
BAREBOX_CMD_HELP_OPT("-r RESET", "use reset handler named RESET")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(reset)
.cmd = cmd_reset,
BAREBOX_CMD_DESC("perform RESET of the CPU")
- BAREBOX_CMD_OPTS("[-flr]")
+ BAREBOX_CMD_OPTS("[-flrw]")
BAREBOX_CMD_GROUP(CMD_GRP_BOOT)
BAREBOX_CMD_HELP(cmd_reset_help)
BAREBOX_CMD_COMPLETE(empty_complete)