Skip to contentSkip to conversation

watchdog: imx2_wdt: add support for WDOG_B signal generation

PATCH Superseded Markus Niebel 2 participants 3 messages Jul 18, 2014 – Jul 21, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 watchdog: imx2_wdt: add support for WDOG_B signal generation

From: Markus Niebel <[email protected]>

Watchdog unit of i.MX supports output of a signal at watchdog shutdown. This feature can be useful to signal an external supevisor that a watchdog reset occured. Support this feature as an option via devicetree.

---
History

v2:
Fix incorrect sent patch
- add include of.h
- fix missing if in probe

 .../devicetree/bindings/watchdog/fsl-imx-wdt.txt   |    3 +++
 drivers/watchdog/imx2_wdt.c                        |   11 +++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt +3 -0
index 2144af1..cb759cd 100644
@@ -5,6 +5,9 @@ Required properties:
 - reg : Should contain WDT registers location and length
 - interrupts : Should contain WDT interrupt
 
+Optional properties:
+- fsl,use-wre: set if watchdog reset out (WDOG_B) signal shall be asserted
+
 Examples:
 
 wdt at 73f98000 {
drivers/watchdog/imx2_wdt.c +9 -2
index 9d4874f..bde96db 100644
@@ -58,6 +58,7 @@ struct imx2_wdt_device {
 	struct regmap *regmap;
 	struct timer_list timer;	/* Pings the watchdog when closed */
 	struct watchdog_device wdog;
+	unsigned int use_wre:1;		/* enable WRE feature */
 };
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -88,7 +89,10 @@ static inline void imx2_wdt_setup(struct watchdog_device *wdog)
 	/* Strip the old watchdog Time-Out value */
 	val &= ~IMX2_WDT_WCR_WT;
 	/* Generate reset if WDOG times out */
-	val &= ~IMX2_WDT_WCR_WRE;
+	if (wdev->use_wre)
+		val |= IMX2_WDT_WCR_WRE;
+	else
+		val &= ~IMX2_WDT_WCR_WRE;
 	/* Keep Watchdog Disabled */
 	val &= ~IMX2_WDT_WCR_WDE;
 	/* Set the watchdog's Time-Out value */
@@ -219,6 +223,9 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
 		return PTR_ERR(wdev->clk);
 	}
 
+	if (of_property_read_bool(pdev->dev.of_node, "fsl,use-wre"))
+		wdev->use_wre = 1;
+
 	wdog			= &wdev->wdog;
 	wdog->info		= &imx2_wdt_info;
 	wdog->ops		= &imx2_wdt_ops;
@@ -226,7 +233,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
 	wdog->max_timeout	= IMX2_WDT_MAX_TIME;
 
 	clk_prepare_enable(wdev->clk);
-
+ 
 	regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val);
 	wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 watchdog: imx2_wdt: add support for WDOG_B signal generation

Quoted 5 lines · Markus Niebel

From: Markus Niebel <[email protected]>

Watchdog unit of i.MX supports output of a signal at watchdog shutdown. This feature can be useful to signal an external supevisor that a watchdog reset occured.

supervisor

Quoted 64 lines

Support this feature as an option via devicetree.

---
History

v2:
Fix incorrect sent patch
- add include of.h
- fix missing if in probe

 .../devicetree/bindings/watchdog/fsl-imx-wdt.txt   |    3 +++
 drivers/watchdog/imx2_wdt.c                        |   11 +++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt +3 -0
index 2144af1..cb759cd 100644
@@ -5,6 +5,9 @@ Required properties:
 - reg : Should contain WDT registers location and length
 - interrupts : Should contain WDT interrupt
 
+Optional properties:
+- fsl,use-wre: set if watchdog reset out (WDOG_B) signal shall be asserted
+
 Examples:
 
 wdt at 73f98000 {
drivers/watchdog/imx2_wdt.c +8 -1
index 9d4874f..bde96db 100644
@@ -58,6 +58,7 @@ struct imx2_wdt_device {
 	struct regmap *regmap;
 	struct timer_list timer;	/* Pings the watchdog when closed */
 	struct watchdog_device wdog;
+	unsigned int use_wre:1;		/* enable WRE feature */
 };
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -88,7 +89,10 @@ static inline void imx2_wdt_setup(struct watchdog_device *wdog)
 	/* Strip the old watchdog Time-Out value */
 	val &= ~IMX2_WDT_WCR_WT;
 	/* Generate reset if WDOG times out */
-	val &= ~IMX2_WDT_WCR_WRE;
+	if (wdev->use_wre)
+		val |= IMX2_WDT_WCR_WRE;
+	else
+		val &= ~IMX2_WDT_WCR_WRE;
 	/* Keep Watchdog Disabled */
 	val &= ~IMX2_WDT_WCR_WDE;
 	/* Set the watchdog's Time-Out value */
@@ -219,6 +223,9 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
 		return PTR_ERR(wdev->clk);
 	}
 
