[RFC PATCH v2 4/4] sysreset: provide type of reset in do_reset cmd
Igor Opaniuk
igor.opaniuk at foundries.io
Tue Mar 30 23:16:59 CEST 2021
From: Igor Opaniuk <igor.opaniuk at foundries.io>
Add additional param for reset cmd, which provides type of reset.
Signed-off-by: Igor Opaniuk <igor.opaniuk at foundries.io>
---
cmd/boot.c | 6 +++++-
drivers/sysreset/sysreset-uclass.c | 23 ++++++++++++++++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/cmd/boot.c b/cmd/boot.c
index 36aba22b30..f27277dacf 100644
--- a/cmd/boot.c
+++ b/cmd/boot.c
@@ -56,8 +56,12 @@ U_BOOT_CMD(
#endif
U_BOOT_CMD(
- reset, 1, 0, do_reset,
+ reset, 2, 0, do_reset,
"Perform RESET of the CPU",
+ "[0|1]\n"
+ " no param - cold reset [default]\n"
+ " 0 - cold reset\n"
+ " 1 - warm reset\n"
""
);
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index 6c9dc7a384..65342d8832 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -122,10 +122,31 @@ void reset_cpu(ulong addr)
#if IS_ENABLED(CONFIG_SYSRESET_CMD_RESET)
int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
+ u32 param;
+ enum sysreset_t reset_type = SYSRESET_COLD;
+
+ if (argc > 2)
+ return CMD_RET_USAGE;
+
+ if (argc == 2) {
+ param = simple_strtoul(argv[1], NULL, 16);
+
+ switch (param) {
+ case 0:
+ reset_type = SYSRESET_COLD;
+ break;
+ case 1:
+ reset_type = SYSRESET_WARM;
+ break;
+ default:
+ return CMD_RET_USAGE;
+ }
+ }
+
printf("resetting ...\n");
mdelay(100);
- sysreset_walk_halt(SYSRESET_COLD);
+ sysreset_walk_halt(reset_type);
return 0;
}
--
2.25.1
More information about the U-Boot
mailing list