linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] watchdog: bindings: dw_wdt: add reset lines
       [not found] <cover.e174fd0fa926fadf54e0f76e07f238bed3e162fc.1494595189.git-series.s.trumtrar@pengutronix.de>
@ 2017-05-12 13:34 ` Steffen Trumtrar
  2017-05-12 13:34   ` [PATCH v2 2/3] watchdog: dw_wdt: get reset lines from dt Steffen Trumtrar
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Steffen Trumtrar @ 2017-05-12 13:34 UTC (permalink / raw)
  To: linux-arm-kernel

Document the reset lines holding the watchdog core in reset.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Cc: Wim Van Sebroeck <wim@iguana.be>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-watchdog at vger.kernel.org
Cc: devicetree at vger.kernel.org
---
 Documentation/devicetree/bindings/watchdog/dw_wdt.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/watchdog/dw_wdt.txt b/Documentation/devicetree/bindings/watchdog/dw_wdt.txt
index 08e16f684f2d..eb0914420c7c 100644
--- a/Documentation/devicetree/bindings/watchdog/dw_wdt.txt
+++ b/Documentation/devicetree/bindings/watchdog/dw_wdt.txt
@@ -10,6 +10,8 @@ Required Properties:
 Optional Properties:
 
 - interrupts	: The interrupt used for the watchdog timeout warning.
+- resets	: phandle pointing to the system reset controller with
+		line index for the watchdog.
 
 Example:
 
@@ -18,4 +20,5 @@ Example:
 		reg = <0xffd02000 0x1000>;
 		interrupts = <0 171 4>;
 		clocks = <&per_base_clk>;
+		resets = <&rst WDT0_RESET>;
 	};
-- 
git-series 0.9.1

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

* [PATCH v2 2/3] watchdog: dw_wdt: get reset lines from dt
  2017-05-12 13:34 ` [PATCH v2 1/3] watchdog: bindings: dw_wdt: add reset lines Steffen Trumtrar
@ 2017-05-12 13:34   ` Steffen Trumtrar
  2017-05-14 14:33     ` Guenter Roeck
  2017-05-17  7:32     ` Philipp Zabel
  2017-05-12 13:34   ` [PATCH v2 3/3] ARM: socfpga: dtsi: add dw-wdt reset lines Steffen Trumtrar
  2017-05-15 21:44   ` [PATCH v2 1/3] watchdog: bindings: dw_wdt: add " Rob Herring
  2 siblings, 2 replies; 6+ messages in thread
From: Steffen Trumtrar @ 2017-05-12 13:34 UTC (permalink / raw)
  To: linux-arm-kernel

The dw_wdt has an external reset line, that can keep the device in reset
and therefore rendering it useless and also is the only way of stopping
the watchdog once it was started.

Get the reset lines for this core from the devicetree.
If resets are not specified just warn but don't fail probing to be compatible
with all users.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Cc: Wim Van Sebroeck <wim@iguana.be>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-watchdog at vger.kernel.org
---
 drivers/watchdog/dw_wdt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index 914da3a4d334..3accddf1f381 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -29,6 +29,7 @@
 #include <linux/of.h>
 #include <linux/pm.h>
 #include <linux/platform_device.h>
+#include <linux/reset.h>
 #include <linux/watchdog.h>
 
 #define WDOG_CONTROL_REG_OFFSET		    0x00
@@ -54,6 +55,7 @@ struct dw_wdt {
 	struct clk		*clk;
 	unsigned long		rate;
 	struct watchdog_device	wdd;
+	struct reset_control	*rst;
 };
 
 #define to_dw_wdt(wdd)	container_of(wdd, struct dw_wdt, wdd)
@@ -234,6 +236,8 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 		goto out_disable_clk;
 	}
 
+	dw_wdt->rst = devm_reset_control_get(&pdev->dev, NULL);
+
 	wdd = &dw_wdt->wdd;
 	wdd->info = &dw_wdt_ident;
 	wdd->ops = &dw_wdt_ops;
@@ -267,6 +271,9 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 	if (ret)
 		goto out_disable_clk;
 
+	if (dw_wdt->rst)
+		reset_control_deassert(dw_wdt->rst);
+
 	return 0;
 
 out_disable_clk:
-- 
git-series 0.9.1

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