+	if (of_property_read_bool(pdev->dev.of_node, "fsl,use-wre"))
+		wdev->use_wre = 1;
+
 	wdog			= &wdev->wdog;
 	wdog->info		= &imx2_wdt_info;
 	wdog->ops		= &imx2_wdt_ops;

drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev) · line 236

Quoted 5 lines
drivers/watchdog/imx2_wdt.c +1 -1
@@ -226,7 +233,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
 	wdog->max_timeout	= IMX2_WDT_MAX_TIME;
 
 	clk_prepare_enable(wdev->clk);
-
+ 

Don't add a space here.

Did you check that this feature works on all cpus that use this driver? On which of them did you test your change?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw

PATCH v2 1/1 watchdog: imx2_wdt: add support for WDOG_B signal generation

Am 21.07.2014 08:30, wrote Uwe Kleine-K?nig:

Quoted 36 lines · Markus Niebel
Quoted 5 lines

From: Markus Niebel <[email protected]>

Watchdog unit of i.MX supports output of a signal at watchdog shutdown. This feature can be useful to signal an external supevisor that a watchdog reset occured.

supervisor

Quoted 28 lines

Support this feature as an option via devicetree.

---
History

v2:
Fix incorrect sent patch
- add include of.h
- fix missing if in probe

 .../devicetree/bindings/watchdog/fsl-imx-wdt.txt   |    3 +++
 drivers/watchdog/imx2_wdt.c                        |   11 +++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt +3 -0
index 2144af1..cb759cd 100644
@@ -5,6 +5,9 @@ Required properties:
 - reg : Should contain WDT registers location and length
 - interrupts : Should contain WDT interrupt
 
+Optional properties:
+- fsl,use-wre: set if watchdog reset out (WDOG_B) signal shall be asserted
+
 Examples:
 
Quoted 5 lines

drivers/watchdog/imx2_wdt.c

Quoted 5 lines
Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt +0 -0
 wdt at 73f98000 {
drivers/watchdog/imx2_wdt.c +0 -0
index 9d4874f..bde96db 100644

#include linux/of.h is missing here ...

Quoted 33 lines
Quoted 33 lines
drivers/watchdog/imx2_wdt.c +8 -1
@@ -58,6 +58,7 @@ struct imx2_wdt_device {
 	struct regmap *regmap;
 	struct timer_list timer;	/* Pings the watchdog when closed */
 	struct watchdog_device wdog;
+	unsigned int use_wre:1;		/* enable WRE feature */
 };
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -88,7 +89,10 @@ static inline void imx2_wdt_setup(struct watchdog_device *wdog)
 	/* Strip the old watchdog Time-Out value */
 	val &= ~IMX2_WDT_WCR_WT;
 	/* Generate reset if WDOG times out */
-	val &= ~IMX2_WDT_WCR_WRE;
+	if (wdev->use_wre)
+		val |= IMX2_WDT_WCR_WRE;
+	else
+		val &= ~IMX2_WDT_WCR_WRE;
 	/* Keep Watchdog Disabled */
 	val &= ~IMX2_WDT_WCR_WDE;
 	/* Set the watchdog's Time-Out value */
@@ -219,6 +223,9 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
 		return PTR_ERR(wdev->clk);
 	}
 
+	if (of_property_read_bool(pdev->dev.of_node, "fsl,use-wre"))
+		wdev->use_wre = 1;
+
 	wdog			= &wdev->wdog;
 	wdog->info		= &imx2_wdt_info;
 	wdog->ops		= &imx2_wdt_ops;
@@ -226,7 +233,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
 	wdog->max_timeout	= IMX2_WDT_MAX_TIME;
 
Quoted 4 lines

drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev) · line 236

Quoted 3 lines
drivers/watchdog/imx2_wdt.c +1 -1
 	clk_prepare_enable(wdev->clk);
-
+ 

Don't add a space here.

Oops

Quoted 4 lines

Did you check that this feature works on all cpus that use this driver? On which of them did you test your change?

We tested with i.MX6Q and i.MX6DL. Reading the RM at least i.MX25, i.MX35 and i.MX53 should implement the same behaviour. But you are right - the i.MX21 is slighly different.

Will prepare v3 after my holiday with
- work out SOC differences
- add missing include
- extended binding docu
- fix whitespace error

Quoted 3 lines

Best regards
Uwe

Best Regards

Markus