Commit 5a9fbf8b authored by Henning Schild's avatar Henning Schild Committed by Wim Van Sebroeck
Browse files

watchdog: w83627hf_wdt: add bootstatus support



The status bit in the status and control register can tell us whether
the last reboot was caused by the watchdog. Make sure to take that into
the bootstatus before clearing it.

Signed-off-by: default avatarHenning Schild <henning.schild@siemens.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220824152448.7736-1-henning.schild@siemens.com


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
parent dc1f12b9
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -113,6 +113,10 @@ MODULE_PARM_DESC(early_disable, "Disable watchdog at boot time (default=0)");
#define W836X7HF_WDT_CSR	0xf7
#define NCT6102D_WDT_CSR	0xf2

#define WDT_CSR_STATUS		0x10
#define WDT_CSR_KBD		0x40
#define WDT_CSR_MOUSE		0x80

static void superio_outb(int reg, int val)
{
	outb(reg, WDT_EFER);
@@ -244,8 +248,12 @@ static int w83627hf_init(struct watchdog_device *wdog, enum chips chip)
	t = superio_inb(cr_wdt_control) & ~0x0C;
	superio_outb(cr_wdt_control, t);

	/* reset trigger, disable keyboard & mouse turning off watchdog */
	t = superio_inb(cr_wdt_csr) & ~0xD0;
	t = superio_inb(cr_wdt_csr);
	if (t & WDT_CSR_STATUS)
		wdog->bootstatus |= WDIOF_CARDRESET;

	/* reset status, disable keyboard & mouse turning off watchdog */
	t &= ~(WDT_CSR_STATUS | WDT_CSR_KBD | WDT_CSR_MOUSE);
	superio_outb(cr_wdt_csr, t);

	superio_exit();