OSDN Git Service

watchdog: sama5d4: readout initial state
authorMathieu Othacehe <othacehe@gnu.org>
Sat, 19 Aug 2023 08:47:26 +0000 (10:47 +0200)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sat, 19 Aug 2023 15:36:20 +0000 (17:36 +0200)
Readout the AT91_WDT_MR bit at probe so that it becomes possible to get the
pre-userspace handler working.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20230819084726.11037-1-othacehe@gnu.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/sama5d4_wdt.c

index 71e8b5f..13e7291 100644 (file)
@@ -254,6 +254,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
        struct sama5d4_wdt *wdt;
        void __iomem *regs;
        u32 irq = 0;
+       u32 reg;
        int ret;
 
        wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
@@ -304,6 +305,12 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
 
        watchdog_init_timeout(wdd, wdt_timeout, dev);
 
+       reg = wdt_read(wdt, AT91_WDT_MR);
+       if (!(reg & AT91_WDT_WDDIS)) {
+               wdt->mr &= ~AT91_WDT_WDDIS;
+               set_bit(WDOG_HW_RUNNING, &wdd->status);
+       }
+
        ret = sama5d4_wdt_init(wdt);
        if (ret)
                return ret;