mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/2] watchdog: rti_wdt: Fix reset on AM62L
Date: Thu, 14 Aug 2025 11:56:42 +0200	[thread overview]
Message-ID: <20250814095643.1132022-1-s.hauer@pengutronix.de> (raw)

Due to different watchdog output routing on the AM62L we have to set RTIWWDRXCTRL
register differently in order to properly reset the SoC. Handle this
difference in form of a SoC specific compatible string. Based on the
corresponding Linux patch posted here [1]

[1] https://lore.kernel.org/all/20250721235705.1160972-1-jm@ti.com/

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/watchdog/rti_wdt.c | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
index ffc4427059..ba943495ff 100644
--- a/drivers/watchdog/rti_wdt.c
+++ b/drivers/watchdog/rti_wdt.c
@@ -26,7 +26,8 @@
 #define RTIWWDRXCTRL		0xa4
 #define RTIWWDSIZECTRL		0xa8
 
-#define RTIWWDRX_NMI		0xa
+#define RTIWWDRXN_RST 		0x5
+#define RTIWWDRXN_NMI		0xa
 
 #define RTIWWDSIZE_100P		0x5
 #define RTIWWDSIZE_50P		0x50
@@ -42,10 +43,15 @@
 
 #define DWDST			BIT(1)
 
+struct rti_wdt_data {
+	bool nmi;
+};
+
 struct rti_wdt_priv {
 	void __iomem *regs;
 	struct watchdog wdt;
 	unsigned int clk_hz;
+	struct rti_wdt_data *data;
 };
 
 static int rti_wdt_ping(struct watchdog *wdt)
@@ -67,7 +73,7 @@ static int rti_wdt_ping(struct watchdog *wdt)
 static int rti_wdt_settimeout(struct watchdog *wdt, unsigned int timeout)
 {
 	struct rti_wdt_priv *priv = container_of(wdt, struct rti_wdt_priv, wdt);
-	u32 timer_margin;
+	u32 timer_margin, reaction;
 
 	if (!timeout)
 		return -ENOSYS;
@@ -84,7 +90,13 @@ static int rti_wdt_settimeout(struct watchdog *wdt, unsigned int timeout)
 		timer_margin = WDT_PRELOAD_MAX;
 
 	writel(timer_margin, priv->regs + RTIDWDPRLD);
-	writel(RTIWWDRX_NMI, priv->regs + RTIWWDRXCTRL);
+
+	if (priv->data->nmi)
+		reaction = RTIWWDRXN_NMI;
+	else
+		reaction = RTIWWDRXN_RST;
+
+	writel(reaction, priv->regs + RTIWWDRXCTRL);
 	writel(RTIWWDSIZE_50P, priv->regs + RTIWWDSIZECTRL);
 
 	(void)readl(priv->regs + RTIWWDSIZECTRL);
@@ -137,6 +149,8 @@ static int rti_wdt_probe(struct device *dev)
 	if (priv->clk_hz == 0)
 		return -EINVAL;
 
+	priv->data = device_get_match_data(dev);
+
 	/*
 	 * If watchdog is running at 32k clock, it is not accurate.
 	 * Adjust frequency down in this case so that it does not expire
@@ -172,8 +186,17 @@ static int rti_wdt_probe(struct device *dev)
 	return watchdog_register(wdt);
 }
 
+static struct rti_wdt_data j7_wdt = {
+	.nmi = true,
+};
+
+static struct rti_wdt_data am62l_wdt = {
+	.nmi = false,
+};
+
 static const struct of_device_id rti_wdt_of_match[] = {
-	{ .compatible = "ti,j7-rti-wdt", },
+	{ .compatible = "ti,j7-rti-wdt", .data = &j7_wdt },
+	{ .compatible = "ti,am62l-rti-wdt", .data = &am62l_wdt },
 	{ /* sentinel */ }
 };
 
-- 
2.39.5




             reply	other threads:[~2025-08-14 13:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14  9:56 Sascha Hauer [this message]
2025-08-14  9:56 ` [PATCH 2/2] ARM: dts: AM62L: switch watchdog to SoC specific compatible 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=20250814095643.1132022-1-s.hauer@pengutronix.de \
    --to=s.hauer@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