hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards
Subsystems (2)
v2 cover hwmon: (nct6683) Fan control and sensor names for ASRock NCT6686D boards
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/[email protected]/
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
Signature · 1 line
2.53.0
PATCH v2 1/7 hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi
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.
--- Documentation/hwmon/nct6683.rst | 1 + drivers/hwmon/nct6683.c | 3 +++ 2 files changed, 4 insertions(+)
Documentation/hwmon/nct6683.rst +1 -0
@@ -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
drivers/hwmon/nct6683.c +3 -0
@@ -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 ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 1/7] hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines
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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2 1/7] hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi
In reply to Johan DahlinQuoted 8 lines · 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 <[email protected]>Tested-by Alwyn Kik <[email protected]>---
Applied.
Thanks,
Guenter
PATCH v2 2/7 hwmon: (nct6683) Restore automatic fan control on driver removal
In reply to Johan DahlinA 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.
--- drivers/hwmon/nct6683.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/hwmon/nct6683.c +34 -0
@@ -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);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 2/7] hwmon: (nct6683) Restore automatic fan control on driver removal
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
A fan switched to manual mode through
pwmN_enablekeeps 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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v2 2/7] hwmon: (nct6683) Restore automatic fan control on driver removal
In reply to Johan DahlinQuoted 8 lines · Johan Dahlin
A fan switched to manual mode through
pwmN_enablekeeps 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 <[email protected]>
Applied.
Thanks,
Geunter
PATCH v2 3/7 hwmon: (nct6683) Enable fan control on ASRock B850 Steel Legend WiFi
In reply to Johan DahlinThe 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.
--- Documentation/hwmon/nct6683.rst | 4 ++++ drivers/hwmon/nct6683.c | 3 +++ 2 files changed, 7 insertions(+)
Documentation/hwmon/nct6683.rst +4 -0
@@ -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
drivers/hwmon/nct6683.c +3 -0
@@ -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 ); }/*
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 3/7] hwmon: (nct6683) Enable fan control on ASRock B850 Steel Legend WiFi
Sashiko has reviewed this patch and found no issues.
Quoted 11 lines
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_enableset 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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v2 3/7] hwmon: (nct6683) Enable fan control on ASRock B850 Steel Legend WiFi
In reply to Johan DahlinQuoted 11 lines · 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_enableset 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 <[email protected]>
Applied.
Thanks,
Guenter
PATCH v2 4/7 hwmon: (nct6683) Enable fan control on ASRock BC-250
In reply to Johan DahlinThe 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.
--- Documentation/hwmon/nct6683.rst | 2 +- drivers/hwmon/nct6683.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
Documentation/hwmon/nct6683.rst +1 -1
@@ -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:
drivers/hwmon/nct6683.c +2 -1
@@ -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 ); }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 4/7] hwmon: (nct6683) Enable fan control on ASRock BC-250
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
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 <[email protected]>Signed-off-by Johan Dahlin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v2 4/7] hwmon: (nct6683) Enable fan control on ASRock BC-250
In reply to Johan DahlinQuoted 8 lines · 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 <[email protected]>Signed-off-by Johan Dahlin <[email protected]>
Applied.
Thanks,
Guenter
PATCH v2 5/7 hwmon: (nct6683) Name the sensors of the ASRock B850 Steel Legend WiFi
In reply to Johan DahlinThe 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.
--- Documentation/hwmon/nct6683.rst | 3 ++ drivers/hwmon/nct6683.c | 53 +++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-)
Documentation/hwmon/nct6683.rst +3 -0
@@ -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
drivers/hwmon/nct6683.c +51 -2
89 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 5/7] hwmon: (nct6683) Name the sensors of the ASRock B850 Steel Legend WiFi
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
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.
Quoted 8 lines
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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v2 5/7] hwmon: (nct6683) Name the sensors of the ASRock B850 Steel Legend WiFi
In reply to Johan DahlinQuoted 4 lines · 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.
Quoted 8 lines
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 <[email protected]>
NACK, please don't do that. Add desired per-board names to sensors3.conf instead.
Thanks,
Guenter
PATCH v2 6/7 hwmon: (nct6683) Name the fan headers of the ASRock B850 Steel Legend WiFi
In reply to Johan DahlinWith 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.
--- Documentation/hwmon/nct6683.rst | 3 ++- drivers/hwmon/nct6683.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-)
Documentation/hwmon/nct6683.rst +2 -1
@@ -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:
drivers/hwmon/nct6683.c +30 -2
@@ -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)
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 6/7] hwmon: (nct6683) Name the fan headers of the ASRock B850 Steel Legend WiFi
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
With fan control available, users need to know which pwm channel drives which header. The driver has no fan labels.
Add a
fanN_labelattribute, 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_PUMPandCHA_FAN1toCHA_FAN3. The order was inferred from the readings and the BIOS defaults.Signed-off-by Johan Dahlin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Guenter Roeck
maintainerRe: [PATCH v2 6/7] hwmon: (nct6683) Name the fan headers of the ASRock B850 Steel Legend WiFi
In reply to Johan DahlinQuoted 9 lines · 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_labelattribute, 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_PUMPandCHA_FAN1toCHA_FAN3. The order was inferred from the readings and the BIOS defaults.Signed-off-by Johan Dahlin <[email protected]>
Again, please add per-board sensor names to sensors3.conf.
Thanks,
Guenter
PATCH v2 7/7 hwmon: (nct6683) Scale the +5V and +12V inputs of the ASRock B850 Steel Legend WiFi
In reply to Johan DahlinThe +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.
--- Documentation/hwmon/nct6683.rst | 3 ++- drivers/hwmon/nct6683.c | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-)
Documentation/hwmon/nct6683.rst +2 -1
@@ -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:
drivers/hwmon/nct6683.c +15 -5
@@ -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,
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 7/7] hwmon: (nct6683) Scale the +5V and +12V inputs of the ASRock B850 Steel Legend WiFi
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
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.rstasks 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 <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Guenter Roeck
maintainerRe: [PATCH v2 7/7] hwmon: (nct6683) Scale the +5V and +12V inputs of the ASRock B850 Steel Legend WiFi
In reply to Johan DahlinQuoted 9 lines · 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.rstasks 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 <[email protected]>
Again, this belongs into sensors3.conf.
Thanks,
Guenter