Skip to contentSkip to conversation

watchdog: w83627hf: Convert to watchdog infrastructure

PATCH Superseded Guenter Roeck 4 participants 28 messages Mar 10, 2013 – Apr 29, 2013

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

v2 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. Additional test feedback for other chips would be appreciated.

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.

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 v2 1/7 watchdog: w83627hf: Convert to watchdog infrastructure

---
v2: Keep timeout module parameter
Eliminate whitespace/cosmetic changes
Drop spinlock.h include
Keep "initialized" message

 drivers/watchdog/Kconfig        |    1 +
 drivers/watchdog/w83627hf_wdt.c |  225 +++++++++------------------------------
 2 files changed, 51 insertions(+), 175 deletions(-)
drivers/watchdog/Kconfig +1 -0
index 9fcc70c..dd462af 100644
@@ -856,6 +856,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 · 6 lines
1.7.9.7

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#2 lore raw

PATCH v2 2/7 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.

---
v2: No change

 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
#3 lore raw

Re: [PATCH v2 2/7] watchdog: w83627hf: Enable watchdog only once

Quoted 2 lines · Guenter Roeck

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

Is this also the case on systems where the superio chip is used for other things? I've the impression that this may break some systems (though I no longer have the hardware to test). Arbitration of multiple users of the superio device may be managed be a central user space app, or by a kernel level arbitrator.

thanks,
Pádraig.
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#4 lore raw

Re: [PATCH v2 2/7] watchdog: w83627hf: Enable watchdog only once

Quoted 11 lines · Pádraig Brady
Quoted 2 lines · Guenter Roeck

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

Is this also the case on systems where the superio chip is used for other things? I've the impression that this may break some systems (though I no longer have the hardware to test). Arbitration of multiple users of the superio device may be managed be a central user space app, or by a kernel level arbitrator.

Not sure if I understand you correctly.

You mean some entity might actually disable the watchdog between accesses to it by the watchdog driver ? That would make it pretty useless. Might as well turn it off entirely if that is the case.

Or do you refer to _selecting_ the hwmon logical device ? If so, this patch is about enabling it only once, not about selecting it only once.

Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Re: [PATCH v2 2/7] watchdog: w83627hf: Enable watchdog only once

Quoted 12 lines · Guenter Roeck
Quoted 11 lines · Pádraig Brady
Quoted 2 lines · Guenter Roeck

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

Is this also the case on systems where the superio chip is used for other things? I've the impression that this may break some systems (though I no longer have the hardware to test). Arbitration of multiple users of the superio device may be managed be a central user space app, or by a kernel level arbitrator.

Quoted 8 lines

Not sure if I understand you correctly.

You mean some entity might actually disable the watchdog between accesses to it by the watchdog driver ? That would make it pretty useless. Might as well turn it off entirely if that is the case.

Or do you refer to _selecting_ the hwmon logical device ? If so, this patch is about enabling it only once, not about selecting it only once.

I meant selecting.
Enabling only once is fine.

sorry for the noise,

thanks,
Pádraig.
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#6 lore raw

PATCH v2 3/7 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.

---
v2: No change

 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
#7 lore raw

PATCH v2 4/7 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.

---
v2: Request memory region only when needed

 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
#8 lore raw

PATCH v2 5/7 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.

---
v2: Merge with patch 6/8

    Add support for W83627S, W83627DHG-P, W83667HG, and NCT6779
 drivers/watchdog/Kconfig        |   15 +++-
 drivers/watchdog/w83627hf_wdt.c |  182 ++++++++++++++++++++++++++++++++++-----
 2 files changed, 173 insertions(+), 24 deletions(-)
drivers/watchdog/Kconfig +11 -4
index dd462af..ef41028 100644
@@ -854,13 +854,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
#9 lore raw

PATCH v2 6/7 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.

---
v2: Previously patch 7/8
No change

 drivers/watchdog/Kconfig        |    2 ++
 drivers/watchdog/w83627hf_wdt.c |   62 +++++++++++++++++++++++++++++++--------
 2 files changed, 51 insertions(+), 13 deletions(-)
drivers/watchdog/Kconfig +2 -0
index ef41028..bf04b38 100644
@@ -864,6 +864,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
#10 lore raw

PATCH v2 7/7 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.

---
v2: Previously patch 8/8
No change

 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 bf04b38..d9ded4e 100644
