Skip to contentSkip to conversation

watchdog: w83627hf: Convert to watchdog infrastructure

PATCH Superseded Guenter Roeck 3 participants 17 messages Aug 17, 2013 – Nov 17, 2013 Watchdog device drivers

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

v3 cover watchdog: w83627hf: Convert to watchdog infrastructure

Convert to watchdog infrastructure, cleanup, add support for additional chips, and merge with W83697HF and W83697UG watchdog drivers.

Tested with W83627UHG, NCT6775, NCT6776.

Original idea was to prepare the driver for use as a client to an MFD driver, but I found that requesting memory with request_muxed_region works just as well and has less impact. v2 includes the knowledge gained from converting the driver to an MFD client driver, but without the actual conversion.

With this set of patches, the watchdog driver for the supported chips can be used together with the hwmon driver for those chips.

Wim, please consider merging this set of patches into 3.12. I need both watchdog and hwmon driver running, which means I have to run patched kernels which gets a bit annoying over time. If you don't like the idea of merging the drivers for W83697HF and W83697UG into this one, please drop patch 6 and 7 from the series.

v3: Reset watchdog trigger on startup

    Rebased to v3.11-rc5

v2: Tested with W83627UHG
Retain timeout module parameter; use watchdog_init_timeout to set it Eliminate some cosmetic changes
Drop spinlock.h include
Keep "initialized" message
Don't try to configure WDTO for W83627UHG and W83627EHF Don't report the nowayout option with the 'initializing' message Use request_muxed_region to reserve memory range only while needed Add support for W83627S, W83627DHG-P, W83667HG, and NCT6779

author maintainer
#1 lore raw

PATCH v3 1/8 watchdog: w83627hf: Convert to watchdog infrastructure

---
 drivers/watchdog/Kconfig        |    1 +
 drivers/watchdog/w83627hf_wdt.c |  225 +++++++++------------------------------
 2 files changed, 51 insertions(+), 175 deletions(-)
drivers/watchdog/Kconfig +1 -0
index 362085d..c73db85 100644
@@ -858,6 +858,7 @@ config VIA_WDT
 config W83627HF_WDT
 	tristate "W83627HF/W83627DHG Watchdog Timer"
 	depends on X86
+	select WATCHDOG_CORE
 	---help---
 	  This is the driver for the hardware watchdog on the W83627HF chipset
 	  as used in Advantech PC-9578 and Tyan S2721-533 motherboards
drivers/watchdog/w83627hf_wdt.c +50 -175

354 lines not on this page · raw message

Signature · 1 line
1.7.9.7
#2 lore raw

Real nice work on this series.
Looks good to me.

thanks!
Pádraig.

#4 lore raw
In reply to Guenter Roeck

Hi Guenter,

Quoted 63 lines
---
 drivers/watchdog/Kconfig        |    1 +
 drivers/watchdog/w83627hf_wdt.c |  225 +++++++++------------------------------
 2 files changed, 51 insertions(+), 175 deletions(-)
drivers/watchdog/Kconfig +1 -0
index 362085d..c73db85 100644
@@ -858,6 +858,7 @@ config VIA_WDT
 config W83627HF_WDT
 	tristate "W83627HF/W83627DHG Watchdog Timer"
 	depends on X86
+	select WATCHDOG_CORE
 	---help---
 	  This is the driver for the hardware watchdog on the W83627HF chipset
 	  as used in Advantech PC-9578 and Tyan S2721-533 motherboards
drivers/watchdog/w83627hf_wdt.c +4 -10
index 92f1326..51a22ab 100644
@@ -1,6 +1,9 @@
 /*
  *	w83627hf/thf WDT driver
  *
+ *	(c) Copyright 2013 Guenter Roeck
+ *		converted to watchdog infrastructure
+ *
  *	(c) Copyright 2007 Vlad Drukker <[email protected]>
  *		added support for W83627THF.
  *
@@ -31,42 +34,27 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/types.h>
-#include <linux/miscdevice.h>
 #include <linux/watchdog.h>
-#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
-#include <linux/spinlock.h>
 #include <linux/io.h>
-#include <linux/uaccess.h>
-
 
 #define WATCHDOG_NAME "w83627hf/thf/hg/dhg WDT"
 #define WATCHDOG_TIMEOUT 60		/* 60 sec default timeout */
 
-static unsigned long wdt_is_open;
-static char expect_close;
-static DEFINE_SPINLOCK(io_lock);
-
 /* You must set this - there is no sane way to probe for this board. */
 static int wdt_io = 0x2E;
 module_param(wdt_io, int, 0);
 MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port (default 0x2E)");
 
-static int timeout = WATCHDOG_TIMEOUT;	/* in seconds */
+static int timeout;			/* in seconds */
 module_param(timeout, int, 0);

drivers/watchdog/w83627hf_wdt.c line 69

Quoted 10 lines
drivers/watchdog/w83627hf_wdt.c +0 -6
 MODULE_PARM_DESC(timeout,
 		"Watchdog timeout in seconds. 1 <= timeout <= 255, default="
 				__MODULE_STRING(WATCHDOG_TIMEOUT) ".");
 
-static bool nowayout = WATCHDOG_NOWAYOUT;
-module_param(nowayout, bool, 0);
-MODULE_PARM_DESC(nowayout,
-		"Watchdog cannot be stopped once started (default="
-				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
-

Why do you remove the nowayout module param?

Kind regards,
Wim.

Quoted 317 lines
drivers/watchdog/w83627hf_wdt.c +46 -159
 /*
  *	Kernel methods.
  */
@@ -110,7 +98,7 @@ static void w83627hf_unselect_wd_register(void)
 /* tyan motherboards seem to set F5 to 0x4C ?
  * So explicitly init to appropriate value. */
 
-static void w83627hf_init(void)
+static void w83627hf_init(struct watchdog_device *wdog)
 {
 	unsigned char t;
 
@@ -120,8 +108,8 @@ static void w83627hf_init(void)
 	t = inb_p(WDT_EFDR);      /* read CRF6 */
 	if (t != 0) {
 		pr_info("Watchdog already running. Resetting timeout to %d sec\n",
-			timeout);
-		outb_p(timeout, WDT_EFDR);    /* Write back to CRF6 */
+			wdog->timeout);
+		outb_p(wdog->timeout, WDT_EFDR);	/* Write back to CRF6 */
 	}
 
 	outb_p(0xF5, WDT_EFER); /* Select CRF5 */
@@ -141,10 +129,8 @@ static void w83627hf_init(void)
 	w83627hf_unselect_wd_register();
 }
 
