aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/i8k.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2013-12-14 12:30:11 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-18 19:45:38 -0500
commitd83c39de196ebe632870148179a449bd5e574def (patch)
treedd663f966464fd783c056249001086027f39bef9 /drivers/char/i8k.c
parent82ba1d3f9703fc8e40c14b2afe06895980ecee67 (diff)
i8k: Support additional temperature sensors
The SMM API suggests that more than one temperature sensor is supported, so add support for them. Currently only supported for hwmon interface. Cc: Jean Delvare <khali@linux-fr.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char/i8k.c')
-rw-r--r--drivers/char/i8k.c64
1 files changed, 45 insertions, 19 deletions
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index ee42eabc464d..b5af4cae736a 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -69,8 +69,11 @@ static struct device *i8k_hwmon_dev;
69static u32 i8k_hwmon_flags; 69static u32 i8k_hwmon_flags;
70 70
71#define I8K_HWMON_HAVE_TEMP1 (1 << 0) 71#define I8K_HWMON_HAVE_TEMP1 (1 << 0)
72#define I8K_HWMON_HAVE_FAN1 (1 << 1) 72#define I8K_HWMON_HAVE_TEMP2 (1 << 1)
73#define I8K_HWMON_HAVE_FAN2 (1 << 2) 73#define I8K_HWMON_HAVE_TEMP3 (1 << 2)
74#define I8K_HWMON_HAVE_TEMP4 (1 << 3)
75#define I8K_HWMON_HAVE_FAN1 (1 << 4)
76#define I8K_HWMON_HAVE_FAN2 (1 << 5)
74 77
75MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)"); 78MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)");
76MODULE_DESCRIPTION("Driver for accessing SMM BIOS on Dell laptops"); 79MODULE_DESCRIPTION("Driver for accessing SMM BIOS on Dell laptops");
@@ -286,7 +289,7 @@ static int i8k_get_temp(int sensor)
286 int temp; 289 int temp;
287 290
288#ifdef I8K_TEMPERATURE_BUG 291#ifdef I8K_TEMPERATURE_BUG
289 static int prev; 292 static int prev[4];
290#endif 293#endif
291 regs.ebx = sensor & 0xff; 294 regs.ebx = sensor & 0xff;
292 rc = i8k_smm(&regs); 295 rc = i8k_smm(&regs);
@@ -304,10 +307,10 @@ static int i8k_get_temp(int sensor)
304 # 1003655139 00000054 00005c52 307 # 1003655139 00000054 00005c52
305 */ 308 */
306 if (temp > I8K_MAX_TEMP) { 309 if (temp > I8K_MAX_TEMP) {
307 temp = prev; 310 temp = prev[sensor];
308 prev = I8K_MAX_TEMP; 311 prev[sensor] = I8K_MAX_TEMP;
309 } else { 312 } else {
310 prev = temp; 313 prev[sensor] = temp;
311 } 314 }
312#endif 315#endif
313 316
@@ -482,12 +485,13 @@ static ssize_t i8k_hwmon_show_temp(struct device *dev,
482 struct device_attribute *devattr, 485 struct device_attribute *devattr,
483 char *buf) 486 char *buf)
484{ 487{
485 int cpu_temp; 488 int index = to_sensor_dev_attr(devattr)->index;
489 int temp;
486 490
487 cpu_temp = i8k_get_temp(0); 491 temp = i8k_get_temp(index);
488 if (cpu_temp < 0) 492 if (temp < 0)
489 return cpu_temp; 493 return temp;
490 return sprintf(buf, "%d\n", cpu_temp * 1000); 494 return sprintf(buf, "%d\n", temp * 1000);
491} 495}
492 496
493static ssize_t i8k_hwmon_show_fan(struct device *dev, 497static ssize_t i8k_hwmon_show_fan(struct device *dev,
@@ -517,7 +521,10 @@ static ssize_t i8k_hwmon_show_label(struct device *dev,
517 return sprintf(buf, "%s\n", labels[index]); 521 return sprintf(buf, "%s\n", labels[index]);
518} 522}
519 523
520static DEVICE_ATTR(temp1_input, S_IRUGO, i8k_hwmon_show_temp, NULL); 524static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 0);
525static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 1);
526static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 2);
527static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 3);
521static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, i8k_hwmon_show_fan, NULL, 528static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, i8k_hwmon_show_fan, NULL,
522 I8K_FAN_LEFT); 529 I8K_FAN_LEFT);
523static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, i8k_hwmon_show_fan, NULL, 530static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, i8k_hwmon_show_fan, NULL,
@@ -527,12 +534,15 @@ static SENSOR_DEVICE_ATTR(fan1_label, S_IRUGO, i8k_hwmon_show_label, NULL, 1);
527static SENSOR_DEVICE_ATTR(fan2_label, S_IRUGO, i8k_hwmon_show_label, NULL, 2); 534static SENSOR_DEVICE_ATTR(fan2_label, S_IRUGO, i8k_hwmon_show_label, NULL, 2);
528 535
529static struct attribute *i8k_attrs[] = { 536static struct attribute *i8k_attrs[] = {
530 &dev_attr_temp1_input.attr, /* 0 */ 537 &sensor_dev_attr_temp1_input.dev_attr.attr, /* 0 */
531 &sensor_dev_attr_temp1_label.dev_attr.attr, /* 1 */ 538 &sensor_dev_attr_temp1_label.dev_attr.attr, /* 1 */
532 &sensor_dev_attr_fan1_input.dev_attr.attr, /* 2 */ 539 &sensor_dev_attr_temp2_input.dev_attr.attr, /* 2 */
533 &sensor_dev_attr_fan1_label.dev_attr.attr, /* 3 */ 540 &sensor_dev_attr_temp3_input.dev_attr.attr, /* 3 */
534 &sensor_dev_attr_fan2_input.dev_attr.attr, /* 4 */ 541 &sensor_dev_attr_temp4_input.dev_attr.attr, /* 4 */
535 &sensor_dev_attr_fan2_label.dev_attr.attr, /* 5 */ 542 &sensor_dev_attr_fan1_input.dev_attr.attr, /* 5 */
543 &sensor_dev_attr_fan1_label.dev_attr.attr, /* 6 */
544 &sensor_dev_attr_fan2_input.dev_attr.attr, /* 7 */
545 &sensor_dev_attr_fan2_label.dev_attr.attr, /* 8 */
536 NULL 546 NULL
537}; 547};
538 548
@@ -542,10 +552,16 @@ static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr,
542 if ((index == 0 || index == 1) && 552 if ((index == 0 || index == 1) &&
543 !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) 553 !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1))
544 return 0; 554 return 0;
545 if ((index == 2 || index == 3) && 555 if (index == 2 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP2))
556 return 0;
557 if (index == 3 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP3))
558 return 0;
559 if (index == 4 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP4))
560 return 0;
561 if ((index == 5 || index == 6) &&
546 !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN1)) 562 !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN1))
547 return 0; 563 return 0;
548 if ((index == 4 || index == 5) && 564 if ((index == 7 || index == 8) &&
549 !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN2)) 565 !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN2))
550 return 0; 566 return 0;
551 567
@@ -568,6 +584,16 @@ static int __init i8k_init_hwmon(void)
568 err = i8k_get_temp(0); 584 err = i8k_get_temp(0);
569 if (err >= 0) 585 if (err >= 0)
570 i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP1; 586 i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP1;
587 /* check for additional temperature sensors */
588 err = i8k_get_temp(1);
589 if (err >= 0)
590 i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP2;
591 err = i8k_get_temp(2);
592 if (err >= 0)
593 i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP3;
594 err = i8k_get_temp(3);
595 if (err >= 0)
596 i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP4;
571 597
572 /* Left fan attributes, if left fan is present */ 598 /* Left fan attributes, if left fan is present */
573 err = i8k_get_fan_status(I8K_FAN_LEFT); 599 err = i8k_get_fan_status(I8K_FAN_LEFT);