* [PATCH v2 3/3] ARM: socfpga: dtsi: add dw-wdt reset lines
  2017-05-12 13:34 ` [PATCH v2 1/3] watchdog: bindings: dw_wdt: add reset lines Steffen Trumtrar
  2017-05-12 13:34   ` [PATCH v2 2/3] watchdog: dw_wdt: get reset lines from dt Steffen Trumtrar
@ 2017-05-12 13:34   ` Steffen Trumtrar
  2017-05-15 21:44   ` [PATCH v2 1/3] watchdog: bindings: dw_wdt: add " Rob Herring
  2 siblings, 0 replies; 6+ messages in thread
From: Steffen Trumtrar @ 2017-05-12 13:34 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
Cc: linux-arm-kernel at lists.infradead.org
---
 arch/arm/boot/dts/socfpga.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
index 2c43c4d85dee..bd976cfc3b07 100644
--- a/arch/arm/boot/dts/socfpga.dtsi
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -916,6 +916,7 @@
 			reg = <0xffd02000 0x1000>;
 			interrupts = <0 171 4>;
 			clocks = <&osc1>;
+			resets = <&rst L4WD0_RESET>;
 			status = "disabled";
 		};
 
@@ -924,6 +925,7 @@
 			reg = <0xffd03000 0x1000>;
 			interrupts = <0 172 4>;
 			clocks = <&osc1>;
+			resets = <&rst L4WD1_RESET>;
 			status = "disabled";
 		};
 	};
-- 
git-series 0.9.1

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

* [PATCH v2 2/3] watchdog: dw_wdt: get reset lines from dt
  2017-05-12 13:34   ` [PATCH v2 2/3] watchdog: dw_wdt: get reset lines from dt Steffen Trumtrar
@ 2017-05-14 14:33     ` Guenter Roeck
  2017-05-17  7:32     ` Philipp Zabel
  1 sibling, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2017-05-14 14:33 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/12/2017 06:34 AM, Steffen Trumtrar wrote:
> The dw_wdt has an external reset line, that can keep the device in reset
> and therefore rendering it useless and also is the only way of stopping
> the watchdog once it was started.
>
> Get the reset lines for this core from the devicetree.
> If resets are not specified just warn but don't fail probing to be compatible
> with all users.
>
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> Cc: Wim Van Sebroeck <wim@iguana.be>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: linux-watchdog at vger.kernel.org
> ---
>  drivers/watchdog/dw_wdt.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
> index 914da3a4d334..3accddf1f381 100644
> --- a/drivers/watchdog/dw_wdt.c
> +++ b/drivers/watchdog/dw_wdt.c
> @@ -29,6 +29,7 @@
>  #include <linux/of.h>
>  #include <linux/pm.h>
>  #include <linux/platform_device.h>
> +#include <linux/reset.h>
>  #include <linux/watchdog.h>
>
>  #define WDOG_CONTROL_REG_OFFSET		    0x00
> @@ -54,6 +55,7 @@ struct dw_wdt {
>  	struct clk		*clk;
>  	unsigned long		rate;
>  	struct watchdog_device	wdd;
> +	struct reset_control	*rst;
>  };
>
>  #define to_dw_wdt(wdd)	container_of(wdd, struct dw_wdt, wdd)
> @@ -234,6 +236,8 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
>  		goto out_disable_clk;
>  	}
>
> +	dw_wdt->rst = devm_reset_control_get(&pdev->dev, NULL);
> +

devm_reset_control_get() does not return NULL, it returns ERR_PTR on error.

>  	wdd = &dw_wdt->wdd;
>  	wdd->info = &dw_wdt_ident;
>  	wdd->ops = &dw_wdt_ops;
> @@ -267,6 +271,9 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto out_disable_clk;
>
> +	if (dw_wdt->rst)
> +		reset_control_deassert(dw_wdt->rst);

Granted, this doesn't cause a crash here, but a warning with traceback.
Either case, the if() statement misses the point.

> +
>  	return 0;
>
>  out_disable_clk:
>

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

* [PATCH v2 1/3] watchdog: bindings: dw_wdt: add reset lines
  2017-05-12 13:34 ` [PATCH v2 1/3] watchdog: bindings: dw_wdt: add reset lines Steffen Trumtrar
  2017-05-12 13:34   ` [PATCH v2 2/3] watchdog: dw_wdt: get reset lines from dt Steffen Trumtrar
  2017-05-12 13:34   ` [PATCH v2 3/3] ARM: socfpga: dtsi: add dw-wdt reset lines Steffen Trumtrar