@@ -879,36 +879,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 a300b94..b330b1f 100644
@@ -103,8 +103,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 · 6 lines
1.7.9.7

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw
In reply to Guenter Roeck

Hi Guenter,

Quoted 11 lines

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

Tested with W83627UHG, NCT6775, NCT6776. Additional test feedback for other chips would be appreciated.

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.

Quoted 9 lines

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

In 2011 I started something similar but then with the MFD approach in mind. Goal was also to clean-up the w836* watchdog drivers and get a clean driver that supports all Winbond super-I/O based watchdog drivers.

I dug op the development code again. I'll post it in a next e-mail so that we can see what the best way forward is. Note: I took the MFD approach because:
1) all superio shares the similar functions for using the Super-I/O registers.
2) Goal is to have low-level driver that support the specific super-I/O chipsets and that does the platform stuff for hwmon, watchdog, gpio, ...

Kind regards,
Wim.

#12 lore raw

RFC 1/1 winbond Super-I/O MFD driver

As said in previous mail, I would post my old
development code for the winbond super-I/O MFD
device. It's development code and it definitely
can be improved. Goal at this point is to see
which direction we should take (with super-i/o
device drivers in general imho).

Kind regards,
Wim.
---
commit dc8987180ad87da86740448f033b8cfe46ea90dd

Author: Wim Van Sebroeck <[email protected]>
Date:   Fri Mar 22 22:02:16 2013 +0100

Sample Winbond Super-I/O MFD device consisting out of a lowel-level driver that does the detection and creates the platform-data and a watchdog driver.

drivers/mfd/Kconfig +8 -0
index c346941..943399f 100644
@@ -1119,6 +1119,14 @@ config MFD_AS3711
 	help
 	  Support for the AS3711 PMIC from AMS
 
+config MFD_SIO_WINBOND
+	tristate "Winbond SuperIO chips"
+	select MFD_CORE
+	depends on X86
+	help
+	  Say yes here to enable support for various functions of the
+	  Winbond Super IO chipsets.
+
 endmenu
 endif
 
drivers/mfd/Makefile +1 -0
index b90409c..3c7673b 100644
@@ -148,3 +148,4 @@ obj-$(CONFIG_MFD_LM3533)	+= lm3533-core.o lm3533-ctrlbank.o
 obj-$(CONFIG_VEXPRESS_CONFIG)	+= vexpress-config.o vexpress-sysreg.o
 obj-$(CONFIG_MFD_RETU)		+= retu-mfd.o
 obj-$(CONFIG_MFD_AS3711)	+= as3711.o
+obj-$(CONFIG_MFD_SIO_WINBOND)	+= winbond-superio.o
drivers/mfd/winbond-superio.c new file +327 -0

327 lines not on this page · raw message

drivers/watchdog/Kconfig +12 -0
index 9fcc70c..6886adb 100644
@@ -927,6 +927,18 @@ config W83977F_WDT
 	  To compile this driver as a module, choose M here: the
 	  module will be called w83977f_wdt.
 
+config WINBOND_WDT
+	tristate "Winbond Watchdog Timer"
+	depends on X86
+	select WINBOND_SIO
+	select WATCHDOG_CORE
+	---help---
+	  This is the driver for the hardware watchdog on the Winbond Super I/O
+	  chipsets.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called winbond_wdt.
+
 config MACHZ_WDT
 	tristate "ZF MachZ Watchdog"
 	depends on X86
drivers/watchdog/Makefile +1 -0
index a300b94..fb46d37 100644
@@ -107,6 +107,7 @@ 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_WINBOND_WDT) += winbond_wdt.o
 obj-$(CONFIG_MACHZ_WDT) += machzwd.o
 obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o
 obj-$(CONFIG_INTEL_SCU_WATCHDOG) += intel_scu_watchdog.o
drivers/watchdog/winbond_wdt.c new file +284 -0

284 lines not on this page · raw message

include/linux/mfd/superio.h new file +27 -0
new file mode 100644
index 0000000..4b6dee5
@@ -0,0 +1,27 @@
+
+#ifndef __SUPERIO_MFD_H
+#define __SUPERIO_MFD_H
+
+#include <linux/io.h>
+
+#define SIO_LD_SEL	0x07	/* Super-I/O Logical Device Select */
+
+inline void superio_outb(int ioreg, int reg, int val)
+{
+	outb(reg, ioreg);
+	outb(val, ioreg + 1);
+}
+
+inline int superio_inb(int ioreg, int reg)
+{
+	outb(reg, ioreg);
+	return inb(ioreg + 1);
+}
+
+inline void superio_select(int ioreg, int ld)
+{
+	outb(SIO_LD_SEL, ioreg);
+	outb(ld, ioreg + 1);
+}
+
+#endif /* __SUPERIO_MFD_H */
include/linux/mfd/winbond_superio.h new file +63 -0

