reset: add board reset type
v2 cover reset: add board reset type
This series introduces convenience functionality for prototype boards where reset is not fully working - for example, where only warm reset is functional, but cold reset must still be enabled for the production variant.
Patch 1 allows per-board default reset override.
Patch 2 adds reset -c support to explicitly trigger cold reset. Patch 3 adds reset type printout on the console.
Patch 4 introduces a small fixup for the x86 reset driver. Patch 5 updates documentation for reset command.
Patch 6 updates reset command tests.
Denis Mukhin (6):
reset: Allow per-board reset type
reset: Add explicit cold reset support
reset: Print reset type on diagnostic console
reset: x86: Use cpu_hlt() in pch_sysreset_power_off()
docs: reset: document cold reset option
tests: reset: add cold/warm reset types
cmd/boot.c | 3 +- doc/usage/cmd/reset.rst | 8 +++++ drivers/sysreset/Kconfig | 31 ++++++++++++++++++ drivers/sysreset/sysreset-uclass.c | 50 +++++++++++++++++++++++++++--- drivers/sysreset/sysreset_x86.c | 5 +-- test/py/tests/test_reset.py | 8 ++--- test/py/u_boot_boardenv_sandbox.py | 3 ++ 7 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 test/py/u_boot_boardenv_sandbox.py
Signature · 1 line
2.54.0
PATCH v2 1/6 reset: Allow per-board reset type
From: Denis Mukhin <[email protected]>
Some prototype boards may not have (temporarily) all required reset types supported (e.g. only warm reset supported).
Add a Kconfig choice to select the board-specific default reset type used by the reset command, allowing it to work on such boards.
Keep cold reset as the default.
---
Changes since v1:
- reworked to Kconfig choice
--- drivers/sysreset/Kconfig | 31 ++++++++++++++++++++++++++++++ drivers/sysreset/sysreset-uclass.c | 19 +++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-)
drivers/sysreset/Kconfig +31 -0
@@ -57,6 +57,37 @@ config SYSRESET_CMD_RESET_ARGS additional arguments for implementing arch/board specific functionality. +if SYSRESET_CMD_RESET +choice + prompt "Default reset type for reset command" + default SYSRESET_CMD_RESET_DEFAULT_COLD + help + Select the default reset type used by the reset command when no + explicit reset type is requested. + +config SYSRESET_CMD_RESET_DEFAULT_WARM + bool "Warm reset" + help + Reset CPU while keeping GPIOs active. + +config SYSRESET_CMD_RESET_DEFAULT_COLD + bool "Cold reset" + help + Reset CPU and GPIOs. + +config SYSRESET_CMD_RESET_DEFAULT_POWER + bool "Power reset" + help + Reset PMIC by removing and restoring power. + +config SYSRESET_CMD_RESET_DEFAULT_POWER_OFF + bool "Power off" + help + Turn off power. + +endchoice +endif + if CMD_POWEROFF config SYSRESET_CMD_POWEROFF
drivers/sysreset/sysreset-uclass.c +18 -1
@@ -150,9 +150,26 @@ void reset_cpu(void) }#if IS_ENABLED (CONFIG_SYSRESET_CMD_RESET ) +static enum sysreset_t sysreset_get_default_type (void ) +{ +if (IS_ENABLED (CONFIG_SYSRESET_CMD_RESET_DEFAULT_WARM )) +return SYSRESET_WARM ; + +if (IS_ENABLED (CONFIG_SYSRESET_CMD_RESET_DEFAULT_COLD )) +return SYSRESET_COLD ; + +if (IS_ENABLED (CONFIG_SYSRESET_CMD_RESET_DEFAULT_POWER )) +return SYSRESET_POWER ; + +if (IS_ENABLED (CONFIG_SYSRESET_CMD_RESET_DEFAULT_POWER_OFF )) +return SYSRESET_POWER_OFF ; + +return SYSRESET_COLD ; +} +int do_reset (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { -enum sysreset_t reset_type =SYSRESET_COLD ; +enum sysreset_t reset_type =sysreset_get_default_type ();if (argc >2 )return CMD_RET_USAGE ;
Signature · 1 line
2.54.0
PATCH v2 2/6 reset: Add explicit cold reset support
In reply to [email protected]From: Denis Mukhin <[email protected]>
Some prototype boards default to a non-cold reset type, e.g. warm reset.
Add reset -c so users can excplicitly request a cold reset when needed.
---
Changes since v1:
- corrected args parsing in do_reset()
- updated commit message
- fixup reset command description
--- cmd/boot.c | 3 ++- drivers/sysreset/sysreset-uclass.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-)
cmd/boot.c +2 -1
@@ -59,13 +59,14 @@ U_BOOT_CMD(U_BOOT_CMD ( reset,2 ,0 , do_reset,"Perform RESET of the CPU" , - "- cold boot without level specifier\n" + "- reset without level specifier\n" #if IS_ENABLED(CONFIG_SYSRESET_CMD_RESET_ARGS) // All options handled by sysreset drivers via their sysreset_ops.request_arg callback #ifdef CONFIG_SYSRESET_QCOM_PSCI "reset -edl - Boot to Emergency DownLoad mode\n" #endif #endif +"reset -c - cold reset if implemented\n" "reset -w - warm reset if implemented" );
drivers/sysreset/sysreset-uclass.c +11 -2
@@ -174,8 +174,17 @@ int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])if (argc >2 )return CMD_RET_USAGE ; -if (argc ==2 && argv[1 ][0 ] =='-' && argv[1 ][1 ] =='w' ) { - reset_type =SYSRESET_WARM ; +if (argc ==2 && argv[1 ][0 ] =='-' ) { +switch (argv[1 ][1 ]) { +case 'c' : + reset_type =SYSRESET_COLD ; +break ; +case 'w' : + reset_type =SYSRESET_WARM ; +break ; +default : +return CMD_RET_USAGE ; + } }printf ("resetting ...\n" );
Signature · 1 line
2.54.0
PATCH v2 3/6 reset: Print reset type on diagnostic console
In reply to [email protected]From: Denis Mukhin <[email protected]>
Add a diagnostic console trace indicating the reset type.
---
Changes since v1:
- corrected the string representation for SYSRESET_POWER
--- drivers/sysreset/sysreset-uclass.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/sysreset/sysreset-uclass.c +17 -1
@@ -22,6 +22,22 @@#include <linux/err.h> #include <asm/global_data.h> +static const char *get_reset_type_str (enum sysreset_t reset_type) +{ +switch (reset_type) { +case SYSRESET_WARM : +return "warm" ; +case SYSRESET_COLD : +return "cold" ; +case SYSRESET_POWER : +return "power" ; +case SYSRESET_POWER_OFF : +return "power off" ; +default : +return "unknown" ; + } +} +int sysreset_request (struct udevice *dev,enum sysreset_t type) {struct sysreset_ops *ops =sysreset_get_ops (dev);
@@ -187,7 +203,7 @@ int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } } -printf ("resetting ...\n" ); +printf ("resetting (%s)...\n" ,get_reset_type_str (reset_type));mdelay (100 );#if IS_ENABLED (CONFIG_SYSRESET_CMD_RESET_ARGS )
Signature · 1 line
2.54.0
PATCH v2 4/6 reset: x86: Use cpu_hlt() in pch_sysreset_power_off()
In reply to [email protected]From: Denis Mukhin <[email protected]>
Use cpu_hlt() instead of open-coded "hlt" in pch_sysreset_power_off().
Also, replace the open-coded busy loop in efi_reset_system() and use cpu_hlt().
---
Changes since v1:
- dropped unneeded #include
- corrected the commit message
--- drivers/sysreset/sysreset_x86.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/sysreset/sysreset_x86.c +3 -2
@@ -65,7 +65,7 @@ int pch_sysreset_power_off(struct udevice *dev)outl (reg32, pm.base + pm.pm1_cnt_ofs);for (;;) - asm("hlt" ); +cpu_hlt (); }static int x86_sysreset_request (struct udevice *dev,enum sysreset_t type)
@@ -120,7 +120,8 @@ void __efi_runtime EFIAPI efi_reset_system(/* TODO EFI_RESET_SHUTDOWN */ - while (1) { } +for (;;) + cpu_hlt(); }#endif
Signature · 1 line
2.54.0
PATCH v2 5/6 docs: reset: document cold reset option
In reply to [email protected]From: Denis Mukhin <[email protected]>
Update the reset command documentation to cover reset -c and explain that the default reset type can be overridden through the relevant Kconfig choice.
---
Changes since v1:
- new patch
--- doc/usage/cmd/reset.rst | 8 ++++++++ 1 file changed, 8 insertions(+)
doc/usage/cmd/reset.rst +8 -0
@@ -12,6 +12,7 @@ Synopsis :: reset + reset -c reset -w reset -edl
@@ -21,6 +22,13 @@ Description Perform reset of the CPU. By default does COLD reset, which resets CPU, DDR and peripherals, on some boards also resets external PMIC. +The default behavior may be overridden via +CONFIG_SYSRESET_CMD_RESET_DEFAULT_{COLD,WARM,POWER,POWER_OFF}. + +-c + Do COLD reset: reset CPU and peripheral/DDR; on some boards also resets + external PMIC. + -w Do WARM reset: reset CPU but keep peripheral/DDR/PMIC active.
Signature · 1 line
2.54.0
PATCH v2 6/6 tests: reset: add cold/warm reset types
In reply to [email protected]From: Denis Mukhin <[email protected]>
Extend reset tests to cover both -c/-w reset command flags. Make sure sandbox reset tests are passing.
---
Changes since v1:
- new patch
Test for sandbox:./test/py/test.py --bd sandbox --build -k test_reset -v
--- test/py/tests/test_reset.py | 8 ++++---- test/py/u_boot_boardenv_sandbox.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 test/py/u_boot_boardenv_sandbox.py
test/py/tests/test_reset.py +4 -4
@@ -52,12 +52,12 @@ def test_reset(ubman): test_000_version.test_version(ubman) @pytest.mark.buildconfigspec('hush_parser') -def test_reset_w(ubman): - """Test the reset -w command in non-JTAG bootmode. - It does WARM reset, which resets CPU but keep DDR/peripherals active. [email protected]("reset_type", ["c", "w"]) +def test_reset_type(ubman, reset_type): + """Test the reset -{c,w} command in non-JTAG bootmode. """ setup_reset_env(ubman) - ubman.run_command('reset -w', wait_for_reboot=True) + ubman.run_command(f"reset -{reset_type}", wait_for_reboot=True) # Checks the u-boot command prompt's functionality after reset test_000_version.test_version(ubman)
test/py/u_boot_boardenv_sandbox.py new file +3 -0
@@ -0,0 +1,3 @@ +env__reset_test = { + 'bootmode': 'sandbox', +}
Signature · 1 line
2.54.0
Re: [PATCH v2 6/6] tests: reset: add cold/warm reset types
Quoted 10 lines · On Wed, May 27, 2026 at 04:13:06PM -0700, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Extend reset tests to cover both -c/-w reset command flags. Make sure sandbox reset tests are passing.
Signed-off-by Denis Mukhin <[email protected]>---
Changes since v1:
- new patch
Quoted 7 lines
Test for sandbox:
./test/py/test.py--bd sandbox --build -ktest_reset-v--- test/py/tests/test_reset.py | 8 ++++---- test/py/u_boot_boardenv_sandbox.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 test/py/u_boot_boardenv_sandbox.py
I'm not surprised to see we could put a u_boot_boardenv file there, but, that's not where it should be really. I think for now we can just keep the reset test on the list of tests not running on sandbox and address putting a u_boot_boardenv_sandbox.py file in the u-boot-test-hooks repository as a follow-up.
Signature · 1 line
Tom
Re: [PATCH v2 6/6] tests: reset: add cold/warm reset types
Quoted 19 lines · Tom Rini
Quoted 10 lines · On Wed, May 27, 2026 at 04:13:06PM -0700, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Extend reset tests to cover both -c/-w reset command flags. Make sure sandbox reset tests are passing.
Signed-off-by Denis Mukhin <[email protected]>---
Changes since v1:
- new patchQuoted 7 lines
Test for sandbox:
./test/py/test.py--bd sandbox --build -ktest_reset-v--- test/py/tests/test_reset.py | 8 ++++---- test/py/u_boot_boardenv_sandbox.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 test/py/u_boot_boardenv_sandbox.py
Quoted 5 lines
I'm not surprised to see we could put a
u_boot_boardenvfile there, but, that's not where it should be really. I think for now we can just keep the reset test on the list of tests not running on sandbox and address putting au_boot_boardenv_sandbox.pyfile in the u-boot-test-hooks repository as a follow-up.
OK, thanks!
Will drop the sandbox config.
Quoted 3 lines
Signature · 2 lines
-- Tom