All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] reset: add board reset type
@ 2026-05-27 23:13 dmukhin
  2026-05-27 23:13 ` [PATCH v2 1/6] reset: Allow per-board " dmukhin
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: dmukhin @ 2026-05-27 23:13 UTC (permalink / raw)
  To: u-boot; +Cc: sjg, trini, dmukhin

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

-- 
2.54.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/6] reset: Allow per-board reset type
  2026-05-27 23:13 [PATCH v2 0/6] reset: add board reset type dmukhin
@ 2026-05-27 23:13 ` dmukhin
  2026-05-27 23:13 ` [PATCH v2 2/6] reset: Add explicit cold reset support dmukhin
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: dmukhin @ 2026-05-27 23:13 UTC (permalink / raw)
  To: u-boot; +Cc: sjg, trini, dmukhin

From: Denis Mukhin <dmukhin@ford.com> 

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.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
Changes since v1:
- reworked to Kconfig choice
---
 drivers/sysreset/Kconfig           | 31 ++++++++++++++++++++++++++++++
 drivers/sysreset/sysreset-uclass.c | 19 +++++++++++++++++-
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
index 90f740f51d42..2584c2b203e5 100644
--- a/drivers/sysreset/Kconfig
+++ b/drivers/sysreset/Kconfig
@@ -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
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index f25e09e9cd06..d2fddb470bf1 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -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;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/6] reset: Add explicit cold reset support
  2026-05-27 23:13 [PATCH v2 0/6] reset: add board reset type dmukhin
  2026-05-27 23:13 ` [PATCH v2 1/6] reset: Allow per-board " dmukhin
@ 2026-05-27 23:13 ` dmukhin
  2026-05-27 23:13 ` [PATCH v2 3/6] reset: Print reset type on diagnostic console dmukhin
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: dmukhin @ 2026-05-27 23:13 UTC (permalink / raw)
  To: u-boot; +Cc: sjg, trini, dmukhin

From: Denis Mukhin <dmukhin@ford.com> 

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.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
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(-)

diff --git a/cmd/boot.c b/cmd/boot.c
index 29cdf4a9a81a..2cef907e291e 100644
--- a/cmd/boot.c
+++ b/cmd/boot.c
@@ -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"
 );
 
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index d2fddb470bf1..df68b5c3f9eb 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -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");
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/6] reset: Print reset type on diagnostic console
  2026-05-27 23:13 [PATCH v2 0/6] reset: add board reset type dmukhin
  2026-05-27 23:13 ` [PATCH v2 1/6] reset: Allow per-board " dmukhin
  2026-05-27 23:13 ` [PATCH v2 2/6] reset: Add explicit cold reset support dmukhin
@ 2026-05-27 23:13 ` dmukhin
  2026-05-27 23:13 ` [PATCH v2 4/6] reset: x86: Use cpu_hlt() in pch_sysreset_power_off() dmukhin
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: dmukhin @ 2026-05-27 23:13 UTC (permalink / raw)
  To: u-boot; +Cc: sjg, trini, dmukhin

From: Denis Mukhin <dmukhin@ford.com> 

Add a diagnostic console trace indicating the reset type.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
Changes since v1:
- corrected the string representation for SYSRESET_POWER
---
 drivers/sysreset/sysreset-uclass.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index df68b5c3f9eb..8f49a6093d49 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -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)
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 4/6] reset: x86: Use cpu_hlt() in pch_sysreset_power_off()
  2026-05-27 23:13 [PATCH v2 0/6] reset: add board reset type dmukhin
                   ` (2 preceding siblings ...)
  2026-05-27 23:13 ` [PATCH v2 3/6] reset: Print reset type on diagnostic console dmukhin
