[PATCH v2 7/7] hwmon: (nct6683) Scale the +5V and +12V inputs of the ASRock B850 Steel Legend WiFi

From: Johan Dahlin

Date: Wed Nov 11 2026 - 03:33:19 EST


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