From 4cbfe8084d1e0942b16beacdc28d224f708aea57 Mon Sep 17 00:00:00 2001 From: fboltz Date: Sun, 17 Jul 2022 11:48:26 +0200 Subject: [PATCH] FEAT: Add manual configuration support --- README.md | 51 ++++++++++++++++++++++++++++++++++++++- nct6687.c | 34 ++++++++++++++++++++------ sensors.d/B460M-7C83.conf | 31 ++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 sensors.d/B460M-7C83.conf diff --git a/README.md b/README.md index 1005eb9..b5369fb 100644 --- a/README.md +++ b/README.md @@ -122,9 +122,58 @@ This module was tested on Ubuntu 20.04 with all kernel availble on motherboard [ ## CHANGELOG - Add support for MSI B460M Bazooka having NCT6687 with another device ID +- Add support to use generic voltage input without multiplier, allows sensors custom conf
+## VOLTAGE MANUAL CONFIGURATION + +Some people report that voltage are wrong. The reason is with some motherboard, voltage sensors are not connected on the same nct6687 register. + +As example the **VCore** sensor is connected on the **5th** register for AMD but is connected on the **3rd** register for INTEL. +
+Also the **DIMM** sensor is connected on the **4th** register for AMD but connected to **5th** register for INTEL. + +To allow customize voltage configuration you must add **manual=1** parameter passed to the module at load + +`sudo sh -c 'echo "nct6687 manual=1" >> /etc/modules'` + +And use a sensors conf like this **/etc/sensors.d/B460M-7C83.conf** + +``` +# Micro-Star International Co., Ltd. +# MAG B460M BAZOOKA (MS-7C83) + +chip "nct6687-*" + label in0 "+12V" + label in1 "+5V" + label in2 "VCore" + label in3 "Voltage #1" + label in4 "DIMM" + label in5 "CPU I/O" + label in6 "CPU SA" + label in7 "Voltage #2" + label in8 "+3.3V" + label in9 "VTT" + label in10 "VRef" + label in11 "VSB" + label in12 "AVSB" + label in13 "VBat" + + ignore in3 + ignore in7 + ignore in9 + ignore in10 + ignore in13 + + ignore temp6 + ignore temp7 + + compute in0 (@ * 12), (@ / 12) + compute in1 (@ * 5), (@ / 5) + compute in4 (@ * 2), (@ / 2) +``` + ## VERIFIED **1. Fan speed control** -- Changing fan speed was tested succesfuly by users, see reported issue. +- Changing fan speed was tested succesfuly by users, see reported issue. \ No newline at end of file diff --git a/nct6687.c b/nct6687.c index a4acd76..3a6385b 100644 --- a/nct6687.c +++ b/nct6687.c @@ -46,9 +46,14 @@ enum kinds }; static bool force; +static bool manual; + module_param(force, bool, 0); MODULE_PARM_DESC(force, "Set to one to enable support for unknown vendors"); +module_param(manual, bool, 0); +MODULE_PARM_DESC(manual, "Set voltage input and voltage label configured with external sensors file"); + static const char *const nct6687_device_names[] = { "nct6683", "nct6687", @@ -400,6 +405,16 @@ struct sensor_template_group static void nct6687_save_fan_control(struct nct6687_data *data, int index); +static const char* nct6687_voltage_label(char* buf, int index) +{ + if (manual) + sprintf(buf, "in%d", index); + else + strcpy(buf, nct6687_voltage_definition[index].label); + + return buf; +} + static struct attribute_group *nct6687_create_attr_group(struct device *dev, const struct sensor_template_group *tg, int repeat) { struct sensor_device_attribute_2 *a2; @@ -527,21 +542,22 @@ static void nct6687_update_temperatures(struct nct6687_data *data) static void nct6687_update_voltage(struct nct6687_data *data) { int index; + char buf[128]; /* Measured voltages and limits */ for (index = 0; index < NCT6687_NUM_REG_VOLTAGE; index++) { - s16 reg = nct6687_voltage_definition[index].reg; + s16 reg = manual ? index : nct6687_voltage_definition[index].reg; s16 high = nct6687_read(data, NCT6687_REG_VOLTAGE(reg)) * 16; s16 low = ((u16)nct6687_read(data, NCT6687_REG_VOLTAGE(reg) + 1)) >> 4; s16 value = low + high; - s16 voltage = value * nct6687_voltage_definition[index].multiplier; + s16 voltage = manual ? value : value * nct6687_voltage_definition[index].multiplier; data->voltage[0][index] = voltage; data->voltage[1][index] = MIN(voltage, data->voltage[1][index]); data->voltage[2][index] = MAX(voltage, data->voltage[2][index]); - pr_debug("nct6687_update_voltage[%d], %s, addr=0x%04x, value=%d, voltage=%d\n", index, nct6687_voltage_definition[index].label, NCT6687_REG_VOLTAGE(index), value, voltage); + pr_debug("nct6687_update_voltage[%d], %s, reg=%d, addr=0x%04x, value=%d, voltage=%d\n", index, nct6687_voltage_label(buf, index), reg, NCT6687_REG_VOLTAGE(index), value, voltage); } pr_debug("nct6687_update_voltage\n"); @@ -603,7 +619,10 @@ static ssize_t show_voltage_label(struct device *dev, struct device_attribute *a { struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); - return sprintf(buf, "%s\n", nct6687_voltage_definition[sattr->index].label); + if (manual) + return sprintf(buf, "in%d\n", sattr->index); + else + return sprintf(buf, "%s\n", nct6687_voltage_definition[sattr->index].label); } static ssize_t show_voltage_value(struct device *dev, struct device_attribute *attr, char *buf) @@ -871,21 +890,22 @@ static void nct6687_setup_fans(struct nct6687_data *data) static void nct6687_setup_voltages(struct nct6687_data *data) { int index; + char buf[64]; /* Measured voltages and limits */ for (index = 0; index < NCT6687_NUM_REG_VOLTAGE; index++) { - s16 reg = nct6687_voltage_definition[index].reg; + s16 reg = manual ? index : nct6687_voltage_definition[index].reg; s16 high = nct6687_read(data, NCT6687_REG_VOLTAGE(reg)) * 16; s16 low = ((u16)nct6687_read(data, NCT6687_REG_VOLTAGE(reg) + 1)) >> 4; s16 value = low + high; - s16 voltage = value * nct6687_voltage_definition[index].multiplier; + s16 voltage = manual ? value : value * nct6687_voltage_definition[index].multiplier; data->voltage[0][index] = voltage; data->voltage[1][index] = voltage; data->voltage[2][index] = voltage; - pr_debug("nct6687_setup_voltages[%d], %s, addr=0x%04x, value=%d, voltage=%d\n", index, nct6687_voltage_definition[index].label, NCT6687_REG_VOLTAGE(index), value, voltage); + pr_debug("nct6687_setup_voltages[%d], %s, addr=0x%04x, value=%d, voltage=%d\n", index, nct6687_voltage_label(buf, index), NCT6687_REG_VOLTAGE(index), value, voltage); } } diff --git a/sensors.d/B460M-7C83.conf b/sensors.d/B460M-7C83.conf new file mode 100644 index 0000000..94108e9 --- /dev/null +++ b/sensors.d/B460M-7C83.conf @@ -0,0 +1,31 @@ +# Micro-Star International Co., Ltd. +# MAG B460M BAZOOKA (MS-7C83) + +chip "nct6687-*" + label in0 "+12V" + label in1 "+5V" + label in2 "VCore" + label in3 "Voltage #1" + label in4 "DIMM" + label in5 "CPU I/O" + label in6 "CPU SA" + label in7 "Voltage #2" + label in8 "+3.3V" + label in9 "VTT" + label in10 "VRef" + label in11 "VSB" + label in12 "AVSB" + label in13 "VBat" + + ignore in3 + ignore in7 + ignore in9 + ignore in10 + ignore in13 + + ignore temp6 + ignore temp7 + + compute in0 (@ * 12), (@ / 12) + compute in1 (@ * 5), (@ / 5) + compute in4 (@ * 2), (@ / 2) \ No newline at end of file