63 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#13 lore raw
In reply to Wim Van Sebroeck
Quoted 27 lines · Wim Van Sebroeck

Hi Guenter,

Quoted 11 lines

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

Tested with W83627UHG, NCT6775, NCT6776. Additional test feedback for other chips would be appreciated.

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.

Quoted 9 lines

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

In 2011 I started something similar but then with the MFD approach in mind. Goal was also to clean-up the w836* watchdog drivers and get a clean driver that supports all Winbond super-I/O based watchdog drivers.

Quoted 6 lines

I dug op the development code again. I'll post it in a next e-mail so that we can see what the best way forward is. Note: I took the MFD approach because:
1) all superio shares the similar functions for using the Super-I/O registers.
2) Goal is to have low-level driver that support the specific super-I/O chipsets and that does the platform stuff for hwmon, watchdog, gpio, ...

Hi Wim,

I started with a similar approach, only I used mfd cells to pass on platform specific information such as the device type and the superio base address. I still have the patchset for the mfd driver, in case you are interested. My code is based on the patches submitted by Rodolfo Giometti a couple of years ago. Want me to post it ?

What I noticed in my testing is that the superio address range (2e or 4e), which the drivers currently take as granted, is at least on my systems (all three of them) reserved by ACPI. Unfortunately that means one can not use the mfd infrastructure to pass on the superio memory region, since it checks for acpi conflicts. With that I gave up on the idea and reverted to using request_muxed_region. That seemed simpler and accomplish the same as long as all drivers actually use it.

Ultimately, I am open to either approach.

Thanks,
Guenter

#14 lore raw

Hi Guenter,

Quoted 10 lines
Quoted 10 lines

In 2011 I started something similar but then with the MFD approach in mind. Goal was also to clean-up the w836* watchdog drivers and get a clean driver that supports all Winbond super-I/O based watchdog drivers.

I dug op the development code again. I'll post it in a next e-mail so that we can see what the best way forward is. Note: I took the MFD approach because:
1) all superio shares the similar functions for using the Super-I/O registers.
2) Goal is to have low-level driver that support the specific super-I/O chipsets and that does the platform stuff for hwmon, watchdog, gpio, ...

Quoted 7 lines

Hi Wim,

I started with a similar approach, only I used mfd cells to pass on platform specific information such as the device type and the superio base address. I still have the patchset for the mfd driver, in case you are interested. My code is based on the patches submitted by Rodolfo Giometti a couple of years ago. Want me to post it ?

If it's not v1 then I am interested.
I think it depends on the super-I/O chipset of what info you can pass. I would not use mfd cells for the winbond driver but use platform data (similar to drivers/mfd/adp5520.c) because you don't need more then just pass some data.

Quoted 7 lines

What I noticed in my testing is that the superio address range (2e or 4e), which the drivers currently take as granted, is at least on my systems (all three of them) reserved by ACPI. Unfortunately that means one can not use the mfd infrastructure to pass on the superio memory region, since it checks for acpi conflicts. With that I gave up on the idea and reverted to using request_muxed_region. That seemed simpler and accomplish the same as long as all drivers actually use it.

Noticed the same. That's why passing the platform data together with the superio-address and type seems the best way to go. I also kept the superio_enter and superio_exit a function in the low level driver because I used a lock to make sure that the hwmon code doesn't start doing things when the watchdog is doing things. But I think that the request_muxed_region is doing something similar also.

Kind regards,
Wim.

author maintainer
#15 lore raw
Quoted 20 lines · Wim Van Sebroeck

Hi Guenter,

Quoted 10 lines
Quoted 10 lines

In 2011 I started something similar but then with the MFD approach in mind. Goal was also to clean-up the w836* watchdog drivers and get a clean driver that supports all Winbond super-I/O based watchdog drivers.

I dug op the development code again. I'll post it in a next e-mail so that we can see what the best way forward is. Note: I took the MFD approach because:
1) all superio shares the similar functions for using the Super-I/O registers.
2) Goal is to have low-level driver that support the specific super-I/O chipsets and that does the platform stuff for hwmon, watchdog, gpio, ...

