From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/4] restart: make warm reboot a callback argument
Date: Tue, 22 Apr 2025 09:56:15 +0200 [thread overview]
Message-ID: <20250422075615.220139-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250422075615.220139-1-a.fatoum@pengutronix.de>
From: Ahmad Fatoum <a.fatoum@barebox.org>
This simplifies handling of the existing warm reboot support and allow
for simple addition of more flags in future.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/arm/dts/imx7.dtsi | 2 +-
commands/reset.c | 4 ++--
common/restart.c | 6 ++++--
drivers/watchdog/imxwd.c | 35 +++++++++++------------------------
include/restart.h | 2 +-
5 files changed, 19 insertions(+), 30 deletions(-)
diff --git a/arch/arm/dts/imx7.dtsi b/arch/arm/dts/imx7.dtsi
index 1c67bdc54620..d0f6b253ed86 100644
--- a/arch/arm/dts/imx7.dtsi
+++ b/arch/arm/dts/imx7.dtsi
@@ -28,7 +28,7 @@ ca7_reset: cortex-a7-reboot {
/* This is not fit for use as general purpose reset */
restart-priority = <5>;
/*
- * Can't use imxwd-warm due to errata e10574:
+ * Can't use imxwd without fsl,ext-reset-output due to errata e10574:
* Watchdog: A watchdog timeout or software trigger will
* not reset the SOC
*/
diff --git a/commands/reset.c b/commands/reset.c
index e97b5668bacb..ccd8291f5353 100644
--- a/commands/reset.c
+++ b/commands/reset.c
@@ -26,7 +26,7 @@ static int cmd_reset(int argc, char *argv[])
restart_handlers_print();
return 0;
case 'w':
- flags |= RESTART_FLAG_WARM_BOOTROM;
+ flags |= RESTART_WARM;
break;
case 'r':
name = optarg;
@@ -47,7 +47,7 @@ static int cmd_reset(int argc, char *argv[])
if (rst) {
console_flush();
- rst->restart(rst, 0);
+ rst->restart(rst, flags);
}
hang();
diff --git a/common/restart.c b/common/restart.c
index dce7e974f64a..d0ceeab7acd0 100644
--- a/common/restart.c
+++ b/common/restart.c
@@ -32,7 +32,7 @@ int restart_handler_register(struct restart_handler *rst)
&rst->priority);
if (of_property_read_bool(rst->of_node,
"barebox,restart-warm-bootrom"))
- rst->flags |= RESTART_FLAG_WARM_BOOTROM;
+ rst->flags |= RESTART_WARM;
}
list_add_tail(&rst->list, &restart_handler_list);
@@ -127,8 +127,10 @@ void restart_handlers_print(void)
list_for_each_entry(tmp, &restart_handler_list, list) {
printf("%-20s %-20s %6d ",
tmp->name, tmp->dev ? dev_name(tmp->dev) : "", tmp->priority);
- if (tmp->flags & RESTART_FLAG_WARM_BOOTROM)
+ if (tmp->flags & RESTART_WARM)
putchar('W');
putchar('\n');
}
+
+ printf("\nW: Warm restart capable\n");
}
diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c
index 10d94645fae6..35c688fc2701 100644
--- a/drivers/watchdog/imxwd.c
+++ b/drivers/watchdog/imxwd.c
@@ -30,7 +30,6 @@ struct imx_wd {
struct device *dev;
const struct imx_wd_ops *ops;
struct restart_handler restart;
- struct restart_handler restart_warm;
bool ext_reset;
bool bigendian;
bool suspend_in_lpm;
@@ -176,6 +175,9 @@ static void __noreturn imxwd_force_soc_reset(struct restart_handler *rst,
{
struct imx_wd *priv = container_of(rst, struct imx_wd, restart);
+ if (flags & RESTART_WARM)
+ priv->ext_reset = false;
+
priv->ops->soc_reset(priv);
mdelay(1000);
@@ -183,15 +185,6 @@ static void __noreturn imxwd_force_soc_reset(struct restart_handler *rst,
hang();
}
-static void __noreturn imxwd_force_soc_reset_internal(struct restart_handler *rst,
- unsigned long flags)
-{
- struct imx_wd *priv = container_of(rst, struct imx_wd, restart_warm);
-
- priv->ext_reset = false;
- imxwd_force_soc_reset(&priv->restart, flags);
-}
-
static void imx_watchdog_detect_reset_source(struct imx_wd *priv)
{
u16 val = imxwd_read(priv, IMX21_WDOG_WSTR);
@@ -232,13 +225,7 @@ static int imx21_wd_init_no_warm_reset(struct imx_wd *priv)
static int imx21_wd_init(struct imx_wd *priv)
{
- priv->restart_warm.name = "imxwd-warm";
- priv->restart_warm.restart = imxwd_force_soc_reset_internal;
- priv->restart_warm.priority = RESTART_DEFAULT_PRIORITY - 10;
- priv->restart_warm.flags = RESTART_FLAG_WARM_BOOTROM;
-
- restart_handler_register(&priv->restart_warm);
-
+ priv->restart.flags = RESTART_WARM;
return imx21_wd_init_no_warm_reset(priv);
}
@@ -295,6 +282,13 @@ static int imx_wd_probe(struct device *dev)
}
}
+ dev->priv = priv;
+
+ priv->restart.name = "imxwd";
+ priv->restart.restart = imxwd_force_soc_reset;
+ priv->restart.priority = RESTART_DEFAULT_PRIORITY;
+ priv->restart.dev = &priv->wd.dev;
+
if (priv->ops->init) {
ret = priv->ops->init(priv);
if (ret) {
@@ -304,13 +298,6 @@ static int imx_wd_probe(struct device *dev)
}
}
- dev->priv = priv;
-
- priv->restart.name = "imxwd";
- priv->restart.restart = imxwd_force_soc_reset;
- priv->restart.priority = RESTART_DEFAULT_PRIORITY;
- priv->restart.dev = &priv->wd.dev;
-
restart_handler_register(&priv->restart);
return 0;
diff --git a/include/restart.h b/include/restart.h
index 9707a2f40f14..5414fc1fcb69 100644
--- a/include/restart.h
+++ b/include/restart.h
@@ -9,6 +9,7 @@
struct device_node;
void restart_handlers_print(void);
+#define RESTART_WARM BIT(0)
void __noreturn restart_machine(unsigned long restart_flags);
struct restart_handler *restart_handler_get_by_name(const char *name, int flags);
@@ -17,7 +18,6 @@ struct device_node;
struct restart_handler {
void (*restart)(struct restart_handler *, unsigned long);
int priority;
-#define RESTART_FLAG_WARM_BOOTROM BIT(0)
int flags;
struct device_node *of_node;
const char *name;
--
2.39.5
next prev parent reply other threads:[~2025-04-22 8:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 7:56 [PATCH 1/4] restart: give poweroff_machine and restart_machine a flag parameter Ahmad Fatoum
2025-04-22 7:56 ` [PATCH 2/4] restart: give all restart_handler::restart callbacks a flags parameter Ahmad Fatoum
2025-04-22 7:56 ` [PATCH 3/4] poweroff: give all poweroff_handler::poweroff " Ahmad Fatoum
2025-04-22 10:32 ` Sascha Hauer
2025-04-22 10:42 ` Ahmad Fatoum
2025-04-22 7:56 ` Ahmad Fatoum [this message]
2025-04-22 11:36 ` [PATCH 1/4] restart: give poweroff_machine and restart_machine a flag parameter Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250422075615.220139-4-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox