[PATCH v2 6/7] hwmon: (nct6683) Name the fan headers of the ASRock B850 Steel Legend WiFi
From: Johan Dahlin
Date: Wed Nov 11 2026 - 03:35:56 EST
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@xxxxxxxxx>
---
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