aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/it87.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-08-14 15:08:50 -0400
committerJean Delvare <khali@linux-fr.org>2010-08-14 15:08:50 -0400
commit738e5e05362bdbb31dbc270d31005c12cec8dbb2 (patch)
tree0917c008a2f248620eac381a24909d69c0ba56d1 /drivers/hwmon/it87.c
parent9914518e79800c977e20eda1335d43a4df813e3d (diff)
hwmon: (it87) Export labels for internal sensors
Some voltage sensors can be wired internally to the IT87xxF chip's own power supply channels. In that case, we can inform user-space that the wiring is known by exporting proper labels for these sensors. Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/it87.c')
-rw-r--r--drivers/hwmon/it87.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 25763d2223b6..f7701295937d 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -259,6 +259,7 @@ struct it87_sio_data {
259 u8 revision; 259 u8 revision;
260 u8 vid_value; 260 u8 vid_value;
261 u8 beep_pin; 261 u8 beep_pin;
262 u8 internal; /* Internal sensors can be labeled */
262 /* Features skipped based on config or DMI */ 263 /* Features skipped based on config or DMI */
263 u8 skip_vid; 264 u8 skip_vid;
264 u8 skip_fan; 265 u8 skip_fan;
@@ -1194,6 +1195,22 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr,
1194} 1195}
1195static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); 1196static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
1196 1197
1198static ssize_t show_label(struct device *dev, struct device_attribute *attr,
1199 char *buf)
1200{
1201 static const char *labels[] = {
1202 "+5V",
1203 "5VSB",
1204 "Vbat",
1205 };
1206 int nr = to_sensor_dev_attr(attr)->index;
1207
1208 return sprintf(buf, "%s\n", labels[nr]);
1209}
1210static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 0);
1211static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 1);
1212static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 2);
1213
1197static ssize_t show_name(struct device *dev, struct device_attribute 1214static ssize_t show_name(struct device *dev, struct device_attribute
1198 *devattr, char *buf) 1215 *devattr, char *buf)
1199{ 1216{
@@ -1434,6 +1451,17 @@ static const struct attribute_group it87_group_vid = {
1434 .attrs = it87_attributes_vid, 1451 .attrs = it87_attributes_vid,
1435}; 1452};
1436 1453
1454static struct attribute *it87_attributes_label[] = {
1455 &sensor_dev_attr_in3_label.dev_attr.attr,
1456 &sensor_dev_attr_in7_label.dev_attr.attr,
1457 &sensor_dev_attr_in8_label.dev_attr.attr,
1458 NULL
1459};
1460
1461static const struct attribute_group it87_group_label = {
1462 .attrs = it87_attributes_vid,
1463};
1464
1437/* SuperIO detection - will change isa_address if a chip is found */ 1465/* SuperIO detection - will change isa_address if a chip is found */
1438static int __init it87_find(unsigned short *address, 1466static int __init it87_find(unsigned short *address,
1439 struct it87_sio_data *sio_data) 1467 struct it87_sio_data *sio_data)
@@ -1487,6 +1515,9 @@ static int __init it87_find(unsigned short *address,
1487 pr_info("it87: Found IT%04xF chip at 0x%x, revision %d\n", 1515 pr_info("it87: Found IT%04xF chip at 0x%x, revision %d\n",
1488 chip_type, *address, sio_data->revision); 1516 chip_type, *address, sio_data->revision);
1489 1517
1518 /* in8 (Vbat) is always internal */
1519 sio_data->internal = (1 << 2);
1520
1490 /* Read GPIO config and VID value from LDN 7 (GPIO) */ 1521 /* Read GPIO config and VID value from LDN 7 (GPIO) */
1491 if (sio_data->type == it87) { 1522 if (sio_data->type == it87) {
1492 /* The IT8705F doesn't have VID pins at all */ 1523 /* The IT8705F doesn't have VID pins at all */
@@ -1540,9 +1571,9 @@ static int __init it87_find(unsigned short *address,
1540 pr_notice("it87: Routing internal VCCH to in7\n"); 1571 pr_notice("it87: Routing internal VCCH to in7\n");
1541 } 1572 }
1542 if (reg & (1 << 0)) 1573 if (reg & (1 << 0))
1543 pr_info("it87: in3 is VCC (+5V)\n"); 1574 sio_data->internal |= (1 << 0);
1544 if (reg & (1 << 1)) 1575 if (reg & (1 << 1))
1545 pr_info("it87: in7 is VCCH (+5V Stand-By)\n"); 1576 sio_data->internal |= (1 << 1);
1546 1577
1547 sio_data->beep_pin = superio_inb(IT87_SIO_BEEP_PIN_REG) & 0x3f; 1578 sio_data->beep_pin = superio_inb(IT87_SIO_BEEP_PIN_REG) & 0x3f;
1548 } 1579 }
@@ -1600,6 +1631,7 @@ static void it87_remove_files(struct device *dev)
1600 } 1631 }
1601 if (!sio_data->skip_vid) 1632 if (!sio_data->skip_vid)
1602 sysfs_remove_group(&dev->kobj, &it87_group_vid); 1633 sysfs_remove_group(&dev->kobj, &it87_group_vid);
1634 sysfs_remove_group(&dev->kobj, &it87_group_label);
1603} 1635}
1604 1636
1605static int __devinit it87_probe(struct platform_device *pdev) 1637static int __devinit it87_probe(struct platform_device *pdev)
@@ -1725,6 +1757,16 @@ static int __devinit it87_probe(struct platform_device *pdev)
1725 goto ERROR4; 1757 goto ERROR4;
1726 } 1758 }
1727 1759
1760 /* Export labels for internal sensors */
1761 for (i = 0; i < 3; i++) {
1762 if (!(sio_data->internal & (1 << i)))
1763 continue;
1764 err = sysfs_create_file(&dev->kobj,
1765 it87_attributes_label[i]);
1766 if (err)
1767 goto ERROR4;
1768 }
1769
1728 data->hwmon_dev = hwmon_device_register(dev); 1770 data->hwmon_dev = hwmon_device_register(dev);
1729 if (IS_ERR(data->hwmon_dev)) { 1771 if (IS_ERR(data->hwmon_dev)) {
1730 err = PTR_ERR(data->hwmon_dev); 1772 err = PTR_ERR(data->hwmon_dev);