Quoted 7 lines

Hi Wim,

I started with a similar approach, only I used mfd cells to pass on platform specific information such as the device type and the superio base address. I still have the patchset for the mfd driver, in case you are interested. My code is based on the patches submitted by Rodolfo Giometti a couple of years ago. Want me to post it ?

Quoted 5 lines

If it's not v1 then I am interested.
I think it depends on the super-I/O chipset of what info you can pass. I would not use mfd cells for the winbond driver but use platform data (similar to drivers/mfd/adp5520.c) because you don't need more then just pass some data.

Actually one can pass platform data through mfd cells, which is what I do. I pass the SIO address, the chip type (as enum), and the chip name to the platform driver.

Quoted 8 lines
Quoted 7 lines

What I noticed in my testing is that the superio address range (2e or 4e), which the drivers currently take as granted, is at least on my systems (all three of them) reserved by ACPI. Unfortunately that means one can not use the mfd infrastructure to pass on the superio memory region, since it checks for acpi conflicts. With that I gave up on the idea and reverted to using request_muxed_region. That seemed simpler and accomplish the same as long as all drivers actually use it.

Quoted 7 lines

Noticed the same. That's why passing the platform data together with the superio-address and type seems the best way to go. I also kept the superio_enter and superio_exit a function in the low level driver because I used a lock to make sure that the hwmon code doesn't start doing things when the watchdog is doing things. But I think that the request_muxed_region is doing something similar also.

Yes, it does the same. Only difference is that using a function in the mfd driver increases the use count on it when a client module is loaded.

Patch follows.

Thanks,
Guenter

author maintainer
#16 lore raw

mfd: Core driver for W836{2389}7[T]HF

In reply to Wim Van Sebroeck

MFD core driver for various variants of Winbond/Nuvoton SuperIO chips.

---

My variant of an MFD core driver for Winbond chips.

Key differences to Wim's driver
- Uses mfd infrastructure
- Passes enum instead of raw device id to client drivers
- Uses request_muxed_region instead of an in-module function for superio_enter
[ Using an in-module function and in-module locking may be better ]

TODO:
- Detect and instantiate superio chips on both addresses, not just one.
- Replace static variables 'pdev' and mfd_cells[].

 drivers/mfd/Kconfig          |   22 +++
 drivers/mfd/Makefile         |    1 +
 drivers/mfd/w83627hf-core.c  |  324 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/w83627hf.h |  131 +++++++++++++++++
 4 files changed, 478 insertions(+)
 create mode 100644 drivers/mfd/w83627hf-core.c
 create mode 100644 include/linux/mfd/w83627hf.h
drivers/mfd/Kconfig +22 -0
index c346941..a141ef6 100644
@@ -1119,6 +1119,28 @@ config MFD_AS3711
 	help
 	  Support for the AS3711 PMIC from AMS
 
+config MFD_W83627HF
+	tristate "Winbond W83627HF and compatibles"
+	select MFD_CORE
+	help
+	  If you say yes here you add support for the Winbond W836X7 and Nuvoton
+	  NCT677X series of super-IO chips. The following chips are supported:
+		W83627F/HF/G/HG/DHG/DHG-P/EHF/EHG/S/SF/THF/UHG/UG
+		W83637HF
+		W83667HG/HG-B
+		W83687THF
+		W83697HF
+		NCT6775
+		NCT6776
+		NCT6779
+
+	  This is a multi functional device and this support defines a new
+	  platform device only. See other configuration submenus in order to
+	  enable the drivers of Winbond chip's functionalities.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called w83627hf-core.
+
 endmenu
 endif
 
drivers/mfd/Makefile +1 -0
index b90409c..3e9e830 100644
@@ -77,6 +77,7 @@ obj-$(CONFIG_MFD_MC13XXX_I2C)	+= mc13xxx-i2c.o
 obj-$(CONFIG_MFD_CORE)		+= mfd-core.o
 
 obj-$(CONFIG_EZX_PCAP)		+= ezx-pcap.o
+obj-$(CONFIG_MFD_W83627HF)	+= w83627hf-core.o
 
 obj-$(CONFIG_MCP)		+= mcp-core.o
 obj-$(CONFIG_MCP_SA11X0)	+= mcp-sa11x0.o
drivers/mfd/w83627hf-core.c new file +324 -0

