U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct
       [not found] <20250331191520.1805001-1-admin@hifiphile.com>
@ 2025-03-31 19:15 ` Zixun LI
  2025-04-02 21:00   ` [PATCH 0/7] watchdog: at91sam9_wdt driver enhancement Zixun LI
  2025-04-10 10:28   ` [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct Eugen Hristev
  2025-03-31 19:15 ` [PATCH 2/7] arm: at91: wdt: Rename regval in priv data to mr Zixun LI
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 10+ messages in thread
From: Zixun LI @ 2025-03-31 19:15 UTC (permalink / raw)
  To: Eugen Hristev, Tom Rini; +Cc: Zixun LI, u-boot

at91_wdt struct is not used by anyone, let's remove it.

Signed-off-by: Zixun LI <admin@hifiphile.com>
---
 arch/arm/mach-at91/include/mach/at91_wdt.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/arm/mach-at91/include/mach/at91_wdt.h b/arch/arm/mach-at91/include/mach/at91_wdt.h
index 8ef8e007d77..78ad0453fd9 100644
--- a/arch/arm/mach-at91/include/mach/at91_wdt.h
+++ b/arch/arm/mach-at91/include/mach/at91_wdt.h
@@ -19,12 +19,6 @@
 
 #else
 
-typedef struct at91_wdt {
-	u32	cr;
-	u32	mr;
-	u32	sr;
-} at91_wdt_t;
-
 struct at91_wdt_priv {
 	void __iomem *regs;
 	u32 regval;
-- 
2.49.0


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

* [PATCH 2/7] arm: at91: wdt: Rename regval in priv data to mr
       [not found] <20250331191520.1805001-1-admin@hifiphile.com>
  2025-03-31 19:15 ` [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct Zixun LI
@ 2025-03-31 19:15 ` Zixun LI
  2025-03-31 19:15 ` [PATCH 3/7] watchdog: at91sam9_wdt: Rename priv to wdt Zixun LI
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Zixun LI @ 2025-03-31 19:15 UTC (permalink / raw)
  To: Eugen Hristev, Tom Rini, Stefan Roese; +Cc: Zixun LI, u-boot

Use the name "mr" since we are referring to timer mode register.

Signed-off-by: Zixun LI <admin@hifiphile.com>
---
 arch/arm/mach-at91/include/mach/at91_wdt.h | 2 +-
 drivers/watchdog/at91sam9_wdt.c            | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-at91/include/mach/at91_wdt.h b/arch/arm/mach-at91/include/mach/at91_wdt.h
index 78ad0453fd9..a5accbae521 100644
--- a/arch/arm/mach-at91/include/mach/at91_wdt.h
+++ b/arch/arm/mach-at91/include/mach/at91_wdt.h
@@ -21,7 +21,7 @@
 
 struct at91_wdt_priv {
 	void __iomem *regs;
-	u32 regval;
+	u32 mr;
 };
 
 #endif
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index c809a8936b8..dab7b6a9b8c 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -60,11 +60,11 @@ static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 	 * Since WDV is a 12-bit counter, the maximum period is
 	 * 4096 / 256 = 16 seconds.
 	 */
-	priv->regval = AT91_WDT_MR_WDRSTEN	/* causes watchdog reset */
+	priv->mr = AT91_WDT_MR_WDRSTEN	/* causes watchdog reset */
 		| AT91_WDT_MR_WDDBGHLT		/* disabled in debug mode */
 		| AT91_WDT_MR_WDD(0xfff)	/* restart at any time */
 		| AT91_WDT_MR_WDV(ticks);	/* timer value */
-	writel(priv->regval, priv->regs + AT91_WDT_MR);
+	writel(priv->mr, priv->regs + AT91_WDT_MR);
 
 	return 0;
 }
@@ -74,8 +74,8 @@ static int at91_wdt_stop(struct udevice *dev)
 	struct at91_wdt_priv *priv = dev_get_priv(dev);
 
 	/* Disable Watchdog Timer */
-	priv->regval |= AT91_WDT_MR_WDDIS;
-	writel(priv->regval, priv->regs + AT91_WDT_MR);
+	priv->mr |= AT91_WDT_MR_WDDIS;
+	writel(priv->mr, priv->regs + AT91_WDT_MR);
 
 	return 0;
 }
-- 
2.49.0


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

* [PATCH 3/7] watchdog: at91sam9_wdt: Rename priv to wdt
       [not found] <20250331191520.1805001-1-admin@hifiphile.com>
  2025-03-31 19:15 ` [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct Zixun LI
  2025-03-31 19:15 ` [PATCH 2/7] arm: at91: wdt: Rename regval in priv data to mr Zixun LI
@ 2025-03-31 19:15 ` Zixun LI
  2025-03-31 19:15 ` [PATCH 4/7] arm: at91: wdt: Add SAM9X60 register definition Zixun LI
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Zixun LI @ 2025-03-31 19:15 UTC (permalink / raw)
  To: Stefan Roese, Tom Rini; +Cc: Zixun LI, u-boot

"wdt" is a better name for watchdog rather than generic "priv".

Signed-off-by: Zixun LI <admin@hifiphile.com>
---
 drivers/watchdog/at91sam9_wdt.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index dab7b6a9b8c..5ca3e5a5fde 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -38,7 +38,7 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 {
-	struct at91_wdt_priv *priv = dev_get_priv(dev);
+	struct at91_wdt_priv *wdt = dev_get_priv(dev);
 	u64 timeout;
 	u32 ticks;
 
@@ -49,7 +49,7 @@ static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 	ticks = WDT_SEC2TICKS(timeout);
 
 	/* Check if disabled */
-	if (readl(priv->regs + AT91_WDT_MR) & AT91_WDT_MR_WDDIS) {
+	if (readl(wdt->regs + AT91_WDT_MR) & AT91_WDT_MR_WDDIS) {
 		printf("sorry, watchdog is disabled\n");
 		return -1;
 	}
@@ -60,31 +60,31 @@ static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 	 * Since WDV is a 12-bit counter, the maximum period is
 	 * 4096 / 256 = 16 seconds.
 	 */
-	priv->mr = AT91_WDT_MR_WDRSTEN	/* causes watchdog reset */
+	wdt->mr = AT91_WDT_MR_WDRSTEN	/* causes watchdog reset */
 		| AT91_WDT_MR_WDDBGHLT		/* disabled in debug mode */
 		| AT91_WDT_MR_WDD(0xfff)	/* restart at any time */
 		| AT91_WDT_MR_WDV(ticks);	/* timer value */
-	writel(priv->mr, priv->regs + AT91_WDT_MR);
+	writel(wdt->mr, wdt->regs + AT91_WDT_MR);
 
 	return 0;
 }
 
 static int at91_wdt_stop(struct udevice *dev)
 {
-	struct at91_wdt_priv *priv = dev_get_priv(dev);
+	struct at91_wdt_priv *wdt = dev_get_priv(dev);
 
 	/* Disable Watchdog Timer */
-	priv->mr |= AT91_WDT_MR_WDDIS;
-	writel(priv->mr, priv->regs + AT91_WDT_MR);
+	wdt->mr |= AT91_WDT_MR_WDDIS;
+	writel(wdt->mr, wdt->regs + AT91_WDT_MR);
 
 	return 0;
 }
 
 static int at91_wdt_reset(struct udevice *dev)
 {
-	struct at91_wdt_priv *priv = dev_get_priv(dev);
+	struct at91_wdt_priv *wdt = dev_get_priv(dev);
 
-	writel(AT91_WDT_CR_WDRSTT | AT91_WDT_CR_KEY, priv->regs + AT91_WDT_CR);
+	writel(AT91_WDT_CR_WDRSTT | AT91_WDT_CR_KEY, wdt->regs + AT91_WDT_CR);
 
 	return 0;
 }
@@ -102,10 +102,10 @@ static const struct udevice_id at91_wdt_ids[] = {
 
 static int at91_wdt_probe(struct udevice *dev)
 {
-	struct at91_wdt_priv *priv = dev_get_priv(dev);
+	struct at91_wdt_priv *wdt = dev_get_priv(dev);
 
-	priv->regs = dev_remap_addr(dev);
-	if (!priv->regs)
+	wdt->regs = dev_remap_addr(dev);
+	if (!wdt->regs)
 		return -EINVAL;
 
 	debug("%s: Probing wdt%u\n", __func__, dev_seq(dev));
-- 
2.49.0


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

* [PATCH 4/7] arm: at91: wdt: Add SAM9X60 register definition
       [not found] <20250331191520.1805001-1-admin@hifiphile.com>
                   ` (2 preceding siblings ...)
  2025-03-31 19:15 ` [PATCH 3/7] watchdog: at91sam9_wdt: Rename priv to wdt Zixun LI
@ 2025-03-31 19:15 ` Zixun LI
  2025-03-31 19:15 ` [PATCH 5/7] watchdog: at91sam9_wdt: Add SAM9X60 support Zixun LI
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Zixun LI @ 2025-03-31 19:15 UTC (permalink / raw)
  To: Eugen Hristev, Tom Rini; +Cc: Zixun LI, u-boot

SAM9X60 has different watchdog register definition.

Signed-off-by: Zixun LI <admin@hifiphile.com>
---
 arch/arm/mach-at91/include/mach/at91_wdt.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-at91/include/mach/at91_wdt.h b/arch/arm/mach-at91/include/mach/at91_wdt.h
index a5accbae521..9ba5283123b 100644
--- a/arch/arm/mach-at91/include/mach/at91_wdt.h
+++ b/arch/arm/mach-at91/include/mach/at91_wdt.h
@@ -33,14 +33,22 @@ struct at91_wdt_priv {
 
 /* Watchdog Mode Register*/
 #define AT91_WDT_MR			0X04
-#define AT91_WDT_MR_WDV(x)		(x & 0xfff)
+#define AT91_WDT_MR_WDV(x)		((x) & 0xfff)
+#define AT91_SAM9X60_MR_PERIODRST	0x00000010
 #define AT91_WDT_MR_WDFIEN		0x00001000
+#define AT91_SAM9X60_MR_WDDIS		0x00001000
 #define AT91_WDT_MR_WDRSTEN		0x00002000
 #define AT91_WDT_MR_WDRPROC		0x00004000
 #define AT91_WDT_MR_WDDIS		0x00008000
-#define AT91_WDT_MR_WDD(x)		((x & 0xfff) << 16)
+#define AT91_WDT_MR_WDD(x)		(((x) & 0xfff) << 16)
 #define AT91_WDT_MR_WDDBGHLT		0x10000000
+#define AT91_SAM9X60_MR_WDIDLEHLT	0x10000000
 #define AT91_WDT_MR_WDIDLEHLT		0x20000000
+#define AT91_SAM9X60_MR_WDDBGHLT	0x20000000
+
+/* Watchdog Window Level Register */
+#define AT91_SAM9X60_WLR		0x0c
+#define AT91_SAM9X60_WLR_COUNTER(x)	((x) & 0xfff)
 
 /* Hardware timeout in seconds */
 #define WDT_MAX_TIMEOUT		16
-- 
2.49.0


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

* [PATCH 5/7] watchdog: at91sam9_wdt: Add SAM9X60 support
       [not found] <20250331191520.1805001-1-admin@hifiphile.com>
                   ` (3 preceding siblings ...)
  2025-03-31 19:15 ` [PATCH 4/7] arm: at91: wdt: Add SAM9X60 register definition Zixun LI
@ 2025-03-31 19:15 ` Zixun LI
  2025-03-31 19:15 ` [PATCH 6/7] ARM: dts: sam9x60: Add watchdog DT node Zixun LI
  2025-03-31 19:15 ` [PATCH 7/7] ARM: dts: at91: sam9x60-curiosity: Enable watchdog node Zixun LI
  6 siblings, 0 replies; 10+ messages in thread
From: Zixun LI @ 2025-03-31 19:15 UTC (permalink / raw)
  To: Eugen Hristev, Tom Rini, Stefan Roese; +Cc: Zixun LI, u-boot

SAM9X60 has a slightly different watchdog implementation:
- Timer value moved into a new register WLR
- Some MR register fields have their position changed

This patch add SAM9X60 support, also adds a compatible
for SAMA5D4 who is the same as existing SAM9260.

Signed-off-by: Zixun LI <admin@hifiphile.com>
---
 arch/arm/mach-at91/include/mach/at91_wdt.h |  7 ++++
 drivers/watchdog/at91sam9_wdt.c            | 39 +++++++++++++++++-----
 2 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-at91/include/mach/at91_wdt.h b/arch/arm/mach-at91/include/mach/at91_wdt.h
index 9ba5283123b..9a3976d9e97 100644
--- a/arch/arm/mach-at91/include/mach/at91_wdt.h
+++ b/arch/arm/mach-at91/include/mach/at91_wdt.h
@@ -19,9 +19,16 @@
 
 #else
 
+enum {
+	AT91_WDT_MODE_SAM9260 = 0,
+	AT91_WDT_MODE_SAM9X60 = 1
+};
+
 struct at91_wdt_priv {
 	void __iomem *regs;
 	u32 mr;
+	u32 wddis;
+	u8 mode;
 };
 
 #endif
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index 5ca3e5a5fde..72e13787448 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -49,7 +49,7 @@ static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 	ticks = WDT_SEC2TICKS(timeout);
 
 	/* Check if disabled */
-	if (readl(wdt->regs + AT91_WDT_MR) & AT91_WDT_MR_WDDIS) {
+	if (readl(wdt->regs + AT91_WDT_MR) & wdt->wddis) {
 		printf("sorry, watchdog is disabled\n");
 		return -1;
 	}
@@ -60,11 +60,21 @@ static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 	 * Since WDV is a 12-bit counter, the maximum period is
 	 * 4096 / 256 = 16 seconds.
 	 */
-	wdt->mr = AT91_WDT_MR_WDRSTEN	/* causes watchdog reset */
-		| AT91_WDT_MR_WDDBGHLT		/* disabled in debug mode */
-		| AT91_WDT_MR_WDD(0xfff)	/* restart at any time */
-		| AT91_WDT_MR_WDV(ticks);	/* timer value */
-	writel(wdt->mr, wdt->regs + AT91_WDT_MR);
+
+	if (wdt->mode == AT91_WDT_MODE_SAM9260) {
+		wdt->mr = AT91_WDT_MR_WDRSTEN	/* causes watchdog reset */
+		    | AT91_WDT_MR_WDDBGHLT	/* disabled in debug mode */
+		    | AT91_WDT_MR_WDD(0xfff)	/* restart at any time */
+		    | AT91_WDT_MR_WDV(ticks);	/* timer value */
+		writel(wdt->mr, wdt->regs + AT91_WDT_MR);
+	} else if (wdt->mode == AT91_WDT_MODE_SAM9X60) {
+		writel(AT91_SAM9X60_WLR_COUNTER(ticks),	/* timer value */
+		       wdt->regs + AT91_SAM9X60_WLR);
+
+		wdt->mr = AT91_SAM9X60_MR_PERIODRST /* causes watchdog reset */
+			| AT91_SAM9X60_MR_WDDBGHLT; /* disabled in debug mode */
+		writel(wdt->mr, wdt->regs + AT91_WDT_MR);
+	}
 
 	return 0;
 }
@@ -74,7 +84,7 @@ static int at91_wdt_stop(struct udevice *dev)
 	struct at91_wdt_priv *wdt = dev_get_priv(dev);
 
 	/* Disable Watchdog Timer */
-	wdt->mr |= AT91_WDT_MR_WDDIS;
+	wdt->mr |= wdt->wddis;
 	writel(wdt->mr, wdt->regs + AT91_WDT_MR);
 
 	return 0;
@@ -96,7 +106,14 @@ static const struct wdt_ops at91_wdt_ops = {
 };
 
 static const struct udevice_id at91_wdt_ids[] = {
-	{ .compatible = "atmel,at91sam9260-wdt" },
+	{ .compatible = "atmel,at91sam9260-wdt",
+	  .data = AT91_WDT_MODE_SAM9260 },
+	{ .compatible = "atmel,sama5d4-wdt",
+	  .data = AT91_WDT_MODE_SAM9260 },
+	{ .compatible = "microchip,sam9x60-wdt",
+	  .data = AT91_WDT_MODE_SAM9X60 },
+	{ .compatible = "microchip,sama7g5-wdt",
+	  .data = AT91_WDT_MODE_SAM9X60 },
 	{}
 };
 
@@ -108,6 +125,12 @@ static int at91_wdt_probe(struct udevice *dev)
 	if (!wdt->regs)
 		return -EINVAL;
 
+	wdt->mode = dev_get_driver_data(dev);
+	if (wdt->mode == AT91_WDT_MODE_SAM9260)
+		wdt->wddis = AT91_WDT_MR_WDDIS;
+	else if (wdt->mode == AT91_WDT_MODE_SAM9X60)
+		wdt->wddis = AT91_SAM9X60_MR_WDDIS;
+
 	debug("%s: Probing wdt%u\n", __func__, dev_seq(dev));
 
 	return 0;
-- 
2.49.0


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

* [PATCH 6/7] ARM: dts: sam9x60: Add watchdog DT node.
       [not found] <20250331191520.1805001-1-admin@hifiphile.com>
                   ` (4 preceding siblings ...)
  2025-03-31 19:15 ` [PATCH 5/7] watchdog: at91sam9_wdt: Add SAM9X60 support Zixun LI
@ 2025-03-31 19:15 ` Zixun LI
  2025-03-31 19:15 ` [PATCH 7/7] ARM: dts: at91: sam9x60-curiosity: Enable watchdog node Zixun LI
  6 siblings, 0 replies; 10+ messages in thread
From: Zixun LI @ 2025-03-31 19:15 UTC (permalink / raw)
  To: Eugen Hristev, Tom Rini; +Cc: Zixun LI, u-boot

Add the watchdog timer node for the sam9x60 SoC's.

Signed-off-by: Zixun LI <admin@hifiphile.com>
---
 arch/arm/dts/sam9x60.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/dts/sam9x60.dtsi b/arch/arm/dts/sam9x60.dtsi
index 3b684fc63d5..f32d51eb231 100644
--- a/arch/arm/dts/sam9x60.dtsi
+++ b/arch/arm/dts/sam9x60.dtsi
@@ -333,6 +333,13 @@
 				clocks = <&slow_rc_osc>, <&slow_xtal>;
 				#clock-cells = <1>;
 			};
+
+			watchdog: watchdog@ffffff80 {
+				compatible = "microchip,sam9x60-wdt";
+				reg = <0xffffff80 0x24>;
+				clocks = <&clk32 0>;
+				status = "disabled";
+			};
 		};
 	};
 