@ 2026-05-27 23:13 ` dmukhin
  2026-05-27 23:13 ` [PATCH v2 5/6] docs: reset: document cold reset option dmukhin
  2026-05-27 23:13 ` [PATCH v2 6/6] tests: reset: add cold/warm reset types dmukhin
  5 siblings, 0 replies; 9+ messages in thread
From: dmukhin @ 2026-05-27 23:13 UTC (permalink / raw)
  To: u-boot; +Cc: sjg, trini, dmukhin

From: Denis Mukhin <dmukhin@ford.com> 

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().

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
Changes since v1:
- dropped unneeded #include
- corrected the commit message
---
 drivers/sysreset/sysreset_x86.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/sysreset/sysreset_x86.c b/drivers/sysreset/sysreset_x86.c
index c2f28c65280f..afb77d9c5c21 100644
--- a/drivers/sysreset/sysreset_x86.c
+++ b/drivers/sysreset/sysreset_x86.c
@@ -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
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 5/6] docs: reset: document cold reset option
  2026-05-27 23:13 [PATCH v2 0/6] reset: add board reset type dmukhin
                   ` (3 preceding siblings ...)
  2026-05-27 23:13 ` [PATCH v2 4/6] reset: x86: Use cpu_hlt() in pch_sysreset_power_off() dmukhin
@ 2026-05-27 23:13 ` dmukhin
  2026-05-27 23:13 ` [PATCH v2 6/6] tests: reset: add cold/warm reset types dmukhin
  5 siblings, 0 replies; 9+ messages in thread
From: dmukhin @ 2026-05-27 23:13 UTC (permalink / raw)
  To: u-boot; +Cc: sjg, trini, dmukhin

From: Denis Mukhin <dmukhin@ford.com> 

Update the reset command documentation to cover `reset -c` and explain
that the default reset type can be overridden through the relevant
Kconfig choice.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
Changes since v1:
- new patch
---
 doc/usage/cmd/reset.rst | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/doc/usage/cmd/reset.rst b/doc/usage/cmd/reset.rst
index 79bc8b9deca5..e319d2146caa 100644
--- a/doc/usage/cmd/reset.rst
+++ b/doc/usage/cmd/reset.rst
@@ -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.
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 6/6] tests: reset: add cold/warm reset types
  2026-05-27 23:13 [PATCH v2 0/6] reset: add board reset type dmukhin
                   ` (4 preceding siblings ...)
  2026-05-27 23:13 ` [PATCH v2 5/6] docs: reset: document cold reset option dmukhin
@ 2026-05-27 23:13 ` dmukhin
  2026-05-27 23:47   ` Tom Rini
  5 siblings, 1 reply; 9+ messages in thread
From: dmukhin @ 2026-05-27 23:13 UTC (permalink / raw)
  To: u-boot; +Cc: sjg, trini, dmukhin

From: Denis Mukhin <dmukhin@ford.com> 

Extend reset tests to cover both -c/-w reset command flags.
Make sure sandbox reset tests are passing.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
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

diff --git a/test/py/tests/test_reset.py b/test/py/tests/test_reset.py
index af079a706647..e1037c963f77 100644
--- a/test/py/tests/test_reset.py
+++ b/test/py/tests/test_reset.py
@@ -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.
+@pytest.mark.parametrize("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)
diff --git a/test/py/u_boot_boardenv_sandbox.py b/test/py/u_boot_boardenv_sandbox.py
new file mode 100644
index 000000000000..1057f7c3674c
--- /dev/null
+++ b/test/py/u_boot_boardenv_sandbox.py
@@ -0,0 +1,3 @@
+env__reset_test = {
+    'bootmode': 'sandbox',
+}
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 6/6] tests: reset: add cold/warm reset types
  2026-05-27 23:13 ` [PATCH v2 6/6] tests: reset: add cold/warm reset types dmukhin
@ 2026-05-27 23:47   ` Tom Rini
  2026-05-28  0:02     ` dmukhin
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Rini @ 2026-05-27 23:47 UTC (permalink / raw)
  To: dmukhin; +Cc: u-boot, sjg

[-- Attachment #1: Type: text/plain, Size: 948 bytes --]

On Wed, May 27, 2026 at 04:13:06PM -0700, dmukhin@ford.com wrote:
> From: Denis Mukhin <dmukhin@ford.com> 
> 
> Extend reset tests to cover both -c/-w reset command flags.
> Make sure sandbox reset tests are passing.
> 
> Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> ---
> 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

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.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 6/6] tests: reset: add cold/warm reset types
  2026-05-27 23:47   ` Tom Rini
@ 2026-05-28  0:02     ` dmukhin
  0 siblings, 0 replies; 9+ messages in thread
From: dmukhin @ 2026-05-28  0:02 UTC (permalink / raw)
  To: Tom Rini; +Cc: dmukhin, u-boot, sjg

On Wed, May 27, 2026 at 05:47:15PM -0600, Tom Rini wrote:
> On Wed, May 27, 2026 at 04:13:06PM -0700, dmukhin@ford.com wrote:
> > From: Denis Mukhin <dmukhin@ford.com> 
> > 
> > Extend reset tests to cover both -c/-w reset command flags.
> > Make sure sandbox reset tests are passing.
> > 
> > Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> > ---
> > 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
> 
> 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.

OK, thanks!
Will drop the sandbox config.

> 
> -- 
> Tom



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-05-28  0:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 23:13 [PATCH v2 0/6] reset: add board reset type dmukhin
2026-05-27 23:13 ` [PATCH v2 1/6] reset: Allow per-board " dmukhin
2026-05-27 23:13 ` [PATCH v2 2/6] reset: Add explicit cold reset support dmukhin
2026-05-27 23:13 ` [PATCH v2 3/6] reset: Print reset type on diagnostic console dmukhin
2026-05-27 23:13 ` [PATCH v2 4/6] reset: x86: Use cpu_hlt() in pch_sysreset_power_off() dmukhin
2026-05-27 23:13 ` [PATCH v2 5/6] docs: reset: document cold reset option dmukhin
2026-05-27 23:13 ` [PATCH v2 6/6] tests: reset: add cold/warm reset types dmukhin
2026-05-27 23:47   ` Tom Rini
2026-05-28  0:02     ` dmukhin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.