-static void wdt_set_time(int timeout)
+static int wdt_set_time(unsigned int timeout)
 {
-	spin_lock(&io_lock);
-
 	w83627hf_select_wd_register();
 
 	outb_p(0xF6, WDT_EFER);    /* Select CRF6 */
@@ -152,34 +138,30 @@ static void wdt_set_time(int timeout)
 
 	w83627hf_unselect_wd_register();
 
-	spin_unlock(&io_lock);
+	return 0;
 }
 
-static int wdt_ping(void)
+static int wdt_start(struct watchdog_device *wdog)
 {
-	wdt_set_time(timeout);
-	return 0;
+	return wdt_set_time(wdog->timeout);
 }
 
-static int wdt_disable(void)
+static int wdt_stop(struct watchdog_device *wdog)
 {
-	wdt_set_time(0);
-	return 0;
+	return wdt_set_time(0);
 }
 
-static int wdt_set_heartbeat(int t)
+static int wdt_set_timeout(struct watchdog_device *wdog, unsigned int timeout)
 {
-	if (t < 1 || t > 255)
-		return -EINVAL;
-	timeout = t;
+	wdt_set_time(timeout);
+	wdog->timeout = timeout;
+
 	return 0;
 }
 
-static int wdt_get_time(void)
+static unsigned int wdt_get_time(struct watchdog_device *wdog)
 {
-	int timeleft;
-
-	spin_lock(&io_lock);
+	unsigned int timeleft;
 
 	w83627hf_select_wd_register();
 
@@ -188,124 +170,17 @@ static int wdt_get_time(void)
 
 	w83627hf_unselect_wd_register();
 
-	spin_unlock(&io_lock);
-
 	return timeleft;
 }
 
-static ssize_t wdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
-{
-	if (count) {
-		if (!nowayout) {
-			size_t i;
-
-			expect_close = 0;
-
-			for (i = 0; i != count; i++) {
-				char c;
-				if (get_user(c, buf + i))
-					return -EFAULT;
-				if (c == 'V')
-					expect_close = 42;
-			}
-		}
-		wdt_ping();
-	}
-	return count;
-}
-
-static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	void __user *argp = (void __user *)arg;
-	int __user *p = argp;
-	int timeval;
-	static const struct watchdog_info ident = {
-		.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
-							WDIOF_MAGICCLOSE,
-		.firmware_version = 1,
-		.identity = "W83627HF WDT",
-	};
-
-	switch (cmd) {
-	case WDIOC_GETSUPPORT:
-		if (copy_to_user(argp, &ident, sizeof(ident)))
-			return -EFAULT;
-		break;
-	case WDIOC_GETSTATUS:
-	case WDIOC_GETBOOTSTATUS:
-		return put_user(0, p);
-	case WDIOC_SETOPTIONS:
-	{
-		int options, retval = -EINVAL;
-
-		if (get_user(options, p))
-			return -EFAULT;
-		if (options & WDIOS_DISABLECARD) {
-			wdt_disable();
-			retval = 0;
-		}
-		if (options & WDIOS_ENABLECARD) {
-			wdt_ping();
-			retval = 0;
-		}
-		return retval;
-	}
-	case WDIOC_KEEPALIVE:
-		wdt_ping();
-		break;
-	case WDIOC_SETTIMEOUT:
-		if (get_user(timeval, p))
-			return -EFAULT;
-		if (wdt_set_heartbeat(timeval))
-			return -EINVAL;
-		wdt_ping();
-		/* Fall */
-	case WDIOC_GETTIMEOUT:
-		return put_user(timeout, p);
-	case WDIOC_GETTIMELEFT:
-		timeval = wdt_get_time();
-		return put_user(timeval, p);
-	default:
-		return -ENOTTY;
-	}
-	return 0;
-}
-
-static int wdt_open(struct inode *inode, struct file *file)
-{
-	if (test_and_set_bit(0, &wdt_is_open))
-		return -EBUSY;
-	/*
-	 *	Activate
-	 */
-
-	wdt_ping();
-	return nonseekable_open(inode, file);
-}
-
-static int wdt_close(struct inode *inode, struct file *file)
-{
-	if (expect_close == 42)
-		wdt_disable();
-	else {
-		pr_crit("Unexpected close, not stopping watchdog!\n");
-		wdt_ping();
-	}
-	expect_close = 0;
-	clear_bit(0, &wdt_is_open);
-	return 0;
-}
-
 /*
  *	Notifier for system down
  */
-
 static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
 	void *unused)
 {
 	if (code == SYS_DOWN || code == SYS_HALT)
-		wdt_disable();	/* Turn the WDT off */
+		wdt_set_time(0);	/* Turn the WDT off */
 
 	return NOTIFY_DONE;
 }
@@ -314,19 +189,26 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
  *	Kernel Interfaces
  */
 
