From: linux@roeck-us.net (Guenter Roeck)
To: linux-arm-kernel@lists.infradead.org
Subject: [3/5,v2] watchdog: ftwdt010: Make interrupt optional
Date: Sun, 22 Oct 2017 10:19:54 -0700 [thread overview]
Message-ID: <20171022171954.GA17141@roeck-us.net> (raw)
In-Reply-To: <20171016205427.4297-3-linus.walleij@linaro.org>
On Mon, Oct 16, 2017 at 10:54:25PM +0200, Linus Walleij wrote:
> The Moxart does not appear to be using the interrupt from the
> watchdog timer, maybe it's not even routed, so as to support
> more architectures with this driver, make the interrupt
> optional.
>
> While we are at it: actually enable the use of the interrupt
> if present by setting the right bit in the control register
> and define the missing control register bits.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> ChangeLog v1->v2:
> - Fix surplus flag assignment of enable |= WDCR_CLOCK_5MHZ
> ---
> drivers/watchdog/ftwdt010_wdt.c | 30 ++++++++++++++++++------------
> 1 file changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c
> index 637ffd812f0b..a9c2912ee280 100644
> --- a/drivers/watchdog/ftwdt010_wdt.c
> +++ b/drivers/watchdog/ftwdt010_wdt.c
> @@ -30,6 +30,8 @@
> #define WDRESTART_MAGIC 0x5AB9
>
> #define WDCR_CLOCK_5MHZ BIT(4)
> +#define WDCR_WDEXT BIT(3)
> +#define WDCR_WDINTR BIT(2)
> #define WDCR_SYS_RST BIT(1)
> #define WDCR_ENABLE BIT(0)
>
> @@ -39,6 +41,7 @@ struct ftwdt010_wdt {
> struct watchdog_device wdd;
> struct device *dev;
> void __iomem *base;
> + bool has_irq;
> };
>
> static inline
> @@ -50,14 +53,17 @@ struct ftwdt010_wdt *to_ftwdt010_wdt(struct watchdog_device *wdd)
> static int ftwdt010_wdt_start(struct watchdog_device *wdd)
> {
> struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd);
> + u32 enable;
>
> writel(wdd->timeout * WDT_CLOCK, gwdt->base + FTWDT010_WDLOAD);
> writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART);
> /* set clock before enabling */
> - writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST,
> - gwdt->base + FTWDT010_WDCR);
> - writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST | WDCR_ENABLE,
> - gwdt->base + FTWDT010_WDCR);
> + enable = WDCR_CLOCK_5MHZ | WDCR_SYS_RST;
> + writel(enable, gwdt->base + FTWDT010_WDCR);
> + if (gwdt->has_irq)
> + enable |= WDCR_WDINTR;
> + enable |= WDCR_ENABLE;
> + writel(enable, gwdt->base + FTWDT010_WDCR);
>
> return 0;
> }
> @@ -133,10 +139,6 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev)
> if (IS_ERR(gwdt->base))
> return PTR_ERR(gwdt->base);
>
> - irq = platform_get_irq(pdev, 0);
> - if (!irq)
> - return -EINVAL;
> -
> gwdt->dev = dev;
> gwdt->wdd.info = &ftwdt010_wdt_info;
> gwdt->wdd.ops = &ftwdt010_wdt_ops;
> @@ -158,10 +160,14 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev)
> writel(reg, gwdt->base + FTWDT010_WDCR);
> }
>
> - ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0,
> - "watchdog bark", gwdt);
> - if (ret)
> - return ret;
> + irq = platform_get_irq(pdev, 0);
> + if (irq) {
> + ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0,
> + "watchdog bark", gwdt);
> + if (ret)
> + return ret;
> + gwdt->has_irq = true;
> + }
>
> ret = devm_watchdog_register_device(dev, &gwdt->wdd);
> if (ret) {
next prev parent reply other threads:[~2017-10-22 17:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 20:54 [PATCH 1/5 v2] watchdog: gemini/ftwdt010: rename DT bindings Linus Walleij
2017-10-16 20:54 ` [PATCH 2/5 v2] watchdog: gemini/ftwdt010: rename driver and symbols Linus Walleij
2017-10-22 17:18 ` [2/5,v2] " Guenter Roeck
2017-10-16 20:54 ` [PATCH 3/5 v2] watchdog: ftwdt010: Make interrupt optional Linus Walleij
2017-10-22 17:19 ` Guenter Roeck [this message]
2017-10-16 20:54 ` [PATCH 4/5 v2] watchdog: ftwdt010: Add clock support Linus Walleij
2017-10-22 17:30 ` [4/5,v2] " Guenter Roeck
2017-10-16 20:54 ` [PATCH 5/5 v2] watchdog: ftwdt010: Add restart support Linus Walleij
2017-10-22 17:31 ` [5/5,v2] " Guenter Roeck
2017-10-22 17:11 ` [1/5,v2] watchdog: gemini/ftwdt010: rename DT bindings Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171022171954.GA17141@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).