Commit d5433fd6 authored by Linus Walleij's avatar Linus Walleij Committed by Wim Van Sebroeck

watchdog: ftwdt010: Make interrupt optional

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: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent 766a2aad
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#define WDRESTART_MAGIC 0x5AB9 #define WDRESTART_MAGIC 0x5AB9
#define WDCR_CLOCK_5MHZ BIT(4) #define WDCR_CLOCK_5MHZ BIT(4)
#define WDCR_WDEXT BIT(3)
#define WDCR_WDINTR BIT(2)
#define WDCR_SYS_RST BIT(1) #define WDCR_SYS_RST BIT(1)
#define WDCR_ENABLE BIT(0) #define WDCR_ENABLE BIT(0)
...@@ -39,6 +41,7 @@ struct ftwdt010_wdt { ...@@ -39,6 +41,7 @@ struct ftwdt010_wdt {
struct watchdog_device wdd; struct watchdog_device wdd;
struct device *dev; struct device *dev;
void __iomem *base; void __iomem *base;
bool has_irq;
}; };
static inline static inline
...@@ -50,14 +53,17 @@ struct ftwdt010_wdt *to_ftwdt010_wdt(struct watchdog_device *wdd) ...@@ -50,14 +53,17 @@ struct ftwdt010_wdt *to_ftwdt010_wdt(struct watchdog_device *wdd)
static int ftwdt010_wdt_start(struct watchdog_device *wdd) static int ftwdt010_wdt_start(struct watchdog_device *wdd)
{ {
struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd);
u32 enable;
writel(wdd->timeout * WDT_CLOCK, gwdt->base + FTWDT010_WDLOAD); writel(wdd->timeout * WDT_CLOCK, gwdt->base + FTWDT010_WDLOAD);
writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART); writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART);
/* set clock before enabling */ /* set clock before enabling */
writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST, enable = WDCR_CLOCK_5MHZ | WDCR_SYS_RST;
gwdt->base + FTWDT010_WDCR); writel(enable, gwdt->base + FTWDT010_WDCR);
writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST | WDCR_ENABLE, if (gwdt->has_irq)
gwdt->base + FTWDT010_WDCR); enable |= WDCR_WDINTR;
enable |= WDCR_ENABLE;
writel(enable, gwdt->base + FTWDT010_WDCR);
return 0; return 0;
} }
...@@ -133,10 +139,6 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) ...@@ -133,10 +139,6 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev)
if (IS_ERR(gwdt->base)) if (IS_ERR(gwdt->base))
return PTR_ERR(gwdt->base); return PTR_ERR(gwdt->base);
irq = platform_get_irq(pdev, 0);
if (!irq)
return -EINVAL;
gwdt->dev = dev; gwdt->dev = dev;
gwdt->wdd.info = &ftwdt010_wdt_info; gwdt->wdd.info = &ftwdt010_wdt_info;
gwdt->wdd.ops = &ftwdt010_wdt_ops; gwdt->wdd.ops = &ftwdt010_wdt_ops;
...@@ -158,10 +160,14 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) ...@@ -158,10 +160,14 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev)
writel(reg, gwdt->base + FTWDT010_WDCR); writel(reg, gwdt->base + FTWDT010_WDCR);
} }
ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0, irq = platform_get_irq(pdev, 0);
"watchdog bark", gwdt); if (irq) {
if (ret) ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0,
return ret; "watchdog bark", gwdt);
if (ret)
return ret;
gwdt->has_irq = true;
}
ret = devm_watchdog_register_device(dev, &gwdt->wdd); ret = devm_watchdog_register_device(dev, &gwdt->wdd);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment