diff --git a/doc/chips/vt8231 b/doc/chips/vt8231 index 2e67871f..fdf7c989 100644 --- a/doc/chips/vt8231 +++ b/doc/chips/vt8231 @@ -4,7 +4,7 @@ Kernel driver `vt8231.o' Status: Beta Supported chips: - * Via VT8231 South Bridge + * VIA VT8231 South Bridge Prefix: 'vt8231' Addresses scanned: none, address read from PCI space @@ -36,24 +36,20 @@ Module Parameters Description ----------- -The Via VT8231 South Bridge contains voltage/temperature monitoring and +The VIA VT8231 South Bridge contains voltage/temperature monitoring and PWM control circuitry for two fans. -We define the sensors as follows. Somewhat convoluted to minimize -changes from via686a. Temp1 and in6 are unimplemented in the vt8231 -chip but are included in the driver. +We define the sensors as follows. Sensor Voltage Mode Temp Mode uch_config bit ------ ------------ --------- -------------- - Reading 1 temp3 - Reading 3 temp1 - UCH1/Reading 2 in0 temp2 0x04 (4) - UCH2 in1 temp4 0x08 (8) - UCH3 in2 temp5 0x10 (16) - UCH4 in3 temp6 0x20 (32) - UCH5 in4 temp7 0x40 (64) + Reading 1 temp1 + UCH1 in0 temp2 0x04 (4) + UCH2 in1 temp3 0x08 (8) + UCH3 in2 temp4 0x10 (16) + UCH4 in3 temp5 0x20 (32) + UCH5 in4 temp6 0x40 (64) 3.3V in5 - -12V in6 As noted above, 5 of the sensors are "universal channels" and can be set for either voltage or temperature. @@ -91,21 +87,18 @@ in2 - - R- 2 in3 - - R- 2 in4 - - R- 2 in5 - - R- 2 -in6 - - R- 2 in0_min in0 in0 RW 2 in1_min in1 in1 RW 2 in2_min in2 in2 RW 2 in3_min in3 in3 RW 2 in4_min in4 in4 RW 2 in5_min in5 in5 RW 2 -in6_min in6 in6 RW 2 in0_max in0 in0 RW 2 in1_max in1 in1 RW 2 in2_max in2 in2 RW 2 in3_max in3 in3 RW 2 in4_max in4 in4 RW 2 in5_max in5 in5 RW 2 -in6_max in6 in6 RW 2 fan1 - - R- 0 fan2 - - R- 0 fan1_min fan1 fan1 RW 0 @@ -113,24 +106,21 @@ fan2_min fan2 fan2 RW 0 temp1 - - R- 1 temp1_hyst temp1 temp1 RW 1 temp1_over temp1 temp1 RW 1 -temp2 - - R- 1 -temp2_hyst temp2 temp2 RW 1 -temp2_over temp2 temp2 RW 1 -temp3 - - R- 1 -temp3_hyst temp3 temp3 RW 1 -temp3_over temp3 temp3 RW 1 -temp4 - - R- 1 -temp4_hyst temp4 temp4 RW 1 -temp4_over temp4 temp4 RW 1 -temp5 - - R- 1 -temp5_hyst temp5 temp5 RW 1 -temp5_over temp5 temp5 RW 1 -temp6 - - R- 1 -temp6_hyst temp6 temp6 RW 1 -temp6_over temp6 temp6 RW 1 -temp7 - - R- 1 -temp7_hyst temp7 temp7 RW 1 -temp7_over temp7 temp7 RW 1 +temp2 - - R- 2 +temp2_hyst temp2 temp2 RW 2 +temp2_over temp2 temp2 RW 2 +temp3 - - R- 2 +temp3_hyst temp3 temp3 RW 2 +temp3_over temp3 temp3 RW 2 +temp4 - - R- 2 +temp4_hyst temp4 temp4 RW 2 +temp4_over temp4 temp4 RW 2 +temp5 - - R- 2 +temp5_hyst temp5 temp5 RW 2 +temp5_over temp5 temp5 RW 2 +temp6 - - R- 2 +temp6_hyst temp6 temp6 RW 2 +temp6_over temp6 temp6 RW 2 fan1_div fan1 - RW 0 fan2_div fan2 - RW 0 alarms - - R- 0 @@ -145,21 +135,18 @@ in2 SENSORS_VT8231_IN2 in2:3 in3 SENSORS_VT8231_IN3 in3:3 in4 SENSORS_VT8231_IN4 in4:3 in5 SENSORS_VT8231_IN5 in5:3 -in6 SENSORS_VT8231_IN6 in6:3 in0_min SENSORS_VT8231_IN0_MIN in0:1 in1_min SENSORS_VT8231_IN1_MIN in1:1 in2_min SENSORS_VT8231_IN2_MIN in2:1 in3_min SENSORS_VT8231_IN3_MIN in3:1 in4_min SENSORS_VT8231_IN4_MIN in4:1 in5_min SENSORS_VT8231_IN5_MIN in5:1 -in6_min SENSORS_VT8231_IN6_MIN in6:1 in0_max SENSORS_VT8231_IN0_MAX in0:2 in1_max SENSORS_VT8231_IN1_MAX in1:2 in2_max SENSORS_VT8231_IN2_MAX in2:2 in3_max SENSORS_VT8231_IN3_MAX in3:2 in4_max SENSORS_VT8231_IN4_MAX in4:2 in5_max SENSORS_VT8231_IN5_MAX in5:2 -in6_max SENSORS_VT8231_IN6_MAX in6:2 fan1 SENSORS_VT8231_FAN1 fan1:2 fan2 SENSORS_VT8231_FAN2 fan2:2 fan1_min SENSORS_VT8231_FAN1_MIN fan1:1 @@ -182,9 +169,6 @@ temp5_over SENSORS_VT8231_TEMP5_OVER temp5:1 temp6 SENSORS_VT8231_TEMP6 temp6:3 temp6_hyst SENSORS_VT8231_TEMP6_HYST temp6:2 temp6_over SENSORS_VT8231_TEMP6_OVER temp6:1 -temp7 SENSORS_VT8231_TEMP7 temp7:3 -temp7_hyst SENSORS_VT8231_TEMP7_HYST temp7:2 -temp7_over SENSORS_VT8231_TEMP7_OVER temp7:1 fan1_div SENSORS_VT8231_FAN1_DIV fan_div:1 fan2_div SENSORS_VT8231_FAN2_DIV fan_div:2 alarms SENSORS_VT8231_ALARMS alarms:1 @@ -196,5 +180,5 @@ config SENSORS_VT8231_UCH uch_config:1 Notes ----- -The lm_sensors project gratefully acknowledges the support of Via in the +The lm_sensors project gratefully acknowledges the support of VIA in the development of this driver. diff --git a/etc/sensors.conf.eg b/etc/sensors.conf.eg index 70225e3c..1f45957d 100644 --- a/etc/sensors.conf.eg +++ b/etc/sensors.conf.eg @@ -1918,9 +1918,9 @@ chip "lm63-*" # set fan1_min 2000 -chip "vt1211-*" "vt8231-*" +chip "vt1211-*" # -# temp1 and in6 are not implemented in vt1211 / vt8231 +# temp1 and in6 are not implemented in vt1211 # # 1 for temp, 0 for volt. # Sensor Voltage Mode Temp Mode config bit @@ -1935,7 +1935,7 @@ chip "vt1211-*" "vt8231-*" # # set uch1-2 to temp mode, uch3-5 to voltage mode # - set config 12 +# set config 12 ignore in0 ignore in1 ignore temp5 @@ -2027,6 +2027,93 @@ chip "vt1211-*" "vt8231-*" set fan1_min 3000 set fan2_min 3000 +chip "vt8231-*" +# +# 1 for temp, 0 for volt. +# Sensor Voltage Mode Temp Mode config bit +# -------- ------------ --------- -------------- +# Reading 1 temp1 +# UCH1 in0 temp2 0x04 (4) +# UCH2 in1 temp3 0x08 (8) +# UCH3 in2 temp4 0x10 (16) +# UCH4 in3 temp5 0x20 (32) +# UCH5 in4 temp6 0x40 (64) +# 3.3V in5 +# +# Hardware default is UCH1 in temp mode, UCH2-5 in voltage mode +# Note that the Linux 2.6 driver will not let you change the channel +# configuration. In theory, the BIOS should have done it properly. +# set config 4 + +# ignore in0 +# ignore temp3 +# ignore temp4 +# ignore temp5 +# ignore temp6 + + label in1 "+2.5V" + label in2 "VCore" + label in3 "+5V" + label in4 "+12V" + label in5 "+3.3V" + + label temp1 "CPU Temp" + label temp2 "M/B Temp" + +# Here are the resistor values as recommended by VIA: +# Voltage R1 R2 +# VCore no scaling +# 2.5 2k 10k +# 3.5 (3.3V ext.) 6.8k 10k +# 5.0 14k 10k +# 12.0 47k 10k + +# compute in0 @ * (1 + 6.8 / 10), @ / (1 + 6.8 / 10) + compute in1 @ * (1 + 2 / 10), @ / (1 + 2 / 10) + compute in3 @ * (1 + 14 / 10), @ / (1 + 14 / 10) + compute in4 @ * (1 + 47 / 10), @ / (1 + 47 / 10) +# in5 is scaled internally so scaling is done by the driver. + +# set in0_min 2.5 * 0.95 +# set in0_max 2.5 * 1.05 +# set in1_min 2.5 * 0.95 +# set in1_max 2.5 * 1.05 +# Replace "2.0" with your nominal CPU voltage for in2. +# set in2_min 2.0 * 0.95 +# set in2_max 2.0 * 1.05 +# set in3_min 5.0 * 0.95 + set in3_max 5.0 * 1.05 + set in4_min 12.0 * 0.95 + set in4_max 12.0 * 1.05 + set in5_min 3.3 * 0.95 + set in5_max 3.3 * 1.05 + +# For Intel CPU: + compute temp1 (@ - 65) / 0.9686, (@ * 0.9686) + 65 + +# For VIA EPIA CPU (provided by Roger Lucas): +# compute temp1 (@ - 45) / 0.7809, (@ * 0.7809) + 45 + +# Thermistor calculations +# 3435 is the thermistor beta, 2.2 is the reference voltage. +# '^' is the e**x operator; '`' is the ln(x) operator +# (valid in library version 1.4.0 / lm_sensors 2.7.1 or higher) +# This assumes that the thermistor forms a resistor divider with a resistor +# equal to its nominal value @ 25C. + + compute temp2 3435 / (` (1 / (1 - @ / 2.2) - 1) + 3435 / 298.15) - 273.15, \ + 2.2 * (1 - 1 / (1 + (^ (3435 / (273.15 + @) - 3435 / 298.15)))) + compute temp3 3435 / (` (1 / (1 - @ / 2.2) - 1) + 3435 / 298.15) - 273.15, \ + 2.2 * (1 - 1 / (1 + (^ (3435 / (273.15 + @) - 3435 / 298.15)))) + +# set temp2_hyst 40 +# set temp2_over 45 +# set temp3_hyst 60 +# set temp3_over 65 + +# set fan1_min 3000 +# set fan2_min 3000 + chip "bmc-*" # # You should not need compute lines here, the driver will diff --git a/kernel/chips/vt8231.c b/kernel/chips/vt8231.c index f807d661..24ab2e49 100644 --- a/kernel/chips/vt8231.c +++ b/kernel/chips/vt8231.c @@ -54,22 +54,19 @@ SENSORS_INSMOD_1(vt8231); #define VT8231_REG_PWM_CTL 0x51 /* The VT8231 registers */ -/* We define the sensors as follows. Somewhat convoluted to minimize - changes from via686a. +/* We define the sensors as follows. Sensor Voltage Mode Temp Mode -------- ------------ --------- - Reading 1 temp3 - Reading 3 temp1 not in vt8231 - UCH1/Reading2 in0 temp2 - UCH2 in1 temp4 - UCH3 in2 temp5 - UCH4 in3 temp6 - UCH5 in4 temp7 + Reading 1 temp1 + UCH1 in0 temp2 + UCH2 in1 temp3 + UCH3 in2 temp4 + UCH4 in3 temp5 + UCH5 in4 temp6 3.3V in5 - -12V in6 not in vt8231 */ -/* ins numbered 0-6 */ +/* ins numbered 0-5 */ #define VT8231_REG_IN_MAX(nr) ((nr)==0 ? 0x3d : 0x29 + ((nr) * 2)) #define VT8231_REG_IN_MIN(nr) ((nr)==0 ? 0x3e : 0x2a + ((nr) * 2)) #define VT8231_REG_IN(nr) (0x21 + (nr)) @@ -78,17 +75,16 @@ SENSORS_INSMOD_1(vt8231); #define VT8231_REG_FAN_MIN(nr) (0x3a + (nr)) #define VT8231_REG_FAN(nr) (0x28 + (nr)) -static const u8 regtemp[] = { 0x20, 0x21, 0x1f, 0x22, 0x23, 0x24, 0x25 }; -static const u8 regover[] = { 0x39, 0x3d, 0x1d, 0x2b, 0x2d, 0x2f, 0x31 }; -static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e, 0x2c, 0x2e, 0x30, 0x32 }; +static const u8 regtemp[] = { 0x1f, 0x21, 0x22, 0x23, 0x24, 0x25 }; +static const u8 regover[] = { 0x39, 0x3d, 0x2b, 0x2d, 0x2f, 0x31 }; +static const u8 reghyst[] = { 0x3a, 0x3e, 0x2c, 0x2e, 0x30, 0x32 }; -/* temps numbered 1-7 */ +/* temps numbered 1-6 */ #define VT8231_REG_TEMP(nr) (regtemp[(nr) - 1]) #define VT8231_REG_TEMP_OVER(nr) (regover[(nr) - 1]) #define VT8231_REG_TEMP_HYST(nr) (reghyst[(nr) - 1]) -#define VT8231_REG_TEMP_LOW3 0x4b /* bits 7-6 */ -#define VT8231_REG_TEMP_LOW2 0x49 /* bits 5-4 */ -#define VT8231_REG_TEMP_LOW47 0x4d +#define VT8231_REG_TEMP_LOW12 0x49 +#define VT8231_REG_TEMP_LOW36 0x4d #define VT8231_REG_CONFIG 0x40 #define VT8231_REG_ALARM1 0x41 @@ -99,24 +95,35 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e, 0x2c, 0x2e, 0x30, 0x32 }; #define VT8231_REG_TEMP1_CONFIG 0x4b #define VT8231_REG_TEMP2_CONFIG 0x4c -/* temps 1-7; voltages 0-6 */ +/* temps 1-6; voltages 0-5 */ #define ISTEMP(i, ch_config) ((i) == 1 ? 1 : \ - (i) == 3 ? 1 : \ - (i) == 2 ? ((ch_config) >> 1) & 0x01 : \ - ((ch_config) >> ((i)-1)) & 0x01) -#define ISVOLT(i, ch_config) ((i) > 4 ? 1 : !(((ch_config) >> ((i)+2)) & 0x01)) + ((ch_config) >> (i)) & 0x01) +#define ISVOLT(i, ch_config) ((i) == 5 ? 1 : \ + !(((ch_config) >> ((i)+2)) & 0x01)) #define DIV_FROM_REG(val) (1 << (val)) #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) #define PWM_FROM_REG(val) (val) #define PWM_TO_REG(val) SENSORS_LIMIT((val), 0, 255) +/* Used for temp1 (diode) */ #define TEMP_FROM_REG(val) ((val)*10) #define TEMP_FROM_REG10(val) (((val)*10)/4) #define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)<0?(((val)-5)/10):\ ((val)+5)/10),0,255)) -#define IN_FROM_REG(val) /*(((val)*10+5)/10)*/ (val) -#define IN_TO_REG(val) (SENSORS_LIMIT((((val) * 10 + 5)/10),0,255)) + +/* Used for temp2-temp6 (thermistor) */ +#define THERM_FROM_REG(reg) (((253 * 4 - (reg)) * 55 + 105) / 210) +#define THERM_TO_REG(val) (253 - ((val) * 210 + 110) / 220) + +/* Used for in0-in4 */ +#define IN_FROM_REG(val) ((((val) - 3) * 1000 + 479) / 958) +#define IN_TO_REG(val) SENSORS_LIMIT(((val) * 958 + 500) \ + / 1000 + 3, 0, 255) +/* Used for in5 (scaled internally) */ +#define IN5_FROM_REG(val) ((((val) - 3) * 54000 + 16286) / 32572) +#define IN5_TO_REG(val) SENSORS_LIMIT(((val) * 32572 + 27000) \ + / 54000 + 3, 0, 255) /********* FAN RPM CONVERSIONS ********/ @@ -142,12 +149,12 @@ struct vt8231_data { char valid; /* !=0 if following fields are valid */ unsigned long last_updated; /* In jiffies */ - u8 in[7]; /* Register value */ - u8 in_max[7]; /* Register value */ - u8 in_min[7]; /* Register value */ - u16 temp[7]; /* Register value 10 bit */ - u8 temp_over[7]; /* Register value */ - u8 temp_hyst[7]; /* Register value */ + u8 in[6]; /* Register value */ + u8 in_max[6]; /* Register value */ + u8 in_min[6]; /* Register value */ + u16 temp[6]; /* Register value 10 bit */ + u8 temp_over[6]; /* Register value */ + u8 temp_hyst[6]; /* Register value */ u8 fan[2]; /* Register value */ u8 fan_min[2]; /* Register value */ u8 fan_div[2]; /* Register encoding, shifted right */ @@ -179,6 +186,8 @@ static void vt8231_fan_div(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); static void vt8231_in(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); +static void vt8231_in5(struct i2c_client *client, int operation, + int ctl_name, int *nrels_mag, long *results); static void vt8231_pwm(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); static void vt8231_vid(struct i2c_client *client, int operation, @@ -189,6 +198,8 @@ static void vt8231_uch(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); static void vt8231_temp(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); +static void vt8231_therm(struct i2c_client *client, int operation, + int ctl_name, int *nrels_mag, long *results); static struct i2c_driver vt8231_driver = { .name = "VT8231 sensors driver", @@ -205,7 +216,6 @@ static struct i2c_driver vt8231_driver = { #define VT8231_SYSCTL_IN3 1003 #define VT8231_SYSCTL_IN4 1004 #define VT8231_SYSCTL_IN5 1005 -#define VT8231_SYSCTL_IN6 1006 #define VT8231_SYSCTL_FAN1 1101 #define VT8231_SYSCTL_FAN2 1102 #define VT8231_SYSCTL_TEMP 1200 @@ -214,7 +224,6 @@ static struct i2c_driver vt8231_driver = { #define VT8231_SYSCTL_TEMP4 1203 #define VT8231_SYSCTL_TEMP5 1204 #define VT8231_SYSCTL_TEMP6 1205 -#define VT8231_SYSCTL_TEMP7 1206 #define VT8231_SYSCTL_VID 1300 #define VT8231_SYSCTL_PWM1 1401 #define VT8231_SYSCTL_PWM2 1402 @@ -231,16 +240,14 @@ static struct i2c_driver vt8231_driver = { #define VT8231_ALARM_FAN1 0x40 #define VT8231_ALARM_FAN2 0x80 #define VT8231_ALARM_IN4 0x100 -#define VT8231_ALARM_IN6 0x200 #define VT8231_ALARM_TEMP2 0x800 #define VT8231_ALARM_CHAS 0x1000 -#define VT8231_ALARM_TEMP3 0x8000 /* duplicates */ -#define VT8231_ALARM_IN0 VT8231_ALARM_TEMP -#define VT8231_ALARM_TEMP4 VT8231_ALARM_IN1 -#define VT8231_ALARM_TEMP5 VT8231_ALARM_IN2 -#define VT8231_ALARM_TEMP6 VT8231_ALARM_IN3 -#define VT8231_ALARM_TEMP7 VT8231_ALARM_IN4 +#define VT8231_ALARM_IN0 VT8231_ALARM_TEMP2 +#define VT8231_ALARM_TEMP3 VT8231_ALARM_IN1 +#define VT8231_ALARM_TEMP4 VT8231_ALARM_IN2 +#define VT8231_ALARM_TEMP5 VT8231_ALARM_IN3 +#define VT8231_ALARM_TEMP6 VT8231_ALARM_IN4 /* -- SENSORS SYSCTL END -- */ @@ -256,26 +263,19 @@ static ctl_table vt8231_dir_table_template[] = { {VT8231_SYSCTL_IN4, "in4", NULL, 0, 0644, NULL, &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_in}, {VT8231_SYSCTL_IN5, "in5", NULL, 0, 0644, NULL, &i2c_proc_real, - &i2c_sysctl_real, NULL, &vt8231_in}, -/* - not in 8231 - {VT8231_SYSCTL_IN6, "in6", NULL, 0, 0644, NULL, &i2c_proc_real, - &i2c_sysctl_real, NULL, &vt8231_in}, - {VT8231_SYSCTL_TEMP, "temp1", NULL, 0, 0644, NULL, &i2c_proc_real, - &i2c_sysctl_real, NULL, &vt8231_temp}, -*/ + &i2c_sysctl_real, NULL, &vt8231_in5}, + {VT8231_SYSCTL_TEMP, "temp1", NULL, 0, 0644, NULL, + &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_temp}, {VT8231_SYSCTL_TEMP2, "temp2", NULL, 0, 0644, NULL, - &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_temp}, + &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_therm}, {VT8231_SYSCTL_TEMP3, "temp3", NULL, 0, 0644, NULL, - &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_temp}, + &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_therm}, {VT8231_SYSCTL_TEMP4, "temp4", NULL, 0, 0644, NULL, - &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_temp}, + &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_therm}, {VT8231_SYSCTL_TEMP5, "temp5", NULL, 0, 0644, NULL, - &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_temp}, + &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_therm}, {VT8231_SYSCTL_TEMP6, "temp6", NULL, 0, 0644, NULL, - &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_temp}, - {VT8231_SYSCTL_TEMP7, "temp7", NULL, 0, 0644, NULL, - &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_temp}, + &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_therm}, {VT8231_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &i2c_proc_real, &i2c_sysctl_real, NULL, &vt8231_fan}, {VT8231_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, &i2c_proc_real, @@ -485,33 +485,25 @@ static void vt8231_update_client(struct i2c_client *client) data->fan_min[i - 1] = vt_rdval(client, VT8231_REG_FAN_MIN(i)); } - for (i = 2; i <= 7; i++) { + for (i = 1; i <= 6; i++) { if(ISTEMP(i, data->uch_config)) { data->temp[i - 1] = vt_rdval(client, VT8231_REG_TEMP(i)) << 2; switch(i) { case 1: - /* ? */ - j = 0; + j = (vt_rdval(client, + VT8231_REG_TEMP_LOW12) & + 0xc0) >> 6; break; case 2: j = (vt_rdval(client, - VT8231_REG_TEMP_LOW2) & + VT8231_REG_TEMP_LOW12) & 0x30) >> 4; break; - case 3: - j = (vt_rdval(client, - VT8231_REG_TEMP_LOW3) & - 0xc0) >> 6; - break; - case 4: - case 5: - case 6: - case 7: default: j = (vt_rdval(client, - VT8231_REG_TEMP_LOW47) >> - ((i-4)*2)) & 0x03; + VT8231_REG_TEMP_LOW36) >> + ((i-3)*2)) & 0x03; break; } @@ -577,6 +569,33 @@ void vt8231_in(struct i2c_client *client, int operation, int ctl_name, } } +void vt8231_in5(struct i2c_client *client, int operation, int ctl_name, + int *nrels_mag, long *results) +{ + struct vt8231_data *data = client->data; + + if (operation == SENSORS_PROC_REAL_INFO) + *nrels_mag = 2; + else if (operation == SENSORS_PROC_REAL_READ) { + vt8231_update_client(client); + results[0] = IN5_FROM_REG(data->in_min[5]); + results[1] = IN5_FROM_REG(data->in_max[5]); + results[2] = IN5_FROM_REG(data->in[5]); + *nrels_mag = 3; + } else if (operation == SENSORS_PROC_REAL_WRITE) { + if (*nrels_mag >= 1) { + data->in_min[5] = IN5_TO_REG(results[0]); + vt8231_write_value(client, VT8231_REG_IN_MIN(5), + data->in_min[5]); + } + if (*nrels_mag >= 2) { + data->in_max[5] = IN5_TO_REG(results[1]); + vt8231_write_value(client, VT8231_REG_IN_MAX(5), + data->in_max[5]); + } + } +} + void vt8231_fan(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { @@ -610,25 +629,54 @@ void vt8231_temp(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { struct vt8231_data *data = client->data; - int nr = ctl_name - VT8231_SYSCTL_TEMP; if (operation == SENSORS_PROC_REAL_INFO) *nrels_mag = 1; else if (operation == SENSORS_PROC_REAL_READ) { vt8231_update_client(client); - results[0] = TEMP_FROM_REG(data->temp_over[nr]); - results[1] = TEMP_FROM_REG(data->temp_hyst[nr]); - results[2] = TEMP_FROM_REG10(data->temp[nr]); + results[0] = TEMP_FROM_REG(data->temp_over[0]); + results[1] = TEMP_FROM_REG(data->temp_hyst[0]); + results[2] = TEMP_FROM_REG10(data->temp[0]); *nrels_mag = 3; } else if (operation == SENSORS_PROC_REAL_WRITE) { if (*nrels_mag >= 1) { - data->temp_over[nr] = TEMP_TO_REG(results[0]); + data->temp_over[0] = TEMP_TO_REG(results[0]); + vt8231_write_value(client, + VT8231_REG_TEMP_OVER(1), + data->temp_over[0]); + } + if (*nrels_mag >= 2) { + data->temp_hyst[0] = TEMP_TO_REG(results[1]); + vt8231_write_value(client, + VT8231_REG_TEMP_HYST(1), + data->temp_hyst[0]); + } + } +} + +void vt8231_therm(struct i2c_client *client, int operation, int ctl_name, + int *nrels_mag, long *results) +{ + struct vt8231_data *data = client->data; + int nr = ctl_name - VT8231_SYSCTL_TEMP; + + if (operation == SENSORS_PROC_REAL_INFO) + *nrels_mag = 2; + else if (operation == SENSORS_PROC_REAL_READ) { + vt8231_update_client(client); + results[0] = THERM_FROM_REG(data->temp_over[nr] * 4); + results[1] = THERM_FROM_REG(data->temp_hyst[nr] * 4); + results[2] = THERM_FROM_REG(data->temp[nr]); + *nrels_mag = 3; + } else if (operation == SENSORS_PROC_REAL_WRITE) { + if (*nrels_mag >= 1) { + data->temp_over[nr] = THERM_TO_REG(results[0]); vt8231_write_value(client, VT8231_REG_TEMP_OVER(nr + 1), data->temp_over[nr]); } if (*nrels_mag >= 2) { - data->temp_hyst[nr] = TEMP_TO_REG(results[1]); + data->temp_hyst[nr] = THERM_TO_REG(results[1]); vt8231_write_value(client, VT8231_REG_TEMP_HYST(nr + 1), data->temp_hyst[nr]); diff --git a/lib/chips.c b/lib/chips.c index dea417c0..e46210af 100644 --- a/lib/chips.c +++ b/lib/chips.c @@ -4966,55 +4966,54 @@ static sensors_chip_feature vt8231_features[] = { SENSORS_VT8231_FAN2_MIN, "fan2_min", SENSORS_VT8231_FAN2, SENSORS_VT8231_FAN2, RW, VT8231_SYSCTL_FAN2, VALUE(1), 0 }, - /* no temp1 */ + { SENSORS_VT8231_TEMP, "temp1", NOMAP, NOMAP, + R, VT8231_SYSCTL_TEMP, VALUE(3), 1 }, + { SENSORS_VT8231_TEMP_HYST, "temp1_hyst", SENSORS_VT8231_TEMP, + SENSORS_VT8231_TEMP, RW, + VT8231_SYSCTL_TEMP, VALUE(2), 1 }, + { SENSORS_VT8231_TEMP_OVER, "temp1_over", SENSORS_VT8231_TEMP, + SENSORS_VT8231_TEMP, RW, + VT8231_SYSCTL_TEMP, VALUE(1), 1 }, { SENSORS_VT8231_TEMP2, "temp2", NOMAP, NOMAP, - R, VT8231_SYSCTL_TEMP2, VALUE(3), 1 }, + R, VT8231_SYSCTL_TEMP2, VALUE(3), 2 }, { SENSORS_VT8231_TEMP2_HYST, "temp2_hyst", SENSORS_VT8231_TEMP2, SENSORS_VT8231_TEMP2, RW, - VT8231_SYSCTL_TEMP2, VALUE(2), 1 }, + VT8231_SYSCTL_TEMP2, VALUE(2), 2 }, { SENSORS_VT8231_TEMP2_OVER, "temp2_over", SENSORS_VT8231_TEMP2, SENSORS_VT8231_TEMP2, RW, - VT8231_SYSCTL_TEMP2, VALUE(1), 1 }, + VT8231_SYSCTL_TEMP2, VALUE(1), 2 }, { SENSORS_VT8231_TEMP3, "temp3", NOMAP, NOMAP, - R, VT8231_SYSCTL_TEMP3, VALUE(3), 1 }, + R, VT8231_SYSCTL_TEMP3, VALUE(3), 2 }, { SENSORS_VT8231_TEMP3_HYST, "temp3_hyst", SENSORS_VT8231_TEMP3, SENSORS_VT8231_TEMP3, RW, - VT8231_SYSCTL_TEMP3, VALUE(2), 1 }, + VT8231_SYSCTL_TEMP3, VALUE(2), 2 }, { SENSORS_VT8231_TEMP3_OVER, "temp3_over", SENSORS_VT8231_TEMP3, SENSORS_VT8231_TEMP3, RW, - VT8231_SYSCTL_TEMP3, VALUE(1), 1 }, + VT8231_SYSCTL_TEMP3, VALUE(1), 2 }, { SENSORS_VT8231_TEMP4, "temp4", NOMAP, NOMAP, - R, VT8231_SYSCTL_TEMP4, VALUE(3), 1 }, + R, VT8231_SYSCTL_TEMP4, VALUE(3), 2 }, { SENSORS_VT8231_TEMP4_HYST, "temp4_hyst", SENSORS_VT8231_TEMP4, SENSORS_VT8231_TEMP4, RW, - VT8231_SYSCTL_TEMP4, VALUE(2), 1 }, + VT8231_SYSCTL_TEMP4, VALUE(2), 2 }, { SENSORS_VT8231_TEMP4_OVER, "temp4_over", SENSORS_VT8231_TEMP4, SENSORS_VT8231_TEMP4, RW, - VT8231_SYSCTL_TEMP4, VALUE(1), 1 }, + VT8231_SYSCTL_TEMP4, VALUE(1), 2 }, { SENSORS_VT8231_TEMP5, "temp5", NOMAP, NOMAP, - R, VT8231_SYSCTL_TEMP5, VALUE(3), 1 }, + R, VT8231_SYSCTL_TEMP5, VALUE(3), 2 }, { SENSORS_VT8231_TEMP5_HYST, "temp5_hyst", SENSORS_VT8231_TEMP5, SENSORS_VT8231_TEMP5, RW, - VT8231_SYSCTL_TEMP5, VALUE(2), 1 }, + VT8231_SYSCTL_TEMP5, VALUE(2), 2 }, { SENSORS_VT8231_TEMP5_OVER, "temp5_over", SENSORS_VT8231_TEMP5, SENSORS_VT8231_TEMP5, RW, - VT8231_SYSCTL_TEMP5, VALUE(1), 1 }, + VT8231_SYSCTL_TEMP5, VALUE(1), 2 }, { SENSORS_VT8231_TEMP6, "temp6", NOMAP, NOMAP, - R, VT8231_SYSCTL_TEMP6, VALUE(3), 1 }, + R, VT8231_SYSCTL_TEMP6, VALUE(3), 2 }, { SENSORS_VT8231_TEMP6_HYST, "temp6_hyst", SENSORS_VT8231_TEMP6, SENSORS_VT8231_TEMP6, RW, - VT8231_SYSCTL_TEMP6, VALUE(2), 1 }, + VT8231_SYSCTL_TEMP6, VALUE(2), 2 }, { SENSORS_VT8231_TEMP6_OVER, "temp6_over", SENSORS_VT8231_TEMP6, SENSORS_VT8231_TEMP6, RW, - VT8231_SYSCTL_TEMP6, VALUE(1), 1 }, - { SENSORS_VT8231_TEMP7, "temp7", NOMAP, NOMAP, - R, VT8231_SYSCTL_TEMP7, VALUE(3), 1 }, - { SENSORS_VT8231_TEMP7_HYST, "temp7_hyst", SENSORS_VT8231_TEMP7, - SENSORS_VT8231_TEMP7, RW, - VT8231_SYSCTL_TEMP7, VALUE(2), 1 }, - { SENSORS_VT8231_TEMP7_OVER, "temp7_over", SENSORS_VT8231_TEMP7, - SENSORS_VT8231_TEMP7, RW, - VT8231_SYSCTL_TEMP7, VALUE(1), 1 }, + VT8231_SYSCTL_TEMP6, VALUE(1), 2 }, { SENSORS_VT8231_FAN1_DIV, "fan1_div", SENSORS_VT8231_FAN1, NOMAP, RW, VT8231_SYSCTL_FAN_DIV, VALUE(1), diff --git a/lib/chips.h b/lib/chips.h index f7f67fca..8c403a84 100644 --- a/lib/chips.h +++ b/lib/chips.h @@ -1864,21 +1864,18 @@ #define SENSORS_VT8231_IN3 4 /* R */ #define SENSORS_VT8231_IN4 5 /* R */ #define SENSORS_VT8231_IN5 6 /* R */ -#define SENSORS_VT8231_IN6 7 /* R */ #define SENSORS_VT8231_IN0_MIN 11 /* RW */ #define SENSORS_VT8231_IN1_MIN 12 /* RW */ #define SENSORS_VT8231_IN2_MIN 13 /* RW */ #define SENSORS_VT8231_IN3_MIN 14 /* RW */ #define SENSORS_VT8231_IN4_MIN 15 /* RW */ #define SENSORS_VT8231_IN5_MIN 16 /* RW */ -#define SENSORS_VT8231_IN6_MIN 17 /* RW */ #define SENSORS_VT8231_IN0_MAX 21 /* RW */ #define SENSORS_VT8231_IN1_MAX 22 /* RW */ #define SENSORS_VT8231_IN2_MAX 23 /* RW */ #define SENSORS_VT8231_IN3_MAX 24 /* RW */ #define SENSORS_VT8231_IN4_MAX 25 /* RW */ #define SENSORS_VT8231_IN5_MAX 26 /* RW */ -#define SENSORS_VT8231_IN6_MAX 27 /* RW */ #define SENSORS_VT8231_FAN1 31 /* R */ #define SENSORS_VT8231_FAN2 32 /* R */ #define SENSORS_VT8231_FAN1_MIN 41 /* RW */ @@ -1901,9 +1898,6 @@ #define SENSORS_VT8231_TEMP6 66 /* R */ #define SENSORS_VT8231_TEMP6_HYST 67 /* RW */ #define SENSORS_VT8231_TEMP6_OVER 68 /* RW */ -#define SENSORS_VT8231_TEMP7 69 /* R */ -#define SENSORS_VT8231_TEMP7_HYST 70 /* RW */ -#define SENSORS_VT8231_TEMP7_OVER 71 /* RW */ #define SENSORS_VT8231_FAN1_DIV 75 /* RW */ #define SENSORS_VT8231_FAN2_DIV 76 /* RW */ #define SENSORS_VT8231_ALARMS 81 /* R */ diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index c4b30539..51d85d1a 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -4649,8 +4649,7 @@ void print_vt8231(const sensors_chip_name *name) printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", cur,min,max,alarms&VT8231_ALARM_IN0?"ALARM":""); } - } else - printf("ERROR: Can't get IN0 data!\n"); + } free(label); if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_IN1,&label,&valid) && !sensors_get_feature(*name,SENSORS_VT8231_IN1,&cur) && @@ -4661,8 +4660,7 @@ void print_vt8231(const sensors_chip_name *name) printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", cur,min,max,alarms&VT8231_ALARM_IN1?"ALARM":""); } - } else - printf("ERROR: Can't get IN1 data!\n"); + } free(label); if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_IN2,&label,&valid) && !sensors_get_feature(*name,SENSORS_VT8231_IN2,&cur) && @@ -4673,8 +4671,7 @@ void print_vt8231(const sensors_chip_name *name) printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", cur,min,max,alarms&VT8231_ALARM_IN2?"ALARM":""); } - } else - printf("ERROR: Can't get IN2 data!\n"); + } free(label); if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_IN3,&label,&valid) && !sensors_get_feature(*name,SENSORS_VT8231_IN3,&cur) && @@ -4685,8 +4682,7 @@ void print_vt8231(const sensors_chip_name *name) printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", cur,min,max,alarms&VT8231_ALARM_IN3?"ALARM":""); } - } else - printf("ERROR: Can't get IN3 data!\n"); + } free(label); if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_IN4,&label,&valid) && !sensors_get_feature(*name,SENSORS_VT8231_IN4,&cur) && @@ -4697,8 +4693,7 @@ void print_vt8231(const sensors_chip_name *name) printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", cur,min,max,alarms&VT8231_ALARM_IN4?"ALARM":""); } - } else - printf("ERROR: Can't get IN4 data!\n"); + } free(label); if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_IN5,&label,&valid) && !sensors_get_feature(*name,SENSORS_VT8231_IN5,&cur) && @@ -4738,7 +4733,19 @@ void print_vt8231(const sensors_chip_name *name) printf("ERROR: Can't get FAN2 data!\n"); free(label); - /* no temp 1 */ + if (!sensors_get_label_and_valid(*name, SENSORS_VT8231_TEMP, + &label, &valid) && + !sensors_get_feature(*name, SENSORS_VT8231_TEMP, &cur) && + !sensors_get_feature(*name, SENSORS_VT8231_TEMP_HYST, &min) && + !sensors_get_feature(*name, SENSORS_VT8231_TEMP_OVER, &max)) { + if (valid) { + print_label(label, 10); + print_temp_info(cur, max, min, HYST, 1, 0); + printf(" %s\n", alarms & VT8231_ALARM_TEMP ? "ALARM" : ""); + } + } else + printf("ERROR: Can't get TEMP1 data!\n"); + free(label); if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_TEMP2,&label,&valid) && !sensors_get_feature(*name,SENSORS_VT8231_TEMP2,&cur) && !sensors_get_feature(*name,SENSORS_VT8231_TEMP2_HYST,&min) && @@ -4748,8 +4755,7 @@ void print_vt8231(const sensors_chip_name *name) print_temp_info( cur, max, min, HYST, 1, 0); printf(" %s\n", alarms & VT8231_ALARM_TEMP2 ? "ALARM" : "" ); } - } else - printf("ERROR: Can't get TEMP2 data!\n"); + } free(label); if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_TEMP3,&label,&valid) && !sensors_get_feature(*name,SENSORS_VT8231_TEMP3,&cur) && @@ -4760,8 +4766,7 @@ void print_vt8231(const sensors_chip_name *name) print_temp_info( cur, max, min, HYST, 1, 0); printf(" %s\n", alarms & VT8231_ALARM_TEMP3 ? "ALARM" : "" ); } - } else - printf("ERROR: Can't get TEMP3 data!\n"); + } free(label); if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_TEMP4,&label,&valid) && !sensors_get_feature(*name,SENSORS_VT8231_TEMP4,&cur) && @@ -4772,8 +4777,7 @@ void print_vt8231(const sensors_chip_name *name) print_temp_info( cur, max, min, HYST, 1, 0); printf(" %s\n", alarms & VT8231_ALARM_TEMP4 ? "ALARM" : "" ); } - } else - printf("ERROR: Can't get TEMP4 data!\n"); + } free(label); if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_TEMP5,&label,&valid) && !sensors_get_feature(*name,SENSORS_VT8231_TEMP5,&cur) && @@ -4784,8 +4788,7 @@ void print_vt8231(const sensors_chip_name *name) print_temp_info( cur, max, min, HYST, 1, 0); printf(" %s\n", alarms & VT8231_ALARM_TEMP5 ? "ALARM" : "" ); } - } else - printf("ERROR: Can't get TEMP5 data!\n"); + } free(label); if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_TEMP6,&label,&valid) && !sensors_get_feature(*name,SENSORS_VT8231_TEMP6,&cur) && @@ -4796,20 +4799,7 @@ void print_vt8231(const sensors_chip_name *name) print_temp_info( cur, max, min, HYST, 1, 0); printf(" %s\n", alarms & VT8231_ALARM_TEMP6 ? "ALARM" : "" ); } - } else - printf("ERROR: Can't get TEMP6 data!\n"); - free(label); - if (!sensors_get_label_and_valid(*name,SENSORS_VT8231_TEMP7,&label,&valid) && - !sensors_get_feature(*name,SENSORS_VT8231_TEMP7,&cur) && - !sensors_get_feature(*name,SENSORS_VT8231_TEMP7_HYST,&min) && - !sensors_get_feature(*name,SENSORS_VT8231_TEMP7_OVER,&max)) { - if (valid) { - print_label(label,10); - print_temp_info( cur, max, min, HYST, 1, 0); - printf(" %s\n", alarms & VT8231_ALARM_TEMP7 ? "ALARM" : "" ); - } - } else - printf("ERROR: Can't get TEMP7 data!\n"); + } free(label); print_vid_info(name, SENSORS_VT8231_VID, SENSORS_VT8231_VRM);