Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times
@ 2026-11-28 20:55 Tomasz Bojanowski
  2026-11-28 20:55 ` [PATCH 1/2] hwmon: (nct6683) Document manual mode on unload and MSI-only fan curves Tomasz Bojanowski
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Tomasz Bojanowski @ 2026-11-28 20:55 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-hwmon, Hamza Mahfooz, Jonathan Corbet, Shuah Khan,
	Randy Dunlap, linux-doc, linux-kernel

Two small changes for nct6683, based on hwmon-next.

The first one brings the fan control documentation up to date with two
recent changes: fans set to manual mode through the driver return to
automatic mode when the module is unloaded, and the fan curve attributes
only exist on MSI boards with an NCT6687D-R.

The second one reports the step up and step down times the EC applies
between PWM steps on NCT6687D-R, as read-only pwmN_step_up_time and
pwmN_step_down_time.

Tested on an MSI MAG B850M MORTAR WIFI (MS-7E61), EC firmware 0.0 build
03/10/25; the BIOS versions are given in the second patch.

Tomasz Bojanowski (2):
  hwmon: (nct6683) Document manual mode on unload and MSI-only fan
    curves
  hwmon: (nct6683) Report the step up and step down times of NCT6687D-R
    fans

 Documentation/hwmon/nct6683.rst | 12 ++++++---
 drivers/hwmon/nct6683.c         | 44 +++++++++++++++++++++++++++++++--
 2 files changed, 51 insertions(+), 5 deletions(-)


base-commit: 8d0f79f49fb10c9f07fee6720551113272a1812b
-- 
2.56.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] hwmon: (nct6683) Document manual mode on unload and MSI-only fan curves
  2026-11-28 20:55 [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times Tomasz Bojanowski
@ 2026-11-28 20:55 ` Tomasz Bojanowski
  2026-11-29  0:33   ` Guenter Roeck
  2026-11-28 20:55 ` [PATCH 2/2] hwmon: (nct6683) Report the step up and step down times of NCT6687D-R fans Tomasz Bojanowski
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Tomasz Bojanowski @ 2026-11-28 20:55 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-hwmon, Hamza Mahfooz, Jonathan Corbet, Shuah Khan,
	Randy Dunlap, linux-doc, linux-kernel

The fan control documentation has not kept up with two recent changes:

- Fan control was enabled on ASRock boards, which have pwmN_enable but
  no fan curve attributes. The documentation still says that the curve
  of each fan with a pwmN_enable attribute is reported.
- Fans set to manual mode through the driver are now switched back to
  automatic mode when the driver is unloaded. The documentation only
  says that the curves are kept.

Update both.

Signed-off-by: Tomasz Bojanowski <tomasz@bojanowski.me>
---
I used an AI assistant (Claude Code) during development, including for
the test scripts and for comparing the EC register dumps. I reviewed all
of the changes and take responsibility for them.

 Documentation/hwmon/nct6683.rst | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/hwmon/nct6683.rst b/Documentation/hwmon/nct6683.rst
index 1afdf4788d82..d9ee2b02a26e 100644
--- a/Documentation/hwmon/nct6683.rst
+++ b/Documentation/hwmon/nct6683.rst
@@ -67,10 +67,11 @@ pwmN_enable selects the fan control mode:
   * 2: automatic mode, using the current fan curve
 
 pwmN can only be written in manual mode. Switching to manual mode keeps the
-current duty cycle.
+current duty cycle. Fans which were set to manual mode through the driver
+are switched back to automatic mode when the driver is unloaded.
 