-static const struct file_operations wdt_fops = {
-	.owner		= THIS_MODULE,
-	.llseek		= no_llseek,
-	.write		= wdt_write,
-	.unlocked_ioctl	= wdt_ioctl,
-	.open		= wdt_open,
-	.release	= wdt_close,
+static struct watchdog_info wdt_info = {
+	.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
+	.identity = "W83627HF Watchdog",
+};
+
+static struct watchdog_ops wdt_ops = {
+	.owner = THIS_MODULE,
+	.start = wdt_start,
+	.stop = wdt_stop,
+	.ping = wdt_start,
+	.set_timeout = wdt_set_timeout,
+	.get_timeleft = wdt_get_time,
 };
 
-static struct miscdevice wdt_miscdev = {
-	.minor = WATCHDOG_MINOR,
-	.name = "watchdog",
-	.fops = &wdt_fops,
+static struct watchdog_device wdt_dev = {
+	.info = &wdt_info,
+	.ops = &wdt_ops,
+	.timeout = WATCHDOG_TIMEOUT,
+	.min_timeout = 1,
+	.max_timeout = 255,
 };
 
 /*
@@ -341,22 +223,19 @@ static struct notifier_block wdt_notifier = {
 static int __init wdt_init(void)
 {
 	int ret;
+	bool nowayout = WATCHDOG_NOWAYOUT;
 
 	pr_info("WDT driver for the Winbond(TM) W83627HF/THF/HG/DHG Super I/O chip initialising\n");
 
-	if (wdt_set_heartbeat(timeout)) {
-		wdt_set_heartbeat(WATCHDOG_TIMEOUT);
-		pr_info("timeout value must be 1 <= timeout <= 255, using %d\n",
-			WATCHDOG_TIMEOUT);
-	}
-
 	if (!request_region(wdt_io, 1, WATCHDOG_NAME)) {
 		pr_err("I/O address 0x%04x already in use\n", wdt_io);
-		ret = -EIO;
-		goto out;
+		return -EIO;
 	}
 
-	w83627hf_init();
+	watchdog_init_timeout(&wdt_dev, timeout, NULL);
+	watchdog_set_nowayout(&wdt_dev, nowayout);
+
+	w83627hf_init(&wdt_dev);
 
 	ret = register_reboot_notifier(&wdt_notifier);
 	if (ret != 0) {
@@ -364,28 +243,25 @@ static int __init wdt_init(void)
 		goto unreg_regions;
 	}
 
-	ret = misc_register(&wdt_miscdev);
-	if (ret != 0) {
-		pr_err("cannot register miscdev on minor=%d (err=%d)\n",
-		       WATCHDOG_MINOR, ret);
+	ret = watchdog_register_device(&wdt_dev);
+	if (ret)
 		goto unreg_reboot;
-	}
 
 	pr_info("initialized. timeout=%d sec (nowayout=%d)\n",
-		timeout, nowayout);
+		wdt_dev.timeout, nowayout);
 
-out:
 	return ret;
+
 unreg_reboot:
 	unregister_reboot_notifier(&wdt_notifier);
 unreg_regions:
 	release_region(wdt_io, 1);
-	goto out;
+	return ret;
 }
 
 static void __exit wdt_exit(void)
 {
-	misc_deregister(&wdt_miscdev);
+	watchdog_unregister_device(&wdt_dev);
 	unregister_reboot_notifier(&wdt_notifier);
 	release_region(wdt_io, 1);
 }
@@ -396,4 +272,3 @@ module_exit(wdt_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Pádraig  Brady <[email protected]>");
 MODULE_DESCRIPTION("w83627hf/thf WDT driver");
-MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
Signature · 1 line
1.7.9.7
author maintainer
#5 lore raw
Quoted 69 lines · Wim Van Sebroeck

Hi Guenter,

Quoted 67 lines
---
 drivers/watchdog/Kconfig        |    1 +
 drivers/watchdog/w83627hf_wdt.c |  225 +++++++++------------------------------
 2 files changed, 51 insertions(+), 175 deletions(-)
drivers/watchdog/Kconfig +1 -0
index 362085d..c73db85 100644
@@ -858,6 +858,7 @@ config VIA_WDT
 config W83627HF_WDT
 	tristate "W83627HF/W83627DHG Watchdog Timer"
 	depends on X86
+	select WATCHDOG_CORE
 	---help---
 	  This is the driver for the hardware watchdog on the W83627HF chipset
 	  as used in Advantech PC-9578 and Tyan S2721-533 motherboards
drivers/watchdog/w83627hf_wdt.c +4 -10
index 92f1326..51a22ab 100644
@@ -1,6 +1,9 @@
 /*
  *	w83627hf/thf WDT driver
  *
+ *	(c) Copyright 2013 Guenter Roeck
+ *		converted to watchdog infrastructure
+ *
  *	(c) Copyright 2007 Vlad Drukker <[email protected]>
  *		added support for W83627THF.
  *
@@ -31,42 +34,27 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/types.h>
-#include <linux/miscdevice.h>
 #include <linux/watchdog.h>
-#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
-#include <linux/spinlock.h>
 #include <linux/io.h>
-#include <linux/uaccess.h>
-
 
 #define WATCHDOG_NAME "w83627hf/thf/hg/dhg WDT"
 #define WATCHDOG_TIMEOUT 60		/* 60 sec default timeout */
 
-static unsigned long wdt_is_open;
-static char expect_close;
-static DEFINE_SPINLOCK(io_lock);
-
 /* You must set this - there is no sane way to probe for this board. */
 static int wdt_io = 0x2E;
 module_param(wdt_io, int, 0);
 MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port (default 0x2E)");
 
-static int timeout = WATCHDOG_TIMEOUT;	/* in seconds */
+static int timeout;			/* in seconds */
 module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout,
 		"Watchdog timeout in seconds. 1 <= timeout <= 255, default="
 				__MODULE_STRING(WATCHDOG_TIMEOUT) ".");
 
Quoted 9 lines

drivers/watchdog/w83627hf_wdt.c line 69

Quoted 6 lines
drivers/watchdog/w83627hf_wdt.c +0 -6
-static bool nowayout = WATCHDOG_NOWAYOUT;
-module_param(nowayout, bool, 0);
-MODULE_PARM_DESC(nowayout,
-		"Watchdog cannot be stopped once started (default="
-				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
-

Why do you remove the nowayout module param?

Hi Wim,

sorry, that is too long ago. I simply don't remember what drove me to do that. Looking at other drivers, that doesn't seem to make much sense, does it ?

I'll be happy to resubmit the patch with the parameter restored, or submit a patch on top of it to restore it. Please let me know what you prefer.

Thanks,
Guenter

author maintainer
#6 lore raw

PATCH v4 1/1 watchdog: w83627hf: Convert to watchdog infrastructure

In reply to Wim Van Sebroeck

---
v4: Restore 'nowayout' module parameter

The changes cause a trivial conflict with 'watchdog: w83627hf: Auto-detect IO address and supported chips'. Please let me know if I should re-send the entire series.

 drivers/watchdog/Kconfig        |    1 +
 drivers/watchdog/w83627hf_wdt.c |  218 +++++++++------------------------------
 2 files changed, 50 insertions(+), 169 deletions(-)
drivers/watchdog/Kconfig +1 -0
index d1d53f3..dcaecd0 100644
@@ -868,6 +868,7 @@ config VIA_WDT
 config W83627HF_WDT
 	tristate "W83627HF/W83627DHG Watchdog Timer"
 	depends on X86
+	select WATCHDOG_CORE
 	---help---
 	  This is the driver for the hardware watchdog on the W83627HF chipset
 	  as used in Advantech PC-9578 and Tyan S2721-533 motherboards
drivers/watchdog/w83627hf_wdt.c +49 -169

339 lines not on this page · raw message

Signature · 1 line
1.7.9.7
#7 lore raw

Hi Guenter,

Quoted 8 lines

---
v4: Restore 'nowayout' module parameter

The changes cause a trivial conflict with 'watchdog: w83627hf: Auto-detect IO address and supported chips'. Please let me know if I should re-send the entire series.

Let me review the other patches still before we do any re-sending.

Kind regards,
Wim.

#8 lore raw
In reply to Guenter Roeck

Hi Guenter,

Quoted 124 lines

---
v4: Restore 'nowayout' module parameter

The changes cause a trivial conflict with 'watchdog: w83627hf: Auto-detect IO address and supported chips'. Please let me know if I should re-send the entire series.

 drivers/watchdog/Kconfig        |    1 +
 drivers/watchdog/w83627hf_wdt.c |  218 +++++++++------------------------------
 2 files changed, 50 insertions(+), 169 deletions(-)
drivers/watchdog/Kconfig +1 -0
index d1d53f3..dcaecd0 100644
@@ -868,6 +868,7 @@ config VIA_WDT
 config W83627HF_WDT
 	tristate "W83627HF/W83627DHG Watchdog Timer"
 	depends on X86
+	select WATCHDOG_CORE
 	---help---
 	  This is the driver for the hardware watchdog on the W83627HF chipset
 	  as used in Advantech PC-9578 and Tyan S2721-533 motherboards
drivers/watchdog/w83627hf_wdt.c +12 -23
index 92f1326..e204c2b 100644
@@ -1,6 +1,9 @@
 /*
  *	w83627hf/thf WDT driver
  *
+ *	(c) Copyright 2013 Guenter Roeck
+ *		converted to watchdog infrastructure
+ *
  *	(c) Copyright 2007 Vlad Drukker <[email protected]>
  *		added support for W83627THF.
  *
@@ -31,31 +34,22 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/types.h>
-#include <linux/miscdevice.h>
 #include <linux/watchdog.h>
-#include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
-#include <linux/spinlock.h>
 #include <linux/io.h>
-#include <linux/uaccess.h>
-
 
 #define WATCHDOG_NAME "w83627hf/thf/hg/dhg WDT"
 #define WATCHDOG_TIMEOUT 60		/* 60 sec default timeout */
 
-static unsigned long wdt_is_open;
-static char expect_close;
-static DEFINE_SPINLOCK(io_lock);
-
 /* You must set this - there is no sane way to probe for this board. */
 static int wdt_io = 0x2E;
 module_param(wdt_io, int, 0);
 MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port (default 0x2E)");
 
-static int timeout = WATCHDOG_TIMEOUT;	/* in seconds */
+static int timeout;			/* in seconds */
 module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout,
 		"Watchdog timeout in seconds. 1 <= timeout <= 255, default="
@@ -110,7 +104,7 @@ static void w83627hf_unselect_wd_register(void)
 /* tyan motherboards seem to set F5 to 0x4C ?
  * So explicitly init to appropriate value. */
 
-static void w83627hf_init(void)
+static void w83627hf_init(struct watchdog_device *wdog)
 {
 	unsigned char t;
 
@@ -120,8 +114,8 @@ static void w83627hf_init(void)
 	t = inb_p(WDT_EFDR);      /* read CRF6 */
 	if (t != 0) {
 		pr_info("Watchdog already running. Resetting timeout to %d sec\n",
-			timeout);
-		outb_p(timeout, WDT_EFDR);    /* Write back to CRF6 */
+			wdog->timeout);
+		outb_p(wdog->timeout, WDT_EFDR);	/* Write back to CRF6 */
 	}
 
 	outb_p(0xF5, WDT_EFER); /* Select CRF5 */
@@ -141,10 +135,8 @@ static void w83627hf_init(void)
 	w83627hf_unselect_wd_register();
 }
 
-static void wdt_set_time(int timeout)
+static int wdt_set_time(unsigned int timeout)
 {
-	spin_lock(&io_lock);
-
 	w83627hf_select_wd_register();
 
 	outb_p(0xF6, WDT_EFER);    /* Select CRF6 */
@@ -152,34 +144,30 @@ static void wdt_set_time(int timeout)
 
 	w83627hf_unselect_wd_register();
 
-	spin_unlock(&io_lock);
+	return 0;
 }
 
-static int wdt_ping(void)
+static int wdt_start(struct watchdog_device *wdog)
 {
-	wdt_set_time(timeout);
-	return 0;
+	return wdt_set_time(wdog->timeout);
 }
 
-static int wdt_disable(void)
+static int wdt_stop(struct watchdog_device *wdog)
 {
-	wdt_set_time(0);
-	return 0;

drivers/watchdog/w83627hf_wdt.c static void wdt_set_time(int timeout) · line 162

Quoted 10 lines
drivers/watchdog/w83627hf_wdt.c +3 -4
+	return wdt_set_time(0);
 }
 
-static int wdt_set_heartbeat(int t)
+static int wdt_set_timeout(struct watchdog_device *wdog, unsigned int timeout)
 {
-	if (t < 1 || t > 255)
-		return -EINVAL;
-	timeout = t;
+	wdt_set_time(timeout);

Since the core code does a "ping()" after calling the wdt_set_timeout operation you don't need the above line.

Quoted 152 lines
drivers/watchdog/w83627hf_wdt.c +5 -119
+	wdog->timeout = timeout;
+
 	return 0;
 }
 
-static int wdt_get_time(void)
+static unsigned int wdt_get_time(struct watchdog_device *wdog)
 {
-	int timeleft;
-
-	spin_lock(&io_lock);
+	unsigned int timeleft;
 
 	w83627hf_select_wd_register();
 
@@ -188,124 +176,17 @@ static int wdt_get_time(void)
 
 	w83627hf_unselect_wd_register();
 
-	spin_unlock(&io_lock);
-
 	return timeleft;
 }
 
-static ssize_t wdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
-{
-	if (count) {
-		if (!nowayout) {
-			size_t i;
-
-			expect_close = 0;
-
-			for (i = 0; i != count; i++) {
-				char c;
-				if (get_user(c, buf + i))
-					return -EFAULT;
-				if (c == 'V')
-					expect_close = 42;
-			}
-		}
-		wdt_ping();
-	}
-	return count;
-}
-
-static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	void __user *argp = (void __user *)arg;
-	int __user *p = argp;
-	int timeval;
-	static const struct watchdog_info ident = {
-		.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
-							WDIOF_MAGICCLOSE,
-		.firmware_version = 1,
-		.identity = "W83627HF WDT",
-	};
-
-	switch (cmd) {
-	case WDIOC_GETSUPPORT:
-		if (copy_to_user(argp, &ident, sizeof(ident)))
-			return -EFAULT;
-		break;
-	case WDIOC_GETSTATUS:
-	case WDIOC_GETBOOTSTATUS:
-		return put_user(0, p);
-	case WDIOC_SETOPTIONS:
-	{
-		int options, retval = -EINVAL;
-
-		if (get_user(options, p))
-			return -EFAULT;
-		if (options & WDIOS_DISABLECARD) {
-			wdt_disable();
-			retval = 0;
-		}
-		if (options & WDIOS_ENABLECARD) {
-			wdt_ping();
-			retval = 0;
-		}
-		return retval;
-	}
-	case WDIOC_KEEPALIVE:
-		wdt_ping();
-		break;
-	case WDIOC_SETTIMEOUT:
-		if (get_user(timeval, p))
-			return -EFAULT;
-		if (wdt_set_heartbeat(timeval))
-			return -EINVAL;
-		wdt_ping();
-		/* Fall */
-	case WDIOC_GETTIMEOUT:
-		return put_user(timeout, p);
-	case WDIOC_GETTIMELEFT:
-		timeval = wdt_get_time();
-		return put_user(timeval, p);
-	default:
-		return -ENOTTY;
-	}
-	return 0;
-}
-
-static int wdt_open(struct inode *inode, struct file *file)
-{
-	if (test_and_set_bit(0, &wdt_is_open))
-		return -EBUSY;
-	/*
-	 *	Activate
-	 */
-
-	wdt_ping();
-	return nonseekable_open(inode, file);
-}
-
-static int wdt_close(struct inode *inode, struct file *file)
-{
-	if (expect_close == 42)
-		wdt_disable();
-	else {
-		pr_crit("Unexpected close, not stopping watchdog!\n");
-		wdt_ping();
-	}
-	expect_close = 0;
-	clear_bit(0, &wdt_is_open);
-	return 0;
-}
-
 /*
  *	Notifier for system down
  */
