Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

watchdog: bcm2835_wdt: set WDOG_HW_RUNNING bit when appropriate

A bootloader may start the watchdog device before handing control to
the kernel - in that case, we should tell the kernel about it so the
watchdog framework can keep it alive until userspace opens
/dev/watchdog0.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Rasmus Villemoes and committed by
Guenter Roeck
054ae194 1d8565ee

+20
+20
drivers/watchdog/bcm2835_wdt.c
··· 55 55 static unsigned int heartbeat; 56 56 static bool nowayout = WATCHDOG_NOWAYOUT; 57 57 58 + static bool bcm2835_wdt_is_running(struct bcm2835_wdt *wdt) 59 + { 60 + uint32_t cur; 61 + 62 + cur = readl(wdt->base + PM_RSTC); 63 + 64 + return !!(cur & PM_RSTC_WRCFG_FULL_RESET); 65 + } 66 + 58 67 static int bcm2835_wdt_start(struct watchdog_device *wdog) 59 68 { 60 69 struct bcm2835_wdt *wdt = watchdog_get_drvdata(wdog); ··· 190 181 watchdog_init_timeout(&bcm2835_wdt_wdd, heartbeat, dev); 191 182 watchdog_set_nowayout(&bcm2835_wdt_wdd, nowayout); 192 183 bcm2835_wdt_wdd.parent = &pdev->dev; 184 + if (bcm2835_wdt_is_running(wdt)) { 185 + /* 186 + * The currently active timeout value (set by the 187 + * bootloader) may be different from the module 188 + * heartbeat parameter or the value in device 189 + * tree. But we just need to set WDOG_HW_RUNNING, 190 + * because then the framework will "immediately" ping 191 + * the device, updating the timeout. 192 + */ 193 + set_bit(WDOG_HW_RUNNING, &bcm2835_wdt_wdd.status); 194 + } 193 195 err = watchdog_register_device(&bcm2835_wdt_wdd); 194 196 if (err) { 195 197 dev_err(dev, "Failed to register watchdog device");