-For each fan with a pwmN_enable attribute, the fan curve is reported with
-the following attributes, if the curve sets a duty cycle:
+On the MSI boards, the fan curve of each fan with a pwmN_enable attribute
+is reported with the following attributes, if the curve sets a duty cycle:
 
   * pwmN_auto_point[1-7]_temp: temperature of the curve point, in
     millidegrees Celsius
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] hwmon: (nct6683) Report the step up and step down times of NCT6687D-R fans
  2026-11-28 20:55 [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times Tomasz Bojanowski
  2026-11-28 20:55 ` [PATCH 1/2] hwmon: (nct6683) Document manual mode on unload and MSI-only fan curves Tomasz Bojanowski
@ 2026-11-28 20:55 ` Tomasz Bojanowski
  2026-11-29  0:34   ` Guenter Roeck
  2026-11-28 20:59 ` [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times sashiko-bot
  2026-11-28 21:24 ` Tomasz Bojanowski
  3 siblings, 1 reply; 7+ messages in thread
From: Tomasz Bojanowski @ 2026-11-28 20:55 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-hwmon, Hamza Mahfooz, Jonathan Corbet, Shuah Khan,
	Randy Dunlap, linux-doc, linux-kernel

On MSI boards with an NCT6687D-R (customer ID 0x20d), the BIOS setup
offers a Step Up Time and a Step Down Time for each fan. Report them as
pwmN_step_up_time and pwmN_step_down_time, in milliseconds as the
nct6775 driver does, for the fans whose curve is reported.

The EC holds the times in tenths of a second, in tables indexed by
channel: 0x81a + n (step up) and 0x824 + n (step down) for channels 0-9,
0xe7e + n - 10 (step up) and 0xe84 + n - 10 (step down) for channels
10-15. This was found on an MSI MAG B850M MORTAR WIFI (MS-7E61) by
changing the times in the BIOS setup and reading the EC before and
after. Each changed time changed one byte in these tables, and setting
the times back restored them. Taken together, the readings identify the
byte of each time of pwm1, pwm2, pwm13, pwm14 and pwm16; for pwm15,
whose two times always had the same value, they identify the two bytes,
and which of them is the step up time follows from the layout of the
tables. Channels 10 and 11 have no fan header on this board. Times of
0.1, 0.2, 0.3, 0.7 and 1.0 seconds read as 0x01, 0x02, 0x03, 0x07 and
0x0a.

On pwm16, the duty cycle changed by one per step time while following
the curve with times of 300, 700 and 1000 ms, and by one per 200 ms
with 100 ms.

The attributes are read-only. Whether the EC uses a time written
outside the BIOS setup has not been checked.

Tested on the same board with two different sets of times in the BIOS
setup: all six fans with a curve (pwm1, pwm2 and pwm13 to pwm16)
reported the times set there.

Signed-off-by: Tomasz Bojanowski <tomasz@bojanowski.me>
---
The tests above were done with BIOS 1.A68. After updating to BIOS 1.A6A
(same EC firmware, build 03/10/25), I repeated the read test with one of
the two sets of times, with the same result.

I used an AI assistant (Claude Code) during development, including for
the test scripts and for comparing the EC register dumps. I reviewed all
of the changes, ran the tests on the hardware described above, and take
responsibility for them.

 Documentation/hwmon/nct6683.rst |  5 ++++
 drivers/hwmon/nct6683.c         | 44 +++++++++++++++++++++++++++++++--
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/Documentation/hwmon/nct6683.rst b/Documentation/hwmon/nct6683.rst
index d9ee2b02a26e..890b7153ab1a 100644
--- a/Documentation/hwmon/nct6683.rst
+++ b/Documentation/hwmon/nct6683.rst
@@ -78,6 +78,9 @@ is reported with the following attributes, if the curve sets a duty cycle:
   * pwmN_auto_point[1-7]_pwm: duty cycle of the curve point (0-255)
   * pwmN_auto_channels_temp: temperature channels used by the curve, as a
     bitmap (1 is temp1, 2 is temp2, 4 is temp3 etc.)
+  * pwmN_step_up_time: Step Up Time set in the BIOS setup, in milliseconds
+  * pwmN_step_down_time: Step Down Time set in the BIOS setup, in
+    milliseconds
 
 The fan curve is initially the one configured in the BIOS setup. A fan with
 Smart Fan disabled in the BIOS setup has a flat curve, with its fixed duty
@@ -108,6 +111,8 @@ not take the new temperature. It can be written in manual and in automatic
 mode. In manual mode, the new temperature is used after switching to
 automatic mode.
 
+pwmN_step_up_time and pwmN_step_down_time are read-only.
+
 The BIOS may restore its own settings when resuming from suspend, so the
 driver restores the curves written and the temperatures selected through
 it. They are kept when the driver is unloaded.
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index 36565afe8297..00cd9adc39ed 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -194,6 +194,12 @@ superio_exit(int ioreg)
 #define NCT6687DR_CURVE_MODE_PWM	0x40
 #define NCT6687DR_CURVE_TEMP_MAX	127	/* degrees Celsius */
 
+/* Step up and step down times of the fan curves, in tenths of a second */
+#define NCT6687DR_REG_STEP_UP(x)	(0x81a + (x))		/* channels 0-9 */
+#define NCT6687DR_REG_STEP_DOWN(x)	(0x824 + (x))		/* channels 0-9 */
+#define NCT6687DR_REG_STEP_UP_SYS(x)	(0xe7e + (x) - 10)	/* channels 10-15 */
+#define NCT6687DR_REG_STEP_DOWN_SYS(x)	(0xe84 + (x) - 10)	/* channels 10-15 */
+
 #define NCT6687DR_REG_FAN_ENGINE_STS	0xcf8
 #define NCT6687DR_FAN_ENGINE_PHASE	BIT(3)
 #define NCT6687DR_FAN_ENGINE_INVALID	BIT(4)
@@ -1580,6 +1586,31 @@ store_pwm_auto_channels_temp(struct device *dev, struct device_attribute *attr,
 	return err ? err : count;
 }
 
+/* Step times of the fan curves, read from the EC on each access */
+static ssize_t
+show_pwm_step_time(struct device *dev, struct device_attribute *attr,
+		   char *buf)
+{
+	struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
+	struct nct6683_data *data = dev_get_drvdata(dev);
+	int ch = sattr->nr;
+	u16 reg;
+	int val;
+
+	if (sattr->index)	/* step down */
+		reg = ch < 10 ? NCT6687DR_REG_STEP_DOWN(ch) :
+				NCT6687DR_REG_STEP_DOWN_SYS(ch);
+	else
+		reg = ch < 10 ? NCT6687DR_REG_STEP_UP(ch) :
+				NCT6687DR_REG_STEP_UP_SYS(ch);
+
+	mutex_lock(&data->update_lock);
+	val = nct6683_read(data, reg);
+	mutex_unlock(&data->update_lock);
+
+	return sysfs_emit(buf, "%d\n", val * 100);
+}
+
 SENSOR_TEMPLATE(pwm_auto_channels_temp, "pwm%d_auto_channels_temp", 0644,
 		show_pwm_auto_channels_temp, store_pwm_auto_channels_temp, 0);
 SENSOR_TEMPLATE_2(pwm_auto_point1_temp, "pwm%d_auto_point1_temp", 0644,
@@ -1610,9 +1641,16 @@ SENSOR_TEMPLATE_2(pwm_auto_point7_temp, "pwm%d_auto_point7_temp", 0644,
 		  show_pwm_auto_point_temp, store_pwm_auto_point_temp, 0, 6);
 SENSOR_TEMPLATE_2(pwm_auto_point7_pwm, "pwm%d_auto_point7_pwm", 0644,
 		  show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, 0, 6);
+SENSOR_TEMPLATE_2(pwm_step_up_time, "pwm%d_step_up_time", 0444,
+		  show_pwm_step_time, NULL, 0, 0);
+SENSOR_TEMPLATE_2(pwm_step_down_time, "pwm%d_step_down_time", 0444,
+		  show_pwm_step_time, NULL, 0, 1);
 
-/* pwm, pwm_enable, pwm_auto_channels_temp and the fan curve points */
-#define NCT6683_PWM_TEMPLATES	(3 + 2 * NCT6687DR_CURVE_POINTS)
+/*
+ * pwm, pwm_enable, pwm_auto_channels_temp, the fan curve points and the
+ * step times
+ */
+#define NCT6683_PWM_TEMPLATES	(5 + 2 * NCT6687DR_CURVE_POINTS)
 
 static umode_t nct6683_pwm_is_visible(struct kobject *kobj,
 				      struct attribute *attr, int index)
@@ -1668,6 +1706,8 @@ static struct sensor_device_template *nct6683_attributes_pwm_template[] = {
 	&sensor_dev_template_pwm_auto_point6_pwm,
 	&sensor_dev_template_pwm_auto_point7_temp,
 	&sensor_dev_template_pwm_auto_point7_pwm,
+	&sensor_dev_template_pwm_step_up_time,
+	&sensor_dev_template_pwm_step_down_time,
 	NULL
 };
 
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times
  2026-11-28 20:55 [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times Tomasz Bojanowski
  2026-11-28 20:55 ` [PATCH 1/2] hwmon: (nct6683) Document manual mode on unload and MSI-only fan curves Tomasz Bojanowski
  2026-11-28 20:55 ` [PATCH 2/2] hwmon: (nct6683) Report the step up and step down times of NCT6687D-R fans Tomasz Bojanowski
@ 2026-11-28 20:59 ` sashiko-bot
  2026-11-28 21:24 ` Tomasz Bojanowski
  3 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-28 20:59 UTC (permalink / raw)
  To: Tomasz Bojanowski; +Cc: linux-hwmon

Sashiko has reviewed this 2-patch series and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128205511.177514-1-tomasz@bojanowski.me

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times
  2026-11-28 20:55 [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times Tomasz Bojanowski
                   ` (2 preceding siblings ...)
  2026-11-28 20:59 ` [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times sashiko-bot
@ 2026-11-28 21:24 ` Tomasz Bojanowski
  3 siblings, 0 replies; 7+ messages in thread
From: Tomasz Bojanowski @ 2026-11-28 21:24 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-hwmon, Hamza Mahfooz, Jonathan Corbet, Shuah Khan,
	Randy Dunlap, linux-doc, linux-kernel

A clarification to the cover letter: the reported times are the ones the EC
is configured with, not always the ones it applies. On pwm16 the duty cycle
changed by one per configured time at 300, 700 and 1000 ms, but by one per
200 ms when the time was set to 100 ms. The description of patch 2/2 gives
these measurements.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] hwmon: (nct6683) Document manual mode on unload and MSI-only fan curves
  2026-11-28 20:55 ` [PATCH 1/2] hwmon: (nct6683) Document manual mode on unload and MSI-only fan curves Tomasz Bojanowski
@ 2026-11-29  0:33   ` Guenter Roeck
  0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2026-11-29  0:33 UTC (permalink / raw)
  To: Tomasz Bojanowski
  Cc: linux-hwmon, Hamza Mahfooz, Jonathan Corbet, Shuah Khan,
	Randy Dunlap, linux-doc, linux-kernel

On Sat, Nov 28, 2026 at 09:55:10PM +0100, Tomasz Bojanowski wrote:
> The fan control documentation has not kept up with two recent changes:
> 
> - Fan control was enabled on ASRock boards, which have pwmN_enable but
>   no fan curve attributes. The documentation still says that the curve
>   of each fan with a pwmN_enable attribute is reported.
> - Fans set to manual mode through the driver are now switched back to
>   automatic mode when the driver is unloaded. The documentation only
>   says that the curves are kept.
> 
> Update both.
> 
> Signed-off-by: Tomasz Bojanowski <tomasz@bojanowski.me>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] hwmon: (nct6683) Report the step up and step down times of NCT6687D-R fans
  2026-11-28 20:55 ` [PATCH 2/2] hwmon: (nct6683) Report the step up and step down times of NCT6687D-R fans Tomasz Bojanowski
@ 2026-11-29  0:34   ` Guenter Roeck
  0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2026-11-29  0:34 UTC (permalink / raw)
  To: Tomasz Bojanowski
  Cc: linux-hwmon, Hamza Mahfooz, Jonathan Corbet, Shuah Khan,
	Randy Dunlap, linux-doc, linux-kernel

