[PATCH 2/2] hwmon: (nct6683) Report the step up and step down times of NCT6687D-R fans

From: Tomasz Bojanowski

Date: Sat Nov 28 2026 - 15:55:34 EST


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@xxxxxxxxxxxxx>
---
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