@ 2017-05-15 21:44   ` Rob Herring
  2 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2017-05-15 21:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, May 12, 2017 at 03:34:35PM +0200, Steffen Trumtrar wrote:
> Document the reset lines holding the watchdog core in reset.
> 
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> Cc: Wim Van Sebroeck <wim@iguana.be>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: linux-watchdog at vger.kernel.org
> Cc: devicetree at vger.kernel.org
> ---
>  Documentation/devicetree/bindings/watchdog/dw_wdt.txt | 3 +++
>  1 file changed, 3 insertions(+)

Acked-by: Rob Herring <robh@kernel.org>

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

* [PATCH v2 2/3] watchdog: dw_wdt: get reset lines from dt
  2017-05-12 13:34   ` [PATCH v2 2/3] watchdog: dw_wdt: get reset lines from dt Steffen Trumtrar
  2017-05-14 14:33     ` Guenter Roeck
@ 2017-05-17  7:32     ` Philipp Zabel
  1 sibling, 0 replies; 6+ messages in thread
From: Philipp Zabel @ 2017-05-17  7:32 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Steffen,

On Fri, 2017-05-12 at 15:34 +0200, Steffen Trumtrar wrote:
> The dw_wdt has an external reset line, that can keep the device in reset
> and therefore rendering it useless and also is the only way of stopping
> the watchdog once it was started.
> 
> Get the reset lines for this core from the devicetree.
> If resets are not specified just warn but don't fail probing to be compatible
> with all users.
> 
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> Cc: Wim Van Sebroeck <wim@iguana.be>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: linux-watchdog at vger.kernel.org
> ---
>  drivers/watchdog/dw_wdt.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
> index 914da3a4d334..3accddf1f381 100644
> --- a/drivers/watchdog/dw_wdt.c
> +++ b/drivers/watchdog/dw_wdt.c
> @@ -29,6 +29,7 @@
>  #include <linux/of.h>
>  #include <linux/pm.h>
>  #include <linux/platform_device.h>
> +#include <linux/reset.h>
>  #include <linux/watchdog.h>
>  
>  #define WDOG_CONTROL_REG_OFFSET		    0x00
> @@ -54,6 +55,7 @@ struct dw_wdt {
>  	struct clk		*clk;
>  	unsigned long		rate;
>  	struct watchdog_device	wdd;
> +	struct reset_control	*rst;
>  };
>  
>  #define to_dw_wdt(wdd)	container_of(wdd, struct dw_wdt, wdd)
> @@ -234,6 +236,8 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
>  		goto out_disable_clk;
>  	}
>  
> +	dw_wdt->rst = devm_reset_control_get(&pdev->dev, NULL);
> +

This should be
	dw_wdt->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
	if (IS_ERR(dw_wdt->rst))
		return PTR_ERR(dw_wdt->rst);
The optional variants return NULL if the reset is not specified in the
DT.

>  	wdd = &dw_wdt->wdd;
>  	wdd->info = &dw_wdt_ident;
>  	wdd->ops = &dw_wdt_ops;
> @@ -267,6 +271,9 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto out_disable_clk;
>  
> +	if (dw_wdt->rst)
> +		reset_control_deassert(dw_wdt->rst);
> +

This can be changed to
	reset_control_deassert(dw_wdt->rst);

>  	return 0;
>  
>  out_disable_clk:

Consider adding a call to reset_control_assert() in dw_wdt_drv_remove.

regards
Philipp

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

end of thread, other threads:[~2017-05-17  7:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.e174fd0fa926fadf54e0f76e07f238bed3e162fc.1494595189.git-series.s.trumtrar@pengutronix.de>
2017-05-12 13:34 ` [PATCH v2 1/3] watchdog: bindings: dw_wdt: add reset lines Steffen Trumtrar
2017-05-12 13:34   ` [PATCH v2 2/3] watchdog: dw_wdt: get reset lines from dt Steffen Trumtrar
2017-05-14 14:33     ` Guenter Roeck
2017-05-17  7:32     ` Philipp Zabel
2017-05-12 13:34   ` [PATCH v2 3/3] ARM: socfpga: dtsi: add dw-wdt reset lines Steffen Trumtrar
2017-05-15 21:44   ` [PATCH v2 1/3] watchdog: bindings: dw_wdt: add " Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).