* [PATCH v2 0/7] hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards
@ 2026-11-11 8:28 Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 1/7] hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi Johan Dahlin
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Johan Dahlin @ 2026-11-11 8:28 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-hwmon, linux-kernel, Alwyn Kik, Fabio Baltieri,
Hamza Mahfooz, Johan Dahlin
Add the ASRock B850 Steel Legend WiFi (NCT6686D, customer ID 0x164a) to
the nct6683 driver and enable fan control on it, reusing the NCT6687D-R
fan control that landed in hwmon-next since v1.
Changes in v2:
- Rebased on hwmon-next; use the NCT6687D-R fan control path and
have_fan_ctrl (Guenter)
- Dropped the pwm_enable and pwm write retry patches, both in hwmon-next
- Restore automatic mode on removal through the fan control path
- Added the ASRock BC-250 (Fabio Baltieri), needs a re-test on the new path
- Added sensor names, fan header names and +5V/+12V scaling as separate
patches; the M/B thermistor and the fan header order are inferred, and
the scaling patch can be dropped in favour of sensors.conf
- The struct cast flagged by Sashiko was fixed in hwmon-next (c4a01c2a80b2)
- Kept Alwyn Kik's Tested-by on the unchanged patch 1
- Link to v1: https://lore.kernel.org/linux-hwmon/20260825092546.669450-1-jdahlin@gmail.com/
Johan Dahlin (7):
hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi
hwmon: (nct6683) Restore automatic fan control on driver removal
hwmon: (nct6683) Enable fan control on ASRock B850 Steel Legend WiFi
hwmon: (nct6683) Enable fan control on ASRock BC-250
hwmon: (nct6683) Name the sensors of the ASRock B850 Steel Legend WiFi
hwmon: (nct6683) Name the fan headers of the ASRock B850 Steel Legend
WiFi
hwmon: (nct6683) Scale the +5V and +12V inputs of the ASRock B850
Steel Legend WiFi
Documentation/hwmon/nct6683.rst | 10 +++
drivers/hwmon/nct6683.c | 140 ++++++++++++++++++++++++++++++--
2 files changed, 144 insertions(+), 6 deletions(-)
base-commit: 44c8ceae2dd3ae536c5f4f956cedb24c157aac23
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/7] hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi
2026-11-11 8:28 [PATCH v2 0/7] hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards Johan Dahlin
@ 2026-11-11 8:28 ` Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 2/7] hwmon: (nct6683) Restore automatic fan control on driver removal Johan Dahlin
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Johan Dahlin @ 2026-11-11 8:28 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-hwmon, linux-kernel, Alwyn Kik, Fabio Baltieri,
Hamza Mahfooz, Johan Dahlin
The ASRock B850 Steel Legend WiFi has an NCT6686D with customer ID
0x164a, so the driver only probes on it with the force module parameter.
Add the customer ID so the driver probes on this board by default.
Signed-off-by: Johan Dahlin <jdahlin@gmail.com>
Tested-by: Alwyn Kik <alwyn@kik.pw>
---
Documentation/hwmon/nct6683.rst | 1 +
drivers/hwmon/nct6683.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/Documentation/hwmon/nct6683.rst b/Documentation/hwmon/nct6683.rst
index 62da8fd011c8..4c137eda6583 100644
--- a/Documentation/hwmon/nct6683.rst
+++ b/Documentation/hwmon/nct6683.rst
@@ -97,6 +97,7 @@ ASRock X570 NCT6683D EC firmware version 1.0 build 06/28/19
ASRock X670E NCT6686D EC firmware version 1.0 build 05/19/22
ASRock B650 Steel Legend WiFi NCT6686D EC firmware version 1.0 build 11/09/23
ASRock Z590 Taichi NCT6686D EC firmware version 1.0 build 01/25/21
+ASRock B850 Steel Legend WiFi NCT6686D EC firmware version 1.0 build 10/29/24
MSI B550 NCT6687D EC firmware version 1.0 build 05/07/20
MSI B550M NCT6687D EC firmware version 1.0 build 05/07/20
MSI B650 NCT6687D EC firmware version 0.0 build 09/27/22
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index de5b0194c256..0565ca9290eb 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -209,6 +209,7 @@ superio_exit(int ioreg)
#define NCT6683_CUSTOMER_ID_ASROCK5 0x1621
#define NCT6683_CUSTOMER_ID_ASROCK6 0x1633
#define NCT6683_CUSTOMER_ID_ASROCK7 0x163d
+#define NCT6683_CUSTOMER_ID_ASROCK8 0x164a
#define NCT6683_REG_BUILD_YEAR 0x604
#define NCT6683_REG_BUILD_MONTH 0x605
@@ -1640,6 +1641,8 @@ static int nct6683_probe(struct platform_device *pdev)
break;
case NCT6683_CUSTOMER_ID_ASROCK7:
break;
+ case NCT6683_CUSTOMER_ID_ASROCK8:
+ break;
default:
if (!force)
return -ENODEV;
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/7] hwmon: (nct6683) Restore automatic fan control on driver removal
2026-11-11 8:28 [PATCH v2 0/7] hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 1/7] hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi Johan Dahlin
@ 2026-11-11 8:28 ` Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 3/7] hwmon: (nct6683) Enable fan control on ASRock B850 Steel Legend WiFi Johan Dahlin
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Johan Dahlin @ 2026-11-11 8:28 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-hwmon, linux-kernel, Alwyn Kik, Fabio Baltieri,
Hamza Mahfooz, Johan Dahlin
A fan switched to manual mode through pwmN_enable keeps its last duty
cycle after the driver is unloaded, with nothing left to adjust it.
Return the channels the driver switched to manual mode to automatic mode
when the device is removed, using the bitmap kept for resume. Other
channels are not touched.
Signed-off-by: Johan Dahlin <jdahlin@gmail.com>
---
drivers/hwmon/nct6683.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index 0565ca9290eb..d43dcf90048b 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -1584,6 +1584,32 @@ static void nct6683_setup_sensors(struct nct6683_data *data)
}
}
+/*
+ * Hand the fans the driver switched to manual mode back to the EC, so that
+ * they do not stay at a fixed duty cycle once nobody is left to adjust it.
+ */
+static void nct6683_restore_fan_control(void *_dev)
+{
+ struct device *dev = _dev;
+ struct nct6683_data *data = dev_get_drvdata(dev);
+ unsigned long manual;
+ int ch, err;
+
+ mutex_lock(&data->update_lock);
+ manual = data->pwm_manual;
+ for_each_set_bit(ch, &manual, NCT6683_NUM_REG_FAN) {
+ err = nct6683_fan_ctrl_update(data, ch, false, -1);
+ if (err) {
+ dev_warn(dev, "Failed to restore automatic mode of pwm%d: %d\n",
+ ch + 1, err);
+ /* The EC does not respond, skip the remaining channels */
+ if (err == -ETIMEDOUT)
+ break;
+ }
+ }
+ mutex_unlock(&data->update_lock);
+}
+
static int nct6683_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -1593,6 +1619,7 @@ static int nct6683_probe(struct platform_device *pdev)
struct device *hwmon_dev;
struct resource *res;
int groups = 0;
+ int err;
char build[16];
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
@@ -1710,6 +1737,13 @@ static int nct6683_probe(struct platform_device *pdev)
nct6683_read(data, NCT6683_REG_VERSION_LO),
build);
+ if (data->have_fan_ctrl) {
+ err = devm_add_action_or_reset(dev, nct6683_restore_fan_control,
+ dev);
+ if (err)
+ return err;
+ }
+
hwmon_dev = devm_hwmon_device_register_with_groups(dev,
nct6683_device_names[data->kind], data, data->groups);
return PTR_ERR_OR_ZERO(hwmon_dev);
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 3/7] hwmon: (nct6683) Enable fan control on ASRock B850 Steel Legend WiFi
2026-11-11 8:28 [PATCH v2 0/7] hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 1/7] hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 2/7] hwmon: (nct6683) Restore automatic fan control on driver removal Johan Dahlin
@ 2026-11-11 8:28 ` Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 4/7] hwmon: (nct6683) Enable fan control on ASRock BC-250 Johan Dahlin
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Johan Dahlin @ 2026-11-11 8:28 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-hwmon, linux-kernel, Alwyn Kik, Fabio Baltieri,
Hamza Mahfooz, Johan Dahlin
The NCT6686D on the ASRock B850 Steel Legend WiFi (customer ID 0x164a)
uses the same fan mode register and configuration phase as the NCT6687D-R
on MSI boards.
Enable fan control for channels 0 to 7 on this board.
Tested with pwm6_enable set to 1: pwm6 written as 255, 120 and 60 gives
803, 577 and 342 RPM on fan6. Writing 2 returns the fan to the BIOS
curve, and so does unloading the driver.
Signed-off-by: Johan Dahlin <jdahlin@gmail.com>
---
Documentation/hwmon/nct6683.rst | 4 ++++
drivers/hwmon/nct6683.c | 3 +++
2 files changed, 7 insertions(+)
diff --git a/Documentation/hwmon/nct6683.rst b/Documentation/hwmon/nct6683.rst
index 4c137eda6583..026515c35243 100644
--- a/Documentation/hwmon/nct6683.rst
+++ b/Documentation/hwmon/nct6683.rst
@@ -57,6 +57,10 @@ Fan control is supported on MSI boards with an NCT6687D-R (customer ID
pwm16 control the system fan headers that are present. pwmN controls the
fan reported by fanN_input.
+It is also supported on the ASRock B850 Steel Legend WiFi (NCT6686D,
+customer ID 0x164a), where pwm1 to pwm6 control the fan headers reported
+by fan1 to fan6.
+
pwmN_enable selects the fan control mode:
* 1: manual mode, the duty cycle is set with pwmN
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index d43dcf90048b..29fbf438c04c 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -1539,6 +1539,9 @@ nct6683_setup_fans(struct nct6683_data *data)
data->have_curve |= BIT(i);
}
}
+
+ if (data->customer_id == NCT6683_CUSTOMER_ID_ASROCK8)
+ data->have_fan_ctrl = data->have_pwm & GENMASK(7, 0);
}
/*
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 4/7] hwmon: (nct6683) Enable fan control on ASRock BC-250
2026-11-11 8:28 [PATCH v2 0/7] hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards Johan Dahlin
` (2 preceding siblings ...)
2026-11-11 8:28 ` [PATCH v2 3/7] hwmon: (nct6683) Enable fan control on ASRock B850 Steel Legend WiFi Johan Dahlin
@ 2026-11-11 8:28 ` Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 5/7] hwmon: (nct6683) Name the sensors of the ASRock B850 Steel Legend WiFi Johan Dahlin
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Johan Dahlin @ 2026-11-11 8:28 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-hwmon, linux-kernel, Alwyn Kik, Fabio Baltieri,
Hamza Mahfooz, Johan Dahlin
The ASRock BC-250 (customer ID 0x162b) has an NCT6686D with the same fan
control registers as the B850 Steel Legend WiFi, and manual fan control
was reported to work there.
Enable fan control for channels 0 to 7 on this board as well.
Suggested-by: Fabio Baltieri <fabio.baltieri@gmail.com>
Signed-off-by: Johan Dahlin <jdahlin@gmail.com>
---
Documentation/hwmon/nct6683.rst | 2 +-
drivers/hwmon/nct6683.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/hwmon/nct6683.rst b/Documentation/hwmon/nct6683.rst
index 026515c35243..8e5cd1d7dcd2 100644
--- a/Documentation/hwmon/nct6683.rst
+++ b/Documentation/hwmon/nct6683.rst
@@ -59,7 +59,7 @@ fan reported by fanN_input.
It is also supported on the ASRock B850 Steel Legend WiFi (NCT6686D,
customer ID 0x164a), where pwm1 to pwm6 control the fan headers reported
-by fan1 to fan6.
+by fan1 to fan6, and on the ASRock BC-250 (NCT6686D, customer ID 0x162b).
pwmN_enable selects the fan control mode:
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index 29fbf438c04c..f656b84ee8ac 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -1540,7 +1540,8 @@ nct6683_setup_fans(struct nct6683_data *data)
}
}
- if (data->customer_id == NCT6683_CUSTOMER_ID_ASROCK8)
+ if (data->customer_id == NCT6683_CUSTOMER_ID_ASROCK8 ||
+ data->customer_id == NCT6683_CUSTOMER_ID_AMD)
data->have_fan_ctrl = data->have_pwm & GENMASK(7, 0);
}
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 5/7] hwmon: (nct6683) Name the sensors of the ASRock B850 Steel Legend WiFi
2026-11-11 8:28 [PATCH v2 0/7] hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards Johan Dahlin
` (3 preceding siblings ...)
2026-11-11 8:28 ` [PATCH v2 4/7] hwmon: (nct6683) Enable fan control on ASRock BC-250 Johan Dahlin
@ 2026-11-11 8:28 ` Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 6/7] hwmon: (nct6683) Name the fan headers " Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 7/7] hwmon: (nct6683) Scale the +5V and +12V inputs " Johan Dahlin
6 siblings, 0 replies; 8+ messages in thread
From: Johan Dahlin @ 2026-11-11 8:28 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-hwmon, linux-kernel, Alwyn Kik, Fabio Baltieri,
Hamza Mahfooz, Johan Dahlin
The inputs are labeled after the monitoring source of the EC, such as
"Thermistor 14" or "VIN5", which says nothing about what they measure.
The UEFI setup of this board names them on its H/W Monitor page.
Add a per-board table of sensor names keyed on the monitoring source and
fill it in for the ASRock B850 Steel Legend WiFi. Sources without an
entry keep their generic name.
The CPU temperature matches k10temp and the voltages match their nominal
values. Which thermistor is the M/B one was inferred from the readings.
Signed-off-by: Johan Dahlin <jdahlin@gmail.com>
---
Documentation/hwmon/nct6683.rst | 3 ++
drivers/hwmon/nct6683.c | 53 +++++++++++++++++++++++++++++++--
2 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/Documentation/hwmon/nct6683.rst b/Documentation/hwmon/nct6683.rst
index 8e5cd1d7dcd2..a9c53d6eab9c 100644
--- a/Documentation/hwmon/nct6683.rst
+++ b/Documentation/hwmon/nct6683.rst
@@ -61,6 +61,9 @@ It is also supported on the ASRock B850 Steel Legend WiFi (NCT6686D,
customer ID 0x164a), where pwm1 to pwm6 control the fan headers reported
by fan1 to fan6, and on the ASRock BC-250 (NCT6686D, customer ID 0x162b).
+On the ASRock B850 Steel Legend WiFi the temperature and voltage inputs
+are named after the H/W Monitor page of the BIOS setup.
+
pwmN_enable selects the fan control mode:
* 1: manual mode, the duty cycle is set with pwmN
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index f656b84ee8ac..4fcd0c74af44 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -328,6 +328,32 @@ static const char *const nct6683_mon_label[] = {
#define NUM_MON_LABELS ARRAY_SIZE(nct6683_mon_label)
#define MON_VOLTAGE_START 0x60
+/* Board specific names for the monitoring sources */
+struct nct6683_mon_desc {
+ u8 src; /* index into nct6683_mon_label */
+ const char *label;
+};
+
+/*
+ * ASRock B850 Steel Legend WiFi, named after the "H/W Monitor" page of the
+ * UEFI setup (BIOS 4.10). T_SENSOR1 is the thermistor cable header, see the
+ * ASRock B850 Steel Legend WiFi User Manual, section 2.12 "Onboard Headers
+ * and Connectors", page 49.
+ */
+static const struct nct6683_mon_desc asrock_b850sl_mon_desc[] = {
+ { 0x08, "M/B" }, /* Thermistor 14 */
+ { 0x0a, "T_SENSOR1" }, /* Thermistor 16 */
+ { 0x46, "CPU" }, /* AMD TSI Addr 98h */
+ { 0x60, "+3.3V" }, /* VCC */
+ { 0x66, "CPU Vcore" }, /* VIN0 */
+ { 0x69, "+5V" }, /* VIN3 */
+ { 0x6b, "VDDCR_SOC" }, /* VIN5 */
+ { 0x6c, "VDD_MISC" }, /* VIN6 */
+ { 0x6d, "DRAM" }, /* VIN7 */
+ { 0x76, "+12V" }, /* VIN16 */
+ { }
+};
+
/* ------------------------------------------------------- */
struct nct6683_data {
@@ -347,6 +373,9 @@ struct nct6683_data {
u8 in_index[NCT6683_NUM_REG_MON];
u8 in_src[NCT6683_NUM_REG_MON];
+ /* Board specific sensor names, NULL if none */
+ const struct nct6683_mon_desc *mon_desc;
+
struct mutex update_lock; /* used to protect sensor updates */
bool valid; /* true if following fields are valid */
u64 last_updated; /* In jiffies */
@@ -524,6 +553,25 @@ static inline long in_from_reg(u8 reg)
return reg * 16;
}
+static const struct nct6683_mon_desc *
+nct6683_find_mon_desc(struct nct6683_data *data, u8 src)
+{
+ const struct nct6683_mon_desc *desc;
+
+ for (desc = data->mon_desc; desc && desc->label; desc++)
+ if (desc->src == src)
+ return desc;
+
+ return NULL;
+}
+
+static const char *nct6683_mon_name(struct nct6683_data *data, u8 src)
+{
+ const struct nct6683_mon_desc *desc = nct6683_find_mon_desc(data, src);
+
+ return desc ? desc->label : nct6683_mon_label[src];
+}
+
static u16 nct6683_read(struct nct6683_data *data, u16 reg)
{
int res;
@@ -694,7 +742,7 @@ show_in_label(struct device *dev, struct device_attribute *attr, char *buf)
struct nct6683_data *data = nct6683_update_device(dev);
int nr = sattr->index;
- return sprintf(buf, "%s\n", nct6683_mon_label[data->in_src[nr]]);
+ return sprintf(buf, "%s\n", nct6683_mon_name(data, data->in_src[nr]));
}
static ssize_t
@@ -824,7 +872,7 @@ show_temp_label(struct device *dev, struct device_attribute *attr, char *buf)
struct nct6683_data *data = nct6683_update_device(dev);
int nr = sattr->index;
- return sprintf(buf, "%s\n", nct6683_mon_label[data->temp_src[nr]]);
+ return sprintf(buf, "%s\n", nct6683_mon_name(data, data->temp_src[nr]));
}
static ssize_t
@@ -1673,6 +1721,7 @@ static int nct6683_probe(struct platform_device *pdev)
case NCT6683_CUSTOMER_ID_ASROCK7:
break;
case NCT6683_CUSTOMER_ID_ASROCK8:
+ data->mon_desc = asrock_b850sl_mon_desc;
break;
default:
if (!force)
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 6/7] hwmon: (nct6683) Name the fan headers of the ASRock B850 Steel Legend WiFi
2026-11-11 8:28 [PATCH v2 0/7] hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards Johan Dahlin
` (4 preceding siblings ...)
2026-11-11 8:28 ` [PATCH v2 5/7] hwmon: (nct6683) Name the sensors of the ASRock B850 Steel Legend WiFi Johan Dahlin
@ 2026-11-11 8:28 ` Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 7/7] hwmon: (nct6683) Scale the +5V and +12V inputs " Johan Dahlin
6 siblings, 0 replies; 8+ messages in thread
From: Johan Dahlin @ 2026-11-11 8:28 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-hwmon, linux-kernel, Alwyn Kik, Fabio Baltieri,
Hamza Mahfooz, Johan Dahlin
With fan control available, users need to know which pwm channel drives
which header. The driver has no fan labels.
Add a fanN_label attribute, visible on boards with a name table, and name
the channels of the ASRock B850 Steel Legend WiFi after the headers
printed on the board: CPU_FAN1, CPU_FAN2, AIO_PUMP and CHA_FAN1 to
CHA_FAN3. The order was inferred from the readings and the BIOS defaults.
Signed-off-by: Johan Dahlin <jdahlin@gmail.com>
---
Documentation/hwmon/nct6683.rst | 3 ++-
drivers/hwmon/nct6683.c | 32 ++++++++++++++++++++++++++++++--
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/Documentation/hwmon/nct6683.rst b/Documentation/hwmon/nct6683.rst
index a9c53d6eab9c..c8b8ade3b95b 100644
--- a/Documentation/hwmon/nct6683.rst
+++ b/Documentation/hwmon/nct6683.rst
@@ -62,7 +62,8 @@ customer ID 0x164a), where pwm1 to pwm6 control the fan headers reported
by fan1 to fan6, and on the ASRock BC-250 (NCT6686D, customer ID 0x162b).
On the ASRock B850 Steel Legend WiFi the temperature and voltage inputs
-are named after the H/W Monitor page of the BIOS setup.
+are named after the H/W Monitor page of the BIOS setup, and fanN_label
+names the fan header each channel is wired to.
pwmN_enable selects the fan control mode:
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index 4fcd0c74af44..dcad72d1ef97 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -354,6 +354,15 @@ static const struct nct6683_mon_desc asrock_b850sl_mon_desc[] = {
{ }
};
+/*
+ * Fan headers as printed on the board, see the ASRock B850 Steel Legend WiFi
+ * User Manual, section 1.3 "Motherboard Layout", page 7, and section 2.12
+ * "Onboard Headers and Connectors", pages 44 to 46.
+ */
+static const char * const asrock_b850sl_fan_label[] = {
+ "CPU_FAN1", "CPU_FAN2", "AIO_PUMP", "CHA_FAN1", "CHA_FAN2", "CHA_FAN3",
+};
+
/* ------------------------------------------------------- */
struct nct6683_data {
@@ -375,6 +384,8 @@ struct nct6683_data {
/* Board specific sensor names, NULL if none */
const struct nct6683_mon_desc *mon_desc;
+ const char * const *fan_label;
+ int num_fan_label;
struct mutex update_lock; /* used to protect sensor updates */
bool valid; /* true if following fields are valid */
@@ -822,17 +833,30 @@ show_fan_pulses(struct device *dev, struct device_attribute *attr, char *buf)
((data->fanin_cfg[sattr->index] >> 5) & 0x03) + 1);
}
+static ssize_t
+show_fan_label(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
+ struct nct6683_data *data = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%s\n", data->fan_label[sattr->index]);
+}
+
static umode_t nct6683_fan_is_visible(struct kobject *kobj,
struct attribute *attr, int index)
{
struct device *dev = kobj_to_dev(kobj);
struct nct6683_data *data = dev_get_drvdata(dev);
- int fan = index / 3; /* fan index */
- int nr = index % 3; /* attribute index */
+ int fan = index / 4; /* fan index */
+ int nr = index % 4; /* attribute index */
if (!(data->have_fan & (1 << fan)))
return 0;
+ /* Fan names are only known for some boards */
+ if (nr == 3 && fan >= data->num_fan_label)
+ return 0;
+
/*
* Intel may have minimum fan speed limits,
* but register location and encoding are unknown.
@@ -846,6 +870,7 @@ static umode_t nct6683_fan_is_visible(struct kobject *kobj,
SENSOR_TEMPLATE(fan_input, "fan%d_input", S_IRUGO, show_fan, NULL, 0);
SENSOR_TEMPLATE(fan_pulses, "fan%d_pulses", S_IRUGO, show_fan_pulses, NULL, 0);
SENSOR_TEMPLATE(fan_min, "fan%d_min", S_IRUGO, show_fan_min, NULL, 0);
+SENSOR_TEMPLATE(fan_label, "fan%d_label", 0444, show_fan_label, NULL, 0);
/*
* nct6683_fan_is_visible uses the index into the following array
@@ -856,6 +881,7 @@ static struct sensor_device_template *nct6683_attributes_fan_template[] = {
&sensor_dev_template_fan_input,
&sensor_dev_template_fan_pulses,
&sensor_dev_template_fan_min,
+ &sensor_dev_template_fan_label,
NULL
};
@@ -1722,6 +1748,8 @@ static int nct6683_probe(struct platform_device *pdev)
break;
case NCT6683_CUSTOMER_ID_ASROCK8:
data->mon_desc = asrock_b850sl_mon_desc;
+ data->fan_label = asrock_b850sl_fan_label;
+ data->num_fan_label = ARRAY_SIZE(asrock_b850sl_fan_label);
break;
default:
if (!force)
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 7/7] hwmon: (nct6683) Scale the +5V and +12V inputs of the ASRock B850 Steel Legend WiFi
2026-11-11 8:28 [PATCH v2 0/7] hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards Johan Dahlin
` (5 preceding siblings ...)
2026-11-11 8:28 ` [PATCH v2 6/7] hwmon: (nct6683) Name the fan headers " Johan Dahlin
@ 2026-11-11 8:28 ` Johan Dahlin
6 siblings, 0 replies; 8+ messages in thread
From: Johan Dahlin @ 2026-11-11 8:28 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-hwmon, linux-kernel, Alwyn Kik, Fabio Baltieri,
Hamza Mahfooz, Johan Dahlin
The +5V and +12V rails reach the chip through resistor dividers, so they
read as 1.70 V and 2.03 V while the UEFI setup shows 5.04 V and 12.19 V.
Let the sensor table carry a divider ratio and apply it when reading the
input, with ratios of 3 and 6 on this board. sysfs-interface.rst asks for
such conversions in user space because dividers differ between boards.
Here the board is identified by its customer ID, so the ratios are fixed.
Signed-off-by: Johan Dahlin <jdahlin@gmail.com>
---
Documentation/hwmon/nct6683.rst | 3 ++-
drivers/hwmon/nct6683.c | 20 +++++++++++++++-----
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/Documentation/hwmon/nct6683.rst b/Documentation/hwmon/nct6683.rst
index c8b8ade3b95b..17fba35bf9bb 100644
--- a/Documentation/hwmon/nct6683.rst
+++ b/Documentation/hwmon/nct6683.rst
@@ -63,7 +63,8 @@ by fan1 to fan6, and on the ASRock BC-250 (NCT6686D, customer ID 0x162b).
On the ASRock B850 Steel Legend WiFi the temperature and voltage inputs
are named after the H/W Monitor page of the BIOS setup, and fanN_label
-names the fan header each channel is wired to.
+names the fan header each channel is wired to. The +5V and +12V inputs
+report the rail voltage rather than the divided voltage seen by the chip.
pwmN_enable selects the fan control mode:
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index dcad72d1ef97..9a306728ee84 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -328,10 +328,14 @@ static const char *const nct6683_mon_label[] = {
#define NUM_MON_LABELS ARRAY_SIZE(nct6683_mon_label)
#define MON_VOLTAGE_START 0x60
-/* Board specific names for the monitoring sources */
+/*
+ * Board specific names for the monitoring sources, and the ratio of the
+ * resistor divider in front of a voltage input.
+ */
struct nct6683_mon_desc {
u8 src; /* index into nct6683_mon_label */
const char *label;
+ u8 scale; /* voltage divider ratio, 0 if none */
};
/*
@@ -346,11 +350,11 @@ static const struct nct6683_mon_desc asrock_b850sl_mon_desc[] = {
{ 0x46, "CPU" }, /* AMD TSI Addr 98h */
{ 0x60, "+3.3V" }, /* VCC */
{ 0x66, "CPU Vcore" }, /* VIN0 */
- { 0x69, "+5V" }, /* VIN3 */
+ { 0x69, "+5V", 3 }, /* VIN3 */
{ 0x6b, "VDDCR_SOC" }, /* VIN5 */
{ 0x6c, "VDD_MISC" }, /* VIN6 */
{ 0x6d, "DRAM" }, /* VIN7 */
- { 0x76, "+12V" }, /* VIN16 */
+ { 0x76, "+12V", 6 }, /* VIN16 */
{ }
};
@@ -761,11 +765,17 @@ show_in_reg(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 = nct6683_update_device(dev);
+ const struct nct6683_mon_desc *desc;
int index = sattr->index;
int nr = sattr->nr;
+ long val = in_from_reg(data->in[index][nr]);
+
+ /* Report the rail voltage for inputs behind a resistor divider */
+ desc = nct6683_find_mon_desc(data, data->in_src[nr]);
+ if (desc && desc->scale)
+ val *= desc->scale;
- return sprintf(buf, "%ld\n",
- in_from_reg(data->in[index][nr]));
+ return sprintf(buf, "%ld\n", val);
}
static umode_t nct6683_in_is_visible(struct kobject *kobj,
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-11 8:28 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 8:28 [PATCH v2 0/7] hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 1/7] hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 2/7] hwmon: (nct6683) Restore automatic fan control on driver removal Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 3/7] hwmon: (nct6683) Enable fan control on ASRock B850 Steel Legend WiFi Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 4/7] hwmon: (nct6683) Enable fan control on ASRock BC-250 Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 5/7] hwmon: (nct6683) Name the sensors of the ASRock B850 Steel Legend WiFi Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 6/7] hwmon: (nct6683) Name the fan headers " Johan Dahlin
2026-11-11 8:28 ` [PATCH v2 7/7] hwmon: (nct6683) Scale the +5V and +12V inputs " Johan Dahlin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®