aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83781d.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-01-19 14:02:27 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2012-03-18 21:27:37 -0400
commitaff6e00ee142d04ffeb8d8dcd3b2c0b8f789c354 (patch)
tree400fcef111f1ccecf42a98f9a473466eb7193d33 /drivers/hwmon/w83781d.c
parent2a52dd667d74a074ebb54d2eec84ca55a73834b9 (diff)
hwmon: (w83781d) Fix multi-line comments
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/w83781d.c')
-rw-r--r--drivers/hwmon/w83781d.c197
1 files changed, 117 insertions, 80 deletions
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index e8a19005b7d2..cbed525a425f 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1,37 +1,37 @@
1/* 1/*
2 w83781d.c - Part of lm_sensors, Linux kernel modules for hardware 2 * w83781d.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring 3 * monitoring
4 Copyright (c) 1998 - 2001 Frodo Looijaard <frodol@dds.nl>, 4 * Copyright (c) 1998 - 2001 Frodo Looijaard <frodol@dds.nl>,
5 Philip Edelbrock <phil@netroedge.com>, 5 * Philip Edelbrock <phil@netroedge.com>,
6 and Mark Studebaker <mdsxyz123@yahoo.com> 6 * and Mark Studebaker <mdsxyz123@yahoo.com>
7 Copyright (c) 2007 - 2008 Jean Delvare <khali@linux-fr.org> 7 * Copyright (c) 2007 - 2008 Jean Delvare <khali@linux-fr.org>
8 8 *
9 This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version. 12 * (at your option) any later version.
13 13 *
14 This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details. 17 * GNU General Public License for more details.
18 18 *
19 You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/ 22 */
23 23
24/* 24/*
25 Supports following chips: 25 * Supports following chips:
26 26 *
27 Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA 27 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
28 as99127f 7 3 0 3 0x31 0x12c3 yes no 28 * as99127f 7 3 0 3 0x31 0x12c3 yes no
29 as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no 29 * as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no
30 w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes 30 * w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes
31 w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes 31 * w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes
32 w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no 32 * w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no
33 33 *
34*/ 34 */
35 35
36#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 36#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
37 37
@@ -145,8 +145,10 @@ static const u8 W83781D_REG_PWM[] = { 0x5B, 0x5A, 0x5E, 0x5F };
145#define W83781D_REG_I2C_ADDR 0x48 145#define W83781D_REG_I2C_ADDR 0x48
146#define W83781D_REG_I2C_SUBADDR 0x4A 146#define W83781D_REG_I2C_SUBADDR 0x4A
147 147
148/* The following are undocumented in the data sheets however we 148/*
149 received the information in an email from Winbond tech support */ 149 * The following are undocumented in the data sheets however we
150 * received the information in an email from Winbond tech support
151 */
150/* Sensor selection - not on 781d */ 152/* Sensor selection - not on 781d */
151#define W83781D_REG_SCFG1 0x5D 153#define W83781D_REG_SCFG1 0x5D
152static const u8 BIT_SCFG1[] = { 0x02, 0x04, 0x08 }; 154static const u8 BIT_SCFG1[] = { 0x02, 0x04, 0x08 };
@@ -238,9 +240,11 @@ struct w83781d_data {
238 u32 beep_mask; /* Register encoding, combined */ 240 u32 beep_mask; /* Register encoding, combined */
239 u8 pwm[4]; /* Register value */ 241 u8 pwm[4]; /* Register value */
240 u8 pwm2_enable; /* Boolean */ 242 u8 pwm2_enable; /* Boolean */
241 u16 sens[3]; /* 782D/783S only. 243 u16 sens[3]; /*
242 1 = pentium diode; 2 = 3904 diode; 244 * 782D/783S only.
243 4 = thermistor */ 245 * 1 = pentium diode; 2 = 3904 diode;
246 * 4 = thermistor
247 */
244 u8 vrm; 248 u8 vrm;
245}; 249};
246 250
@@ -636,10 +640,12 @@ show_fan_div(struct device *dev, struct device_attribute *da, char *buf)
636 (long) DIV_FROM_REG(data->fan_div[attr->index])); 640 (long) DIV_FROM_REG(data->fan_div[attr->index]));
637} 641}
638 642
639/* Note: we save and restore the fan minimum here, because its value is 643/*
640 determined in part by the fan divisor. This follows the principle of 644 * Note: we save and restore the fan minimum here, because its value is
641 least surprise; the user doesn't expect the fan minimum to change just 645 * determined in part by the fan divisor. This follows the principle of
642 because the divisor changed. */ 646 * least surprise; the user doesn't expect the fan minimum to change just
647 * because the divisor changed.
648 */
643static ssize_t 649static ssize_t
644store_fan_div(struct device *dev, struct device_attribute *da, 650store_fan_div(struct device *dev, struct device_attribute *da,
645 const char *buf, size_t count) 651 const char *buf, size_t count)
@@ -847,7 +853,8 @@ static SENSOR_DEVICE_ATTR(temp2_type, S_IRUGO | S_IWUSR,
847static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO | S_IWUSR, 853static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO | S_IWUSR,
848 show_sensor, store_sensor, 2); 854 show_sensor, store_sensor, 2);
849 855
850/* Assumes that adapter is of I2C, not ISA variety. 856/*
857 * Assumes that adapter is of I2C, not ISA variety.
851 * OTHERWISE DON'T CALL THIS 858 * OTHERWISE DON'T CALL THIS
852 */ 859 */
853static int 860static int
@@ -1102,9 +1109,11 @@ w83781d_detect(struct i2c_client *client, struct i2c_board_info *info)
1102 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 1109 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
1103 return -ENODEV; 1110 return -ENODEV;
1104 1111
1105 /* We block updates of the ISA device to minimize the risk of 1112 /*
1106 concurrent access to the same W83781D chip through different 1113 * We block updates of the ISA device to minimize the risk of
1107 interfaces. */ 1114 * concurrent access to the same W83781D chip through different
1115 * interfaces.
1116 */
1108 if (isa) 1117 if (isa)
1109 mutex_lock(&isa->update_lock); 1118 mutex_lock(&isa->update_lock);
1110 1119
@@ -1124,8 +1133,10 @@ w83781d_detect(struct i2c_client *client, struct i2c_board_info *info)
1124 "Detection of w83781d chip failed at step 4\n"); 1133 "Detection of w83781d chip failed at step 4\n");
1125 goto err_nodev; 1134 goto err_nodev;
1126 } 1135 }
1127 /* If Winbond SMBus, check address at 0x48. 1136 /*
1128 Asus doesn't support, except for as99127f rev.2 */ 1137 * If Winbond SMBus, check address at 0x48.
1138 * Asus doesn't support, except for as99127f rev.2
1139 */
1129 if ((!(val1 & 0x80) && val2 == 0xa3) || 1140 if ((!(val1 & 0x80) && val2 == 0xa3) ||
1130 ((val1 & 0x80) && val2 == 0x5c)) { 1141 ((val1 & 0x80) && val2 == 0x5c)) {
1131 if (i2c_smbus_read_byte_data(client, W83781D_REG_I2C_ADDR) 1142 if (i2c_smbus_read_byte_data(client, W83781D_REG_I2C_ADDR)
@@ -1346,25 +1357,33 @@ w83781d_init_device(struct device *dev)
1346 int type = data->type; 1357 int type = data->type;
1347 u8 tmp; 1358 u8 tmp;
1348 1359
1349 if (reset && type != as99127f) { /* this resets registers we don't have 1360 if (reset && type != as99127f) { /*
1350 documentation for on the as99127f */ 1361 * this resets registers we don't have
1351 /* Resetting the chip has been the default for a long time, 1362 * documentation for on the as99127f
1352 but it causes the BIOS initializations (fan clock dividers, 1363 */
1353 thermal sensor types...) to be lost, so it is now optional. 1364 /*
1354 It might even go away if nobody reports it as being useful, 1365 * Resetting the chip has been the default for a long time,
1355 as I see very little reason why this would be needed at 1366 * but it causes the BIOS initializations (fan clock dividers,
1356 all. */ 1367 * thermal sensor types...) to be lost, so it is now optional.
1368 * It might even go away if nobody reports it as being useful,
1369 * as I see very little reason why this would be needed at
1370 * all.
1371 */
1357 dev_info(dev, "If reset=1 solved a problem you were " 1372 dev_info(dev, "If reset=1 solved a problem you were "
1358 "having, please report!\n"); 1373 "having, please report!\n");
1359 1374
1360 /* save these registers */ 1375 /* save these registers */
1361 i = w83781d_read_value(data, W83781D_REG_BEEP_CONFIG); 1376 i = w83781d_read_value(data, W83781D_REG_BEEP_CONFIG);
1362 p = w83781d_read_value(data, W83781D_REG_PWMCLK12); 1377 p = w83781d_read_value(data, W83781D_REG_PWMCLK12);
1363 /* Reset all except Watchdog values and last conversion values 1378 /*
1364 This sets fan-divs to 2, among others */ 1379 * Reset all except Watchdog values and last conversion values
1380 * This sets fan-divs to 2, among others
1381 */
1365 w83781d_write_value(data, W83781D_REG_CONFIG, 0x80); 1382 w83781d_write_value(data, W83781D_REG_CONFIG, 0x80);
1366 /* Restore the registers and disable power-on abnormal beep. 1383 /*
1367 This saves FAN 1/2/3 input/output values set by BIOS. */ 1384 * Restore the registers and disable power-on abnormal beep.
1385 * This saves FAN 1/2/3 input/output values set by BIOS.
1386 */
1368 w83781d_write_value(data, W83781D_REG_BEEP_CONFIG, i | 0x80); 1387 w83781d_write_value(data, W83781D_REG_BEEP_CONFIG, i | 0x80);
1369 w83781d_write_value(data, W83781D_REG_PWMCLK12, p); 1388 w83781d_write_value(data, W83781D_REG_PWMCLK12, p);
1370 /* 1389 /*
@@ -1375,8 +1394,10 @@ w83781d_init_device(struct device *dev)
1375 w83781d_write_value(data, W83781D_REG_BEEP_INTS2, 0); 1394 w83781d_write_value(data, W83781D_REG_BEEP_INTS2, 0);
1376 } 1395 }
1377 1396
1378 /* Disable power-on abnormal beep, as advised by the datasheet. 1397 /*
1379 Already done if reset=1. */ 1398 * Disable power-on abnormal beep, as advised by the datasheet.
1399 * Already done if reset=1.
1400 */
1380 if (init && !reset && type != as99127f) { 1401 if (init && !reset && type != as99127f) {
1381 i = w83781d_read_value(data, W83781D_REG_BEEP_CONFIG); 1402 i = w83781d_read_value(data, W83781D_REG_BEEP_CONFIG);
1382 w83781d_write_value(data, W83781D_REG_BEEP_CONFIG, i | 0x80); 1403 w83781d_write_value(data, W83781D_REG_BEEP_CONFIG, i | 0x80);
@@ -1533,8 +1554,10 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
1533 | (w83781d_read_value(data, 1554 | (w83781d_read_value(data,
1534 W83782D_REG_ALARM2) << 8); 1555 W83782D_REG_ALARM2) << 8);
1535 } else { 1556 } else {
1536 /* No real-time status registers, fall back to 1557 /*
1537 interrupt status registers */ 1558 * No real-time status registers, fall back to
1559 * interrupt status registers
1560 */
1538 data->alarms = w83781d_read_value(data, 1561 data->alarms = w83781d_read_value(data,
1539 W83781D_REG_ALARM1) 1562 W83781D_REG_ALARM1)
1540 | (w83781d_read_value(data, 1563 | (w83781d_read_value(data,
@@ -1588,8 +1611,10 @@ static struct platform_device *pdev;
1588 1611
1589static unsigned short isa_address = 0x290; 1612static unsigned short isa_address = 0x290;
1590 1613
1591/* I2C devices get this name attribute automatically, but for ISA devices 1614/*
1592 we must create it by ourselves. */ 1615 * I2C devices get this name attribute automatically, but for ISA devices
1616 * we must create it by ourselves.
1617 */
1593static ssize_t 1618static ssize_t
1594show_name(struct device *dev, struct device_attribute *devattr, char *buf) 1619show_name(struct device *dev, struct device_attribute *devattr, char *buf)
1595{ 1620{
@@ -1619,8 +1644,10 @@ static int w83781d_alias_detect(struct i2c_client *client, u8 chipid)
1619 if (w83781d_read_value(isa, W83781D_REG_WCHIPID) != chipid) 1644 if (w83781d_read_value(isa, W83781D_REG_WCHIPID) != chipid)
1620 return 0; /* Chip type doesn't match */ 1645 return 0; /* Chip type doesn't match */
1621 1646
1622 /* We compare all the limit registers, the config register and the 1647 /*
1623 * interrupt mask registers */ 1648 * We compare all the limit registers, the config register and the
1649 * interrupt mask registers
1650 */
1624 for (i = 0x2b; i <= 0x3d; i++) { 1651 for (i = 0x2b; i <= 0x3d; i++) {
1625 if (w83781d_read_value(isa, i) != 1652 if (w83781d_read_value(isa, i) !=
1626 i2c_smbus_read_byte_data(client, i)) 1653 i2c_smbus_read_byte_data(client, i))
@@ -1701,12 +1728,14 @@ w83781d_write_value_isa(struct w83781d_data *data, u16 reg, u16 value)
1701 } 1728 }
1702} 1729}
1703 1730
1704/* The SMBus locks itself, usually, but nothing may access the Winbond between 1731/*
1705 bank switches. ISA access must always be locked explicitly! 1732 * The SMBus locks itself, usually, but nothing may access the Winbond between
1706 We ignore the W83781D BUSY flag at this moment - it could lead to deadlocks, 1733 * bank switches. ISA access must always be locked explicitly!
1707 would slow down the W83781D access and should not be necessary. 1734 * We ignore the W83781D BUSY flag at this moment - it could lead to deadlocks,
1708 There are some ugly typecasts here, but the good news is - they should 1735 * would slow down the W83781D access and should not be necessary.
1709 nowhere else be necessary! */ 1736 * There are some ugly typecasts here, but the good news is - they should
1737 * nowhere else be necessary!
1738 */
1710static int 1739static int
1711w83781d_read_value(struct w83781d_data *data, u16 reg) 1740w83781d_read_value(struct w83781d_data *data, u16 reg)
1712{ 1741{
@@ -1833,9 +1862,11 @@ w83781d_isa_found(unsigned short address)
1833 int val, save, found = 0; 1862 int val, save, found = 0;
1834 int port; 1863 int port;
1835 1864
1836 /* Some boards declare base+0 to base+7 as a PNP device, some base+4 1865 /*
1866 * Some boards declare base+0 to base+7 as a PNP device, some base+4
1837 * to base+7 and some base+5 to base+6. So we better request each port 1867 * to base+7 and some base+5 to base+6. So we better request each port
1838 * individually for the probing phase. */ 1868 * individually for the probing phase.
1869 */
1839 for (port = address; port < address + W83781D_EXTENT; port++) { 1870 for (port = address; port < address + W83781D_EXTENT; port++) {
1840 if (!request_region(port, 1, "w83781d")) { 1871 if (!request_region(port, 1, "w83781d")) {
1841 pr_debug("Failed to request port 0x%x\n", port); 1872 pr_debug("Failed to request port 0x%x\n", port);
@@ -1844,8 +1875,10 @@ w83781d_isa_found(unsigned short address)
1844 } 1875 }
1845 1876
1846#define REALLY_SLOW_IO 1877#define REALLY_SLOW_IO
1847 /* We need the timeouts for at least some W83781D-like 1878 /*
1848 chips. But only if we read 'undefined' registers. */ 1879 * We need the timeouts for at least some W83781D-like
1880 * chips. But only if we read 'undefined' registers.
1881 */
1849 val = inb_p(address + 1); 1882 val = inb_p(address + 1);
1850 if (inb_p(address + 2) != val 1883 if (inb_p(address + 2) != val
1851 || inb_p(address + 3) != val 1884 || inb_p(address + 3) != val
@@ -1855,8 +1888,10 @@ w83781d_isa_found(unsigned short address)
1855 } 1888 }
1856#undef REALLY_SLOW_IO 1889#undef REALLY_SLOW_IO
1857 1890
1858 /* We should be able to change the 7 LSB of the address port. The 1891 /*
1859 MSB (busy flag) should be clear initially, set after the write. */ 1892 * We should be able to change the 7 LSB of the address port. The
1893 * MSB (busy flag) should be clear initially, set after the write.
1894 */
1860 save = inb_p(address + W83781D_ADDR_REG_OFFSET); 1895 save = inb_p(address + W83781D_ADDR_REG_OFFSET);
1861 if (save & 0x80) { 1896 if (save & 0x80) {
1862 pr_debug("Detection failed at step %d\n", 2); 1897 pr_debug("Detection failed at step %d\n", 2);
@@ -2042,8 +2077,10 @@ sensors_w83781d_init(void)
2042{ 2077{
2043 int res; 2078 int res;
2044 2079
2045 /* We register the ISA device first, so that we can skip the 2080 /*
2046 * registration of an I2C interface to the same device. */ 2081 * We register the ISA device first, so that we can skip the
2082 * registration of an I2C interface to the same device.
2083 */
2047 res = w83781d_isa_register(); 2084 res = w83781d_isa_register();
2048 if (res) 2085 if (res)
2049 goto exit; 2086 goto exit;