-- 
2.49.0


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

* [PATCH 7/7] ARM: dts: at91: sam9x60-curiosity: Enable watchdog node
       [not found] <20250331191520.1805001-1-admin@hifiphile.com>
                   ` (5 preceding siblings ...)
  2025-03-31 19:15 ` [PATCH 6/7] ARM: dts: sam9x60: Add watchdog DT node Zixun LI
@ 2025-03-31 19:15 ` Zixun LI
  6 siblings, 0 replies; 10+ messages in thread
From: Zixun LI @ 2025-03-31 19:15 UTC (permalink / raw)
  To: Eugen Hristev, Tom Rini; +Cc: Zixun LI, u-boot

Enable watchdog node on SAM9X60-Curiosity board.

Signed-off-by: Zixun LI <admin@hifiphile.com>
---
 arch/arm/dts/at91-sam9x60_curiosity.dts | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/dts/at91-sam9x60_curiosity.dts b/arch/arm/dts/at91-sam9x60_curiosity.dts
index 99867d2bf8e..cdb782e28ff 100644
--- a/arch/arm/dts/at91-sam9x60_curiosity.dts
+++ b/arch/arm/dts/at91-sam9x60_curiosity.dts
@@ -248,6 +248,11 @@
 	};
 };
 
+&watchdog {
+	status = "okay";
+	timeout-sec = <16>;
+};
+
 &usb1 {
 	num-ports = <3>;
 	atmel,vbus-gpio = <0
-- 
2.49.0


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

* [PATCH 0/7] watchdog: at91sam9_wdt driver enhancement
  2025-03-31 19:15 ` [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct Zixun LI
@ 2025-04-02 21:00   ` Zixun LI
  2025-04-10 10:28   ` [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct Eugen Hristev
  1 sibling, 0 replies; 10+ messages in thread
From: Zixun LI @ 2025-04-02 21:00 UTC (permalink / raw)
  To: Eugen Hristev, Tom Rini; +Cc: Zixun LI, u-boot

It looks like cover letter was missing...

This patch series includes some code refactor and adds new device support
for at91sam9_wdt driver.

Instead of add a new driver like Linux kernel, at91sam9_wdt driver is
extended as new watchdog variant is similar to existing one, especially
for the function subset used by u-boot.

1. Remove unused typedef and rename variables for readability.

2. Add SAMA5D4 compatible, it has the same watchdog as SAM9260 except a
new lockout feature is added. Currently this feature is unimplemented.

3. SAM9X60, SAM9X7 and SAMA7 series have a new watchdog variant, some
bitfields bof MR register shifted their position, a new register is added
for timer value.

4. Add DT node to SAM9X60-Currently board

It has been tested on SAM9X60-Currently board:
- Start & stop
- Set timeout from DT node
- Reset kick in with a while(1) loop

Zixun LI (7):
  arm: at91: wdt: Remove unused at91_wdt struct
  arm: at91: wdt: Rename regval in priv data to mr
  watchdog: at91sam9_wdt: Rename priv to wdt
  arm: at91: wdt: Add SAM9X60 register definition
  watchdog: at91sam9_wdt: Add SAM9X60 support
  ARM: dts: sam9x60: Add watchdog DT node.
  ARM: dts: at91: sam9x60-curiosity: Enable watchdog node

 arch/arm/dts/at91-sam9x60_curiosity.dts    |  5 ++
 arch/arm/dts/sam9x60.dtsi                  |  7 +++
 arch/arm/mach-at91/include/mach/at91_wdt.h | 25 ++++++----
 drivers/watchdog/at91sam9_wdt.c            | 55 +++++++++++++++-------
 4 files changed, 68 insertions(+), 24 deletions(-)

--
2.49.0


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

* Re: [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct
  2025-03-31 19:15 ` [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct Zixun LI
  2025-04-02 21:00   ` [PATCH 0/7] watchdog: at91sam9_wdt driver enhancement Zixun LI
@ 2025-04-10 10:28   ` Eugen Hristev
  2025-04-10 16:42     ` Zixun LI
  1 sibling, 1 reply; 10+ messages in thread
From: Eugen Hristev @ 2025-04-10 10:28 UTC (permalink / raw)
  To: Zixun LI, Tom Rini; +Cc: u-boot



On 3/31/25 22:15, Zixun LI wrote:
> at91_wdt struct is not used by anyone, let's remove it.
> 
> Signed-off-by: Zixun LI <admin@hifiphile.com>
> ---
>  arch/arm/mach-at91/include/mach/at91_wdt.h | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/include/mach/at91_wdt.h b/arch/arm/mach-at91/include/mach/at91_wdt.h
> index 8ef8e007d77..78ad0453fd9 100644
> --- a/arch/arm/mach-at91/include/mach/at91_wdt.h
> +++ b/arch/arm/mach-at91/include/mach/at91_wdt.h
> @@ -19,12 +19,6 @@
>  
>  #else
>  
> -typedef struct at91_wdt {
> -	u32	cr;
> -	u32	mr;
> -	u32	sr;
> -} at91_wdt_t;
> -
>  struct at91_wdt_priv {
>  	void __iomem *regs;
>  	u32 regval;

This breaks sama5d2_xplained_mmc_defconfig for example.

In file included from arch/arm/mach-at91/spl.c:8:
arch/arm/mach-at91/spl.c: In function ‘at91_disable_wdt’:
arch/arm/mach-at91/spl.c:19:39: error: invalid use of undefined type
‘struct at91_wdt’
   19 |         writel(AT91_WDT_MR_WDDIS, &wdt->mr);
      |                                       ^~
./arch/arm/include/asm/io.h:31:69: note: in definition of macro
‘__arch_putl’
   31 | #define __arch_putl(v,a)                (*(volatile unsigned int
*)(a) = (v))
      |
   ^
arch/arm/mach-at91/spl.c:19:9: note: in expansion of macro ‘writel’
   19 |         writel(AT91_WDT_MR_WDDIS, &wdt->mr);
      |         ^~~~~~


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

* Re: [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct
  2025-04-10 10:28   ` [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct Eugen Hristev
@ 2025-04-10 16:42     ` Zixun LI
  0 siblings, 0 replies; 10+ messages in thread
From: Zixun LI @ 2025-04-10 16:42 UTC (permalink / raw)
  To: Eugen Hristev; +Cc: Tom Rini, u-boot

On Thu, Apr 10, 2025 at 12:28 PM Eugen Hristev <eugen.hristev@linaro.org> wrote:
>
> This breaks sama5d2_xplained_mmc_defconfig for example.
>
> In file included from arch/arm/mach-at91/spl.c:8:
> arch/arm/mach-at91/spl.c: In function ‘at91_disable_wdt’:
> arch/arm/mach-at91/spl.c:19:39: error: invalid use of undefined type
> ‘struct at91_wdt’
>    19 |         writel(AT91_WDT_MR_WDDIS, &wdt->mr);
>       |                                       ^~
> ./arch/arm/include/asm/io.h:31:69: note: in definition of macro
> ‘__arch_putl’
>    31 | #define __arch_putl(v,a)                (*(volatile unsigned int
> *)(a) = (v))
>       |
>    ^
> arch/arm/mach-at91/spl.c:19:9: note: in expansion of macro ‘writel’
>    19 |         writel(AT91_WDT_MR_WDDIS, &wdt->mr);
>       |         ^~~~~~
>

Thank you for the spot. I can add a patch like this:

 #if !defined(CONFIG_WDT_AT91)
 void at91_disable_wdt(void)
 {
-    struct at91_wdt *wdt = (struct at91_wdt *)ATMEL_BASE_WDT;
-
-    writel(AT91_WDT_MR_WDDIS, &wdt->mr);
+#if defined(CONFIG_SAM9X60)
+    writel(AT91_SAM9X60_MR_WDDIS, ATMEL_BASE_WDT + AT91_WDT_MR);
+#else
+    writel(AT91_WDT_MR_WDDIS, ATMEL_BASE_WDT + AT91_WDT_MR);
+#endif
 }
 #endif

Zixun

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

end of thread, other threads:[~2025-04-10 17:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250331191520.1805001-1-admin@hifiphile.com>
2025-03-31 19:15 ` [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct Zixun LI
2025-04-02 21:00   ` [PATCH 0/7] watchdog: at91sam9_wdt driver enhancement Zixun LI
2025-04-10 10:28   ` [PATCH 1/7] arm: at91: wdt: Remove unused at91_wdt struct Eugen Hristev
2025-04-10 16:42     ` Zixun LI
2025-03-31 19:15 ` [PATCH 2/7] arm: at91: wdt: Rename regval in priv data to mr Zixun LI
2025-03-31 19:15 ` [PATCH 3/7] watchdog: at91sam9_wdt: Rename priv to wdt Zixun LI
2025-03-31 19:15 ` [PATCH 4/7] arm: at91: wdt: Add SAM9X60 register definition Zixun LI
2025-03-31 19:15 ` [PATCH 5/7] watchdog: at91sam9_wdt: Add SAM9X60 support Zixun LI
2025-03-31 19:15 ` [PATCH 6/7] ARM: dts: sam9x60: Add watchdog DT node Zixun LI
2025-03-31 19:15 ` [PATCH 7/7] ARM: dts: at91: sam9x60-curiosity: Enable watchdog node Zixun LI

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox