Skip to contentSkip to conversation

watchdog: aspeed: Add aspeed,reset-mask property

PATCH In review Zev Weiss 2 participants 4 messages Nov 10, 2023

Subsystems (3)
lore
Share & tools
lore

Zev Weiss

author
#0 lore raw

cover watchdog: aspeed: Add aspeed,reset-mask property

Hello,

This series is a backport of a couple patches (now merged upstream, review discussion here: [1]) adding support for controlling what Aspeed SOC peripherals get resets by the watchdog timer.

Thanks,
Zev

[1] https://lore.kernel.org/lkml/[email protected]/

Zev Weiss (2):
dt-bindings: watchdog: aspeed-wdt: Add aspeed,reset-mask property
watchdog: aspeed: Add support for aspeed,reset-mask DT property

 .../bindings/watchdog/aspeed-wdt.txt          | 18 +++-
 drivers/watchdog/aspeed_wdt.c                 | 11 +++
 include/dt-bindings/watchdog/aspeed-wdt.h     | 92 +++++++++++++++++++
 3 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/watchdog/aspeed-wdt.h
Signature · 1 line
2.42.0
author
#1 lore raw

PATCH 1/2 dt-bindings: watchdog: aspeed-wdt: Add aspeed,reset-mask property

This property configures the Aspeed watchdog timer's reset mask, which controls which peripherals are reset when the watchdog timer expires. Some platforms require that certain devices be left untouched across a reboot; aspeed,reset-mask can now be used to express such constraints.

---
 .../bindings/watchdog/aspeed-wdt.txt          | 18 +++-
 include/dt-bindings/watchdog/aspeed-wdt.h     | 92 +++++++++++++++++++
 2 files changed, 109 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/watchdog/aspeed-wdt.h
Documentation/devicetree/bindings/watchdog/aspeed-wdt.txt +17 -1
index a8197632d6d2..3208adb3e52e 100644
@@ -47,7 +47,15 @@ Optional properties for AST2500-compatible watchdogs:
 			   is configured as push-pull, then set the pulse
 			   polarity to active-high. The default is active-low.
 
-Example:
+Optional properties for AST2500- and AST2600-compatible watchdogs:
+ - aspeed,reset-mask: A bitmask indicating which peripherals will be reset if
+		      the watchdog timer expires.  On AST2500 this should be a
+		      single word defined using the AST2500_WDT_RESET_* macros;
+		      on AST2600 this should be a two-word array with the first
+		      word defined using the AST2600_WDT_RESET1_* macros and the
+		      second word defined using the AST2600_WDT_RESET2_* macros.
+
+Examples:
 
 	wdt1: watchdog@1e785000 {
 		compatible = "aspeed,ast2400-wdt";
@@ -55,3 +63,11 @@ Example:
 		aspeed,reset-type = "system";
 		aspeed,external-signal;
 	};
+
+	#include <dt-bindings/watchdog/aspeed-wdt.h>
+	wdt2: watchdog@1e785040 {
+		compatible = "aspeed,ast2600-wdt";
+		reg = <0x1e785040 0x40>;
+		aspeed,reset-mask = <AST2600_WDT_RESET1_DEFAULT
+				     (AST2600_WDT_RESET2_DEFAULT & ~AST2600_WDT_RESET2_LPC)>;
+	};
include/dt-bindings/watchdog/aspeed-wdt.h new file +92 -0

92 lines not on this page · raw message

Signature · 1 line
2.42.0
author
#2 lore raw

PATCH 2/2 watchdog: aspeed: Add support for aspeed,reset-mask DT property

In reply to Zev Weiss

This property allows the device-tree to specify how the Aspeed watchdog timer's reset mask register(s) should be set, so that peripherals can be individually exempted from (or opted in to) being reset when the watchdog timer expires.

---
 drivers/watchdog/aspeed_wdt.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/watchdog/aspeed_wdt.c +11 -0
index b72a858bbac7..b4773a6aaf8c 100644
@@ -79,6 +79,8 @@ MODULE_DEVICE_TABLE(of, aspeed_wdt_of_table);
 #define   WDT_TIMEOUT_STATUS_BOOT_SECONDARY	BIT(1)
 #define WDT_CLEAR_TIMEOUT_STATUS	0x14
 #define   WDT_CLEAR_TIMEOUT_AND_BOOT_CODE_SELECTION	BIT(0)
+#define WDT_RESET_MASK1		0x1c
+#define WDT_RESET_MASK2		0x20
 
 /*
  * WDT_RESET_WIDTH controls the characteristics of the external pulse (if
@@ -402,6 +404,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
 
 	if ((of_device_is_compatible(np, "aspeed,ast2500-wdt")) ||
 		(of_device_is_compatible(np, "aspeed,ast2600-wdt"))) {
+		u32 reset_mask[2];
+		size_t nrstmask = of_device_is_compatible(np, "aspeed,ast2600-wdt") ? 2 : 1;
 		u32 reg = readl(wdt->base + WDT_RESET_WIDTH);
 
 		reg &= wdt->cfg->ext_pulse_width_mask;
@@ -419,6 +423,13 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
 			reg |= WDT_OPEN_DRAIN_MAGIC;
 
 		writel(reg, wdt->base + WDT_RESET_WIDTH);
+
+		ret = of_property_read_u32_array(np, "aspeed,reset-mask", reset_mask, nrstmask);
+		if (!ret) {
+			writel(reset_mask[0], wdt->base + WDT_RESET_MASK1);
+			if (nrstmask > 1)
+				writel(reset_mask[1], wdt->base + WDT_RESET_MASK2);
+		}
 	}
 
 	if (!of_property_read_u32(np, "aspeed,ext-pulse-duration", &duration)) {
Signature · 1 line
2.42.0
maintainer
#3 lore raw
In reply to Zev Weiss
Quoted 6 lines · Zev Weiss

Hello,

This series is a backport of a couple patches (now merged upstream, review discussion here: [1]) adding support for controlling what Aspeed SOC peripherals get resets by the watchdog timer.

Thanks Zev, good work as always. These have been merged.

Cheers,

Joel