* [PATCH 0/3] watchdog: dw_wdt: add reset lines
@ 2016-09-22 7:02 Steffen Trumtrar
2016-09-22 7:02 ` [PATCH 1/3] watchdog: bindings: " Steffen Trumtrar
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Steffen Trumtrar @ 2016-09-22 7:02 UTC (permalink / raw)
To: linux-watchdog; +Cc: kernel, Steffen Trumtrar, devicetree, linux-kernel
Hi!
This series adds support for the reset line that is
(potentially) holding the watchdog in reset.
As the watchdog is useless if this happens, it needs to be deasserted
in the probe function.
Additionally, the reset is the only way of stopping a once started watchdog.
This was previously not supported, so add the stop operation to the watchdog ops.
Tested on the SoCFPGA platform.
Regards,
Steffen
Steffen Trumtrar (3):
watchdog: bindings: dw_wdt: add reset lines
watchdog: dw_wdt: get reset lines from dt
watchdog: dw_wdt: add stop watchdog operation
.../devicetree/bindings/watchdog/dw_wdt.txt | 5 +++++
drivers/watchdog/dw_wdt.c | 25 ++++++++++++++++++++++
2 files changed, 30 insertions(+)
--
2.8.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] watchdog: bindings: dw_wdt: add reset lines
2016-09-22 7:02 [PATCH 0/3] watchdog: dw_wdt: add reset lines Steffen Trumtrar
@ 2016-09-22 7:02 ` Steffen Trumtrar
2016-09-23 19:59 ` Rob Herring
2016-09-22 7:02 ` [PATCH 2/3] watchdog: dw_wdt: get reset lines from dt Steffen Trumtrar
2016-09-22 7:02 ` [PATCH 3/3] watchdog: dw_wdt: add stop watchdog operation Steffen Trumtrar
2 siblings, 1 reply; 7+ messages in thread
From: Steffen Trumtrar @ 2016-09-22 7:02 UTC (permalink / raw)
To: linux-watchdog
Cc: kernel, Steffen Trumtrar, Wim Van Sebroeck, Rob Herring,
Mark Rutland, devicetree, Guenter Roeck, linux-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@vger.kernel.org
Cc: devicetree@vger.kernel.org
---
Documentation/devicetree/bindings/watchdog/dw_wdt.txt | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/watchdog/dw_wdt.txt b/Documentation/devicetree/bindings/watchdog/dw_wdt.txt
index 08e16f684f2d..3bf386c72241 100644
--- a/Documentation/devicetree/bindings/watchdog/dw_wdt.txt
+++ b/Documentation/devicetree/bindings/watchdog/dw_wdt.txt
@@ -10,6 +10,9 @@ 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.
+- reset-names : must be set to "dw-wdt".
Example:
@@ -18,4 +21,6 @@ Example:
reg = <0xffd02000 0x1000>;
interrupts = <0 171 4>;
clocks = <&per_base_clk>;
+ resets = <&rst WDT0_RESET>;
+ reset-names = "dw-wdt";
};
--
2.8.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] watchdog: dw_wdt: get reset lines from dt
2016-09-22 7:02 [PATCH 0/3] watchdog: dw_wdt: add reset lines Steffen Trumtrar
2016-09-22 7:02 ` [PATCH 1/3] watchdog: bindings: " Steffen Trumtrar
@ 2016-09-22 7:02 ` Steffen Trumtrar
2016-09-22 13:14 ` Guenter Roeck
2016-09-22 7:02 ` [PATCH 3/3] watchdog: dw_wdt: add stop watchdog operation Steffen Trumtrar
2 siblings, 1 reply; 7+ messages in thread
From: Steffen Trumtrar @ 2016-09-22 7:02 UTC (permalink / raw)
To: linux-watchdog
Cc: kernel, Steffen Trumtrar, Wim Van Sebroeck, Guenter Roeck,
linux-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@vger.kernel.org
---
drivers/watchdog/dw_wdt.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index 2acb51cf5504..e024722e8b3b 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -31,6 +31,7 @@
#include <linux/pm.h>
#include <linux/platform_device.h>
#include <linux/reboot.h>
+#include <linux/reset.h>
#include <linux/watchdog.h>
#define WDOG_CONTROL_REG_OFFSET 0x00
@@ -56,6 +57,7 @@ struct dw_wdt {
struct clk *clk;
struct notifier_block restart_handler;
struct watchdog_device wdd;
+ struct reset_control *rst;
};
#define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd)
@@ -231,6 +233,10 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
if (ret)
return ret;
+ dw_wdt->rst = devm_reset_control_get(&pdev->dev, "dw-wdt");
+ if (IS_ERR(dw_wdt->rst))
+ dev_warn(dev, "No reset lines. Will not be able to stop once started.\n");
+
wdd = &dw_wdt->wdd;
wdd->info = &dw_wdt_ident;
wdd->ops = &dw_wdt_ops;
@@ -268,6 +274,9 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
if (ret)
pr_warn("cannot register restart handler\n");
+ if (dw_wdt->rst)
+ reset_control_deassert(dw_wdt->rst);
+
return 0;
out_disable_clk:
--
2.8.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] watchdog: dw_wdt: add stop watchdog operation
2016-09-22 7:02 [PATCH 0/3] watchdog: dw_wdt: add reset lines Steffen Trumtrar
2016-09-22 7:02 ` [PATCH 1/3] watchdog: bindings: " Steffen Trumtrar
2016-09-22 7:02 ` [PATCH 2/3] watchdog: dw_wdt: get reset lines from dt Steffen Trumtrar
@ 2016-09-22 7:02 ` Steffen Trumtrar
2016-09-22 13:20 ` Guenter Roeck
2 siblings, 1 reply; 7+ messages in thread
From: Steffen Trumtrar @ 2016-09-22 7:02 UTC (permalink / raw)
To: linux-watchdog
Cc: kernel, Steffen Trumtrar, Wim Van Sebroeck, Guenter Roeck,
linux-kernel
The only way of stopping the watchdog is by resetting it.
Add the watchdog op for stopping the device and reset if
a reset line is provided.
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@vger.kernel.org
---
drivers/watchdog/dw_wdt.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index e024722e8b3b..5b067984d5e8 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -137,6 +137,21 @@ static int dw_wdt_start(struct watchdog_device *wdd)
return 0;
}
+static int dw_wdt_stop(struct watchdog_device *wdd)
+{
+ struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
+
+ if (IS_ERR(dw_wdt->rst)) {
+ dev_warn(wdd->parent, "No reset line. Will not stop.\n");
+ return PTR_ERR(dw_wdt->rst);
+ }
+
+ reset_control_assert(dw_wdt->rst);
+ reset_control_deassert(dw_wdt->rst);
+
+ return 0;
+}
+
static int dw_wdt_restart_handle(struct notifier_block *this,
unsigned long mode, void *cmd)
{
@@ -177,6 +192,7 @@ static const struct watchdog_info dw_wdt_ident = {
static const struct watchdog_ops dw_wdt_ops = {
.owner = THIS_MODULE,
.start = dw_wdt_start,
+ .stop = dw_wdt_stop,
.ping = dw_wdt_ping,
.set_timeout = dw_wdt_set_timeout,
.get_timeleft = dw_wdt_get_timeleft,
--
2.8.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] watchdog: dw_wdt: get reset lines from dt
2016-09-22 7:02 ` [PATCH 2/3] watchdog: dw_wdt: get reset lines from dt Steffen Trumtrar
@ 2016-09-22 13:14 ` Guenter Roeck
0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2016-09-22 13:14 UTC (permalink / raw)
To: Steffen Trumtrar, linux-watchdog; +Cc: kernel, Wim Van Sebroeck, linux-kernel
On 09/22/2016 12:02 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@vger.kernel.org
> ---
> drivers/watchdog/dw_wdt.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
> index 2acb51cf5504..e024722e8b3b 100644
> --- a/drivers/watchdog/dw_wdt.c
> +++ b/drivers/watchdog/dw_wdt.c
> @@ -31,6 +31,7 @@
> #include <linux/pm.h>
> #include <linux/platform_device.h>
> #include <linux/reboot.h>
> +#include <linux/reset.h>
> #include <linux/watchdog.h>
>
> #define WDOG_CONTROL_REG_OFFSET 0x00
> @@ -56,6 +57,7 @@ struct dw_wdt {
> struct clk *clk;
> struct notifier_block restart_handler;
> struct watchdog_device wdd;
> + struct reset_control *rst;
> };
>
> #define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd)
> @@ -231,6 +233,10 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> + dw_wdt->rst = devm_reset_control_get(&pdev->dev, "dw-wdt");
> + if (IS_ERR(dw_wdt->rst))
> + dev_warn(dev, "No reset lines. Will not be able to stop once started.\n");
This situation is already handled by the driver. Actually, I don't even
know what will happen, since the watchdog core will continue to ping
the watchdog after close, and it won't be possible to unload the driver
if the watchdog is running.
I don't think a warning is warranted in this case. We did not need one before,
we should not need one now.
> +
> wdd = &dw_wdt->wdd;
> wdd->info = &dw_wdt_ident;
> wdd->ops = &dw_wdt_ops;
> @@ -268,6 +274,9 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
> if (ret)
> pr_warn("cannot register restart handler\n");
>
> + if (dw_wdt->rst)
> + reset_control_deassert(dw_wdt->rst);
> +
> return 0;
>
> out_disable_clk:
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] watchdog: dw_wdt: add stop watchdog operation
2016-09-22 7:02 ` [PATCH 3/3] watchdog: dw_wdt: add stop watchdog operation Steffen Trumtrar
@ 2016-09-22 13:20 ` Guenter Roeck
0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2016-09-22 13:20 UTC (permalink / raw)
To: Steffen Trumtrar, linux-watchdog; +Cc: kernel, Wim Van Sebroeck, linux-kernel
On 09/22/2016 12:02 AM, Steffen Trumtrar wrote:
> The only way of stopping the watchdog is by resetting it.
> Add the watchdog op for stopping the device and reset if
> a reset line is provided.
>
> 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@vger.kernel.org
> ---
> drivers/watchdog/dw_wdt.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
> index e024722e8b3b..5b067984d5e8 100644
> --- a/drivers/watchdog/dw_wdt.c
> +++ b/drivers/watchdog/dw_wdt.c
> @@ -137,6 +137,21 @@ static int dw_wdt_start(struct watchdog_device *wdd)
> return 0;
> }
>
> +static int dw_wdt_stop(struct watchdog_device *wdd)
> +{
> + struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
> +
> + if (IS_ERR(dw_wdt->rst)) {
> + dev_warn(wdd->parent, "No reset line. Will not stop.\n");
As mentioned in the other patch, this warning is not warranted.
Also, you'll need to inform the watchdog core that the watchdog is still
running, otherwise the system _will_ reset. That would be a definite
and unwanted change in behavior.
> + return PTR_ERR(dw_wdt->rst);
This is not an error. The code handled that situation before without
reporting an error, it can handle it now.
> + }
> +
> + reset_control_assert(dw_wdt->rst);
> + reset_control_deassert(dw_wdt->rst);
> +
> + return 0;
> +}
> +
> static int dw_wdt_restart_handle(struct notifier_block *this,
> unsigned long mode, void *cmd)
> {
> @@ -177,6 +192,7 @@ static const struct watchdog_info dw_wdt_ident = {
> static const struct watchdog_ops dw_wdt_ops = {
> .owner = THIS_MODULE,
> .start = dw_wdt_start,
> + .stop = dw_wdt_stop,
> .ping = dw_wdt_ping,
> .set_timeout = dw_wdt_set_timeout,
> .get_timeleft = dw_wdt_get_timeleft,
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] watchdog: bindings: dw_wdt: add reset lines
2016-09-22 7:02 ` [PATCH 1/3] watchdog: bindings: " Steffen Trumtrar
@ 2016-09-23 19:59 ` Rob Herring
0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2016-09-23 19:59 UTC (permalink / raw)
To: Steffen Trumtrar
Cc: linux-watchdog, kernel, Wim Van Sebroeck, Mark Rutland,
devicetree, Guenter Roeck, linux-kernel
On Thu, Sep 22, 2016 at 09:02:30AM +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@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> ---
> Documentation/devicetree/bindings/watchdog/dw_wdt.txt | 5 +++++
> 1 file changed, 5 insertions(+)
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-09-23 19:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-22 7:02 [PATCH 0/3] watchdog: dw_wdt: add reset lines Steffen Trumtrar
2016-09-22 7:02 ` [PATCH 1/3] watchdog: bindings: " Steffen Trumtrar
2016-09-23 19:59 ` Rob Herring
2016-09-22 7:02 ` [PATCH 2/3] watchdog: dw_wdt: get reset lines from dt Steffen Trumtrar
2016-09-22 13:14 ` Guenter Roeck
2016-09-22 7:02 ` [PATCH 3/3] watchdog: dw_wdt: add stop watchdog operation Steffen Trumtrar
2016-09-22 13:20 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox