Skip to content

Commit 066951c

Browse files
stephan-ghWim Van Sebroeck
authored andcommitted
watchdog: pm8916_wdt: Handle watchdog enabled by bootloader
The bootloader might already enable the watchdog to catch hangs during the boot process. In that case the kernel needs to ping the watchdog temporarily until userspace is fully started. Add a check for this in the probe() function and set the WDOG_HW_RUNNING flag to make the watchdog core handle this automatically. Signed-off-by: Stephan Gerhold <[email protected]> Reviewed-by: Loic Poulain <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent e7c54a4 commit 066951c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/watchdog/pm8916_wdt.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static int pm8916_wdt_probe(struct platform_device *pdev)
142142
struct device *dev = &pdev->dev;
143143
struct pm8916_wdt *wdt;
144144
struct device *parent;
145+
unsigned int val;
145146
int err, irq;
146147
u8 poff[2];
147148

@@ -199,6 +200,15 @@ static int pm8916_wdt_probe(struct platform_device *pdev)
199200
if (poff[1] & PON_POFF_REASON2_OTST3)
200201
wdt->wdev.bootstatus |= WDIOF_OVERHEAT;
201202

203+
err = regmap_read(wdt->regmap, wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL2,
204+
&val);
205+
if (err) {
206+
dev_err(dev, "failed to check if watchdog is active: %d\n", err);
207+
return err;
208+
}
209+
if (val & S2_RESET_EN_BIT)
210+
set_bit(WDOG_HW_RUNNING, &wdt->wdev.status);
211+
202212
/* Configure watchdog to hard-reset mode */
203213
err = regmap_write(wdt->regmap,
204214
wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL,

0 commit comments

Comments
 (0)