mirror of
https://github.com/Fred78290/nct6687d
synced 2024-11-16 07:48:04 +01:00
Merge pull request #46 from Fred78290/manual-voltage
Manual voltage configuration
This commit is contained in:
commit
f59feefb32
4 changed files with 143 additions and 12 deletions
2
Makefile
2
Makefile
|
@ -33,7 +33,7 @@ dkms/install:
|
||||||
sudo modprobe nct6687
|
sudo modprobe nct6687
|
||||||
|
|
||||||
dkms/clean:
|
dkms/clean:
|
||||||
sudo dkms remove nct6687d/1
|
sudo dkms remove nct6687d/1 --all
|
||||||
make -C /lib/modules/${kver}/build M=${curpwd} clean
|
make -C /lib/modules/${kver}/build M=${curpwd} clean
|
||||||
|
|
||||||
|
|
||||||
|
|
51
README.md
51
README.md
|
@ -122,9 +122,58 @@ This module was tested on Ubuntu 20.04 with all kernel availble on motherboard [
|
||||||
## CHANGELOG
|
## CHANGELOG
|
||||||
|
|
||||||
- Add support for MSI B460M Bazooka having NCT6687 with another device ID
|
- 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
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
<br>
|
||||||
|
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
|
## VERIFIED
|
||||||
**1. Fan speed control**
|
**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.
|
71
nct6687.c
71
nct6687.c
|
@ -46,9 +46,14 @@ enum kinds
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool force;
|
static bool force;
|
||||||
|
static bool manual;
|
||||||
|
|
||||||
module_param(force, bool, 0);
|
module_param(force, bool, 0);
|
||||||
MODULE_PARM_DESC(force, "Set to one to enable support for unknown vendors");
|
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[] = {
|
static const char *const nct6687_device_names[] = {
|
||||||
"nct6683",
|
"nct6683",
|
||||||
"nct6687",
|
"nct6687",
|
||||||
|
@ -233,12 +238,44 @@ static struct voltage_reg nct6687_voltage_definition[] = {
|
||||||
.multiplier = 2,
|
.multiplier = 2,
|
||||||
.label = "DRAM",
|
.label = "DRAM",
|
||||||
},
|
},
|
||||||
// DRAM
|
// Chipset
|
||||||
{
|
{
|
||||||
.reg = 5,
|
.reg = 5,
|
||||||
.multiplier = 1,
|
.multiplier = 1,
|
||||||
.label = "Chipset",
|
.label = "Chipset",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// CPU SA
|
||||||
|
{
|
||||||
|
.reg = 6,
|
||||||
|
.multiplier = 1,
|
||||||
|
.label = "CPU SA",
|
||||||
|
},
|
||||||
|
// Voltage #2
|
||||||
|
{
|
||||||
|
.reg = 7,
|
||||||
|
.multiplier = 1,
|
||||||
|
.label = "Voltage #2",
|
||||||
|
},
|
||||||
|
// AVCC3
|
||||||
|
{
|
||||||
|
.reg = 8,
|
||||||
|
.multiplier = 1,
|
||||||
|
.label = "AVCC3",
|
||||||
|
},
|
||||||
|
// AVSB
|
||||||
|
{
|
||||||
|
.reg = 12,
|
||||||
|
.multiplier = 1,
|
||||||
|
.label = "AVSB",
|
||||||
|
},
|
||||||
|
// VBAT
|
||||||
|
{
|
||||||
|
.reg = 13,
|
||||||
|
.multiplier = 1,
|
||||||
|
.label = "VBat",
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *const nct6687_temp_label[] = {
|
static const char *const nct6687_temp_label[] = {
|
||||||
|
@ -368,6 +405,16 @@ struct sensor_template_group
|
||||||
|
|
||||||
static void nct6687_save_fan_control(struct nct6687_data *data, int index);
|
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)
|
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;
|
struct sensor_device_attribute_2 *a2;
|
||||||
|
@ -482,7 +529,7 @@ static void nct6687_update_temperatures(struct nct6687_data *data)
|
||||||
{
|
{
|
||||||
s32 value = (char)nct6687_read(data, NCT6687_REG_TEMP(i));
|
s32 value = (char)nct6687_read(data, NCT6687_REG_TEMP(i));
|
||||||
s32 half = (nct6687_read(data, NCT6687_REG_TEMP(i) + 1) >> 7) & 0x1;
|
s32 half = (nct6687_read(data, NCT6687_REG_TEMP(i) + 1) >> 7) & 0x1;
|
||||||
s32 temperature = (value * 1000) + (5 * half);
|
s32 temperature = (value * 1000) + (500 * half);
|
||||||
|
|
||||||
data->temperature[0][i] = temperature;
|
data->temperature[0][i] = temperature;
|
||||||
data->temperature[1][i] = MIN(temperature, data->temperature[1][i]);
|
data->temperature[1][i] = MIN(temperature, data->temperature[1][i]);
|
||||||
|
@ -495,25 +542,25 @@ static void nct6687_update_temperatures(struct nct6687_data *data)
|
||||||
static void nct6687_update_voltage(struct nct6687_data *data)
|
static void nct6687_update_voltage(struct nct6687_data *data)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
|
char buf[128];
|
||||||
|
|
||||||
/* Measured voltages and limits */
|
/* Measured voltages and limits */
|
||||||
for (index = 0; index < NCT6687_NUM_REG_VOLTAGE; index++)
|
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 high = nct6687_read(data, NCT6687_REG_VOLTAGE(reg)) * 16;
|
||||||
s16 low = ((u16)nct6687_read(data, NCT6687_REG_VOLTAGE(reg) + 1)) >> 4;
|
s16 low = ((u16)nct6687_read(data, NCT6687_REG_VOLTAGE(reg) + 1)) >> 4;
|
||||||
s16 value = low + high;
|
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[0][index] = voltage;
|
||||||
data->voltage[1][index] = MIN(voltage, data->voltage[1][index]);
|
data->voltage[1][index] = MIN(voltage, data->voltage[1][index]);
|
||||||
data->voltage[2][index] = MAX(voltage, data->voltage[2][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");
|
pr_debug("nct6687_update_voltage\n");
|
||||||
pr_debug("nct6687_update_voltage\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nct6687_update_fans(struct nct6687_data *data)
|
static void nct6687_update_fans(struct nct6687_data *data)
|
||||||
|
@ -572,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);
|
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)
|
static ssize_t show_voltage_value(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
|
@ -840,21 +890,22 @@ static void nct6687_setup_fans(struct nct6687_data *data)
|
||||||
static void nct6687_setup_voltages(struct nct6687_data *data)
|
static void nct6687_setup_voltages(struct nct6687_data *data)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
/* Measured voltages and limits */
|
/* Measured voltages and limits */
|
||||||
for (index = 0; index < NCT6687_NUM_REG_VOLTAGE; index++)
|
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 high = nct6687_read(data, NCT6687_REG_VOLTAGE(reg)) * 16;
|
||||||
s16 low = ((u16)nct6687_read(data, NCT6687_REG_VOLTAGE(reg) + 1)) >> 4;
|
s16 low = ((u16)nct6687_read(data, NCT6687_REG_VOLTAGE(reg) + 1)) >> 4;
|
||||||
s16 value = low + high;
|
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[0][index] = voltage;
|
||||||
data->voltage[1][index] = voltage;
|
data->voltage[1][index] = voltage;
|
||||||
data->voltage[2][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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
sensors.d/B460M-7C83.conf
Normal file
31
sensors.d/B460M-7C83.conf
Normal file
|
@ -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)
|
Loading…
Reference in a new issue