diff options
58 files changed, 2319 insertions, 1742 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 591e94448e63..2a4d77946c7d 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -483,3 +483,10 @@ Why: With the recent innovations in CPU hardware acceleration technologies | |||
483 | Who: Alok N Kataria <akataria@vmware.com> | 483 | Who: Alok N Kataria <akataria@vmware.com> |
484 | 484 | ||
485 | ---------------------------- | 485 | ---------------------------- |
486 | |||
487 | What: adt7473 hardware monitoring driver | ||
488 | When: February 2010 | ||
489 | Why: Obsoleted by the adt7475 driver. | ||
490 | Who: Jean Delvare <khali@linux-fr.org> | ||
491 | |||
492 | --------------------------- | ||
diff --git a/Documentation/hwmon/adt7473 b/Documentation/hwmon/adt7473 index 1cbf671822e2..446612bd1fb9 100644 --- a/Documentation/hwmon/adt7473 +++ b/Documentation/hwmon/adt7473 | |||
@@ -9,6 +9,8 @@ Supported chips: | |||
9 | 9 | ||
10 | Author: Darrick J. Wong | 10 | Author: Darrick J. Wong |
11 | 11 | ||
12 | This driver is depreacted, please use the adt7475 driver instead. | ||
13 | |||
12 | Description | 14 | Description |
13 | ----------- | 15 | ----------- |
14 | 16 | ||
diff --git a/Documentation/hwmon/adt7475 b/Documentation/hwmon/adt7475 index a2b1abec850e..0502f2b464e1 100644 --- a/Documentation/hwmon/adt7475 +++ b/Documentation/hwmon/adt7475 | |||
@@ -1,87 +1,117 @@ | |||
1 | This describes the interface for the ADT7475 driver: | 1 | Kernel driver adt7475 |
2 | 2 | ===================== | |
3 | (there are 4 fans, numbered fan1 to fan4): | 3 | |
4 | 4 | Supported chips: | |
5 | fanX_input Read the current speed of the fan (in RPMs) | 5 | * Analog Devices ADT7473 |
6 | fanX_min Read/write the minimum speed of the fan. Dropping | 6 | Prefix: 'adt7473' |
7 | below this sets an alarm. | 7 | Addresses scanned: I2C 0x2C, 0x2D, 0x2E |
8 | 8 | Datasheet: Publicly available at the On Semiconductors website | |
9 | (there are three PWMs, numbered pwm1 to pwm3): | 9 | * Analog Devices ADT7475 |
10 | 10 | Prefix: 'adt7475' | |
11 | pwmX Read/write the current duty cycle of the PWM. Writes | 11 | Addresses scanned: I2C 0x2E |
12 | only have effect when auto mode is turned off (see | 12 | Datasheet: Publicly available at the On Semiconductors website |
13 | below). Range is 0 - 255. | 13 | * Analog Devices ADT7476 |
14 | 14 | Prefix: 'adt7476' | |
15 | pwmX_enable Fan speed control method: | 15 | Addresses scanned: I2C 0x2C, 0x2D, 0x2E |
16 | 16 | Datasheet: Publicly available at the On Semiconductors website | |
17 | 0 - No control (fan at full speed) | 17 | * Analog Devices ADT7490 |
18 | 1 - Manual fan speed control (using pwm[1-*]) | 18 | Prefix: 'adt7490' |
19 | 2 - Automatic fan speed control | 19 | Addresses scanned: I2C 0x2C, 0x2D, 0x2E |
20 | 20 | Datasheet: Publicly available at the On Semiconductors website | |
21 | pwmX_auto_channels_temp Select which channels affect this PWM | 21 | |
22 | 22 | Authors: | |
23 | 1 - TEMP1 controls PWM | 23 | Jordan Crouse |
24 | 2 - TEMP2 controls PWM | 24 | Hans de Goede |
25 | 4 - TEMP3 controls PWM | 25 | Darrick J. Wong (documentation) |
26 | 6 - TEMP2 and TEMP3 control PWM | 26 | Jean Delvare |
27 | 7 - All three inputs control PWM | 27 | |
28 | 28 | ||
29 | pwmX_freq Read/write the PWM frequency in Hz. The number | 29 | Description |
30 | should be one of the following: | 30 | ----------- |
31 | 31 | ||
32 | 11 Hz | 32 | This driver implements support for the Analog Devices ADT7473, ADT7475, |
33 | 14 Hz | 33 | ADT7476 and ADT7490 chip family. The ADT7473 and ADT7475 differ only in |
34 | 22 Hz | 34 | minor details. The ADT7476 has additional features, including extra voltage |
35 | 29 Hz | 35 | measurement inputs and VID support. The ADT7490 also has additional |
36 | 35 Hz | 36 | features, including extra voltage measurement inputs and PECI support. All |
37 | 44 Hz | 37 | the supported chips will be collectively designed by the name "ADT747x" in |
38 | 58 Hz | 38 | the rest of this document. |
39 | 88 Hz | 39 | |
40 | 40 | The ADT747x uses the 2-wire interface compatible with the SMBus 2.0 | |
41 | pwmX_auto_point1_pwm Read/write the minimum PWM duty cycle in automatic mode | 41 | specification. Using an analog to digital converter it measures three (3) |
42 | 42 | temperatures and two (2) or more voltages. It has four (4) 16-bit counters | |
43 | pwmX_auto_point2_pwm Read/write the maximum PWM duty cycle in automatic mode | 43 | for measuring fan speed. There are three (3) PWM outputs that can be used |
44 | 44 | to control fan speed. | |
45 | (there are three temperature settings numbered temp1 to temp3): | 45 | |
46 | 46 | A sophisticated control system for the PWM outputs is designed into the | |
47 | tempX_input Read the current temperature. The value is in milli | 47 | ADT747x that allows fan speed to be adjusted automatically based on any of the |
48 | degrees of Celsius. | 48 | three temperature sensors. Each PWM output is individually adjustable and |
49 | 49 | programmable. Once configured, the ADT747x will adjust the PWM outputs in | |
50 | tempX_max Read/write the upper temperature limit - exceeding this | 50 | response to the measured temperatures without further host intervention. |
51 | will cause an alarm. | 51 | This feature can also be disabled for manual control of the PWM's. |
52 | 52 | ||
53 | tempX_min Read/write the lower temperature limit - exceeding this | 53 | Each of the measured inputs (voltage, temperature, fan speed) has |
54 | will cause an alarm. | 54 | corresponding high/low limit values. The ADT747x will signal an ALARM if |
55 | 55 | any measured value exceeds either limit. | |
56 | tempX_offset Read/write the temperature adjustment offset | 56 | |
57 | 57 | The ADT747x samples all inputs continuously. The driver will not read | |
58 | tempX_crit Read/write the THERM limit for remote1. | 58 | the registers more often than once every other second. Further, |
59 | 59 | configuration data is only read once per minute. | |
60 | tempX_crit_hyst Set the temperature value below crit where the | 60 | |
61 | fans will stay on - this helps drive the temperature | 61 | Chip Differences Summary |
62 | low enough so it doesn't stay near the edge and | 62 | ------------------------ |
63 | cause THERM to keep tripping. | 63 | |
64 | 64 | ADT7473: | |
65 | tempX_auto_point1_temp Read/write the minimum temperature where the fans will | 65 | * 2 voltage inputs |
66 | turn on in automatic mode. | 66 | * system acoustics optimizations (not implemented) |
67 | 67 | ||
68 | tempX_auto_point2_temp Read/write the maximum temperature over which the fans | 68 | ADT7475: |
69 | will run in automatic mode. tempX_auto_point1_temp | 69 | * 2 voltage inputs |
70 | and tempX_auto_point2_temp together define the | 70 | |
71 | range of automatic control. | 71 | ADT7476: |
72 | 72 | * 5 voltage inputs | |
73 | tempX_alarm Read a 1 if the max/min alarm is set | 73 | * VID support |
74 | tempX_fault Read a 1 if either temp1 or temp3 diode has a fault | 74 | |
75 | 75 | ADT7490: | |
76 | (There are two voltage settings, in1 and in2): | 76 | * 6 voltage inputs |
77 | 77 | * 1 Imon input (not implemented) | |
78 | inX_input Read the current voltage on VCC. Value is in | 78 | * PECI support (not implemented) |
79 | millivolts. | 79 | * 2 GPIO pins (not implemented) |
80 | 80 | * system acoustics optimizations (not implemented) | |
81 | inX_min read/write the minimum voltage limit. | 81 | |
82 | Dropping below this causes an alarm. | 82 | Special Features |
83 | 83 | ---------------- | |
84 | inX_max read/write the maximum voltage limit. | 84 | |
85 | Exceeding this causes an alarm. | 85 | The ADT747x has a 10-bit ADC and can therefore measure temperatures |
86 | 86 | with a resolution of 0.25 degree Celsius. Temperature readings can be | |
87 | inX_alarm Read a 1 if the max/min alarm is set. | 87 | configured either for two's complement format or "Offset 64" format, |
88 | wherein 64 is subtracted from the raw value to get the temperature value. | ||
89 | |||
90 | The datasheet is very detailed and describes a procedure for determining | ||
91 | an optimal configuration for the automatic PWM control. | ||
92 | |||
93 | Fan Speed Control | ||
94 | ----------------- | ||
95 | |||
96 | The driver exposes two trip points per PWM channel. | ||
97 | |||
98 | point1: Set the PWM speed at the lower temperature bound | ||
99 | point2: Set the PWM speed at the higher temperature bound | ||
100 | |||
101 | The ADT747x will scale the PWM linearly between the lower and higher PWM | ||
102 | speed when the temperature is between the two temperature boundaries. | ||
103 | Temperature boundaries are associated to temperature channels rather than | ||
104 | PWM outputs, and a given PWM output can be controlled by several temperature | ||
105 | channels. As a result, the ADT747x may compute more than one PWM value | ||
106 | for a channel at a given time, in which case the maximum value (fastest | ||
107 | fan speed) is applied. PWM values range from 0 (off) to 255 (full speed). | ||
108 | |||
109 | Fan speed may be set to maximum when the temperature sensor associated with | ||
110 | the PWM control exceeds temp#_max. | ||
111 | |||
112 | Notes | ||
113 | ----- | ||
114 | |||
115 | The nVidia binary driver presents an ADT7473 chip via an on-card i2c bus. | ||
116 | Unfortunately, they fail to set the i2c adapter class, so this driver may | ||
117 | fail to find the chip until the nvidia driver is patched. | ||
diff --git a/Documentation/hwmon/f71882fg b/Documentation/hwmon/f71882fg index bee4c30bc1e2..a7952c2bd959 100644 --- a/Documentation/hwmon/f71882fg +++ b/Documentation/hwmon/f71882fg | |||
@@ -14,6 +14,10 @@ Supported chips: | |||
14 | Prefix: 'f71882fg' | 14 | Prefix: 'f71882fg' |
15 | Addresses scanned: none, address read from Super I/O config space | 15 | Addresses scanned: none, address read from Super I/O config space |
16 | Datasheet: Available from the Fintek website | 16 | Datasheet: Available from the Fintek website |
17 | * Fintek F71889FG | ||
18 | Prefix: 'f71889fg' | ||
19 | Addresses scanned: none, address read from Super I/O config space | ||
20 | Datasheet: Should become available on the Fintek website soon | ||
17 | * Fintek F8000 | 21 | * Fintek F8000 |
18 | Prefix: 'f8000' | 22 | Prefix: 'f8000' |
19 | Addresses scanned: none, address read from Super I/O config space | 23 | Addresses scanned: none, address read from Super I/O config space |
@@ -51,6 +55,12 @@ supported. The right one to use depends on external circuitry on the | |||
51 | motherboard, so the driver assumes that the BIOS set the method | 55 | motherboard, so the driver assumes that the BIOS set the method |
52 | properly. | 56 | properly. |
53 | 57 | ||
58 | Note that the lowest numbered temperature zone trip point corresponds to | ||
59 | to the border between the highest and one but highest temperature zones, and | ||
60 | vica versa. So the temperature zone trip points 1-4 (or 1-2) go from high temp | ||
61 | to low temp! This is how things are implemented in the IC, and the driver | ||
62 | mimicks this. | ||
63 | |||
54 | There are 2 modes to specify the speed of the fan, PWM duty cycle (or DC | 64 | There are 2 modes to specify the speed of the fan, PWM duty cycle (or DC |
55 | voltage) mode, where 0-100% duty cycle (0-100% of 12V) is specified. And RPM | 65 | voltage) mode, where 0-100% duty cycle (0-100% of 12V) is specified. And RPM |
56 | mode where the actual RPM of the fan (as measured) is controlled and the speed | 66 | mode where the actual RPM of the fan (as measured) is controlled and the speed |
diff --git a/Documentation/hwmon/it87 b/Documentation/hwmon/it87 index 659315d98e00..f9ba96c0ac4a 100644 --- a/Documentation/hwmon/it87 +++ b/Documentation/hwmon/it87 | |||
@@ -86,7 +86,6 @@ The IT8712F and IT8716F additionally feature VID inputs, used to report | |||
86 | the Vcore voltage of the processor. The early IT8712F have 5 VID pins, | 86 | the Vcore voltage of the processor. The early IT8712F have 5 VID pins, |
87 | the IT8716F and late IT8712F have 6. They are shared with other functions | 87 | the IT8716F and late IT8712F have 6. They are shared with other functions |
88 | though, so the functionality may not be available on a given system. | 88 | though, so the functionality may not be available on a given system. |
89 | The driver dumbly assume it is there. | ||
90 | 89 | ||
91 | The IT8718F and IT8720F also features VID inputs (up to 8 pins) but the value | 90 | The IT8718F and IT8720F also features VID inputs (up to 8 pins) but the value |
92 | is stored in the Super-I/O configuration space. Due to technical limitations, | 91 | is stored in the Super-I/O configuration space. Due to technical limitations, |
diff --git a/Documentation/hwmon/mc13783-adc b/Documentation/hwmon/mc13783-adc new file mode 100644 index 000000000000..044531a86405 --- /dev/null +++ b/Documentation/hwmon/mc13783-adc | |||
@@ -0,0 +1,50 @@ | |||
1 | Kernel driver mc13783-adc | ||
2 | ========================= | ||
3 | |||
4 | Supported chips: | ||
5 | * Freescale Atlas MC13783 | ||
6 | Prefix: 'mc13783_adc' | ||
7 | Datasheet: http://www.freescale.com/files/rf_if/doc/data_sheet/MC13783.pdf?fsrch=1 | ||
8 | |||
9 | Authors: | ||
10 | Sascha Hauer <s.hauer@pengutronix.de> | ||
11 | Luotao Fu <l.fu@pengutronix.de> | ||
12 | |||
13 | Description | ||
14 | ----------- | ||
15 | |||
16 | The Freescale MC13783 is a Power Management and Audio Circuit. Among | ||
17 | other things it contains a 10-bit A/D converter. The converter has 16 | ||
18 | channels which can be used in different modes. | ||
19 | The A/D converter has a resolution of 2.25mV. Channels 0-4 have | ||
20 | a dedicated meaning with chip internal scaling applied. Channels 5-7 | ||
21 | can be used as general purpose inputs or alternatively in a dedicated | ||
22 | mode. Channels 12-15 are occupied by the touchscreen if it's active. | ||
23 | |||
24 | Currently the driver only supports channels 2 and 5-15 with no alternative | ||
25 | modes for channels 5-7. | ||
26 | |||
27 | See this table for the meaning of the different channels and their chip | ||
28 | internal scaling: | ||
29 | |||
30 | Channel Signal Input Range Scaling | ||
31 | ------------------------------------------------------------------------------- | ||
32 | 0 Battery Voltage (BATT) 2.50 - 4.65V -2.40V | ||
33 | 1 Battery Current (BATT - BATTISNS) -50 - 50 mV x20 | ||
34 | 2 Application Supply (BP) 2.50 - 4.65V -2.40V | ||
35 | 3 Charger Voltage (CHRGRAW) 0 - 10V / /5 | ||
36 | 0 - 20V /10 | ||
37 | 4 Charger Current (CHRGISNSP-CHRGISNSN) -0.25V - 0.25V x4 | ||
38 | 5 General Purpose ADIN5 / Battery Pack Thermistor 0 - 2.30V No | ||
39 | 6 General Purpose ADIN6 / Backup Voltage (LICELL) 0 - 2.30V / No / | ||
40 | 1.50 - 3.50V -1.20V | ||
41 | 7 General Purpose ADIN7 / UID / Die Temperature 0 - 2.30V / No / | ||
42 | 0 - 2.55V / x0.9 / No | ||
43 | 8 General Purpose ADIN8 0 - 2.30V No | ||
44 | 9 General Purpose ADIN9 0 - 2.30V No | ||
45 | 10 General Purpose ADIN10 0 - 2.30V No | ||
46 | 11 General Purpose ADIN11 0 - 2.30V No | ||
47 | 12 General Purpose TSX1 / Touchscreen X-plate 1 0 - 2.30V No | ||
48 | 13 General Purpose TSX2 / Touchscreen X-plate 2 0 - 2.30V No | ||
49 | 14 General Purpose TSY1 / Touchscreen Y-plate 1 0 - 2.30V No | ||
50 | 15 General Purpose TSY2 / Touchscreen Y-plate 2 0 - 2.30V No | ||
diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface index 82def883361b..3de6b0bcb147 100644 --- a/Documentation/hwmon/sysfs-interface +++ b/Documentation/hwmon/sysfs-interface | |||
@@ -225,8 +225,6 @@ pwm[1-*]_auto_point[1-*]_temp_hyst | |||
225 | to PWM output channels. | 225 | to PWM output channels. |
226 | RW | 226 | RW |
227 | 227 | ||
228 | OR | ||
229 | |||
230 | temp[1-*]_auto_point[1-*]_pwm | 228 | temp[1-*]_auto_point[1-*]_pwm |
231 | temp[1-*]_auto_point[1-*]_temp | 229 | temp[1-*]_auto_point[1-*]_temp |
232 | temp[1-*]_auto_point[1-*]_temp_hyst | 230 | temp[1-*]_auto_point[1-*]_temp_hyst |
@@ -235,6 +233,15 @@ temp[1-*]_auto_point[1-*]_temp_hyst | |||
235 | to temperature channels. | 233 | to temperature channels. |
236 | RW | 234 | RW |
237 | 235 | ||
236 | There is a third case where trip points are associated to both PWM output | ||
237 | channels and temperature channels: the PWM values are associated to PWM | ||
238 | output channels while the temperature values are associated to temperature | ||
239 | channels. In that case, the result is determined by the mapping between | ||
240 | temperature inputs and PWM outputs. When several temperature inputs are | ||
241 | mapped to a given PWM output, this leads to several candidate PWM values. | ||
242 | The actual result is up to the chip, but in general the highest candidate | ||
243 | value (fastest fan speed) wins. | ||
244 | |||
238 | 245 | ||
239 | **************** | 246 | **************** |
240 | * Temperatures * | 247 | * Temperatures * |
diff --git a/Documentation/hwmon/w83627hf b/Documentation/hwmon/w83627hf index 6ee36dbafd64..44dd2bcc72bd 100644 --- a/Documentation/hwmon/w83627hf +++ b/Documentation/hwmon/w83627hf | |||
@@ -32,8 +32,6 @@ Authors: | |||
32 | Module Parameters | 32 | Module Parameters |
33 | ----------------- | 33 | ----------------- |
34 | 34 | ||
35 | * force_addr: int | ||
36 | Initialize the ISA address of the sensors | ||
37 | * force_i2c: int | 35 | * force_i2c: int |
38 | Initialize the I2C address of the sensors | 36 | Initialize the I2C address of the sensors |
39 | * init: int | 37 | * init: int |
@@ -70,3 +68,30 @@ doesn't help, you may just ignore the bogus VID reading with no harm done. | |||
70 | For further information on this driver see the w83781d driver documentation. | 68 | For further information on this driver see the w83781d driver documentation. |
71 | 69 | ||
72 | [1] http://www.lm-sensors.org/browser/lm-sensors/trunk/doc/vid | 70 | [1] http://www.lm-sensors.org/browser/lm-sensors/trunk/doc/vid |
71 | |||
72 | Forcing the address | ||
73 | ------------------- | ||
74 | |||
75 | The driver used to have a module parameter named force_addr, which could | ||
76 | be used to force the base I/O address of the hardware monitoring block. | ||
77 | This was meant as a workaround for mainboards with a broken BIOS. This | ||
78 | module parameter is gone for technical reasons. If you need this feature, | ||
79 | you can obtain the same result by using the isaset tool (part of | ||
80 | lm-sensors) before loading the driver: | ||
81 | |||
82 | # Enter the Super I/O config space | ||
83 | isaset -y -f 0x2e 0x87 | ||
84 | isaset -y -f 0x2e 0x87 | ||
85 | |||
86 | # Select the hwmon logical device | ||
87 | isaset -y 0x2e 0x2f 0x07 0x0b | ||
88 | |||
89 | # Set the base I/O address (to 0x290 in this example) | ||
90 | isaset -y 0x2e 0x2f 0x60 0x02 | ||
91 | isaset -y 0x2e 0x2f 0x61 0x90 | ||
92 | |||
93 | # Exit the Super-I/O config space | ||
94 | isaset -y -f 0x2e 0xaa | ||
95 | |||
96 | The above sequence assumes a Super-I/O config space at 0x2e/0x2f, but | ||
97 | 0x4e/0x4f is also possible. | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 107a5a5a0174..746b706206da 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -327,6 +327,13 @@ M: Colin Leroy <colin@colino.net> | |||
327 | S: Maintained | 327 | S: Maintained |
328 | F: drivers/macintosh/therm_adt746x.c | 328 | F: drivers/macintosh/therm_adt746x.c |
329 | 329 | ||
330 | ADT7475 HARDWARE MONITOR DRIVER | ||
331 | M: Jean Delvare <khali@linux-fr.org> | ||
332 | L: lm-sensors@lm-sensors.org | ||
333 | S: Maintained | ||
334 | F: Documentation/hwmon/adt7475 | ||
335 | F: drivers/hwmon/adt7475.c | ||
336 | |||
330 | ADVANSYS SCSI DRIVER | 337 | ADVANSYS SCSI DRIVER |
331 | M: Matthew Wilcox <matthew@wil.cx> | 338 | M: Matthew Wilcox <matthew@wil.cx> |
332 | L: linux-scsi@vger.kernel.org | 339 | L: linux-scsi@vger.kernel.org |
@@ -2416,7 +2423,9 @@ HARDWARE MONITORING | |||
2416 | L: lm-sensors@lm-sensors.org | 2423 | L: lm-sensors@lm-sensors.org |
2417 | W: http://www.lm-sensors.org/ | 2424 | W: http://www.lm-sensors.org/ |
2418 | S: Orphan | 2425 | S: Orphan |
2426 | F: Documentation/hwmon/ | ||
2419 | F: drivers/hwmon/ | 2427 | F: drivers/hwmon/ |
2428 | F: include/linux/hwmon*.h | ||
2420 | 2429 | ||
2421 | HARDWARE RANDOM NUMBER GENERATOR CORE | 2430 | HARDWARE RANDOM NUMBER GENERATOR CORE |
2422 | M: Matt Mackall <mpm@selenic.com> | 2431 | M: Matt Mackall <mpm@selenic.com> |
@@ -3312,6 +3321,12 @@ S: Maintained | |||
3312 | F: Documentation/hwmon/lis3lv02d | 3321 | F: Documentation/hwmon/lis3lv02d |
3313 | F: drivers/hwmon/lis3lv02d.* | 3322 | F: drivers/hwmon/lis3lv02d.* |
3314 | 3323 | ||
3324 | LM73 HARDWARE MONITOR DRIVER | ||
3325 | M: Guillaume Ligneul <guillaume.ligneul@gmail.com> | ||
3326 | L: lm-sensors@lm-sensors.org | ||
3327 | S: Maintained | ||
3328 | F: drivers/hwmon/lm73.c | ||
3329 | |||
3315 | LM83 HARDWARE MONITOR DRIVER | 3330 | LM83 HARDWARE MONITOR DRIVER |
3316 | M: Jean Delvare <khali@linux-fr.org> | 3331 | M: Jean Delvare <khali@linux-fr.org> |
3317 | L: lm-sensors@lm-sensors.org | 3332 | L: lm-sensors@lm-sensors.org |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 700e93adeb33..9e640c62ebd9 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -191,21 +191,27 @@ config SENSORS_ADT7470 | |||
191 | will be called adt7470. | 191 | will be called adt7470. |
192 | 192 | ||
193 | config SENSORS_ADT7473 | 193 | config SENSORS_ADT7473 |
194 | tristate "Analog Devices ADT7473" | 194 | tristate "Analog Devices ADT7473 (DEPRECATED)" |
195 | depends on I2C && EXPERIMENTAL | 195 | depends on I2C && EXPERIMENTAL |
196 | select SENSORS_ADT7475 | ||
196 | help | 197 | help |
197 | If you say yes here you get support for the Analog Devices | 198 | If you say yes here you get support for the Analog Devices |
198 | ADT7473 temperature monitoring chips. | 199 | ADT7473 temperature monitoring chips. |
199 | 200 | ||
201 | This driver is deprecated, you should use the adt7475 driver | ||
202 | instead. | ||
203 | |||
200 | This driver can also be built as a module. If so, the module | 204 | This driver can also be built as a module. If so, the module |
201 | will be called adt7473. | 205 | will be called adt7473. |
202 | 206 | ||
203 | config SENSORS_ADT7475 | 207 | config SENSORS_ADT7475 |
204 | tristate "Analog Devices ADT7475" | 208 | tristate "Analog Devices ADT7473, ADT7475, ADT7476 and ADT7490" |
205 | depends on I2C && EXPERIMENTAL | 209 | depends on I2C && EXPERIMENTAL |
210 | select HWMON_VID | ||
206 | help | 211 | help |
207 | If you say yes here you get support for the Analog Devices | 212 | If you say yes here you get support for the Analog Devices |
208 | ADT7475 hardware monitoring chips. | 213 | ADT7473, ADT7475, ADT7476 and ADT7490 hardware monitoring |
214 | chips. | ||
209 | 215 | ||
210 | This driver can also be build as a module. If so, the module | 216 | This driver can also be build as a module. If so, the module |
211 | will be called adt7475. | 217 | will be called adt7475. |
@@ -305,12 +311,12 @@ config SENSORS_F71805F | |||
305 | will be called f71805f. | 311 | will be called f71805f. |
306 | 312 | ||
307 | config SENSORS_F71882FG | 313 | config SENSORS_F71882FG |
308 | tristate "Fintek F71858FG, F71862FG, F71882FG and F8000" | 314 | tristate "Fintek F71858FG, F71862FG, F71882FG, F71889FG and F8000" |
309 | depends on EXPERIMENTAL | 315 | depends on EXPERIMENTAL |
310 | help | 316 | help |
311 | If you say yes here you get support for hardware monitoring | 317 | If you say yes here you get support for hardware monitoring |
312 | features of the Fintek F71858FG, F71862FG/71863FG, F71882FG/F71883FG | 318 | features of the Fintek F71858FG, F71862FG/71863FG, F71882FG/F71883FG, |
313 | and F8000 Super-I/O chips. | 319 | F71889FG and F8000 Super-I/O chips. |
314 | 320 | ||
315 | This driver can also be built as a module. If so, the module | 321 | This driver can also be built as a module. If so, the module |
316 | will be called f71882fg. | 322 | will be called f71882fg. |
@@ -442,6 +448,15 @@ config SENSORS_LM70 | |||
442 | This driver can also be built as a module. If so, the module | 448 | This driver can also be built as a module. If so, the module |
443 | will be called lm70. | 449 | will be called lm70. |
444 | 450 | ||
451 | config SENSORS_LM73 | ||
452 | tristate "National Semiconductor LM73" | ||
453 | depends on I2C | ||
454 | help | ||
455 | If you say yes here you get support for National Semiconductor LM73 | ||
456 | sensor chips. | ||
457 | This driver can also be built as a module. If so, the module | ||
458 | will be called lm73. | ||
459 | |||
445 | config SENSORS_LM75 | 460 | config SENSORS_LM75 |
446 | tristate "National Semiconductor LM75 and compatibles" | 461 | tristate "National Semiconductor LM75 and compatibles" |
447 | depends on I2C | 462 | depends on I2C |
@@ -841,7 +856,7 @@ config SENSORS_W83781D | |||
841 | 856 | ||
842 | config SENSORS_W83791D | 857 | config SENSORS_W83791D |
843 | tristate "Winbond W83791D" | 858 | tristate "Winbond W83791D" |
844 | depends on I2C && EXPERIMENTAL | 859 | depends on I2C |
845 | select HWMON_VID | 860 | select HWMON_VID |
846 | help | 861 | help |
847 | If you say yes here you get support for the Winbond W83791D chip. | 862 | If you say yes here you get support for the Winbond W83791D chip. |
@@ -1008,6 +1023,12 @@ config SENSORS_APPLESMC | |||
1008 | Say Y here if you have an applicable laptop and want to experience | 1023 | Say Y here if you have an applicable laptop and want to experience |
1009 | the awesome power of applesmc. | 1024 | the awesome power of applesmc. |
1010 | 1025 | ||
1026 | config SENSORS_MC13783_ADC | ||
1027 | tristate "Freescale MC13783 ADC" | ||
1028 | depends on MFD_MC13783 | ||
1029 | help | ||
1030 | Support for the A/D converter on MC13783 PMIC. | ||
1031 | |||
1011 | if ACPI | 1032 | if ACPI |
1012 | 1033 | ||
1013 | comment "ACPI drivers" | 1034 | comment "ACPI drivers" |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 9f46cb019cc6..33c2ee105284 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -57,6 +57,7 @@ obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o hp_accel.o | |||
57 | obj-$(CONFIG_SENSORS_LIS3_SPI) += lis3lv02d.o lis3lv02d_spi.o | 57 | obj-$(CONFIG_SENSORS_LIS3_SPI) += lis3lv02d.o lis3lv02d_spi.o |
58 | obj-$(CONFIG_SENSORS_LM63) += lm63.o | 58 | obj-$(CONFIG_SENSORS_LM63) += lm63.o |
59 | obj-$(CONFIG_SENSORS_LM70) += lm70.o | 59 | obj-$(CONFIG_SENSORS_LM70) += lm70.o |
60 | obj-$(CONFIG_SENSORS_LM73) += lm73.o | ||
60 | obj-$(CONFIG_SENSORS_LM75) += lm75.o | 61 | obj-$(CONFIG_SENSORS_LM75) += lm75.o |
61 | obj-$(CONFIG_SENSORS_LM77) += lm77.o | 62 | obj-$(CONFIG_SENSORS_LM77) += lm77.o |
62 | obj-$(CONFIG_SENSORS_LM78) += lm78.o | 63 | obj-$(CONFIG_SENSORS_LM78) += lm78.o |
@@ -73,6 +74,7 @@ obj-$(CONFIG_SENSORS_LTC4245) += ltc4245.o | |||
73 | obj-$(CONFIG_SENSORS_MAX1111) += max1111.o | 74 | obj-$(CONFIG_SENSORS_MAX1111) += max1111.o |
74 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o | 75 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o |
75 | obj-$(CONFIG_SENSORS_MAX6650) += max6650.o | 76 | obj-$(CONFIG_SENSORS_MAX6650) += max6650.o |
77 | obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o | ||
76 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o | 78 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o |
77 | obj-$(CONFIG_SENSORS_PC87427) += pc87427.o | 79 | obj-$(CONFIG_SENSORS_PC87427) += pc87427.o |
78 | obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o | 80 | obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o |
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index afc594318125..33acf29531af 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -288,9 +288,8 @@ static int adm1021_detect(struct i2c_client *client, int kind, | |||
288 | struct i2c_board_info *info) | 288 | struct i2c_board_info *info) |
289 | { | 289 | { |
290 | struct i2c_adapter *adapter = client->adapter; | 290 | struct i2c_adapter *adapter = client->adapter; |
291 | int i; | 291 | const char *type_name; |
292 | const char *type_name = ""; | 292 | int conv_rate, status, config, man_id, dev_id; |
293 | int conv_rate, status, config; | ||
294 | 293 | ||
295 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 294 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
296 | pr_debug("adm1021: detect failed, " | 295 | pr_debug("adm1021: detect failed, " |
@@ -303,62 +302,37 @@ static int adm1021_detect(struct i2c_client *client, int kind, | |||
303 | ADM1021_REG_CONV_RATE_R); | 302 | ADM1021_REG_CONV_RATE_R); |
304 | config = i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R); | 303 | config = i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R); |
305 | 304 | ||
306 | /* Now, we do the remaining detection. */ | 305 | /* Check unused bits */ |
307 | if (kind < 0) { | 306 | if ((status & 0x03) || (config & 0x3F) || (conv_rate & 0xF8)) { |
308 | if ((status & 0x03) != 0x00 || (config & 0x3F) != 0x00 | 307 | pr_debug("adm1021: detect failed, chip not detected!\n"); |
309 | || (conv_rate & 0xF8) != 0x00) { | 308 | return -ENODEV; |
310 | pr_debug("adm1021: detect failed, " | ||
311 | "chip not detected!\n"); | ||
312 | return -ENODEV; | ||
313 | } | ||
314 | } | 309 | } |
315 | 310 | ||
316 | /* Determine the chip type. */ | 311 | /* Determine the chip type. */ |
317 | if (kind <= 0) { | 312 | man_id = i2c_smbus_read_byte_data(client, ADM1021_REG_MAN_ID); |
318 | i = i2c_smbus_read_byte_data(client, ADM1021_REG_MAN_ID); | 313 | dev_id = i2c_smbus_read_byte_data(client, ADM1021_REG_DEV_ID); |
319 | if (i == 0x41) | ||
320 | if ((i2c_smbus_read_byte_data(client, | ||
321 | ADM1021_REG_DEV_ID) & 0xF0) == 0x30) | ||
322 | kind = adm1023; | ||
323 | else | ||
324 | kind = adm1021; | ||
325 | else if (i == 0x49) | ||
326 | kind = thmc10; | ||
327 | else if (i == 0x23) | ||
328 | kind = gl523sm; | ||
329 | else if ((i == 0x4d) && | ||
330 | (i2c_smbus_read_byte_data(client, | ||
331 | ADM1021_REG_DEV_ID) == 0x01)) | ||
332 | kind = max1617a; | ||
333 | else if (i == 0x54) | ||
334 | kind = mc1066; | ||
335 | /* LM84 Mfr ID in a different place, and it has more unused bits */ | ||
336 | else if (conv_rate == 0x00 | ||
337 | && (kind == 0 /* skip extra detection */ | ||
338 | || ((config & 0x7F) == 0x00 | ||
339 | && (status & 0xAB) == 0x00))) | ||
340 | kind = lm84; | ||
341 | else | ||
342 | kind = max1617; | ||
343 | } | ||
344 | 314 | ||
345 | if (kind == max1617) { | 315 | if (man_id == 0x4d && dev_id == 0x01) |
346 | type_name = "max1617"; | ||
347 | } else if (kind == max1617a) { | ||
348 | type_name = "max1617a"; | 316 | type_name = "max1617a"; |
349 | } else if (kind == adm1021) { | 317 | else if (man_id == 0x41) { |
350 | type_name = "adm1021"; | 318 | if ((dev_id & 0xF0) == 0x30) |
351 | } else if (kind == adm1023) { | 319 | type_name = "adm1023"; |
352 | type_name = "adm1023"; | 320 | else |
353 | } else if (kind == thmc10) { | 321 | type_name = "adm1021"; |
322 | } else if (man_id == 0x49) | ||
354 | type_name = "thmc10"; | 323 | type_name = "thmc10"; |
355 | } else if (kind == lm84) { | 324 | else if (man_id == 0x23) |
356 | type_name = "lm84"; | ||
357 | } else if (kind == gl523sm) { | ||
358 | type_name = "gl523sm"; | 325 | type_name = "gl523sm"; |
359 | } else if (kind == mc1066) { | 326 | else if (man_id == 0x54) |
360 | type_name = "mc1066"; | 327 | type_name = "mc1066"; |
361 | } | 328 | /* LM84 Mfr ID in a different place, and it has more unused bits */ |
329 | else if (conv_rate == 0x00 | ||
330 | && (config & 0x7F) == 0x00 | ||
331 | && (status & 0xAB) == 0x00) | ||
332 | type_name = "lm84"; | ||
333 | else | ||
334 | type_name = "max1617"; | ||
335 | |||
362 | pr_debug("adm1021: Detected chip %s at adapter %d, address 0x%02x.\n", | 336 | pr_debug("adm1021: Detected chip %s at adapter %d, address 0x%02x.\n", |
363 | type_name, i2c_adapter_id(adapter), client->addr); | 337 | type_name, i2c_adapter_id(adapter), client->addr); |
364 | strlcpy(info->type, type_name, I2C_NAME_SIZE); | 338 | strlcpy(info->type, type_name, I2C_NAME_SIZE); |
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 4db04d603ec9..db6ac2b04f6f 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * adm1025.c | 2 | * adm1025.c |
3 | * | 3 | * |
4 | * Copyright (C) 2000 Chen-Yuan Wu <gwu@esoft.com> | 4 | * Copyright (C) 2000 Chen-Yuan Wu <gwu@esoft.com> |
5 | * Copyright (C) 2003-2008 Jean Delvare <khali@linux-fr.org> | 5 | * Copyright (C) 2003-2009 Jean Delvare <khali@linux-fr.org> |
6 | * | 6 | * |
7 | * The ADM1025 is a sensor chip made by Analog Devices. It reports up to 6 | 7 | * The ADM1025 is a sensor chip made by Analog Devices. It reports up to 6 |
8 | * voltages (including its own power source) and up to two temperatures | 8 | * voltages (including its own power source) and up to two temperatures |
@@ -413,67 +413,34 @@ static int adm1025_detect(struct i2c_client *client, int kind, | |||
413 | struct i2c_board_info *info) | 413 | struct i2c_board_info *info) |
414 | { | 414 | { |
415 | struct i2c_adapter *adapter = client->adapter; | 415 | struct i2c_adapter *adapter = client->adapter; |
416 | const char *name = ""; | 416 | const char *name; |
417 | u8 config; | 417 | u8 man_id, chip_id; |
418 | 418 | ||
419 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 419 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
420 | return -ENODEV; | 420 | return -ENODEV; |
421 | 421 | ||
422 | /* | 422 | /* Check for unused bits */ |
423 | * Now we do the remaining detection. A negative kind means that | 423 | if ((i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG) & 0x80) |
424 | * the driver was loaded with no force parameter (default), so we | 424 | || (i2c_smbus_read_byte_data(client, ADM1025_REG_STATUS1) & 0xC0) |
425 | * must both detect and identify the chip. A zero kind means that | 425 | || (i2c_smbus_read_byte_data(client, ADM1025_REG_STATUS2) & 0xBC)) { |
426 | * the driver was loaded with the force parameter, the detection | 426 | dev_dbg(&adapter->dev, "ADM1025 detection failed at 0x%02x\n", |
427 | * step shall be skipped. A positive kind means that the driver | 427 | client->addr); |
428 | * was loaded with the force parameter and a given kind of chip is | 428 | return -ENODEV; |
429 | * requested, so both the detection and the identification steps | ||
430 | * are skipped. | ||
431 | */ | ||
432 | config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG); | ||
433 | if (kind < 0) { /* detection */ | ||
434 | if ((config & 0x80) != 0x00 | ||
435 | || (i2c_smbus_read_byte_data(client, | ||
436 | ADM1025_REG_STATUS1) & 0xC0) != 0x00 | ||
437 | || (i2c_smbus_read_byte_data(client, | ||
438 | ADM1025_REG_STATUS2) & 0xBC) != 0x00) { | ||
439 | dev_dbg(&adapter->dev, | ||
440 | "ADM1025 detection failed at 0x%02x.\n", | ||
441 | client->addr); | ||
442 | return -ENODEV; | ||
443 | } | ||
444 | } | 429 | } |
445 | 430 | ||
446 | if (kind <= 0) { /* identification */ | 431 | /* Identification */ |
447 | u8 man_id, chip_id; | 432 | chip_id = i2c_smbus_read_byte_data(client, ADM1025_REG_CHIP_ID); |
448 | 433 | if ((chip_id & 0xF0) != 0x20) | |
449 | man_id = i2c_smbus_read_byte_data(client, ADM1025_REG_MAN_ID); | 434 | return -ENODEV; |
450 | chip_id = i2c_smbus_read_byte_data(client, ADM1025_REG_CHIP_ID); | ||
451 | |||
452 | if (man_id == 0x41) { /* Analog Devices */ | ||
453 | if ((chip_id & 0xF0) == 0x20) { /* ADM1025/ADM1025A */ | ||
454 | kind = adm1025; | ||
455 | } | ||
456 | } else | ||
457 | if (man_id == 0xA1) { /* Philips */ | ||
458 | if (client->addr != 0x2E | ||
459 | && (chip_id & 0xF0) == 0x20) { /* NE1619 */ | ||
460 | kind = ne1619; | ||
461 | } | ||
462 | } | ||
463 | |||
464 | if (kind <= 0) { /* identification failed */ | ||
465 | dev_info(&adapter->dev, | ||
466 | "Unsupported chip (man_id=0x%02X, " | ||
467 | "chip_id=0x%02X).\n", man_id, chip_id); | ||
468 | return -ENODEV; | ||
469 | } | ||
470 | } | ||
471 | 435 | ||
472 | if (kind == adm1025) { | 436 | man_id = i2c_smbus_read_byte_data(client, ADM1025_REG_MAN_ID); |
437 | if (man_id == 0x41) | ||
473 | name = "adm1025"; | 438 | name = "adm1025"; |
474 | } else if (kind == ne1619) { | 439 | else if (man_id == 0xA1 && client->addr != 0x2E) |
475 | name = "ne1619"; | 440 | name = "ne1619"; |
476 | } | 441 | else |
442 | return -ENODEV; | ||
443 | |||
477 | strlcpy(info->type, name, I2C_NAME_SIZE); | 444 | strlcpy(info->type, name, I2C_NAME_SIZE); |
478 | 445 | ||
479 | return 0; | 446 | return 0; |
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index ff7de40b6e35..fb5363985e21 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -1672,35 +1672,26 @@ static int adm1026_detect(struct i2c_client *client, int kind, | |||
1672 | i2c_adapter_id(client->adapter), client->addr, | 1672 | i2c_adapter_id(client->adapter), client->addr, |
1673 | company, verstep); | 1673 | company, verstep); |
1674 | 1674 | ||
1675 | /* If auto-detecting, Determine the chip type. */ | 1675 | /* Determine the chip type. */ |
1676 | if (kind <= 0) { | 1676 | dev_dbg(&adapter->dev, "Autodetecting device at %d,0x%02x...\n", |
1677 | dev_dbg(&adapter->dev, "Autodetecting device at %d,0x%02x " | 1677 | i2c_adapter_id(adapter), address); |
1678 | "...\n", i2c_adapter_id(adapter), address); | 1678 | if (company == ADM1026_COMPANY_ANALOG_DEV |
1679 | if (company == ADM1026_COMPANY_ANALOG_DEV | 1679 | && verstep == ADM1026_VERSTEP_ADM1026) { |
1680 | && verstep == ADM1026_VERSTEP_ADM1026) { | 1680 | /* Analog Devices ADM1026 */ |
1681 | kind = adm1026; | 1681 | } else if (company == ADM1026_COMPANY_ANALOG_DEV |
1682 | } else if (company == ADM1026_COMPANY_ANALOG_DEV | 1682 | && (verstep & 0xf0) == ADM1026_VERSTEP_GENERIC) { |
1683 | && (verstep & 0xf0) == ADM1026_VERSTEP_GENERIC) { | 1683 | dev_err(&adapter->dev, "Unrecognized stepping " |
1684 | dev_err(&adapter->dev, "Unrecognized stepping " | 1684 | "0x%02x. Defaulting to ADM1026.\n", verstep); |
1685 | "0x%02x. Defaulting to ADM1026.\n", verstep); | 1685 | } else if ((verstep & 0xf0) == ADM1026_VERSTEP_GENERIC) { |
1686 | kind = adm1026; | 1686 | dev_err(&adapter->dev, "Found version/stepping " |
1687 | } else if ((verstep & 0xf0) == ADM1026_VERSTEP_GENERIC) { | 1687 | "0x%02x. Assuming generic ADM1026.\n", |
1688 | dev_err(&adapter->dev, "Found version/stepping " | 1688 | verstep); |
1689 | "0x%02x. Assuming generic ADM1026.\n", | 1689 | } else { |
1690 | verstep); | 1690 | dev_dbg(&adapter->dev, "Autodetection failed\n"); |
1691 | kind = any_chip; | 1691 | /* Not an ADM1026... */ |
1692 | } else { | 1692 | return -ENODEV; |
1693 | dev_dbg(&adapter->dev, "Autodetection failed\n"); | ||
1694 | /* Not an ADM1026 ... */ | ||
1695 | if (kind == 0) { /* User used force=x,y */ | ||
1696 | dev_err(&adapter->dev, "Generic ADM1026 not " | ||
1697 | "found at %d,0x%02x. Try " | ||
1698 | "force_adm1026.\n", | ||
1699 | i2c_adapter_id(adapter), address); | ||
1700 | } | ||
1701 | return -ENODEV; | ||
1702 | } | ||
1703 | } | 1693 | } |
1694 | |||
1704 | strlcpy(info->type, "adm1026", I2C_NAME_SIZE); | 1695 | strlcpy(info->type, "adm1026", I2C_NAME_SIZE); |
1705 | 1696 | ||
1706 | return 0; | 1697 | return 0; |
diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c index e845b75ccee4..ef91e2a4a567 100644 --- a/drivers/hwmon/adm1029.c +++ b/drivers/hwmon/adm1029.c | |||
@@ -301,59 +301,36 @@ static int adm1029_detect(struct i2c_client *client, int kind, | |||
301 | struct i2c_board_info *info) | 301 | struct i2c_board_info *info) |
302 | { | 302 | { |
303 | struct i2c_adapter *adapter = client->adapter; | 303 | struct i2c_adapter *adapter = client->adapter; |
304 | u8 man_id, chip_id, temp_devices_installed, nb_fan_support; | ||
304 | 305 | ||
305 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 306 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
306 | return -ENODEV; | 307 | return -ENODEV; |
307 | 308 | ||
308 | /* Now we do the detection and identification. A negative kind | ||
309 | * means that the driver was loaded with no force parameter | ||
310 | * (default), so we must both detect and identify the chip | ||
311 | * (actually there is only one possible kind of chip for now, adm1029). | ||
312 | * A zero kind means that the driver was loaded with the force | ||
313 | * parameter, the detection step shall be skipped. A positive kind | ||
314 | * means that the driver was loaded with the force parameter and a | ||
315 | * given kind of chip is requested, so both the detection and the | ||
316 | * identification steps are skipped. */ | ||
317 | |||
318 | /* Default to an adm1029 if forced */ | ||
319 | if (kind == 0) | ||
320 | kind = adm1029; | ||
321 | |||
322 | /* ADM1029 doesn't have CHIP ID, check just MAN ID | 309 | /* ADM1029 doesn't have CHIP ID, check just MAN ID |
323 | * For better detection we check also ADM1029_TEMP_DEVICES_INSTALLED, | 310 | * For better detection we check also ADM1029_TEMP_DEVICES_INSTALLED, |
324 | * ADM1029_REG_NB_FAN_SUPPORT and compare it with possible values | 311 | * ADM1029_REG_NB_FAN_SUPPORT and compare it with possible values |
325 | * documented | 312 | * documented |
326 | */ | 313 | */ |
327 | 314 | ||
328 | if (kind <= 0) { /* identification */ | 315 | man_id = i2c_smbus_read_byte_data(client, ADM1029_REG_MAN_ID); |
329 | u8 man_id, chip_id, temp_devices_installed, nb_fan_support; | 316 | chip_id = i2c_smbus_read_byte_data(client, ADM1029_REG_CHIP_ID); |
330 | 317 | temp_devices_installed = i2c_smbus_read_byte_data(client, | |
331 | man_id = i2c_smbus_read_byte_data(client, ADM1029_REG_MAN_ID); | ||
332 | chip_id = i2c_smbus_read_byte_data(client, ADM1029_REG_CHIP_ID); | ||
333 | temp_devices_installed = i2c_smbus_read_byte_data(client, | ||
334 | ADM1029_REG_TEMP_DEVICES_INSTALLED); | 318 | ADM1029_REG_TEMP_DEVICES_INSTALLED); |
335 | nb_fan_support = i2c_smbus_read_byte_data(client, | 319 | nb_fan_support = i2c_smbus_read_byte_data(client, |
336 | ADM1029_REG_NB_FAN_SUPPORT); | 320 | ADM1029_REG_NB_FAN_SUPPORT); |
337 | /* 0x41 is Analog Devices */ | 321 | /* 0x41 is Analog Devices */ |
338 | if (man_id == 0x41 && (temp_devices_installed & 0xf9) == 0x01 | 322 | if (man_id != 0x41 || (temp_devices_installed & 0xf9) != 0x01 |
339 | && nb_fan_support == 0x03) { | 323 | || nb_fan_support != 0x03) |
340 | if ((chip_id & 0xF0) == 0x00) { | 324 | return -ENODEV; |
341 | kind = adm1029; | ||
342 | } else { | ||
343 | /* There are no "official" CHIP ID, so actually | ||
344 | * we use Major/Minor revision for that */ | ||
345 | printk(KERN_INFO | ||
346 | "adm1029: Unknown major revision %x, " | ||
347 | "please let us know\n", chip_id); | ||
348 | } | ||
349 | } | ||
350 | 325 | ||
351 | if (kind <= 0) { /* identification failed */ | 326 | if ((chip_id & 0xF0) != 0x00) { |
352 | pr_debug("adm1029: Unsupported chip (man_id=0x%02X, " | 327 | /* There are no "official" CHIP ID, so actually |
353 | "chip_id=0x%02X)\n", man_id, chip_id); | 328 | * we use Major/Minor revision for that */ |
354 | return -ENODEV; | 329 | pr_info("adm1029: Unknown major revision %x, " |
355 | } | 330 | "please let us know\n", chip_id); |
331 | return -ENODEV; | ||
356 | } | 332 | } |
333 | |||
357 | strlcpy(info->type, "adm1029", I2C_NAME_SIZE); | 334 | strlcpy(info->type, "adm1029", I2C_NAME_SIZE); |
358 | 335 | ||
359 | return 0; | 336 | return 0; |
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 56905955352c..0e722175aae0 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -817,31 +817,19 @@ static int adm1031_detect(struct i2c_client *client, int kind, | |||
817 | struct i2c_board_info *info) | 817 | struct i2c_board_info *info) |
818 | { | 818 | { |
819 | struct i2c_adapter *adapter = client->adapter; | 819 | struct i2c_adapter *adapter = client->adapter; |
820 | const char *name = ""; | 820 | const char *name; |
821 | int id, co; | ||
821 | 822 | ||
822 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 823 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
823 | return -ENODEV; | 824 | return -ENODEV; |
824 | 825 | ||
825 | if (kind < 0) { | 826 | id = i2c_smbus_read_byte_data(client, 0x3d); |
826 | int id, co; | 827 | co = i2c_smbus_read_byte_data(client, 0x3e); |
827 | id = i2c_smbus_read_byte_data(client, 0x3d); | ||
828 | co = i2c_smbus_read_byte_data(client, 0x3e); | ||
829 | 828 | ||
830 | if (!((id == 0x31 || id == 0x30) && co == 0x41)) | 829 | if (!((id == 0x31 || id == 0x30) && co == 0x41)) |
831 | return -ENODEV; | 830 | return -ENODEV; |
832 | kind = (id == 0x30) ? adm1030 : adm1031; | 831 | name = (id == 0x30) ? "adm1030" : "adm1031"; |
833 | } | ||
834 | |||
835 | if (kind <= 0) | ||
836 | kind = adm1031; | ||
837 | 832 | ||
838 | /* Given the detected chip type, set the chip name and the | ||
839 | * auto fan control helper table. */ | ||
840 | if (kind == adm1030) { | ||
841 | name = "adm1030"; | ||
842 | } else if (kind == adm1031) { | ||
843 | name = "adm1031"; | ||
844 | } | ||
845 | strlcpy(info->type, name, I2C_NAME_SIZE); | 833 | strlcpy(info->type, name, I2C_NAME_SIZE); |
846 | 834 | ||
847 | return 0; | 835 | return 0; |
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 2444b15f2e9d..20e0481cc206 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -556,51 +556,34 @@ static int adm9240_detect(struct i2c_client *new_client, int kind, | |||
556 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 556 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
557 | return -ENODEV; | 557 | return -ENODEV; |
558 | 558 | ||
559 | if (kind == 0) { | 559 | /* verify chip: reg address should match i2c address */ |
560 | kind = adm9240; | 560 | if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) |
561 | } | 561 | != address) { |
562 | 562 | dev_err(&adapter->dev, "detect fail: address match, 0x%02x\n", | |
563 | if (kind < 0) { | 563 | address); |
564 | 564 | return -ENODEV; | |
565 | /* verify chip: reg address should match i2c address */ | ||
566 | if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) | ||
567 | != address) { | ||
568 | dev_err(&adapter->dev, "detect fail: address match, " | ||
569 | "0x%02x\n", address); | ||
570 | return -ENODEV; | ||
571 | } | ||
572 | |||
573 | /* check known chip manufacturer */ | ||
574 | man_id = i2c_smbus_read_byte_data(new_client, | ||
575 | ADM9240_REG_MAN_ID); | ||
576 | if (man_id == 0x23) { | ||
577 | kind = adm9240; | ||
578 | } else if (man_id == 0xda) { | ||
579 | kind = ds1780; | ||
580 | } else if (man_id == 0x01) { | ||
581 | kind = lm81; | ||
582 | } else { | ||
583 | dev_err(&adapter->dev, "detect fail: unknown manuf, " | ||
584 | "0x%02x\n", man_id); | ||
585 | return -ENODEV; | ||
586 | } | ||
587 | |||
588 | /* successful detect, print chip info */ | ||
589 | die_rev = i2c_smbus_read_byte_data(new_client, | ||
590 | ADM9240_REG_DIE_REV); | ||
591 | dev_info(&adapter->dev, "found %s revision %u\n", | ||
592 | man_id == 0x23 ? "ADM9240" : | ||
593 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | ||
594 | } | 565 | } |
595 | 566 | ||
596 | /* either forced or detected chip kind */ | 567 | /* check known chip manufacturer */ |
597 | if (kind == adm9240) { | 568 | man_id = i2c_smbus_read_byte_data(new_client, ADM9240_REG_MAN_ID); |
569 | if (man_id == 0x23) { | ||
598 | name = "adm9240"; | 570 | name = "adm9240"; |
599 | } else if (kind == ds1780) { | 571 | } else if (man_id == 0xda) { |
600 | name = "ds1780"; | 572 | name = "ds1780"; |
601 | } else if (kind == lm81) { | 573 | } else if (man_id == 0x01) { |
602 | name = "lm81"; | 574 | name = "lm81"; |
575 | } else { | ||
576 | dev_err(&adapter->dev, "detect fail: unknown manuf, 0x%02x\n", | ||
577 | man_id); | ||
578 | return -ENODEV; | ||
603 | } | 579 | } |
580 | |||
581 | /* successful detect, print chip info */ | ||
582 | die_rev = i2c_smbus_read_byte_data(new_client, ADM9240_REG_DIE_REV); | ||
583 | dev_info(&adapter->dev, "found %s revision %u\n", | ||
584 | man_id == 0x23 ? "ADM9240" : | ||
585 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | ||
586 | |||
604 | strlcpy(info->type, name, I2C_NAME_SIZE); | 587 | strlcpy(info->type, name, I2C_NAME_SIZE); |
605 | 588 | ||
606 | return 0; | 589 | return 0; |
diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c index 5c39b4af1b23..451977bca7d6 100644 --- a/drivers/hwmon/ads7828.c +++ b/drivers/hwmon/ads7828.c | |||
@@ -191,6 +191,7 @@ static int ads7828_detect(struct i2c_client *client, int kind, | |||
191 | struct i2c_board_info *info) | 191 | struct i2c_board_info *info) |
192 | { | 192 | { |
193 | struct i2c_adapter *adapter = client->adapter; | 193 | struct i2c_adapter *adapter = client->adapter; |
194 | int ch; | ||
194 | 195 | ||
195 | /* Check we have a valid client */ | 196 | /* Check we have a valid client */ |
196 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_WORD_DATA)) | 197 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_WORD_DATA)) |
@@ -202,20 +203,17 @@ static int ads7828_detect(struct i2c_client *client, int kind, | |||
202 | - Read from the 8 channel addresses | 203 | - Read from the 8 channel addresses |
203 | - Check the top 4 bits of each result are not set (12 data bits) | 204 | - Check the top 4 bits of each result are not set (12 data bits) |
204 | */ | 205 | */ |
205 | if (kind < 0) { | 206 | for (ch = 0; ch < ADS7828_NCH; ch++) { |
206 | int ch; | 207 | u16 in_data; |
207 | for (ch = 0; ch < ADS7828_NCH; ch++) { | 208 | u8 cmd = channel_cmd_byte(ch); |
208 | u16 in_data; | 209 | in_data = ads7828_read_value(client, cmd); |
209 | u8 cmd = channel_cmd_byte(ch); | 210 | if (in_data & 0xF000) { |
210 | in_data = ads7828_read_value(client, cmd); | 211 | pr_debug("%s : Doesn't look like an ads7828 device\n", |
211 | if (in_data & 0xF000) { | 212 | __func__); |
212 | printk(KERN_DEBUG | 213 | return -ENODEV; |
213 | "%s : Doesn't look like an ads7828 device\n", | ||
214 | __func__); | ||
215 | return -ENODEV; | ||
216 | } | ||
217 | } | 214 | } |
218 | } | 215 | } |
216 | |||
219 | strlcpy(info->type, "ads7828", I2C_NAME_SIZE); | 217 | strlcpy(info->type, "ads7828", I2C_NAME_SIZE); |
220 | 218 | ||
221 | return 0; | 219 | return 0; |
diff --git a/drivers/hwmon/adt7462.c b/drivers/hwmon/adt7462.c index 1852f27bac51..f9c9562b6a94 100644 --- a/drivers/hwmon/adt7462.c +++ b/drivers/hwmon/adt7462.c | |||
@@ -1906,27 +1906,22 @@ static int adt7462_detect(struct i2c_client *client, int kind, | |||
1906 | struct i2c_board_info *info) | 1906 | struct i2c_board_info *info) |
1907 | { | 1907 | { |
1908 | struct i2c_adapter *adapter = client->adapter; | 1908 | struct i2c_adapter *adapter = client->adapter; |
1909 | int vendor, device, revision; | ||
1909 | 1910 | ||
1910 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 1911 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
1911 | return -ENODEV; | 1912 | return -ENODEV; |
1912 | 1913 | ||
1913 | if (kind <= 0) { | 1914 | vendor = i2c_smbus_read_byte_data(client, ADT7462_REG_VENDOR); |
1914 | int vendor, device, revision; | 1915 | if (vendor != ADT7462_VENDOR) |
1915 | 1916 | return -ENODEV; | |
1916 | vendor = i2c_smbus_read_byte_data(client, ADT7462_REG_VENDOR); | ||
1917 | if (vendor != ADT7462_VENDOR) | ||
1918 | return -ENODEV; | ||
1919 | 1917 | ||
1920 | device = i2c_smbus_read_byte_data(client, ADT7462_REG_DEVICE); | 1918 | device = i2c_smbus_read_byte_data(client, ADT7462_REG_DEVICE); |
1921 | if (device != ADT7462_DEVICE) | 1919 | if (device != ADT7462_DEVICE) |
1922 | return -ENODEV; | 1920 | return -ENODEV; |
1923 | 1921 | ||
1924 | revision = i2c_smbus_read_byte_data(client, | 1922 | revision = i2c_smbus_read_byte_data(client, ADT7462_REG_REVISION); |
1925 | ADT7462_REG_REVISION); | 1923 | if (revision != ADT7462_REVISION) |
1926 | if (revision != ADT7462_REVISION) | 1924 | return -ENODEV; |
1927 | return -ENODEV; | ||
1928 | } else | ||
1929 | dev_dbg(&adapter->dev, "detection forced\n"); | ||
1930 | 1925 | ||
1931 | strlcpy(info->type, "adt7462", I2C_NAME_SIZE); | 1926 | strlcpy(info->type, "adt7462", I2C_NAME_SIZE); |
1932 | 1927 | ||
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index 633e1a1e9d79..32b1750a6890 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c | |||
@@ -1229,27 +1229,22 @@ static int adt7470_detect(struct i2c_client *client, int kind, | |||
1229 | struct i2c_board_info *info) | 1229 | struct i2c_board_info *info) |
1230 | { | 1230 | { |
1231 | struct i2c_adapter *adapter = client->adapter; | 1231 | struct i2c_adapter *adapter = client->adapter; |
1232 | int vendor, device, revision; | ||
1232 | 1233 | ||
1233 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 1234 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
1234 | return -ENODEV; | 1235 | return -ENODEV; |
1235 | 1236 | ||
1236 | if (kind <= 0) { | 1237 | vendor = i2c_smbus_read_byte_data(client, ADT7470_REG_VENDOR); |
1237 | int vendor, device, revision; | 1238 | if (vendor != ADT7470_VENDOR) |
1238 | 1239 | return -ENODEV; | |
1239 | vendor = i2c_smbus_read_byte_data(client, ADT7470_REG_VENDOR); | ||
1240 | if (vendor != ADT7470_VENDOR) | ||
1241 | return -ENODEV; | ||
1242 | 1240 | ||
1243 | device = i2c_smbus_read_byte_data(client, ADT7470_REG_DEVICE); | 1241 | device = i2c_smbus_read_byte_data(client, ADT7470_REG_DEVICE); |
1244 | if (device != ADT7470_DEVICE) | 1242 | if (device != ADT7470_DEVICE) |
1245 | return -ENODEV; | 1243 | return -ENODEV; |
1246 | 1244 | ||
1247 | revision = i2c_smbus_read_byte_data(client, | 1245 | revision = i2c_smbus_read_byte_data(client, ADT7470_REG_REVISION); |
1248 | ADT7470_REG_REVISION); | 1246 | if (revision != ADT7470_REVISION) |
1249 | if (revision != ADT7470_REVISION) | 1247 | return -ENODEV; |
1250 | return -ENODEV; | ||
1251 | } else | ||
1252 | dev_dbg(&adapter->dev, "detection forced\n"); | ||
1253 | 1248 | ||
1254 | strlcpy(info->type, "adt7470", I2C_NAME_SIZE); | 1249 | strlcpy(info->type, "adt7470", I2C_NAME_SIZE); |
1255 | 1250 | ||
diff --git a/drivers/hwmon/adt7473.c b/drivers/hwmon/adt7473.c index 0a6ce2367b42..aea244db974e 100644 --- a/drivers/hwmon/adt7473.c +++ b/drivers/hwmon/adt7473.c | |||
@@ -174,7 +174,6 @@ static const struct i2c_device_id adt7473_id[] = { | |||
174 | { "adt7473", adt7473 }, | 174 | { "adt7473", adt7473 }, |
175 | { } | 175 | { } |
176 | }; | 176 | }; |
177 | MODULE_DEVICE_TABLE(i2c, adt7473_id); | ||
178 | 177 | ||
179 | static struct i2c_driver adt7473_driver = { | 178 | static struct i2c_driver adt7473_driver = { |
180 | .class = I2C_CLASS_HWMON, | 179 | .class = I2C_CLASS_HWMON, |
@@ -1090,27 +1089,22 @@ static int adt7473_detect(struct i2c_client *client, int kind, | |||
1090 | struct i2c_board_info *info) | 1089 | struct i2c_board_info *info) |
1091 | { | 1090 | { |
1092 | struct i2c_adapter *adapter = client->adapter; | 1091 | struct i2c_adapter *adapter = client->adapter; |
1092 | int vendor, device, revision; | ||
1093 | 1093 | ||
1094 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 1094 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
1095 | return -ENODEV; | 1095 | return -ENODEV; |
1096 | 1096 | ||
1097 | if (kind <= 0) { | 1097 | vendor = i2c_smbus_read_byte_data(client, ADT7473_REG_VENDOR); |
1098 | int vendor, device, revision; | 1098 | if (vendor != ADT7473_VENDOR) |
1099 | 1099 | return -ENODEV; | |
1100 | vendor = i2c_smbus_read_byte_data(client, ADT7473_REG_VENDOR); | ||
1101 | if (vendor != ADT7473_VENDOR) | ||
1102 | return -ENODEV; | ||
1103 | 1100 | ||
1104 | device = i2c_smbus_read_byte_data(client, ADT7473_REG_DEVICE); | 1101 | device = i2c_smbus_read_byte_data(client, ADT7473_REG_DEVICE); |
1105 | if (device != ADT7473_DEVICE) | 1102 | if (device != ADT7473_DEVICE) |
1106 | return -ENODEV; | 1103 | return -ENODEV; |
1107 | 1104 | ||
1108 | revision = i2c_smbus_read_byte_data(client, | 1105 | revision = i2c_smbus_read_byte_data(client, ADT7473_REG_REVISION); |
1109 | ADT7473_REG_REVISION); | 1106 | if (revision != ADT7473_REV_68 && revision != ADT7473_REV_69) |
1110 | if (revision != ADT7473_REV_68 && revision != ADT7473_REV_69) | 1107 | return -ENODEV; |
1111 | return -ENODEV; | ||
1112 | } else | ||
1113 | dev_dbg(&adapter->dev, "detection forced\n"); | ||
1114 | 1108 | ||
1115 | strlcpy(info->type, "adt7473", I2C_NAME_SIZE); | 1109 | strlcpy(info->type, "adt7473", I2C_NAME_SIZE); |
1116 | 1110 | ||
@@ -1171,6 +1165,8 @@ static int adt7473_remove(struct i2c_client *client) | |||
1171 | 1165 | ||
1172 | static int __init adt7473_init(void) | 1166 | static int __init adt7473_init(void) |
1173 | { | 1167 | { |
1168 | pr_notice("The adt7473 driver is deprecated, please use the adt7475 " | ||
1169 | "driver instead\n"); | ||
1174 | return i2c_add_driver(&adt7473_driver); | 1170 | return i2c_add_driver(&adt7473_driver); |
1175 | } | 1171 | } |
1176 | 1172 | ||
diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index b5a95193c694..99abfddedbc3 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c | |||
@@ -3,7 +3,8 @@ | |||
3 | * Copyright (C) 2007-2008, Advanced Micro Devices, Inc. | 3 | * Copyright (C) 2007-2008, Advanced Micro Devices, Inc. |
4 | * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net> | 4 | * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net> |
5 | * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com> | 5 | * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com> |
6 | 6 | * Copyright (C) 2009 Jean Delvare <khali@linux-fr.org> | |
7 | * | ||
7 | * Derived from the lm83 driver by Jean Delvare | 8 | * Derived from the lm83 driver by Jean Delvare |
8 | * | 9 | * |
9 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
@@ -17,6 +18,7 @@ | |||
17 | #include <linux/i2c.h> | 18 | #include <linux/i2c.h> |
18 | #include <linux/hwmon.h> | 19 | #include <linux/hwmon.h> |
19 | #include <linux/hwmon-sysfs.h> | 20 | #include <linux/hwmon-sysfs.h> |
21 | #include <linux/hwmon-vid.h> | ||
20 | #include <linux/err.h> | 22 | #include <linux/err.h> |
21 | 23 | ||
22 | /* Indexes for the sysfs hooks */ | 24 | /* Indexes for the sysfs hooks */ |
@@ -39,7 +41,12 @@ | |||
39 | 41 | ||
40 | /* 7475 Common Registers */ | 42 | /* 7475 Common Registers */ |
41 | 43 | ||
42 | #define REG_VOLTAGE_BASE 0x21 | 44 | #define REG_DEVREV2 0x12 /* ADT7490 only */ |
45 | |||
46 | #define REG_VTT 0x1E /* ADT7490 only */ | ||
47 | #define REG_EXTEND3 0x1F /* ADT7490 only */ | ||
48 | |||
49 | #define REG_VOLTAGE_BASE 0x20 | ||
43 | #define REG_TEMP_BASE 0x25 | 50 | #define REG_TEMP_BASE 0x25 |
44 | #define REG_TACH_BASE 0x28 | 51 | #define REG_TACH_BASE 0x28 |
45 | #define REG_PWM_BASE 0x30 | 52 | #define REG_PWM_BASE 0x30 |
@@ -47,12 +54,15 @@ | |||
47 | 54 | ||
48 | #define REG_DEVID 0x3D | 55 | #define REG_DEVID 0x3D |
49 | #define REG_VENDID 0x3E | 56 | #define REG_VENDID 0x3E |
57 | #define REG_DEVID2 0x3F | ||
50 | 58 | ||
51 | #define REG_STATUS1 0x41 | 59 | #define REG_STATUS1 0x41 |
52 | #define REG_STATUS2 0x42 | 60 | #define REG_STATUS2 0x42 |
53 | 61 | ||
54 | #define REG_VOLTAGE_MIN_BASE 0x46 | 62 | #define REG_VID 0x43 /* ADT7476 only */ |
55 | #define REG_VOLTAGE_MAX_BASE 0x47 | 63 | |
64 | #define REG_VOLTAGE_MIN_BASE 0x44 | ||
65 | #define REG_VOLTAGE_MAX_BASE 0x45 | ||
56 | 66 | ||
57 | #define REG_TEMP_MIN_BASE 0x4E | 67 | #define REG_TEMP_MIN_BASE 0x4E |
58 | #define REG_TEMP_MAX_BASE 0x4F | 68 | #define REG_TEMP_MAX_BASE 0x4F |
@@ -73,16 +83,39 @@ | |||
73 | 83 | ||
74 | #define REG_TEMP_OFFSET_BASE 0x70 | 84 | #define REG_TEMP_OFFSET_BASE 0x70 |
75 | 85 | ||
86 | #define REG_CONFIG2 0x73 | ||
87 | |||
76 | #define REG_EXTEND1 0x76 | 88 | #define REG_EXTEND1 0x76 |
77 | #define REG_EXTEND2 0x77 | 89 | #define REG_EXTEND2 0x77 |
90 | |||
91 | #define REG_CONFIG3 0x78 | ||
78 | #define REG_CONFIG5 0x7C | 92 | #define REG_CONFIG5 0x7C |
93 | #define REG_CONFIG4 0x7D | ||
94 | |||
95 | #define REG_STATUS4 0x81 /* ADT7490 only */ | ||
96 | |||
97 | #define REG_VTT_MIN 0x84 /* ADT7490 only */ | ||
98 | #define REG_VTT_MAX 0x86 /* ADT7490 only */ | ||
99 | |||
100 | #define VID_VIDSEL 0x80 /* ADT7476 only */ | ||
101 | |||
102 | #define CONFIG2_ATTN 0x20 | ||
103 | |||
104 | #define CONFIG3_SMBALERT 0x01 | ||
105 | #define CONFIG3_THERM 0x02 | ||
106 | |||
107 | #define CONFIG4_PINFUNC 0x03 | ||
108 | #define CONFIG4_MAXDUTY 0x08 | ||
109 | #define CONFIG4_ATTN_IN10 0x30 | ||
110 | #define CONFIG4_ATTN_IN43 0xC0 | ||
79 | 111 | ||
80 | #define CONFIG5_TWOSCOMP 0x01 | 112 | #define CONFIG5_TWOSCOMP 0x01 |
81 | #define CONFIG5_TEMPOFFSET 0x02 | 113 | #define CONFIG5_TEMPOFFSET 0x02 |
114 | #define CONFIG5_VIDGPIO 0x10 /* ADT7476 only */ | ||
82 | 115 | ||
83 | /* ADT7475 Settings */ | 116 | /* ADT7475 Settings */ |
84 | 117 | ||
85 | #define ADT7475_VOLTAGE_COUNT 2 | 118 | #define ADT7475_VOLTAGE_COUNT 5 /* Not counting Vtt */ |
86 | #define ADT7475_TEMP_COUNT 3 | 119 | #define ADT7475_TEMP_COUNT 3 |
87 | #define ADT7475_TACH_COUNT 4 | 120 | #define ADT7475_TACH_COUNT 4 |
88 | #define ADT7475_PWM_COUNT 3 | 121 | #define ADT7475_PWM_COUNT 3 |
@@ -113,12 +146,15 @@ | |||
113 | #define TEMP_OFFSET_REG(idx) (REG_TEMP_OFFSET_BASE + (idx)) | 146 | #define TEMP_OFFSET_REG(idx) (REG_TEMP_OFFSET_BASE + (idx)) |
114 | #define TEMP_TRANGE_REG(idx) (REG_TEMP_TRANGE_BASE + (idx)) | 147 | #define TEMP_TRANGE_REG(idx) (REG_TEMP_TRANGE_BASE + (idx)) |
115 | 148 | ||
116 | static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END }; | 149 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
117 | 150 | ||
118 | I2C_CLIENT_INSMOD_1(adt7475); | 151 | I2C_CLIENT_INSMOD_4(adt7473, adt7475, adt7476, adt7490); |
119 | 152 | ||
120 | static const struct i2c_device_id adt7475_id[] = { | 153 | static const struct i2c_device_id adt7475_id[] = { |
154 | { "adt7473", adt7473 }, | ||
121 | { "adt7475", adt7475 }, | 155 | { "adt7475", adt7475 }, |
156 | { "adt7476", adt7476 }, | ||
157 | { "adt7490", adt7490 }, | ||
122 | { } | 158 | { } |
123 | }; | 159 | }; |
124 | MODULE_DEVICE_TABLE(i2c, adt7475_id); | 160 | MODULE_DEVICE_TABLE(i2c, adt7475_id); |
@@ -131,15 +167,24 @@ struct adt7475_data { | |||
131 | unsigned long limits_updated; | 167 | unsigned long limits_updated; |
132 | char valid; | 168 | char valid; |
133 | 169 | ||
170 | u8 config4; | ||
134 | u8 config5; | 171 | u8 config5; |
135 | u16 alarms; | 172 | u8 has_voltage; |
136 | u16 voltage[3][3]; | 173 | u8 bypass_attn; /* Bypass voltage attenuator */ |
174 | u8 has_pwm2:1; | ||
175 | u8 has_fan4:1; | ||
176 | u8 has_vid:1; | ||
177 | u32 alarms; | ||
178 | u16 voltage[3][6]; | ||
137 | u16 temp[7][3]; | 179 | u16 temp[7][3]; |
138 | u16 tach[2][4]; | 180 | u16 tach[2][4]; |
139 | u8 pwm[4][3]; | 181 | u8 pwm[4][3]; |
140 | u8 range[3]; | 182 | u8 range[3]; |
141 | u8 pwmctl[3]; | 183 | u8 pwmctl[3]; |
142 | u8 pwmchan[3]; | 184 | u8 pwmchan[3]; |
185 | |||
186 | u8 vid; | ||
187 | u8 vrm; | ||
143 | }; | 188 | }; |
144 | 189 | ||
145 | static struct i2c_driver adt7475_driver; | 190 | static struct i2c_driver adt7475_driver; |
@@ -196,26 +241,35 @@ static inline u16 rpm2tach(unsigned long rpm) | |||
196 | return SENSORS_LIMIT((90000 * 60) / rpm, 1, 0xFFFF); | 241 | return SENSORS_LIMIT((90000 * 60) / rpm, 1, 0xFFFF); |
197 | } | 242 | } |
198 | 243 | ||
199 | static inline int reg2vcc(u16 reg) | 244 | /* Scaling factors for voltage inputs, taken from the ADT7490 datasheet */ |
200 | { | 245 | static const int adt7473_in_scaling[ADT7475_VOLTAGE_COUNT + 1][2] = { |
201 | return (4296 * reg) / 1000; | 246 | { 45, 94 }, /* +2.5V */ |
202 | } | 247 | { 175, 525 }, /* Vccp */ |
248 | { 68, 71 }, /* Vcc */ | ||
249 | { 93, 47 }, /* +5V */ | ||
250 | { 120, 20 }, /* +12V */ | ||
251 | { 45, 45 }, /* Vtt */ | ||
252 | }; | ||
203 | 253 | ||
204 | static inline int reg2vccp(u16 reg) | 254 | static inline int reg2volt(int channel, u16 reg, u8 bypass_attn) |
205 | { | 255 | { |
206 | return (2929 * reg) / 1000; | 256 | const int *r = adt7473_in_scaling[channel]; |
207 | } | ||
208 | 257 | ||
209 | static inline u16 vcc2reg(long vcc) | 258 | if (bypass_attn & (1 << channel)) |
210 | { | 259 | return DIV_ROUND_CLOSEST(reg * 2250, 1024); |
211 | vcc = SENSORS_LIMIT(vcc, 0, 4396); | 260 | return DIV_ROUND_CLOSEST(reg * (r[0] + r[1]) * 2250, r[1] * 1024); |
212 | return (vcc * 1000) / 4296; | ||
213 | } | 261 | } |
214 | 262 | ||
215 | static inline u16 vccp2reg(long vcc) | 263 | static inline u16 volt2reg(int channel, long volt, u8 bypass_attn) |
216 | { | 264 | { |
217 | vcc = SENSORS_LIMIT(vcc, 0, 2998); | 265 | const int *r = adt7473_in_scaling[channel]; |
218 | return (vcc * 1000) / 2929; | 266 | long reg; |
267 | |||
268 | if (bypass_attn & (1 << channel)) | ||
269 | reg = (volt * 1024) / 2250; | ||
270 | else | ||
271 | reg = (volt * r[1] * 1024) / ((r[0] + r[1]) * 2250); | ||
272 | return SENSORS_LIMIT(reg, 0, 1023) & (0xff << 2); | ||
219 | } | 273 | } |
220 | 274 | ||
221 | static u16 adt7475_read_word(struct i2c_client *client, int reg) | 275 | static u16 adt7475_read_word(struct i2c_client *client, int reg) |
@@ -271,12 +325,11 @@ static ssize_t show_voltage(struct device *dev, struct device_attribute *attr, | |||
271 | switch (sattr->nr) { | 325 | switch (sattr->nr) { |
272 | case ALARM: | 326 | case ALARM: |
273 | return sprintf(buf, "%d\n", | 327 | return sprintf(buf, "%d\n", |
274 | (data->alarms >> (sattr->index + 1)) & 1); | 328 | (data->alarms >> sattr->index) & 1); |
275 | default: | 329 | default: |
276 | val = data->voltage[sattr->nr][sattr->index]; | 330 | val = data->voltage[sattr->nr][sattr->index]; |
277 | return sprintf(buf, "%d\n", | 331 | return sprintf(buf, "%d\n", |
278 | sattr->index == | 332 | reg2volt(sattr->index, val, data->bypass_attn)); |
279 | 0 ? reg2vccp(val) : reg2vcc(val)); | ||
280 | } | 333 | } |
281 | } | 334 | } |
282 | 335 | ||
@@ -296,12 +349,19 @@ static ssize_t set_voltage(struct device *dev, struct device_attribute *attr, | |||
296 | mutex_lock(&data->lock); | 349 | mutex_lock(&data->lock); |
297 | 350 | ||
298 | data->voltage[sattr->nr][sattr->index] = | 351 | data->voltage[sattr->nr][sattr->index] = |
299 | sattr->index ? vcc2reg(val) : vccp2reg(val); | 352 | volt2reg(sattr->index, val, data->bypass_attn); |
300 | 353 | ||
301 | if (sattr->nr == MIN) | 354 | if (sattr->index < ADT7475_VOLTAGE_COUNT) { |
302 | reg = VOLTAGE_MIN_REG(sattr->index); | 355 | if (sattr->nr == MIN) |
303 | else | 356 | reg = VOLTAGE_MIN_REG(sattr->index); |
304 | reg = VOLTAGE_MAX_REG(sattr->index); | 357 | else |
358 | reg = VOLTAGE_MAX_REG(sattr->index); | ||
359 | } else { | ||
360 | if (sattr->nr == MIN) | ||
361 | reg = REG_VTT_MIN; | ||
362 | else | ||
363 | reg = REG_VTT_MAX; | ||
364 | } | ||
305 | 365 | ||
306 | i2c_smbus_write_byte_data(client, reg, | 366 | i2c_smbus_write_byte_data(client, reg, |
307 | data->voltage[sattr->nr][sattr->index] >> 2); | 367 | data->voltage[sattr->nr][sattr->index] >> 2); |
@@ -778,18 +838,103 @@ static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr, | |||
778 | return count; | 838 | return count; |
779 | } | 839 | } |
780 | 840 | ||
781 | static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 0); | 841 | static ssize_t show_pwm_at_crit(struct device *dev, |
782 | static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage, | 842 | struct device_attribute *devattr, char *buf) |
843 | { | ||
844 | struct adt7475_data *data = adt7475_update_device(dev); | ||
845 | return sprintf(buf, "%d\n", !!(data->config4 & CONFIG4_MAXDUTY)); | ||
846 | } | ||
847 | |||
848 | static ssize_t set_pwm_at_crit(struct device *dev, | ||
849 | struct device_attribute *devattr, | ||
850 | const char *buf, size_t count) | ||
851 | { | ||
852 | struct i2c_client *client = to_i2c_client(dev); | ||
853 | struct adt7475_data *data = i2c_get_clientdata(client); | ||
854 | long val; | ||
855 | |||
856 | if (strict_strtol(buf, 10, &val)) | ||
857 | return -EINVAL; | ||
858 | if (val != 0 && val != 1) | ||
859 | return -EINVAL; | ||
860 | |||
861 | mutex_lock(&data->lock); | ||
862 | data->config4 = i2c_smbus_read_byte_data(client, REG_CONFIG4); | ||
863 | if (val) | ||
864 | data->config4 |= CONFIG4_MAXDUTY; | ||
865 | else | ||
866 | data->config4 &= ~CONFIG4_MAXDUTY; | ||
867 | i2c_smbus_write_byte_data(client, REG_CONFIG4, data->config4); | ||
868 | mutex_unlock(&data->lock); | ||
869 | |||
870 | return count; | ||
871 | } | ||
872 | |||
873 | static ssize_t show_vrm(struct device *dev, struct device_attribute *devattr, | ||
874 | char *buf) | ||
875 | { | ||
876 | struct adt7475_data *data = dev_get_drvdata(dev); | ||
877 | return sprintf(buf, "%d\n", (int)data->vrm); | ||
878 | } | ||
879 | |||
880 | static ssize_t set_vrm(struct device *dev, struct device_attribute *devattr, | ||
881 | const char *buf, size_t count) | ||
882 | { | ||
883 | struct adt7475_data *data = dev_get_drvdata(dev); | ||
884 | long val; | ||
885 | |||
886 | if (strict_strtol(buf, 10, &val)) | ||
887 | return -EINVAL; | ||
888 | if (val < 0 || val > 255) | ||
889 | return -EINVAL; | ||
890 | data->vrm = val; | ||
891 | |||
892 | return count; | ||
893 | } | ||
894 | |||
895 | static ssize_t show_vid(struct device *dev, struct device_attribute *devattr, | ||
896 | char *buf) | ||
897 | { | ||
898 | struct adt7475_data *data = adt7475_update_device(dev); | ||
899 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); | ||
900 | } | ||
901 | |||
902 | static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_voltage, NULL, INPUT, 0); | ||
903 | static SENSOR_DEVICE_ATTR_2(in0_max, S_IRUGO | S_IWUSR, show_voltage, | ||
783 | set_voltage, MAX, 0); | 904 | set_voltage, MAX, 0); |
784 | static SENSOR_DEVICE_ATTR_2(in1_min, S_IRUGO | S_IWUSR, show_voltage, | 905 | static SENSOR_DEVICE_ATTR_2(in0_min, S_IRUGO | S_IWUSR, show_voltage, |
785 | set_voltage, MIN, 0); | 906 | set_voltage, MIN, 0); |
786 | static SENSOR_DEVICE_ATTR_2(in1_alarm, S_IRUGO, show_voltage, NULL, ALARM, 0); | 907 | static SENSOR_DEVICE_ATTR_2(in0_alarm, S_IRUGO, show_voltage, NULL, ALARM, 0); |
787 | static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_voltage, NULL, INPUT, 1); | 908 | static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 1); |
788 | static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_voltage, | 909 | static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage, |
789 | set_voltage, MAX, 1); | 910 | set_voltage, MAX, 1); |
790 | static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_voltage, | 911 | static SENSOR_DEVICE_ATTR_2(in1_min, S_IRUGO | S_IWUSR, show_voltage, |
791 | set_voltage, MIN, 1); | 912 | set_voltage, MIN, 1); |
792 | static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, show_voltage, NULL, ALARM, 1); | 913 | static SENSOR_DEVICE_ATTR_2(in1_alarm, S_IRUGO, show_voltage, NULL, ALARM, 1); |
914 | static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_voltage, NULL, INPUT, 2); | ||
915 | static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_voltage, | ||
916 | set_voltage, MAX, 2); | ||
917 | static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_voltage, | ||
918 | set_voltage, MIN, 2); | ||
919 | static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, show_voltage, NULL, ALARM, 2); | ||
920 | static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, show_voltage, NULL, INPUT, 3); | ||
921 | static SENSOR_DEVICE_ATTR_2(in3_max, S_IRUGO | S_IWUSR, show_voltage, | ||
922 | set_voltage, MAX, 3); | ||
923 | static SENSOR_DEVICE_ATTR_2(in3_min, S_IRUGO | S_IWUSR, show_voltage, | ||
924 | set_voltage, MIN, 3); | ||
925 | static SENSOR_DEVICE_ATTR_2(in3_alarm, S_IRUGO, show_voltage, NULL, ALARM, 3); | ||
926 | static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, show_voltage, NULL, INPUT, 4); | ||
927 | static SENSOR_DEVICE_ATTR_2(in4_max, S_IRUGO | S_IWUSR, show_voltage, | ||
928 | set_voltage, MAX, 4); | ||
929 | static SENSOR_DEVICE_ATTR_2(in4_min, S_IRUGO | S_IWUSR, show_voltage, | ||
930 | set_voltage, MIN, 4); | ||
931 | static SENSOR_DEVICE_ATTR_2(in4_alarm, S_IRUGO, show_voltage, NULL, ALARM, 8); | ||
932 | static SENSOR_DEVICE_ATTR_2(in5_input, S_IRUGO, show_voltage, NULL, INPUT, 5); | ||
933 | static SENSOR_DEVICE_ATTR_2(in5_max, S_IRUGO | S_IWUSR, show_voltage, | ||
934 | set_voltage, MAX, 5); | ||
935 | static SENSOR_DEVICE_ATTR_2(in5_min, S_IRUGO | S_IWUSR, show_voltage, | ||
936 | set_voltage, MIN, 5); | ||
937 | static SENSOR_DEVICE_ATTR_2(in5_alarm, S_IRUGO, show_voltage, NULL, ALARM, 31); | ||
793 | static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, INPUT, 0); | 938 | static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, INPUT, 0); |
794 | static SENSOR_DEVICE_ATTR_2(temp1_alarm, S_IRUGO, show_temp, NULL, ALARM, 0); | 939 | static SENSOR_DEVICE_ATTR_2(temp1_alarm, S_IRUGO, show_temp, NULL, ALARM, 0); |
795 | static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, show_temp, NULL, FAULT, 0); | 940 | static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, show_temp, NULL, FAULT, 0); |
@@ -893,6 +1038,13 @@ static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm, | |||
893 | static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm, | 1038 | static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm, |
894 | set_pwm, MAX, 2); | 1039 | set_pwm, MAX, 2); |
895 | 1040 | ||
1041 | /* Non-standard name, might need revisiting */ | ||
1042 | static DEVICE_ATTR(pwm_use_point2_pwm_at_crit, S_IWUSR | S_IRUGO, | ||
1043 | show_pwm_at_crit, set_pwm_at_crit); | ||
1044 | |||
1045 | static DEVICE_ATTR(vrm, S_IWUSR | S_IRUGO, show_vrm, set_vrm); | ||
1046 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | ||
1047 | |||
896 | static struct attribute *adt7475_attrs[] = { | 1048 | static struct attribute *adt7475_attrs[] = { |
897 | &sensor_dev_attr_in1_input.dev_attr.attr, | 1049 | &sensor_dev_attr_in1_input.dev_attr.attr, |
898 | &sensor_dev_attr_in1_max.dev_attr.attr, | 1050 | &sensor_dev_attr_in1_max.dev_attr.attr, |
@@ -940,60 +1092,156 @@ static struct attribute *adt7475_attrs[] = { | |||
940 | &sensor_dev_attr_fan3_input.dev_attr.attr, | 1092 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
941 | &sensor_dev_attr_fan3_min.dev_attr.attr, | 1093 | &sensor_dev_attr_fan3_min.dev_attr.attr, |
942 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | 1094 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, |
943 | &sensor_dev_attr_fan4_input.dev_attr.attr, | ||
944 | &sensor_dev_attr_fan4_min.dev_attr.attr, | ||
945 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, | ||
946 | &sensor_dev_attr_pwm1.dev_attr.attr, | 1095 | &sensor_dev_attr_pwm1.dev_attr.attr, |
947 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, | 1096 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, |
948 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | 1097 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, |
949 | &sensor_dev_attr_pwm1_auto_channels_temp.dev_attr.attr, | 1098 | &sensor_dev_attr_pwm1_auto_channels_temp.dev_attr.attr, |
950 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, | 1099 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, |
951 | &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr, | 1100 | &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr, |
952 | &sensor_dev_attr_pwm2.dev_attr.attr, | ||
953 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, | ||
954 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | ||
955 | &sensor_dev_attr_pwm2_auto_channels_temp.dev_attr.attr, | ||
956 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, | ||
957 | &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr, | ||
958 | &sensor_dev_attr_pwm3.dev_attr.attr, | 1101 | &sensor_dev_attr_pwm3.dev_attr.attr, |
959 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, | 1102 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, |
960 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | 1103 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, |
961 | &sensor_dev_attr_pwm3_auto_channels_temp.dev_attr.attr, | 1104 | &sensor_dev_attr_pwm3_auto_channels_temp.dev_attr.attr, |
962 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, | 1105 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, |
963 | &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, | 1106 | &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, |
1107 | &dev_attr_pwm_use_point2_pwm_at_crit.attr, | ||
964 | NULL, | 1108 | NULL, |
965 | }; | 1109 | }; |
966 | 1110 | ||
967 | struct attribute_group adt7475_attr_group = { .attrs = adt7475_attrs }; | 1111 | static struct attribute *fan4_attrs[] = { |
1112 | &sensor_dev_attr_fan4_input.dev_attr.attr, | ||
1113 | &sensor_dev_attr_fan4_min.dev_attr.attr, | ||
1114 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, | ||
1115 | NULL | ||
1116 | }; | ||
1117 | |||
1118 | static struct attribute *pwm2_attrs[] = { | ||
1119 | &sensor_dev_attr_pwm2.dev_attr.attr, | ||
1120 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, | ||
1121 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | ||
1122 | &sensor_dev_attr_pwm2_auto_channels_temp.dev_attr.attr, | ||
1123 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, | ||
1124 | &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr, | ||
1125 | NULL | ||
1126 | }; | ||
1127 | |||
1128 | static struct attribute *in0_attrs[] = { | ||
1129 | &sensor_dev_attr_in0_input.dev_attr.attr, | ||
1130 | &sensor_dev_attr_in0_max.dev_attr.attr, | ||
1131 | &sensor_dev_attr_in0_min.dev_attr.attr, | ||
1132 | &sensor_dev_attr_in0_alarm.dev_attr.attr, | ||
1133 | NULL | ||
1134 | }; | ||
1135 | |||
1136 | static struct attribute *in3_attrs[] = { | ||
1137 | &sensor_dev_attr_in3_input.dev_attr.attr, | ||
1138 | &sensor_dev_attr_in3_max.dev_attr.attr, | ||
1139 | &sensor_dev_attr_in3_min.dev_attr.attr, | ||
1140 | &sensor_dev_attr_in3_alarm.dev_attr.attr, | ||
1141 | NULL | ||
1142 | }; | ||
1143 | |||
1144 | static struct attribute *in4_attrs[] = { | ||
1145 | &sensor_dev_attr_in4_input.dev_attr.attr, | ||
1146 | &sensor_dev_attr_in4_max.dev_attr.attr, | ||
1147 | &sensor_dev_attr_in4_min.dev_attr.attr, | ||
1148 | &sensor_dev_attr_in4_alarm.dev_attr.attr, | ||
1149 | NULL | ||
1150 | }; | ||
1151 | |||
1152 | static struct attribute *in5_attrs[] = { | ||
1153 | &sensor_dev_attr_in5_input.dev_attr.attr, | ||
1154 | &sensor_dev_attr_in5_max.dev_attr.attr, | ||
1155 | &sensor_dev_attr_in5_min.dev_attr.attr, | ||
1156 | &sensor_dev_attr_in5_alarm.dev_attr.attr, | ||
1157 | NULL | ||
1158 | }; | ||
1159 | |||
1160 | static struct attribute *vid_attrs[] = { | ||
1161 | &dev_attr_cpu0_vid.attr, | ||
1162 | &dev_attr_vrm.attr, | ||
1163 | NULL | ||
1164 | }; | ||
1165 | |||
1166 | static struct attribute_group adt7475_attr_group = { .attrs = adt7475_attrs }; | ||
1167 | static struct attribute_group fan4_attr_group = { .attrs = fan4_attrs }; | ||
1168 | static struct attribute_group pwm2_attr_group = { .attrs = pwm2_attrs }; | ||
1169 | static struct attribute_group in0_attr_group = { .attrs = in0_attrs }; | ||
1170 | static struct attribute_group in3_attr_group = { .attrs = in3_attrs }; | ||
1171 | static struct attribute_group in4_attr_group = { .attrs = in4_attrs }; | ||
1172 | static struct attribute_group in5_attr_group = { .attrs = in5_attrs }; | ||
1173 | static struct attribute_group vid_attr_group = { .attrs = vid_attrs }; | ||
968 | 1174 | ||
969 | static int adt7475_detect(struct i2c_client *client, int kind, | 1175 | static int adt7475_detect(struct i2c_client *client, int kind, |
970 | struct i2c_board_info *info) | 1176 | struct i2c_board_info *info) |
971 | { | 1177 | { |
972 | struct i2c_adapter *adapter = client->adapter; | 1178 | struct i2c_adapter *adapter = client->adapter; |
1179 | int vendid, devid, devid2; | ||
1180 | const char *name; | ||
973 | 1181 | ||
974 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 1182 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
975 | return -ENODEV; | 1183 | return -ENODEV; |
976 | 1184 | ||
977 | if (kind <= 0) { | 1185 | vendid = adt7475_read(REG_VENDID); |
978 | if (adt7475_read(REG_VENDID) != 0x41 || | 1186 | devid2 = adt7475_read(REG_DEVID2); |
979 | adt7475_read(REG_DEVID) != 0x75) { | 1187 | if (vendid != 0x41 || /* Analog Devices */ |
980 | dev_err(&adapter->dev, | 1188 | (devid2 & 0xf8) != 0x68) |
981 | "Couldn't detect a adt7475 part at 0x%02x\n", | 1189 | return -ENODEV; |
982 | (unsigned int)client->addr); | 1190 | |
983 | return -ENODEV; | 1191 | devid = adt7475_read(REG_DEVID); |
984 | } | 1192 | if (devid == 0x73) |
1193 | name = "adt7473"; | ||
1194 | else if (devid == 0x75 && client->addr == 0x2e) | ||
1195 | name = "adt7475"; | ||
1196 | else if (devid == 0x76) | ||
1197 | name = "adt7476"; | ||
1198 | else if ((devid2 & 0xfc) == 0x6c) | ||
1199 | name = "adt7490"; | ||
1200 | else { | ||
1201 | dev_dbg(&adapter->dev, | ||
1202 | "Couldn't detect an ADT7473/75/76/90 part at " | ||
1203 | "0x%02x\n", (unsigned int)client->addr); | ||
1204 | return -ENODEV; | ||
985 | } | 1205 | } |
986 | 1206 | ||
987 | strlcpy(info->type, adt7475_id[0].name, I2C_NAME_SIZE); | 1207 | strlcpy(info->type, name, I2C_NAME_SIZE); |
988 | 1208 | ||
989 | return 0; | 1209 | return 0; |
990 | } | 1210 | } |
991 | 1211 | ||
1212 | static void adt7475_remove_files(struct i2c_client *client, | ||
1213 | struct adt7475_data *data) | ||
1214 | { | ||
1215 | sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group); | ||
1216 | if (data->has_fan4) | ||
1217 | sysfs_remove_group(&client->dev.kobj, &fan4_attr_group); | ||
1218 | if (data->has_pwm2) | ||
1219 | sysfs_remove_group(&client->dev.kobj, &pwm2_attr_group); | ||
1220 | if (data->has_voltage & (1 << 0)) | ||
1221 | sysfs_remove_group(&client->dev.kobj, &in0_attr_group); | ||
1222 | if (data->has_voltage & (1 << 3)) | ||
1223 | sysfs_remove_group(&client->dev.kobj, &in3_attr_group); | ||
1224 | if (data->has_voltage & (1 << 4)) | ||
1225 | sysfs_remove_group(&client->dev.kobj, &in4_attr_group); | ||
1226 | if (data->has_voltage & (1 << 5)) | ||
1227 | sysfs_remove_group(&client->dev.kobj, &in5_attr_group); | ||
1228 | if (data->has_vid) | ||
1229 | sysfs_remove_group(&client->dev.kobj, &vid_attr_group); | ||
1230 | } | ||
1231 | |||
992 | static int adt7475_probe(struct i2c_client *client, | 1232 | static int adt7475_probe(struct i2c_client *client, |
993 | const struct i2c_device_id *id) | 1233 | const struct i2c_device_id *id) |
994 | { | 1234 | { |
1235 | static const char *names[] = { | ||
1236 | [adt7473] = "ADT7473", | ||
1237 | [adt7475] = "ADT7475", | ||
1238 | [adt7476] = "ADT7476", | ||
1239 | [adt7490] = "ADT7490", | ||
1240 | }; | ||
1241 | |||
995 | struct adt7475_data *data; | 1242 | struct adt7475_data *data; |
996 | int i, ret = 0; | 1243 | int i, ret = 0, revision; |
1244 | u8 config2, config3; | ||
997 | 1245 | ||
998 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 1246 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
999 | if (data == NULL) | 1247 | if (data == NULL) |
@@ -1002,6 +1250,70 @@ static int adt7475_probe(struct i2c_client *client, | |||
1002 | mutex_init(&data->lock); | 1250 | mutex_init(&data->lock); |
1003 | i2c_set_clientdata(client, data); | 1251 | i2c_set_clientdata(client, data); |
1004 | 1252 | ||
1253 | /* Initialize device-specific values */ | ||
1254 | switch (id->driver_data) { | ||
1255 | case adt7476: | ||
1256 | data->has_voltage = 0x0e; /* in1 to in3 */ | ||
1257 | revision = adt7475_read(REG_DEVID2) & 0x07; | ||
1258 | break; | ||
1259 | case adt7490: | ||
1260 | data->has_voltage = 0x3e; /* in1 to in5 */ | ||
1261 | revision = adt7475_read(REG_DEVID2) & 0x03; | ||
1262 | if (revision == 0x03) | ||
1263 | revision += adt7475_read(REG_DEVREV2); | ||
1264 | break; | ||
1265 | default: | ||
1266 | data->has_voltage = 0x06; /* in1, in2 */ | ||
1267 | revision = adt7475_read(REG_DEVID2) & 0x07; | ||
1268 | } | ||
1269 | |||
1270 | config3 = adt7475_read(REG_CONFIG3); | ||
1271 | /* Pin PWM2 may alternatively be used for ALERT output */ | ||
1272 | if (!(config3 & CONFIG3_SMBALERT)) | ||
1273 | data->has_pwm2 = 1; | ||
1274 | /* Meaning of this bit is inverted for the ADT7473-1 */ | ||
1275 | if (id->driver_data == adt7473 && revision >= 1) | ||
1276 | data->has_pwm2 = !data->has_pwm2; | ||
1277 | |||
1278 | data->config4 = adt7475_read(REG_CONFIG4); | ||
1279 | /* Pin TACH4 may alternatively be used for THERM */ | ||
1280 | if ((data->config4 & CONFIG4_PINFUNC) == 0x0) | ||
1281 | data->has_fan4 = 1; | ||
1282 | |||
1283 | /* THERM configuration is more complex on the ADT7476 and ADT7490, | ||
1284 | because 2 different pins (TACH4 and +2.5 Vin) can be used for | ||
1285 | this function */ | ||
1286 | if (id->driver_data == adt7490) { | ||
1287 | if ((data->config4 & CONFIG4_PINFUNC) == 0x1 && | ||
1288 | !(config3 & CONFIG3_THERM)) | ||
1289 | data->has_fan4 = 1; | ||
1290 | } | ||
1291 | if (id->driver_data == adt7476 || id->driver_data == adt7490) { | ||
1292 | if (!(config3 & CONFIG3_THERM) || | ||
1293 | (data->config4 & CONFIG4_PINFUNC) == 0x1) | ||
1294 | data->has_voltage |= (1 << 0); /* in0 */ | ||
1295 | } | ||
1296 | |||
1297 | /* On the ADT7476, the +12V input pin may instead be used as VID5, | ||
1298 | and VID pins may alternatively be used as GPIO */ | ||
1299 | if (id->driver_data == adt7476) { | ||
1300 | u8 vid = adt7475_read(REG_VID); | ||
1301 | if (!(vid & VID_VIDSEL)) | ||
1302 | data->has_voltage |= (1 << 4); /* in4 */ | ||
1303 | |||
1304 | data->has_vid = !(adt7475_read(REG_CONFIG5) & CONFIG5_VIDGPIO); | ||
1305 | } | ||
1306 | |||
1307 | /* Voltage attenuators can be bypassed, globally or individually */ | ||
1308 | config2 = adt7475_read(REG_CONFIG2); | ||
1309 | if (config2 & CONFIG2_ATTN) { | ||
1310 | data->bypass_attn = (0x3 << 3) | 0x3; | ||
1311 | } else { | ||
1312 | data->bypass_attn = ((data->config4 & CONFIG4_ATTN_IN10) >> 4) | | ||
1313 | ((data->config4 & CONFIG4_ATTN_IN43) >> 3); | ||
1314 | } | ||
1315 | data->bypass_attn &= data->has_voltage; | ||
1316 | |||
1005 | /* Call adt7475_read_pwm for all pwm's as this will reprogram any | 1317 | /* Call adt7475_read_pwm for all pwm's as this will reprogram any |
1006 | pwm's which are disabled to manual mode with 0% duty cycle */ | 1318 | pwm's which are disabled to manual mode with 0% duty cycle */ |
1007 | for (i = 0; i < ADT7475_PWM_COUNT; i++) | 1319 | for (i = 0; i < ADT7475_PWM_COUNT; i++) |
@@ -1011,16 +1323,70 @@ static int adt7475_probe(struct i2c_client *client, | |||
1011 | if (ret) | 1323 | if (ret) |
1012 | goto efree; | 1324 | goto efree; |
1013 | 1325 | ||
1326 | /* Features that can be disabled individually */ | ||
1327 | if (data->has_fan4) { | ||
1328 | ret = sysfs_create_group(&client->dev.kobj, &fan4_attr_group); | ||
1329 | if (ret) | ||
1330 | goto eremove; | ||
1331 | } | ||
1332 | if (data->has_pwm2) { | ||
1333 | ret = sysfs_create_group(&client->dev.kobj, &pwm2_attr_group); | ||
1334 | if (ret) | ||
1335 | goto eremove; | ||
1336 | } | ||
1337 | if (data->has_voltage & (1 << 0)) { | ||
1338 | ret = sysfs_create_group(&client->dev.kobj, &in0_attr_group); | ||
1339 | if (ret) | ||
1340 | goto eremove; | ||
1341 | } | ||
1342 | if (data->has_voltage & (1 << 3)) { | ||
1343 | ret = sysfs_create_group(&client->dev.kobj, &in3_attr_group); | ||
1344 | if (ret) | ||
1345 | goto eremove; | ||
1346 | } | ||
1347 | if (data->has_voltage & (1 << 4)) { | ||
1348 | ret = sysfs_create_group(&client->dev.kobj, &in4_attr_group); | ||
1349 | if (ret) | ||
1350 | goto eremove; | ||
1351 | } | ||
1352 | if (data->has_voltage & (1 << 5)) { | ||
1353 | ret = sysfs_create_group(&client->dev.kobj, &in5_attr_group); | ||
1354 | if (ret) | ||
1355 | goto eremove; | ||
1356 | } | ||
1357 | if (data->has_vid) { | ||
1358 | data->vrm = vid_which_vrm(); | ||
1359 | ret = sysfs_create_group(&client->dev.kobj, &vid_attr_group); | ||
1360 | if (ret) | ||
1361 | goto eremove; | ||
1362 | } | ||
1363 | |||
1014 | data->hwmon_dev = hwmon_device_register(&client->dev); | 1364 | data->hwmon_dev = hwmon_device_register(&client->dev); |
1015 | if (IS_ERR(data->hwmon_dev)) { | 1365 | if (IS_ERR(data->hwmon_dev)) { |
1016 | ret = PTR_ERR(data->hwmon_dev); | 1366 | ret = PTR_ERR(data->hwmon_dev); |
1017 | goto eremove; | 1367 | goto eremove; |
1018 | } | 1368 | } |
1019 | 1369 | ||
1370 | dev_info(&client->dev, "%s device, revision %d\n", | ||
1371 | names[id->driver_data], revision); | ||
1372 | if ((data->has_voltage & 0x11) || data->has_fan4 || data->has_pwm2) | ||
1373 | dev_info(&client->dev, "Optional features:%s%s%s%s%s\n", | ||
1374 | (data->has_voltage & (1 << 0)) ? " in0" : "", | ||
1375 | (data->has_voltage & (1 << 4)) ? " in4" : "", | ||
1376 | data->has_fan4 ? " fan4" : "", | ||
1377 | data->has_pwm2 ? " pwm2" : "", | ||
1378 | data->has_vid ? " vid" : ""); | ||
1379 | if (data->bypass_attn) | ||
1380 | dev_info(&client->dev, "Bypassing attenuators on:%s%s%s%s\n", | ||
1381 | (data->bypass_attn & (1 << 0)) ? " in0" : "", | ||
1382 | (data->bypass_attn & (1 << 1)) ? " in1" : "", | ||
1383 | (data->bypass_attn & (1 << 3)) ? " in3" : "", | ||
1384 | (data->bypass_attn & (1 << 4)) ? " in4" : ""); | ||
1385 | |||
1020 | return 0; | 1386 | return 0; |
1021 | 1387 | ||
1022 | eremove: | 1388 | eremove: |
1023 | sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group); | 1389 | adt7475_remove_files(client, data); |
1024 | efree: | 1390 | efree: |
1025 | kfree(data); | 1391 | kfree(data); |
1026 | return ret; | 1392 | return ret; |
@@ -1031,7 +1397,7 @@ static int adt7475_remove(struct i2c_client *client) | |||
1031 | struct adt7475_data *data = i2c_get_clientdata(client); | 1397 | struct adt7475_data *data = i2c_get_clientdata(client); |
1032 | 1398 | ||
1033 | hwmon_device_unregister(data->hwmon_dev); | 1399 | hwmon_device_unregister(data->hwmon_dev); |
1034 | sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group); | 1400 | adt7475_remove_files(client, data); |
1035 | kfree(data); | 1401 | kfree(data); |
1036 | 1402 | ||
1037 | return 0; | 1403 | return 0; |
@@ -1116,7 +1482,7 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) | |||
1116 | { | 1482 | { |
1117 | struct i2c_client *client = to_i2c_client(dev); | 1483 | struct i2c_client *client = to_i2c_client(dev); |
1118 | struct adt7475_data *data = i2c_get_clientdata(client); | 1484 | struct adt7475_data *data = i2c_get_clientdata(client); |
1119 | u8 ext; | 1485 | u16 ext; |
1120 | int i; | 1486 | int i; |
1121 | 1487 | ||
1122 | mutex_lock(&data->lock); | 1488 | mutex_lock(&data->lock); |
@@ -1127,25 +1493,44 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) | |||
1127 | data->alarms = adt7475_read(REG_STATUS2) << 8; | 1493 | data->alarms = adt7475_read(REG_STATUS2) << 8; |
1128 | data->alarms |= adt7475_read(REG_STATUS1); | 1494 | data->alarms |= adt7475_read(REG_STATUS1); |
1129 | 1495 | ||
1130 | ext = adt7475_read(REG_EXTEND1); | 1496 | ext = (adt7475_read(REG_EXTEND2) << 8) | |
1131 | for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) | 1497 | adt7475_read(REG_EXTEND1); |
1498 | for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) { | ||
1499 | if (!(data->has_voltage & (1 << i))) | ||
1500 | continue; | ||
1132 | data->voltage[INPUT][i] = | 1501 | data->voltage[INPUT][i] = |
1133 | (adt7475_read(VOLTAGE_REG(i)) << 2) | | 1502 | (adt7475_read(VOLTAGE_REG(i)) << 2) | |
1134 | ((ext >> ((i + 1) * 2)) & 3); | 1503 | ((ext >> (i * 2)) & 3); |
1504 | } | ||
1135 | 1505 | ||
1136 | ext = adt7475_read(REG_EXTEND2); | ||
1137 | for (i = 0; i < ADT7475_TEMP_COUNT; i++) | 1506 | for (i = 0; i < ADT7475_TEMP_COUNT; i++) |
1138 | data->temp[INPUT][i] = | 1507 | data->temp[INPUT][i] = |
1139 | (adt7475_read(TEMP_REG(i)) << 2) | | 1508 | (adt7475_read(TEMP_REG(i)) << 2) | |
1140 | ((ext >> ((i + 1) * 2)) & 3); | 1509 | ((ext >> ((i + 5) * 2)) & 3); |
1141 | 1510 | ||
1142 | for (i = 0; i < ADT7475_TACH_COUNT; i++) | 1511 | if (data->has_voltage & (1 << 5)) { |
1512 | data->alarms |= adt7475_read(REG_STATUS4) << 24; | ||
1513 | ext = adt7475_read(REG_EXTEND3); | ||
1514 | data->voltage[INPUT][5] = adt7475_read(REG_VTT) << 2 | | ||
1515 | ((ext >> 4) & 3); | ||
1516 | } | ||
1517 | |||
1518 | for (i = 0; i < ADT7475_TACH_COUNT; i++) { | ||
1519 | if (i == 3 && !data->has_fan4) | ||
1520 | continue; | ||
1143 | data->tach[INPUT][i] = | 1521 | data->tach[INPUT][i] = |
1144 | adt7475_read_word(client, TACH_REG(i)); | 1522 | adt7475_read_word(client, TACH_REG(i)); |
1523 | } | ||
1145 | 1524 | ||
1146 | /* Updated by hw when in auto mode */ | 1525 | /* Updated by hw when in auto mode */ |
1147 | for (i = 0; i < ADT7475_PWM_COUNT; i++) | 1526 | for (i = 0; i < ADT7475_PWM_COUNT; i++) { |
1527 | if (i == 1 && !data->has_pwm2) | ||
1528 | continue; | ||
1148 | data->pwm[INPUT][i] = adt7475_read(PWM_REG(i)); | 1529 | data->pwm[INPUT][i] = adt7475_read(PWM_REG(i)); |
1530 | } | ||
1531 | |||
1532 | if (data->has_vid) | ||
1533 | data->vid = adt7475_read(REG_VID) & 0x3f; | ||
1149 | 1534 | ||
1150 | data->measure_updated = jiffies; | 1535 | data->measure_updated = jiffies; |
1151 | } | 1536 | } |
@@ -1153,9 +1538,12 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) | |||
1153 | /* Limits and settings, should never change update every 60 seconds */ | 1538 | /* Limits and settings, should never change update every 60 seconds */ |
1154 | if (time_after(jiffies, data->limits_updated + HZ * 60) || | 1539 | if (time_after(jiffies, data->limits_updated + HZ * 60) || |
1155 | !data->valid) { | 1540 | !data->valid) { |
1541 | data->config4 = adt7475_read(REG_CONFIG4); | ||
1156 | data->config5 = adt7475_read(REG_CONFIG5); | 1542 | data->config5 = adt7475_read(REG_CONFIG5); |
1157 | 1543 | ||
1158 | for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) { | 1544 | for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) { |
1545 | if (!(data->has_voltage & (1 << i))) | ||
1546 | continue; | ||
1159 | /* Adjust values so they match the input precision */ | 1547 | /* Adjust values so they match the input precision */ |
1160 | data->voltage[MIN][i] = | 1548 | data->voltage[MIN][i] = |
1161 | adt7475_read(VOLTAGE_MIN_REG(i)) << 2; | 1549 | adt7475_read(VOLTAGE_MIN_REG(i)) << 2; |
@@ -1163,6 +1551,11 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) | |||
1163 | adt7475_read(VOLTAGE_MAX_REG(i)) << 2; | 1551 | adt7475_read(VOLTAGE_MAX_REG(i)) << 2; |
1164 | } | 1552 | } |
1165 | 1553 | ||
1554 | if (data->has_voltage & (1 << 5)) { | ||
1555 | data->voltage[MIN][5] = adt7475_read(REG_VTT_MIN) << 2; | ||
1556 | data->voltage[MAX][5] = adt7475_read(REG_VTT_MAX) << 2; | ||
1557 | } | ||
1558 | |||
1166 | for (i = 0; i < ADT7475_TEMP_COUNT; i++) { | 1559 | for (i = 0; i < ADT7475_TEMP_COUNT; i++) { |
1167 | /* Adjust values so they match the input precision */ | 1560 | /* Adjust values so they match the input precision */ |
1168 | data->temp[MIN][i] = | 1561 | data->temp[MIN][i] = |
@@ -1178,11 +1571,16 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) | |||
1178 | } | 1571 | } |
1179 | adt7475_read_hystersis(client); | 1572 | adt7475_read_hystersis(client); |
1180 | 1573 | ||
1181 | for (i = 0; i < ADT7475_TACH_COUNT; i++) | 1574 | for (i = 0; i < ADT7475_TACH_COUNT; i++) { |
1575 | if (i == 3 && !data->has_fan4) | ||
1576 | continue; | ||
1182 | data->tach[MIN][i] = | 1577 | data->tach[MIN][i] = |
1183 | adt7475_read_word(client, TACH_MIN_REG(i)); | 1578 | adt7475_read_word(client, TACH_MIN_REG(i)); |
1579 | } | ||
1184 | 1580 | ||
1185 | for (i = 0; i < ADT7475_PWM_COUNT; i++) { | 1581 | for (i = 0; i < ADT7475_PWM_COUNT; i++) { |
1582 | if (i == 1 && !data->has_pwm2) | ||
1583 | continue; | ||
1186 | data->pwm[MAX][i] = adt7475_read(PWM_MAX_REG(i)); | 1584 | data->pwm[MAX][i] = adt7475_read(PWM_MAX_REG(i)); |
1187 | data->pwm[MIN][i] = adt7475_read(PWM_MIN_REG(i)); | 1585 | data->pwm[MIN][i] = adt7475_read(PWM_MIN_REG(i)); |
1188 | /* Set the channel and control information */ | 1586 | /* Set the channel and control information */ |
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 8acf82977e7b..480f80ea1fa0 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -701,6 +701,7 @@ static int asb100_detect(struct i2c_client *client, int kind, | |||
701 | struct i2c_board_info *info) | 701 | struct i2c_board_info *info) |
702 | { | 702 | { |
703 | struct i2c_adapter *adapter = client->adapter; | 703 | struct i2c_adapter *adapter = client->adapter; |
704 | int val1, val2; | ||
704 | 705 | ||
705 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 706 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
706 | pr_debug("asb100.o: detect failed, " | 707 | pr_debug("asb100.o: detect failed, " |
@@ -708,50 +709,30 @@ static int asb100_detect(struct i2c_client *client, int kind, | |||
708 | return -ENODEV; | 709 | return -ENODEV; |
709 | } | 710 | } |
710 | 711 | ||
711 | /* The chip may be stuck in some other bank than bank 0. This may | 712 | val1 = i2c_smbus_read_byte_data(client, ASB100_REG_BANK); |
712 | make reading other information impossible. Specify a force=... or | 713 | val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN); |
713 | force_*=... parameter, and the chip will be reset to the right | ||
714 | bank. */ | ||
715 | if (kind < 0) { | ||
716 | |||
717 | int val1 = i2c_smbus_read_byte_data(client, ASB100_REG_BANK); | ||
718 | int val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN); | ||
719 | |||
720 | /* If we're in bank 0 */ | ||
721 | if ((!(val1 & 0x07)) && | ||
722 | /* Check for ASB100 ID (low byte) */ | ||
723 | (((!(val1 & 0x80)) && (val2 != 0x94)) || | ||
724 | /* Check for ASB100 ID (high byte ) */ | ||
725 | ((val1 & 0x80) && (val2 != 0x06)))) { | ||
726 | pr_debug("asb100.o: detect failed, " | ||
727 | "bad chip id 0x%02x!\n", val2); | ||
728 | return -ENODEV; | ||
729 | } | ||
730 | 714 | ||
731 | } /* kind < 0 */ | 715 | /* If we're in bank 0 */ |
716 | if ((!(val1 & 0x07)) && | ||
717 | /* Check for ASB100 ID (low byte) */ | ||
718 | (((!(val1 & 0x80)) && (val2 != 0x94)) || | ||
719 | /* Check for ASB100 ID (high byte ) */ | ||
720 | ((val1 & 0x80) && (val2 != 0x06)))) { | ||
721 | pr_debug("asb100: detect failed, bad chip id 0x%02x!\n", val2); | ||
722 | return -ENODEV; | ||
723 | } | ||
732 | 724 | ||
733 | /* We have either had a force parameter, or we have already detected | 725 | /* Put it now into bank 0 and Vendor ID High Byte */ |
734 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ | ||
735 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, | 726 | i2c_smbus_write_byte_data(client, ASB100_REG_BANK, |
736 | (i2c_smbus_read_byte_data(client, ASB100_REG_BANK) & 0x78) | 727 | (i2c_smbus_read_byte_data(client, ASB100_REG_BANK) & 0x78) |
737 | | 0x80); | 728 | | 0x80); |
738 | 729 | ||
739 | /* Determine the chip type. */ | 730 | /* Determine the chip type. */ |
740 | if (kind <= 0) { | 731 | val1 = i2c_smbus_read_byte_data(client, ASB100_REG_WCHIPID); |
741 | int val1 = i2c_smbus_read_byte_data(client, ASB100_REG_WCHIPID); | 732 | val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN); |
742 | int val2 = i2c_smbus_read_byte_data(client, ASB100_REG_CHIPMAN); | 733 | |
743 | 734 | if (val1 != 0x31 || val2 != 0x06) | |
744 | if ((val1 == 0x31) && (val2 == 0x06)) | 735 | return -ENODEV; |
745 | kind = asb100; | ||
746 | else { | ||
747 | if (kind == 0) | ||
748 | dev_warn(&adapter->dev, "ignoring " | ||
749 | "'force' parameter for unknown chip " | ||
750 | "at adapter %d, address 0x%02x.\n", | ||
751 | i2c_adapter_id(adapter), client->addr); | ||
752 | return -ENODEV; | ||
753 | } | ||
754 | } | ||
755 | 736 | ||
756 | strlcpy(info->type, "asb100", I2C_NAME_SIZE); | 737 | strlcpy(info->type, "asb100", I2C_NAME_SIZE); |
757 | 738 | ||
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c index 27d62574284f..4377bb0cc526 100644 --- a/drivers/hwmon/dme1737.c +++ b/drivers/hwmon/dme1737.c | |||
@@ -2220,33 +2220,23 @@ static int dme1737_i2c_detect(struct i2c_client *client, int kind, | |||
2220 | return -ENODEV; | 2220 | return -ENODEV; |
2221 | } | 2221 | } |
2222 | 2222 | ||
2223 | /* A negative kind means that the driver was loaded with no force | 2223 | company = i2c_smbus_read_byte_data(client, DME1737_REG_COMPANY); |
2224 | * parameter (default), so we must identify the chip. */ | 2224 | verstep = i2c_smbus_read_byte_data(client, DME1737_REG_VERSTEP); |
2225 | if (kind < 0) { | ||
2226 | company = i2c_smbus_read_byte_data(client, DME1737_REG_COMPANY); | ||
2227 | verstep = i2c_smbus_read_byte_data(client, DME1737_REG_VERSTEP); | ||
2228 | |||
2229 | if (company == DME1737_COMPANY_SMSC && | ||
2230 | (verstep & DME1737_VERSTEP_MASK) == DME1737_VERSTEP) { | ||
2231 | kind = dme1737; | ||
2232 | } else if (company == DME1737_COMPANY_SMSC && | ||
2233 | verstep == SCH5027_VERSTEP) { | ||
2234 | kind = sch5027; | ||
2235 | } else { | ||
2236 | return -ENODEV; | ||
2237 | } | ||
2238 | } | ||
2239 | 2225 | ||
2240 | if (kind == sch5027) { | 2226 | if (company == DME1737_COMPANY_SMSC && |
2227 | verstep == SCH5027_VERSTEP) { | ||
2241 | name = "sch5027"; | 2228 | name = "sch5027"; |
2242 | } else { | 2229 | |
2243 | kind = dme1737; | 2230 | } else if (company == DME1737_COMPANY_SMSC && |
2231 | (verstep & DME1737_VERSTEP_MASK) == DME1737_VERSTEP) { | ||
2244 | name = "dme1737"; | 2232 | name = "dme1737"; |
2233 | } else { | ||
2234 | return -ENODEV; | ||
2245 | } | 2235 | } |
2246 | 2236 | ||
2247 | dev_info(dev, "Found a %s chip at 0x%02x (rev 0x%02x).\n", | 2237 | dev_info(dev, "Found a %s chip at 0x%02x (rev 0x%02x).\n", |
2248 | kind == sch5027 ? "SCH5027" : "DME1737", client->addr, | 2238 | verstep == SCH5027_VERSTEP ? "SCH5027" : "DME1737", |
2249 | verstep); | 2239 | client->addr, verstep); |
2250 | strlcpy(info->type, name, I2C_NAME_SIZE); | 2240 | strlcpy(info->type, name, I2C_NAME_SIZE); |
2251 | 2241 | ||
2252 | return 0; | 2242 | return 0; |
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 53f88f511816..2a4c6a05b14f 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
@@ -237,20 +237,16 @@ static int ds1621_detect(struct i2c_client *client, int kind, | |||
237 | return -ENODEV; | 237 | return -ENODEV; |
238 | 238 | ||
239 | /* Now, we do the remaining detection. It is lousy. */ | 239 | /* Now, we do the remaining detection. It is lousy. */ |
240 | if (kind < 0) { | 240 | /* The NVB bit should be low if no EEPROM write has been requested |
241 | /* The NVB bit should be low if no EEPROM write has been | 241 | during the latest 10ms, which is highly improbable in our case. */ |
242 | requested during the latest 10ms, which is highly | 242 | conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); |
243 | improbable in our case. */ | 243 | if (conf < 0 || conf & DS1621_REG_CONFIG_NVB) |
244 | conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); | 244 | return -ENODEV; |
245 | if (conf < 0 || conf & DS1621_REG_CONFIG_NVB) | 245 | /* The 7 lowest bits of a temperature should always be 0. */ |
246 | for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) { | ||
247 | temp = i2c_smbus_read_word_data(client, DS1621_REG_TEMP[i]); | ||
248 | if (temp < 0 || (temp & 0x7f00)) | ||
246 | return -ENODEV; | 249 | return -ENODEV; |
247 | /* The 7 lowest bits of a temperature should always be 0. */ | ||
248 | for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) { | ||
249 | temp = i2c_smbus_read_word_data(client, | ||
250 | DS1621_REG_TEMP[i]); | ||
251 | if (temp < 0 || (temp & 0x7f00)) | ||
252 | return -ENODEV; | ||
253 | } | ||
254 | } | 250 | } |
255 | 251 | ||
256 | strlcpy(info->type, "ds1621", I2C_NAME_SIZE); | 252 | strlcpy(info->type, "ds1621", I2C_NAME_SIZE); |
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index 4146105f1a57..a95fa4256caa 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #define SIO_F71858_ID 0x0507 /* Chipset ID */ | 48 | #define SIO_F71858_ID 0x0507 /* Chipset ID */ |
49 | #define SIO_F71862_ID 0x0601 /* Chipset ID */ | 49 | #define SIO_F71862_ID 0x0601 /* Chipset ID */ |
50 | #define SIO_F71882_ID 0x0541 /* Chipset ID */ | 50 | #define SIO_F71882_ID 0x0541 /* Chipset ID */ |
51 | #define SIO_F71889_ID 0x0723 /* Chipset ID */ | ||
51 | #define SIO_F8000_ID 0x0581 /* Chipset ID */ | 52 | #define SIO_F8000_ID 0x0581 /* Chipset ID */ |
52 | 53 | ||
53 | #define REGION_LENGTH 8 | 54 | #define REGION_LENGTH 8 |
@@ -95,12 +96,13 @@ static unsigned short force_id; | |||
95 | module_param(force_id, ushort, 0); | 96 | module_param(force_id, ushort, 0); |
96 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); | 97 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); |
97 | 98 | ||
98 | enum chips { f71858fg, f71862fg, f71882fg, f8000 }; | 99 | enum chips { f71858fg, f71862fg, f71882fg, f71889fg, f8000 }; |
99 | 100 | ||
100 | static const char *f71882fg_names[] = { | 101 | static const char *f71882fg_names[] = { |
101 | "f71858fg", | 102 | "f71858fg", |
102 | "f71862fg", | 103 | "f71862fg", |
103 | "f71882fg", | 104 | "f71882fg", |
105 | "f71889fg", | ||
104 | "f8000", | 106 | "f8000", |
105 | }; | 107 | }; |
106 | 108 | ||
@@ -155,7 +157,7 @@ struct f71882fg_data { | |||
155 | u8 pwm_auto_point_hyst[2]; | 157 | u8 pwm_auto_point_hyst[2]; |
156 | u8 pwm_auto_point_mapping[4]; | 158 | u8 pwm_auto_point_mapping[4]; |
157 | u8 pwm_auto_point_pwm[4][5]; | 159 | u8 pwm_auto_point_pwm[4][5]; |
158 | u8 pwm_auto_point_temp[4][4]; | 160 | s8 pwm_auto_point_temp[4][4]; |
159 | }; | 161 | }; |
160 | 162 | ||
161 | /* Sysfs in */ | 163 | /* Sysfs in */ |
@@ -258,7 +260,9 @@ static struct platform_driver f71882fg_driver = { | |||
258 | 260 | ||
259 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 261 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); |
260 | 262 | ||
261 | /* Temp and in attr for the f71858fg */ | 263 | /* Temp and in attr for the f71858fg, the f71858fg is special as it |
264 | has its temperature indexes start at 0 (the others start at 1) and | ||
265 | it only has 3 voltage inputs */ | ||
262 | static struct sensor_device_attribute_2 f71858fg_in_temp_attr[] = { | 266 | static struct sensor_device_attribute_2 f71858fg_in_temp_attr[] = { |
263 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), | 267 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), |
264 | SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1), | 268 | SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1), |
@@ -302,8 +306,8 @@ static struct sensor_device_attribute_2 f71858fg_in_temp_attr[] = { | |||
302 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), | 306 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), |
303 | }; | 307 | }; |
304 | 308 | ||
305 | /* Temp and in attr common to both the f71862fg and f71882fg */ | 309 | /* Temp and in attr common to the f71862fg, f71882fg and f71889fg */ |
306 | static struct sensor_device_attribute_2 f718x2fg_in_temp_attr[] = { | 310 | static struct sensor_device_attribute_2 fxxxx_in_temp_attr[] = { |
307 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), | 311 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), |
308 | SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1), | 312 | SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1), |
309 | SENSOR_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 0, 2), | 313 | SENSOR_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 0, 2), |
@@ -371,8 +375,8 @@ static struct sensor_device_attribute_2 f718x2fg_in_temp_attr[] = { | |||
371 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 3), | 375 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 3), |
372 | }; | 376 | }; |
373 | 377 | ||
374 | /* Temp and in attr found only on the f71882fg */ | 378 | /* For models with in1 alarm capability */ |
375 | static struct sensor_device_attribute_2 f71882fg_in_temp_attr[] = { | 379 | static struct sensor_device_attribute_2 fxxxx_in1_alarm_attr[] = { |
376 | SENSOR_ATTR_2(in1_max, S_IRUGO|S_IWUSR, show_in_max, store_in_max, | 380 | SENSOR_ATTR_2(in1_max, S_IRUGO|S_IWUSR, show_in_max, store_in_max, |
377 | 0, 1), | 381 | 0, 1), |
378 | SENSOR_ATTR_2(in1_beep, S_IRUGO|S_IWUSR, show_in_beep, store_in_beep, | 382 | SENSOR_ATTR_2(in1_beep, S_IRUGO|S_IWUSR, show_in_beep, store_in_beep, |
@@ -383,6 +387,7 @@ static struct sensor_device_attribute_2 f71882fg_in_temp_attr[] = { | |||
383 | /* Temp and in attr for the f8000 | 387 | /* Temp and in attr for the f8000 |
384 | Note on the f8000 temp_ovt (crit) is used as max, and temp_high (max) | 388 | Note on the f8000 temp_ovt (crit) is used as max, and temp_high (max) |
385 | is used as hysteresis value to clear alarms | 389 | is used as hysteresis value to clear alarms |
390 | Also like the f71858fg its temperature indexes start at 0 | ||
386 | */ | 391 | */ |
387 | static struct sensor_device_attribute_2 f8000_in_temp_attr[] = { | 392 | static struct sensor_device_attribute_2 f8000_in_temp_attr[] = { |
388 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), | 393 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), |
@@ -413,61 +418,70 @@ static struct sensor_device_attribute_2 f8000_in_temp_attr[] = { | |||
413 | }; | 418 | }; |
414 | 419 | ||
415 | /* Fan / PWM attr common to all models */ | 420 | /* Fan / PWM attr common to all models */ |
416 | static struct sensor_device_attribute_2 fxxxx_fan_attr[] = { | 421 | static struct sensor_device_attribute_2 fxxxx_fan_attr[4][6] = { { |
417 | SENSOR_ATTR_2(fan1_input, S_IRUGO, show_fan, NULL, 0, 0), | 422 | SENSOR_ATTR_2(fan1_input, S_IRUGO, show_fan, NULL, 0, 0), |
418 | SENSOR_ATTR_2(fan1_full_speed, S_IRUGO|S_IWUSR, | 423 | SENSOR_ATTR_2(fan1_full_speed, S_IRUGO|S_IWUSR, |
419 | show_fan_full_speed, | 424 | show_fan_full_speed, |
420 | store_fan_full_speed, 0, 0), | 425 | store_fan_full_speed, 0, 0), |
421 | SENSOR_ATTR_2(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 0), | 426 | SENSOR_ATTR_2(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 0), |
422 | SENSOR_ATTR_2(fan2_input, S_IRUGO, show_fan, NULL, 0, 1), | ||
423 | SENSOR_ATTR_2(fan2_full_speed, S_IRUGO|S_IWUSR, | ||
424 | show_fan_full_speed, | ||
425 | store_fan_full_speed, 0, 1), | ||
426 | SENSOR_ATTR_2(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 1), | ||
427 | SENSOR_ATTR_2(fan3_input, S_IRUGO, show_fan, NULL, 0, 2), | ||
428 | SENSOR_ATTR_2(fan3_full_speed, S_IRUGO|S_IWUSR, | ||
429 | show_fan_full_speed, | ||
430 | store_fan_full_speed, 0, 2), | ||
431 | SENSOR_ATTR_2(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 2), | ||
432 | |||
433 | SENSOR_ATTR_2(pwm1, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 0), | 427 | SENSOR_ATTR_2(pwm1, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 0), |
434 | SENSOR_ATTR_2(pwm1_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | 428 | SENSOR_ATTR_2(pwm1_enable, S_IRUGO|S_IWUSR, show_pwm_enable, |
435 | store_pwm_enable, 0, 0), | 429 | store_pwm_enable, 0, 0), |
436 | SENSOR_ATTR_2(pwm1_interpolate, S_IRUGO|S_IWUSR, | 430 | SENSOR_ATTR_2(pwm1_interpolate, S_IRUGO|S_IWUSR, |
437 | show_pwm_interpolate, store_pwm_interpolate, 0, 0), | 431 | show_pwm_interpolate, store_pwm_interpolate, 0, 0), |
438 | SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR, | 432 | }, { |
439 | show_pwm_auto_point_channel, | 433 | SENSOR_ATTR_2(fan2_input, S_IRUGO, show_fan, NULL, 0, 1), |
440 | store_pwm_auto_point_channel, 0, 0), | 434 | SENSOR_ATTR_2(fan2_full_speed, S_IRUGO|S_IWUSR, |
441 | 435 | show_fan_full_speed, | |
436 | store_fan_full_speed, 0, 1), | ||
437 | SENSOR_ATTR_2(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 1), | ||
442 | SENSOR_ATTR_2(pwm2, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 1), | 438 | SENSOR_ATTR_2(pwm2, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 1), |
443 | SENSOR_ATTR_2(pwm2_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | 439 | SENSOR_ATTR_2(pwm2_enable, S_IRUGO|S_IWUSR, show_pwm_enable, |
444 | store_pwm_enable, 0, 1), | 440 | store_pwm_enable, 0, 1), |
445 | SENSOR_ATTR_2(pwm2_interpolate, S_IRUGO|S_IWUSR, | 441 | SENSOR_ATTR_2(pwm2_interpolate, S_IRUGO|S_IWUSR, |
446 | show_pwm_interpolate, store_pwm_interpolate, 0, 1), | 442 | show_pwm_interpolate, store_pwm_interpolate, 0, 1), |
447 | SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR, | 443 | }, { |
448 | show_pwm_auto_point_channel, | 444 | SENSOR_ATTR_2(fan3_input, S_IRUGO, show_fan, NULL, 0, 2), |
449 | store_pwm_auto_point_channel, 0, 1), | 445 | SENSOR_ATTR_2(fan3_full_speed, S_IRUGO|S_IWUSR, |
450 | 446 | show_fan_full_speed, | |
447 | store_fan_full_speed, 0, 2), | ||
448 | SENSOR_ATTR_2(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 2), | ||
451 | SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2), | 449 | SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2), |
452 | SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | 450 | SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable, |
453 | store_pwm_enable, 0, 2), | 451 | store_pwm_enable, 0, 2), |
454 | SENSOR_ATTR_2(pwm3_interpolate, S_IRUGO|S_IWUSR, | 452 | SENSOR_ATTR_2(pwm3_interpolate, S_IRUGO|S_IWUSR, |
455 | show_pwm_interpolate, store_pwm_interpolate, 0, 2), | 453 | show_pwm_interpolate, store_pwm_interpolate, 0, 2), |
456 | SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, | 454 | }, { |
457 | show_pwm_auto_point_channel, | 455 | SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), |
458 | store_pwm_auto_point_channel, 0, 2), | 456 | SENSOR_ATTR_2(fan4_full_speed, S_IRUGO|S_IWUSR, |
459 | }; | 457 | show_fan_full_speed, |
458 | store_fan_full_speed, 0, 3), | ||
459 | SENSOR_ATTR_2(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 3), | ||
460 | SENSOR_ATTR_2(pwm4, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 3), | ||
461 | SENSOR_ATTR_2(pwm4_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | ||
462 | store_pwm_enable, 0, 3), | ||
463 | SENSOR_ATTR_2(pwm4_interpolate, S_IRUGO|S_IWUSR, | ||
464 | show_pwm_interpolate, store_pwm_interpolate, 0, 3), | ||
465 | } }; | ||
460 | 466 | ||
461 | /* Fan / PWM attr for the f71862fg, less pwms and less zones per pwm than the | 467 | /* Attr for models which can beep on Fan alarm */ |
462 | f71882fg */ | 468 | static struct sensor_device_attribute_2 fxxxx_fan_beep_attr[] = { |
463 | static struct sensor_device_attribute_2 f71862fg_fan_attr[] = { | ||
464 | SENSOR_ATTR_2(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep, | 469 | SENSOR_ATTR_2(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep, |
465 | store_fan_beep, 0, 0), | 470 | store_fan_beep, 0, 0), |
466 | SENSOR_ATTR_2(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep, | 471 | SENSOR_ATTR_2(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep, |
467 | store_fan_beep, 0, 1), | 472 | store_fan_beep, 0, 1), |
468 | SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep, | 473 | SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep, |
469 | store_fan_beep, 0, 2), | 474 | store_fan_beep, 0, 2), |
475 | SENSOR_ATTR_2(fan4_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
476 | store_fan_beep, 0, 3), | ||
477 | }; | ||
470 | 478 | ||
479 | /* PWM attr for the f71862fg, fewer pwms and fewer zones per pwm than the | ||
480 | f71858fg / f71882fg / f71889fg */ | ||
481 | static struct sensor_device_attribute_2 f71862fg_auto_pwm_attr[] = { | ||
482 | SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR, | ||
483 | show_pwm_auto_point_channel, | ||
484 | store_pwm_auto_point_channel, 0, 0), | ||
471 | SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR, | 485 | SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR, |
472 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 486 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
473 | 1, 0), | 487 | 1, 0), |
@@ -487,6 +501,9 @@ static struct sensor_device_attribute_2 f71862fg_fan_attr[] = { | |||
487 | SENSOR_ATTR_2(pwm1_auto_point2_temp_hyst, S_IRUGO, | 501 | SENSOR_ATTR_2(pwm1_auto_point2_temp_hyst, S_IRUGO, |
488 | show_pwm_auto_point_temp_hyst, NULL, 3, 0), | 502 | show_pwm_auto_point_temp_hyst, NULL, 3, 0), |
489 | 503 | ||
504 | SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR, | ||
505 | show_pwm_auto_point_channel, | ||
506 | store_pwm_auto_point_channel, 0, 1), | ||
490 | SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR, | 507 | SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR, |
491 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 508 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
492 | 1, 1), | 509 | 1, 1), |
@@ -506,6 +523,9 @@ static struct sensor_device_attribute_2 f71862fg_fan_attr[] = { | |||
506 | SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO, | 523 | SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO, |
507 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), | 524 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), |
508 | 525 | ||
526 | SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, | ||
527 | show_pwm_auto_point_channel, | ||
528 | store_pwm_auto_point_channel, 0, 2), | ||
509 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, | 529 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, |
510 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 530 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
511 | 1, 2), | 531 | 1, 2), |
@@ -526,8 +546,11 @@ static struct sensor_device_attribute_2 f71862fg_fan_attr[] = { | |||
526 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), | 546 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), |
527 | }; | 547 | }; |
528 | 548 | ||
529 | /* Fan / PWM attr common to both the f71882fg and f71858fg */ | 549 | /* PWM attr common to the f71858fg, f71882fg and f71889fg */ |
530 | static struct sensor_device_attribute_2 f71882fg_f71858fg_fan_attr[] = { | 550 | static struct sensor_device_attribute_2 fxxxx_auto_pwm_attr[4][14] = { { |
551 | SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR, | ||
552 | show_pwm_auto_point_channel, | ||
553 | store_pwm_auto_point_channel, 0, 0), | ||
531 | SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR, | 554 | SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR, |
532 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 555 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
533 | 0, 0), | 556 | 0, 0), |
@@ -565,7 +588,10 @@ static struct sensor_device_attribute_2 f71882fg_f71858fg_fan_attr[] = { | |||
565 | show_pwm_auto_point_temp_hyst, NULL, 2, 0), | 588 | show_pwm_auto_point_temp_hyst, NULL, 2, 0), |
566 | SENSOR_ATTR_2(pwm1_auto_point4_temp_hyst, S_IRUGO, | 589 | SENSOR_ATTR_2(pwm1_auto_point4_temp_hyst, S_IRUGO, |
567 | show_pwm_auto_point_temp_hyst, NULL, 3, 0), | 590 | show_pwm_auto_point_temp_hyst, NULL, 3, 0), |
568 | 591 | }, { | |
592 | SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR, | ||
593 | show_pwm_auto_point_channel, | ||
594 | store_pwm_auto_point_channel, 0, 1), | ||
569 | SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR, | 595 | SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR, |
570 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 596 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
571 | 0, 1), | 597 | 0, 1), |
@@ -603,7 +629,10 @@ static struct sensor_device_attribute_2 f71882fg_f71858fg_fan_attr[] = { | |||
603 | show_pwm_auto_point_temp_hyst, NULL, 2, 1), | 629 | show_pwm_auto_point_temp_hyst, NULL, 2, 1), |
604 | SENSOR_ATTR_2(pwm2_auto_point4_temp_hyst, S_IRUGO, | 630 | SENSOR_ATTR_2(pwm2_auto_point4_temp_hyst, S_IRUGO, |
605 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), | 631 | show_pwm_auto_point_temp_hyst, NULL, 3, 1), |
606 | 632 | }, { | |
633 | SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, | ||
634 | show_pwm_auto_point_channel, | ||
635 | store_pwm_auto_point_channel, 0, 2), | ||
607 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, | 636 | SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR, |
608 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 637 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
609 | 0, 2), | 638 | 0, 2), |
@@ -641,30 +670,7 @@ static struct sensor_device_attribute_2 f71882fg_f71858fg_fan_attr[] = { | |||
641 | show_pwm_auto_point_temp_hyst, NULL, 2, 2), | 670 | show_pwm_auto_point_temp_hyst, NULL, 2, 2), |
642 | SENSOR_ATTR_2(pwm3_auto_point4_temp_hyst, S_IRUGO, | 671 | SENSOR_ATTR_2(pwm3_auto_point4_temp_hyst, S_IRUGO, |
643 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), | 672 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), |
644 | }; | 673 | }, { |
645 | |||
646 | /* Fan / PWM attr found on the f71882fg but not on the f71858fg */ | ||
647 | static struct sensor_device_attribute_2 f71882fg_fan_attr[] = { | ||
648 | SENSOR_ATTR_2(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
649 | store_fan_beep, 0, 0), | ||
650 | SENSOR_ATTR_2(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
651 | store_fan_beep, 0, 1), | ||
652 | SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
653 | store_fan_beep, 0, 2), | ||
654 | |||
655 | SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), | ||
656 | SENSOR_ATTR_2(fan4_full_speed, S_IRUGO|S_IWUSR, | ||
657 | show_fan_full_speed, | ||
658 | store_fan_full_speed, 0, 3), | ||
659 | SENSOR_ATTR_2(fan4_beep, S_IRUGO|S_IWUSR, show_fan_beep, | ||
660 | store_fan_beep, 0, 3), | ||
661 | SENSOR_ATTR_2(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 3), | ||
662 | |||
663 | SENSOR_ATTR_2(pwm4, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 3), | ||
664 | SENSOR_ATTR_2(pwm4_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | ||
665 | store_pwm_enable, 0, 3), | ||
666 | SENSOR_ATTR_2(pwm4_interpolate, S_IRUGO|S_IWUSR, | ||
667 | show_pwm_interpolate, store_pwm_interpolate, 0, 3), | ||
668 | SENSOR_ATTR_2(pwm4_auto_channels_temp, S_IRUGO|S_IWUSR, | 674 | SENSOR_ATTR_2(pwm4_auto_channels_temp, S_IRUGO|S_IWUSR, |
669 | show_pwm_auto_point_channel, | 675 | show_pwm_auto_point_channel, |
670 | store_pwm_auto_point_channel, 0, 3), | 676 | store_pwm_auto_point_channel, 0, 3), |
@@ -705,14 +711,20 @@ static struct sensor_device_attribute_2 f71882fg_fan_attr[] = { | |||
705 | show_pwm_auto_point_temp_hyst, NULL, 2, 3), | 711 | show_pwm_auto_point_temp_hyst, NULL, 2, 3), |
706 | SENSOR_ATTR_2(pwm4_auto_point4_temp_hyst, S_IRUGO, | 712 | SENSOR_ATTR_2(pwm4_auto_point4_temp_hyst, S_IRUGO, |
707 | show_pwm_auto_point_temp_hyst, NULL, 3, 3), | 713 | show_pwm_auto_point_temp_hyst, NULL, 3, 3), |
708 | }; | 714 | } }; |
709 | 715 | ||
710 | /* Fan / PWM attr for the f8000, zones mapped to temp instead of to pwm! | 716 | /* Fan attr specific to the f8000 (4th fan input can only measure speed) */ |
711 | Also the register block at offset A0 maps to TEMP1 (so our temp2, as the | ||
712 | F8000 starts counting temps at 0), B0 maps the TEMP2 and C0 maps to TEMP0 */ | ||
713 | static struct sensor_device_attribute_2 f8000_fan_attr[] = { | 717 | static struct sensor_device_attribute_2 f8000_fan_attr[] = { |
714 | SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), | 718 | SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3), |
719 | }; | ||
715 | 720 | ||
721 | /* PWM attr for the f8000, zones mapped to temp instead of to pwm! | ||
722 | Also the register block at offset A0 maps to TEMP1 (so our temp2, as the | ||
723 | F8000 starts counting temps at 0), B0 maps the TEMP2 and C0 maps to TEMP0 */ | ||
724 | static struct sensor_device_attribute_2 f8000_auto_pwm_attr[] = { | ||
725 | SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR, | ||
726 | show_pwm_auto_point_channel, | ||
727 | store_pwm_auto_point_channel, 0, 0), | ||
716 | SENSOR_ATTR_2(temp1_auto_point1_pwm, S_IRUGO|S_IWUSR, | 728 | SENSOR_ATTR_2(temp1_auto_point1_pwm, S_IRUGO|S_IWUSR, |
717 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 729 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
718 | 0, 2), | 730 | 0, 2), |
@@ -751,6 +763,9 @@ static struct sensor_device_attribute_2 f8000_fan_attr[] = { | |||
751 | SENSOR_ATTR_2(temp1_auto_point4_temp_hyst, S_IRUGO, | 763 | SENSOR_ATTR_2(temp1_auto_point4_temp_hyst, S_IRUGO, |
752 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), | 764 | show_pwm_auto_point_temp_hyst, NULL, 3, 2), |
753 | 765 | ||
766 | SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR, | ||
767 | show_pwm_auto_point_channel, | ||
768 | store_pwm_auto_point_channel, 0, 1), | ||
754 | SENSOR_ATTR_2(temp2_auto_point1_pwm, S_IRUGO|S_IWUSR, | 769 | SENSOR_ATTR_2(temp2_auto_point1_pwm, S_IRUGO|S_IWUSR, |
755 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 770 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
756 | 0, 0), | 771 | 0, 0), |
@@ -789,6 +804,9 @@ static struct sensor_device_attribute_2 f8000_fan_attr[] = { | |||
789 | SENSOR_ATTR_2(temp2_auto_point4_temp_hyst, S_IRUGO, | 804 | SENSOR_ATTR_2(temp2_auto_point4_temp_hyst, S_IRUGO, |
790 | show_pwm_auto_point_temp_hyst, NULL, 3, 0), | 805 | show_pwm_auto_point_temp_hyst, NULL, 3, 0), |
791 | 806 | ||
807 | SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR, | ||
808 | show_pwm_auto_point_channel, | ||
809 | store_pwm_auto_point_channel, 0, 2), | ||
792 | SENSOR_ATTR_2(temp3_auto_point1_pwm, S_IRUGO|S_IWUSR, | 810 | SENSOR_ATTR_2(temp3_auto_point1_pwm, S_IRUGO|S_IWUSR, |
793 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, | 811 | show_pwm_auto_point_pwm, store_pwm_auto_point_pwm, |
794 | 0, 1), | 812 | 0, 1), |
@@ -929,7 +947,7 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
929 | /* Update once every 60 seconds */ | 947 | /* Update once every 60 seconds */ |
930 | if ( time_after(jiffies, data->last_limits + 60 * HZ ) || | 948 | if ( time_after(jiffies, data->last_limits + 60 * HZ ) || |
931 | !data->valid) { | 949 | !data->valid) { |
932 | if (data->type == f71882fg) { | 950 | if (data->type == f71882fg || data->type == f71889fg) { |
933 | data->in1_max = | 951 | data->in1_max = |
934 | f71882fg_read8(data, F71882FG_REG_IN1_HIGH); | 952 | f71882fg_read8(data, F71882FG_REG_IN1_HIGH); |
935 | data->in_beep = | 953 | data->in_beep = |
@@ -951,7 +969,8 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
951 | F71882FG_REG_TEMP_HYST(1)); | 969 | F71882FG_REG_TEMP_HYST(1)); |
952 | } | 970 | } |
953 | 971 | ||
954 | if (data->type == f71862fg || data->type == f71882fg) { | 972 | if (data->type == f71862fg || data->type == f71882fg || |
973 | data->type == f71889fg) { | ||
955 | data->fan_beep = f71882fg_read8(data, | 974 | data->fan_beep = f71882fg_read8(data, |
956 | F71882FG_REG_FAN_BEEP); | 975 | F71882FG_REG_FAN_BEEP); |
957 | data->temp_beep = f71882fg_read8(data, | 976 | data->temp_beep = f71882fg_read8(data, |
@@ -961,15 +980,33 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
961 | data->temp_type[2] = (reg & 0x04) ? 2 : 4; | 980 | data->temp_type[2] = (reg & 0x04) ? 2 : 4; |
962 | data->temp_type[3] = (reg & 0x08) ? 2 : 4; | 981 | data->temp_type[3] = (reg & 0x08) ? 2 : 4; |
963 | } | 982 | } |
964 | reg2 = f71882fg_read8(data, F71882FG_REG_PECI); | 983 | /* Determine temp index 1 sensor type */ |
965 | if ((reg2 & 0x03) == 0x01) | 984 | if (data->type == f71889fg) { |
966 | data->temp_type[1] = 6 /* PECI */; | 985 | reg2 = f71882fg_read8(data, F71882FG_REG_START); |
967 | else if ((reg2 & 0x03) == 0x02) | 986 | switch ((reg2 & 0x60) >> 5) { |
968 | data->temp_type[1] = 5 /* AMDSI */; | 987 | case 0x00: /* BJT / Thermistor */ |
969 | else if (data->type == f71862fg || data->type == f71882fg) | 988 | data->temp_type[1] = (reg & 0x02) ? 2 : 4; |
970 | data->temp_type[1] = (reg & 0x02) ? 2 : 4; | 989 | break; |
971 | else | 990 | case 0x01: /* AMDSI */ |
972 | data->temp_type[1] = 2; /* Only supports BJT */ | 991 | data->temp_type[1] = 5; |
992 | break; | ||
993 | case 0x02: /* PECI */ | ||
994 | case 0x03: /* Ibex Peak ?? Report as PECI for now */ | ||
995 | data->temp_type[1] = 6; | ||
996 | break; | ||
997 | } | ||
998 | } else { | ||
999 | reg2 = f71882fg_read8(data, F71882FG_REG_PECI); | ||
1000 | if ((reg2 & 0x03) == 0x01) | ||
1001 | data->temp_type[1] = 6; /* PECI */ | ||
1002 | else if ((reg2 & 0x03) == 0x02) | ||
1003 | data->temp_type[1] = 5; /* AMDSI */ | ||
1004 | else if (data->type == f71862fg || | ||
1005 | data->type == f71882fg) | ||
1006 | data->temp_type[1] = (reg & 0x02) ? 2 : 4; | ||
1007 | else /* f71858fg and f8000 only support BJT */ | ||
1008 | data->temp_type[1] = 2; | ||
1009 | } | ||
973 | 1010 | ||
974 | data->pwm_enable = f71882fg_read8(data, | 1011 | data->pwm_enable = f71882fg_read8(data, |
975 | F71882FG_REG_PWM_ENABLE); | 1012 | F71882FG_REG_PWM_ENABLE); |
@@ -1046,7 +1083,7 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
1046 | if (data->type == f8000) | 1083 | if (data->type == f8000) |
1047 | data->fan[3] = f71882fg_read16(data, | 1084 | data->fan[3] = f71882fg_read16(data, |
1048 | F71882FG_REG_FAN(3)); | 1085 | F71882FG_REG_FAN(3)); |
1049 | if (data->type == f71882fg) | 1086 | if (data->type == f71882fg || data->type == f71889fg) |
1050 | data->in_status = f71882fg_read8(data, | 1087 | data->in_status = f71882fg_read8(data, |
1051 | F71882FG_REG_IN_STATUS); | 1088 | F71882FG_REG_IN_STATUS); |
1052 | for (nr = 0; nr < nr_ins; nr++) | 1089 | for (nr = 0; nr < nr_ins; nr++) |
@@ -1764,7 +1801,11 @@ static ssize_t store_pwm_auto_point_temp(struct device *dev, | |||
1764 | int pwm = to_sensor_dev_attr_2(devattr)->index; | 1801 | int pwm = to_sensor_dev_attr_2(devattr)->index; |
1765 | int point = to_sensor_dev_attr_2(devattr)->nr; | 1802 | int point = to_sensor_dev_attr_2(devattr)->nr; |
1766 | long val = simple_strtol(buf, NULL, 10) / 1000; | 1803 | long val = simple_strtol(buf, NULL, 10) / 1000; |
1767 | val = SENSORS_LIMIT(val, 0, 255); | 1804 | |
1805 | if (data->type == f71889fg) | ||
1806 | val = SENSORS_LIMIT(val, -128, 127); | ||
1807 | else | ||
1808 | val = SENSORS_LIMIT(val, 0, 127); | ||
1768 | 1809 | ||
1769 | mutex_lock(&data->update_lock); | 1810 | mutex_lock(&data->update_lock); |
1770 | f71882fg_write8(data, F71882FG_REG_POINT_TEMP(pwm, point), val); | 1811 | f71882fg_write8(data, F71882FG_REG_POINT_TEMP(pwm, point), val); |
@@ -1794,6 +1835,15 @@ static int __devinit f71882fg_create_sysfs_files(struct platform_device *pdev, | |||
1794 | return 0; | 1835 | return 0; |
1795 | } | 1836 | } |
1796 | 1837 | ||
1838 | static void f71882fg_remove_sysfs_files(struct platform_device *pdev, | ||
1839 | struct sensor_device_attribute_2 *attr, int count) | ||
1840 | { | ||
1841 | int i; | ||
1842 | |||
1843 | for (i = 0; i < count; i++) | ||
1844 | device_remove_file(&pdev->dev, &attr[i].dev_attr); | ||
1845 | } | ||
1846 | |||
1797 | static int __devinit f71882fg_probe(struct platform_device *pdev) | 1847 | static int __devinit f71882fg_probe(struct platform_device *pdev) |
1798 | { | 1848 | { |
1799 | struct f71882fg_data *data; | 1849 | struct f71882fg_data *data; |
@@ -1846,16 +1896,17 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1846 | ARRAY_SIZE(f71858fg_in_temp_attr)); | 1896 | ARRAY_SIZE(f71858fg_in_temp_attr)); |
1847 | break; | 1897 | break; |
1848 | case f71882fg: | 1898 | case f71882fg: |
1899 | case f71889fg: | ||
1849 | err = f71882fg_create_sysfs_files(pdev, | 1900 | err = f71882fg_create_sysfs_files(pdev, |
1850 | f71882fg_in_temp_attr, | 1901 | fxxxx_in1_alarm_attr, |
1851 | ARRAY_SIZE(f71882fg_in_temp_attr)); | 1902 | ARRAY_SIZE(fxxxx_in1_alarm_attr)); |
1852 | if (err) | 1903 | if (err) |
1853 | goto exit_unregister_sysfs; | 1904 | goto exit_unregister_sysfs; |
1854 | /* fall through! */ | 1905 | /* fall through! */ |
1855 | case f71862fg: | 1906 | case f71862fg: |
1856 | err = f71882fg_create_sysfs_files(pdev, | 1907 | err = f71882fg_create_sysfs_files(pdev, |
1857 | f718x2fg_in_temp_attr, | 1908 | fxxxx_in_temp_attr, |
1858 | ARRAY_SIZE(f718x2fg_in_temp_attr)); | 1909 | ARRAY_SIZE(fxxxx_in_temp_attr)); |
1859 | break; | 1910 | break; |
1860 | case f8000: | 1911 | case f8000: |
1861 | err = f71882fg_create_sysfs_files(pdev, | 1912 | err = f71882fg_create_sysfs_files(pdev, |
@@ -1883,6 +1934,7 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1883 | err = (data->pwm_enable & 0x15) != 0x15; | 1934 | err = (data->pwm_enable & 0x15) != 0x15; |
1884 | break; | 1935 | break; |
1885 | case f71882fg: | 1936 | case f71882fg: |
1937 | case f71889fg: | ||
1886 | err = 0; | 1938 | err = 0; |
1887 | break; | 1939 | break; |
1888 | case f8000: | 1940 | case f8000: |
@@ -1897,34 +1949,55 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1897 | goto exit_unregister_sysfs; | 1949 | goto exit_unregister_sysfs; |
1898 | } | 1950 | } |
1899 | 1951 | ||
1900 | err = f71882fg_create_sysfs_files(pdev, fxxxx_fan_attr, | 1952 | err = f71882fg_create_sysfs_files(pdev, &fxxxx_fan_attr[0][0], |
1901 | ARRAY_SIZE(fxxxx_fan_attr)); | 1953 | ARRAY_SIZE(fxxxx_fan_attr[0]) * nr_fans); |
1902 | if (err) | 1954 | if (err) |
1903 | goto exit_unregister_sysfs; | 1955 | goto exit_unregister_sysfs; |
1904 | 1956 | ||
1905 | switch (data->type) { | 1957 | if (data->type == f71862fg || data->type == f71882fg || |
1906 | case f71862fg: | 1958 | data->type == f71889fg) { |
1907 | err = f71882fg_create_sysfs_files(pdev, | ||
1908 | f71862fg_fan_attr, | ||
1909 | ARRAY_SIZE(f71862fg_fan_attr)); | ||
1910 | break; | ||
1911 | case f71882fg: | ||
1912 | err = f71882fg_create_sysfs_files(pdev, | 1959 | err = f71882fg_create_sysfs_files(pdev, |
1913 | f71882fg_fan_attr, | 1960 | fxxxx_fan_beep_attr, nr_fans); |
1914 | ARRAY_SIZE(f71882fg_fan_attr)); | ||
1915 | if (err) | 1961 | if (err) |
1916 | goto exit_unregister_sysfs; | 1962 | goto exit_unregister_sysfs; |
1917 | /* fall through! */ | 1963 | } |
1918 | case f71858fg: | 1964 | |
1965 | switch (data->type) { | ||
1966 | case f71862fg: | ||
1919 | err = f71882fg_create_sysfs_files(pdev, | 1967 | err = f71882fg_create_sysfs_files(pdev, |
1920 | f71882fg_f71858fg_fan_attr, | 1968 | f71862fg_auto_pwm_attr, |
1921 | ARRAY_SIZE(f71882fg_f71858fg_fan_attr)); | 1969 | ARRAY_SIZE(f71862fg_auto_pwm_attr)); |
1922 | break; | 1970 | break; |
1923 | case f8000: | 1971 | case f8000: |
1924 | err = f71882fg_create_sysfs_files(pdev, | 1972 | err = f71882fg_create_sysfs_files(pdev, |
1925 | f8000_fan_attr, | 1973 | f8000_fan_attr, |
1926 | ARRAY_SIZE(f8000_fan_attr)); | 1974 | ARRAY_SIZE(f8000_fan_attr)); |
1975 | if (err) | ||
1976 | goto exit_unregister_sysfs; | ||
1977 | err = f71882fg_create_sysfs_files(pdev, | ||
1978 | f8000_auto_pwm_attr, | ||
1979 | ARRAY_SIZE(f8000_auto_pwm_attr)); | ||
1927 | break; | 1980 | break; |
1981 | case f71889fg: | ||
1982 | for (i = 0; i < nr_fans; i++) { | ||
1983 | data->pwm_auto_point_mapping[i] = | ||
1984 | f71882fg_read8(data, | ||
1985 | F71882FG_REG_POINT_MAPPING(i)); | ||
1986 | if (data->pwm_auto_point_mapping[i] & 0x80) | ||
1987 | break; | ||
1988 | } | ||
1989 | if (i != nr_fans) { | ||
1990 | dev_warn(&pdev->dev, | ||
1991 | "Auto pwm controlled by raw digital " | ||
1992 | "data, disabling pwm auto_point " | ||
1993 | "sysfs attributes\n"); | ||
1994 | break; | ||
1995 | } | ||
1996 | /* fall through */ | ||
1997 | default: /* f71858fg / f71882fg */ | ||
1998 | err = f71882fg_create_sysfs_files(pdev, | ||
1999 | &fxxxx_auto_pwm_attr[0][0], | ||
2000 | ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans); | ||
1928 | } | 2001 | } |
1929 | if (err) | 2002 | if (err) |
1930 | goto exit_unregister_sysfs; | 2003 | goto exit_unregister_sysfs; |
@@ -1954,33 +2027,76 @@ exit_free: | |||
1954 | 2027 | ||
1955 | static int f71882fg_remove(struct platform_device *pdev) | 2028 | static int f71882fg_remove(struct platform_device *pdev) |
1956 | { | 2029 | { |
1957 | int i; | ||
1958 | struct f71882fg_data *data = platform_get_drvdata(pdev); | 2030 | struct f71882fg_data *data = platform_get_drvdata(pdev); |
2031 | int nr_fans = (data->type == f71882fg) ? 4 : 3; | ||
2032 | u8 start_reg = f71882fg_read8(data, F71882FG_REG_START); | ||
1959 | 2033 | ||
1960 | platform_set_drvdata(pdev, NULL); | 2034 | platform_set_drvdata(pdev, NULL); |
1961 | if (data->hwmon_dev) | 2035 | if (data->hwmon_dev) |
1962 | hwmon_device_unregister(data->hwmon_dev); | 2036 | hwmon_device_unregister(data->hwmon_dev); |
1963 | 2037 | ||
1964 | /* Note we are not looping over all attr arrays we have as the ones | ||
1965 | below are supersets of the ones skipped. */ | ||
1966 | device_remove_file(&pdev->dev, &dev_attr_name); | 2038 | device_remove_file(&pdev->dev, &dev_attr_name); |
1967 | 2039 | ||
1968 | for (i = 0; i < ARRAY_SIZE(f718x2fg_in_temp_attr); i++) | 2040 | if (start_reg & 0x01) { |
1969 | device_remove_file(&pdev->dev, | 2041 | switch (data->type) { |
1970 | &f718x2fg_in_temp_attr[i].dev_attr); | 2042 | case f71858fg: |
1971 | 2043 | if (data->temp_config & 0x10) | |
1972 | for (i = 0; i < ARRAY_SIZE(f71882fg_in_temp_attr); i++) | 2044 | f71882fg_remove_sysfs_files(pdev, |
1973 | device_remove_file(&pdev->dev, | 2045 | f8000_in_temp_attr, |
1974 | &f71882fg_in_temp_attr[i].dev_attr); | 2046 | ARRAY_SIZE(f8000_in_temp_attr)); |
2047 | else | ||
2048 | f71882fg_remove_sysfs_files(pdev, | ||
2049 | f71858fg_in_temp_attr, | ||
2050 | ARRAY_SIZE(f71858fg_in_temp_attr)); | ||
2051 | break; | ||
2052 | case f71882fg: | ||
2053 | case f71889fg: | ||
2054 | f71882fg_remove_sysfs_files(pdev, | ||
2055 | fxxxx_in1_alarm_attr, | ||
2056 | ARRAY_SIZE(fxxxx_in1_alarm_attr)); | ||
2057 | /* fall through! */ | ||
2058 | case f71862fg: | ||
2059 | f71882fg_remove_sysfs_files(pdev, | ||
2060 | fxxxx_in_temp_attr, | ||
2061 | ARRAY_SIZE(fxxxx_in_temp_attr)); | ||
2062 | break; | ||
2063 | case f8000: | ||
2064 | f71882fg_remove_sysfs_files(pdev, | ||
2065 | f8000_in_temp_attr, | ||
2066 | ARRAY_SIZE(f8000_in_temp_attr)); | ||
2067 | break; | ||
2068 | } | ||
2069 | } | ||
1975 | 2070 | ||
1976 | for (i = 0; i < ARRAY_SIZE(fxxxx_fan_attr); i++) | 2071 | if (start_reg & 0x02) { |
1977 | device_remove_file(&pdev->dev, &fxxxx_fan_attr[i].dev_attr); | 2072 | f71882fg_remove_sysfs_files(pdev, &fxxxx_fan_attr[0][0], |
2073 | ARRAY_SIZE(fxxxx_fan_attr[0]) * nr_fans); | ||
1978 | 2074 | ||
1979 | for (i = 0; i < ARRAY_SIZE(f71882fg_fan_attr); i++) | 2075 | if (data->type == f71862fg || data->type == f71882fg || |
1980 | device_remove_file(&pdev->dev, &f71882fg_fan_attr[i].dev_attr); | 2076 | data->type == f71889fg) |
2077 | f71882fg_remove_sysfs_files(pdev, | ||
2078 | fxxxx_fan_beep_attr, nr_fans); | ||
1981 | 2079 | ||
1982 | for (i = 0; i < ARRAY_SIZE(f8000_fan_attr); i++) | 2080 | switch (data->type) { |
1983 | device_remove_file(&pdev->dev, &f8000_fan_attr[i].dev_attr); | 2081 | case f71862fg: |
2082 | f71882fg_remove_sysfs_files(pdev, | ||
2083 | f71862fg_auto_pwm_attr, | ||
2084 | ARRAY_SIZE(f71862fg_auto_pwm_attr)); | ||
2085 | break; | ||
2086 | case f8000: | ||
2087 | f71882fg_remove_sysfs_files(pdev, | ||
2088 | f8000_fan_attr, | ||
2089 | ARRAY_SIZE(f8000_fan_attr)); | ||
2090 | f71882fg_remove_sysfs_files(pdev, | ||
2091 | f8000_auto_pwm_attr, | ||
2092 | ARRAY_SIZE(f8000_auto_pwm_attr)); | ||
2093 | break; | ||
2094 | default: /* f71858fg / f71882fg / f71889fg */ | ||
2095 | f71882fg_remove_sysfs_files(pdev, | ||
2096 | &fxxxx_auto_pwm_attr[0][0], | ||
2097 | ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans); | ||
2098 | } | ||
2099 | } | ||
1984 | 2100 | ||
1985 | kfree(data); | 2101 | kfree(data); |
1986 | 2102 | ||
@@ -2012,11 +2128,15 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, | |||
2012 | case SIO_F71882_ID: | 2128 | case SIO_F71882_ID: |
2013 | sio_data->type = f71882fg; | 2129 | sio_data->type = f71882fg; |
2014 | break; | 2130 | break; |
2131 | case SIO_F71889_ID: | ||
2132 | sio_data->type = f71889fg; | ||
2133 | break; | ||
2015 | case SIO_F8000_ID: | 2134 | case SIO_F8000_ID: |
2016 | sio_data->type = f8000; | 2135 | sio_data->type = f8000; |
2017 | break; | 2136 | break; |
2018 | default: | 2137 | default: |
2019 | printk(KERN_INFO DRVNAME ": Unsupported Fintek device\n"); | 2138 | printk(KERN_INFO DRVNAME ": Unsupported Fintek device: %04x\n", |
2139 | (unsigned int)devid); | ||
2020 | goto exit; | 2140 | goto exit; |
2021 | } | 2141 | } |
2022 | 2142 | ||
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c index e2107e533ede..40dfbcd3f3f2 100644 --- a/drivers/hwmon/f75375s.c +++ b/drivers/hwmon/f75375s.c | |||
@@ -681,30 +681,20 @@ static int f75375_detect(struct i2c_client *client, int kind, | |||
681 | struct i2c_board_info *info) | 681 | struct i2c_board_info *info) |
682 | { | 682 | { |
683 | struct i2c_adapter *adapter = client->adapter; | 683 | struct i2c_adapter *adapter = client->adapter; |
684 | u8 version = 0; | 684 | u16 vendid, chipid; |
685 | const char *name = ""; | 685 | u8 version; |
686 | 686 | const char *name; | |
687 | if (kind < 0) { | ||
688 | u16 vendid = f75375_read16(client, F75375_REG_VENDOR); | ||
689 | u16 chipid = f75375_read16(client, F75375_CHIP_ID); | ||
690 | version = f75375_read8(client, F75375_REG_VERSION); | ||
691 | if (chipid == 0x0306 && vendid == 0x1934) { | ||
692 | kind = f75375; | ||
693 | } else if (chipid == 0x0204 && vendid == 0x1934) { | ||
694 | kind = f75373; | ||
695 | } else { | ||
696 | dev_err(&adapter->dev, | ||
697 | "failed,%02X,%02X,%02X\n", | ||
698 | chipid, version, vendid); | ||
699 | return -ENODEV; | ||
700 | } | ||
701 | } | ||
702 | 687 | ||
703 | if (kind == f75375) { | 688 | vendid = f75375_read16(client, F75375_REG_VENDOR); |
689 | chipid = f75375_read16(client, F75375_CHIP_ID); | ||
690 | if (chipid == 0x0306 && vendid == 0x1934) | ||
704 | name = "f75375"; | 691 | name = "f75375"; |
705 | } else if (kind == f75373) { | 692 | else if (chipid == 0x0204 && vendid == 0x1934) |
706 | name = "f75373"; | 693 | name = "f75373"; |
707 | } | 694 | else |
695 | return -ENODEV; | ||
696 | |||
697 | version = f75375_read8(client, F75375_REG_VERSION); | ||
708 | dev_info(&adapter->dev, "found %s version: %02X\n", name, version); | 698 | dev_info(&adapter->dev, "found %s version: %02X\n", name, version); |
709 | strlcpy(info->type, name, I2C_NAME_SIZE); | 699 | strlcpy(info->type, name, I2C_NAME_SIZE); |
710 | 700 | ||
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c index da1b1f9488af..281829cd1533 100644 --- a/drivers/hwmon/fschmd.c +++ b/drivers/hwmon/fschmd.c | |||
@@ -1000,43 +1000,38 @@ static void fschmd_dmi_decode(const struct dmi_header *header, void *dummy) | |||
1000 | } | 1000 | } |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | static int fschmd_detect(struct i2c_client *client, int kind, | 1003 | static int fschmd_detect(struct i2c_client *client, int _kind, |
1004 | struct i2c_board_info *info) | 1004 | struct i2c_board_info *info) |
1005 | { | 1005 | { |
1006 | enum chips kind; | ||
1006 | struct i2c_adapter *adapter = client->adapter; | 1007 | struct i2c_adapter *adapter = client->adapter; |
1008 | char id[4]; | ||
1007 | 1009 | ||
1008 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 1010 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
1009 | return -ENODEV; | 1011 | return -ENODEV; |
1010 | 1012 | ||
1011 | /* Detect & Identify the chip */ | 1013 | /* Detect & Identify the chip */ |
1012 | if (kind <= 0) { | 1014 | id[0] = i2c_smbus_read_byte_data(client, FSCHMD_REG_IDENT_0); |
1013 | char id[4]; | 1015 | id[1] = i2c_smbus_read_byte_data(client, FSCHMD_REG_IDENT_1); |
1014 | 1016 | id[2] = i2c_smbus_read_byte_data(client, FSCHMD_REG_IDENT_2); | |
1015 | id[0] = i2c_smbus_read_byte_data(client, | 1017 | id[3] = '\0'; |
1016 | FSCHMD_REG_IDENT_0); | 1018 | |
1017 | id[1] = i2c_smbus_read_byte_data(client, | 1019 | if (!strcmp(id, "PEG")) |
1018 | FSCHMD_REG_IDENT_1); | 1020 | kind = fscpos; |
1019 | id[2] = i2c_smbus_read_byte_data(client, | 1021 | else if (!strcmp(id, "HER")) |
1020 | FSCHMD_REG_IDENT_2); | 1022 | kind = fscher; |
1021 | id[3] = '\0'; | 1023 | else if (!strcmp(id, "SCY")) |
1022 | 1024 | kind = fscscy; | |
1023 | if (!strcmp(id, "PEG")) | 1025 | else if (!strcmp(id, "HRC")) |
1024 | kind = fscpos; | 1026 | kind = fschrc; |
1025 | else if (!strcmp(id, "HER")) | 1027 | else if (!strcmp(id, "HMD")) |
1026 | kind = fscher; | 1028 | kind = fschmd; |
1027 | else if (!strcmp(id, "SCY")) | 1029 | else if (!strcmp(id, "HDS")) |
1028 | kind = fscscy; | 1030 | kind = fschds; |
1029 | else if (!strcmp(id, "HRC")) | 1031 | else if (!strcmp(id, "SYL")) |
1030 | kind = fschrc; | 1032 | kind = fscsyl; |
1031 | else if (!strcmp(id, "HMD")) | 1033 | else |
1032 | kind = fschmd; | 1034 | return -ENODEV; |
1033 | else if (!strcmp(id, "HDS")) | ||
1034 | kind = fschds; | ||
1035 | else if (!strcmp(id, "SYL")) | ||
1036 | kind = fscsyl; | ||
1037 | else | ||
1038 | return -ENODEV; | ||
1039 | } | ||
1040 | 1035 | ||
1041 | strlcpy(info->type, fschmd_id[kind - 1].name, I2C_NAME_SIZE); | 1036 | strlcpy(info->type, fschmd_id[kind - 1].name, I2C_NAME_SIZE); |
1042 | 1037 | ||
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 7820df45d77a..1d69458aa0b6 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -488,36 +488,21 @@ static int gl518_detect(struct i2c_client *client, int kind, | |||
488 | struct i2c_board_info *info) | 488 | struct i2c_board_info *info) |
489 | { | 489 | { |
490 | struct i2c_adapter *adapter = client->adapter; | 490 | struct i2c_adapter *adapter = client->adapter; |
491 | int i; | 491 | int rev; |
492 | 492 | ||
493 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 493 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
494 | I2C_FUNC_SMBUS_WORD_DATA)) | 494 | I2C_FUNC_SMBUS_WORD_DATA)) |
495 | return -ENODEV; | 495 | return -ENODEV; |
496 | 496 | ||
497 | /* Now, we do the remaining detection. */ | 497 | /* Now, we do the remaining detection. */ |
498 | 498 | if ((gl518_read_value(client, GL518_REG_CHIP_ID) != 0x80) | |
499 | if (kind < 0) { | 499 | || (gl518_read_value(client, GL518_REG_CONF) & 0x80)) |
500 | if ((gl518_read_value(client, GL518_REG_CHIP_ID) != 0x80) | 500 | return -ENODEV; |
501 | || (gl518_read_value(client, GL518_REG_CONF) & 0x80)) | ||
502 | return -ENODEV; | ||
503 | } | ||
504 | 501 | ||
505 | /* Determine the chip type. */ | 502 | /* Determine the chip type. */ |
506 | if (kind <= 0) { | 503 | rev = gl518_read_value(client, GL518_REG_REVISION); |
507 | i = gl518_read_value(client, GL518_REG_REVISION); | 504 | if (rev != 0x00 && rev != 0x80) |
508 | if (i == 0x00) { | 505 | return -ENODEV; |
509 | kind = gl518sm_r00; | ||
510 | } else if (i == 0x80) { | ||
511 | kind = gl518sm_r80; | ||
512 | } else { | ||
513 | if (kind <= 0) | ||
514 | dev_info(&adapter->dev, | ||
515 | "Ignoring 'force' parameter for unknown " | ||
516 | "chip at adapter %d, address 0x%02x\n", | ||
517 | i2c_adapter_id(adapter), client->addr); | ||
518 | return -ENODEV; | ||
519 | } | ||
520 | } | ||
521 | 506 | ||
522 | strlcpy(info->type, "gl518sm", I2C_NAME_SIZE); | 507 | strlcpy(info->type, "gl518sm", I2C_NAME_SIZE); |
523 | 508 | ||
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 19616f2242b0..92b5720ceaff 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -691,13 +691,11 @@ static int gl520_detect(struct i2c_client *client, int kind, | |||
691 | return -ENODEV; | 691 | return -ENODEV; |
692 | 692 | ||
693 | /* Determine the chip type. */ | 693 | /* Determine the chip type. */ |
694 | if (kind < 0) { | 694 | if ((gl520_read_value(client, GL520_REG_CHIP_ID) != 0x20) || |
695 | if ((gl520_read_value(client, GL520_REG_CHIP_ID) != 0x20) || | 695 | ((gl520_read_value(client, GL520_REG_REVISION) & 0x7f) != 0x00) || |
696 | ((gl520_read_value(client, GL520_REG_REVISION) & 0x7f) != 0x00) || | 696 | ((gl520_read_value(client, GL520_REG_CONF) & 0x80) != 0x00)) { |
697 | ((gl520_read_value(client, GL520_REG_CONF) & 0x80) != 0x00)) { | 697 | dev_dbg(&client->dev, "Unknown chip type, skipping\n"); |
698 | dev_dbg(&client->dev, "Unknown chip type, skipping\n"); | 698 | return -ENODEV; |
699 | return -ENODEV; | ||
700 | } | ||
701 | } | 699 | } |
702 | 700 | ||
703 | strlcpy(info->type, "gl520sm", I2C_NAME_SIZE); | 701 | strlcpy(info->type, "gl520sm", I2C_NAME_SIZE); |
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index a3749cb0f181..0ffe84d190bb 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -124,6 +124,8 @@ superio_exit(void) | |||
124 | #define IT87_BASE_REG 0x60 | 124 | #define IT87_BASE_REG 0x60 |
125 | 125 | ||
126 | /* Logical device 7 registers (IT8712F and later) */ | 126 | /* Logical device 7 registers (IT8712F and later) */ |
127 | #define IT87_SIO_GPIO3_REG 0x27 | ||
128 | #define IT87_SIO_GPIO5_REG 0x29 | ||
127 | #define IT87_SIO_PINX2_REG 0x2c /* Pin selection */ | 129 | #define IT87_SIO_PINX2_REG 0x2c /* Pin selection */ |
128 | #define IT87_SIO_VID_REG 0xfc /* VID value */ | 130 | #define IT87_SIO_VID_REG 0xfc /* VID value */ |
129 | 131 | ||
@@ -244,7 +246,9 @@ struct it87_sio_data { | |||
244 | /* Values read from Super-I/O config space */ | 246 | /* Values read from Super-I/O config space */ |
245 | u8 revision; | 247 | u8 revision; |
246 | u8 vid_value; | 248 | u8 vid_value; |
247 | /* Values set based on DMI strings */ | 249 | /* Features skipped based on config or DMI */ |
250 | u8 skip_vid; | ||
251 | u8 skip_fan; | ||
248 | u8 skip_pwm; | 252 | u8 skip_pwm; |
249 | }; | 253 | }; |
250 | 254 | ||
@@ -1028,11 +1032,35 @@ static int __init it87_find(unsigned short *address, | |||
1028 | chip_type, *address, sio_data->revision); | 1032 | chip_type, *address, sio_data->revision); |
1029 | 1033 | ||
1030 | /* Read GPIO config and VID value from LDN 7 (GPIO) */ | 1034 | /* Read GPIO config and VID value from LDN 7 (GPIO) */ |
1031 | if (sio_data->type != it87) { | 1035 | if (sio_data->type == it87) { |
1036 | /* The IT8705F doesn't have VID pins at all */ | ||
1037 | sio_data->skip_vid = 1; | ||
1038 | } else { | ||
1032 | int reg; | 1039 | int reg; |
1033 | 1040 | ||
1034 | superio_select(GPIO); | 1041 | superio_select(GPIO); |
1035 | if (sio_data->type == it8718 || sio_data->type == it8720) | 1042 | /* We need at least 4 VID pins */ |
1043 | reg = superio_inb(IT87_SIO_GPIO3_REG); | ||
1044 | if (reg & 0x0f) { | ||
1045 | pr_info("it87: VID is disabled (pins used for GPIO)\n"); | ||
1046 | sio_data->skip_vid = 1; | ||
1047 | } | ||
1048 | |||
1049 | /* Check if fan3 is there or not */ | ||
1050 | if (reg & (1 << 6)) | ||
1051 | sio_data->skip_pwm |= (1 << 2); | ||
1052 | if (reg & (1 << 7)) | ||
1053 | sio_data->skip_fan |= (1 << 2); | ||
1054 | |||
1055 | /* Check if fan2 is there or not */ | ||
1056 | reg = superio_inb(IT87_SIO_GPIO5_REG); | ||
1057 | if (reg & (1 << 1)) | ||
1058 | sio_data->skip_pwm |= (1 << 1); | ||
1059 | if (reg & (1 << 2)) | ||
1060 | sio_data->skip_fan |= (1 << 1); | ||
1061 | |||
1062 | if ((sio_data->type == it8718 || sio_data->type == it8720) | ||
1063 | && !(sio_data->skip_vid)) | ||
1036 | sio_data->vid_value = superio_inb(IT87_SIO_VID_REG); | 1064 | sio_data->vid_value = superio_inb(IT87_SIO_VID_REG); |
1037 | 1065 | ||
1038 | reg = superio_inb(IT87_SIO_PINX2_REG); | 1066 | reg = superio_inb(IT87_SIO_PINX2_REG); |
@@ -1236,8 +1264,7 @@ static int __devinit it87_probe(struct platform_device *pdev) | |||
1236 | } | 1264 | } |
1237 | } | 1265 | } |
1238 | 1266 | ||
1239 | if (data->type == it8712 || data->type == it8716 | 1267 | if (!sio_data->skip_vid) { |
1240 | || data->type == it8718 || data->type == it8720) { | ||
1241 | data->vrm = vid_which_vrm(); | 1268 | data->vrm = vid_which_vrm(); |
1242 | /* VID reading from Super-I/O config space if available */ | 1269 | /* VID reading from Super-I/O config space if available */ |
1243 | data->vid = sio_data->vid_value; | 1270 | data->vid = sio_data->vid_value; |
@@ -1355,8 +1382,10 @@ static int __devinit it87_check_pwm(struct device *dev) | |||
1355 | /* Called when we have found a new IT87. */ | 1382 | /* Called when we have found a new IT87. */ |
1356 | static void __devinit it87_init_device(struct platform_device *pdev) | 1383 | static void __devinit it87_init_device(struct platform_device *pdev) |
1357 | { | 1384 | { |
1385 | struct it87_sio_data *sio_data = pdev->dev.platform_data; | ||
1358 | struct it87_data *data = platform_get_drvdata(pdev); | 1386 | struct it87_data *data = platform_get_drvdata(pdev); |
1359 | int tmp, i; | 1387 | int tmp, i; |
1388 | u8 mask; | ||
1360 | 1389 | ||
1361 | /* initialize to sane defaults: | 1390 | /* initialize to sane defaults: |
1362 | * - if the chip is in manual pwm mode, this will be overwritten with | 1391 | * - if the chip is in manual pwm mode, this will be overwritten with |
@@ -1402,10 +1431,11 @@ static void __devinit it87_init_device(struct platform_device *pdev) | |||
1402 | } | 1431 | } |
1403 | 1432 | ||
1404 | /* Check if tachometers are reset manually or by some reason */ | 1433 | /* Check if tachometers are reset manually or by some reason */ |
1434 | mask = 0x70 & ~(sio_data->skip_fan << 4); | ||
1405 | data->fan_main_ctrl = it87_read_value(data, IT87_REG_FAN_MAIN_CTRL); | 1435 | data->fan_main_ctrl = it87_read_value(data, IT87_REG_FAN_MAIN_CTRL); |
1406 | if ((data->fan_main_ctrl & 0x70) == 0) { | 1436 | if ((data->fan_main_ctrl & mask) == 0) { |
1407 | /* Enable all fan tachometers */ | 1437 | /* Enable all fan tachometers */ |
1408 | data->fan_main_ctrl |= 0x70; | 1438 | data->fan_main_ctrl |= mask; |
1409 | it87_write_value(data, IT87_REG_FAN_MAIN_CTRL, data->fan_main_ctrl); | 1439 | it87_write_value(data, IT87_REG_FAN_MAIN_CTRL, data->fan_main_ctrl); |
1410 | } | 1440 | } |
1411 | data->has_fan = (data->fan_main_ctrl >> 4) & 0x07; | 1441 | data->has_fan = (data->fan_main_ctrl >> 4) & 0x07; |
@@ -1428,6 +1458,9 @@ static void __devinit it87_init_device(struct platform_device *pdev) | |||
1428 | } | 1458 | } |
1429 | } | 1459 | } |
1430 | 1460 | ||
1461 | /* Fan input pins may be used for alternative functions */ | ||
1462 | data->has_fan &= ~sio_data->skip_fan; | ||
1463 | |||
1431 | /* Set current fan mode registers and the default settings for the | 1464 | /* Set current fan mode registers and the default settings for the |
1432 | * other mode registers */ | 1465 | * other mode registers */ |
1433 | for (i = 0; i < 3; i++) { | 1466 | for (i = 0; i < 3; i++) { |
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 3195a265f0e9..5da66ab04f74 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -427,40 +427,34 @@ static int lm63_detect(struct i2c_client *new_client, int kind, | |||
427 | struct i2c_board_info *info) | 427 | struct i2c_board_info *info) |
428 | { | 428 | { |
429 | struct i2c_adapter *adapter = new_client->adapter; | 429 | struct i2c_adapter *adapter = new_client->adapter; |
430 | u8 man_id, chip_id, reg_config1, reg_config2; | ||
431 | u8 reg_alert_status, reg_alert_mask; | ||
430 | 432 | ||
431 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 433 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
432 | return -ENODEV; | 434 | return -ENODEV; |
433 | 435 | ||
434 | if (kind < 0) { /* must identify */ | 436 | man_id = i2c_smbus_read_byte_data(new_client, LM63_REG_MAN_ID); |
435 | u8 man_id, chip_id, reg_config1, reg_config2; | 437 | chip_id = i2c_smbus_read_byte_data(new_client, LM63_REG_CHIP_ID); |
436 | u8 reg_alert_status, reg_alert_mask; | 438 | |
437 | 439 | reg_config1 = i2c_smbus_read_byte_data(new_client, | |
438 | man_id = i2c_smbus_read_byte_data(new_client, | 440 | LM63_REG_CONFIG1); |
439 | LM63_REG_MAN_ID); | 441 | reg_config2 = i2c_smbus_read_byte_data(new_client, |
440 | chip_id = i2c_smbus_read_byte_data(new_client, | 442 | LM63_REG_CONFIG2); |
441 | LM63_REG_CHIP_ID); | 443 | reg_alert_status = i2c_smbus_read_byte_data(new_client, |
442 | reg_config1 = i2c_smbus_read_byte_data(new_client, | 444 | LM63_REG_ALERT_STATUS); |
443 | LM63_REG_CONFIG1); | 445 | reg_alert_mask = i2c_smbus_read_byte_data(new_client, |
444 | reg_config2 = i2c_smbus_read_byte_data(new_client, | 446 | LM63_REG_ALERT_MASK); |
445 | LM63_REG_CONFIG2); | 447 | |
446 | reg_alert_status = i2c_smbus_read_byte_data(new_client, | 448 | if (man_id != 0x01 /* National Semiconductor */ |
447 | LM63_REG_ALERT_STATUS); | 449 | || chip_id != 0x41 /* LM63 */ |
448 | reg_alert_mask = i2c_smbus_read_byte_data(new_client, | 450 | || (reg_config1 & 0x18) != 0x00 |
449 | LM63_REG_ALERT_MASK); | 451 | || (reg_config2 & 0xF8) != 0x00 |
450 | 452 | || (reg_alert_status & 0x20) != 0x00 | |
451 | if (man_id == 0x01 /* National Semiconductor */ | 453 | || (reg_alert_mask & 0xA4) != 0xA4) { |
452 | && chip_id == 0x41 /* LM63 */ | 454 | dev_dbg(&adapter->dev, |
453 | && (reg_config1 & 0x18) == 0x00 | 455 | "Unsupported chip (man_id=0x%02X, chip_id=0x%02X)\n", |
454 | && (reg_config2 & 0xF8) == 0x00 | 456 | man_id, chip_id); |
455 | && (reg_alert_status & 0x20) == 0x00 | 457 | return -ENODEV; |
456 | && (reg_alert_mask & 0xA4) == 0xA4) { | ||
457 | kind = lm63; | ||
458 | } else { /* failed */ | ||
459 | dev_dbg(&adapter->dev, "Unsupported chip " | ||
460 | "(man_id=0x%02X, chip_id=0x%02X).\n", | ||
461 | man_id, chip_id); | ||
462 | return -ENODEV; | ||
463 | } | ||
464 | } | 458 | } |
465 | 459 | ||
466 | strlcpy(info->type, "lm63", I2C_NAME_SIZE); | 460 | strlcpy(info->type, "lm63", I2C_NAME_SIZE); |
diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c new file mode 100644 index 000000000000..0bf8b2a8e9f0 --- /dev/null +++ b/drivers/hwmon/lm73.c | |||
@@ -0,0 +1,205 @@ | |||
1 | /* | ||
2 | * LM73 Sensor driver | ||
3 | * Based on LM75 | ||
4 | * | ||
5 | * Copyright (C) 2007, CenoSYS (www.cenosys.com). | ||
6 | * Copyright (C) 2009, Bollore telecom (www.bolloretelecom.eu). | ||
7 | * | ||
8 | * Guillaume Ligneul <guillaume.ligneul@gmail.com> | ||
9 | * Adrien Demarez <adrien.demarez@bolloretelecom.eu> | ||
10 | * Jeremy Laine <jeremy.laine@bolloretelecom.eu> | ||
11 | * | ||
12 | * This software program is licensed subject to the GNU General Public License | ||
13 | * (GPL).Version 2,June 1991, available at | ||
14 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | ||
15 | */ | ||
16 | |||
17 | #include <linux/module.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/i2c.h> | ||
21 | #include <linux/hwmon.h> | ||
22 | #include <linux/hwmon-sysfs.h> | ||
23 | #include <linux/err.h> | ||
24 | |||
25 | |||
26 | /* Addresses scanned */ | ||
27 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c, | ||
28 | 0x4d, 0x4e, I2C_CLIENT_END }; | ||
29 | |||
30 | /* Insmod parameters */ | ||
31 | I2C_CLIENT_INSMOD_1(lm73); | ||
32 | |||
33 | /* LM73 registers */ | ||
34 | #define LM73_REG_INPUT 0x00 | ||
35 | #define LM73_REG_CONF 0x01 | ||
36 | #define LM73_REG_MAX 0x02 | ||
37 | #define LM73_REG_MIN 0x03 | ||
38 | #define LM73_REG_CTRL 0x04 | ||
39 | #define LM73_REG_ID 0x07 | ||
40 | |||
41 | #define LM73_ID 0x9001 /* or 0x190 after a swab16() */ | ||
42 | #define DRVNAME "lm73" | ||
43 | #define LM73_TEMP_MIN (-40) | ||
44 | #define LM73_TEMP_MAX 150 | ||
45 | |||
46 | /*-----------------------------------------------------------------------*/ | ||
47 | |||
48 | |||
49 | static ssize_t set_temp(struct device *dev, struct device_attribute *da, | ||
50 | const char *buf, size_t count) | ||
51 | { | ||
52 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | ||
53 | struct i2c_client *client = to_i2c_client(dev); | ||
54 | long temp; | ||
55 | short value; | ||
56 | |||
57 | int status = strict_strtol(buf, 10, &temp); | ||
58 | if (status < 0) | ||
59 | return status; | ||
60 | |||
61 | /* Write value */ | ||
62 | value = (short) SENSORS_LIMIT(temp/250, (LM73_TEMP_MIN*4), | ||
63 | (LM73_TEMP_MAX*4)) << 5; | ||
64 | i2c_smbus_write_word_data(client, attr->index, swab16(value)); | ||
65 | return count; | ||
66 | } | ||
67 | |||
68 | static ssize_t show_temp(struct device *dev, struct device_attribute *da, | ||
69 | char *buf) | ||
70 | { | ||
71 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | ||
72 | struct i2c_client *client = to_i2c_client(dev); | ||
73 | /* use integer division instead of equivalent right shift to | ||
74 | guarantee arithmetic shift and preserve the sign */ | ||
75 | int temp = ((s16) (swab16(i2c_smbus_read_word_data(client, | ||
76 | attr->index)))*250) / 32; | ||
77 | return sprintf(buf, "%d\n", temp); | ||
78 | } | ||
79 | |||
80 | |||
81 | /*-----------------------------------------------------------------------*/ | ||
82 | |||
83 | /* sysfs attributes for hwmon */ | ||
84 | |||
85 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
86 | show_temp, set_temp, LM73_REG_MAX); | ||
87 | static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, | ||
88 | show_temp, set_temp, LM73_REG_MIN); | ||
89 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, | ||
90 | show_temp, NULL, LM73_REG_INPUT); | ||
91 | |||
92 | |||
93 | static struct attribute *lm73_attributes[] = { | ||
94 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
95 | &sensor_dev_attr_temp1_max.dev_attr.attr, | ||
96 | &sensor_dev_attr_temp1_min.dev_attr.attr, | ||
97 | |||
98 | NULL | ||
99 | }; | ||
100 | |||
101 | static const struct attribute_group lm73_group = { | ||
102 | .attrs = lm73_attributes, | ||
103 | }; | ||
104 | |||
105 | /*-----------------------------------------------------------------------*/ | ||
106 | |||
107 | /* device probe and removal */ | ||
108 | |||
109 | static int | ||
110 | lm73_probe(struct i2c_client *client, const struct i2c_device_id *id) | ||
111 | { | ||
112 | struct device *hwmon_dev; | ||
113 | int status; | ||
114 | |||
115 | /* Register sysfs hooks */ | ||
116 | status = sysfs_create_group(&client->dev.kobj, &lm73_group); | ||
117 | if (status) | ||
118 | return status; | ||
119 | |||
120 | hwmon_dev = hwmon_device_register(&client->dev); | ||
121 | if (IS_ERR(hwmon_dev)) { | ||
122 | status = PTR_ERR(hwmon_dev); | ||
123 | goto exit_remove; | ||
124 | } | ||
125 | i2c_set_clientdata(client, hwmon_dev); | ||
126 | |||
127 | dev_info(&client->dev, "%s: sensor '%s'\n", | ||
128 | dev_name(hwmon_dev), client->name); | ||
129 | |||
130 | return 0; | ||
131 | |||
132 | exit_remove: | ||
133 | sysfs_remove_group(&client->dev.kobj, &lm73_group); | ||
134 | return status; | ||
135 | } | ||
136 | |||
137 | static int lm73_remove(struct i2c_client *client) | ||
138 | { | ||
139 | struct device *hwmon_dev = i2c_get_clientdata(client); | ||
140 | |||
141 | hwmon_device_unregister(hwmon_dev); | ||
142 | sysfs_remove_group(&client->dev.kobj, &lm73_group); | ||
143 | i2c_set_clientdata(client, NULL); | ||
144 | return 0; | ||
145 | } | ||
146 | |||
147 | static const struct i2c_device_id lm73_ids[] = { | ||
148 | { "lm73", lm73 }, | ||
149 | { /* LIST END */ } | ||
150 | }; | ||
151 | MODULE_DEVICE_TABLE(i2c, lm73_ids); | ||
152 | |||
153 | /* Return 0 if detection is successful, -ENODEV otherwise */ | ||
154 | static int lm73_detect(struct i2c_client *new_client, int kind, | ||
155 | struct i2c_board_info *info) | ||
156 | { | ||
157 | struct i2c_adapter *adapter = new_client->adapter; | ||
158 | u16 id; | ||
159 | u8 ctrl; | ||
160 | |||
161 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | ||
162 | I2C_FUNC_SMBUS_WORD_DATA)) | ||
163 | return -ENODEV; | ||
164 | |||
165 | /* Check device ID */ | ||
166 | id = i2c_smbus_read_word_data(new_client, LM73_REG_ID); | ||
167 | ctrl = i2c_smbus_read_byte_data(new_client, LM73_REG_CTRL); | ||
168 | if ((id != LM73_ID) || (ctrl & 0x10)) | ||
169 | return -ENODEV; | ||
170 | |||
171 | strlcpy(info->type, "lm73", I2C_NAME_SIZE); | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static struct i2c_driver lm73_driver = { | ||
177 | .class = I2C_CLASS_HWMON, | ||
178 | .driver = { | ||
179 | .name = "lm73", | ||
180 | }, | ||
181 | .probe = lm73_probe, | ||
182 | .remove = lm73_remove, | ||
183 | .id_table = lm73_ids, | ||
184 | .detect = lm73_detect, | ||
185 | .address_data = &addr_data, | ||
186 | }; | ||
187 | |||
188 | /* module glue */ | ||
189 | |||
190 | static int __init sensors_lm73_init(void) | ||
191 | { | ||
192 | return i2c_add_driver(&lm73_driver); | ||
193 | } | ||
194 | |||
195 | static void __exit sensors_lm73_exit(void) | ||
196 | { | ||
197 | i2c_del_driver(&lm73_driver); | ||
198 | } | ||
199 | |||
200 | MODULE_AUTHOR("Guillaume Ligneul <guillaume.ligneul@gmail.com>"); | ||
201 | MODULE_DESCRIPTION("LM73 driver"); | ||
202 | MODULE_LICENSE("GPL"); | ||
203 | |||
204 | module_init(sensors_lm73_init); | ||
205 | module_exit(sensors_lm73_exit); | ||
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 55bd87c15c9a..e392548cccb8 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -239,6 +239,7 @@ static int lm75_detect(struct i2c_client *new_client, int kind, | |||
239 | { | 239 | { |
240 | struct i2c_adapter *adapter = new_client->adapter; | 240 | struct i2c_adapter *adapter = new_client->adapter; |
241 | int i; | 241 | int i; |
242 | int cur, conf, hyst, os; | ||
242 | 243 | ||
243 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 244 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
244 | I2C_FUNC_SMBUS_WORD_DATA)) | 245 | I2C_FUNC_SMBUS_WORD_DATA)) |
@@ -251,40 +252,35 @@ static int lm75_detect(struct i2c_client *new_client, int kind, | |||
251 | The cycling+unused addresses combination is not tested, | 252 | The cycling+unused addresses combination is not tested, |
252 | since it would significantly slow the detection down and would | 253 | since it would significantly slow the detection down and would |
253 | hardly add any value. */ | 254 | hardly add any value. */ |
254 | if (kind < 0) { | ||
255 | int cur, conf, hyst, os; | ||
256 | |||
257 | /* Unused addresses */ | ||
258 | cur = i2c_smbus_read_word_data(new_client, 0); | ||
259 | conf = i2c_smbus_read_byte_data(new_client, 1); | ||
260 | hyst = i2c_smbus_read_word_data(new_client, 2); | ||
261 | if (i2c_smbus_read_word_data(new_client, 4) != hyst | ||
262 | || i2c_smbus_read_word_data(new_client, 5) != hyst | ||
263 | || i2c_smbus_read_word_data(new_client, 6) != hyst | ||
264 | || i2c_smbus_read_word_data(new_client, 7) != hyst) | ||
265 | return -ENODEV; | ||
266 | os = i2c_smbus_read_word_data(new_client, 3); | ||
267 | if (i2c_smbus_read_word_data(new_client, 4) != os | ||
268 | || i2c_smbus_read_word_data(new_client, 5) != os | ||
269 | || i2c_smbus_read_word_data(new_client, 6) != os | ||
270 | || i2c_smbus_read_word_data(new_client, 7) != os) | ||
271 | return -ENODEV; | ||
272 | 255 | ||
273 | /* Unused bits */ | 256 | /* Unused addresses */ |
274 | if (conf & 0xe0) | 257 | cur = i2c_smbus_read_word_data(new_client, 0); |
275 | return -ENODEV; | 258 | conf = i2c_smbus_read_byte_data(new_client, 1); |
259 | hyst = i2c_smbus_read_word_data(new_client, 2); | ||
260 | if (i2c_smbus_read_word_data(new_client, 4) != hyst | ||
261 | || i2c_smbus_read_word_data(new_client, 5) != hyst | ||
262 | || i2c_smbus_read_word_data(new_client, 6) != hyst | ||
263 | || i2c_smbus_read_word_data(new_client, 7) != hyst) | ||
264 | return -ENODEV; | ||
265 | os = i2c_smbus_read_word_data(new_client, 3); | ||
266 | if (i2c_smbus_read_word_data(new_client, 4) != os | ||
267 | || i2c_smbus_read_word_data(new_client, 5) != os | ||
268 | || i2c_smbus_read_word_data(new_client, 6) != os | ||
269 | || i2c_smbus_read_word_data(new_client, 7) != os) | ||
270 | return -ENODEV; | ||
276 | 271 | ||
277 | /* Addresses cycling */ | 272 | /* Unused bits */ |
278 | for (i = 8; i < 0xff; i += 8) | 273 | if (conf & 0xe0) |
279 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf | 274 | return -ENODEV; |
280 | || i2c_smbus_read_word_data(new_client, i + 2) != hyst | 275 | |
281 | || i2c_smbus_read_word_data(new_client, i + 3) != os) | 276 | /* Addresses cycling */ |
282 | return -ENODEV; | 277 | for (i = 8; i < 0xff; i += 8) { |
278 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf | ||
279 | || i2c_smbus_read_word_data(new_client, i + 2) != hyst | ||
280 | || i2c_smbus_read_word_data(new_client, i + 3) != os) | ||
281 | return -ENODEV; | ||
283 | } | 282 | } |
284 | 283 | ||
285 | /* NOTE: we treat "force=..." and "force_lm75=..." the same. | ||
286 | * Only new-style driver binding distinguishes chip types. | ||
287 | */ | ||
288 | strlcpy(info->type, "lm75", I2C_NAME_SIZE); | 284 | strlcpy(info->type, "lm75", I2C_NAME_SIZE); |
289 | 285 | ||
290 | return 0; | 286 | return 0; |
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 866b401ab6e8..ac067fd19482 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -249,6 +249,7 @@ static int lm77_detect(struct i2c_client *new_client, int kind, | |||
249 | struct i2c_board_info *info) | 249 | struct i2c_board_info *info) |
250 | { | 250 | { |
251 | struct i2c_adapter *adapter = new_client->adapter; | 251 | struct i2c_adapter *adapter = new_client->adapter; |
252 | int i, cur, conf, hyst, crit, min, max; | ||
252 | 253 | ||
253 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 254 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
254 | I2C_FUNC_SMBUS_WORD_DATA)) | 255 | I2C_FUNC_SMBUS_WORD_DATA)) |
@@ -265,51 +266,48 @@ static int lm77_detect(struct i2c_client *new_client, int kind, | |||
265 | 4. registers cycling over 8-address boundaries | 266 | 4. registers cycling over 8-address boundaries |
266 | 267 | ||
267 | Word-sized registers are high-byte first. */ | 268 | Word-sized registers are high-byte first. */ |
268 | if (kind < 0) { | ||
269 | int i, cur, conf, hyst, crit, min, max; | ||
270 | |||
271 | /* addresses cycling */ | ||
272 | cur = i2c_smbus_read_word_data(new_client, 0); | ||
273 | conf = i2c_smbus_read_byte_data(new_client, 1); | ||
274 | hyst = i2c_smbus_read_word_data(new_client, 2); | ||
275 | crit = i2c_smbus_read_word_data(new_client, 3); | ||
276 | min = i2c_smbus_read_word_data(new_client, 4); | ||
277 | max = i2c_smbus_read_word_data(new_client, 5); | ||
278 | for (i = 8; i <= 0xff; i += 8) | ||
279 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf | ||
280 | || i2c_smbus_read_word_data(new_client, i + 2) != hyst | ||
281 | || i2c_smbus_read_word_data(new_client, i + 3) != crit | ||
282 | || i2c_smbus_read_word_data(new_client, i + 4) != min | ||
283 | || i2c_smbus_read_word_data(new_client, i + 5) != max) | ||
284 | return -ENODEV; | ||
285 | |||
286 | /* sign bits */ | ||
287 | if (((cur & 0x00f0) != 0xf0 && (cur & 0x00f0) != 0x0) | ||
288 | || ((hyst & 0x00f0) != 0xf0 && (hyst & 0x00f0) != 0x0) | ||
289 | || ((crit & 0x00f0) != 0xf0 && (crit & 0x00f0) != 0x0) | ||
290 | || ((min & 0x00f0) != 0xf0 && (min & 0x00f0) != 0x0) | ||
291 | || ((max & 0x00f0) != 0xf0 && (max & 0x00f0) != 0x0)) | ||
292 | return -ENODEV; | ||
293 | 269 | ||
294 | /* unused bits */ | 270 | /* addresses cycling */ |
295 | if (conf & 0xe0) | 271 | cur = i2c_smbus_read_word_data(new_client, 0); |
272 | conf = i2c_smbus_read_byte_data(new_client, 1); | ||
273 | hyst = i2c_smbus_read_word_data(new_client, 2); | ||
274 | crit = i2c_smbus_read_word_data(new_client, 3); | ||
275 | min = i2c_smbus_read_word_data(new_client, 4); | ||
276 | max = i2c_smbus_read_word_data(new_client, 5); | ||
277 | for (i = 8; i <= 0xff; i += 8) { | ||
278 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf | ||
279 | || i2c_smbus_read_word_data(new_client, i + 2) != hyst | ||
280 | || i2c_smbus_read_word_data(new_client, i + 3) != crit | ||
281 | || i2c_smbus_read_word_data(new_client, i + 4) != min | ||
282 | || i2c_smbus_read_word_data(new_client, i + 5) != max) | ||
296 | return -ENODEV; | 283 | return -ENODEV; |
284 | } | ||
297 | 285 | ||
298 | /* 0x06 and 0x07 return the last read value */ | 286 | /* sign bits */ |
299 | cur = i2c_smbus_read_word_data(new_client, 0); | 287 | if (((cur & 0x00f0) != 0xf0 && (cur & 0x00f0) != 0x0) |
300 | if (i2c_smbus_read_word_data(new_client, 6) != cur | 288 | || ((hyst & 0x00f0) != 0xf0 && (hyst & 0x00f0) != 0x0) |
301 | || i2c_smbus_read_word_data(new_client, 7) != cur) | 289 | || ((crit & 0x00f0) != 0xf0 && (crit & 0x00f0) != 0x0) |
302 | return -ENODEV; | 290 | || ((min & 0x00f0) != 0xf0 && (min & 0x00f0) != 0x0) |
303 | hyst = i2c_smbus_read_word_data(new_client, 2); | 291 | || ((max & 0x00f0) != 0xf0 && (max & 0x00f0) != 0x0)) |
304 | if (i2c_smbus_read_word_data(new_client, 6) != hyst | 292 | return -ENODEV; |
305 | || i2c_smbus_read_word_data(new_client, 7) != hyst) | ||
306 | return -ENODEV; | ||
307 | min = i2c_smbus_read_word_data(new_client, 4); | ||
308 | if (i2c_smbus_read_word_data(new_client, 6) != min | ||
309 | || i2c_smbus_read_word_data(new_client, 7) != min) | ||
310 | return -ENODEV; | ||
311 | 293 | ||
312 | } | 294 | /* unused bits */ |
295 | if (conf & 0xe0) | ||
296 | return -ENODEV; | ||
297 | |||
298 | /* 0x06 and 0x07 return the last read value */ | ||
299 | cur = i2c_smbus_read_word_data(new_client, 0); | ||
300 | if (i2c_smbus_read_word_data(new_client, 6) != cur | ||
301 | || i2c_smbus_read_word_data(new_client, 7) != cur) | ||
302 | return -ENODEV; | ||
303 | hyst = i2c_smbus_read_word_data(new_client, 2); | ||
304 | if (i2c_smbus_read_word_data(new_client, 6) != hyst | ||
305 | || i2c_smbus_read_word_data(new_client, 7) != hyst) | ||
306 | return -ENODEV; | ||
307 | min = i2c_smbus_read_word_data(new_client, 4); | ||
308 | if (i2c_smbus_read_word_data(new_client, 6) != min | ||
309 | || i2c_smbus_read_word_data(new_client, 7) != min) | ||
310 | return -ENODEV; | ||
313 | 311 | ||
314 | strlcpy(info->type, "lm77", I2C_NAME_SIZE); | 312 | strlcpy(info->type, "lm77", I2C_NAME_SIZE); |
315 | 313 | ||
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index f7e70163e016..5978291cebb3 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c | |||
@@ -576,52 +576,34 @@ static int lm78_i2c_detect(struct i2c_client *client, int kind, | |||
576 | if (isa) | 576 | if (isa) |
577 | mutex_lock(&isa->update_lock); | 577 | mutex_lock(&isa->update_lock); |
578 | 578 | ||
579 | if (kind < 0) { | 579 | if ((i2c_smbus_read_byte_data(client, LM78_REG_CONFIG) & 0x80) |
580 | if ((i2c_smbus_read_byte_data(client, LM78_REG_CONFIG) & 0x80) | 580 | || i2c_smbus_read_byte_data(client, LM78_REG_I2C_ADDR) != address) |
581 | || i2c_smbus_read_byte_data(client, LM78_REG_I2C_ADDR) | 581 | goto err_nodev; |
582 | != address) | 582 | |
583 | goto err_nodev; | 583 | /* Explicitly prevent the misdetection of Winbond chips */ |
584 | 584 | i = i2c_smbus_read_byte_data(client, 0x4f); | |
585 | /* Explicitly prevent the misdetection of Winbond chips */ | 585 | if (i == 0xa3 || i == 0x5c) |
586 | i = i2c_smbus_read_byte_data(client, 0x4f); | 586 | goto err_nodev; |
587 | if (i == 0xa3 || i == 0x5c) | ||
588 | goto err_nodev; | ||
589 | } | ||
590 | 587 | ||
591 | /* Determine the chip type. */ | 588 | /* Determine the chip type. */ |
592 | if (kind <= 0) { | 589 | i = i2c_smbus_read_byte_data(client, LM78_REG_CHIPID); |
593 | i = i2c_smbus_read_byte_data(client, LM78_REG_CHIPID); | 590 | if (i == 0x00 || i == 0x20 /* LM78 */ |
594 | if (i == 0x00 || i == 0x20 /* LM78 */ | 591 | || i == 0x40) /* LM78-J */ |
595 | || i == 0x40) /* LM78-J */ | 592 | client_name = "lm78"; |
596 | kind = lm78; | 593 | else if ((i & 0xfe) == 0xc0) |
597 | else if ((i & 0xfe) == 0xc0) | 594 | client_name = "lm79"; |
598 | kind = lm79; | 595 | else |
599 | else { | 596 | goto err_nodev; |
600 | if (kind == 0) | ||
601 | dev_warn(&adapter->dev, "Ignoring 'force' " | ||
602 | "parameter for unknown chip at " | ||
603 | "adapter %d, address 0x%02x\n", | ||
604 | i2c_adapter_id(adapter), address); | ||
605 | goto err_nodev; | ||
606 | } | ||
607 | 597 | ||
608 | if (lm78_alias_detect(client, i)) { | 598 | if (lm78_alias_detect(client, i)) { |
609 | dev_dbg(&adapter->dev, "Device at 0x%02x appears to " | 599 | dev_dbg(&adapter->dev, "Device at 0x%02x appears to " |
610 | "be the same as ISA device\n", address); | 600 | "be the same as ISA device\n", address); |
611 | goto err_nodev; | 601 | goto err_nodev; |
612 | } | ||
613 | } | 602 | } |
614 | 603 | ||
615 | if (isa) | 604 | if (isa) |
616 | mutex_unlock(&isa->update_lock); | 605 | mutex_unlock(&isa->update_lock); |
617 | 606 | ||
618 | switch (kind) { | ||
619 | case lm79: | ||
620 | client_name = "lm79"; | ||
621 | break; | ||
622 | default: | ||
623 | client_name = "lm78"; | ||
624 | } | ||
625 | strlcpy(info->type, client_name, I2C_NAME_SIZE); | 607 | strlcpy(info->type, client_name, I2C_NAME_SIZE); |
626 | 608 | ||
627 | return 0; | 609 | return 0; |
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index e59e2d1f080c..08b03e6ed0b7 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm83.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * lm83.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | * monitoring | 3 | * monitoring |
4 | * Copyright (C) 2003-2008 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2003-2009 Jean Delvare <khali@linux-fr.org> |
5 | * | 5 | * |
6 | * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is | 6 | * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is |
7 | * a sensor chip made by National Semiconductor. It reports up to four | 7 | * a sensor chip made by National Semiconductor. It reports up to four |
@@ -295,69 +295,40 @@ static int lm83_detect(struct i2c_client *new_client, int kind, | |||
295 | struct i2c_board_info *info) | 295 | struct i2c_board_info *info) |
296 | { | 296 | { |
297 | struct i2c_adapter *adapter = new_client->adapter; | 297 | struct i2c_adapter *adapter = new_client->adapter; |
298 | const char *name = ""; | 298 | const char *name; |
299 | u8 man_id, chip_id; | ||
299 | 300 | ||
300 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 301 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
301 | return -ENODEV; | 302 | return -ENODEV; |
302 | 303 | ||
303 | /* Now we do the detection and identification. A negative kind | 304 | /* Detection */ |
304 | * means that the driver was loaded with no force parameter | 305 | if ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS1) & 0xA8) || |
305 | * (default), so we must both detect and identify the chip | 306 | (i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS2) & 0x48) || |
306 | * (actually there is only one possible kind of chip for now, LM83). | 307 | (i2c_smbus_read_byte_data(new_client, LM83_REG_R_CONFIG) & 0x41)) { |
307 | * A zero kind means that the driver was loaded with the force | 308 | dev_dbg(&adapter->dev, "LM83 detection failed at 0x%02x\n", |
308 | * parameter, the detection step shall be skipped. A positive kind | 309 | new_client->addr); |
309 | * means that the driver was loaded with the force parameter and a | 310 | return -ENODEV; |
310 | * given kind of chip is requested, so both the detection and the | ||
311 | * identification steps are skipped. */ | ||
312 | |||
313 | /* Default to an LM83 if forced */ | ||
314 | if (kind == 0) | ||
315 | kind = lm83; | ||
316 | |||
317 | if (kind < 0) { /* detection */ | ||
318 | if (((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS1) | ||
319 | & 0xA8) != 0x00) || | ||
320 | ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS2) | ||
321 | & 0x48) != 0x00) || | ||
322 | ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_CONFIG) | ||
323 | & 0x41) != 0x00)) { | ||
324 | dev_dbg(&adapter->dev, | ||
325 | "LM83 detection failed at 0x%02x.\n", | ||
326 | new_client->addr); | ||
327 | return -ENODEV; | ||
328 | } | ||
329 | } | 311 | } |
330 | 312 | ||
331 | if (kind <= 0) { /* identification */ | 313 | /* Identification */ |
332 | u8 man_id, chip_id; | 314 | man_id = i2c_smbus_read_byte_data(new_client, LM83_REG_R_MAN_ID); |
333 | 315 | if (man_id != 0x01) /* National Semiconductor */ | |
334 | man_id = i2c_smbus_read_byte_data(new_client, | 316 | return -ENODEV; |
335 | LM83_REG_R_MAN_ID); | ||
336 | chip_id = i2c_smbus_read_byte_data(new_client, | ||
337 | LM83_REG_R_CHIP_ID); | ||
338 | |||
339 | if (man_id == 0x01) { /* National Semiconductor */ | ||
340 | if (chip_id == 0x03) { | ||
341 | kind = lm83; | ||
342 | } else | ||
343 | if (chip_id == 0x01) { | ||
344 | kind = lm82; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | if (kind <= 0) { /* identification failed */ | ||
349 | dev_info(&adapter->dev, | ||
350 | "Unsupported chip (man_id=0x%02X, " | ||
351 | "chip_id=0x%02X).\n", man_id, chip_id); | ||
352 | return -ENODEV; | ||
353 | } | ||
354 | } | ||
355 | 317 | ||
356 | if (kind == lm83) { | 318 | chip_id = i2c_smbus_read_byte_data(new_client, LM83_REG_R_CHIP_ID); |
319 | switch (chip_id) { | ||
320 | case 0x03: | ||
357 | name = "lm83"; | 321 | name = "lm83"; |
358 | } else | 322 | break; |
359 | if (kind == lm82) { | 323 | case 0x01: |
360 | name = "lm82"; | 324 | name = "lm82"; |
325 | break; | ||
326 | default: | ||
327 | /* identification failed */ | ||
328 | dev_info(&adapter->dev, | ||
329 | "Unsupported chip (man_id=0x%02X, chip_id=0x%02X)\n", | ||
330 | man_id, chip_id); | ||
331 | return -ENODEV; | ||
361 | } | 332 | } |
362 | 333 | ||
363 | strlcpy(info->type, name, I2C_NAME_SIZE); | 334 | strlcpy(info->type, name, I2C_NAME_SIZE); |
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 6c53d987de10..d56da2e74708 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -5,7 +5,7 @@ | |||
5 | Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com> | 5 | Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com> |
6 | Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de> | 6 | Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de> |
7 | Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com> | 7 | Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com> |
8 | Copyright (C) 2007, 2008 Jean Delvare <khali@linux-fr.org> | 8 | Copyright (C) 2007--2009 Jean Delvare <khali@linux-fr.org> |
9 | 9 | ||
10 | Chip details at <http://www.national.com/ds/LM/LM85.pdf> | 10 | Chip details at <http://www.national.com/ds/LM/LM85.pdf> |
11 | 11 | ||
@@ -1162,107 +1162,80 @@ static int lm85_detect(struct i2c_client *client, int kind, | |||
1162 | struct i2c_adapter *adapter = client->adapter; | 1162 | struct i2c_adapter *adapter = client->adapter; |
1163 | int address = client->addr; | 1163 | int address = client->addr; |
1164 | const char *type_name; | 1164 | const char *type_name; |
1165 | int company, verstep; | ||
1165 | 1166 | ||
1166 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 1167 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
1167 | /* We need to be able to do byte I/O */ | 1168 | /* We need to be able to do byte I/O */ |
1168 | return -ENODEV; | 1169 | return -ENODEV; |
1169 | } | 1170 | } |
1170 | 1171 | ||
1171 | /* If auto-detecting, determine the chip type */ | 1172 | /* Determine the chip type */ |
1172 | if (kind < 0) { | 1173 | company = lm85_read_value(client, LM85_REG_COMPANY); |
1173 | int company = lm85_read_value(client, LM85_REG_COMPANY); | 1174 | verstep = lm85_read_value(client, LM85_REG_VERSTEP); |
1174 | int verstep = lm85_read_value(client, LM85_REG_VERSTEP); | 1175 | |
1175 | 1176 | dev_dbg(&adapter->dev, "Detecting device at 0x%02x with " | |
1176 | dev_dbg(&adapter->dev, "Detecting device at 0x%02x with " | 1177 | "COMPANY: 0x%02x and VERSTEP: 0x%02x\n", |
1177 | "COMPANY: 0x%02x and VERSTEP: 0x%02x\n", | 1178 | address, company, verstep); |
1178 | address, company, verstep); | 1179 | |
1179 | 1180 | /* All supported chips have the version in common */ | |
1180 | /* All supported chips have the version in common */ | 1181 | if ((verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC && |
1181 | if ((verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC && | 1182 | (verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC2) { |
1182 | (verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC2) { | 1183 | dev_dbg(&adapter->dev, |
1183 | dev_dbg(&adapter->dev, "Autodetection failed: " | 1184 | "Autodetection failed: unsupported version\n"); |
1184 | "unsupported version\n"); | 1185 | return -ENODEV; |
1185 | return -ENODEV; | 1186 | } |
1186 | } | 1187 | type_name = "lm85"; |
1187 | kind = any_chip; | 1188 | |
1188 | 1189 | /* Now, refine the detection */ | |
1189 | /* Now, refine the detection */ | 1190 | if (company == LM85_COMPANY_NATIONAL) { |
1190 | if (company == LM85_COMPANY_NATIONAL) { | 1191 | switch (verstep) { |
1191 | switch (verstep) { | 1192 | case LM85_VERSTEP_LM85C: |
1192 | case LM85_VERSTEP_LM85C: | 1193 | type_name = "lm85c"; |
1193 | kind = lm85c; | 1194 | break; |
1194 | break; | 1195 | case LM85_VERSTEP_LM85B: |
1195 | case LM85_VERSTEP_LM85B: | 1196 | type_name = "lm85b"; |
1196 | kind = lm85b; | 1197 | break; |
1197 | break; | 1198 | case LM85_VERSTEP_LM96000_1: |
1198 | case LM85_VERSTEP_LM96000_1: | 1199 | case LM85_VERSTEP_LM96000_2: |
1199 | case LM85_VERSTEP_LM96000_2: | 1200 | /* Check for Winbond WPCD377I */ |
1200 | /* Check for Winbond WPCD377I */ | 1201 | if (lm85_is_fake(client)) { |
1201 | if (lm85_is_fake(client)) { | 1202 | dev_dbg(&adapter->dev, |
1202 | dev_dbg(&adapter->dev, | 1203 | "Found Winbond WPCD377I, ignoring\n"); |
1203 | "Found Winbond WPCD377I, " | 1204 | return -ENODEV; |
1204 | "ignoring\n"); | ||
1205 | return -ENODEV; | ||
1206 | } | ||
1207 | break; | ||
1208 | } | ||
1209 | } else if (company == LM85_COMPANY_ANALOG_DEV) { | ||
1210 | switch (verstep) { | ||
1211 | case LM85_VERSTEP_ADM1027: | ||
1212 | kind = adm1027; | ||
1213 | break; | ||
1214 | case LM85_VERSTEP_ADT7463: | ||
1215 | case LM85_VERSTEP_ADT7463C: | ||
1216 | kind = adt7463; | ||
1217 | break; | ||
1218 | case LM85_VERSTEP_ADT7468_1: | ||
1219 | case LM85_VERSTEP_ADT7468_2: | ||
1220 | kind = adt7468; | ||
1221 | break; | ||
1222 | } | ||
1223 | } else if (company == LM85_COMPANY_SMSC) { | ||
1224 | switch (verstep) { | ||
1225 | case LM85_VERSTEP_EMC6D100_A0: | ||
1226 | case LM85_VERSTEP_EMC6D100_A1: | ||
1227 | /* Note: we can't tell a '100 from a '101 */ | ||
1228 | kind = emc6d100; | ||
1229 | break; | ||
1230 | case LM85_VERSTEP_EMC6D102: | ||
1231 | kind = emc6d102; | ||
1232 | break; | ||
1233 | } | 1205 | } |
1234 | } else { | 1206 | break; |
1235 | dev_dbg(&adapter->dev, "Autodetection failed: " | 1207 | } |
1236 | "unknown vendor\n"); | 1208 | } else if (company == LM85_COMPANY_ANALOG_DEV) { |
1237 | return -ENODEV; | 1209 | switch (verstep) { |
1210 | case LM85_VERSTEP_ADM1027: | ||
1211 | type_name = "adm1027"; | ||
1212 | break; | ||
1213 | case LM85_VERSTEP_ADT7463: | ||
1214 | case LM85_VERSTEP_ADT7463C: | ||
1215 | type_name = "adt7463"; | ||
1216 | break; | ||
1217 | case LM85_VERSTEP_ADT7468_1: | ||
1218 | case LM85_VERSTEP_ADT7468_2: | ||
1219 | type_name = "adt7468"; | ||
1220 | break; | ||
1238 | } | 1221 | } |
1222 | } else if (company == LM85_COMPANY_SMSC) { | ||
1223 | switch (verstep) { | ||
1224 | case LM85_VERSTEP_EMC6D100_A0: | ||
1225 | case LM85_VERSTEP_EMC6D100_A1: | ||
1226 | /* Note: we can't tell a '100 from a '101 */ | ||
1227 | type_name = "emc6d100"; | ||
1228 | break; | ||
1229 | case LM85_VERSTEP_EMC6D102: | ||
1230 | type_name = "emc6d102"; | ||
1231 | break; | ||
1232 | } | ||
1233 | } else { | ||
1234 | dev_dbg(&adapter->dev, | ||
1235 | "Autodetection failed: unknown vendor\n"); | ||
1236 | return -ENODEV; | ||
1239 | } | 1237 | } |
1240 | 1238 | ||
1241 | switch (kind) { | ||
1242 | case lm85b: | ||
1243 | type_name = "lm85b"; | ||
1244 | break; | ||
1245 | case lm85c: | ||
1246 | type_name = "lm85c"; | ||
1247 | break; | ||
1248 | case adm1027: | ||
1249 | type_name = "adm1027"; | ||
1250 | break; | ||
1251 | case adt7463: | ||
1252 | type_name = "adt7463"; | ||
1253 | break; | ||
1254 | case adt7468: | ||
1255 | type_name = "adt7468"; | ||
1256 | break; | ||
1257 | case emc6d100: | ||
1258 | type_name = "emc6d100"; | ||
1259 | break; | ||
1260 | case emc6d102: | ||
1261 | type_name = "emc6d102"; | ||
1262 | break; | ||
1263 | default: | ||
1264 | type_name = "lm85"; | ||
1265 | } | ||
1266 | strlcpy(info->type, type_name, I2C_NAME_SIZE); | 1239 | strlcpy(info->type, type_name, I2C_NAME_SIZE); |
1267 | 1240 | ||
1268 | return 0; | 1241 | return 0; |
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 2e4a3cea95f7..4929b1815eee 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -666,37 +666,32 @@ static int lm87_detect(struct i2c_client *new_client, int kind, | |||
666 | struct i2c_board_info *info) | 666 | struct i2c_board_info *info) |
667 | { | 667 | { |
668 | struct i2c_adapter *adapter = new_client->adapter; | 668 | struct i2c_adapter *adapter = new_client->adapter; |
669 | static const char *names[] = { "lm87", "adm1024" }; | 669 | const char *name; |
670 | u8 cid, rev; | ||
670 | 671 | ||
671 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 672 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
672 | return -ENODEV; | 673 | return -ENODEV; |
673 | 674 | ||
674 | /* Default to an LM87 if forced */ | 675 | if (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80) |
675 | if (kind == 0) | 676 | return -ENODEV; |
676 | kind = lm87; | ||
677 | 677 | ||
678 | /* Now, we do the remaining detection. */ | 678 | /* Now, we do the remaining detection. */ |
679 | if (kind < 0) { | 679 | cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID); |
680 | u8 cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID); | 680 | rev = lm87_read_value(new_client, LM87_REG_REVISION); |
681 | u8 rev = lm87_read_value(new_client, LM87_REG_REVISION); | 681 | |
682 | 682 | if (cid == 0x02 /* National Semiconductor */ | |
683 | if (cid == 0x02 /* National Semiconductor */ | 683 | && (rev >= 0x01 && rev <= 0x08)) |
684 | && (rev >= 0x01 && rev <= 0x08)) | 684 | name = "lm87"; |
685 | kind = lm87; | 685 | else if (cid == 0x41 /* Analog Devices */ |
686 | else if (cid == 0x41 /* Analog Devices */ | 686 | && (rev & 0xf0) == 0x10) |
687 | && (rev & 0xf0) == 0x10) | 687 | name = "adm1024"; |
688 | kind = adm1024; | 688 | else { |
689 | 689 | dev_dbg(&adapter->dev, "LM87 detection failed at 0x%02x\n", | |
690 | if (kind < 0 | 690 | new_client->addr); |
691 | || (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80)) { | 691 | return -ENODEV; |
692 | dev_dbg(&adapter->dev, | ||
693 | "LM87 detection failed at 0x%02x.\n", | ||
694 | new_client->addr); | ||
695 | return -ENODEV; | ||
696 | } | ||
697 | } | 692 | } |
698 | 693 | ||
699 | strlcpy(info->type, names[kind - 1], I2C_NAME_SIZE); | 694 | strlcpy(info->type, name, I2C_NAME_SIZE); |
700 | 695 | ||
701 | return 0; | 696 | return 0; |
702 | } | 697 | } |
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 1aff7575799d..b7c905f50ed4 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm90.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * lm90.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | * monitoring | 3 | * monitoring |
4 | * Copyright (C) 2003-2008 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2003-2009 Jean Delvare <khali@linux-fr.org> |
5 | * | 5 | * |
6 | * Based on the lm83 driver. The LM90 is a sensor chip made by National | 6 | * Based on the lm83 driver. The LM90 is a sensor chip made by National |
7 | * Semiconductor. It reports up to two temperatures (its own plus up to | 7 | * Semiconductor. It reports up to two temperatures (its own plus up to |
@@ -661,154 +661,118 @@ static int lm90_detect(struct i2c_client *new_client, int kind, | |||
661 | { | 661 | { |
662 | struct i2c_adapter *adapter = new_client->adapter; | 662 | struct i2c_adapter *adapter = new_client->adapter; |
663 | int address = new_client->addr; | 663 | int address = new_client->addr; |
664 | const char *name = ""; | 664 | const char *name = NULL; |
665 | int man_id, chip_id, reg_config1, reg_convrate; | ||
665 | 666 | ||
666 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 667 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
667 | return -ENODEV; | 668 | return -ENODEV; |
668 | 669 | ||
669 | /* | 670 | /* detection and identification */ |
670 | * Now we do the remaining detection. A negative kind means that | 671 | if ((man_id = i2c_smbus_read_byte_data(new_client, |
671 | * the driver was loaded with no force parameter (default), so we | ||
672 | * must both detect and identify the chip. A zero kind means that | ||
673 | * the driver was loaded with the force parameter, the detection | ||
674 | * step shall be skipped. A positive kind means that the driver | ||
675 | * was loaded with the force parameter and a given kind of chip is | ||
676 | * requested, so both the detection and the identification steps | ||
677 | * are skipped. | ||
678 | */ | ||
679 | |||
680 | /* Default to an LM90 if forced */ | ||
681 | if (kind == 0) | ||
682 | kind = lm90; | ||
683 | |||
684 | if (kind < 0) { /* detection and identification */ | ||
685 | int man_id, chip_id, reg_config1, reg_convrate; | ||
686 | |||
687 | if ((man_id = i2c_smbus_read_byte_data(new_client, | ||
688 | LM90_REG_R_MAN_ID)) < 0 | 672 | LM90_REG_R_MAN_ID)) < 0 |
689 | || (chip_id = i2c_smbus_read_byte_data(new_client, | 673 | || (chip_id = i2c_smbus_read_byte_data(new_client, |
690 | LM90_REG_R_CHIP_ID)) < 0 | 674 | LM90_REG_R_CHIP_ID)) < 0 |
691 | || (reg_config1 = i2c_smbus_read_byte_data(new_client, | 675 | || (reg_config1 = i2c_smbus_read_byte_data(new_client, |
692 | LM90_REG_R_CONFIG1)) < 0 | 676 | LM90_REG_R_CONFIG1)) < 0 |
693 | || (reg_convrate = i2c_smbus_read_byte_data(new_client, | 677 | || (reg_convrate = i2c_smbus_read_byte_data(new_client, |
694 | LM90_REG_R_CONVRATE)) < 0) | 678 | LM90_REG_R_CONVRATE)) < 0) |
679 | return -ENODEV; | ||
680 | |||
681 | if ((address == 0x4C || address == 0x4D) | ||
682 | && man_id == 0x01) { /* National Semiconductor */ | ||
683 | int reg_config2; | ||
684 | |||
685 | reg_config2 = i2c_smbus_read_byte_data(new_client, | ||
686 | LM90_REG_R_CONFIG2); | ||
687 | if (reg_config2 < 0) | ||
695 | return -ENODEV; | 688 | return -ENODEV; |
696 | 689 | ||
697 | if ((address == 0x4C || address == 0x4D) | 690 | if ((reg_config1 & 0x2A) == 0x00 |
698 | && man_id == 0x01) { /* National Semiconductor */ | 691 | && (reg_config2 & 0xF8) == 0x00 |
699 | int reg_config2; | 692 | && reg_convrate <= 0x09) { |
700 | 693 | if (address == 0x4C | |
701 | if ((reg_config2 = i2c_smbus_read_byte_data(new_client, | 694 | && (chip_id & 0xF0) == 0x20) { /* LM90 */ |
702 | LM90_REG_R_CONFIG2)) < 0) | 695 | name = "lm90"; |
703 | return -ENODEV; | ||
704 | |||
705 | if ((reg_config1 & 0x2A) == 0x00 | ||
706 | && (reg_config2 & 0xF8) == 0x00 | ||
707 | && reg_convrate <= 0x09) { | ||
708 | if (address == 0x4C | ||
709 | && (chip_id & 0xF0) == 0x20) { /* LM90 */ | ||
710 | kind = lm90; | ||
711 | } else | ||
712 | if ((chip_id & 0xF0) == 0x30) { /* LM89/LM99 */ | ||
713 | kind = lm99; | ||
714 | dev_info(&adapter->dev, | ||
715 | "Assuming LM99 chip at " | ||
716 | "0x%02x\n", address); | ||
717 | dev_info(&adapter->dev, | ||
718 | "If it is an LM89, pass " | ||
719 | "force_lm86=%d,0x%02x when " | ||
720 | "loading the lm90 driver\n", | ||
721 | i2c_adapter_id(adapter), | ||
722 | address); | ||
723 | } else | ||
724 | if (address == 0x4C | ||
725 | && (chip_id & 0xF0) == 0x10) { /* LM86 */ | ||
726 | kind = lm86; | ||
727 | } | ||
728 | } | ||
729 | } else | ||
730 | if ((address == 0x4C || address == 0x4D) | ||
731 | && man_id == 0x41) { /* Analog Devices */ | ||
732 | if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ | ||
733 | && (reg_config1 & 0x3F) == 0x00 | ||
734 | && reg_convrate <= 0x0A) { | ||
735 | kind = adm1032; | ||
736 | } else | ||
737 | if (chip_id == 0x51 /* ADT7461 */ | ||
738 | && (reg_config1 & 0x1B) == 0x00 | ||
739 | && reg_convrate <= 0x0A) { | ||
740 | kind = adt7461; | ||
741 | } | ||
742 | } else | ||
743 | if (man_id == 0x4D) { /* Maxim */ | ||
744 | /* | ||
745 | * The MAX6657, MAX6658 and MAX6659 do NOT have a | ||
746 | * chip_id register. Reading from that address will | ||
747 | * return the last read value, which in our case is | ||
748 | * those of the man_id register. Likewise, the config1 | ||
749 | * register seems to lack a low nibble, so the value | ||
750 | * will be those of the previous read, so in our case | ||
751 | * those of the man_id register. | ||
752 | */ | ||
753 | if (chip_id == man_id | ||
754 | && (address == 0x4C || address == 0x4D) | ||
755 | && (reg_config1 & 0x1F) == (man_id & 0x0F) | ||
756 | && reg_convrate <= 0x09) { | ||
757 | kind = max6657; | ||
758 | } else | 696 | } else |
759 | /* The chip_id register of the MAX6680 and MAX6681 | 697 | if ((chip_id & 0xF0) == 0x30) { /* LM89/LM99 */ |
760 | * holds the revision of the chip. | 698 | name = "lm99"; |
761 | * the lowest bit of the config1 register is unused | 699 | dev_info(&adapter->dev, |
762 | * and should return zero when read, so should the | 700 | "Assuming LM99 chip at 0x%02x\n", |
763 | * second to last bit of config1 (software reset) | 701 | address); |
764 | */ | 702 | dev_info(&adapter->dev, |
765 | if (chip_id == 0x01 | 703 | "If it is an LM89, instantiate it " |
766 | && (reg_config1 & 0x03) == 0x00 | 704 | "with the new_device sysfs " |
767 | && reg_convrate <= 0x07) { | 705 | "interface\n"); |
768 | kind = max6680; | ||
769 | } else | 706 | } else |
770 | /* The chip_id register of the MAX6646/6647/6649 | 707 | if (address == 0x4C |
771 | * holds the revision of the chip. | 708 | && (chip_id & 0xF0) == 0x10) { /* LM86 */ |
772 | * The lowest 6 bits of the config1 register are | 709 | name = "lm86"; |
773 | * unused and should return zero when read. | ||
774 | */ | ||
775 | if (chip_id == 0x59 | ||
776 | && (reg_config1 & 0x3f) == 0x00 | ||
777 | && reg_convrate <= 0x07) { | ||
778 | kind = max6646; | ||
779 | } | 710 | } |
780 | } | 711 | } |
781 | 712 | } else | |
782 | if (kind <= 0) { /* identification failed */ | 713 | if ((address == 0x4C || address == 0x4D) |
783 | dev_dbg(&adapter->dev, | 714 | && man_id == 0x41) { /* Analog Devices */ |
784 | "Unsupported chip at 0x%02x (man_id=0x%02X, " | 715 | if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ |
785 | "chip_id=0x%02X)\n", address, man_id, chip_id); | 716 | && (reg_config1 & 0x3F) == 0x00 |
786 | return -ENODEV; | 717 | && reg_convrate <= 0x0A) { |
718 | name = "adm1032"; | ||
719 | /* The ADM1032 supports PEC, but only if combined | ||
720 | transactions are not used. */ | ||
721 | if (i2c_check_functionality(adapter, | ||
722 | I2C_FUNC_SMBUS_BYTE)) | ||
723 | info->flags |= I2C_CLIENT_PEC; | ||
724 | } else | ||
725 | if (chip_id == 0x51 /* ADT7461 */ | ||
726 | && (reg_config1 & 0x1B) == 0x00 | ||
727 | && reg_convrate <= 0x0A) { | ||
728 | name = "adt7461"; | ||
729 | } | ||
730 | } else | ||
731 | if (man_id == 0x4D) { /* Maxim */ | ||
732 | /* | ||
733 | * The MAX6657, MAX6658 and MAX6659 do NOT have a chip_id | ||
734 | * register. Reading from that address will return the last | ||
735 | * read value, which in our case is those of the man_id | ||
736 | * register. Likewise, the config1 register seems to lack a | ||
737 | * low nibble, so the value will be those of the previous | ||
738 | * read, so in our case those of the man_id register. | ||
739 | */ | ||
740 | if (chip_id == man_id | ||
741 | && (address == 0x4C || address == 0x4D) | ||
742 | && (reg_config1 & 0x1F) == (man_id & 0x0F) | ||
743 | && reg_convrate <= 0x09) { | ||
744 | name = "max6657"; | ||
745 | } else | ||
746 | /* | ||
747 | * The chip_id register of the MAX6680 and MAX6681 holds the | ||
748 | * revision of the chip. The lowest bit of the config1 register | ||
749 | * is unused and should return zero when read, so should the | ||
750 | * second to last bit of config1 (software reset). | ||
751 | */ | ||
752 | if (chip_id == 0x01 | ||
753 | && (reg_config1 & 0x03) == 0x00 | ||
754 | && reg_convrate <= 0x07) { | ||
755 | name = "max6680"; | ||
756 | } else | ||
757 | /* | ||
758 | * The chip_id register of the MAX6646/6647/6649 holds the | ||
759 | * revision of the chip. The lowest 6 bits of the config1 | ||
760 | * register are unused and should return zero when read. | ||
761 | */ | ||
762 | if (chip_id == 0x59 | ||
763 | && (reg_config1 & 0x3f) == 0x00 | ||
764 | && reg_convrate <= 0x07) { | ||
765 | name = "max6646"; | ||
787 | } | 766 | } |
788 | } | 767 | } |
789 | 768 | ||
790 | /* Fill the i2c board info */ | 769 | if (!name) { /* identification failed */ |
791 | if (kind == lm90) { | 770 | dev_dbg(&adapter->dev, |
792 | name = "lm90"; | 771 | "Unsupported chip at 0x%02x (man_id=0x%02X, " |
793 | } else if (kind == adm1032) { | 772 | "chip_id=0x%02X)\n", address, man_id, chip_id); |
794 | name = "adm1032"; | 773 | return -ENODEV; |
795 | /* The ADM1032 supports PEC, but only if combined | ||
796 | transactions are not used. */ | ||
797 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) | ||
798 | info->flags |= I2C_CLIENT_PEC; | ||
799 | } else if (kind == lm99) { | ||
800 | name = "lm99"; | ||
801 | } else if (kind == lm86) { | ||
802 | name = "lm86"; | ||
803 | } else if (kind == max6657) { | ||
804 | name = "max6657"; | ||
805 | } else if (kind == max6680) { | ||
806 | name = "max6680"; | ||
807 | } else if (kind == adt7461) { | ||
808 | name = "adt7461"; | ||
809 | } else if (kind == max6646) { | ||
810 | name = "max6646"; | ||
811 | } | 774 | } |
775 | |||
812 | strlcpy(info->type, name, I2C_NAME_SIZE); | 776 | strlcpy(info->type, name, I2C_NAME_SIZE); |
813 | 777 | ||
814 | return 0; | 778 | return 0; |
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index b2e00c5a7eec..47ac698709dc 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -323,31 +323,22 @@ static int lm92_detect(struct i2c_client *new_client, int kind, | |||
323 | struct i2c_board_info *info) | 323 | struct i2c_board_info *info) |
324 | { | 324 | { |
325 | struct i2c_adapter *adapter = new_client->adapter; | 325 | struct i2c_adapter *adapter = new_client->adapter; |
326 | u8 config; | ||
327 | u16 man_id; | ||
326 | 328 | ||
327 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | 329 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
328 | | I2C_FUNC_SMBUS_WORD_DATA)) | 330 | | I2C_FUNC_SMBUS_WORD_DATA)) |
329 | return -ENODEV; | 331 | return -ENODEV; |
330 | 332 | ||
331 | /* A negative kind means that the driver was loaded with no force | 333 | config = i2c_smbus_read_byte_data(new_client, LM92_REG_CONFIG); |
332 | parameter (default), so we must identify the chip. */ | 334 | man_id = i2c_smbus_read_word_data(new_client, LM92_REG_MAN_ID); |
333 | if (kind < 0) { | 335 | |
334 | u8 config = i2c_smbus_read_byte_data(new_client, | 336 | if ((config & 0xe0) == 0x00 && man_id == 0x0180) |
335 | LM92_REG_CONFIG); | 337 | pr_info("lm92: Found National Semiconductor LM92 chip\n"); |
336 | u16 man_id = i2c_smbus_read_word_data(new_client, | 338 | else if (max6635_check(new_client)) |
337 | LM92_REG_MAN_ID); | 339 | pr_info("lm92: Found Maxim MAX6635 chip\n"); |
338 | 340 | else | |
339 | if ((config & 0xe0) == 0x00 | 341 | return -ENODEV; |
340 | && man_id == 0x0180) { | ||
341 | pr_info("lm92: Found National Semiconductor LM92 chip\n"); | ||
342 | kind = lm92; | ||
343 | } else | ||
344 | if (max6635_check(new_client)) { | ||
345 | pr_info("lm92: Found Maxim MAX6635 chip\n"); | ||
346 | kind = lm92; /* No separate prefix */ | ||
347 | } | ||
348 | else | ||
349 | return -ENODEV; | ||
350 | } | ||
351 | 342 | ||
352 | strlcpy(info->type, "lm92", I2C_NAME_SIZE); | 343 | strlcpy(info->type, "lm92", I2C_NAME_SIZE); |
353 | 344 | ||
diff --git a/drivers/hwmon/lm93.c b/drivers/hwmon/lm93.c index c48a284b8314..124dd7cea54c 100644 --- a/drivers/hwmon/lm93.c +++ b/drivers/hwmon/lm93.c | |||
@@ -2505,34 +2505,24 @@ static int lm93_detect(struct i2c_client *client, int kind, | |||
2505 | struct i2c_board_info *info) | 2505 | struct i2c_board_info *info) |
2506 | { | 2506 | { |
2507 | struct i2c_adapter *adapter = client->adapter; | 2507 | struct i2c_adapter *adapter = client->adapter; |
2508 | int mfr, ver; | ||
2508 | 2509 | ||
2509 | if (!i2c_check_functionality(adapter, LM93_SMBUS_FUNC_MIN)) | 2510 | if (!i2c_check_functionality(adapter, LM93_SMBUS_FUNC_MIN)) |
2510 | return -ENODEV; | 2511 | return -ENODEV; |
2511 | 2512 | ||
2512 | /* detection */ | 2513 | /* detection */ |
2513 | if (kind < 0) { | 2514 | mfr = lm93_read_byte(client, LM93_REG_MFR_ID); |
2514 | int mfr = lm93_read_byte(client, LM93_REG_MFR_ID); | 2515 | if (mfr != 0x01) { |
2515 | 2516 | dev_dbg(&adapter->dev, | |
2516 | if (mfr != 0x01) { | 2517 | "detect failed, bad manufacturer id 0x%02x!\n", mfr); |
2517 | dev_dbg(&adapter->dev,"detect failed, " | 2518 | return -ENODEV; |
2518 | "bad manufacturer id 0x%02x!\n", mfr); | ||
2519 | return -ENODEV; | ||
2520 | } | ||
2521 | } | 2519 | } |
2522 | 2520 | ||
2523 | if (kind <= 0) { | 2521 | ver = lm93_read_byte(client, LM93_REG_VER); |
2524 | int ver = lm93_read_byte(client, LM93_REG_VER); | 2522 | if (ver != LM93_MFR_ID && ver != LM93_MFR_ID_PROTOTYPE) { |
2525 | 2523 | dev_dbg(&adapter->dev, | |
2526 | if ((ver == LM93_MFR_ID) || (ver == LM93_MFR_ID_PROTOTYPE)) { | 2524 | "detect failed, bad version id 0x%02x!\n", ver); |
2527 | kind = lm93; | 2525 | return -ENODEV; |
2528 | } else { | ||
2529 | dev_dbg(&adapter->dev,"detect failed, " | ||
2530 | "bad version id 0x%02x!\n", ver); | ||
2531 | if (kind == 0) | ||
2532 | dev_dbg(&adapter->dev, | ||
2533 | "(ignored 'force' parameter)\n"); | ||
2534 | return -ENODEV; | ||
2535 | } | ||
2536 | } | 2526 | } |
2537 | 2527 | ||
2538 | strlcpy(info->type, "lm93", I2C_NAME_SIZE); | 2528 | strlcpy(info->type, "lm93", I2C_NAME_SIZE); |
diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c index e34f9e402a2c..906b896cf1d0 100644 --- a/drivers/hwmon/lm95241.c +++ b/drivers/hwmon/lm95241.c | |||
@@ -315,51 +315,23 @@ static int lm95241_detect(struct i2c_client *new_client, int kind, | |||
315 | { | 315 | { |
316 | struct i2c_adapter *adapter = new_client->adapter; | 316 | struct i2c_adapter *adapter = new_client->adapter; |
317 | int address = new_client->addr; | 317 | int address = new_client->addr; |
318 | const char *name = ""; | 318 | const char *name; |
319 | 319 | ||
320 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 320 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
321 | return -ENODEV; | 321 | return -ENODEV; |
322 | 322 | ||
323 | /* | 323 | if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) |
324 | * Now we do the remaining detection. A negative kind means that | 324 | == MANUFACTURER_ID) |
325 | * the driver was loaded with no force parameter (default), so we | 325 | && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) |
326 | * must both detect and identify the chip. A zero kind means that | 326 | >= DEFAULT_REVISION)) { |
327 | * the driver was loaded with the force parameter, the detection | 327 | name = "lm95241"; |
328 | * step shall be skipped. A positive kind means that the driver | 328 | } else { |
329 | * was loaded with the force parameter and a given kind of chip is | 329 | dev_dbg(&adapter->dev, "LM95241 detection failed at 0x%02x\n", |
330 | * requested, so both the detection and the identification steps | 330 | address); |
331 | * are skipped. | 331 | return -ENODEV; |
332 | */ | ||
333 | if (kind < 0) { /* detection */ | ||
334 | if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) | ||
335 | != MANUFACTURER_ID) | ||
336 | || (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) | ||
337 | < DEFAULT_REVISION)) { | ||
338 | dev_dbg(&adapter->dev, | ||
339 | "LM95241 detection failed at 0x%02x.\n", | ||
340 | address); | ||
341 | return -ENODEV; | ||
342 | } | ||
343 | } | ||
344 | |||
345 | if (kind <= 0) { /* identification */ | ||
346 | if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) | ||
347 | == MANUFACTURER_ID) | ||
348 | && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) | ||
349 | >= DEFAULT_REVISION)) { | ||
350 | |||
351 | kind = lm95241; | ||
352 | |||
353 | if (kind <= 0) { /* identification failed */ | ||
354 | dev_info(&adapter->dev, "Unsupported chip\n"); | ||
355 | return -ENODEV; | ||
356 | } | ||
357 | } | ||
358 | } | 332 | } |
359 | 333 | ||
360 | /* Fill the i2c board info */ | 334 | /* Fill the i2c board info */ |
361 | if (kind == lm95241) | ||
362 | name = "lm95241"; | ||
363 | strlcpy(info->type, name, I2C_NAME_SIZE); | 335 | strlcpy(info->type, name, I2C_NAME_SIZE); |
364 | return 0; | 336 | return 0; |
365 | } | 337 | } |
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 7897754f3a5c..7fcf5ff89e7f 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -226,58 +226,34 @@ static const struct attribute_group max1619_group = { | |||
226 | */ | 226 | */ |
227 | 227 | ||
228 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 228 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
229 | static int max1619_detect(struct i2c_client *new_client, int kind, | 229 | static int max1619_detect(struct i2c_client *client, int kind, |
230 | struct i2c_board_info *info) | 230 | struct i2c_board_info *info) |
231 | { | 231 | { |
232 | struct i2c_adapter *adapter = new_client->adapter; | 232 | struct i2c_adapter *adapter = client->adapter; |
233 | u8 reg_config=0, reg_convrate=0, reg_status=0; | 233 | u8 reg_config, reg_convrate, reg_status, man_id, chip_id; |
234 | 234 | ||
235 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 235 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
236 | return -ENODEV; | 236 | return -ENODEV; |
237 | 237 | ||
238 | /* | 238 | /* detection */ |
239 | * Now we do the remaining detection. A negative kind means that | 239 | reg_config = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CONFIG); |
240 | * the driver was loaded with no force parameter (default), so we | 240 | reg_convrate = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CONVRATE); |
241 | * must both detect and identify the chip. A zero kind means that | 241 | reg_status = i2c_smbus_read_byte_data(client, MAX1619_REG_R_STATUS); |
242 | * the driver was loaded with the force parameter, the detection | 242 | if ((reg_config & 0x03) != 0x00 |
243 | * step shall be skipped. A positive kind means that the driver | 243 | || reg_convrate > 0x07 || (reg_status & 0x61) != 0x00) { |
244 | * was loaded with the force parameter and a given kind of chip is | 244 | dev_dbg(&adapter->dev, "MAX1619 detection failed at 0x%02x\n", |
245 | * requested, so both the detection and the identification steps | 245 | client->addr); |
246 | * are skipped. | 246 | return -ENODEV; |
247 | */ | ||
248 | if (kind < 0) { /* detection */ | ||
249 | reg_config = i2c_smbus_read_byte_data(new_client, | ||
250 | MAX1619_REG_R_CONFIG); | ||
251 | reg_convrate = i2c_smbus_read_byte_data(new_client, | ||
252 | MAX1619_REG_R_CONVRATE); | ||
253 | reg_status = i2c_smbus_read_byte_data(new_client, | ||
254 | MAX1619_REG_R_STATUS); | ||
255 | if ((reg_config & 0x03) != 0x00 | ||
256 | || reg_convrate > 0x07 || (reg_status & 0x61 ) !=0x00) { | ||
257 | dev_dbg(&adapter->dev, | ||
258 | "MAX1619 detection failed at 0x%02x.\n", | ||
259 | new_client->addr); | ||
260 | return -ENODEV; | ||
261 | } | ||
262 | } | 247 | } |
263 | 248 | ||
264 | if (kind <= 0) { /* identification */ | 249 | /* identification */ |
265 | u8 man_id, chip_id; | 250 | man_id = i2c_smbus_read_byte_data(client, MAX1619_REG_R_MAN_ID); |
266 | 251 | chip_id = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CHIP_ID); | |
267 | man_id = i2c_smbus_read_byte_data(new_client, | 252 | if (man_id != 0x4D || chip_id != 0x04) { |
268 | MAX1619_REG_R_MAN_ID); | 253 | dev_info(&adapter->dev, |
269 | chip_id = i2c_smbus_read_byte_data(new_client, | 254 | "Unsupported chip (man_id=0x%02X, chip_id=0x%02X).\n", |
270 | MAX1619_REG_R_CHIP_ID); | 255 | man_id, chip_id); |
271 | 256 | return -ENODEV; | |
272 | if ((man_id == 0x4D) && (chip_id == 0x04)) | ||
273 | kind = max1619; | ||
274 | |||
275 | if (kind <= 0) { /* identification failed */ | ||
276 | dev_info(&adapter->dev, | ||
277 | "Unsupported chip (man_id=0x%02X, " | ||
278 | "chip_id=0x%02X).\n", man_id, chip_id); | ||
279 | return -ENODEV; | ||
280 | } | ||
281 | } | 257 | } |
282 | 258 | ||
283 | strlcpy(info->type, "max1619", I2C_NAME_SIZE); | 259 | strlcpy(info->type, "max1619", I2C_NAME_SIZE); |
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index 58f66be61b1f..1da561e0cb37 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c | |||
@@ -534,7 +534,7 @@ static int max6650_detect(struct i2c_client *client, int kind, | |||
534 | struct i2c_adapter *adapter = client->adapter; | 534 | struct i2c_adapter *adapter = client->adapter; |
535 | int address = client->addr; | 535 | int address = client->addr; |
536 | 536 | ||
537 | dev_dbg(&adapter->dev, "max6650_detect called, kind = %d\n", kind); | 537 | dev_dbg(&adapter->dev, "max6650_detect called\n"); |
538 | 538 | ||
539 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 539 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
540 | dev_dbg(&adapter->dev, "max6650: I2C bus doesn't support " | 540 | dev_dbg(&adapter->dev, "max6650: I2C bus doesn't support " |
@@ -542,23 +542,7 @@ static int max6650_detect(struct i2c_client *client, int kind, | |||
542 | return -ENODEV; | 542 | return -ENODEV; |
543 | } | 543 | } |
544 | 544 | ||
545 | /* | 545 | if (((i2c_smbus_read_byte_data(client, MAX6650_REG_CONFIG) & 0xC0) |
546 | * Now we do the remaining detection. A negative kind means that | ||
547 | * the driver was loaded with no force parameter (default), so we | ||
548 | * must both detect and identify the chip (actually there is only | ||
549 | * one possible kind of chip for now, max6650). A zero kind means that | ||
550 | * the driver was loaded with the force parameter, the detection | ||
551 | * step shall be skipped. A positive kind means that the driver | ||
552 | * was loaded with the force parameter and a given kind of chip is | ||
553 | * requested, so both the detection and the identification steps | ||
554 | * are skipped. | ||
555 | * | ||
556 | * Currently I can find no way to distinguish between a MAX6650 and | ||
557 | * a MAX6651. This driver has only been tried on the former. | ||
558 | */ | ||
559 | |||
560 | if ((kind < 0) && | ||
561 | ( (i2c_smbus_read_byte_data(client, MAX6650_REG_CONFIG) & 0xC0) | ||
562 | ||(i2c_smbus_read_byte_data(client, MAX6650_REG_GPIO_STAT) & 0xE0) | 546 | ||(i2c_smbus_read_byte_data(client, MAX6650_REG_GPIO_STAT) & 0xE0) |
563 | ||(i2c_smbus_read_byte_data(client, MAX6650_REG_ALARM_EN) & 0xE0) | 547 | ||(i2c_smbus_read_byte_data(client, MAX6650_REG_ALARM_EN) & 0xE0) |
564 | ||(i2c_smbus_read_byte_data(client, MAX6650_REG_ALARM) & 0xE0) | 548 | ||(i2c_smbus_read_byte_data(client, MAX6650_REG_ALARM) & 0xE0) |
diff --git a/drivers/hwmon/mc13783-adc.c b/drivers/hwmon/mc13783-adc.c new file mode 100644 index 000000000000..883fa8197da4 --- /dev/null +++ b/drivers/hwmon/mc13783-adc.c | |||
@@ -0,0 +1,236 @@ | |||
1 | /* | ||
2 | * Driver for the Freescale Semiconductor MC13783 adc. | ||
3 | * | ||
4 | * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
5 | * Copyright (C) 2009 Sascha Hauer, Pengutronix | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along with | ||
17 | * this program; if not, write to the Free Software Foundation, Inc., 51 | ||
18 | * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include <linux/mfd/mc13783-private.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/hwmon-sysfs.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/hwmon.h> | ||
27 | #include <linux/init.h> | ||
28 | #include <linux/err.h> | ||
29 | |||
30 | #define MC13783_ADC_NAME "mc13783-adc" | ||
31 | |||
32 | struct mc13783_adc_priv { | ||
33 | struct mc13783 *mc13783; | ||
34 | struct device *hwmon_dev; | ||
35 | }; | ||
36 | |||
37 | static ssize_t mc13783_adc_show_name(struct device *dev, struct device_attribute | ||
38 | *devattr, char *buf) | ||
39 | { | ||
40 | return sprintf(buf, "mc13783_adc\n"); | ||
41 | } | ||
42 | |||
43 | static int mc13783_adc_read(struct device *dev, | ||
44 | struct device_attribute *devattr, unsigned int *val) | ||
45 | { | ||
46 | struct platform_device *pdev = to_platform_device(dev); | ||
47 | struct mc13783_adc_priv *priv = platform_get_drvdata(pdev); | ||
48 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
49 | unsigned int channel = attr->index; | ||
50 | unsigned int sample[4]; | ||
51 | int ret; | ||
52 | |||
53 | ret = mc13783_adc_do_conversion(priv->mc13783, | ||
54 | MC13783_ADC_MODE_MULT_CHAN, | ||
55 | channel, sample); | ||
56 | if (ret) | ||
57 | return ret; | ||
58 | |||
59 | channel &= 0x7; | ||
60 | |||
61 | *val = (sample[channel % 4] >> (channel > 3 ? 14 : 2)) & 0x3ff; | ||
62 | |||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | static ssize_t mc13783_adc_read_bp(struct device *dev, | ||
67 | struct device_attribute *devattr, char *buf) | ||
68 | { | ||
69 | unsigned val; | ||
70 | int ret = mc13783_adc_read(dev, devattr, &val); | ||
71 | |||
72 | if (ret) | ||
73 | return ret; | ||
74 | |||
75 | /* | ||
76 | * BP (channel 2) reports with offset 2.4V to the actual value to fit | ||
77 | * the input range of the ADC. unit = 2.25mV = 9/4 mV. | ||
78 | */ | ||
79 | val = DIV_ROUND_CLOSEST(val * 9, 4) + 2400; | ||
80 | |||
81 | return sprintf(buf, "%u\n", val); | ||
82 | } | ||
83 | |||
84 | static ssize_t mc13783_adc_read_gp(struct device *dev, | ||
85 | struct device_attribute *devattr, char *buf) | ||
86 | { | ||
87 | unsigned val; | ||
88 | int ret = mc13783_adc_read(dev, devattr, &val); | ||
89 | |||
90 | if (ret) | ||
91 | return ret; | ||
92 | |||
93 | /* | ||
94 | * input range is [0, 2.3V], val has 10 bits, so each bit | ||
95 | * is worth 9/4 mV. | ||
96 | */ | ||
97 | val = DIV_ROUND_CLOSEST(val * 9, 4); | ||
98 | |||
99 | return sprintf(buf, "%u\n", val); | ||
100 | } | ||
101 | |||
102 | static DEVICE_ATTR(name, S_IRUGO, mc13783_adc_show_name, NULL); | ||
103 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, mc13783_adc_read_bp, NULL, 2); | ||
104 | static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, mc13783_adc_read_gp, NULL, 5); | ||
105 | static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, mc13783_adc_read_gp, NULL, 6); | ||
106 | static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, mc13783_adc_read_gp, NULL, 7); | ||
107 | static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, mc13783_adc_read_gp, NULL, 8); | ||
108 | static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, mc13783_adc_read_gp, NULL, 9); | ||
109 | static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, mc13783_adc_read_gp, NULL, 10); | ||
110 | static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, mc13783_adc_read_gp, NULL, 11); | ||
111 | static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, mc13783_adc_read_gp, NULL, 12); | ||
112 | static SENSOR_DEVICE_ATTR(in13_input, S_IRUGO, mc13783_adc_read_gp, NULL, 13); | ||
113 | static SENSOR_DEVICE_ATTR(in14_input, S_IRUGO, mc13783_adc_read_gp, NULL, 14); | ||
114 | static SENSOR_DEVICE_ATTR(in15_input, S_IRUGO, mc13783_adc_read_gp, NULL, 15); | ||
115 | |||
116 | static struct attribute *mc13783_attr[] = { | ||
117 | &dev_attr_name.attr, | ||
118 | &sensor_dev_attr_in2_input.dev_attr.attr, | ||
119 | &sensor_dev_attr_in5_input.dev_attr.attr, | ||
120 | &sensor_dev_attr_in6_input.dev_attr.attr, | ||
121 | &sensor_dev_attr_in7_input.dev_attr.attr, | ||
122 | &sensor_dev_attr_in8_input.dev_attr.attr, | ||
123 | &sensor_dev_attr_in9_input.dev_attr.attr, | ||
124 | &sensor_dev_attr_in10_input.dev_attr.attr, | ||
125 | &sensor_dev_attr_in11_input.dev_attr.attr, | ||
126 | NULL | ||
127 | }; | ||
128 | |||
129 | static const struct attribute_group mc13783_group = { | ||
130 | .attrs = mc13783_attr, | ||
131 | }; | ||
132 | |||
133 | /* last four channels may be occupied by the touchscreen */ | ||
134 | static struct attribute *mc13783_attr_ts[] = { | ||
135 | &sensor_dev_attr_in12_input.dev_attr.attr, | ||
136 | &sensor_dev_attr_in13_input.dev_attr.attr, | ||
137 | &sensor_dev_attr_in14_input.dev_attr.attr, | ||
138 | &sensor_dev_attr_in15_input.dev_attr.attr, | ||
139 | NULL | ||
140 | }; | ||
141 | |||
142 | static const struct attribute_group mc13783_group_ts = { | ||
143 | .attrs = mc13783_attr_ts, | ||
144 | }; | ||
145 | |||
146 | static int __init mc13783_adc_probe(struct platform_device *pdev) | ||
147 | { | ||
148 | struct mc13783_adc_priv *priv; | ||
149 | int ret; | ||
150 | |||
151 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
152 | if (!priv) | ||
153 | return -ENOMEM; | ||
154 | |||
155 | priv->mc13783 = dev_get_drvdata(pdev->dev.parent); | ||
156 | |||
157 | platform_set_drvdata(pdev, priv); | ||
158 | |||
159 | /* Register sysfs hooks */ | ||
160 | ret = sysfs_create_group(&pdev->dev.kobj, &mc13783_group); | ||
161 | if (ret) | ||
162 | goto out_err_create1; | ||
163 | |||
164 | if (!(priv->mc13783->flags & MC13783_USE_TOUCHSCREEN)) | ||
165 | ret = sysfs_create_group(&pdev->dev.kobj, &mc13783_group_ts); | ||
166 | if (ret) | ||
167 | goto out_err_create2; | ||
168 | |||
169 | priv->hwmon_dev = hwmon_device_register(&pdev->dev); | ||
170 | if (IS_ERR(priv->hwmon_dev)) { | ||
171 | ret = PTR_ERR(priv->hwmon_dev); | ||
172 | dev_err(&pdev->dev, | ||
173 | "hwmon_device_register failed with %d.\n", ret); | ||
174 | goto out_err_register; | ||
175 | } | ||
176 | |||
177 | |||
178 | return 0; | ||
179 | |||
180 | out_err_register: | ||
181 | |||
182 | if (!(priv->mc13783->flags & MC13783_USE_TOUCHSCREEN)) | ||
183 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_ts); | ||
184 | out_err_create2: | ||
185 | |||
186 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group); | ||
187 | out_err_create1: | ||
188 | |||
189 | platform_set_drvdata(pdev, NULL); | ||
190 | kfree(priv); | ||
191 | |||
192 | return ret; | ||
193 | } | ||
194 | |||
195 | static int __devexit mc13783_adc_remove(struct platform_device *pdev) | ||
196 | { | ||
197 | struct mc13783_adc_priv *priv = platform_get_drvdata(pdev); | ||
198 | |||
199 | hwmon_device_unregister(priv->hwmon_dev); | ||
200 | |||
201 | if (!(priv->mc13783->flags & MC13783_USE_TOUCHSCREEN)) | ||
202 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_ts); | ||
203 | |||
204 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group); | ||
205 | |||
206 | platform_set_drvdata(pdev, NULL); | ||
207 | kfree(priv); | ||
208 | |||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | static struct platform_driver mc13783_adc_driver = { | ||
213 | .remove = __devexit_p(mc13783_adc_remove), | ||
214 | .driver = { | ||
215 | .owner = THIS_MODULE, | ||
216 | .name = MC13783_ADC_NAME, | ||
217 | }, | ||
218 | }; | ||
219 | |||
220 | static int __init mc13783_adc_init(void) | ||
221 | { | ||
222 | return platform_driver_probe(&mc13783_adc_driver, mc13783_adc_probe); | ||
223 | } | ||
224 | |||
225 | static void __exit mc13783_adc_exit(void) | ||
226 | { | ||
227 | platform_driver_unregister(&mc13783_adc_driver); | ||
228 | } | ||
229 | |||
230 | module_init(mc13783_adc_init); | ||
231 | module_exit(mc13783_adc_exit); | ||
232 | |||
233 | MODULE_DESCRIPTION("MC13783 ADC driver"); | ||
234 | MODULE_AUTHOR("Luotao Fu <l.fu@pengutronix.de>"); | ||
235 | MODULE_LICENSE("GPL"); | ||
236 | MODULE_ALIAS("platform:" MC13783_ADC_NAME); | ||
diff --git a/drivers/hwmon/s3c-hwmon.c b/drivers/hwmon/s3c-hwmon.c index 71835412529f..3f3f9a47acfd 100644 --- a/drivers/hwmon/s3c-hwmon.c +++ b/drivers/hwmon/s3c-hwmon.c | |||
@@ -323,7 +323,7 @@ static int __devinit s3c_hwmon_probe(struct platform_device *dev) | |||
323 | } | 323 | } |
324 | 324 | ||
325 | for (i = 0; i < ARRAY_SIZE(pdata->in); i++) { | 325 | for (i = 0; i < ARRAY_SIZE(pdata->in); i++) { |
326 | struct s3c24xx_adc_hwmon_incfg *cfg = pdata->in[i]; | 326 | struct s3c_hwmon_chcfg *cfg = pdata->in[i]; |
327 | 327 | ||
328 | if (!cfg) | 328 | if (!cfg) |
329 | continue; | 329 | continue; |
@@ -333,7 +333,7 @@ static int __devinit s3c_hwmon_probe(struct platform_device *dev) | |||
333 | "channel %d multiplier too large\n", | 333 | "channel %d multiplier too large\n", |
334 | i); | 334 | i); |
335 | 335 | ||
336 | if (cfg->divider == 0) { | 336 | if (cfg->div == 0) { |
337 | dev_err(&dev->dev, "channel %d divider zero\n", i); | 337 | dev_err(&dev->dev, "channel %d divider zero\n", i); |
338 | continue; | 338 | continue; |
339 | } | 339 | } |
diff --git a/drivers/hwmon/smsc47m192.c b/drivers/hwmon/smsc47m192.c index 8bb5cb532d4d..4d88c045781c 100644 --- a/drivers/hwmon/smsc47m192.c +++ b/drivers/hwmon/smsc47m192.c | |||
@@ -491,24 +491,22 @@ static int smsc47m192_detect(struct i2c_client *client, int kind, | |||
491 | return -ENODEV; | 491 | return -ENODEV; |
492 | 492 | ||
493 | /* Detection criteria from sensors_detect script */ | 493 | /* Detection criteria from sensors_detect script */ |
494 | if (kind < 0) { | 494 | version = i2c_smbus_read_byte_data(client, SMSC47M192_REG_VERSION); |
495 | if (i2c_smbus_read_byte_data(client, | 495 | if (i2c_smbus_read_byte_data(client, |
496 | SMSC47M192_REG_COMPANY_ID) == 0x55 | 496 | SMSC47M192_REG_COMPANY_ID) == 0x55 |
497 | && ((version = i2c_smbus_read_byte_data(client, | 497 | && (version & 0xf0) == 0x20 |
498 | SMSC47M192_REG_VERSION)) & 0xf0) == 0x20 | 498 | && (i2c_smbus_read_byte_data(client, |
499 | && (i2c_smbus_read_byte_data(client, | ||
500 | SMSC47M192_REG_VID) & 0x70) == 0x00 | 499 | SMSC47M192_REG_VID) & 0x70) == 0x00 |
501 | && (i2c_smbus_read_byte_data(client, | 500 | && (i2c_smbus_read_byte_data(client, |
502 | SMSC47M192_REG_VID4) & 0xfe) == 0x80) { | 501 | SMSC47M192_REG_VID4) & 0xfe) == 0x80) { |
503 | dev_info(&adapter->dev, | 502 | dev_info(&adapter->dev, |
504 | "found SMSC47M192 or compatible, " | 503 | "found SMSC47M192 or compatible, " |
505 | "version 2, stepping A%d\n", version & 0x0f); | 504 | "version 2, stepping A%d\n", version & 0x0f); |
506 | } else { | 505 | } else { |
507 | dev_dbg(&adapter->dev, | 506 | dev_dbg(&adapter->dev, |
508 | "SMSC47M192 detection failed at 0x%02x\n", | 507 | "SMSC47M192 detection failed at 0x%02x\n", |
509 | client->addr); | 508 | client->addr); |
510 | return -ENODEV; | 509 | return -ENODEV; |
511 | } | ||
512 | } | 510 | } |
513 | 511 | ||
514 | strlcpy(info->type, "smsc47m192", I2C_NAME_SIZE); | 512 | strlcpy(info->type, "smsc47m192", I2C_NAME_SIZE); |
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c index 7d97431e132f..4b793849c738 100644 --- a/drivers/hwmon/thmc50.c +++ b/drivers/hwmon/thmc50.c | |||
@@ -36,7 +36,11 @@ static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | |||
36 | 36 | ||
37 | /* Insmod parameters */ | 37 | /* Insmod parameters */ |
38 | I2C_CLIENT_INSMOD_2(thmc50, adm1022); | 38 | I2C_CLIENT_INSMOD_2(thmc50, adm1022); |
39 | I2C_CLIENT_MODULE_PARM(adm1022_temp3, "List of adapter,address pairs " | 39 | |
40 | static unsigned short adm1022_temp3[16]; | ||
41 | static unsigned int adm1022_temp3_num; | ||
42 | module_param_array(adm1022_temp3, ushort, &adm1022_temp3_num, 0); | ||
43 | MODULE_PARM_DESC(adm1022_temp3, "List of adapter,address pairs " | ||
40 | "to enable 3rd temperature (ADM1022 only)"); | 44 | "to enable 3rd temperature (ADM1022 only)"); |
41 | 45 | ||
42 | /* Many THMC50 constants specified below */ | 46 | /* Many THMC50 constants specified below */ |
@@ -289,7 +293,6 @@ static int thmc50_detect(struct i2c_client *client, int kind, | |||
289 | unsigned revision; | 293 | unsigned revision; |
290 | unsigned config; | 294 | unsigned config; |
291 | struct i2c_adapter *adapter = client->adapter; | 295 | struct i2c_adapter *adapter = client->adapter; |
292 | int err = 0; | ||
293 | const char *type_name; | 296 | const char *type_name; |
294 | 297 | ||
295 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 298 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
@@ -301,31 +304,13 @@ static int thmc50_detect(struct i2c_client *client, int kind, | |||
301 | pr_debug("thmc50: Probing for THMC50 at 0x%2X on bus %d\n", | 304 | pr_debug("thmc50: Probing for THMC50 at 0x%2X on bus %d\n", |
302 | client->addr, i2c_adapter_id(client->adapter)); | 305 | client->addr, i2c_adapter_id(client->adapter)); |
303 | 306 | ||
304 | /* Now, we do the remaining detection. */ | ||
305 | company = i2c_smbus_read_byte_data(client, THMC50_REG_COMPANY_ID); | 307 | company = i2c_smbus_read_byte_data(client, THMC50_REG_COMPANY_ID); |
306 | revision = i2c_smbus_read_byte_data(client, THMC50_REG_DIE_CODE); | 308 | revision = i2c_smbus_read_byte_data(client, THMC50_REG_DIE_CODE); |
307 | config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF); | 309 | config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF); |
310 | if (revision < 0xc0 || (config & 0x10)) | ||
311 | return -ENODEV; | ||
308 | 312 | ||
309 | if (kind == 0) | 313 | if (company == 0x41) { |
310 | kind = thmc50; | ||
311 | else if (kind < 0) { | ||
312 | err = -ENODEV; | ||
313 | if (revision >= 0xc0 && ((config & 0x10) == 0)) { | ||
314 | if (company == 0x49) { | ||
315 | kind = thmc50; | ||
316 | err = 0; | ||
317 | } else if (company == 0x41) { | ||
318 | kind = adm1022; | ||
319 | err = 0; | ||
320 | } | ||
321 | } | ||
322 | } | ||
323 | if (err == -ENODEV) { | ||
324 | pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n"); | ||
325 | return err; | ||
326 | } | ||
327 | |||
328 | if (kind == adm1022) { | ||
329 | int id = i2c_adapter_id(client->adapter); | 314 | int id = i2c_adapter_id(client->adapter); |
330 | int i; | 315 | int i; |
331 | 316 | ||
@@ -340,9 +325,13 @@ static int thmc50_detect(struct i2c_client *client, int kind, | |||
340 | config); | 325 | config); |
341 | break; | 326 | break; |
342 | } | 327 | } |
343 | } else { | 328 | } else if (company == 0x49) { |
344 | type_name = "thmc50"; | 329 | type_name = "thmc50"; |
330 | } else { | ||
331 | pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n"); | ||
332 | return -ENODEV; | ||
345 | } | 333 | } |
334 | |||
346 | pr_debug("thmc50: Detected %s (version %x, revision %x)\n", | 335 | pr_debug("thmc50: Detected %s (version %x, revision %x)\n", |
347 | type_name, (revision >> 4) - 0xc, revision & 0xf); | 336 | type_name, (revision >> 4) - 0xc, revision & 0xf); |
348 | 337 | ||
diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c index 7b34f2cd08bb..ee9673467c4a 100644 --- a/drivers/hwmon/tmp401.c +++ b/drivers/hwmon/tmp401.c | |||
@@ -488,46 +488,43 @@ static void tmp401_init_client(struct i2c_client *client) | |||
488 | i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config); | 488 | i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config); |
489 | } | 489 | } |
490 | 490 | ||
491 | static int tmp401_detect(struct i2c_client *client, int kind, | 491 | static int tmp401_detect(struct i2c_client *client, int _kind, |
492 | struct i2c_board_info *info) | 492 | struct i2c_board_info *info) |
493 | { | 493 | { |
494 | enum chips kind; | ||
494 | struct i2c_adapter *adapter = client->adapter; | 495 | struct i2c_adapter *adapter = client->adapter; |
496 | u8 reg; | ||
495 | 497 | ||
496 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 498 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
497 | return -ENODEV; | 499 | return -ENODEV; |
498 | 500 | ||
499 | /* Detect and identify the chip */ | 501 | /* Detect and identify the chip */ |
500 | if (kind <= 0) { | 502 | reg = i2c_smbus_read_byte_data(client, TMP401_MANUFACTURER_ID_REG); |
501 | u8 reg; | 503 | if (reg != TMP401_MANUFACTURER_ID) |
502 | 504 | return -ENODEV; | |
503 | reg = i2c_smbus_read_byte_data(client, | ||
504 | TMP401_MANUFACTURER_ID_REG); | ||
505 | if (reg != TMP401_MANUFACTURER_ID) | ||
506 | return -ENODEV; | ||
507 | |||
508 | reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG); | ||
509 | |||
510 | switch (reg) { | ||
511 | case TMP401_DEVICE_ID: | ||
512 | kind = tmp401; | ||
513 | break; | ||
514 | case TMP411_DEVICE_ID: | ||
515 | kind = tmp411; | ||
516 | break; | ||
517 | default: | ||
518 | return -ENODEV; | ||
519 | } | ||
520 | 505 | ||
521 | reg = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ); | 506 | reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG); |
522 | if (reg & 0x1b) | ||
523 | return -ENODEV; | ||
524 | 507 | ||
525 | reg = i2c_smbus_read_byte_data(client, | 508 | switch (reg) { |
526 | TMP401_CONVERSION_RATE_READ); | 509 | case TMP401_DEVICE_ID: |
527 | /* Datasheet says: 0x1-0x6 */ | 510 | kind = tmp401; |
528 | if (reg > 15) | 511 | break; |
529 | return -ENODEV; | 512 | case TMP411_DEVICE_ID: |
513 | kind = tmp411; | ||
514 | break; | ||
515 | default: | ||
516 | return -ENODEV; | ||
530 | } | 517 | } |
518 | |||
519 | reg = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ); | ||
520 | if (reg & 0x1b) | ||
521 | return -ENODEV; | ||
522 | |||
523 | reg = i2c_smbus_read_byte_data(client, TMP401_CONVERSION_RATE_READ); | ||
524 | /* Datasheet says: 0x1-0x6 */ | ||
525 | if (reg > 15) | ||
526 | return -ENODEV; | ||
527 | |||
531 | strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE); | 528 | strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE); |
532 | 529 | ||
533 | return 0; | 530 | return 0; |
diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c index 20924343431b..bb5464a289ca 100644 --- a/drivers/hwmon/tmp421.c +++ b/drivers/hwmon/tmp421.c | |||
@@ -223,39 +223,36 @@ static int tmp421_init_client(struct i2c_client *client) | |||
223 | return 0; | 223 | return 0; |
224 | } | 224 | } |
225 | 225 | ||
226 | static int tmp421_detect(struct i2c_client *client, int kind, | 226 | static int tmp421_detect(struct i2c_client *client, int _kind, |
227 | struct i2c_board_info *info) | 227 | struct i2c_board_info *info) |
228 | { | 228 | { |
229 | enum chips kind; | ||
229 | struct i2c_adapter *adapter = client->adapter; | 230 | struct i2c_adapter *adapter = client->adapter; |
230 | const char *names[] = { "TMP421", "TMP422", "TMP423" }; | 231 | const char *names[] = { "TMP421", "TMP422", "TMP423" }; |
232 | u8 reg; | ||
231 | 233 | ||
232 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 234 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
233 | return -ENODEV; | 235 | return -ENODEV; |
234 | 236 | ||
235 | if (kind <= 0) { | 237 | reg = i2c_smbus_read_byte_data(client, TMP421_MANUFACTURER_ID_REG); |
236 | u8 reg; | 238 | if (reg != TMP421_MANUFACTURER_ID) |
237 | 239 | return -ENODEV; | |
238 | reg = i2c_smbus_read_byte_data(client, | 240 | |
239 | TMP421_MANUFACTURER_ID_REG); | 241 | reg = i2c_smbus_read_byte_data(client, TMP421_DEVICE_ID_REG); |
240 | if (reg != TMP421_MANUFACTURER_ID) | 242 | switch (reg) { |
241 | return -ENODEV; | 243 | case TMP421_DEVICE_ID: |
242 | 244 | kind = tmp421; | |
243 | reg = i2c_smbus_read_byte_data(client, | 245 | break; |
244 | TMP421_DEVICE_ID_REG); | 246 | case TMP422_DEVICE_ID: |
245 | switch (reg) { | 247 | kind = tmp422; |
246 | case TMP421_DEVICE_ID: | 248 | break; |
247 | kind = tmp421; | 249 | case TMP423_DEVICE_ID: |
248 | break; | 250 | kind = tmp423; |
249 | case TMP422_DEVICE_ID: | 251 | break; |
250 | kind = tmp422; | 252 | default: |
251 | break; | 253 | return -ENODEV; |
252 | case TMP423_DEVICE_ID: | ||
253 | kind = tmp423; | ||
254 | break; | ||
255 | default: | ||
256 | return -ENODEV; | ||
257 | } | ||
258 | } | 254 | } |
255 | |||
259 | strlcpy(info->type, tmp421_id[kind - 1].name, I2C_NAME_SIZE); | 256 | strlcpy(info->type, tmp421_id[kind - 1].name, I2C_NAME_SIZE); |
260 | dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n", | 257 | dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n", |
261 | names[kind - 1], client->addr); | 258 | names[kind - 1], client->addr); |
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 2be28ac4ede0..b257c7223733 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -59,10 +59,11 @@ static struct platform_device *pdev; | |||
59 | #define DRVNAME "w83627hf" | 59 | #define DRVNAME "w83627hf" |
60 | enum chips { w83627hf, w83627thf, w83697hf, w83637hf, w83687thf }; | 60 | enum chips { w83627hf, w83627thf, w83697hf, w83637hf, w83687thf }; |
61 | 61 | ||
62 | static u16 force_addr; | 62 | struct w83627hf_sio_data { |
63 | module_param(force_addr, ushort, 0); | 63 | enum chips type; |
64 | MODULE_PARM_DESC(force_addr, | 64 | int sioaddr; |
65 | "Initialize the base address of the sensors"); | 65 | }; |
66 | |||
66 | static u8 force_i2c = 0x1f; | 67 | static u8 force_i2c = 0x1f; |
67 | module_param(force_i2c, byte, 0); | 68 | module_param(force_i2c, byte, 0); |
68 | MODULE_PARM_DESC(force_i2c, | 69 | MODULE_PARM_DESC(force_i2c, |
@@ -77,9 +78,7 @@ module_param(force_id, ushort, 0); | |||
77 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); | 78 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); |
78 | 79 | ||
79 | /* modified from kernel/include/traps.c */ | 80 | /* modified from kernel/include/traps.c */ |
80 | static int REG; /* The register to read/write */ | ||
81 | #define DEV 0x07 /* Register: Logical device select */ | 81 | #define DEV 0x07 /* Register: Logical device select */ |
82 | static int VAL; /* The value to read/write */ | ||
83 | 82 | ||
84 | /* logical device numbers for superio_select (below) */ | 83 | /* logical device numbers for superio_select (below) */ |
85 | #define W83627HF_LD_FDC 0x00 | 84 | #define W83627HF_LD_FDC 0x00 |
@@ -109,37 +108,37 @@ static int VAL; /* The value to read/write */ | |||
109 | #define W83687THF_VID_DATA 0xF1 /* w83687thf only */ | 108 | #define W83687THF_VID_DATA 0xF1 /* w83687thf only */ |
110 | 109 | ||
111 | static inline void | 110 | static inline void |
112 | superio_outb(int reg, int val) | 111 | superio_outb(struct w83627hf_sio_data *sio, int reg, int val) |
113 | { | 112 | { |
114 | outb(reg, REG); | 113 | outb(reg, sio->sioaddr); |
115 | outb(val, VAL); | 114 | outb(val, sio->sioaddr + 1); |
116 | } | 115 | } |
117 | 116 | ||
118 | static inline int | 117 | static inline int |
119 | superio_inb(int reg) | 118 | superio_inb(struct w83627hf_sio_data *sio, int reg) |
120 | { | 119 | { |
121 | outb(reg, REG); | 120 | outb(reg, sio->sioaddr); |
122 | return inb(VAL); | 121 | return inb(sio->sioaddr + 1); |
123 | } | 122 | } |
124 | 123 | ||
125 | static inline void | 124 | static inline void |
126 | superio_select(int ld) | 125 | superio_select(struct w83627hf_sio_data *sio, int ld) |
127 | { | 126 | { |
128 | outb(DEV, REG); | 127 | outb(DEV, sio->sioaddr); |
129 | outb(ld, VAL); | 128 | outb(ld, sio->sioaddr + 1); |
130 | } | 129 | } |
131 | 130 | ||
132 | static inline void | 131 | static inline void |
133 | superio_enter(void) | 132 | superio_enter(struct w83627hf_sio_data *sio) |
134 | { | 133 | { |
135 | outb(0x87, REG); | 134 | outb(0x87, sio->sioaddr); |
136 | outb(0x87, REG); | 135 | outb(0x87, sio->sioaddr); |
137 | } | 136 | } |
138 | 137 | ||
139 | static inline void | 138 | static inline void |
140 | superio_exit(void) | 139 | superio_exit(struct w83627hf_sio_data *sio) |
141 | { | 140 | { |
142 | outb(0xAA, REG); | 141 | outb(0xAA, sio->sioaddr); |
143 | } | 142 | } |
144 | 143 | ||
145 | #define W627_DEVID 0x52 | 144 | #define W627_DEVID 0x52 |
@@ -380,10 +379,6 @@ struct w83627hf_data { | |||
380 | u8 vrm_ovt; /* Register value, 627THF/637HF/687THF only */ | 379 | u8 vrm_ovt; /* Register value, 627THF/637HF/687THF only */ |
381 | }; | 380 | }; |
382 | 381 | ||
383 | struct w83627hf_sio_data { | ||
384 | enum chips type; | ||
385 | }; | ||
386 | |||
387 | 382 | ||
388 | static int w83627hf_probe(struct platform_device *pdev); | 383 | static int w83627hf_probe(struct platform_device *pdev); |
389 | static int __devexit w83627hf_remove(struct platform_device *pdev); | 384 | static int __devexit w83627hf_remove(struct platform_device *pdev); |
@@ -1140,11 +1135,8 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr, | |||
1140 | "W83687THF", | 1135 | "W83687THF", |
1141 | }; | 1136 | }; |
1142 | 1137 | ||
1143 | REG = sioaddr; | 1138 | superio_enter(sio_data); |
1144 | VAL = sioaddr + 1; | 1139 | val = force_id ? force_id : superio_inb(sio_data, DEVID); |
1145 | |||
1146 | superio_enter(); | ||
1147 | val = force_id ? force_id : superio_inb(DEVID); | ||
1148 | switch (val) { | 1140 | switch (val) { |
1149 | case W627_DEVID: | 1141 | case W627_DEVID: |
1150 | sio_data->type = w83627hf; | 1142 | sio_data->type = w83627hf; |
@@ -1168,16 +1160,9 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr, | |||
1168 | goto exit; | 1160 | goto exit; |
1169 | } | 1161 | } |
1170 | 1162 | ||
1171 | superio_select(W83627HF_LD_HWM); | 1163 | superio_select(sio_data, W83627HF_LD_HWM); |
1172 | force_addr &= WINB_ALIGNMENT; | 1164 | val = (superio_inb(sio_data, WINB_BASE_REG) << 8) | |
1173 | if (force_addr) { | 1165 | superio_inb(sio_data, WINB_BASE_REG + 1); |
1174 | printk(KERN_WARNING DRVNAME ": Forcing address 0x%x\n", | ||
1175 | force_addr); | ||
1176 | superio_outb(WINB_BASE_REG, force_addr >> 8); | ||
1177 | superio_outb(WINB_BASE_REG + 1, force_addr & 0xff); | ||
1178 | } | ||
1179 | val = (superio_inb(WINB_BASE_REG) << 8) | | ||
1180 | superio_inb(WINB_BASE_REG + 1); | ||
1181 | *addr = val & WINB_ALIGNMENT; | 1166 | *addr = val & WINB_ALIGNMENT; |
1182 | if (*addr == 0) { | 1167 | if (*addr == 0) { |
1183 | printk(KERN_WARNING DRVNAME ": Base address not set, " | 1168 | printk(KERN_WARNING DRVNAME ": Base address not set, " |
@@ -1185,18 +1170,19 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr, | |||
1185 | goto exit; | 1170 | goto exit; |
1186 | } | 1171 | } |
1187 | 1172 | ||
1188 | val = superio_inb(WINB_ACT_REG); | 1173 | val = superio_inb(sio_data, WINB_ACT_REG); |
1189 | if (!(val & 0x01)) { | 1174 | if (!(val & 0x01)) { |
1190 | printk(KERN_WARNING DRVNAME ": Enabling HWM logical device\n"); | 1175 | printk(KERN_WARNING DRVNAME ": Enabling HWM logical device\n"); |
1191 | superio_outb(WINB_ACT_REG, val | 0x01); | 1176 | superio_outb(sio_data, WINB_ACT_REG, val | 0x01); |
1192 | } | 1177 | } |
1193 | 1178 | ||
1194 | err = 0; | 1179 | err = 0; |
1180 | sio_data->sioaddr = sioaddr; | ||
1195 | pr_info(DRVNAME ": Found %s chip at %#x\n", | 1181 | pr_info(DRVNAME ": Found %s chip at %#x\n", |
1196 | names[sio_data->type], *addr); | 1182 | names[sio_data->type], *addr); |
1197 | 1183 | ||
1198 | exit: | 1184 | exit: |
1199 | superio_exit(); | 1185 | superio_exit(sio_data); |
1200 | return err; | 1186 | return err; |
1201 | } | 1187 | } |
1202 | 1188 | ||
@@ -1511,20 +1497,21 @@ static int w83627hf_read_value(struct w83627hf_data *data, u16 reg) | |||
1511 | 1497 | ||
1512 | static int __devinit w83627thf_read_gpio5(struct platform_device *pdev) | 1498 | static int __devinit w83627thf_read_gpio5(struct platform_device *pdev) |
1513 | { | 1499 | { |
1500 | struct w83627hf_sio_data *sio_data = pdev->dev.platform_data; | ||
1514 | int res = 0xff, sel; | 1501 | int res = 0xff, sel; |
1515 | 1502 | ||
1516 | superio_enter(); | 1503 | superio_enter(sio_data); |
1517 | superio_select(W83627HF_LD_GPIO5); | 1504 | superio_select(sio_data, W83627HF_LD_GPIO5); |
1518 | 1505 | ||
1519 | /* Make sure these GPIO pins are enabled */ | 1506 | /* Make sure these GPIO pins are enabled */ |
1520 | if (!(superio_inb(W83627THF_GPIO5_EN) & (1<<3))) { | 1507 | if (!(superio_inb(sio_data, W83627THF_GPIO5_EN) & (1<<3))) { |
1521 | dev_dbg(&pdev->dev, "GPIO5 disabled, no VID function\n"); | 1508 | dev_dbg(&pdev->dev, "GPIO5 disabled, no VID function\n"); |
1522 | goto exit; | 1509 | goto exit; |
1523 | } | 1510 | } |
1524 | 1511 | ||
1525 | /* Make sure the pins are configured for input | 1512 | /* Make sure the pins are configured for input |
1526 | There must be at least five (VRM 9), and possibly 6 (VRM 10) */ | 1513 | There must be at least five (VRM 9), and possibly 6 (VRM 10) */ |
1527 | sel = superio_inb(W83627THF_GPIO5_IOSR) & 0x3f; | 1514 | sel = superio_inb(sio_data, W83627THF_GPIO5_IOSR) & 0x3f; |
1528 | if ((sel & 0x1f) != 0x1f) { | 1515 | if ((sel & 0x1f) != 0x1f) { |
1529 | dev_dbg(&pdev->dev, "GPIO5 not configured for VID " | 1516 | dev_dbg(&pdev->dev, "GPIO5 not configured for VID " |
1530 | "function\n"); | 1517 | "function\n"); |
@@ -1532,37 +1519,38 @@ static int __devinit w83627thf_read_gpio5(struct platform_device *pdev) | |||
1532 | } | 1519 | } |
1533 | 1520 | ||
1534 | dev_info(&pdev->dev, "Reading VID from GPIO5\n"); | 1521 | dev_info(&pdev->dev, "Reading VID from GPIO5\n"); |
1535 | res = superio_inb(W83627THF_GPIO5_DR) & sel; | 1522 | res = superio_inb(sio_data, W83627THF_GPIO5_DR) & sel; |
1536 | 1523 | ||
1537 | exit: | 1524 | exit: |
1538 | superio_exit(); | 1525 | superio_exit(sio_data); |
1539 | return res; | 1526 | return res; |
1540 | } | 1527 | } |
1541 | 1528 | ||
1542 | static int __devinit w83687thf_read_vid(struct platform_device *pdev) | 1529 | static int __devinit w83687thf_read_vid(struct platform_device *pdev) |
1543 | { | 1530 | { |
1531 | struct w83627hf_sio_data *sio_data = pdev->dev.platform_data; | ||
1544 | int res = 0xff; | 1532 | int res = 0xff; |
1545 | 1533 | ||
1546 | superio_enter(); | 1534 | superio_enter(sio_data); |
1547 | superio_select(W83627HF_LD_HWM); | 1535 | superio_select(sio_data, W83627HF_LD_HWM); |
1548 | 1536 | ||
1549 | /* Make sure these GPIO pins are enabled */ | 1537 | /* Make sure these GPIO pins are enabled */ |
1550 | if (!(superio_inb(W83687THF_VID_EN) & (1 << 2))) { | 1538 | if (!(superio_inb(sio_data, W83687THF_VID_EN) & (1 << 2))) { |
1551 | dev_dbg(&pdev->dev, "VID disabled, no VID function\n"); | 1539 | dev_dbg(&pdev->dev, "VID disabled, no VID function\n"); |
1552 | goto exit; | 1540 | goto exit; |
1553 | } | 1541 | } |
1554 | 1542 | ||
1555 | /* Make sure the pins are configured for input */ | 1543 | /* Make sure the pins are configured for input */ |
1556 | if (!(superio_inb(W83687THF_VID_CFG) & (1 << 4))) { | 1544 | if (!(superio_inb(sio_data, W83687THF_VID_CFG) & (1 << 4))) { |
1557 | dev_dbg(&pdev->dev, "VID configured as output, " | 1545 | dev_dbg(&pdev->dev, "VID configured as output, " |
1558 | "no VID function\n"); | 1546 | "no VID function\n"); |
1559 | goto exit; | 1547 | goto exit; |
1560 | } | 1548 | } |
1561 | 1549 | ||
1562 | res = superio_inb(W83687THF_VID_DATA) & 0x3f; | 1550 | res = superio_inb(sio_data, W83687THF_VID_DATA) & 0x3f; |
1563 | 1551 | ||
1564 | exit: | 1552 | exit: |
1565 | superio_exit(); | 1553 | superio_exit(sio_data); |
1566 | return res; | 1554 | return res; |
1567 | } | 1555 | } |
1568 | 1556 | ||
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index d27ed1bac002..7ab7967da0a0 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c | |||
@@ -1054,11 +1054,11 @@ static int | |||
1054 | w83781d_detect(struct i2c_client *client, int kind, | 1054 | w83781d_detect(struct i2c_client *client, int kind, |
1055 | struct i2c_board_info *info) | 1055 | struct i2c_board_info *info) |
1056 | { | 1056 | { |
1057 | int val1 = 0, val2; | 1057 | int val1, val2; |
1058 | struct w83781d_data *isa = w83781d_data_if_isa(); | 1058 | struct w83781d_data *isa = w83781d_data_if_isa(); |
1059 | struct i2c_adapter *adapter = client->adapter; | 1059 | struct i2c_adapter *adapter = client->adapter; |
1060 | int address = client->addr; | 1060 | int address = client->addr; |
1061 | const char *client_name = ""; | 1061 | const char *client_name; |
1062 | enum vendor { winbond, asus } vendid; | 1062 | enum vendor { winbond, asus } vendid; |
1063 | 1063 | ||
1064 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 1064 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
@@ -1070,98 +1070,73 @@ w83781d_detect(struct i2c_client *client, int kind, | |||
1070 | if (isa) | 1070 | if (isa) |
1071 | mutex_lock(&isa->update_lock); | 1071 | mutex_lock(&isa->update_lock); |
1072 | 1072 | ||
1073 | /* The w8378?d may be stuck in some other bank than bank 0. This may | 1073 | if (i2c_smbus_read_byte_data(client, W83781D_REG_CONFIG) & 0x80) { |
1074 | make reading other information impossible. Specify a force=... or | 1074 | dev_dbg(&adapter->dev, |
1075 | force_*=... parameter, and the Winbond will be reset to the right | 1075 | "Detection of w83781d chip failed at step 3\n"); |
1076 | bank. */ | 1076 | goto err_nodev; |
1077 | if (kind < 0) { | 1077 | } |
1078 | if (i2c_smbus_read_byte_data | 1078 | |
1079 | (client, W83781D_REG_CONFIG) & 0x80) { | 1079 | val1 = i2c_smbus_read_byte_data(client, W83781D_REG_BANK); |
1080 | dev_dbg(&adapter->dev, "Detection of w83781d chip " | 1080 | val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); |
1081 | "failed at step 3\n"); | 1081 | /* Check for Winbond or Asus ID if in bank 0 */ |
1082 | goto err_nodev; | 1082 | if (!(val1 & 0x07) && |
1083 | } | 1083 | ((!(val1 & 0x80) && val2 != 0xa3 && val2 != 0xc3) || |
1084 | val1 = i2c_smbus_read_byte_data(client, W83781D_REG_BANK); | 1084 | ( (val1 & 0x80) && val2 != 0x5c && val2 != 0x12))) { |
1085 | val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); | 1085 | dev_dbg(&adapter->dev, |
1086 | /* Check for Winbond or Asus ID if in bank 0 */ | 1086 | "Detection of w83781d chip failed at step 4\n"); |
1087 | if ((!(val1 & 0x07)) && | 1087 | goto err_nodev; |
1088 | (((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3)) | 1088 | } |
1089 | || ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) { | 1089 | /* If Winbond SMBus, check address at 0x48. |
1090 | dev_dbg(&adapter->dev, "Detection of w83781d chip " | 1090 | Asus doesn't support, except for as99127f rev.2 */ |
1091 | "failed at step 4\n"); | 1091 | if ((!(val1 & 0x80) && val2 == 0xa3) || |
1092 | ( (val1 & 0x80) && val2 == 0x5c)) { | ||
1093 | if (i2c_smbus_read_byte_data(client, W83781D_REG_I2C_ADDR) | ||
1094 | != address) { | ||
1095 | dev_dbg(&adapter->dev, | ||
1096 | "Detection of w83781d chip failed at step 5\n"); | ||
1092 | goto err_nodev; | 1097 | goto err_nodev; |
1093 | } | 1098 | } |
1094 | /* If Winbond SMBus, check address at 0x48. | ||
1095 | Asus doesn't support, except for as99127f rev.2 */ | ||
1096 | if ((!(val1 & 0x80) && (val2 == 0xa3)) || | ||
1097 | ((val1 & 0x80) && (val2 == 0x5c))) { | ||
1098 | if (i2c_smbus_read_byte_data | ||
1099 | (client, W83781D_REG_I2C_ADDR) != address) { | ||
1100 | dev_dbg(&adapter->dev, "Detection of w83781d " | ||
1101 | "chip failed at step 5\n"); | ||
1102 | goto err_nodev; | ||
1103 | } | ||
1104 | } | ||
1105 | } | 1099 | } |
1106 | 1100 | ||
1107 | /* We have either had a force parameter, or we have already detected the | 1101 | /* Put it now into bank 0 and Vendor ID High Byte */ |
1108 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ | ||
1109 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, | 1102 | i2c_smbus_write_byte_data(client, W83781D_REG_BANK, |
1110 | (i2c_smbus_read_byte_data(client, W83781D_REG_BANK) | 1103 | (i2c_smbus_read_byte_data(client, W83781D_REG_BANK) |
1111 | & 0x78) | 0x80); | 1104 | & 0x78) | 0x80); |
1112 | 1105 | ||
1113 | /* Determine the chip type. */ | 1106 | /* Get the vendor ID */ |
1114 | if (kind <= 0) { | 1107 | val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); |
1115 | /* get vendor ID */ | 1108 | if (val2 == 0x5c) |
1116 | val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); | 1109 | vendid = winbond; |
1117 | if (val2 == 0x5c) | 1110 | else if (val2 == 0x12) |
1118 | vendid = winbond; | 1111 | vendid = asus; |
1119 | else if (val2 == 0x12) | 1112 | else { |
1120 | vendid = asus; | 1113 | dev_dbg(&adapter->dev, |
1121 | else { | 1114 | "w83781d chip vendor is neither Winbond nor Asus\n"); |
1122 | dev_dbg(&adapter->dev, "w83781d chip vendor is " | 1115 | goto err_nodev; |
1123 | "neither Winbond nor Asus\n"); | ||
1124 | goto err_nodev; | ||
1125 | } | ||
1126 | |||
1127 | val1 = i2c_smbus_read_byte_data(client, W83781D_REG_WCHIPID); | ||
1128 | if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond) | ||
1129 | kind = w83781d; | ||
1130 | else if (val1 == 0x30 && vendid == winbond) | ||
1131 | kind = w83782d; | ||
1132 | else if (val1 == 0x40 && vendid == winbond && address == 0x2d) | ||
1133 | kind = w83783s; | ||
1134 | else if (val1 == 0x31) | ||
1135 | kind = as99127f; | ||
1136 | else { | ||
1137 | if (kind == 0) | ||
1138 | dev_warn(&adapter->dev, "Ignoring 'force' " | ||
1139 | "parameter for unknown chip at " | ||
1140 | "address 0x%02x\n", address); | ||
1141 | goto err_nodev; | ||
1142 | } | ||
1143 | |||
1144 | if ((kind == w83781d || kind == w83782d) | ||
1145 | && w83781d_alias_detect(client, val1)) { | ||
1146 | dev_dbg(&adapter->dev, "Device at 0x%02x appears to " | ||
1147 | "be the same as ISA device\n", address); | ||
1148 | goto err_nodev; | ||
1149 | } | ||
1150 | } | 1116 | } |
1151 | 1117 | ||
1152 | if (isa) | 1118 | /* Determine the chip type. */ |
1153 | mutex_unlock(&isa->update_lock); | 1119 | val1 = i2c_smbus_read_byte_data(client, W83781D_REG_WCHIPID); |
1154 | 1120 | if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond) | |
1155 | if (kind == w83781d) { | ||
1156 | client_name = "w83781d"; | 1121 | client_name = "w83781d"; |
1157 | } else if (kind == w83782d) { | 1122 | else if (val1 == 0x30 && vendid == winbond) |
1158 | client_name = "w83782d"; | 1123 | client_name = "w83782d"; |
1159 | } else if (kind == w83783s) { | 1124 | else if (val1 == 0x40 && vendid == winbond && address == 0x2d) |
1160 | client_name = "w83783s"; | 1125 | client_name = "w83783s"; |
1161 | } else if (kind == as99127f) { | 1126 | else if (val1 == 0x31) |
1162 | client_name = "as99127f"; | 1127 | client_name = "as99127f"; |
1128 | else | ||
1129 | goto err_nodev; | ||
1130 | |||
1131 | if (val1 <= 0x30 && w83781d_alias_detect(client, val1)) { | ||
1132 | dev_dbg(&adapter->dev, "Device at 0x%02x appears to " | ||
1133 | "be the same as ISA device\n", address); | ||
1134 | goto err_nodev; | ||
1163 | } | 1135 | } |
1164 | 1136 | ||
1137 | if (isa) | ||
1138 | mutex_unlock(&isa->update_lock); | ||
1139 | |||
1165 | strlcpy(info->type, client_name, I2C_NAME_SIZE); | 1140 | strlcpy(info->type, client_name, I2C_NAME_SIZE); |
1166 | 1141 | ||
1167 | return 0; | 1142 | return 0; |
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c index 97851c5ba3a3..0410bf12c521 100644 --- a/drivers/hwmon/w83791d.c +++ b/drivers/hwmon/w83791d.c | |||
@@ -1270,56 +1270,32 @@ static int w83791d_detect(struct i2c_client *client, int kind, | |||
1270 | return -ENODEV; | 1270 | return -ENODEV; |
1271 | } | 1271 | } |
1272 | 1272 | ||
1273 | /* The w83791d may be stuck in some other bank than bank 0. This may | 1273 | if (w83791d_read(client, W83791D_REG_CONFIG) & 0x80) |
1274 | make reading other information impossible. Specify a force=... | 1274 | return -ENODEV; |
1275 | parameter, and the Winbond will be reset to the right bank. */ | 1275 | |
1276 | if (kind < 0) { | 1276 | val1 = w83791d_read(client, W83791D_REG_BANK); |
1277 | if (w83791d_read(client, W83791D_REG_CONFIG) & 0x80) { | 1277 | val2 = w83791d_read(client, W83791D_REG_CHIPMAN); |
1278 | return -ENODEV; | 1278 | /* Check for Winbond ID if in bank 0 */ |
1279 | } | 1279 | if (!(val1 & 0x07)) { |
1280 | val1 = w83791d_read(client, W83791D_REG_BANK); | 1280 | if ((!(val1 & 0x80) && val2 != 0xa3) || |
1281 | val2 = w83791d_read(client, W83791D_REG_CHIPMAN); | 1281 | ( (val1 & 0x80) && val2 != 0x5c)) { |
1282 | /* Check for Winbond ID if in bank 0 */ | ||
1283 | if (!(val1 & 0x07)) { | ||
1284 | /* yes it is Bank0 */ | ||
1285 | if (((!(val1 & 0x80)) && (val2 != 0xa3)) || | ||
1286 | ((val1 & 0x80) && (val2 != 0x5c))) { | ||
1287 | return -ENODEV; | ||
1288 | } | ||
1289 | } | ||
1290 | /* If Winbond chip, address of chip and W83791D_REG_I2C_ADDR | ||
1291 | should match */ | ||
1292 | if (w83791d_read(client, W83791D_REG_I2C_ADDR) != address) { | ||
1293 | return -ENODEV; | 1282 | return -ENODEV; |
1294 | } | 1283 | } |
1295 | } | 1284 | } |
1285 | /* If Winbond chip, address of chip and W83791D_REG_I2C_ADDR | ||
1286 | should match */ | ||
1287 | if (w83791d_read(client, W83791D_REG_I2C_ADDR) != address) | ||
1288 | return -ENODEV; | ||
1296 | 1289 | ||
1297 | /* We either have a force parameter or we have reason to | 1290 | /* We want bank 0 and Vendor ID high byte */ |
1298 | believe it is a Winbond chip. Either way, we want bank 0 and | ||
1299 | Vendor ID high byte */ | ||
1300 | val1 = w83791d_read(client, W83791D_REG_BANK) & 0x78; | 1291 | val1 = w83791d_read(client, W83791D_REG_BANK) & 0x78; |
1301 | w83791d_write(client, W83791D_REG_BANK, val1 | 0x80); | 1292 | w83791d_write(client, W83791D_REG_BANK, val1 | 0x80); |
1302 | 1293 | ||
1303 | /* Verify it is a Winbond w83791d */ | 1294 | /* Verify it is a Winbond w83791d */ |
1304 | if (kind <= 0) { | 1295 | val1 = w83791d_read(client, W83791D_REG_WCHIPID); |
1305 | /* get vendor ID */ | 1296 | val2 = w83791d_read(client, W83791D_REG_CHIPMAN); |
1306 | val2 = w83791d_read(client, W83791D_REG_CHIPMAN); | 1297 | if (val1 != 0x71 || val2 != 0x5c) |
1307 | if (val2 != 0x5c) { /* the vendor is NOT Winbond */ | 1298 | return -ENODEV; |
1308 | return -ENODEV; | ||
1309 | } | ||
1310 | val1 = w83791d_read(client, W83791D_REG_WCHIPID); | ||
1311 | if (val1 == 0x71) { | ||
1312 | kind = w83791d; | ||
1313 | } else { | ||
1314 | if (kind == 0) | ||
1315 | dev_warn(&adapter->dev, | ||
1316 | "w83791d: Ignoring 'force' parameter " | ||
1317 | "for unknown chip at adapter %d, " | ||
1318 | "address 0x%02x\n", | ||
1319 | i2c_adapter_id(adapter), address); | ||
1320 | return -ENODEV; | ||
1321 | } | ||
1322 | } | ||
1323 | 1299 | ||
1324 | strlcpy(info->type, "w83791d", I2C_NAME_SIZE); | 1300 | strlcpy(info->type, "w83791d", I2C_NAME_SIZE); |
1325 | 1301 | ||
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 2be16194ddf3..38978851333f 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -1273,58 +1273,33 @@ w83792d_detect(struct i2c_client *client, int kind, struct i2c_board_info *info) | |||
1273 | return -ENODEV; | 1273 | return -ENODEV; |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | /* The w83792d may be stuck in some other bank than bank 0. This may | 1276 | if (w83792d_read_value(client, W83792D_REG_CONFIG) & 0x80) |
1277 | make reading other information impossible. Specify a force=... or | 1277 | return -ENODEV; |
1278 | force_*=... parameter, and the Winbond will be reset to the right | 1278 | |
1279 | bank. */ | 1279 | val1 = w83792d_read_value(client, W83792D_REG_BANK); |
1280 | if (kind < 0) { | 1280 | val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); |
1281 | if (w83792d_read_value(client, W83792D_REG_CONFIG) & 0x80) { | 1281 | /* Check for Winbond ID if in bank 0 */ |
1282 | return -ENODEV; | 1282 | if (!(val1 & 0x07)) { /* is Bank0 */ |
1283 | } | 1283 | if ((!(val1 & 0x80) && val2 != 0xa3) || |
1284 | val1 = w83792d_read_value(client, W83792D_REG_BANK); | 1284 | ( (val1 & 0x80) && val2 != 0x5c)) |
1285 | val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); | ||
1286 | /* Check for Winbond ID if in bank 0 */ | ||
1287 | if (!(val1 & 0x07)) { /* is Bank0 */ | ||
1288 | if (((!(val1 & 0x80)) && (val2 != 0xa3)) || | ||
1289 | ((val1 & 0x80) && (val2 != 0x5c))) { | ||
1290 | return -ENODEV; | ||
1291 | } | ||
1292 | } | ||
1293 | /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR | ||
1294 | should match */ | ||
1295 | if (w83792d_read_value(client, | ||
1296 | W83792D_REG_I2C_ADDR) != address) { | ||
1297 | return -ENODEV; | 1285 | return -ENODEV; |
1298 | } | ||
1299 | } | 1286 | } |
1287 | /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR | ||
1288 | should match */ | ||
1289 | if (w83792d_read_value(client, W83792D_REG_I2C_ADDR) != address) | ||
1290 | return -ENODEV; | ||
1300 | 1291 | ||
1301 | /* We have either had a force parameter, or we have already detected the | 1292 | /* Put it now into bank 0 and Vendor ID High Byte */ |
1302 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ | ||
1303 | w83792d_write_value(client, | 1293 | w83792d_write_value(client, |
1304 | W83792D_REG_BANK, | 1294 | W83792D_REG_BANK, |
1305 | (w83792d_read_value(client, | 1295 | (w83792d_read_value(client, |
1306 | W83792D_REG_BANK) & 0x78) | 0x80); | 1296 | W83792D_REG_BANK) & 0x78) | 0x80); |
1307 | 1297 | ||
1308 | /* Determine the chip type. */ | 1298 | /* Determine the chip type. */ |
1309 | if (kind <= 0) { | 1299 | val1 = w83792d_read_value(client, W83792D_REG_WCHIPID); |
1310 | /* get vendor ID */ | 1300 | val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); |
1311 | val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN); | 1301 | if (val1 != 0x7a || val2 != 0x5c) |
1312 | if (val2 != 0x5c) { /* the vendor is NOT Winbond */ | 1302 | return -ENODEV; |
1313 | return -ENODEV; | ||
1314 | } | ||
1315 | val1 = w83792d_read_value(client, W83792D_REG_WCHIPID); | ||
1316 | if (val1 == 0x7a) { | ||
1317 | kind = w83792d; | ||
1318 | } else { | ||
1319 | if (kind == 0) | ||
1320 | dev_warn(&adapter->dev, | ||
1321 | "w83792d: Ignoring 'force' parameter for" | ||
1322 | " unknown chip at adapter %d, address" | ||
1323 | " 0x%02x\n", i2c_adapter_id(adapter), | ||
1324 | address); | ||
1325 | return -ENODEV; | ||
1326 | } | ||
1327 | } | ||
1328 | 1303 | ||
1329 | strlcpy(info->type, "w83792d", I2C_NAME_SIZE); | 1304 | strlcpy(info->type, "w83792d", I2C_NAME_SIZE); |
1330 | 1305 | ||
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c index 47dd398f7258..80a2191bf127 100644 --- a/drivers/hwmon/w83793.c +++ b/drivers/hwmon/w83793.c | |||
@@ -1164,7 +1164,7 @@ ERROR_SC_0: | |||
1164 | static int w83793_detect(struct i2c_client *client, int kind, | 1164 | static int w83793_detect(struct i2c_client *client, int kind, |
1165 | struct i2c_board_info *info) | 1165 | struct i2c_board_info *info) |
1166 | { | 1166 | { |
1167 | u8 tmp, bank; | 1167 | u8 tmp, bank, chip_id; |
1168 | struct i2c_adapter *adapter = client->adapter; | 1168 | struct i2c_adapter *adapter = client->adapter; |
1169 | unsigned short address = client->addr; | 1169 | unsigned short address = client->addr; |
1170 | 1170 | ||
@@ -1174,44 +1174,27 @@ static int w83793_detect(struct i2c_client *client, int kind, | |||
1174 | 1174 | ||
1175 | bank = i2c_smbus_read_byte_data(client, W83793_REG_BANKSEL); | 1175 | bank = i2c_smbus_read_byte_data(client, W83793_REG_BANKSEL); |
1176 | 1176 | ||
1177 | if (kind < 0) { | 1177 | tmp = bank & 0x80 ? 0x5c : 0xa3; |
1178 | tmp = bank & 0x80 ? 0x5c : 0xa3; | 1178 | /* Check Winbond vendor ID */ |
1179 | /* Check Winbond vendor ID */ | 1179 | if (tmp != i2c_smbus_read_byte_data(client, W83793_REG_VENDORID)) { |
1180 | if (tmp != i2c_smbus_read_byte_data(client, | 1180 | pr_debug("w83793: Detection failed at check vendor id\n"); |
1181 | W83793_REG_VENDORID)) { | 1181 | return -ENODEV; |
1182 | pr_debug("w83793: Detection failed at check " | ||
1183 | "vendor id\n"); | ||
1184 | return -ENODEV; | ||
1185 | } | ||
1186 | |||
1187 | /* If Winbond chip, address of chip and W83793_REG_I2C_ADDR | ||
1188 | should match */ | ||
1189 | if ((bank & 0x07) == 0 | ||
1190 | && i2c_smbus_read_byte_data(client, W83793_REG_I2C_ADDR) != | ||
1191 | (address << 1)) { | ||
1192 | pr_debug("w83793: Detection failed at check " | ||
1193 | "i2c addr\n"); | ||
1194 | return -ENODEV; | ||
1195 | } | ||
1196 | |||
1197 | } | 1182 | } |
1198 | 1183 | ||
1199 | /* We have either had a force parameter, or we have already detected the | 1184 | /* If Winbond chip, address of chip and W83793_REG_I2C_ADDR |
1200 | Winbond. Determine the chip type now */ | 1185 | should match */ |
1201 | 1186 | if ((bank & 0x07) == 0 | |
1202 | if (kind <= 0) { | 1187 | && i2c_smbus_read_byte_data(client, W83793_REG_I2C_ADDR) != |
1203 | if (0x7b == i2c_smbus_read_byte_data(client, | 1188 | (address << 1)) { |
1204 | W83793_REG_CHIPID)) { | 1189 | pr_debug("w83793: Detection failed at check i2c addr\n"); |
1205 | kind = w83793; | 1190 | return -ENODEV; |
1206 | } else { | ||
1207 | if (kind == 0) | ||
1208 | dev_warn(&adapter->dev, "w83793: Ignoring " | ||
1209 | "'force' parameter for unknown chip " | ||
1210 | "at address 0x%02x\n", address); | ||
1211 | return -ENODEV; | ||
1212 | } | ||
1213 | } | 1191 | } |
1214 | 1192 | ||
1193 | /* Determine the chip type now */ | ||
1194 | chip_id = i2c_smbus_read_byte_data(client, W83793_REG_CHIPID); | ||
1195 | if (chip_id != 0x7b) | ||
1196 | return -ENODEV; | ||
1197 | |||
1215 | strlcpy(info->type, "w83793", I2C_NAME_SIZE); | 1198 | strlcpy(info->type, "w83793", I2C_NAME_SIZE); |
1216 | 1199 | ||
1217 | return 0; | 1200 | return 0; |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index ea295b9fc4f4..9b6c4c10fba7 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * w83l785ts.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * w83l785ts.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | * monitoring | 3 | * monitoring |
4 | * Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2003-2009 Jean Delvare <khali@linux-fr.org> |
5 | * | 5 | * |
6 | * Inspired from the lm83 driver. The W83L785TS-S is a sensor chip made | 6 | * Inspired from the lm83 driver. The W83L785TS-S is a sensor chip made |
7 | * by Winbond. It reports a single external temperature with a 1 deg | 7 | * by Winbond. It reports a single external temperature with a 1 deg |
@@ -146,60 +146,36 @@ static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, 1); | |||
146 | */ | 146 | */ |
147 | 147 | ||
148 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 148 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
149 | static int w83l785ts_detect(struct i2c_client *new_client, int kind, | 149 | static int w83l785ts_detect(struct i2c_client *client, int kind, |
150 | struct i2c_board_info *info) | 150 | struct i2c_board_info *info) |
151 | { | 151 | { |
152 | struct i2c_adapter *adapter = new_client->adapter; | 152 | struct i2c_adapter *adapter = client->adapter; |
153 | u16 man_id; | ||
154 | u8 chip_id; | ||
153 | 155 | ||
154 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 156 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
155 | return -ENODEV; | 157 | return -ENODEV; |
156 | 158 | ||
157 | /* | 159 | /* detection */ |
158 | * Now we do the remaining detection. A negative kind means that | 160 | if ((w83l785ts_read_value(client, W83L785TS_REG_CONFIG, 0) & 0x80) |
159 | * the driver was loaded with no force parameter (default), so we | 161 | || (w83l785ts_read_value(client, W83L785TS_REG_TYPE, 0) & 0xFC)) { |
160 | * must both detect and identify the chip (actually there is only | 162 | dev_dbg(&adapter->dev, |
161 | * one possible kind of chip for now, W83L785TS-S). A zero kind means | 163 | "W83L785TS-S detection failed at 0x%02x\n", |
162 | * that the driver was loaded with the force parameter, the detection | 164 | client->addr); |
163 | * step shall be skipped. A positive kind means that the driver | 165 | return -ENODEV; |
164 | * was loaded with the force parameter and a given kind of chip is | ||
165 | * requested, so both the detection and the identification steps | ||
166 | * are skipped. | ||
167 | */ | ||
168 | if (kind < 0) { /* detection */ | ||
169 | if (((w83l785ts_read_value(new_client, | ||
170 | W83L785TS_REG_CONFIG, 0) & 0x80) != 0x00) | ||
171 | || ((w83l785ts_read_value(new_client, | ||
172 | W83L785TS_REG_TYPE, 0) & 0xFC) != 0x00)) { | ||
173 | dev_dbg(&adapter->dev, | ||
174 | "W83L785TS-S detection failed at 0x%02x.\n", | ||
175 | new_client->addr); | ||
176 | return -ENODEV; | ||
177 | } | ||
178 | } | 166 | } |
179 | 167 | ||
180 | if (kind <= 0) { /* identification */ | 168 | /* Identification */ |
181 | u16 man_id; | 169 | man_id = (w83l785ts_read_value(client, W83L785TS_REG_MAN_ID1, 0) << 8) |
182 | u8 chip_id; | 170 | + w83l785ts_read_value(client, W83L785TS_REG_MAN_ID2, 0); |
183 | 171 | chip_id = w83l785ts_read_value(client, W83L785TS_REG_CHIP_ID, 0); | |
184 | man_id = (w83l785ts_read_value(new_client, | 172 | |
185 | W83L785TS_REG_MAN_ID1, 0) << 8) + | 173 | if (man_id != 0x5CA3 /* Winbond */ |
186 | w83l785ts_read_value(new_client, | 174 | || chip_id != 0x70) { /* W83L785TS-S */ |
187 | W83L785TS_REG_MAN_ID2, 0); | 175 | dev_dbg(&adapter->dev, |
188 | chip_id = w83l785ts_read_value(new_client, | 176 | "Unsupported chip (man_id=0x%04X, chip_id=0x%02X)\n", |
189 | W83L785TS_REG_CHIP_ID, 0); | 177 | man_id, chip_id); |
190 | 178 | return -ENODEV; | |
191 | if (man_id == 0x5CA3) { /* Winbond */ | ||
192 | if (chip_id == 0x70) { /* W83L785TS-S */ | ||
193 | kind = w83l785ts; | ||
194 | } | ||
195 | } | ||
196 | |||
197 | if (kind <= 0) { /* identification failed */ | ||
198 | dev_info(&adapter->dev, | ||
199 | "Unsupported chip (man_id=0x%04X, " | ||
200 | "chip_id=0x%02X).\n", man_id, chip_id); | ||
201 | return -ENODEV; | ||
202 | } | ||
203 | } | 179 | } |
204 | 180 | ||
205 | strlcpy(info->type, "w83l785ts", I2C_NAME_SIZE); | 181 | strlcpy(info->type, "w83l785ts", I2C_NAME_SIZE); |
diff --git a/drivers/hwmon/w83l786ng.c b/drivers/hwmon/w83l786ng.c index badca769f350..27da7d2b15fb 100644 --- a/drivers/hwmon/w83l786ng.c +++ b/drivers/hwmon/w83l786ng.c | |||
@@ -590,53 +590,31 @@ w83l786ng_detect(struct i2c_client *client, int kind, | |||
590 | struct i2c_board_info *info) | 590 | struct i2c_board_info *info) |
591 | { | 591 | { |
592 | struct i2c_adapter *adapter = client->adapter; | 592 | struct i2c_adapter *adapter = client->adapter; |
593 | u16 man_id; | ||
594 | u8 chip_id; | ||
593 | 595 | ||
594 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 596 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
595 | return -ENODEV; | 597 | return -ENODEV; |
596 | } | 598 | } |
597 | 599 | ||
598 | /* | 600 | /* Detection */ |
599 | * Now we do the remaining detection. A negative kind means that | 601 | if ((w83l786ng_read_value(client, W83L786NG_REG_CONFIG) & 0x80)) { |
600 | * the driver was loaded with no force parameter (default), so we | 602 | dev_dbg(&adapter->dev, "W83L786NG detection failed at 0x%02x\n", |
601 | * must both detect and identify the chip (actually there is only | 603 | client->addr); |
602 | * one possible kind of chip for now, W83L786NG). A zero kind means | 604 | return -ENODEV; |
603 | * that the driver was loaded with the force parameter, the detection | ||
604 | * step shall be skipped. A positive kind means that the driver | ||
605 | * was loaded with the force parameter and a given kind of chip is | ||
606 | * requested, so both the detection and the identification steps | ||
607 | * are skipped. | ||
608 | */ | ||
609 | if (kind < 0) { /* detection */ | ||
610 | if (((w83l786ng_read_value(client, | ||
611 | W83L786NG_REG_CONFIG) & 0x80) != 0x00)) { | ||
612 | dev_dbg(&adapter->dev, | ||
613 | "W83L786NG detection failed at 0x%02x.\n", | ||
614 | client->addr); | ||
615 | return -ENODEV; | ||
616 | } | ||
617 | } | 605 | } |
618 | 606 | ||
619 | if (kind <= 0) { /* identification */ | 607 | /* Identification */ |
620 | u16 man_id; | 608 | man_id = (w83l786ng_read_value(client, W83L786NG_REG_MAN_ID1) << 8) + |
621 | u8 chip_id; | 609 | w83l786ng_read_value(client, W83L786NG_REG_MAN_ID2); |
622 | 610 | chip_id = w83l786ng_read_value(client, W83L786NG_REG_CHIP_ID); | |
623 | man_id = (w83l786ng_read_value(client, | ||
624 | W83L786NG_REG_MAN_ID1) << 8) + | ||
625 | w83l786ng_read_value(client, W83L786NG_REG_MAN_ID2); | ||
626 | chip_id = w83l786ng_read_value(client, W83L786NG_REG_CHIP_ID); | ||
627 | |||
628 | if (man_id == 0x5CA3) { /* Winbond */ | ||
629 | if (chip_id == 0x80) { /* W83L786NG */ | ||
630 | kind = w83l786ng; | ||
631 | } | ||
632 | } | ||
633 | 611 | ||
634 | if (kind <= 0) { /* identification failed */ | 612 | if (man_id != 0x5CA3 || /* Winbond */ |
635 | dev_info(&adapter->dev, | 613 | chip_id != 0x80) { /* W83L786NG */ |
636 | "Unsupported chip (man_id=0x%04X, " | 614 | dev_dbg(&adapter->dev, |
637 | "chip_id=0x%02X).\n", man_id, chip_id); | 615 | "Unsupported chip (man_id=0x%04X, chip_id=0x%02X)\n", |
638 | return -ENODEV; | 616 | man_id, chip_id); |
639 | } | 617 | return -ENODEV; |
640 | } | 618 | } |
641 | 619 | ||
642 | strlcpy(info->type, "w83l786ng", I2C_NAME_SIZE); | 620 | strlcpy(info->type, "w83l786ng", I2C_NAME_SIZE); |