On Sat, Nov 28, 2026 at 09:55:11PM +0100, Tomasz Bojanowski wrote:
> On MSI boards with an NCT6687D-R (customer ID 0x20d), the BIOS setup
> offers a Step Up Time and a Step Down Time for each fan. Report them as
> pwmN_step_up_time and pwmN_step_down_time, in milliseconds as the
> nct6775 driver does, for the fans whose curve is reported.
> 
> The EC holds the times in tenths of a second, in tables indexed by
> channel: 0x81a + n (step up) and 0x824 + n (step down) for channels 0-9,
> 0xe7e + n - 10 (step up) and 0xe84 + n - 10 (step down) for channels
> 10-15. This was found on an MSI MAG B850M MORTAR WIFI (MS-7E61) by
> changing the times in the BIOS setup and reading the EC before and
> after. Each changed time changed one byte in these tables, and setting
> the times back restored them. Taken together, the readings identify the
> byte of each time of pwm1, pwm2, pwm13, pwm14 and pwm16; for pwm15,
> whose two times always had the same value, they identify the two bytes,
> and which of them is the step up time follows from the layout of the
> tables. Channels 10 and 11 have no fan header on this board. Times of
> 0.1, 0.2, 0.3, 0.7 and 1.0 seconds read as 0x01, 0x02, 0x03, 0x07 and
> 0x0a.
> 
> On pwm16, the duty cycle changed by one per step time while following
> the curve with times of 300, 700 and 1000 ms, and by one per 200 ms
> with 100 ms.
> 
> The attributes are read-only. Whether the EC uses a time written
> outside the BIOS setup has not been checked.
> 
> Tested on the same board with two different sets of times in the BIOS
> setup: all six fans with a curve (pwm1, pwm2 and pwm13 to pwm16)
> reported the times set there.
> 
> Signed-off-by: Tomasz Bojanowski <tomasz@bojanowski.me>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-29  0:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 20:55 [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times Tomasz Bojanowski
2026-11-28 20:55 ` [PATCH 1/2] hwmon: (nct6683) Document manual mode on unload and MSI-only fan curves Tomasz Bojanowski
2026-11-29  0:33   ` Guenter Roeck
2026-11-28 20:55 ` [PATCH 2/2] hwmon: (nct6683) Report the step up and step down times of NCT6687D-R fans Tomasz Bojanowski
2026-11-29  0:34   ` Guenter Roeck
2026-11-28 20:59 ` [PATCH 0/2] hwmon: (nct6683) document unload behaviour, report fan step times sashiko-bot
2026-11-28 21:24 ` Tomasz Bojanowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox