diff options
Diffstat (limited to 'drivers/hwmon/f71882fg.c')
-rw-r--r-- | drivers/hwmon/f71882fg.c | 117 |
1 files changed, 60 insertions, 57 deletions
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index 1cfd2231677a..2604c6d7ea58 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c | |||
@@ -63,9 +63,9 @@ | |||
63 | #define F71882FG_REG_FAN_STATUS 0x92 | 63 | #define F71882FG_REG_FAN_STATUS 0x92 |
64 | #define F71882FG_REG_FAN_BEEP 0x93 | 64 | #define F71882FG_REG_FAN_BEEP 0x93 |
65 | 65 | ||
66 | #define F71882FG_REG_TEMP(nr) (0x72 + 2 * (nr)) | 66 | #define F71882FG_REG_TEMP(nr) (0x70 + 2 * (nr)) |
67 | #define F71882FG_REG_TEMP_OVT(nr) (0x82 + 2 * (nr)) | 67 | #define F71882FG_REG_TEMP_OVT(nr) (0x80 + 2 * (nr)) |
68 | #define F71882FG_REG_TEMP_HIGH(nr) (0x83 + 2 * (nr)) | 68 | #define F71882FG_REG_TEMP_HIGH(nr) (0x81 + 2 * (nr)) |
69 | #define F71882FG_REG_TEMP_STATUS 0x62 | 69 | #define F71882FG_REG_TEMP_STATUS 0x62 |
70 | #define F71882FG_REG_TEMP_BEEP 0x63 | 70 | #define F71882FG_REG_TEMP_BEEP 0x63 |
71 | #define F71882FG_REG_TEMP_HYST1 0x6C | 71 | #define F71882FG_REG_TEMP_HYST1 0x6C |
@@ -138,11 +138,14 @@ struct f71882fg_data { | |||
138 | u16 fan_full_speed[4]; | 138 | u16 fan_full_speed[4]; |
139 | u8 fan_status; | 139 | u8 fan_status; |
140 | u8 fan_beep; | 140 | u8 fan_beep; |
141 | u8 temp[3]; | 141 | /* Note: all models have only 3 temperature channels, but on some |
142 | u8 temp_ovt[3]; | 142 | they are addressed as 0-2 and on others as 1-3, so for coding |
143 | u8 temp_high[3]; | 143 | convenience we reserve space for 4 channels */ |
144 | u8 temp_hyst[3]; | 144 | u8 temp[4]; |
145 | u8 temp_type[3]; | 145 | u8 temp_ovt[4]; |
146 | u8 temp_high[4]; | ||
147 | u8 temp_hyst[4]; | ||
148 | u8 temp_type[4]; | ||
146 | u8 temp_status; | 149 | u8 temp_status; |
147 | u8 temp_beep; | 150 | u8 temp_beep; |
148 | u8 temp_diode_open; | 151 | u8 temp_diode_open; |
@@ -264,48 +267,48 @@ static struct sensor_device_attribute_2 f718x2fg_in_temp_attr[] = { | |||
264 | SENSOR_ATTR_2(in6_input, S_IRUGO, show_in, NULL, 0, 6), | 267 | SENSOR_ATTR_2(in6_input, S_IRUGO, show_in, NULL, 0, 6), |
265 | SENSOR_ATTR_2(in7_input, S_IRUGO, show_in, NULL, 0, 7), | 268 | SENSOR_ATTR_2(in7_input, S_IRUGO, show_in, NULL, 0, 7), |
266 | SENSOR_ATTR_2(in8_input, S_IRUGO, show_in, NULL, 0, 8), | 269 | SENSOR_ATTR_2(in8_input, S_IRUGO, show_in, NULL, 0, 8), |
267 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 0), | 270 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 1), |
268 | SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_max, | 271 | SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_max, |
269 | store_temp_max, 0, 0), | 272 | store_temp_max, 0, 1), |
270 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, | 273 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, |
271 | store_temp_max_hyst, 0, 0), | 274 | store_temp_max_hyst, 0, 1), |
272 | SENSOR_ATTR_2(temp1_crit, S_IRUGO|S_IWUSR, show_temp_crit, | 275 | SENSOR_ATTR_2(temp1_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
273 | store_temp_crit, 0, 0), | 276 | store_temp_crit, 0, 1), |
274 | SENSOR_ATTR_2(temp1_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, | 277 | SENSOR_ATTR_2(temp1_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
275 | 0, 0), | 278 | 0, 1), |
276 | SENSOR_ATTR_2(temp1_type, S_IRUGO, show_temp_type, NULL, 0, 0), | 279 | SENSOR_ATTR_2(temp1_type, S_IRUGO, show_temp_type, NULL, 0, 1), |
277 | SENSOR_ATTR_2(temp1_beep, S_IRUGO|S_IWUSR, show_temp_beep, | 280 | SENSOR_ATTR_2(temp1_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
278 | store_temp_beep, 0, 0), | 281 | store_temp_beep, 0, 1), |
279 | SENSOR_ATTR_2(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 0), | 282 | SENSOR_ATTR_2(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 1), |
280 | SENSOR_ATTR_2(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0, 0), | 283 | SENSOR_ATTR_2(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0, 1), |
281 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 1), | 284 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 2), |
282 | SENSOR_ATTR_2(temp2_max, S_IRUGO|S_IWUSR, show_temp_max, | 285 | SENSOR_ATTR_2(temp2_max, S_IRUGO|S_IWUSR, show_temp_max, |
283 | store_temp_max, 0, 1), | 286 | store_temp_max, 0, 2), |
284 | SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, | 287 | SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, |
285 | store_temp_max_hyst, 0, 1), | 288 | store_temp_max_hyst, 0, 2), |
286 | SENSOR_ATTR_2(temp2_crit, S_IRUGO|S_IWUSR, show_temp_crit, | 289 | SENSOR_ATTR_2(temp2_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
287 | store_temp_crit, 0, 1), | 290 | store_temp_crit, 0, 2), |
288 | SENSOR_ATTR_2(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, | 291 | SENSOR_ATTR_2(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
289 | 0, 1), | 292 | 0, 2), |
290 | SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 1), | 293 | SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 2), |
291 | SENSOR_ATTR_2(temp2_beep, S_IRUGO|S_IWUSR, show_temp_beep, | 294 | SENSOR_ATTR_2(temp2_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
292 | store_temp_beep, 0, 1), | 295 | store_temp_beep, 0, 2), |
293 | SENSOR_ATTR_2(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 1), | 296 | SENSOR_ATTR_2(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 2), |
294 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 1), | 297 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), |
295 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 2), | 298 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 3), |
296 | SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_max, | 299 | SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_max, |
297 | store_temp_max, 0, 2), | 300 | store_temp_max, 0, 3), |
298 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, | 301 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, |
299 | store_temp_max_hyst, 0, 2), | 302 | store_temp_max_hyst, 0, 3), |
300 | SENSOR_ATTR_2(temp3_crit, S_IRUGO|S_IWUSR, show_temp_crit, | 303 | SENSOR_ATTR_2(temp3_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
301 | store_temp_crit, 0, 2), | 304 | store_temp_crit, 0, 3), |
302 | SENSOR_ATTR_2(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, | 305 | SENSOR_ATTR_2(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
303 | 0, 2), | 306 | 0, 3), |
304 | SENSOR_ATTR_2(temp3_type, S_IRUGO, show_temp_type, NULL, 0, 2), | 307 | SENSOR_ATTR_2(temp3_type, S_IRUGO, show_temp_type, NULL, 0, 3), |
305 | SENSOR_ATTR_2(temp3_beep, S_IRUGO|S_IWUSR, show_temp_beep, | 308 | SENSOR_ATTR_2(temp3_beep, S_IRUGO|S_IWUSR, show_temp_beep, |
306 | store_temp_beep, 0, 2), | 309 | store_temp_beep, 0, 3), |
307 | SENSOR_ATTR_2(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 2), | 310 | SENSOR_ATTR_2(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 3), |
308 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), | 311 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 3), |
309 | }; | 312 | }; |
310 | 313 | ||
311 | static struct sensor_device_attribute_2 f71882fg_in_temp_attr[] = { | 314 | static struct sensor_device_attribute_2 f71882fg_in_temp_attr[] = { |
@@ -678,7 +681,7 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
678 | } | 681 | } |
679 | 682 | ||
680 | /* Get High & boundary temps*/ | 683 | /* Get High & boundary temps*/ |
681 | for (nr = 0; nr < 3; nr++) { | 684 | for (nr = 1; nr < 4; nr++) { |
682 | data->temp_ovt[nr] = f71882fg_read8(data, | 685 | data->temp_ovt[nr] = f71882fg_read8(data, |
683 | F71882FG_REG_TEMP_OVT(nr)); | 686 | F71882FG_REG_TEMP_OVT(nr)); |
684 | data->temp_high[nr] = f71882fg_read8(data, | 687 | data->temp_high[nr] = f71882fg_read8(data, |
@@ -686,25 +689,25 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
686 | } | 689 | } |
687 | 690 | ||
688 | /* Have to hardcode hyst*/ | 691 | /* Have to hardcode hyst*/ |
689 | data->temp_hyst[0] = f71882fg_read8(data, | 692 | data->temp_hyst[1] = f71882fg_read8(data, |
690 | F71882FG_REG_TEMP_HYST1) >> 4; | 693 | F71882FG_REG_TEMP_HYST1) >> 4; |
691 | /* Hyst temps 2 & 3 stored in same register */ | 694 | /* Hyst temps 2 & 3 stored in same register */ |
692 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_HYST23); | 695 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_HYST23); |
693 | data->temp_hyst[1] = reg & 0x0F; | 696 | data->temp_hyst[2] = reg & 0x0F; |
694 | data->temp_hyst[2] = reg >> 4; | 697 | data->temp_hyst[3] = reg >> 4; |
695 | 698 | ||
696 | /* Have to hardcode type, because temp1 is special */ | 699 | /* Have to hardcode type, because temp1 is special */ |
697 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_TYPE); | 700 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_TYPE); |
698 | reg2 = f71882fg_read8(data, F71882FG_REG_PECI); | 701 | reg2 = f71882fg_read8(data, F71882FG_REG_PECI); |
699 | if ((reg2 & 0x03) == 0x01) | 702 | if ((reg2 & 0x03) == 0x01) |
700 | data->temp_type[0] = 6 /* PECI */; | 703 | data->temp_type[1] = 6 /* PECI */; |
701 | else if ((reg2 & 0x03) == 0x02) | 704 | else if ((reg2 & 0x03) == 0x02) |
702 | data->temp_type[0] = 5 /* AMDSI */; | 705 | data->temp_type[1] = 5 /* AMDSI */; |
703 | else | 706 | else |
704 | data->temp_type[0] = (reg & 0x02) ? 2 : 4; | 707 | data->temp_type[1] = (reg & 0x02) ? 2 : 4; |
705 | 708 | ||
706 | data->temp_type[1] = (reg & 0x04) ? 2 : 4; | 709 | data->temp_type[2] = (reg & 0x04) ? 2 : 4; |
707 | data->temp_type[2] = (reg & 0x08) ? 2 : 4; | 710 | data->temp_type[3] = (reg & 0x08) ? 2 : 4; |
708 | 711 | ||
709 | data->temp_beep = f71882fg_read8(data, F71882FG_REG_TEMP_BEEP); | 712 | data->temp_beep = f71882fg_read8(data, F71882FG_REG_TEMP_BEEP); |
710 | 713 | ||
@@ -763,7 +766,7 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
763 | F71882FG_REG_TEMP_STATUS); | 766 | F71882FG_REG_TEMP_STATUS); |
764 | data->temp_diode_open = f71882fg_read8(data, | 767 | data->temp_diode_open = f71882fg_read8(data, |
765 | F71882FG_REG_TEMP_DIODE_OPEN); | 768 | F71882FG_REG_TEMP_DIODE_OPEN); |
766 | for (nr = 0; nr < 3; nr++) | 769 | for (nr = 1; nr < 4; nr++) |
767 | data->temp[nr] = f71882fg_read8(data, | 770 | data->temp[nr] = f71882fg_read8(data, |
768 | F71882FG_REG_TEMP(nr)); | 771 | F71882FG_REG_TEMP(nr)); |
769 | 772 | ||
@@ -1032,19 +1035,19 @@ static ssize_t store_temp_max_hyst(struct device *dev, struct device_attribute | |||
1032 | 1035 | ||
1033 | /* convert value to register contents */ | 1036 | /* convert value to register contents */ |
1034 | switch (nr) { | 1037 | switch (nr) { |
1035 | case 0: | ||
1036 | val = val << 4; | ||
1037 | break; | ||
1038 | case 1: | 1038 | case 1: |
1039 | val = val | (data->temp_hyst[2] << 4); | 1039 | val = val << 4; |
1040 | break; | 1040 | break; |
1041 | case 2: | 1041 | case 2: |
1042 | val = data->temp_hyst[1] | (val << 4); | 1042 | val = val | (data->temp_hyst[3] << 4); |
1043 | break; | ||
1044 | case 3: | ||
1045 | val = data->temp_hyst[2] | (val << 4); | ||
1043 | break; | 1046 | break; |
1044 | } | 1047 | } |
1045 | 1048 | ||
1046 | f71882fg_write8(data, nr ? F71882FG_REG_TEMP_HYST23 : | 1049 | f71882fg_write8(data, (nr <= 1) ? F71882FG_REG_TEMP_HYST1 : |
1047 | F71882FG_REG_TEMP_HYST1, val); | 1050 | F71882FG_REG_TEMP_HYST23, val); |
1048 | 1051 | ||
1049 | store_temp_max_hyst_exit: | 1052 | store_temp_max_hyst_exit: |
1050 | mutex_unlock(&data->update_lock); | 1053 | mutex_unlock(&data->update_lock); |
@@ -1103,7 +1106,7 @@ static ssize_t show_temp_beep(struct device *dev, struct device_attribute | |||
1103 | struct f71882fg_data *data = f71882fg_update_device(dev); | 1106 | struct f71882fg_data *data = f71882fg_update_device(dev); |
1104 | int nr = to_sensor_dev_attr_2(devattr)->index; | 1107 | int nr = to_sensor_dev_attr_2(devattr)->index; |
1105 | 1108 | ||
1106 | if (data->temp_beep & (1 << (nr + 1))) | 1109 | if (data->temp_beep & (1 << nr)) |
1107 | return sprintf(buf, "1\n"); | 1110 | return sprintf(buf, "1\n"); |
1108 | else | 1111 | else |
1109 | return sprintf(buf, "0\n"); | 1112 | return sprintf(buf, "0\n"); |
@@ -1118,9 +1121,9 @@ static ssize_t store_temp_beep(struct device *dev, struct device_attribute | |||
1118 | 1121 | ||
1119 | mutex_lock(&data->update_lock); | 1122 | mutex_lock(&data->update_lock); |
1120 | if (val) | 1123 | if (val) |
1121 | data->temp_beep |= 1 << (nr + 1); | 1124 | data->temp_beep |= 1 << nr; |
1122 | else | 1125 | else |
1123 | data->temp_beep &= ~(1 << (nr + 1)); | 1126 | data->temp_beep &= ~(1 << nr); |
1124 | 1127 | ||
1125 | f71882fg_write8(data, F71882FG_REG_TEMP_BEEP, data->temp_beep); | 1128 | f71882fg_write8(data, F71882FG_REG_TEMP_BEEP, data->temp_beep); |
1126 | mutex_unlock(&data->update_lock); | 1129 | mutex_unlock(&data->update_lock); |
@@ -1134,7 +1137,7 @@ static ssize_t show_temp_alarm(struct device *dev, struct device_attribute | |||
1134 | struct f71882fg_data *data = f71882fg_update_device(dev); | 1137 | struct f71882fg_data *data = f71882fg_update_device(dev); |
1135 | int nr = to_sensor_dev_attr_2(devattr)->index; | 1138 | int nr = to_sensor_dev_attr_2(devattr)->index; |
1136 | 1139 | ||
1137 | if (data->temp_status & (1 << (nr + 1))) | 1140 | if (data->temp_status & (1 << nr)) |
1138 | return sprintf(buf, "1\n"); | 1141 | return sprintf(buf, "1\n"); |
1139 | else | 1142 | else |
1140 | return sprintf(buf, "0\n"); | 1143 | return sprintf(buf, "0\n"); |
@@ -1146,7 +1149,7 @@ static ssize_t show_temp_fault(struct device *dev, struct device_attribute | |||
1146 | struct f71882fg_data *data = f71882fg_update_device(dev); | 1149 | struct f71882fg_data *data = f71882fg_update_device(dev); |
1147 | int nr = to_sensor_dev_attr_2(devattr)->index; | 1150 | int nr = to_sensor_dev_attr_2(devattr)->index; |
1148 | 1151 | ||
1149 | if (data->temp_diode_open & (1 << (nr + 1))) | 1152 | if (data->temp_diode_open & (1 << nr)) |
1150 | return sprintf(buf, "1\n"); | 1153 | return sprintf(buf, "1\n"); |
1151 | else | 1154 | else |
1152 | return sprintf(buf, "0\n"); | 1155 | return sprintf(buf, "0\n"); |