[RFC PATCH v2 4/4] sysreset: provide type of reset in do_reset cmd
Heinrich Schuchardt
xypron.glpk at gmx.de
Wed Mar 31 08:30:47 CEST 2021
On 3/30/21 11:16 PM, Igor Opaniuk wrote:
> 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",
The reset command is included on most boards, even those where we are
very tight on memory.
"Reset the CPU" is enough.
> + "[0|1]\n"
> + " no param - cold reset [default]\n"
> + " 0 - cold reset\n"
We can save another few bytes by joining the two lines:
+ " 0 - cold reset (default)\n"
> + " 1 - warm reset\n"
Could you, please, contribute a man-page in doc/usage/.
Best regards
Heinrich
> ""
> );
>
> 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;
> }
>
More information about the U-Boot
mailing list