324 lines not on this page · raw message

include/linux/mfd/w83627hf.h new file +131 -0

131 lines not on this page · raw message

Signature · 1 line
1.7.9.7
author maintainer
#17 lore raw

mfd: Core driver for Winbond chips

In reply to Guenter Roeck

MFD core driver for various variants of Winbond/Nuvoton SuperIO chips.

---
 drivers/mfd/Kconfig          |   22 +++
 drivers/mfd/Makefile         |    1 +
 drivers/mfd/w83627hf-core.c  |  324 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/w83627hf.h |  131 +++++++++++++++++
 4 files changed, 478 insertions(+)
 create mode 100644 drivers/mfd/w83627hf-core.c
 create mode 100644 include/linux/mfd/w83627hf.h
drivers/mfd/Kconfig +22 -0
index c346941..a141ef6 100644
@@ -1119,6 +1119,28 @@ config MFD_AS3711
 	help
 	  Support for the AS3711 PMIC from AMS
 
+config MFD_W83627HF
+	tristate "Winbond W83627HF and compatibles"
+	select MFD_CORE
+	help
+	  If you say yes here you add support for the Winbond W836X7 and Nuvoton
+	  NCT677X series of super-IO chips. The following chips are supported:
+		W83627F/HF/G/HG/DHG/DHG-P/EHF/EHG/S/SF/THF/UHG/UG
+		W83637HF
+		W83667HG/HG-B
+		W83687THF
+		W83697HF
+		NCT6775
+		NCT6776
+		NCT6779
+
+	  This is a multi functional device and this support defines a new
+	  platform device only. See other configuration submenus in order to
+	  enable the drivers of Winbond chip's functionalities.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called w83627hf-core.
+
 endmenu
 endif
 
drivers/mfd/Makefile +1 -0
index b90409c..3e9e830 100644
@@ -77,6 +77,7 @@ obj-$(CONFIG_MFD_MC13XXX_I2C)	+= mc13xxx-i2c.o
 obj-$(CONFIG_MFD_CORE)		+= mfd-core.o
 
 obj-$(CONFIG_EZX_PCAP)		+= ezx-pcap.o
+obj-$(CONFIG_MFD_W83627HF)	+= w83627hf-core.o
 
 obj-$(CONFIG_MCP)		+= mcp-core.o
 obj-$(CONFIG_MCP_SA11X0)	+= mcp-sa11x0.o
drivers/mfd/w83627hf-core.c new file +324 -0

324 lines not on this page · raw message

include/linux/mfd/w83627hf.h new file +131 -0

131 lines not on this page · raw message

Signature · 1 line
1.7.9.7
author maintainer
#18 lore raw

Re: mfd: Core driver for Winbond chips

Quoted 3 lines · Guenter Roeck

MFD core driver for various variants of Winbond/Nuvoton SuperIO chips.

Sorry for sending this twice. I seem to be having trouble with outgoing e-mail being delayed for hours. The first patch didn't show up for a long time, and I thought I did something wrong when sending it.

Guenter

#19 lore raw

Re: mfd: Core driver for Winbond chips

In reply to Guenter Roeck

Hi Guenter,

Quoted 11 lines · Guenter Roeck

MFD core driver for various variants of Winbond/Nuvoton SuperIO chips.

---
 drivers/mfd/Kconfig          |   22 +++
 drivers/mfd/Makefile         |    1 +
 drivers/mfd/w83627hf-core.c  |  324 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/w83627hf.h |  131 +++++++++++++++++
 4 files changed, 478 insertions(+)
 create mode 100644 drivers/mfd/w83627hf-core.c
 create mode 100644 include/linux/mfd/w83627hf.h

This driver looks overall good to me. Is this your final version, or should I expect any follow up patch ?

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
author maintainer
#20 lore raw

Re: mfd: Core driver for Winbond chips

Quoted 14 lines · Samuel Ortiz

Hi Guenter,

Quoted 11 lines · Guenter Roeck

MFD core driver for various variants of Winbond/Nuvoton SuperIO chips.

---
 drivers/mfd/Kconfig          |   22 +++
 drivers/mfd/Makefile         |    1 +
 drivers/mfd/w83627hf-core.c  |  324 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/w83627hf.h |  131 +++++++++++++++++
 4 files changed, 478 insertions(+)
 create mode 100644 drivers/mfd/w83627hf-core.c
 create mode 100644 include/linux/mfd/w83627hf.h