-
 static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
 	void *unused)
 {
 	if (code == SYS_DOWN || code == SYS_HALT)
-		wdt_disable();	/* Turn the WDT off */
+		wdt_set_time(0);	/* Turn the WDT off */
 
 	return NOTIFY_DONE;
 }
@@ -314,19 +195,26 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
  *	Kernel Interfaces
  */
 
-static const struct file_operations wdt_fops = {
-	.owner		= THIS_MODULE,
-	.llseek		= no_llseek,
-	.write		= wdt_write,
-	.unlocked_ioctl	= wdt_ioctl,
-	.open		= wdt_open,
-	.release	= wdt_close,

drivers/watchdog/w83627hf_wdt.c static int wdt_notify_sys(struct notifier_block *this, unsigned long code, · line 207

Quoted 10 lines
drivers/watchdog/w83627hf_wdt.c +10 -0
+static struct watchdog_info wdt_info = {
+	.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
+	.identity = "W83627HF Watchdog",
+};
+
+static struct watchdog_ops wdt_ops = {
+	.owner = THIS_MODULE,
+	.start = wdt_start,
+	.stop = wdt_stop,
+	.ping = wdt_start,

This one is not needed since it's the same as start.

Quoted 78 lines
drivers/watchdog/w83627hf_wdt.c +19 -22
+	.set_timeout = wdt_set_timeout,
+	.get_timeleft = wdt_get_time,
 };
 
-static struct miscdevice wdt_miscdev = {
-	.minor = WATCHDOG_MINOR,
-	.name = "watchdog",
-	.fops = &wdt_fops,
+static struct watchdog_device wdt_dev = {
+	.info = &wdt_info,
+	.ops = &wdt_ops,
+	.timeout = WATCHDOG_TIMEOUT,
+	.min_timeout = 1,
+	.max_timeout = 255,
 };
 
 /*
@@ -344,19 +232,15 @@ static int __init wdt_init(void)
 
 	pr_info("WDT driver for the Winbond(TM) W83627HF/THF/HG/DHG Super I/O chip initialising\n");
 
-	if (wdt_set_heartbeat(timeout)) {
-		wdt_set_heartbeat(WATCHDOG_TIMEOUT);
-		pr_info("timeout value must be 1 <= timeout <= 255, using %d\n",
-			WATCHDOG_TIMEOUT);
-	}
-
 	if (!request_region(wdt_io, 1, WATCHDOG_NAME)) {
 		pr_err("I/O address 0x%04x already in use\n", wdt_io);
-		ret = -EIO;
-		goto out;
+		return -EIO;
 	}
 
-	w83627hf_init();
+	watchdog_init_timeout(&wdt_dev, timeout, NULL);
+	watchdog_set_nowayout(&wdt_dev, nowayout);
+
+	w83627hf_init(&wdt_dev);
 
 	ret = register_reboot_notifier(&wdt_notifier);
 	if (ret != 0) {
@@ -364,28 +248,25 @@ static int __init wdt_init(void)
 		goto unreg_regions;
 	}
 
-	ret = misc_register(&wdt_miscdev);
-	if (ret != 0) {
-		pr_err("cannot register miscdev on minor=%d (err=%d)\n",
-		       WATCHDOG_MINOR, ret);
+	ret = watchdog_register_device(&wdt_dev);
+	if (ret)
 		goto unreg_reboot;
-	}
 
 	pr_info("initialized. timeout=%d sec (nowayout=%d)\n",
-		timeout, nowayout);
+		wdt_dev.timeout, nowayout);
 
-out:
 	return ret;
+
 unreg_reboot:
 	unregister_reboot_notifier(&wdt_notifier);
 unreg_regions:
 	release_region(wdt_io, 1);
-	goto out;
+	return ret;
 }
 
 static void __exit wdt_exit(void)
 {
-	misc_deregister(&wdt_miscdev);
+	watchdog_unregister_device(&wdt_dev);
 	unregister_reboot_notifier(&wdt_notifier);
 	release_region(wdt_io, 1);
 }

drivers/watchdog/w83627hf_wdt.c module_exit(wdt_exit); · line 399

Quoted 4 lines
drivers/watchdog/w83627hf_wdt.c +0 -1
@@ -396,4 +277,3 @@ module_exit(wdt_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Pádraig  Brady <[email protected]>");
 MODULE_DESCRIPTION("w83627hf/thf WDT driver");
-MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);

I will add this patch with above two small corrections to linux-watchdog-next.

Kind regards,
Wim.

author maintainer
#9 lore raw
Quoted 10 lines · Wim Van Sebroeck

Hi Guenter,

Quoted 8 lines

---
v4: Restore 'nowayout' module parameter

The changes cause a trivial conflict with 'watchdog: w83627hf: Auto-detect IO address and supported chips'. Please let me know if I should re-send the entire series.

[ ... ]

Quoted 3 lines

I will add this patch with above two small corrections to linux-watchdog-next.

Hi Wim,

still learning watchdog details ;-).

Thanks a lot for picking this up!

Guenter

author maintainer
#10 lore raw

PATCH v3 2/8 watchdog: w83627hf: Enable watchdog only once

In reply to Guenter Roeck

It is unnecessary to enable the logical device and WDT0 each time the watchdog is accessed. Do it only once during initialization.

---
 drivers/watchdog/w83627hf_wdt.c |   35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)
drivers/watchdog/w83627hf_wdt.c +17 -18
index 51a22ab..bb19368 100644
@@ -66,28 +66,10 @@ MODULE_PARM_DESC(timeout,
 
 static void w83627hf_select_wd_register(void)
 {
-	unsigned char c;
 	outb_p(0x87, WDT_EFER); /* Enter extended function mode */
 	outb_p(0x87, WDT_EFER); /* Again according to manual */
-
-	outb(0x20, WDT_EFER);	/* check chip version	*/
-	c = inb(WDT_EFDR);
-	if (c == 0x82) {	/* W83627THF		*/
-		outb_p(0x2b, WDT_EFER); /* select GPIO3 */
-		c = ((inb_p(WDT_EFDR) & 0xf7) | 0x04); /* select WDT0 */
-		outb_p(0x2b, WDT_EFER);
-		outb_p(c, WDT_EFDR);	/* set GPIO3 to WDT0 */
-	} else if (c == 0x88 || c == 0xa0) {	/* W83627EHF / W83627DHG */
-		outb_p(0x2d, WDT_EFER); /* select GPIO5 */
-		c = inb_p(WDT_EFDR) & ~0x01; /* PIN77 -> WDT0# */
-		outb_p(0x2d, WDT_EFER);
-		outb_p(c, WDT_EFDR); /* set GPIO5 to WDT0 */
-	}
-
 	outb_p(0x07, WDT_EFER); /* point to logical device number reg */
 	outb_p(0x08, WDT_EFDR); /* select logical device 8 (GPIO2) */
-	outb_p(0x30, WDT_EFER); /* select CR30 */
-	outb_p(0x01, WDT_EFDR); /* set bit 0 to activate GPIO2 */
 }
 
 static void w83627hf_unselect_wd_register(void)
@@ -104,6 +86,23 @@ static void w83627hf_init(struct watchdog_device *wdog)
 
 	w83627hf_select_wd_register();
 
+	outb(0x20, WDT_EFER);	/* check chip version	*/
+	t = inb(WDT_EFDR);
+	if (t == 0x82) {	/* W83627THF		*/
+		outb_p(0x2b, WDT_EFER); /* select GPIO3 */
+		t = ((inb_p(WDT_EFDR) & 0xf7) | 0x04); /* select WDT0 */
+		outb_p(0x2b, WDT_EFER);
+		outb_p(t, WDT_EFDR);	/* set GPIO3 to WDT0 */
+	} else if (t == 0x88 || t == 0xa0) {	/* W83627EHF / W83627DHG */
+		outb_p(0x2d, WDT_EFER); /* select GPIO5 */
+		t = inb_p(WDT_EFDR) & ~0x01; /* PIN77 -> WDT0# */
+		outb_p(0x2d, WDT_EFER);
+		outb_p(t, WDT_EFDR); /* set GPIO5 to WDT0 */
+	}
+
+	outb_p(0x30, WDT_EFER); /* select CR30 */
+	outb_p(0x01, WDT_EFDR); /* set bit 0 to activate GPIO2 */
+
 	outb_p(0xF6, WDT_EFER); /* Select CRF6 */
 	t = inb_p(WDT_EFDR);      /* read CRF6 */
 	if (t != 0) {
Signature · 1 line
1.7.9.7
author maintainer
#11 lore raw

PATCH v3 3/8 watchdog: w83627hf: Enable watchdog device only if not already enabled

In reply to Guenter Roeck

There is no need to enable the watchdog device if it is already enabled. Also, when enabling the watchdog device, only set the watchdog device enable bit and do not touch other bits; depending on the chip type, those bits may enable other functionality.

---
 drivers/watchdog/w83627hf_wdt.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/watchdog/w83627hf_wdt.c +3 -1
index bb19368..13bad31 100644
@@ -101,7 +101,9 @@ static void w83627hf_init(struct watchdog_device *wdog)
 	}
 
 	outb_p(0x30, WDT_EFER); /* select CR30 */
-	outb_p(0x01, WDT_EFDR); /* set bit 0 to activate GPIO2 */
+	t = inb(WDT_EFDR);
+	if (!(t & 0x01))
+		outb_p(t | 0x01, WDT_EFDR); /* set bit 0 to activate GPIO2 */
 
 	outb_p(0xF6, WDT_EFER); /* Select CRF6 */
 	t = inb_p(WDT_EFDR);      /* read CRF6 */
Signature · 1 line
1.7.9.7
author maintainer
#12 lore raw

PATCH v3 4/8 watchdog: w83627hf: Use helper functions to access superio registers

In reply to Guenter Roeck

Use helper functions named similar to other drivers to access superio registers.

Request memory region only when needed, and use request_muxed_region(). This lets other devices (hwmon, gpio) use the same region.

---
 drivers/watchdog/w83627hf_wdt.c |  132 ++++++++++++++++++++++-----------------
 1 file changed, 76 insertions(+), 56 deletions(-)
drivers/watchdog/w83627hf_wdt.c +76 -56
index 13bad31..04cf20f 100644
@@ -64,80 +64,102 @@ MODULE_PARM_DESC(timeout,
 							(same as EFER) */
 #define WDT_EFDR (WDT_EFIR+1) /* Extended Function Data Register */
 
-static void w83627hf_select_wd_register(void)
+#define W83627HF_LD_WDT		0x08
+
+static void superio_outb(int reg, int val)
+{
+	outb(reg, WDT_EFER);
+	outb(val, WDT_EFDR);
+}
+
+static inline int superio_inb(int reg)
+{
+	outb(reg, WDT_EFER);
+	return inb(WDT_EFDR);
+}
+
+static int superio_enter(void)
 {
+	if (!request_muxed_region(wdt_io, 2, WATCHDOG_NAME))
+		return -EBUSY;
+
 	outb_p(0x87, WDT_EFER); /* Enter extended function mode */
 	outb_p(0x87, WDT_EFER); /* Again according to manual */
-	outb_p(0x07, WDT_EFER); /* point to logical device number reg */
-	outb_p(0x08, WDT_EFDR); /* select logical device 8 (GPIO2) */
+
+	return 0;
 }
 
-static void w83627hf_unselect_wd_register(void)
+static void superio_select(int ld)
+{
+	superio_outb(0x07, ld);
+}
+
+static void superio_exit(void)
 {
 	outb_p(0xAA, WDT_EFER); /* Leave extended function mode */
+	release_region(wdt_io, 2);
 }
 
 /* tyan motherboards seem to set F5 to 0x4C ?
  * So explicitly init to appropriate value. */
 
-static void w83627hf_init(struct watchdog_device *wdog)
+static int w83627hf_init(struct watchdog_device *wdog)
 {
+	int ret;
 	unsigned char t;
 
-	w83627hf_select_wd_register();
+	ret = superio_enter();
+	if (ret)
+		return ret;
 
-	outb(0x20, WDT_EFER);	/* check chip version	*/
-	t = inb(WDT_EFDR);
+	superio_select(W83627HF_LD_WDT);
+	t = superio_inb(0x20);	/* check chip version	*/
 	if (t == 0x82) {	/* W83627THF		*/
-		outb_p(0x2b, WDT_EFER); /* select GPIO3 */
-		t = ((inb_p(WDT_EFDR) & 0xf7) | 0x04); /* select WDT0 */
-		outb_p(0x2b, WDT_EFER);
-		outb_p(t, WDT_EFDR);	/* set GPIO3 to WDT0 */
+		t = (superio_inb(0x2b) & 0xf7);
+		superio_outb(0x2b, t | 0x04); /* set GPIO3 to WDT0 */
 	} else if (t == 0x88 || t == 0xa0) {	/* W83627EHF / W83627DHG */
-		outb_p(0x2d, WDT_EFER); /* select GPIO5 */
-		t = inb_p(WDT_EFDR) & ~0x01; /* PIN77 -> WDT0# */
-		outb_p(0x2d, WDT_EFER);
-		outb_p(t, WDT_EFDR); /* set GPIO5 to WDT0 */
+		t = superio_inb(0x2d);
+		superio_outb(0x2d, t & ~0x01);	/* set GPIO5 to WDT0 */
 	}
 
-	outb_p(0x30, WDT_EFER); /* select CR30 */
-	t = inb(WDT_EFDR);
+	/* set CR30 bit 0 to activate GPIO2 */
+	t = superio_inb(0x30);
 	if (!(t & 0x01))
-		outb_p(t | 0x01, WDT_EFDR); /* set bit 0 to activate GPIO2 */
+		superio_outb(0x30, t | 0x01);
 
-	outb_p(0xF6, WDT_EFER); /* Select CRF6 */
-	t = inb_p(WDT_EFDR);      /* read CRF6 */
+	t = superio_inb(0xF6);
 	if (t != 0) {
 		pr_info("Watchdog already running. Resetting timeout to %d sec\n",
 			wdog->timeout);
-		outb_p(wdog->timeout, WDT_EFDR);	/* Write back to CRF6 */
+		superio_outb(0xF6, wdog->timeout);
 	}
 
-	outb_p(0xF5, WDT_EFER); /* Select CRF5 */
-	t = inb_p(WDT_EFDR);      /* read CRF5 */
-	t &= ~0x0C;               /* set second mode & disable keyboard
-				    turning off watchdog */
-	t |= 0x02;		  /* enable the WDTO# output low pulse
-				    to the KBRST# pin (PIN60) */
-	outb_p(t, WDT_EFDR);    /* Write back to CRF5 */
-
-	outb_p(0xF7, WDT_EFER); /* Select CRF7 */
-	t = inb_p(WDT_EFDR);      /* read CRF7 */
-	t &= ~0xC0;               /* disable keyboard & mouse turning off
-				    watchdog */
-	outb_p(t, WDT_EFDR);    /* Write back to CRF7 */
-
-	w83627hf_unselect_wd_register();
+	/* set second mode & disable keyboard turning off watchdog */
+	t = superio_inb(0xF5) & ~0x0C;
+	/* enable the WDTO# output low pulse to the KBRST# pin */
+	t |= 0x02;
+	superio_outb(0xF5, t);
+
+	/* disable keyboard & mouse turning off watchdog */
+	t = superio_inb(0xF7) & ~0xC0;
+	superio_outb(0xF7, t);
+
+	superio_exit();
+
+	return 0;
 }
 
 static int wdt_set_time(unsigned int timeout)
 {
-	w83627hf_select_wd_register();
+	int ret;
 
-	outb_p(0xF6, WDT_EFER);    /* Select CRF6 */
-	outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF6 */
+	ret = superio_enter();
+	if (ret)
+		return ret;
 
-	w83627hf_unselect_wd_register();
+	superio_select(W83627HF_LD_WDT);
+	superio_outb(0xF6, timeout);
+	superio_exit();
 
 	return 0;
 }
@@ -163,13 +185,15 @@ static int wdt_set_timeout(struct watchdog_device *wdog, unsigned int timeout)
 static unsigned int wdt_get_time(struct watchdog_device *wdog)
 {
 	unsigned int timeleft;
+	int ret;
 
-	w83627hf_select_wd_register();
-
-	outb_p(0xF6, WDT_EFER);    /* Select CRF6 */
-	timeleft = inb_p(WDT_EFDR); /* Read Timeout counter to CRF6 */
+	ret = superio_enter();
+	if (ret)
+		return 0;
 
-	w83627hf_unselect_wd_register();
+	superio_select(W83627HF_LD_WDT);
+	timeleft = superio_inb(0xF6);
+	superio_exit();
 
 	return timeleft;
 }
@@ -228,20 +252,19 @@ static int __init wdt_init(void)
 
 	pr_info("WDT driver for the Winbond(TM) W83627HF/THF/HG/DHG Super I/O chip initialising\n");
 
-	if (!request_region(wdt_io, 1, WATCHDOG_NAME)) {
-		pr_err("I/O address 0x%04x already in use\n", wdt_io);
-		return -EIO;
-	}
-
 	watchdog_init_timeout(&wdt_dev, timeout, NULL);
 	watchdog_set_nowayout(&wdt_dev, nowayout);
 
-	w83627hf_init(&wdt_dev);
+	ret = w83627hf_init(&wdt_dev);
+	if (ret) {
+		pr_err("failed to initialize watchdog (err=%d)\n", ret);
+		return ret;
+	}
 
 	ret = register_reboot_notifier(&wdt_notifier);
 	if (ret != 0) {
 		pr_err("cannot register reboot notifier (err=%d)\n", ret);
-		goto unreg_regions;
+		return ret;
 	}
 
 	ret = watchdog_register_device(&wdt_dev);
@@ -255,8 +278,6 @@ static int __init wdt_init(void)
 
 unreg_reboot:
 	unregister_reboot_notifier(&wdt_notifier);
-unreg_regions:
-	release_region(wdt_io, 1);
 	return ret;
 }
 
@@ -264,7 +285,6 @@ static void __exit wdt_exit(void)
 {
 	watchdog_unregister_device(&wdt_dev);
 	unregister_reboot_notifier(&wdt_notifier);
-	release_region(wdt_io, 1);
 }
 
 module_init(wdt_init);
Signature · 1 line
1.7.9.7
author maintainer
#13 lore raw

PATCH v3 5/8 watchdog: w83627hf: Auto-detect IO address and supported chips

In reply to Guenter Roeck

Instead of requiring the user to provide an IO address per module parameter, auto-detect it as well as supported chips.

---
 drivers/watchdog/Kconfig        |   15 +++-
 drivers/watchdog/w83627hf_wdt.c |  182 ++++++++++++++++++++++++++++++++++-----
 2 files changed, 173 insertions(+), 24 deletions(-)
drivers/watchdog/Kconfig +11 -4
index c73db85..5d04ae4 100644
@@ -856,13 +856,20 @@ config VIA_WDT
 	Most people will say N.
 
 config W83627HF_WDT
-	tristate "W83627HF/W83627DHG Watchdog Timer"
+	tristate "Watchdog timer for W83627HF/W83627DHG and compatibles"
 	depends on X86
 	select WATCHDOG_CORE
 	---help---
-	  This is the driver for the hardware watchdog on the W83627HF chipset
-	  as used in Advantech PC-9578 and Tyan S2721-533 motherboards
-	  (and likely others). The driver also supports the W83627DHG chip.
+	  This is the driver for the hardware watchdog on the following
+	  Super I/O chips.
+		W83627DHG/DHG-P/EHF/EHG/F/G/HF/S/SF/THF/UHG/UG
+		W83637HF
+		W83667HG/HG-B
+		W83687THF
+		NCT6775
+		NCT6776
+		NCT6779
+
 	  This watchdog simply watches your kernel to make sure it doesn't
 	  freeze, and if it does, it reboots your computer after a certain
 	  amount of time.
drivers/watchdog/w83627hf_wdt.c +162 -20

233 lines not on this page · raw message

Signature · 1 line
1.7.9.7
author maintainer
#14 lore raw

PATCH v3 6/8 watchdog: w83627hf: Add support for W83697HF and W83697UG

In reply to Guenter Roeck

Major difference is that the watchdog control and counter registers are different on both chips.

---
 drivers/watchdog/Kconfig        |    2 ++
 drivers/watchdog/w83627hf_wdt.c |   62 +++++++++++++++++++++++++++++++--------
 2 files changed, 51 insertions(+), 13 deletions(-)
drivers/watchdog/Kconfig +2 -0
index 5d04ae4..9ec5f42 100644
@@ -866,6 +866,8 @@ config W83627HF_WDT
 		W83637HF
 		W83667HG/HG-B
 		W83687THF
+		W83697HF
+		W83697UG
 		NCT6775
 		NCT6776
 		NCT6779
drivers/watchdog/w83627hf_wdt.c +49 -13

144 lines not on this page · raw message

Signature · 1 line
1.7.9.7
author maintainer
#15 lore raw

PATCH v3 7/8 watchdog: Remove drivers for W83697HF and W83697UG

In reply to Guenter Roeck

Since both chips are now supported by the w83627hf watchdog driver, the chip specific drivers are no longer needed and can be removed.

---
 drivers/watchdog/Kconfig        |   30 ---
 drivers/watchdog/Makefile       |    2 -
 drivers/watchdog/w83697hf_wdt.c |  461 ---------------------------------------
 drivers/watchdog/w83697ug_wdt.c |  398 ---------------------------------
 4 files changed, 891 deletions(-)
 delete mode 100644 drivers/watchdog/w83697hf_wdt.c
 delete mode 100644 drivers/watchdog/w83697ug_wdt.c
drivers/watchdog/Kconfig +0 -30
index 9ec5f42..540803b 100644
@@ -881,36 +881,6 @@ config W83627HF_WDT
 
 	  Most people will say N.
 
-config W83697HF_WDT
-	tristate "W83697HF/W83697HG Watchdog Timer"
-	depends on X86
-	---help---
-	  This is the driver for the hardware watchdog on the W83697HF/HG
-	  chipset as used in Dedibox/VIA motherboards (and likely others).
-	  This watchdog simply watches your kernel to make sure it doesn't
-	  freeze, and if it does, it reboots your computer after a certain
-	  amount of time.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called w83697hf_wdt.
-
-	  Most people will say N.
-
-config W83697UG_WDT
-	tristate "W83697UG/W83697UF Watchdog Timer"
-	depends on X86
-	---help---
-	  This is the driver for the hardware watchdog on the W83697UG/UF
-	  chipset as used in MSI Fuzzy CX700 VIA motherboards (and likely others).
-	  This watchdog simply watches your kernel to make sure it doesn't
-	  freeze, and if it does, it reboots your computer after a certain
-	  amount of time.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called w83697ug_wdt.
-
-	  Most people will say N.
-
 config W83877F_WDT
 	tristate "W83877F (EMACS) Watchdog Timer"
 	depends on X86
drivers/watchdog/Makefile +0 -2
index 2f26a0b..1807fdb 100644
@@ -104,8 +104,6 @@ obj-$(CONFIG_SMSC_SCH311X_WDT) += sch311x_wdt.o
 obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o
 obj-$(CONFIG_VIA_WDT) += via_wdt.o
 obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o
-obj-$(CONFIG_W83697HF_WDT) += w83697hf_wdt.o
-obj-$(CONFIG_W83697UG_WDT) += w83697ug_wdt.o
 obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
 obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o
 obj-$(CONFIG_MACHZ_WDT) += machzwd.o
drivers/watchdog/w83697hf_wdt.c deleted +0 -461

461 lines not on this page · raw message

drivers/watchdog/w83697ug_wdt.c deleted +0 -398

398 lines not on this page · raw message

Signature · 1 line
1.7.9.7
author maintainer
#16 lore raw

PATCH v3 8/8 watchdog: w83627hf_wdt: Reset watchdog trigger during initialization

In reply to Guenter Roeck

If the watchdog has already triggered for whatever reason, it won't restart unless the trigger is reset.

---
 drivers/watchdog/w83627hf_wdt.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/w83627hf_wdt.c +2 -2
index 4c9f27a..5979c1c 100644
@@ -211,8 +211,8 @@ static int w83627hf_init(struct watchdog_device *wdog, enum chips chip)
 	t = superio_inb(cr_wdt_control) & ~0x0C;
 	superio_outb(cr_wdt_control, t);
 
-	/* disable keyboard & mouse turning off watchdog */
-	t = superio_inb(0xF7) & ~0xC0;
+	/* reset trigger, disable keyboard & mouse turning off watchdog */
+	t = superio_inb(0xF7) & ~0xD0;
 	superio_outb(0xF7, t);
 
 	superio_exit();
Signature · 1 line
1.7.9.7