aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorRudolf Marek <r.marek@assembler.cz>2014-01-29 14:40:08 -0500
committerJean Delvare <khali@endymion.delvare>2014-01-29 14:40:08 -0500
commitc145d5c628c8ca02dabbf6829ae19ce525d42796 (patch)
tree0d3e553a0ae9abaf0c8e67ad7f42bc57431a98a1 /drivers/hwmon
parentd8ec26d7f8287f5788a494f56e8814210f0e64be (diff)
hwmon: (it87) Add support for the ITE IT8603E
Add support for IT8603E. This closes bug #57861: https://bugzilla.kernel.org/show_bug.cgi?id=57861 [JD: Fixes and clean-ups.] Signed-off-by: Rudolf Marek <r.marek@assembler.cz> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/Kconfig4
-rw-r--r--drivers/hwmon/it87.c103
2 files changed, 87 insertions, 20 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 52d548f1dc1d..f6ca3b21aebd 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -573,8 +573,8 @@ config SENSORS_IT87
573 help 573 help
574 If you say yes here you get support for ITE IT8705F, IT8712F, 574 If you say yes here you get support for ITE IT8705F, IT8712F,
575 IT8716F, IT8718F, IT8720F, IT8721F, IT8726F, IT8728F, IT8758E, 575 IT8716F, IT8718F, IT8720F, IT8721F, IT8726F, IT8728F, IT8758E,
576 IT8771E, IT8772E, IT8782F, and IT8783E/F sensor chips, and the 576 IT8771E, IT8772E, IT8782F, IT8783E/F and IT8603E sensor chips,
577 SiS950 clone. 577 and the SiS950 clone.
578 578
579 This driver can also be built as a module. If so, the module 579 This driver can also be built as a module. If so, the module
580 will be called it87. 580 will be called it87.
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 29ffa27c60b8..b78f71110983 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -10,7 +10,8 @@
10 * This driver supports only the Environment Controller in the IT8705F and 10 * This driver supports only the Environment Controller in the IT8705F and
11 * similar parts. The other devices are supported by different drivers. 11 * similar parts. The other devices are supported by different drivers.
12 * 12 *
13 * Supports: IT8705F Super I/O chip w/LPC interface 13 * Supports: IT8603E Super I/O chip w/LPC interface
14 * IT8705F Super I/O chip w/LPC interface
14 * IT8712F Super I/O chip w/LPC interface 15 * IT8712F Super I/O chip w/LPC interface
15 * IT8716F Super I/O chip w/LPC interface 16 * IT8716F Super I/O chip w/LPC interface
16 * IT8718F Super I/O chip w/LPC interface 17 * IT8718F Super I/O chip w/LPC interface
@@ -64,7 +65,7 @@
64#define DRVNAME "it87" 65#define DRVNAME "it87"
65 66
66enum chips { it87, it8712, it8716, it8718, it8720, it8721, it8728, it8771, 67enum chips { it87, it8712, it8716, it8718, it8720, it8721, it8728, it8771,
67 it8772, it8782, it8783 }; 68 it8772, it8782, it8783, it8603 };
68 69
69static unsigned short force_id; 70static unsigned short force_id;
70module_param(force_id, ushort, 0); 71module_param(force_id, ushort, 0);
@@ -146,6 +147,7 @@ static inline void superio_exit(void)
146#define IT8772E_DEVID 0x8772 147#define IT8772E_DEVID 0x8772
147#define IT8782F_DEVID 0x8782 148#define IT8782F_DEVID 0x8782
148#define IT8783E_DEVID 0x8783 149#define IT8783E_DEVID 0x8783
150#define IT8306E_DEVID 0x8603
149#define IT87_ACT_REG 0x30 151#define IT87_ACT_REG 0x30
150#define IT87_BASE_REG 0x60 152#define IT87_BASE_REG 0x60
151 153
@@ -315,6 +317,12 @@ static const struct it87_devices it87_devices[] = {
315 | FEAT_TEMP_OLD_PECI, 317 | FEAT_TEMP_OLD_PECI,
316 .old_peci_mask = 0x4, 318 .old_peci_mask = 0x4,
317 }, 319 },
320 [it8603] = {
321 .name = "it8603",
322 .features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
323 | FEAT_TEMP_OFFSET | FEAT_TEMP_PECI,
324 .peci_mask = 0x07,
325 },
318}; 326};
319 327
320#define has_16bit_fans(data) ((data)->features & FEAT_16BIT_FANS) 328#define has_16bit_fans(data) ((data)->features & FEAT_16BIT_FANS)
@@ -361,7 +369,7 @@ struct it87_data {
361 unsigned long last_updated; /* In jiffies */ 369 unsigned long last_updated; /* In jiffies */
362 370
363 u16 in_scaled; /* Internal voltage sensors are scaled */ 371 u16 in_scaled; /* Internal voltage sensors are scaled */
364 u8 in[9][3]; /* [nr][0]=in, [1]=min, [2]=max */ 372 u8 in[10][3]; /* [nr][0]=in, [1]=min, [2]=max */
365 u8 has_fan; /* Bitfield, fans enabled */ 373 u8 has_fan; /* Bitfield, fans enabled */
366 u16 fan[5][2]; /* Register values, [nr][0]=fan, [1]=min */ 374 u16 fan[5][2]; /* Register values, [nr][0]=fan, [1]=min */
367 u8 has_temp; /* Bitfield, temp sensors enabled */ 375 u8 has_temp; /* Bitfield, temp sensors enabled */
@@ -578,6 +586,7 @@ static SENSOR_DEVICE_ATTR_2(in7_max, S_IRUGO | S_IWUSR, show_in, set_in,
578 7, 2); 586 7, 2);
579 587
580static SENSOR_DEVICE_ATTR_2(in8_input, S_IRUGO, show_in, NULL, 8, 0); 588static SENSOR_DEVICE_ATTR_2(in8_input, S_IRUGO, show_in, NULL, 8, 0);
589static SENSOR_DEVICE_ATTR_2(in9_input, S_IRUGO, show_in, NULL, 9, 0);
581 590
582/* 3 temperatures */ 591/* 3 temperatures */
583static ssize_t show_temp(struct device *dev, struct device_attribute *attr, 592static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
@@ -734,7 +743,7 @@ static int pwm_mode(const struct it87_data *data, int nr)
734{ 743{
735 int ctrl = data->fan_main_ctrl & (1 << nr); 744 int ctrl = data->fan_main_ctrl & (1 << nr);
736 745
737 if (ctrl == 0) /* Full speed */ 746 if (ctrl == 0 && data->type != it8603) /* Full speed */
738 return 0; 747 return 0;
739 if (data->pwm_ctrl[nr] & 0x80) /* Automatic mode */ 748 if (data->pwm_ctrl[nr] & 0x80) /* Automatic mode */
740 return 2; 749 return 2;
@@ -929,6 +938,10 @@ static ssize_t set_pwm_enable(struct device *dev,
929 return -EINVAL; 938 return -EINVAL;
930 } 939 }
931 940
941 /* IT8603E does not have on/off mode */
942 if (val == 0 && data->type == it8603)
943 return -EINVAL;
944
932 mutex_lock(&data->update_lock); 945 mutex_lock(&data->update_lock);
933 946
934 if (val == 0) { 947 if (val == 0) {
@@ -948,10 +961,13 @@ static ssize_t set_pwm_enable(struct device *dev,
948 else /* Automatic mode */ 961 else /* Automatic mode */
949 data->pwm_ctrl[nr] = 0x80 | data->pwm_temp_map[nr]; 962 data->pwm_ctrl[nr] = 0x80 | data->pwm_temp_map[nr];
950 it87_write_value(data, IT87_REG_PWM(nr), data->pwm_ctrl[nr]); 963 it87_write_value(data, IT87_REG_PWM(nr), data->pwm_ctrl[nr]);
951 /* set SmartGuardian mode */ 964
952 data->fan_main_ctrl |= (1 << nr); 965 if (data->type != it8603) {
953 it87_write_value(data, IT87_REG_FAN_MAIN_CTRL, 966 /* set SmartGuardian mode */
954 data->fan_main_ctrl); 967 data->fan_main_ctrl |= (1 << nr);
968 it87_write_value(data, IT87_REG_FAN_MAIN_CTRL,
969 data->fan_main_ctrl);
970 }
955 } 971 }
956 972
957 mutex_unlock(&data->update_lock); 973 mutex_unlock(&data->update_lock);
@@ -1415,6 +1431,8 @@ static ssize_t show_label(struct device *dev, struct device_attribute *attr,
1415static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 0); 1431static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 0);
1416static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 1); 1432static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 1);
1417static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 2); 1433static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 2);
1434/* special AVCC3 IT8306E in9 */
1435static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 0);
1418 1436
1419static ssize_t show_name(struct device *dev, struct device_attribute 1437static ssize_t show_name(struct device *dev, struct device_attribute
1420 *devattr, char *buf) 1438 *devattr, char *buf)
@@ -1424,7 +1442,7 @@ static ssize_t show_name(struct device *dev, struct device_attribute
1424} 1442}
1425static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 1443static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
1426 1444
1427static struct attribute *it87_attributes_in[9][5] = { 1445static struct attribute *it87_attributes_in[10][5] = {
1428{ 1446{
1429 &sensor_dev_attr_in0_input.dev_attr.attr, 1447 &sensor_dev_attr_in0_input.dev_attr.attr,
1430 &sensor_dev_attr_in0_min.dev_attr.attr, 1448 &sensor_dev_attr_in0_min.dev_attr.attr,
@@ -1476,9 +1494,12 @@ static struct attribute *it87_attributes_in[9][5] = {
1476}, { 1494}, {
1477 &sensor_dev_attr_in8_input.dev_attr.attr, 1495 &sensor_dev_attr_in8_input.dev_attr.attr,
1478 NULL 1496 NULL
1497}, {
1498 &sensor_dev_attr_in9_input.dev_attr.attr,
1499 NULL
1479} }; 1500} };
1480 1501
1481static const struct attribute_group it87_group_in[9] = { 1502static const struct attribute_group it87_group_in[10] = {
1482 { .attrs = it87_attributes_in[0] }, 1503 { .attrs = it87_attributes_in[0] },
1483 { .attrs = it87_attributes_in[1] }, 1504 { .attrs = it87_attributes_in[1] },
1484 { .attrs = it87_attributes_in[2] }, 1505 { .attrs = it87_attributes_in[2] },
@@ -1488,6 +1509,7 @@ static const struct attribute_group it87_group_in[9] = {
1488 { .attrs = it87_attributes_in[6] }, 1509 { .attrs = it87_attributes_in[6] },
1489 { .attrs = it87_attributes_in[7] }, 1510 { .attrs = it87_attributes_in[7] },
1490 { .attrs = it87_attributes_in[8] }, 1511 { .attrs = it87_attributes_in[8] },
1512 { .attrs = it87_attributes_in[9] },
1491}; 1513};
1492 1514
1493static struct attribute *it87_attributes_temp[3][6] = { 1515static struct attribute *it87_attributes_temp[3][6] = {
@@ -1546,7 +1568,8 @@ static struct attribute *it87_attributes_in_beep[] = {
1546 &sensor_dev_attr_in5_beep.dev_attr.attr, 1568 &sensor_dev_attr_in5_beep.dev_attr.attr,
1547 &sensor_dev_attr_in6_beep.dev_attr.attr, 1569 &sensor_dev_attr_in6_beep.dev_attr.attr,
1548 &sensor_dev_attr_in7_beep.dev_attr.attr, 1570 &sensor_dev_attr_in7_beep.dev_attr.attr,
1549 NULL 1571 NULL,
1572 NULL,
1550}; 1573};
1551 1574
1552static struct attribute *it87_attributes_temp_beep[] = { 1575static struct attribute *it87_attributes_temp_beep[] = {
@@ -1685,6 +1708,7 @@ static struct attribute *it87_attributes_label[] = {
1685 &sensor_dev_attr_in3_label.dev_attr.attr, 1708 &sensor_dev_attr_in3_label.dev_attr.attr,
1686 &sensor_dev_attr_in7_label.dev_attr.attr, 1709 &sensor_dev_attr_in7_label.dev_attr.attr,
1687 &sensor_dev_attr_in8_label.dev_attr.attr, 1710 &sensor_dev_attr_in8_label.dev_attr.attr,
1711 &sensor_dev_attr_in9_label.dev_attr.attr,
1688 NULL 1712 NULL
1689}; 1713};
1690 1714
@@ -1742,6 +1766,9 @@ static int __init it87_find(unsigned short *address,
1742 case IT8783E_DEVID: 1766 case IT8783E_DEVID:
1743 sio_data->type = it8783; 1767 sio_data->type = it8783;
1744 break; 1768 break;
1769 case IT8306E_DEVID:
1770 sio_data->type = it8603;
1771 break;
1745 case 0xffff: /* No device at all */ 1772 case 0xffff: /* No device at all */
1746 goto exit; 1773 goto exit;
1747 default: 1774 default:
@@ -1763,11 +1790,15 @@ static int __init it87_find(unsigned short *address,
1763 1790
1764 err = 0; 1791 err = 0;
1765 sio_data->revision = superio_inb(DEVREV) & 0x0f; 1792 sio_data->revision = superio_inb(DEVREV) & 0x0f;
1766 pr_info("Found IT%04xF chip at 0x%x, revision %d\n", 1793 pr_info("Found IT%04x%c chip at 0x%x, revision %d\n", chip_type,
1767 chip_type, *address, sio_data->revision); 1794 chip_type == 0x8603 ? 'E' : 'F', *address,
1795 sio_data->revision);
1768 1796
1769 /* in8 (Vbat) is always internal */ 1797 /* in8 (Vbat) is always internal */
1770 sio_data->internal = (1 << 2); 1798 sio_data->internal = (1 << 2);
1799 /* Only the IT8603E has in9 */
1800 if (sio_data->type != it8603)
1801 sio_data->skip_in |= (1 << 9);
1771 1802
1772 /* Read GPIO config and VID value from LDN 7 (GPIO) */ 1803 /* Read GPIO config and VID value from LDN 7 (GPIO) */
1773 if (sio_data->type == it87) { 1804 if (sio_data->type == it87) {
@@ -1844,7 +1875,38 @@ static int __init it87_find(unsigned short *address,
1844 sio_data->internal |= (1 << 1); 1875 sio_data->internal |= (1 << 1);
1845 1876
1846 sio_data->beep_pin = superio_inb(IT87_SIO_BEEP_PIN_REG) & 0x3f; 1877 sio_data->beep_pin = superio_inb(IT87_SIO_BEEP_PIN_REG) & 0x3f;
1878 } else if (sio_data->type == it8603) {
1879 int reg27, reg29;
1880
1881 sio_data->skip_vid = 1; /* No VID */
1882 superio_select(GPIO);
1847 1883
1884 reg27 = superio_inb(IT87_SIO_GPIO3_REG);
1885
1886 /* Check if fan3 is there or not */
1887 if (reg27 & (1 << 6))
1888 sio_data->skip_pwm |= (1 << 2);
1889 if (reg27 & (1 << 7))
1890 sio_data->skip_fan |= (1 << 2);
1891
1892 /* Check if fan2 is there or not */
1893 reg29 = superio_inb(IT87_SIO_GPIO5_REG);
1894 if (reg29 & (1 << 1))
1895 sio_data->skip_pwm |= (1 << 1);
1896 if (reg29 & (1 << 2))
1897 sio_data->skip_fan |= (1 << 1);
1898
1899 sio_data->skip_in |= (1 << 5); /* No VIN5 */
1900 sio_data->skip_in |= (1 << 6); /* No VIN6 */
1901
1902 /* no fan4 */
1903 sio_data->skip_pwm |= (1 << 3);
1904 sio_data->skip_fan |= (1 << 3);
1905
1906 sio_data->internal |= (1 << 1); /* in7 is VSB */
1907 sio_data->internal |= (1 << 3); /* in9 is AVCC */
1908
1909 sio_data->beep_pin = superio_inb(IT87_SIO_BEEP_PIN_REG) & 0x3f;
1848 } else { 1910 } else {
1849 int reg; 1911 int reg;
1850 bool uart6; 1912 bool uart6;
@@ -1966,7 +2028,7 @@ static void it87_remove_files(struct device *dev)
1966 int i; 2028 int i;
1967 2029
1968 sysfs_remove_group(&dev->kobj, &it87_group); 2030 sysfs_remove_group(&dev->kobj, &it87_group);
1969 for (i = 0; i < 9; i++) { 2031 for (i = 0; i < 10; i++) {
1970 if (sio_data->skip_in & (1 << i)) 2032 if (sio_data->skip_in & (1 << i))
1971 continue; 2033 continue;
1972 sysfs_remove_group(&dev->kobj, &it87_group_in[i]); 2034 sysfs_remove_group(&dev->kobj, &it87_group_in[i]);
@@ -2080,6 +2142,8 @@ static int it87_probe(struct platform_device *pdev)
2080 data->in_scaled |= (1 << 7); /* in7 is VSB */ 2142 data->in_scaled |= (1 << 7); /* in7 is VSB */
2081 if (sio_data->internal & (1 << 2)) 2143 if (sio_data->internal & (1 << 2))
2082 data->in_scaled |= (1 << 8); /* in8 is Vbat */ 2144 data->in_scaled |= (1 << 8); /* in8 is Vbat */
2145 if (sio_data->internal & (1 << 3))
2146 data->in_scaled |= (1 << 9); /* in9 is AVCC */
2083 } else if (sio_data->type == it8782 || sio_data->type == it8783) { 2147 } else if (sio_data->type == it8782 || sio_data->type == it8783) {
2084 if (sio_data->internal & (1 << 0)) 2148 if (sio_data->internal & (1 << 0))
2085 data->in_scaled |= (1 << 3); /* in3 is VCC5V */ 2149 data->in_scaled |= (1 << 3); /* in3 is VCC5V */
@@ -2102,7 +2166,7 @@ static int it87_probe(struct platform_device *pdev)
2102 if (err) 2166 if (err)
2103 return err; 2167 return err;
2104 2168
2105 for (i = 0; i < 9; i++) { 2169 for (i = 0; i < 10; i++) {
2106 if (sio_data->skip_in & (1 << i)) 2170 if (sio_data->skip_in & (1 << i))
2107 continue; 2171 continue;
2108 err = sysfs_create_group(&dev->kobj, &it87_group_in[i]); 2172 err = sysfs_create_group(&dev->kobj, &it87_group_in[i]);
@@ -2202,7 +2266,7 @@ static int it87_probe(struct platform_device *pdev)
2202 } 2266 }
2203 2267
2204 /* Export labels for internal sensors */ 2268 /* Export labels for internal sensors */
2205 for (i = 0; i < 3; i++) { 2269 for (i = 0; i < 4; i++) {
2206 if (!(sio_data->internal & (1 << i))) 2270 if (!(sio_data->internal & (1 << i)))
2207 continue; 2271 continue;
2208 err = sysfs_create_file(&dev->kobj, 2272 err = sysfs_create_file(&dev->kobj,
@@ -2383,8 +2447,9 @@ static void it87_init_device(struct platform_device *pdev)
2383 } 2447 }
2384 data->has_fan = (data->fan_main_ctrl >> 4) & 0x07; 2448 data->has_fan = (data->fan_main_ctrl >> 4) & 0x07;
2385 2449
2386 /* Set tachometers to 16-bit mode if needed */ 2450 /* Set tachometers to 16-bit mode if needed, IT8603E (and IT8728F?)
2387 if (has_16bit_fans(data)) { 2451 * has it by default */
2452 if (has_16bit_fans(data) && data->type != it8603) {
2388 tmp = it87_read_value(data, IT87_REG_FAN_16BIT); 2453 tmp = it87_read_value(data, IT87_REG_FAN_16BIT);
2389 if (~tmp & 0x07 & data->has_fan) { 2454 if (~tmp & 0x07 & data->has_fan) {
2390 dev_dbg(&pdev->dev, 2455 dev_dbg(&pdev->dev,
@@ -2464,6 +2529,8 @@ static struct it87_data *it87_update_device(struct device *dev)
2464 } 2529 }
2465 /* in8 (battery) has no limit registers */ 2530 /* in8 (battery) has no limit registers */
2466 data->in[8][0] = it87_read_value(data, IT87_REG_VIN(8)); 2531 data->in[8][0] = it87_read_value(data, IT87_REG_VIN(8));
2532 if (data->type == it8603)
2533 data->in[9][0] = it87_read_value(data, 0x2f);
2467 2534
2468 for (i = 0; i < 5; i++) { 2535 for (i = 0; i < 5; i++) {
2469 /* Skip disabled fans */ 2536 /* Skip disabled fans */