Quoted 3 lines

This driver looks overall good to me. Is this your final version, or should I expect any follow up patch ?

Hi Samuel,

I was waiting for feedback from Wim, who submitted a similar driver, about his thoughts. Key question is how to reserve access to the shared resource - either through an exported function in the mfd driver requesting a mutex, or through request_muxed_region(). I am going back and forth myself on which one is better.

Maybe it does not really matter, but using a function has the slight advantage that it auto-loads and locks the mfd module while one of its client modules is loaded. If we use request_muxed_region, that is not the case and the client module must use another means to request and lock the mfd module.

Maybe you have an opinion ?

Thanks,
Guenter

#21 lore raw

Re: mfd: Core driver for Winbond chips

Hi Guenter,

Quoted 11 lines

I was waiting for feedback from Wim, who submitted a similar driver, about his thoughts. Key question is how to reserve access to the shared resource - either through an exported function in the mfd driver requesting a mutex, or through request_muxed_region(). I am going back and forth myself on which one is better.

Maybe it does not really matter, but using a function has the slight advantage that it auto-loads and locks the mfd module while one of its client modules is loaded. If we use request_muxed_region, that is not the case and the client module must use another means to request and lock the mfd module.

Maybe you have an opinion ?

This is indeed the main issue that has to be solved. Both options will work. I like the auto-load and lock, but I need to look at the request_muxed_region code again first before I can see what the possible drawbacks are :-).

Kind regards,
Wim.

author maintainer
#22 lore raw

Re: mfd: Core driver for Winbond chips

Quoted 12 lines · Wim Van Sebroeck

Hi Guenter,

Quoted 10 lines

I was waiting for feedback from Wim, who submitted a similar driver, about his thoughts. Key question is how to reserve access to the shared resource - either through an exported function in the mfd driver requesting a mutex, or through request_muxed_region(). I am going back and forth myself on which one is better.

Maybe it does not really matter, but using a function has the slight advantage that it auto-loads and locks the mfd module while one of its client modules is loaded. If we use request_muxed_region, that is not the case and the client module must use another means to request and lock the mfd module.

Quoted 6 lines
Quoted 1 line

Maybe you have an opinion ?

This is indeed the main issue that has to be solved. Both options will work. I like the auto-load and lock, but I need to look at the request_muxed_region code again first before I can see what the possible drawbacks are :-).

One drawback of using request_muxed_region is that it needs a return value from superio_enter. Also, it needs some code in the client driver init function to ensure that the mfd driver gets loaded, and possibly a call to __module_get() in the client driver probe function to keep the mfd driver loaded.

winbond_superio_enter() would not need a return value and could use devm_request_region. We could also consider allocating the hwmon memory space in the mfd driver and pass it as resource to the client drivers, which would remove a few more lines of code from those.

Overall I am slightly in favor of using an exported function.

Guenter

#23 lore raw

Re: mfd: Core driver for Winbond chips

Hi Guenter,

Quoted 21 lines
Quoted 10 lines
Quoted 10 lines

I was waiting for feedback from Wim, who submitted a similar driver, about his thoughts. Key question is how to reserve access to the shared resource - either through an exported function in the mfd driver requesting a mutex, or through request_muxed_region(). I am going back and forth myself on which one is better.

Maybe it does not really matter, but using a function has the slight advantage that it auto-loads and locks the mfd module while one of its client modules is loaded. If we use request_muxed_region, that is not the case and the client module must use another means to request and lock the mfd module.

Quoted 6 lines
Quoted 1 line

Maybe you have an opinion ?

This is indeed the main issue that has to be solved. Both options will work. I like the auto-load and lock, but I need to look at the request_muxed_region code again first before I can see what the possible drawbacks are :-).

One drawback of using request_muxed_region is that it needs a return value from superio_enter. Also, it needs some code in the client driver init function to ensure that the mfd driver gets loaded, and possibly a call to __module_get() in the client driver probe function to keep the mfd driver loaded.

Quoted 6 lines

winbond_superio_enter() would not need a return value and could use devm_request_region. We could also consider allocating the hwmon memory space in the mfd driver and pass it as resource to the client drivers, which would remove a few more lines of code from those.

Overall I am slightly in favor of using an exported function.

I looked at commit 8b6d043b7ee2d1b819dc833d677ea2aead71a0c0 (which implements request_muxed_region). You indeed need some extra code for loading the lowl-level mfd driver. So I am also in favour of the exported function.

