diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-12-19 16:17:02 -0500 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2012-12-19 16:17:02 -0500 |
commit | 5d8d2f2bdbd0812dfad05ca37e4b28912fca7e33 (patch) | |
tree | bf4270cef12358a9557688771605c3b226c95441 | |
parent | 483db43e81f4958e3cd11a990112e8082a6a5261 (diff) |
hwmon: (it87) Report thermal sensor type as Intel PECI if appropriate
IT8721 and IT8728 support Intel PECI temperature reporting. Each sensor
can be programmed to display the temperature reported on the PECI interface.
If configured for Intel PECI, the driver reported the wrong sensor type for
the respective thermal sensor. Fix the code to correctly report it as
"Intel PECI (6)".
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r-- | Documentation/hwmon/it87 | 3 | ||||
-rw-r--r-- | drivers/hwmon/it87.c | 20 |
2 files changed, 19 insertions, 4 deletions
diff --git a/Documentation/hwmon/it87 b/Documentation/hwmon/it87 index e1f38287fbb3..8386aadc0a82 100644 --- a/Documentation/hwmon/it87 +++ b/Documentation/hwmon/it87 | |||
@@ -217,4 +217,5 @@ Temperature offset attributes | |||
217 | The driver supports temp[1-3]_offset sysfs attributes to adjust the reported | 217 | The driver supports temp[1-3]_offset sysfs attributes to adjust the reported |
218 | temperature for thermal diodes or diode-connected thermal transistors. | 218 | temperature for thermal diodes or diode-connected thermal transistors. |
219 | If a temperature sensor is configured for thermistors, the attribute values | 219 | If a temperature sensor is configured for thermistors, the attribute values |
220 | are ignored. | 220 | are ignored. If the thermal sensor type is Intel PECI, the temperature offset |
221 | must be programmed to the critical CPU temperature. | ||
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index e8fdc438df0a..3827aa9aa11e 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -231,6 +231,7 @@ static const u8 IT87_REG_TEMP_OFFSET[] = { 0x56, 0x57, 0x59 }; | |||
231 | struct it87_devices { | 231 | struct it87_devices { |
232 | const char *name; | 232 | const char *name; |
233 | u16 features; | 233 | u16 features; |
234 | u16 peci_mask; | ||
234 | }; | 235 | }; |
235 | 236 | ||
236 | #define FEAT_12MV_ADC (1 << 0) | 237 | #define FEAT_12MV_ADC (1 << 0) |
@@ -238,6 +239,7 @@ struct it87_devices { | |||
238 | #define FEAT_OLD_AUTOPWM (1 << 2) | 239 | #define FEAT_OLD_AUTOPWM (1 << 2) |
239 | #define FEAT_16BIT_FANS (1 << 3) | 240 | #define FEAT_16BIT_FANS (1 << 3) |
240 | #define FEAT_TEMP_OFFSET (1 << 4) | 241 | #define FEAT_TEMP_OFFSET (1 << 4) |
242 | #define FEAT_TEMP_PECI (1 << 5) | ||
241 | 243 | ||
242 | static const struct it87_devices it87_devices[] = { | 244 | static const struct it87_devices it87_devices[] = { |
243 | [it87] = { | 245 | [it87] = { |
@@ -263,12 +265,14 @@ static const struct it87_devices it87_devices[] = { | |||
263 | [it8721] = { | 265 | [it8721] = { |
264 | .name = "it8721", | 266 | .name = "it8721", |
265 | .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS | 267 | .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS |
266 | | FEAT_TEMP_OFFSET, | 268 | | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI, |
269 | .peci_mask = 0x05, | ||
267 | }, | 270 | }, |
268 | [it8728] = { | 271 | [it8728] = { |
269 | .name = "it8728", | 272 | .name = "it8728", |
270 | .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS | 273 | .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS |
271 | | FEAT_TEMP_OFFSET, | 274 | | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI, |
275 | .peci_mask = 0x07, | ||
272 | }, | 276 | }, |
273 | [it8782] = { | 277 | [it8782] = { |
274 | .name = "it8782", | 278 | .name = "it8782", |
@@ -285,6 +289,8 @@ static const struct it87_devices it87_devices[] = { | |||
285 | #define has_newer_autopwm(data) ((data)->features & FEAT_NEWER_AUTOPWM) | 289 | #define has_newer_autopwm(data) ((data)->features & FEAT_NEWER_AUTOPWM) |
286 | #define has_old_autopwm(data) ((data)->features & FEAT_OLD_AUTOPWM) | 290 | #define has_old_autopwm(data) ((data)->features & FEAT_OLD_AUTOPWM) |
287 | #define has_temp_offset(data) ((data)->features & FEAT_TEMP_OFFSET) | 291 | #define has_temp_offset(data) ((data)->features & FEAT_TEMP_OFFSET) |
292 | #define has_temp_peci(data, nr) (((data)->features & FEAT_TEMP_PECI) && \ | ||
293 | ((data)->peci_mask & (1 << nr))) | ||
288 | 294 | ||
289 | struct it87_sio_data { | 295 | struct it87_sio_data { |
290 | enum chips type; | 296 | enum chips type; |
@@ -309,6 +315,7 @@ struct it87_data { | |||
309 | struct device *hwmon_dev; | 315 | struct device *hwmon_dev; |
310 | enum chips type; | 316 | enum chips type; |
311 | u16 features; | 317 | u16 features; |
318 | u16 peci_mask; | ||
312 | 319 | ||
313 | unsigned short addr; | 320 | unsigned short addr; |
314 | const char *name; | 321 | const char *name; |
@@ -617,6 +624,8 @@ static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr, | |||
617 | struct it87_data *data = it87_update_device(dev); | 624 | struct it87_data *data = it87_update_device(dev); |
618 | u8 reg = data->sensor; /* In case value is updated while used */ | 625 | u8 reg = data->sensor; /* In case value is updated while used */ |
619 | 626 | ||
627 | if (has_temp_peci(data, nr) && (reg >> 6 == nr + 1)) | ||
628 | return sprintf(buf, "6\n"); /* Intel PECI */ | ||
620 | if (reg & (1 << nr)) | 629 | if (reg & (1 << nr)) |
621 | return sprintf(buf, "3\n"); /* thermal diode */ | 630 | return sprintf(buf, "3\n"); /* thermal diode */ |
622 | if (reg & (8 << nr)) | 631 | if (reg & (8 << nr)) |
@@ -640,16 +649,20 @@ static ssize_t set_temp_type(struct device *dev, struct device_attribute *attr, | |||
640 | reg = it87_read_value(data, IT87_REG_TEMP_ENABLE); | 649 | reg = it87_read_value(data, IT87_REG_TEMP_ENABLE); |
641 | reg &= ~(1 << nr); | 650 | reg &= ~(1 << nr); |
642 | reg &= ~(8 << nr); | 651 | reg &= ~(8 << nr); |
652 | if (has_temp_peci(data, nr) && (reg >> 6 == nr + 1 || val == 6)) | ||
653 | reg &= 0x3f; | ||
643 | if (val == 2) { /* backwards compatibility */ | 654 | if (val == 2) { /* backwards compatibility */ |
644 | dev_warn(dev, | 655 | dev_warn(dev, |
645 | "Sensor type 2 is deprecated, please use 4 instead\n"); | 656 | "Sensor type 2 is deprecated, please use 4 instead\n"); |
646 | val = 4; | 657 | val = 4; |
647 | } | 658 | } |
648 | /* 3 = thermal diode; 4 = thermistor; 0 = disabled */ | 659 | /* 3 = thermal diode; 4 = thermistor; 6 = Intel PECI; 0 = disabled */ |
649 | if (val == 3) | 660 | if (val == 3) |
650 | reg |= 1 << nr; | 661 | reg |= 1 << nr; |
651 | else if (val == 4) | 662 | else if (val == 4) |
652 | reg |= 8 << nr; | 663 | reg |= 8 << nr; |
664 | else if (has_temp_peci(data, nr) && val == 6) | ||
665 | reg |= (nr + 1) << 6; | ||
653 | else if (val != 0) | 666 | else if (val != 0) |
654 | return -EINVAL; | 667 | return -EINVAL; |
655 | 668 | ||
@@ -1966,6 +1979,7 @@ static int it87_probe(struct platform_device *pdev) | |||
1966 | data->addr = res->start; | 1979 | data->addr = res->start; |
1967 | data->type = sio_data->type; | 1980 | data->type = sio_data->type; |
1968 | data->features = it87_devices[sio_data->type].features; | 1981 | data->features = it87_devices[sio_data->type].features; |
1982 | data->peci_mask = it87_devices[sio_data->type].peci_mask; | ||
1969 | data->name = it87_devices[sio_data->type].name; | 1983 | data->name = it87_devices[sio_data->type].name; |
1970 | /* | 1984 | /* |
1971 | * IT8705F Datasheet 0.4.1, 3h == Version G. | 1985 | * IT8705F Datasheet 0.4.1, 3h == Version G. |