summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/it87.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2015-02-12 10:11:38 -0500
committerGuenter Roeck <linux@roeck-us.net>2015-03-09 12:59:35 -0400
commit9faf28ca4beb24cd5a01f38c5655f5ae92d834ba (patch)
tree2938de3eb380b02ae898684e2f9171e8fbfe3cf5 /drivers/hwmon/it87.c
parentfd044868e8056720b52d41bb61da0fbf7f04fd50 (diff)
hwmon: (it87) Add feature flags for fans count and 16-bit fan configuration
Fans 4-5 are not supported on all chips and revisions. Also, 16-bit fan counters are always enabled on some chips. Provide feature flags to simplify adding support for new chips. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/it87.c')
-rw-r--r--drivers/hwmon/it87.c69
1 files changed, 36 insertions, 33 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index e8cbefb9c96d..48b48939d893 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -252,6 +252,8 @@ struct it87_devices {
252#define FEAT_TEMP_OFFSET (1 << 4) 252#define FEAT_TEMP_OFFSET (1 << 4)
253#define FEAT_TEMP_PECI (1 << 5) 253#define FEAT_TEMP_PECI (1 << 5)
254#define FEAT_TEMP_OLD_PECI (1 << 6) 254#define FEAT_TEMP_OLD_PECI (1 << 6)
255#define FEAT_FAN16_CONFIG (1 << 7) /* Need to enable 16-bit fans */
256#define FEAT_FIVE_FANS (1 << 8) /* Supports five fans */
255 257
256static const struct it87_devices it87_devices[] = { 258static const struct it87_devices it87_devices[] = {
257 [it87] = { 259 [it87] = {
@@ -264,67 +266,71 @@ static const struct it87_devices it87_devices[] = {
264 }, 266 },
265 [it8716] = { 267 [it8716] = {
266 .name = "it8716", 268 .name = "it8716",
267 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET, 269 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
270 | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS,
268 }, 271 },
269 [it8718] = { 272 [it8718] = {
270 .name = "it8718", 273 .name = "it8718",
271 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET 274 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
272 | FEAT_TEMP_OLD_PECI, 275 | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS,
273 .old_peci_mask = 0x4, 276 .old_peci_mask = 0x4,
274 }, 277 },
275 [it8720] = { 278 [it8720] = {
276 .name = "it8720", 279 .name = "it8720",
277 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET 280 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
278 | FEAT_TEMP_OLD_PECI, 281 | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS,
279 .old_peci_mask = 0x4, 282 .old_peci_mask = 0x4,
280 }, 283 },
281 [it8721] = { 284 [it8721] = {
282 .name = "it8721", 285 .name = "it8721",
283 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 286 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
284 | FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI, 287 | FEAT_TEMP_OFFSET | FEAT_TEMP_OLD_PECI | FEAT_TEMP_PECI
288 | FEAT_FAN16_CONFIG | FEAT_FIVE_FANS,
285 .peci_mask = 0x05, 289 .peci_mask = 0x05,
286 .old_peci_mask = 0x02, /* Actually reports PCH */ 290 .old_peci_mask = 0x02, /* Actually reports PCH */
287 }, 291 },
288 [it8728] = { 292 [it8728] = {
289 .name = "it8728", 293 .name = "it8728",
290 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 294 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
291 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI, 295 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI | FEAT_FIVE_FANS,
292 .peci_mask = 0x07, 296 .peci_mask = 0x07,
293 }, 297 },
294 [it8771] = { 298 [it8771] = {
295 .name = "it8771", 299 .name = "it8771",
296 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 300 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
297 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI, 301 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI,
298 /* PECI: guesswork */ 302 /* PECI: guesswork */
299 /* 12mV ADC (OHM) */ 303 /* 12mV ADC (OHM) */
300 /* 16 bit fans (OHM) */ 304 /* 16 bit fans (OHM) */
305 /* three fans, always 16 bit (guesswork) */
301 .peci_mask = 0x07, 306 .peci_mask = 0x07,
302 }, 307 },
303 [it8772] = { 308 [it8772] = {
304 .name = "it8772", 309 .name = "it8772",
305 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS 310 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
306 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI, 311 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI,
307 /* PECI (coreboot) */ 312 /* PECI (coreboot) */
308 /* 12mV ADC (HWSensors4, OHM) */ 313 /* 12mV ADC (HWSensors4, OHM) */
309 /* 16 bit fans (HWSensors4, OHM) */ 314 /* 16 bit fans (HWSensors4, OHM) */
315 /* three fans, always 16 bit (datasheet) */
310 .peci_mask = 0x07, 316 .peci_mask = 0x07,
311 }, 317 },
312 [it8781] = { 318 [it8781] = {
313 .name = "it8781", 319 .name = "it8781",
314 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET 320 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
315 | FEAT_TEMP_OLD_PECI, 321 | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG,
316 .old_peci_mask = 0x4, 322 .old_peci_mask = 0x4,
317 }, 323 },
318 [it8782] = { 324 [it8782] = {
319 .name = "it8782", 325 .name = "it8782",
320 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET 326 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
321 | FEAT_TEMP_OLD_PECI, 327 | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG,
322 .old_peci_mask = 0x4, 328 .old_peci_mask = 0x4,
323 }, 329 },
324 [it8783] = { 330 [it8783] = {
325 .name = "it8783", 331 .name = "it8783",
326 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET 332 .features = FEAT_16BIT_FANS | FEAT_TEMP_OFFSET
327 | FEAT_TEMP_OLD_PECI, 333 | FEAT_TEMP_OLD_PECI | FEAT_FAN16_CONFIG,
328 .old_peci_mask = 0x4, 334 .old_peci_mask = 0x4,
329 }, 335 },
330 [it8603] = { 336 [it8603] = {
@@ -345,6 +351,8 @@ static const struct it87_devices it87_devices[] = {
345#define has_temp_old_peci(data, nr) \ 351#define has_temp_old_peci(data, nr) \
346 (((data)->features & FEAT_TEMP_OLD_PECI) && \ 352 (((data)->features & FEAT_TEMP_OLD_PECI) && \
347 ((data)->old_peci_mask & (1 << nr))) 353 ((data)->old_peci_mask & (1 << nr)))
354#define has_fan16_config(data) ((data)->features & FEAT_FAN16_CONFIG)
355#define has_five_fans(data) ((data)->features & FEAT_FIVE_FANS)
348 356
349struct it87_sio_data { 357struct it87_sio_data {
350 enum chips type; 358 enum chips type;
@@ -2124,13 +2132,14 @@ static int it87_probe(struct platform_device *pdev)
2124 case it87: 2132 case it87:
2125 if (sio_data->revision >= 0x03) { 2133 if (sio_data->revision >= 0x03) {
2126 data->features &= ~FEAT_OLD_AUTOPWM; 2134 data->features &= ~FEAT_OLD_AUTOPWM;
2127 data->features |= FEAT_16BIT_FANS; 2135 data->features |= FEAT_FAN16_CONFIG | FEAT_16BIT_FANS;
2128 } 2136 }
2129 break; 2137 break;
2130 case it8712: 2138 case it8712:
2131 if (sio_data->revision >= 0x08) { 2139 if (sio_data->revision >= 0x08) {
2132 data->features &= ~FEAT_OLD_AUTOPWM; 2140 data->features &= ~FEAT_OLD_AUTOPWM;
2133 data->features |= FEAT_16BIT_FANS; 2141 data->features |= FEAT_FAN16_CONFIG | FEAT_16BIT_FANS |
2142 FEAT_FIVE_FANS;
2134 } 2143 }
2135 break; 2144 break;
2136 default: 2145 default:
@@ -2463,12 +2472,8 @@ static void it87_init_device(struct platform_device *pdev)
2463 } 2472 }
2464 data->has_fan = (data->fan_main_ctrl >> 4) & 0x07; 2473 data->has_fan = (data->fan_main_ctrl >> 4) & 0x07;
2465 2474
2466 /* 2475 /* Set tachometers to 16-bit mode if needed */
2467 * Set tachometers to 16-bit mode if needed. IT8603E, IT8728F, 2476 if (has_fan16_config(data)) {
2468 * IT8771E (guesswork), and IT8772E have it by default.
2469 */
2470 if (has_16bit_fans(data) && data->type != it8603 && data->type != it8728
2471 && data->type != it8771 && data->type != it8772) {
2472 tmp = it87_read_value(data, IT87_REG_FAN_16BIT); 2477 tmp = it87_read_value(data, IT87_REG_FAN_16BIT);
2473 if (~tmp & 0x07 & data->has_fan) { 2478 if (~tmp & 0x07 & data->has_fan) {
2474 dev_dbg(&pdev->dev, 2479 dev_dbg(&pdev->dev,
@@ -2476,17 +2481,15 @@ static void it87_init_device(struct platform_device *pdev)
2476 it87_write_value(data, IT87_REG_FAN_16BIT, 2481 it87_write_value(data, IT87_REG_FAN_16BIT,
2477 tmp | 0x07); 2482 tmp | 0x07);
2478 } 2483 }
2479 /* 2484 }
2480 * IT8705F, IT8781F, IT8782F, and IT8783E/F only support 2485
2481 * three fans. 2486 /* Check for additional fans */
2482 */ 2487 if (has_five_fans(data)) {
2483 if (data->type != it87 && data->type != it8781 && 2488 tmp = it87_read_value(data, IT87_REG_FAN_16BIT);
2484 data->type != it8782 && data->type != it8783) { 2489 if (tmp & (1 << 4))
2485 if (tmp & (1 << 4)) 2490 data->has_fan |= (1 << 3); /* fan4 enabled */
2486 data->has_fan |= (1 << 3); /* fan4 enabled */ 2491 if (tmp & (1 << 5))
2487 if (tmp & (1 << 5)) 2492 data->has_fan |= (1 << 4); /* fan5 enabled */
2488 data->has_fan |= (1 << 4); /* fan5 enabled */
2489 }
2490 } 2493 }
2491 2494
2492 /* Fan input pins may be used for alternative functions */ 2495 /* Fan input pins may be used for alternative functions */