Kind regards,
Wim.

author maintainer
#24 lore raw

Re: mfd: Core driver for Winbond chips

Quoted 28 lines · Wim Van Sebroeck

Hi Guenter,

Quoted 26 lines
Quoted 10 lines
Quoted 10 lines

I was waiting for feedback from Wim, who submitted a similar driver, about his thoughts. Key question is how to reserve access to the shared resource - either through an exported function in the mfd driver requesting a mutex, or through request_muxed_region(). I am going back and forth myself on which one is better.

Maybe it does not really matter, but using a function has the slight advantage that it auto-loads and locks the mfd module while one of its client modules is loaded. If we use request_muxed_region, that is not the case and the client module must use another means to request and lock the mfd module.

Quoted 6 lines
Quoted 1 line

Maybe you have an opinion ?

This is indeed the main issue that has to be solved. Both options will work. I like the auto-load and lock, but I need to look at the request_muxed_region code again first before I can see what the possible drawbacks are :-).

One drawback of using request_muxed_region is that it needs a return value from superio_enter. Also, it needs some code in the client driver init function to ensure that the mfd driver gets loaded, and possibly a call to __module_get() in the client driver probe function to keep the mfd driver loaded.

winbond_superio_enter() would not need a return value and could use devm_request_region. We could also consider allocating the hwmon memory space in the mfd driver and pass it as resource to the client drivers, which would remove a few more lines of code from those.

Quoted 6 lines
Quoted 1 line

Overall I am slightly in favor of using an exported function.

I looked at commit 8b6d043b7ee2d1b819dc833d677ea2aead71a0c0 (which implements request_muxed_region). You indeed need some extra code for loading the lowl-level mfd driver. So I am also in favour of the exported function.

So which way should we go ? Take your driver as a starting point or mine ?

One thing I'll want to add is support for both superio regions, as I have a use case for it.

Thanks,
Guenter

#25 lore raw

Re: mfd: Core driver for Winbond chips

Hi Guenter,

Quoted 8 lines
Quoted 4 lines

I looked at commit 8b6d043b7ee2d1b819dc833d677ea2aead71a0c0 (which implements request_muxed_region). You indeed need some extra code for loading the lowl-level mfd driver. So I am also in favour of the exported function.

So which way should we go ? Take your driver as a starting point or mine ?

One thing I'll want to add is support for both superio regions, as I have a use case for it.

I'll come back on this tomorrow. It's going to be a merge of your and my code anyway.

I agree it would be nice to add also hwmon + wdog support in it from the start.

Kind regards,
Wim.

author maintainer
#26 lore raw

Re: mfd: Core driver for Winbond chips

Quoted 6 lines · Wim Van Sebroeck

Hi Guenter,

Quoted 4 lines
Quoted 4 lines

I looked at commit 8b6d043b7ee2d1b819dc833d677ea2aead71a0c0 (which implements request_muxed_region). You indeed need some extra code for loading the lowl-level mfd driver. So I am also in favour of the exported function.

Quoted 9 lines
Quoted 4 lines

So which way should we go ? Take your driver as a starting point or mine ?

One thing I'll want to add is support for both superio regions, as I have a use case for it.

I'll come back on this tomorrow. It's going to be a merge of your and my code anyway.

I agree it would be nice to add also hwmon + wdog support in it from the start.

Hi Wim,

looks like you are busy. Want me to take another stake at it and do the merge ?

Thanks,
Guenter

#27 lore raw

Re: mfd: Core driver for Winbond chips

In reply to Samuel Ortiz

Hi Samuel,

Quoted 11 lines
Quoted 11 lines

MFD core driver for various variants of Winbond/Nuvoton SuperIO chips.

---
 drivers/mfd/Kconfig          |   22 +++
 drivers/mfd/Makefile         |    1 +
 drivers/mfd/w83627hf-core.c  |  324 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/w83627hf.h |  131 +++++++++++++++++
 4 files changed, 478 insertions(+)
 create mode 100644 drivers/mfd/w83627hf-core.c
 create mode 100644 include/linux/mfd/w83627hf.h
Quoted 2 lines

This driver looks overall good to me. Is this your final version, or should I expect any follow up patch ?

If possible could you wait a couple of days. I need to review it with what I had created so that Guenter and Myself can come up with a final version.

Kind regards,
Wim.