diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-22 13:42:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-22 13:42:54 -0400 |
commit | 4e93d3e8859c834ee18dfd33051d24df8669d0c0 (patch) | |
tree | 13f5b39730857257b5040471618e9bcce30ed9cc | |
parent | a0cd30fd26a398c0c6e50c6760610d4529f17a84 (diff) | |
parent | 0087e5ef577d0d6e664be7ab4be513b6a482e7ec (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6
155 files changed, 8326 insertions, 1266 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index b9eb209318ab..26414bc87c65 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -83,3 +83,13 @@ Why: Deprecated in favour of the new ioctl-based rawiso interface, which is | |||
83 | more efficient. You should really be using libraw1394 for raw1394 | 83 | more efficient. You should really be using libraw1394 for raw1394 |
84 | access anyway. | 84 | access anyway. |
85 | Who: Jody McIntyre <scjody@steamballoon.com> | 85 | Who: Jody McIntyre <scjody@steamballoon.com> |
86 | |||
87 | --------------------------- | ||
88 | |||
89 | What: i2c sysfs name change: in1_ref, vid deprecated in favour of cpu0_vid | ||
90 | When: November 2005 | ||
91 | Files: drivers/i2c/chips/adm1025.c, drivers/i2c/chips/adm1026.c | ||
92 | Why: Match the other drivers' name for the same function, duplicate names | ||
93 | will be available until removal of old names. | ||
94 | Who: Grant Coady <gcoady@gmail.com> | ||
95 | |||
diff --git a/Documentation/i2c/busses/i2c-sis69x b/Documentation/i2c/busses/i2c-sis69x index 5be48769f65b..b88953dfd580 100644 --- a/Documentation/i2c/busses/i2c-sis69x +++ b/Documentation/i2c/busses/i2c-sis69x | |||
@@ -42,7 +42,7 @@ I suspect that this driver could be made to work for the following SiS | |||
42 | chipsets as well: 635, and 635T. If anyone owns a board with those chips | 42 | chipsets as well: 635, and 635T. If anyone owns a board with those chips |
43 | AND is willing to risk crashing & burning an otherwise well-behaved kernel | 43 | AND is willing to risk crashing & burning an otherwise well-behaved kernel |
44 | in the name of progress... please contact me at <mhoffman@lightlink.com> or | 44 | in the name of progress... please contact me at <mhoffman@lightlink.com> or |
45 | via the project's mailing list: <sensors@stimpy.netroedge.com>. Please | 45 | via the project's mailing list: <lm-sensors@lm-sensors.org>. Please |
46 | send bug reports and/or success stories as well. | 46 | send bug reports and/or success stories as well. |
47 | 47 | ||
48 | 48 | ||
diff --git a/Documentation/i2c/chips/adm1021 b/Documentation/i2c/chips/adm1021 new file mode 100644 index 000000000000..03d02bfb3df1 --- /dev/null +++ b/Documentation/i2c/chips/adm1021 | |||
@@ -0,0 +1,111 @@ | |||
1 | Kernel driver adm1021 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Analog Devices ADM1021 | ||
6 | Prefix: 'adm1021' | ||
7 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
8 | Datasheet: Publicly available at the Analog Devices website | ||
9 | * Analog Devices ADM1021A/ADM1023 | ||
10 | Prefix: 'adm1023' | ||
11 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
12 | Datasheet: Publicly available at the Analog Devices website | ||
13 | * Genesys Logic GL523SM | ||
14 | Prefix: 'gl523sm' | ||
15 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
16 | Datasheet: | ||
17 | * Intel Xeon Processor | ||
18 | Prefix: - any other - may require 'force_adm1021' parameter | ||
19 | Addresses scanned: none | ||
20 | Datasheet: Publicly available at Intel website | ||
21 | * Maxim MAX1617 | ||
22 | Prefix: 'max1617' | ||
23 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
24 | Datasheet: Publicly available at the Maxim website | ||
25 | * Maxim MAX1617A | ||
26 | Prefix: 'max1617a' | ||
27 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
28 | Datasheet: Publicly available at the Maxim website | ||
29 | * National Semiconductor LM84 | ||
30 | Prefix: 'lm84' | ||
31 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
32 | Datasheet: Publicly available at the National Semiconductor website | ||
33 | * Philips NE1617 | ||
34 | Prefix: 'max1617' (probably detected as a max1617) | ||
35 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
36 | Datasheet: Publicly available at the Philips website | ||
37 | * Philips NE1617A | ||
38 | Prefix: 'max1617' (probably detected as a max1617) | ||
39 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
40 | Datasheet: Publicly available at the Philips website | ||
41 | * TI THMC10 | ||
42 | Prefix: 'thmc10' | ||
43 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
44 | Datasheet: Publicly available at the TI website | ||
45 | * Onsemi MC1066 | ||
46 | Prefix: 'mc1066' | ||
47 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
48 | Datasheet: Publicly available at the Onsemi website | ||
49 | |||
50 | |||
51 | Authors: | ||
52 | Frodo Looijaard <frodol@dds.nl>, | ||
53 | Philip Edelbrock <phil@netroedge.com> | ||
54 | |||
55 | Module Parameters | ||
56 | ----------------- | ||
57 | |||
58 | * read_only: int | ||
59 | Don't set any values, read only mode | ||
60 | |||
61 | |||
62 | Description | ||
63 | ----------- | ||
64 | |||
65 | The chips supported by this driver are very similar. The Maxim MAX1617 is | ||
66 | the oldest; it has the problem that it is not very well detectable. The | ||
67 | MAX1617A solves that. The ADM1021 is a straight clone of the MAX1617A. | ||
68 | Ditto for the THMC10. From here on, we will refer to all these chips as | ||
69 | ADM1021-clones. | ||
70 | |||
71 | The ADM1021 and MAX1617A reports a die code, which is a sort of revision | ||
72 | code. This can help us pinpoint problems; it is not very useful | ||
73 | otherwise. | ||
74 | |||
75 | ADM1021-clones implement two temperature sensors. One of them is internal, | ||
76 | and measures the temperature of the chip itself; the other is external and | ||
77 | is realised in the form of a transistor-like device. A special alarm | ||
78 | indicates whether the remote sensor is connected. | ||
79 | |||
80 | Each sensor has its own low and high limits. When they are crossed, the | ||
81 | corresponding alarm is set and remains on as long as the temperature stays | ||
82 | out of range. Temperatures are measured in degrees Celsius. Measurements | ||
83 | are possible between -65 and +127 degrees, with a resolution of one degree. | ||
84 | |||
85 | If an alarm triggers, it will remain triggered until the hardware register | ||
86 | is read at least once. This means that the cause for the alarm may already | ||
87 | have disappeared! | ||
88 | |||
89 | This driver only updates its values each 1.5 seconds; reading it more often | ||
90 | will do no harm, but will return 'old' values. It is possible to make | ||
91 | ADM1021-clones do faster measurements, but there is really no good reason | ||
92 | for that. | ||
93 | |||
94 | Xeon support | ||
95 | ------------ | ||
96 | |||
97 | Some Xeon processors have real max1617, adm1021, or compatible chips | ||
98 | within them, with two temperature sensors. | ||
99 | |||
100 | Other Xeons have chips with only one sensor. | ||
101 | |||
102 | If you have a Xeon, and the adm1021 module loads, and both temperatures | ||
103 | appear valid, then things are good. | ||
104 | |||
105 | If the adm1021 module doesn't load, you should try this: | ||
106 | modprobe adm1021 force_adm1021=BUS,ADDRESS | ||
107 | ADDRESS can only be 0x18, 0x1a, 0x29, 0x2b, 0x4c, or 0x4e. | ||
108 | |||
109 | If you have dual Xeons you may have appear to have two separate | ||
110 | adm1021-compatible chips, or two single-temperature sensors, at distinct | ||
111 | addresses. | ||
diff --git a/Documentation/i2c/chips/adm1025 b/Documentation/i2c/chips/adm1025 new file mode 100644 index 000000000000..39d2b781b5d6 --- /dev/null +++ b/Documentation/i2c/chips/adm1025 | |||
@@ -0,0 +1,51 @@ | |||
1 | Kernel driver adm1025 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Analog Devices ADM1025, ADM1025A | ||
6 | Prefix: 'adm1025' | ||
7 | Addresses scanned: I2C 0x2c - 0x2e | ||
8 | Datasheet: Publicly available at the Analog Devices website | ||
9 | * Philips NE1619 | ||
10 | Prefix: 'ne1619' | ||
11 | Addresses scanned: I2C 0x2c - 0x2d | ||
12 | Datasheet: Publicly available at the Philips website | ||
13 | |||
14 | The NE1619 presents some differences with the original ADM1025: | ||
15 | * Only two possible addresses (0x2c - 0x2d). | ||
16 | * No temperature offset register, but we don't use it anyway. | ||
17 | * No INT mode for pin 16. We don't play with it anyway. | ||
18 | |||
19 | Authors: | ||
20 | Chen-Yuan Wu <gwu@esoft.com>, | ||
21 | Jean Delvare <khali@linux-fr.org> | ||
22 | |||
23 | Description | ||
24 | ----------- | ||
25 | |||
26 | (This is from Analog Devices.) The ADM1025 is a complete system hardware | ||
27 | monitor for microprocessor-based systems, providing measurement and limit | ||
28 | comparison of various system parameters. Five voltage measurement inputs | ||
29 | are provided, for monitoring +2.5V, +3.3V, +5V and +12V power supplies and | ||
30 | the processor core voltage. The ADM1025 can monitor a sixth power-supply | ||
31 | voltage by measuring its own VCC. One input (two pins) is dedicated to a | ||
32 | remote temperature-sensing diode and an on-chip temperature sensor allows | ||
33 | ambient temperature to be monitored. | ||
34 | |||
35 | One specificity of this chip is that the pin 11 can be hardwired in two | ||
36 | different manners. It can act as the +12V power-supply voltage analog | ||
37 | input, or as the a fifth digital entry for the VID reading (bit 4). It's | ||
38 | kind of strange since both are useful, and the reason for designing the | ||
39 | chip that way is obscure at least to me. The bit 5 of the configuration | ||
40 | register can be used to define how the chip is hardwired. Please note that | ||
41 | it is not a choice you have to make as the user. The choice was already | ||
42 | made by your motherboard's maker. If the configuration bit isn't set | ||
43 | properly, you'll have a wrong +12V reading or a wrong VID reading. The way | ||
44 | the driver handles that is to preserve this bit through the initialization | ||
45 | process, assuming that the BIOS set it up properly beforehand. If it turns | ||
46 | out not to be true in some cases, we'll provide a module parameter to force | ||
47 | modes. | ||
48 | |||
49 | This driver also supports the ADM1025A, which differs from the ADM1025 | ||
50 | only in that it has "open-drain VID inputs while the ADM1025 has on-chip | ||
51 | 100k pull-ups on the VID inputs". It doesn't make any difference for us. | ||
diff --git a/Documentation/i2c/chips/adm1026 b/Documentation/i2c/chips/adm1026 new file mode 100644 index 000000000000..473c689d7924 --- /dev/null +++ b/Documentation/i2c/chips/adm1026 | |||
@@ -0,0 +1,93 @@ | |||
1 | Kernel driver adm1026 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Analog Devices ADM1026 | ||
6 | Prefix: 'adm1026' | ||
7 | Addresses scanned: I2C 0x2c, 0x2d, 0x2e | ||
8 | Datasheet: Publicly available at the Analog Devices website | ||
9 | http://www.analog.com/en/prod/0,,766_825_ADM1026,00.html | ||
10 | |||
11 | Authors: | ||
12 | Philip Pokorny <ppokorny@penguincomputing.com> for Penguin Computing | ||
13 | Justin Thiessen <jthiessen@penguincomputing.com> | ||
14 | |||
15 | Module Parameters | ||
16 | ----------------- | ||
17 | |||
18 | * gpio_input: int array (min = 1, max = 17) | ||
19 | List of GPIO pins (0-16) to program as inputs | ||
20 | * gpio_output: int array (min = 1, max = 17) | ||
21 | List of GPIO pins (0-16) to program as outputs | ||
22 | * gpio_inverted: int array (min = 1, max = 17) | ||
23 | List of GPIO pins (0-16) to program as inverted | ||
24 | * gpio_normal: int array (min = 1, max = 17) | ||
25 | List of GPIO pins (0-16) to program as normal/non-inverted | ||
26 | * gpio_fan: int array (min = 1, max = 8) | ||
27 | List of GPIO pins (0-7) to program as fan tachs | ||
28 | |||
29 | |||
30 | Description | ||
31 | ----------- | ||
32 | |||
33 | This driver implements support for the Analog Devices ADM1026. Analog | ||
34 | Devices calls it a "complete thermal system management controller." | ||
35 | |||
36 | The ADM1026 implements three (3) temperature sensors, 17 voltage sensors, | ||
37 | 16 general purpose digital I/O lines, eight (8) fan speed sensors (8-bit), | ||
38 | an analog output and a PWM output along with limit, alarm and mask bits for | ||
39 | all of the above. There is even 8k bytes of EEPROM memory on chip. | ||
40 | |||
41 | Temperatures are measured in degrees Celsius. There are two external | ||
42 | sensor inputs and one internal sensor. Each sensor has a high and low | ||
43 | limit. If the limit is exceeded, an interrupt (#SMBALERT) can be | ||
44 | generated. The interrupts can be masked. In addition, there are over-temp | ||
45 | limits for each sensor. If this limit is exceeded, the #THERM output will | ||
46 | be asserted. The current temperature and limits have a resolution of 1 | ||
47 | degree. | ||
48 | |||
49 | Fan rotation speeds are reported in RPM (rotations per minute) but measured | ||
50 | in counts of a 22.5kHz internal clock. Each fan has a high limit which | ||
51 | corresponds to a minimum fan speed. If the limit is exceeded, an interrupt | ||
52 | can be generated. Each fan can be programmed to divide the reference clock | ||
53 | by 1, 2, 4 or 8. Not all RPM values can accurately be represented, so some | ||
54 | rounding is done. With a divider of 8, the slowest measurable speed of a | ||
55 | two pulse per revolution fan is 661 RPM. | ||
56 | |||
57 | There are 17 voltage sensors. An alarm is triggered if the voltage has | ||
58 | crossed a programmable minimum or maximum limit. Note that minimum in this | ||
59 | case always means 'closest to zero'; this is important for negative voltage | ||
60 | measurements. Several inputs have integrated attenuators so they can measure | ||
61 | higher voltages directly. 3.3V, 5V, 12V, -12V and battery voltage all have | ||
62 | dedicated inputs. There are several inputs scaled to 0-3V full-scale range | ||
63 | for SCSI terminator power. The remaining inputs are not scaled and have | ||
64 | a 0-2.5V full-scale range. A 2.5V or 1.82V reference voltage is provided | ||
65 | for negative voltage measurements. | ||
66 | |||
67 | If an alarm triggers, it will remain triggered until the hardware register | ||
68 | is read at least once. This means that the cause for the alarm may already | ||
69 | have disappeared! Note that in the current implementation, all hardware | ||
70 | registers are read whenever any data is read (unless it is less than 2.0 | ||
71 | seconds since the last update). This means that you can easily miss | ||
72 | once-only alarms. | ||
73 | |||
74 | The ADM1026 measures continuously. Analog inputs are measured about 4 | ||
75 | times a second. Fan speed measurement time depends on fan speed and | ||
76 | divisor. It can take as long as 1.5 seconds to measure all fan speeds. | ||
77 | |||
78 | The ADM1026 has the ability to automatically control fan speed based on the | ||
79 | temperature sensor inputs. Both the PWM output and the DAC output can be | ||
80 | used to control fan speed. Usually only one of these two outputs will be | ||
81 | used. Write the minimum PWM or DAC value to the appropriate control | ||
82 | register. Then set the low temperature limit in the tmin values for each | ||
83 | temperature sensor. The range of control is fixed at 20 °C, and the | ||
84 | largest difference between current and tmin of the temperature sensors sets | ||
85 | the control output. See the datasheet for several example circuits for | ||
86 | controlling fan speed with the PWM and DAC outputs. The fan speed sensors | ||
87 | do not have PWM compensation, so it is probably best to control the fan | ||
88 | voltage from the power lead rather than on the ground lead. | ||
89 | |||
90 | The datasheet shows an example application with VID signals attached to | ||
91 | GPIO lines. Unfortunately, the chip may not be connected to the VID lines | ||
92 | in this way. The driver assumes that the chips *is* connected this way to | ||
93 | get a VID voltage. | ||
diff --git a/Documentation/i2c/chips/adm1031 b/Documentation/i2c/chips/adm1031 new file mode 100644 index 000000000000..130a38382b98 --- /dev/null +++ b/Documentation/i2c/chips/adm1031 | |||
@@ -0,0 +1,35 @@ | |||
1 | Kernel driver adm1031 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Analog Devices ADM1030 | ||
6 | Prefix: 'adm1030' | ||
7 | Addresses scanned: I2C 0x2c to 0x2e | ||
8 | Datasheet: Publicly available at the Analog Devices website | ||
9 | http://products.analog.com/products/info.asp?product=ADM1030 | ||
10 | |||
11 | * Analog Devices ADM1031 | ||
12 | Prefix: 'adm1031' | ||
13 | Addresses scanned: I2C 0x2c to 0x2e | ||
14 | Datasheet: Publicly available at the Analog Devices website | ||
15 | http://products.analog.com/products/info.asp?product=ADM1031 | ||
16 | |||
17 | Authors: | ||
18 | Alexandre d'Alton <alex@alexdalton.org> | ||
19 | Jean Delvare <khali@linux-fr.org> | ||
20 | |||
21 | Description | ||
22 | ----------- | ||
23 | |||
24 | The ADM1030 and ADM1031 are digital temperature sensors and fan controllers. | ||
25 | They sense their own temperature as well as the temperature of up to one | ||
26 | (ADM1030) or two (ADM1031) external diodes. | ||
27 | |||
28 | All temperature values are given in degrees Celsius. Resolution is 0.5 | ||
29 | degree for the local temperature, 0.125 degree for the remote temperatures. | ||
30 | |||
31 | Each temperature channel has its own high and low limits, plus a critical | ||
32 | limit. | ||
33 | |||
34 | The ADM1030 monitors a single fan speed, while the ADM1031 monitors up to | ||
35 | two. Each fan channel has its own low speed limit. | ||
diff --git a/Documentation/i2c/chips/adm9240 b/Documentation/i2c/chips/adm9240 new file mode 100644 index 000000000000..35f618f32896 --- /dev/null +++ b/Documentation/i2c/chips/adm9240 | |||
@@ -0,0 +1,177 @@ | |||
1 | Kernel driver adm9240 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Analog Devices ADM9240 | ||
6 | Prefix: 'adm9240' | ||
7 | Addresses scanned: I2C 0x2c - 0x2f | ||
8 | Datasheet: Publicly available at the Analog Devices website | ||
9 | http://www.analog.com/UploadedFiles/Data_Sheets/79857778ADM9240_0.pdf | ||
10 | |||
11 | * Dallas Semiconductor DS1780 | ||
12 | Prefix: 'ds1780' | ||
13 | Addresses scanned: I2C 0x2c - 0x2f | ||
14 | Datasheet: Publicly available at the Dallas Semiconductor (Maxim) website | ||
15 | http://pdfserv.maxim-ic.com/en/ds/DS1780.pdf | ||
16 | |||
17 | * National Semiconductor LM81 | ||
18 | Prefix: 'lm81' | ||
19 | Addresses scanned: I2C 0x2c - 0x2f | ||
20 | Datasheet: Publicly available at the National Semiconductor website | ||
21 | http://www.national.com/ds.cgi/LM/LM81.pdf | ||
22 | |||
23 | Authors: | ||
24 | Frodo Looijaard <frodol@dds.nl>, | ||
25 | Philip Edelbrock <phil@netroedge.com>, | ||
26 | Michiel Rook <michiel@grendelproject.nl>, | ||
27 | Grant Coady <gcoady@gmail.com> with guidance | ||
28 | from Jean Delvare <khali@linux-fr.org> | ||
29 | |||
30 | Interface | ||
31 | --------- | ||
32 | The I2C addresses listed above assume BIOS has not changed the | ||
33 | chip MSB 5-bit address. Each chip reports a unique manufacturer | ||
34 | identification code as well as the chip revision/stepping level. | ||
35 | |||
36 | Description | ||
37 | ----------- | ||
38 | [From ADM9240] The ADM9240 is a complete system hardware monitor for | ||
39 | microprocessor-based systems, providing measurement and limit comparison | ||
40 | of up to four power supplies and two processor core voltages, plus | ||
41 | temperature, two fan speeds and chassis intrusion. Measured values can | ||
42 | be read out via an I2C-compatible serial System Management Bus, and values | ||
43 | for limit comparisons can be programmed in over the same serial bus. The | ||
44 | high speed successive approximation ADC allows frequent sampling of all | ||
45 | analog channels to ensure a fast interrupt response to any out-of-limit | ||
46 | measurement. | ||
47 | |||
48 | The ADM9240, DS1780 and LM81 are register compatible, the following | ||
49 | details are common to the three chips. Chip differences are described | ||
50 | after this section. | ||
51 | |||
52 | |||
53 | Measurements | ||
54 | ------------ | ||
55 | The measurement cycle | ||
56 | |||
57 | The adm9240 driver will take a measurement reading no faster than once | ||
58 | each two seconds. User-space may read sysfs interface faster than the | ||
59 | measurement update rate and will receive cached data from the most | ||
60 | recent measurement. | ||
61 | |||
62 | ADM9240 has a very fast 320us temperature and voltage measurement cycle | ||
63 | with independent fan speed measurement cycles counting alternating rising | ||
64 | edges of the fan tacho inputs. | ||
65 | |||
66 | DS1780 measurement cycle is about once per second including fan speed. | ||
67 | |||
68 | LM81 measurement cycle is about once per 400ms including fan speed. | ||
69 | The LM81 12-bit extended temperature measurement mode is not supported. | ||
70 | |||
71 | Temperature | ||
72 | ----------- | ||
73 | On chip temperature is reported as degrees Celsius as 9-bit signed data | ||
74 | with resolution of 0.5 degrees Celsius. High and low temperature limits | ||
75 | are 8-bit signed data with resolution of one degree Celsius. | ||
76 | |||
77 | Temperature alarm is asserted once the temperature exceeds the high limit, | ||
78 | and is cleared when the temperature falls below the temp1_max_hyst value. | ||
79 | |||
80 | Fan Speed | ||
81 | --------- | ||
82 | Two fan tacho inputs are provided, the ADM9240 gates an internal 22.5kHz | ||
83 | clock via a divider to an 8-bit counter. Fan speed (rpm) is calculated by: | ||
84 | |||
85 | rpm = (22500 * 60) / (count * divider) | ||
86 | |||
87 | Automatic fan clock divider | ||
88 | |||
89 | * User sets 0 to fan_min limit | ||
90 | - low speed alarm is disabled | ||
91 | - fan clock divider not changed | ||
92 | - auto fan clock adjuster enabled for valid fan speed reading | ||
93 | |||
94 | * User sets fan_min limit too low | ||
95 | - low speed alarm is enabled | ||
96 | - fan clock divider set to max | ||
97 | - fan_min set to register value 254 which corresponds | ||
98 | to 664 rpm on adm9240 | ||
99 | - low speed alarm will be asserted if fan speed is | ||
100 | less than minimum measurable speed | ||
101 | - auto fan clock adjuster disabled | ||
102 | |||
103 | * User sets reasonable fan speed | ||
104 | - low speed alarm is enabled | ||
105 | - fan clock divider set to suit fan_min | ||
106 | - auto fan clock adjuster enabled: adjusts fan_min | ||
107 | |||
108 | * User sets unreasonably high low fan speed limit | ||
109 | - resolution of the low speed limit may be reduced | ||
110 | - alarm will be asserted | ||
111 | - auto fan clock adjuster enabled: adjusts fan_min | ||
112 | |||
113 | * fan speed may be displayed as zero until the auto fan clock divider | ||
114 | adjuster brings fan speed clock divider back into chip measurement | ||
115 | range, this will occur within a few measurement cycles. | ||
116 | |||
117 | Analog Output | ||
118 | ------------- | ||
119 | An analog output provides a 0 to 1.25 volt signal intended for an external | ||
120 | fan speed amplifier circuit. The analog output is set to maximum value on | ||
121 | power up or reset. This doesn't do much on the test Intel SE440BX-2. | ||
122 | |||
123 | Voltage Monitor | ||
124 | |||
125 | Voltage (IN) measurement is internally scaled: | ||
126 | |||
127 | nr label nominal maximum resolution | ||
128 | mV mV mV | ||
129 | 0 +2.5V 2500 3320 13.0 | ||
130 | 1 Vccp1 2700 3600 14.1 | ||
131 | 2 +3.3V 3300 4380 17.2 | ||
132 | 3 +5V 5000 6640 26.0 | ||
133 | 4 +12V 12000 15940 62.5 | ||
134 | 5 Vccp2 2700 3600 14.1 | ||
135 | |||
136 | The reading is an unsigned 8-bit value, nominal voltage measurement is | ||
137 | represented by a reading of 192, being 3/4 of the measurement range. | ||
138 | |||
139 | An alarm is asserted for any voltage going below or above the set limits. | ||
140 | |||
141 | The driver reports and accepts voltage limits scaled to the above table. | ||
142 | |||
143 | VID Monitor | ||
144 | ----------- | ||
145 | The chip has five inputs to read the 5-bit VID and reports the mV value | ||
146 | based on detected CPU type. | ||
147 | |||
148 | Chassis Intrusion | ||
149 | ----------------- | ||
150 | An alarm is asserted when the CI pin goes active high. The ADM9240 | ||
151 | Datasheet has an example of an external temperature sensor driving | ||
152 | this pin. On an Intel SE440BX-2 the Chassis Intrusion header is | ||
153 | connected to a normally open switch. | ||
154 | |||
155 | The ADM9240 provides an internal open drain on this line, and may output | ||
156 | a 20 ms active low pulse to reset an external Chassis Intrusion latch. | ||
157 | |||
158 | Clear the CI latch by writing value 1 to the sysfs chassis_clear file. | ||
159 | |||
160 | Alarm flags reported as 16-bit word | ||
161 | |||
162 | bit label comment | ||
163 | --- ------------- -------------------------- | ||
164 | 0 +2.5 V_Error high or low limit exceeded | ||
165 | 1 VCCP_Error high or low limit exceeded | ||
166 | 2 +3.3 V_Error high or low limit exceeded | ||
167 | 3 +5 V_Error high or low limit exceeded | ||
168 | 4 Temp_Error temperature error | ||
169 | 6 FAN1_Error fan low limit exceeded | ||
170 | 7 FAN2_Error fan low limit exceeded | ||
171 | 8 +12 V_Error high or low limit exceeded | ||
172 | 9 VCCP2_Error high or low limit exceeded | ||
173 | 12 Chassis_Error CI pin went high | ||
174 | |||
175 | Remaining bits are reserved and thus undefined. It is important to note | ||
176 | that alarm bits may be cleared on read, user-space may latch alarms and | ||
177 | provide the end-user with a method to clear alarm memory. | ||
diff --git a/Documentation/i2c/chips/asb100 b/Documentation/i2c/chips/asb100 new file mode 100644 index 000000000000..ab7365e139be --- /dev/null +++ b/Documentation/i2c/chips/asb100 | |||
@@ -0,0 +1,72 @@ | |||
1 | Kernel driver asb100 | ||
2 | ==================== | ||
3 | |||
4 | Supported Chips: | ||
5 | * Asus ASB100 and ASB100-A "Bach" | ||
6 | Prefix: 'asb100' | ||
7 | Addresses scanned: I2C 0x2d | ||
8 | Datasheet: none released | ||
9 | |||
10 | Author: Mark M. Hoffman <mhoffman@lightlink.com> | ||
11 | |||
12 | Description | ||
13 | ----------- | ||
14 | |||
15 | This driver implements support for the Asus ASB100 and ASB100-A "Bach". | ||
16 | These are custom ASICs available only on Asus mainboards. Asus refuses to | ||
17 | supply a datasheet for these chips. Thanks go to many people who helped | ||
18 | investigate their hardware, including: | ||
19 | |||
20 | Vitaly V. Bursov | ||
21 | Alexander van Kaam (author of MBM for Windows) | ||
22 | Bertrik Sikken | ||
23 | |||
24 | The ASB100 implements seven voltage sensors, three fan rotation speed | ||
25 | sensors, four temperature sensors, VID lines and alarms. In addition to | ||
26 | these, the ASB100-A also implements a single PWM controller for fans 2 and | ||
27 | 3 (i.e. one setting controls both.) If you have a plain ASB100, the PWM | ||
28 | controller will simply not work (or maybe it will for you... it doesn't for | ||
29 | me). | ||
30 | |||
31 | Temperatures are measured and reported in degrees Celsius. | ||
32 | |||
33 | Fan speeds are reported in RPM (rotations per minute). An alarm is | ||
34 | triggered if the rotation speed has dropped below a programmable limit. | ||
35 | |||
36 | Voltage sensors (also known as IN sensors) report values in volts. | ||
37 | |||
38 | The VID lines encode the core voltage value: the voltage level your | ||
39 | processor should work with. This is hardcoded by the mainboard and/or | ||
40 | processor itself. It is a value in volts. | ||
41 | |||
42 | Alarms: (TODO question marks indicate may or may not work) | ||
43 | |||
44 | 0x0001 => in0 (?) | ||
45 | 0x0002 => in1 (?) | ||
46 | 0x0004 => in2 | ||
47 | 0x0008 => in3 | ||
48 | 0x0010 => temp1 (1) | ||
49 | 0x0020 => temp2 | ||
50 | 0x0040 => fan1 | ||
51 | 0x0080 => fan2 | ||
52 | 0x0100 => in4 | ||
53 | 0x0200 => in5 (?) (2) | ||
54 | 0x0400 => in6 (?) (2) | ||
55 | 0x0800 => fan3 | ||
56 | 0x1000 => chassis switch | ||
57 | 0x2000 => temp3 | ||
58 | |||
59 | Alarm Notes: | ||
60 | |||
61 | (1) This alarm will only trigger if the hysteresis value is 127C. | ||
62 | I.e. it behaves the same as w83781d. | ||
63 | |||
64 | (2) The min and max registers for these values appear to | ||
65 | be read-only or otherwise stuck at 0x00. | ||
66 | |||
67 | TODO: | ||
68 | * Experiment with fan divisors > 8. | ||
69 | * Experiment with temp. sensor types. | ||
70 | * Are there really 13 voltage inputs? Probably not... | ||
71 | * Cleanups, no doubt... | ||
72 | |||
diff --git a/Documentation/i2c/chips/ds1621 b/Documentation/i2c/chips/ds1621 new file mode 100644 index 000000000000..1fee6f1e6bc5 --- /dev/null +++ b/Documentation/i2c/chips/ds1621 | |||
@@ -0,0 +1,108 @@ | |||
1 | Kernel driver ds1621 | ||
2 | ==================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Dallas Semiconductor DS1621 | ||
6 | Prefix: 'ds1621' | ||
7 | Addresses scanned: I2C 0x48 - 0x4f | ||
8 | Datasheet: Publicly available at the Dallas Semiconductor website | ||
9 | http://www.dalsemi.com/ | ||
10 | * Dallas Semiconductor DS1625 | ||
11 | Prefix: 'ds1621' | ||
12 | Addresses scanned: I2C 0x48 - 0x4f | ||
13 | Datasheet: Publicly available at the Dallas Semiconductor website | ||
14 | http://www.dalsemi.com/ | ||
15 | |||
16 | Authors: | ||
17 | Christian W. Zuckschwerdt <zany@triq.net> | ||
18 | valuable contributions by Jan M. Sendler <sendler@sendler.de> | ||
19 | ported to 2.6 by Aurelien Jarno <aurelien@aurel32.net> | ||
20 | with the help of Jean Delvare <khali@linux-fr.org> | ||
21 | |||
22 | Module Parameters | ||
23 | ------------------ | ||
24 | |||
25 | * polarity int | ||
26 | Output's polarity: 0 = active high, 1 = active low | ||
27 | |||
28 | Description | ||
29 | ----------- | ||
30 | |||
31 | The DS1621 is a (one instance) digital thermometer and thermostat. It has | ||
32 | both high and low temperature limits which can be user defined (i.e. | ||
33 | programmed into non-volatile on-chip registers). Temperature range is -55 | ||
34 | degree Celsius to +125 in 0.5 increments. You may convert this into a | ||
35 | Fahrenheit range of -67 to +257 degrees with 0.9 steps. If polarity | ||
36 | parameter is not provided, original value is used. | ||
37 | |||
38 | As for the thermostat, behavior can also be programmed using the polarity | ||
39 | toggle. On the one hand ("heater"), the thermostat output of the chip, | ||
40 | Tout, will trigger when the low limit temperature is met or underrun and | ||
41 | stays high until the high limit is met or exceeded. On the other hand | ||
42 | ("cooler"), vice versa. That way "heater" equals "active low", whereas | ||
43 | "conditioner" equals "active high". Please note that the DS1621 data sheet | ||
44 | is somewhat misleading in this point since setting the polarity bit does | ||
45 | not simply invert Tout. | ||
46 | |||
47 | A second thing is that, during extensive testing, Tout showed a tolerance | ||
48 | of up to +/- 0.5 degrees even when compared against precise temperature | ||
49 | readings. Be sure to have a high vs. low temperature limit gap of al least | ||
50 | 1.0 degree Celsius to avoid Tout "bouncing", though! | ||
51 | |||
52 | As for alarms, you can read the alarm status of the DS1621 via the 'alarms' | ||
53 | /sys file interface. The result consists mainly of bit 6 and 5 of the | ||
54 | configuration register of the chip; bit 6 (0x40 or 64) is the high alarm | ||
55 | bit and bit 5 (0x20 or 32) the low one. These bits are set when the high or | ||
56 | low limits are met or exceeded and are reset by the module as soon as the | ||
57 | respective temperature ranges are left. | ||
58 | |||
59 | The alarm registers are in no way suitable to find out about the actual | ||
60 | status of Tout. They will only tell you about its history, whether or not | ||
61 | any of the limits have ever been met or exceeded since last power-up or | ||
62 | reset. Be aware: When testing, it showed that the status of Tout can change | ||
63 | with neither of the alarms set. | ||
64 | |||
65 | Temperature conversion of the DS1621 takes up to 1000ms; internal access to | ||
66 | non-volatile registers may last for 10ms or below. | ||
67 | |||
68 | High Accuracy Temperature Reading | ||
69 | --------------------------------- | ||
70 | |||
71 | As said before, the temperature issued via the 9-bit i2c-bus data is | ||
72 | somewhat arbitrary. Internally, the temperature conversion is of a | ||
73 | different kind that is explained (not so...) well in the DS1621 data sheet. | ||
74 | To cut the long story short: Inside the DS1621 there are two oscillators, | ||
75 | both of them biassed by a temperature coefficient. | ||
76 | |||
77 | Higher resolution of the temperature reading can be achieved using the | ||
78 | internal projection, which means taking account of REG_COUNT and REG_SLOPE | ||
79 | (the driver manages them): | ||
80 | |||
81 | Taken from Dallas Semiconductors App Note 068: 'Increasing Temperature | ||
82 | Resolution on the DS1620' and App Note 105: 'High Resolution Temperature | ||
83 | Measurement with Dallas Direct-to-Digital Temperature Sensors' | ||
84 | |||
85 | - Read the 9-bit temperature and strip the LSB (Truncate the .5 degs) | ||
86 | - The resulting value is TEMP_READ. | ||
87 | - Then, read REG_COUNT. | ||
88 | - And then, REG_SLOPE. | ||
89 | |||
90 | TEMP = TEMP_READ - 0.25 + ((REG_SLOPE - REG_COUNT) / REG_SLOPE) | ||
91 | |||
92 | Note that this is what the DONE bit in the DS1621 configuration register is | ||
93 | good for: Internally, one temperature conversion takes up to 1000ms. Before | ||
94 | that conversion is complete you will not be able to read valid things out | ||
95 | of REG_COUNT and REG_SLOPE. The DONE bit, as you may have guessed by now, | ||
96 | tells you whether the conversion is complete ("done", in plain English) and | ||
97 | thus, whether the values you read are good or not. | ||
98 | |||
99 | The DS1621 has two modes of operation: "Continuous" conversion, which can | ||
100 | be understood as the default stand-alone mode where the chip gets the | ||
101 | temperature and controls external devices via its Tout pin or tells other | ||
102 | i2c's about it if they care. The other mode is called "1SHOT", that means | ||
103 | that it only figures out about the temperature when it is explicitly told | ||
104 | to do so; this can be seen as power saving mode. | ||
105 | |||
106 | Now if you want to read REG_COUNT and REG_SLOPE, you have to either stop | ||
107 | the continuous conversions until the contents of these registers are valid, | ||
108 | or, in 1SHOT mode, you have to have one conversion made. | ||
diff --git a/Documentation/i2c/chips/eeprom b/Documentation/i2c/chips/eeprom new file mode 100644 index 000000000000..f7e8104b5764 --- /dev/null +++ b/Documentation/i2c/chips/eeprom | |||
@@ -0,0 +1,96 @@ | |||
1 | Kernel driver eeprom | ||
2 | ==================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Any EEPROM chip in the designated address range | ||
6 | Prefix: 'eeprom' | ||
7 | Addresses scanned: I2C 0x50 - 0x57 | ||
8 | Datasheets: Publicly available from: | ||
9 | Atmel (www.atmel.com), | ||
10 | Catalyst (www.catsemi.com), | ||
11 | Fairchild (www.fairchildsemi.com), | ||
12 | Microchip (www.microchip.com), | ||
13 | Philips (www.semiconductor.philips.com), | ||
14 | Rohm (www.rohm.com), | ||
15 | ST (www.st.com), | ||
16 | Xicor (www.xicor.com), | ||
17 | and others. | ||
18 | |||
19 | Chip Size (bits) Address | ||
20 | 24C01 1K 0x50 (shadows at 0x51 - 0x57) | ||
21 | 24C01A 1K 0x50 - 0x57 (Typical device on DIMMs) | ||
22 | 24C02 2K 0x50 - 0x57 | ||
23 | 24C04 4K 0x50, 0x52, 0x54, 0x56 | ||
24 | (additional data at 0x51, 0x53, 0x55, 0x57) | ||
25 | 24C08 8K 0x50, 0x54 (additional data at 0x51, 0x52, | ||
26 | 0x53, 0x55, 0x56, 0x57) | ||
27 | 24C16 16K 0x50 (additional data at 0x51 - 0x57) | ||
28 | Sony 2K 0x57 | ||
29 | |||
30 | Atmel 34C02B 2K 0x50 - 0x57, SW write protect at 0x30-37 | ||
31 | Catalyst 34FC02 2K 0x50 - 0x57, SW write protect at 0x30-37 | ||
32 | Catalyst 34RC02 2K 0x50 - 0x57, SW write protect at 0x30-37 | ||
33 | Fairchild 34W02 2K 0x50 - 0x57, SW write protect at 0x30-37 | ||
34 | Microchip 24AA52 2K 0x50 - 0x57, SW write protect at 0x30-37 | ||
35 | ST M34C02 2K 0x50 - 0x57, SW write protect at 0x30-37 | ||
36 | |||
37 | |||
38 | Authors: | ||
39 | Frodo Looijaard <frodol@dds.nl>, | ||
40 | Philip Edelbrock <phil@netroedge.com>, | ||
41 | Jean Delvare <khali@linux-fr.org>, | ||
42 | Greg Kroah-Hartman <greg@kroah.com>, | ||
43 | IBM Corp. | ||
44 | |||
45 | Description | ||
46 | ----------- | ||
47 | |||
48 | This is a simple EEPROM module meant to enable reading the first 256 bytes | ||
49 | of an EEPROM (on a SDRAM DIMM for example). However, it will access serial | ||
50 | EEPROMs on any I2C adapter. The supported devices are generically called | ||
51 | 24Cxx, and are listed above; however the numbering for these | ||
52 | industry-standard devices may vary by manufacturer. | ||
53 | |||
54 | This module was a programming exercise to get used to the new project | ||
55 | organization laid out by Frodo, but it should be at least completely | ||
56 | effective for decoding the contents of EEPROMs on DIMMs. | ||
57 | |||
58 | DIMMS will typically contain a 24C01A or 24C02, or the 34C02 variants. | ||
59 | The other devices will not be found on a DIMM because they respond to more | ||
60 | than one address. | ||
61 | |||
62 | DDC Monitors may contain any device. Often a 24C01, which responds to all 8 | ||
63 | addresses, is found. | ||
64 | |||
65 | Recent Sony Vaio laptops have an EEPROM at 0x57. We couldn't get the | ||
66 | specification, so it is guess work and far from being complete. | ||
67 | |||
68 | The Microchip 24AA52/24LCS52, ST M34C02, and others support an additional | ||
69 | software write protect register at 0x30 - 0x37 (0x20 less than the memory | ||
70 | location). The chip responds to "write quick" detection at this address but | ||
71 | does not respond to byte reads. If this register is present, the lower 128 | ||
72 | bytes of the memory array are not write protected. Any byte data write to | ||
73 | this address will write protect the memory array permanently, and the | ||
74 | device will no longer respond at the 0x30-37 address. The eeprom driver | ||
75 | does not support this register. | ||
76 | |||
77 | Lacking functionality: | ||
78 | |||
79 | * Full support for larger devices (24C04, 24C08, 24C16). These are not | ||
80 | typically found on a PC. These devices will appear as separate devices at | ||
81 | multiple addresses. | ||
82 | |||
83 | * Support for really large devices (24C32, 24C64, 24C128, 24C256, 24C512). | ||
84 | These devices require two-byte address fields and are not supported. | ||
85 | |||
86 | * Enable Writing. Again, no technical reason why not, but making it easy | ||
87 | to change the contents of the EEPROMs (on DIMMs anyway) also makes it easy | ||
88 | to disable the DIMMs (potentially preventing the computer from booting) | ||
89 | until the values are restored somehow. | ||
90 | |||
91 | Use: | ||
92 | |||
93 | After inserting the module (and any other required SMBus/i2c modules), you | ||
94 | should have some EEPROM directories in /sys/bus/i2c/devices/* of names such | ||
95 | as "0-0050". Inside each of these is a series of files, the eeprom file | ||
96 | contains the binary data from EEPROM. | ||
diff --git a/Documentation/i2c/chips/fscher b/Documentation/i2c/chips/fscher new file mode 100644 index 000000000000..64031659aff3 --- /dev/null +++ b/Documentation/i2c/chips/fscher | |||
@@ -0,0 +1,169 @@ | |||
1 | Kernel driver fscher | ||
2 | ==================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Fujitsu-Siemens Hermes chip | ||
6 | Prefix: 'fscher' | ||
7 | Addresses scanned: I2C 0x73 | ||
8 | |||
9 | Authors: | ||
10 | Reinhard Nissl <rnissl@gmx.de> based on work | ||
11 | from Hermann Jung <hej@odn.de>, | ||
12 | Frodo Looijaard <frodol@dds.nl>, | ||
13 | Philip Edelbrock <phil@netroedge.com> | ||
14 | |||
15 | Description | ||
16 | ----------- | ||
17 | |||
18 | This driver implements support for the Fujitsu-Siemens Hermes chip. It is | ||
19 | described in the 'Register Set Specification BMC Hermes based Systemboard' | ||
20 | from Fujitsu-Siemens. | ||
21 | |||
22 | The Hermes chip implements a hardware-based system management, e.g. for | ||
23 | controlling fan speed and core voltage. There is also a watchdog counter on | ||
24 | the chip which can trigger an alarm and even shut the system down. | ||
25 | |||
26 | The chip provides three temperature values (CPU, motherboard and | ||
27 | auxiliary), three voltage values (+12V, +5V and battery) and three fans | ||
28 | (power supply, CPU and auxiliary). | ||
29 | |||
30 | Temperatures are measured in degrees Celsius. The resolution is 1 degree. | ||
31 | |||
32 | Fan rotation speeds are reported in RPM (rotations per minute). The value | ||
33 | can be divided by a programmable divider (1, 2 or 4) which is stored on | ||
34 | the chip. | ||
35 | |||
36 | Voltage sensors (also known as "in" sensors) report their values in volts. | ||
37 | |||
38 | All values are reported as final values from the driver. There is no need | ||
39 | for further calculations. | ||
40 | |||
41 | |||
42 | Detailed description | ||
43 | -------------------- | ||
44 | |||
45 | Below you'll find a single line description of all the bit values. With | ||
46 | this information, you're able to decode e. g. alarms, wdog, etc. To make | ||
47 | use of the watchdog, you'll need to set the watchdog time and enable the | ||
48 | watchdog. After that it is necessary to restart the watchdog time within | ||
49 | the specified period of time, or a system reset will occur. | ||
50 | |||
51 | * revision | ||
52 | READING & 0xff = 0x??: HERMES revision identification | ||
53 | |||
54 | * alarms | ||
55 | READING & 0x80 = 0x80: CPU throttling active | ||
56 | READING & 0x80 = 0x00: CPU running at full speed | ||
57 | |||
58 | READING & 0x10 = 0x10: software event (see control:1) | ||
59 | READING & 0x10 = 0x00: no software event | ||
60 | |||
61 | READING & 0x08 = 0x08: watchdog event (see wdog:2) | ||
62 | READING & 0x08 = 0x00: no watchdog event | ||
63 | |||
64 | READING & 0x02 = 0x02: thermal event (see temp*:1) | ||
65 | READING & 0x02 = 0x00: no thermal event | ||
66 | |||
67 | READING & 0x01 = 0x01: fan event (see fan*:1) | ||
68 | READING & 0x01 = 0x00: no fan event | ||
69 | |||
70 | READING & 0x13 ! 0x00: ALERT LED is flashing | ||
71 | |||
72 | * control | ||
73 | READING & 0x01 = 0x01: software event | ||
74 | READING & 0x01 = 0x00: no software event | ||
75 | |||
76 | WRITING & 0x01 = 0x01: set software event | ||
77 | WRITING & 0x01 = 0x00: clear software event | ||
78 | |||
79 | * watchdog_control | ||
80 | READING & 0x80 = 0x80: power off on watchdog event while thermal event | ||
81 | READING & 0x80 = 0x00: watchdog power off disabled (just system reset enabled) | ||
82 | |||
83 | READING & 0x40 = 0x40: watchdog timebase 60 seconds (see also wdog:1) | ||
84 | READING & 0x40 = 0x00: watchdog timebase 2 seconds | ||
85 | |||
86 | READING & 0x10 = 0x10: watchdog enabled | ||
87 | READING & 0x10 = 0x00: watchdog disabled | ||
88 | |||
89 | WRITING & 0x80 = 0x80: enable "power off on watchdog event while thermal event" | ||
90 | WRITING & 0x80 = 0x00: disable "power off on watchdog event while thermal event" | ||
91 | |||
92 | WRITING & 0x40 = 0x40: set watchdog timebase to 60 seconds | ||
93 | WRITING & 0x40 = 0x00: set watchdog timebase to 2 seconds | ||
94 | |||
95 | WRITING & 0x20 = 0x20: disable watchdog | ||
96 | |||
97 | WRITING & 0x10 = 0x10: enable watchdog / restart watchdog time | ||
98 | |||
99 | * watchdog_state | ||
100 | READING & 0x02 = 0x02: watchdog system reset occurred | ||
101 | READING & 0x02 = 0x00: no watchdog system reset occurred | ||
102 | |||
103 | WRITING & 0x02 = 0x02: clear watchdog event | ||
104 | |||
105 | * watchdog_preset | ||
106 | READING & 0xff = 0x??: configured watch dog time in units (see wdog:3 0x40) | ||
107 | |||
108 | WRITING & 0xff = 0x??: configure watch dog time in units | ||
109 | |||
110 | * in* (0: +5V, 1: +12V, 2: onboard 3V battery) | ||
111 | READING: actual voltage value | ||
112 | |||
113 | * temp*_status (1: CPU sensor, 2: onboard sensor, 3: auxiliary sensor) | ||
114 | READING & 0x02 = 0x02: thermal event (overtemperature) | ||
115 | READING & 0x02 = 0x00: no thermal event | ||
116 | |||
117 | READING & 0x01 = 0x01: sensor is working | ||
118 | READING & 0x01 = 0x00: sensor is faulty | ||
119 | |||
120 | WRITING & 0x02 = 0x02: clear thermal event | ||
121 | |||
122 | * temp*_input (1: CPU sensor, 2: onboard sensor, 3: auxiliary sensor) | ||
123 | READING: actual temperature value | ||
124 | |||
125 | * fan*_status (1: power supply fan, 2: CPU fan, 3: auxiliary fan) | ||
126 | READING & 0x04 = 0x04: fan event (fan fault) | ||
127 | READING & 0x04 = 0x00: no fan event | ||
128 | |||
129 | WRITING & 0x04 = 0x04: clear fan event | ||
130 | |||
131 | * fan*_div (1: power supply fan, 2: CPU fan, 3: auxiliary fan) | ||
132 | Divisors 2,4 and 8 are supported, both for reading and writing | ||
133 | |||
134 | * fan*_pwm (1: power supply fan, 2: CPU fan, 3: auxiliary fan) | ||
135 | READING & 0xff = 0x00: fan may be switched off | ||
136 | READING & 0xff = 0x01: fan must run at least at minimum speed (supply: 6V) | ||
137 | READING & 0xff = 0xff: fan must run at maximum speed (supply: 12V) | ||
138 | READING & 0xff = 0x??: fan must run at least at given speed (supply: 6V..12V) | ||
139 | |||
140 | WRITING & 0xff = 0x00: fan may be switched off | ||
141 | WRITING & 0xff = 0x01: fan must run at least at minimum speed (supply: 6V) | ||
142 | WRITING & 0xff = 0xff: fan must run at maximum speed (supply: 12V) | ||
143 | WRITING & 0xff = 0x??: fan must run at least at given speed (supply: 6V..12V) | ||
144 | |||
145 | * fan*_input (1: power supply fan, 2: CPU fan, 3: auxiliary fan) | ||
146 | READING: actual RPM value | ||
147 | |||
148 | |||
149 | Limitations | ||
150 | ----------- | ||
151 | |||
152 | * Measuring fan speed | ||
153 | It seems that the chip counts "ripples" (typical fans produce 2 ripples per | ||
154 | rotation while VERAX fans produce 18) in a 9-bit register. This register is | ||
155 | read out every second, then the ripple prescaler (2, 4 or 8) is applied and | ||
156 | the result is stored in the 8 bit output register. Due to the limitation of | ||
157 | the counting register to 9 bits, it is impossible to measure a VERAX fan | ||
158 | properly (even with a prescaler of 8). At its maximum speed of 3500 RPM the | ||
159 | fan produces 1080 ripples per second which causes the counting register to | ||
160 | overflow twice, leading to only 186 RPM. | ||
161 | |||
162 | * Measuring input voltages | ||
163 | in2 ("battery") reports the voltage of the onboard lithium battery and not | ||
164 | +3.3V from the power supply. | ||
165 | |||
166 | * Undocumented features | ||
167 | Fujitsu-Siemens Computers has not documented all features of the chip so | ||
168 | far. Their software, System Guard, shows that there are a still some | ||
169 | features which cannot be controlled by this implementation. | ||
diff --git a/Documentation/i2c/chips/gl518sm b/Documentation/i2c/chips/gl518sm new file mode 100644 index 000000000000..ce0881883bca --- /dev/null +++ b/Documentation/i2c/chips/gl518sm | |||
@@ -0,0 +1,74 @@ | |||
1 | Kernel driver gl518sm | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Genesys Logic GL518SM release 0x00 | ||
6 | Prefix: 'gl518sm' | ||
7 | Addresses scanned: I2C 0x2c and 0x2d | ||
8 | Datasheet: http://www.genesyslogic.com/pdf | ||
9 | * Genesys Logic GL518SM release 0x80 | ||
10 | Prefix: 'gl518sm' | ||
11 | Addresses scanned: I2C 0x2c and 0x2d | ||
12 | Datasheet: http://www.genesyslogic.com/pdf | ||
13 | |||
14 | Authors: | ||
15 | Frodo Looijaard <frodol@dds.nl>, | ||
16 | Kyösti Mälkki <kmalkki@cc.hut.fi> | ||
17 | Hong-Gunn Chew <hglinux@gunnet.org> | ||
18 | Jean Delvare <khali@linux-fr.org> | ||
19 | |||
20 | Description | ||
21 | ----------- | ||
22 | |||
23 | IMPORTANT: | ||
24 | |||
25 | For the revision 0x00 chip, the in0, in1, and in2 values (+5V, +3V, | ||
26 | and +12V) CANNOT be read. This is a limitation of the chip, not the driver. | ||
27 | |||
28 | This driver supports the Genesys Logic GL518SM chip. There are at least | ||
29 | two revision of this chip, which we call revision 0x00 and 0x80. Revision | ||
30 | 0x80 chips support the reading of all voltages and revision 0x00 only | ||
31 | for VIN3. | ||
32 | |||
33 | The GL518SM implements one temperature sensor, two fan rotation speed | ||
34 | sensors, and four voltage sensors. It can report alarms through the | ||
35 | computer speakers. | ||
36 | |||
37 | Temperatures are measured in degrees Celsius. An alarm goes off while the | ||
38 | temperature is above the over temperature limit, and has not yet dropped | ||
39 | below the hysteresis limit. The alarm always reflects the current | ||
40 | situation. Measurements are guaranteed between -10 degrees and +110 | ||
41 | degrees, with a accuracy of +/-3 degrees. | ||
42 | |||
43 | Rotation speeds are reported in RPM (rotations per minute). An alarm is | ||
44 | triggered if the rotation speed has dropped below a programmable limit. In | ||
45 | case when you have selected to turn fan1 off, no fan1 alarm is triggered. | ||
46 | |||
47 | Fan readings can be divided by a programmable divider (1, 2, 4 or 8) to | ||
48 | give the readings more range or accuracy. Not all RPM values can | ||
49 | accurately be represented, so some rounding is done. With a divider | ||
50 | of 2, the lowest representable value is around 1900 RPM. | ||
51 | |||
52 | Voltage sensors (also known as VIN sensors) report their values in volts. | ||
53 | An alarm is triggered if the voltage has crossed a programmable minimum or | ||
54 | maximum limit. Note that minimum in this case always means 'closest to | ||
55 | zero'; this is important for negative voltage measurements. The VDD input | ||
56 | measures voltages between 0.000 and 5.865 volt, with a resolution of 0.023 | ||
57 | volt. The other inputs measure voltages between 0.000 and 4.845 volt, with | ||
58 | a resolution of 0.019 volt. Note that revision 0x00 chips do not support | ||
59 | reading the current voltage of any input except for VIN3; limit setting and | ||
60 | alarms work fine, though. | ||
61 | |||
62 | When an alarm is triggered, you can be warned by a beeping signal through your | ||
63 | computer speaker. It is possible to enable all beeping globally, or only the | ||
64 | beeping for some alarms. | ||
65 | |||
66 | If an alarm triggers, it will remain triggered until the hardware register | ||
67 | is read at least once (except for temperature alarms). This means that the | ||
68 | cause for the alarm may already have disappeared! Note that in the current | ||
69 | implementation, all hardware registers are read whenever any data is read | ||
70 | (unless it is less than 1.5 seconds since the last update). This means that | ||
71 | you can easily miss once-only alarms. | ||
72 | |||
73 | The GL518SM only updates its values each 1.5 seconds; reading it more often | ||
74 | will do no harm, but will return 'old' values. | ||
diff --git a/Documentation/i2c/chips/it87 b/Documentation/i2c/chips/it87 new file mode 100644 index 000000000000..0d0195040d88 --- /dev/null +++ b/Documentation/i2c/chips/it87 | |||
@@ -0,0 +1,96 @@ | |||
1 | Kernel driver it87 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * IT8705F | ||
6 | Prefix: 'it87' | ||
7 | Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports) | ||
8 | Datasheet: Publicly available at the ITE website | ||
9 | http://www.ite.com.tw/ | ||
10 | * IT8712F | ||
11 | Prefix: 'it8712' | ||
12 | Addresses scanned: I2C 0x28 - 0x2f | ||
13 | from Super I/O config space, or default ISA 0x290 (8 I/O ports) | ||
14 | Datasheet: Publicly available at the ITE website | ||
15 | http://www.ite.com.tw/ | ||
16 | * SiS950 [clone of IT8705F] | ||
17 | Prefix: 'sis950' | ||
18 | Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports) | ||
19 | Datasheet: No longer be available | ||
20 | |||
21 | Author: Christophe Gauthron <chrisg@0-in.com> | ||
22 | |||
23 | |||
24 | Module Parameters | ||
25 | ----------------- | ||
26 | |||
27 | * update_vbat: int | ||
28 | |||
29 | 0 if vbat should report power on value, 1 if vbat should be updated after | ||
30 | each read. Default is 0. On some boards the battery voltage is provided | ||
31 | by either the battery or the onboard power supply. Only the first reading | ||
32 | at power on will be the actual battery voltage (which the chip does | ||
33 | automatically). On other boards the battery voltage is always fed to | ||
34 | the chip so can be read at any time. Excessive reading may decrease | ||
35 | battery life but no information is given in the datasheet. | ||
36 | |||
37 | * fix_pwm_polarity int | ||
38 | |||
39 | Force PWM polarity to active high (DANGEROUS). Some chips are | ||
40 | misconfigured by BIOS - PWM values would be inverted. This option tries | ||
41 | to fix this. Please contact your BIOS manufacturer and ask him for fix. | ||
42 | |||
43 | Description | ||
44 | ----------- | ||
45 | |||
46 | This driver implements support for the IT8705F, IT8712F and SiS950 chips. | ||
47 | |||
48 | This driver also supports IT8712F, which adds SMBus access, and a VID | ||
49 | input, used to report the Vcore voltage of the Pentium processor. | ||
50 | The IT8712F additionally features VID inputs. | ||
51 | |||
52 | These chips are 'Super I/O chips', supporting floppy disks, infrared ports, | ||
53 | joysticks and other miscellaneous stuff. For hardware monitoring, they | ||
54 | include an 'environment controller' with 3 temperature sensors, 3 fan | ||
55 | rotation speed sensors, 8 voltage sensors, and associated alarms. | ||
56 | |||
57 | Temperatures are measured in degrees Celsius. An alarm is triggered once | ||
58 | when the Overtemperature Shutdown limit is crossed. | ||
59 | |||
60 | Fan rotation speeds are reported in RPM (rotations per minute). An alarm is | ||
61 | triggered if the rotation speed has dropped below a programmable limit. Fan | ||
62 | readings can be divided by a programmable divider (1, 2, 4 or 8) to give the | ||
63 | readings more range or accuracy. Not all RPM values can accurately be | ||
64 | represented, so some rounding is done. With a divider of 2, the lowest | ||
65 | representable value is around 2600 RPM. | ||
66 | |||
67 | Voltage sensors (also known as IN sensors) report their values in volts. An | ||
68 | alarm is triggered if the voltage has crossed a programmable minimum or | ||
69 | maximum limit. Note that minimum in this case always means 'closest to | ||
70 | zero'; this is important for negative voltage measurements. All voltage | ||
71 | inputs can measure voltages between 0 and 4.08 volts, with a resolution of | ||
72 | 0.016 volt. The battery voltage in8 does not have limit registers. | ||
73 | |||
74 | The VID lines (IT8712F only) encode the core voltage value: the voltage | ||
75 | level your processor should work with. This is hardcoded by the mainboard | ||
76 | and/or processor itself. It is a value in volts. | ||
77 | |||
78 | If an alarm triggers, it will remain triggered until the hardware register | ||
79 | is read at least once. This means that the cause for the alarm may already | ||
80 | have disappeared! Note that in the current implementation, all hardware | ||
81 | registers are read whenever any data is read (unless it is less than 1.5 | ||
82 | seconds since the last update). This means that you can easily miss | ||
83 | once-only alarms. | ||
84 | |||
85 | The IT87xx only updates its values each 1.5 seconds; reading it more often | ||
86 | will do no harm, but will return 'old' values. | ||
87 | |||
88 | To change sensor N to a thermistor, 'echo 2 > tempN_type' where N is 1, 2, | ||
89 | or 3. To change sensor N to a thermal diode, 'echo 3 > tempN_type'. | ||
90 | Give 0 for unused sensor. Any other value is invalid. To configure this at | ||
91 | startup, consult lm_sensors's /etc/sensors.conf. (2 = thermistor; | ||
92 | 3 = thermal diode) | ||
93 | |||
94 | The fan speed control features are limited to manual PWM mode. Automatic | ||
95 | "Smart Guardian" mode control handling is not implemented. However | ||
96 | if you want to go for "manual mode" just write 1 to pwmN_enable. | ||
diff --git a/Documentation/i2c/chips/lm63 b/Documentation/i2c/chips/lm63 new file mode 100644 index 000000000000..31660bf97979 --- /dev/null +++ b/Documentation/i2c/chips/lm63 | |||
@@ -0,0 +1,57 @@ | |||
1 | Kernel driver lm63 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor LM63 | ||
6 | Prefix: 'lm63' | ||
7 | Addresses scanned: I2C 0x4c | ||
8 | Datasheet: Publicly available at the National Semiconductor website | ||
9 | http://www.national.com/pf/LM/LM63.html | ||
10 | |||
11 | Author: Jean Delvare <khali@linux-fr.org> | ||
12 | |||
13 | Thanks go to Tyan and especially Alex Buckingham for setting up a remote | ||
14 | access to their S4882 test platform for this driver. | ||
15 | http://www.tyan.com/ | ||
16 | |||
17 | Description | ||
18 | ----------- | ||
19 | |||
20 | The LM63 is a digital temperature sensor with integrated fan monitoring | ||
21 | and control. | ||
22 | |||
23 | The LM63 is basically an LM86 with fan speed monitoring and control | ||
24 | capabilities added. It misses some of the LM86 features though: | ||
25 | - No low limit for local temperature. | ||
26 | - No critical limit for local temperature. | ||
27 | - Critical limit for remote temperature can be changed only once. We | ||
28 | will consider that the critical limit is read-only. | ||
29 | |||
30 | The datasheet isn't very clear about what the tachometer reading is. | ||
31 | |||
32 | An explanation from National Semiconductor: The two lower bits of the read | ||
33 | value have to be masked out. The value is still 16 bit in width. | ||
34 | |||
35 | All temperature values are given in degrees Celsius. Resolution is 1.0 | ||
36 | degree for the local temperature, 0.125 degree for the remote temperature. | ||
37 | |||
38 | The fan speed is measured using a tachometer. Contrary to most chips which | ||
39 | store the value in an 8-bit register and have a selectable clock divider | ||
40 | to make sure that the result will fit in the register, the LM63 uses 16-bit | ||
41 | value for measuring the speed of the fan. It can measure fan speeds down to | ||
42 | 83 RPM, at least in theory. | ||
43 | |||
44 | Note that the pin used for fan monitoring is shared with an alert out | ||
45 | function. Depending on how the board designer wanted to use the chip, fan | ||
46 | speed monitoring will or will not be possible. The proper chip configuration | ||
47 | is left to the BIOS, and the driver will blindly trust it. | ||
48 | |||
49 | A PWM output can be used to control the speed of the fan. The LM63 has two | ||
50 | PWM modes: manual and automatic. Automatic mode is not fully implemented yet | ||
51 | (you cannot define your custom PWM/temperature curve), and mode change isn't | ||
52 | supported either. | ||
53 | |||
54 | The lm63 driver will not update its values more frequently than every | ||
55 | second; reading them more often will do no harm, but will return 'old' | ||
56 | values. | ||
57 | |||
diff --git a/Documentation/i2c/chips/lm75 b/Documentation/i2c/chips/lm75 new file mode 100644 index 000000000000..8e6356fe05d7 --- /dev/null +++ b/Documentation/i2c/chips/lm75 | |||
@@ -0,0 +1,65 @@ | |||
1 | Kernel driver lm75 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor LM75 | ||
6 | Prefix: 'lm75' | ||
7 | Addresses scanned: I2C 0x48 - 0x4f | ||
8 | Datasheet: Publicly available at the National Semiconductor website | ||
9 | http://www.national.com/ | ||
10 | * Dallas Semiconductor DS75 | ||
11 | Prefix: 'lm75' | ||
12 | Addresses scanned: I2C 0x48 - 0x4f | ||
13 | Datasheet: Publicly available at the Dallas Semiconductor website | ||
14 | http://www.maxim-ic.com/ | ||
15 | * Dallas Semiconductor DS1775 | ||
16 | Prefix: 'lm75' | ||
17 | Addresses scanned: I2C 0x48 - 0x4f | ||
18 | Datasheet: Publicly available at the Dallas Semiconductor website | ||
19 | http://www.maxim-ic.com/ | ||
20 | * Maxim MAX6625, MAX6626 | ||
21 | Prefix: 'lm75' | ||
22 | Addresses scanned: I2C 0x48 - 0x4b | ||
23 | Datasheet: Publicly available at the Maxim website | ||
24 | http://www.maxim-ic.com/ | ||
25 | * Microchip (TelCom) TCN75 | ||
26 | Prefix: 'lm75' | ||
27 | Addresses scanned: I2C 0x48 - 0x4f | ||
28 | Datasheet: Publicly available at the Microchip website | ||
29 | http://www.microchip.com/ | ||
30 | |||
31 | Author: Frodo Looijaard <frodol@dds.nl> | ||
32 | |||
33 | Description | ||
34 | ----------- | ||
35 | |||
36 | The LM75 implements one temperature sensor. Limits can be set through the | ||
37 | Overtemperature Shutdown register and Hysteresis register. Each value can be | ||
38 | set and read to half-degree accuracy. | ||
39 | An alarm is issued (usually to a connected LM78) when the temperature | ||
40 | gets higher then the Overtemperature Shutdown value; it stays on until | ||
41 | the temperature falls below the Hysteresis value. | ||
42 | All temperatures are in degrees Celsius, and are guaranteed within a | ||
43 | range of -55 to +125 degrees. | ||
44 | |||
45 | The LM75 only updates its values each 1.5 seconds; reading it more often | ||
46 | will do no harm, but will return 'old' values. | ||
47 | |||
48 | The LM75 is usually used in combination with LM78-like chips, to measure | ||
49 | the temperature of the processor(s). | ||
50 | |||
51 | The DS75, DS1775, MAX6625, and MAX6626 are supported as well. | ||
52 | They are not distinguished from an LM75. While most of these chips | ||
53 | have three additional bits of accuracy (12 vs. 9 for the LM75), | ||
54 | the additional bits are not supported. Not only that, but these chips will | ||
55 | not be detected if not in 9-bit precision mode (use the force parameter if | ||
56 | needed). | ||
57 | |||
58 | The TCN75 is supported as well, and is not distinguished from an LM75. | ||
59 | |||
60 | The LM75 is essentially an industry standard; there may be other | ||
61 | LM75 clones not listed here, with or without various enhancements, | ||
62 | that are supported. | ||
63 | |||
64 | The LM77 is not supported, contrary to what we pretended for a long time. | ||
65 | Both chips are simply not compatible, value encoding differs. | ||
diff --git a/Documentation/i2c/chips/lm77 b/Documentation/i2c/chips/lm77 new file mode 100644 index 000000000000..57c3a46d6370 --- /dev/null +++ b/Documentation/i2c/chips/lm77 | |||
@@ -0,0 +1,22 @@ | |||
1 | Kernel driver lm77 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor LM77 | ||
6 | Prefix: 'lm77' | ||
7 | Addresses scanned: I2C 0x48 - 0x4b | ||
8 | Datasheet: Publicly available at the National Semiconductor website | ||
9 | http://www.national.com/ | ||
10 | |||
11 | Author: Andras BALI <drewie@freemail.hu> | ||
12 | |||
13 | Description | ||
14 | ----------- | ||
15 | |||
16 | The LM77 implements one temperature sensor. The temperature | ||
17 | sensor incorporates a band-gap type temperature sensor, | ||
18 | 10-bit ADC, and a digital comparator with user-programmable upper | ||
19 | and lower limit values. | ||
20 | |||
21 | Limits can be set through the Overtemperature Shutdown register and | ||
22 | Hysteresis register. | ||
diff --git a/Documentation/i2c/chips/lm78 b/Documentation/i2c/chips/lm78 new file mode 100644 index 000000000000..357086ed7f64 --- /dev/null +++ b/Documentation/i2c/chips/lm78 | |||
@@ -0,0 +1,82 @@ | |||
1 | Kernel driver lm78 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor LM78 | ||
6 | Prefix: 'lm78' | ||
7 | Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) | ||
8 | Datasheet: Publicly available at the National Semiconductor website | ||
9 | http://www.national.com/ | ||
10 | * National Semiconductor LM78-J | ||
11 | Prefix: 'lm78-j' | ||
12 | Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) | ||
13 | Datasheet: Publicly available at the National Semiconductor website | ||
14 | http://www.national.com/ | ||
15 | * National Semiconductor LM79 | ||
16 | Prefix: 'lm79' | ||
17 | Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) | ||
18 | Datasheet: Publicly available at the National Semiconductor website | ||
19 | http://www.national.com/ | ||
20 | |||
21 | Author: Frodo Looijaard <frodol@dds.nl> | ||
22 | |||
23 | Description | ||
24 | ----------- | ||
25 | |||
26 | This driver implements support for the National Semiconductor LM78, LM78-J | ||
27 | and LM79. They are described as 'Microprocessor System Hardware Monitors'. | ||
28 | |||
29 | There is almost no difference between the three supported chips. Functionally, | ||
30 | the LM78 and LM78-J are exactly identical. The LM79 has one more VID line, | ||
31 | which is used to report the lower voltages newer Pentium processors use. | ||
32 | From here on, LM7* means either of these three types. | ||
33 | |||
34 | The LM7* implements one temperature sensor, three fan rotation speed sensors, | ||
35 | seven voltage sensors, VID lines, alarms, and some miscellaneous stuff. | ||
36 | |||
37 | Temperatures are measured in degrees Celsius. An alarm is triggered once | ||
38 | when the Overtemperature Shutdown limit is crossed; it is triggered again | ||
39 | as soon as it drops below the Hysteresis value. A more useful behavior | ||
40 | can be found by setting the Hysteresis value to +127 degrees Celsius; in | ||
41 | this case, alarms are issued during all the time when the actual temperature | ||
42 | is above the Overtemperature Shutdown value. Measurements are guaranteed | ||
43 | between -55 and +125 degrees, with a resolution of 1 degree. | ||
44 | |||
45 | Fan rotation speeds are reported in RPM (rotations per minute). An alarm is | ||
46 | triggered if the rotation speed has dropped below a programmable limit. Fan | ||
47 | readings can be divided by a programmable divider (1, 2, 4 or 8) to give | ||
48 | the readings more range or accuracy. Not all RPM values can accurately be | ||
49 | represented, so some rounding is done. With a divider of 2, the lowest | ||
50 | representable value is around 2600 RPM. | ||
51 | |||
52 | Voltage sensors (also known as IN sensors) report their values in volts. | ||
53 | An alarm is triggered if the voltage has crossed a programmable minimum | ||
54 | or maximum limit. Note that minimum in this case always means 'closest to | ||
55 | zero'; this is important for negative voltage measurements. All voltage | ||
56 | inputs can measure voltages between 0 and 4.08 volts, with a resolution | ||
57 | of 0.016 volt. | ||
58 | |||
59 | The VID lines encode the core voltage value: the voltage level your processor | ||
60 | should work with. This is hardcoded by the mainboard and/or processor itself. | ||
61 | It is a value in volts. When it is unconnected, you will often find the | ||
62 | value 3.50 V here. | ||
63 | |||
64 | In addition to the alarms described above, there are a couple of additional | ||
65 | ones. There is a BTI alarm, which gets triggered when an external chip has | ||
66 | crossed its limits. Usually, this is connected to all LM75 chips; if at | ||
67 | least one crosses its limits, this bit gets set. The CHAS alarm triggers | ||
68 | if your computer case is open. The FIFO alarms should never trigger; it | ||
69 | indicates an internal error. The SMI_IN alarm indicates some other chip | ||
70 | has triggered an SMI interrupt. As we do not use SMI interrupts at all, | ||
71 | this condition usually indicates there is a problem with some other | ||
72 | device. | ||
73 | |||
74 | If an alarm triggers, it will remain triggered until the hardware register | ||
75 | is read at least once. This means that the cause for the alarm may | ||
76 | already have disappeared! Note that in the current implementation, all | ||
77 | hardware registers are read whenever any data is read (unless it is less | ||
78 | than 1.5 seconds since the last update). This means that you can easily | ||
79 | miss once-only alarms. | ||
80 | |||
81 | The LM7* only updates its values each 1.5 seconds; reading it more often | ||
82 | will do no harm, but will return 'old' values. | ||
diff --git a/Documentation/i2c/chips/lm80 b/Documentation/i2c/chips/lm80 new file mode 100644 index 000000000000..cb5b407ba3e6 --- /dev/null +++ b/Documentation/i2c/chips/lm80 | |||
@@ -0,0 +1,56 @@ | |||
1 | Kernel driver lm80 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor LM80 | ||
6 | Prefix: 'lm80' | ||
7 | Addresses scanned: I2C 0x28 - 0x2f | ||
8 | Datasheet: Publicly available at the National Semiconductor website | ||
9 | http://www.national.com/ | ||
10 | |||
11 | Authors: | ||
12 | Frodo Looijaard <frodol@dds.nl>, | ||
13 | Philip Edelbrock <phil@netroedge.com> | ||
14 | |||
15 | Description | ||
16 | ----------- | ||
17 | |||
18 | This driver implements support for the National Semiconductor LM80. | ||
19 | It is described as a 'Serial Interface ACPI-Compatible Microprocessor | ||
20 | System Hardware Monitor'. | ||
21 | |||
22 | The LM80 implements one temperature sensor, two fan rotation speed sensors, | ||
23 | seven voltage sensors, alarms, and some miscellaneous stuff. | ||
24 | |||
25 | Temperatures are measured in degrees Celsius. There are two sets of limits | ||
26 | which operate independently. When the HOT Temperature Limit is crossed, | ||
27 | this will cause an alarm that will be reasserted until the temperature | ||
28 | drops below the HOT Hysteresis. The Overtemperature Shutdown (OS) limits | ||
29 | should work in the same way (but this must be checked; the datasheet | ||
30 | is unclear about this). Measurements are guaranteed between -55 and | ||
31 | +125 degrees. The current temperature measurement has a resolution of | ||
32 | 0.0625 degrees; the limits have a resolution of 1 degree. | ||
33 | |||
34 | Fan rotation speeds are reported in RPM (rotations per minute). An alarm is | ||
35 | triggered if the rotation speed has dropped below a programmable limit. Fan | ||
36 | readings can be divided by a programmable divider (1, 2, 4 or 8) to give | ||
37 | the readings more range or accuracy. Not all RPM values can accurately be | ||
38 | represented, so some rounding is done. With a divider of 2, the lowest | ||
39 | representable value is around 2600 RPM. | ||
40 | |||
41 | Voltage sensors (also known as IN sensors) report their values in volts. | ||
42 | An alarm is triggered if the voltage has crossed a programmable minimum | ||
43 | or maximum limit. Note that minimum in this case always means 'closest to | ||
44 | zero'; this is important for negative voltage measurements. All voltage | ||
45 | inputs can measure voltages between 0 and 2.55 volts, with a resolution | ||
46 | of 0.01 volt. | ||
47 | |||
48 | If an alarm triggers, it will remain triggered until the hardware register | ||
49 | is read at least once. This means that the cause for the alarm may | ||
50 | already have disappeared! Note that in the current implementation, all | ||
51 | hardware registers are read whenever any data is read (unless it is less | ||
52 | than 2.0 seconds since the last update). This means that you can easily | ||
53 | miss once-only alarms. | ||
54 | |||
55 | The LM80 only updates its values each 1.5 seconds; reading it more often | ||
56 | will do no harm, but will return 'old' values. | ||
diff --git a/Documentation/i2c/chips/lm83 b/Documentation/i2c/chips/lm83 new file mode 100644 index 000000000000..061d9ed8ff43 --- /dev/null +++ b/Documentation/i2c/chips/lm83 | |||
@@ -0,0 +1,76 @@ | |||
1 | Kernel driver lm83 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor LM83 | ||
6 | Prefix: 'lm83' | ||
7 | Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e | ||
8 | Datasheet: Publicly available at the National Semiconductor website | ||
9 | http://www.national.com/pf/LM/LM83.html | ||
10 | |||
11 | |||
12 | Author: Jean Delvare <khali@linux-fr.org> | ||
13 | |||
14 | Description | ||
15 | ----------- | ||
16 | |||
17 | The LM83 is a digital temperature sensor. It senses its own temperature as | ||
18 | well as the temperature of up to three external diodes. It is compatible | ||
19 | with many other devices such as the LM84 and all other ADM1021 clones. | ||
20 | The main difference between the LM83 and the LM84 in that the later can | ||
21 | only sense the temperature of one external diode. | ||
22 | |||
23 | Using the adm1021 driver for a LM83 should work, but only two temperatures | ||
24 | will be reported instead of four. | ||
25 | |||
26 | The LM83 is only found on a handful of motherboards. Both a confirmed | ||
27 | list and an unconfirmed list follow. If you can confirm or infirm the | ||
28 | fact that any of these motherboards do actually have an LM83, please | ||
29 | contact us. Note that the LM90 can easily be misdetected as a LM83. | ||
30 | |||
31 | Confirmed motherboards: | ||
32 | SBS P014 | ||
33 | |||
34 | Unconfirmed motherboards: | ||
35 | Gigabyte GA-8IK1100 | ||
36 | Iwill MPX2 | ||
37 | Soltek SL-75DRV5 | ||
38 | |||
39 | The driver has been successfully tested by Magnus Forsström, who I'd | ||
40 | like to thank here. More testers will be of course welcome. | ||
41 | |||
42 | The fact that the LM83 is only scarcely used can be easily explained. | ||
43 | Most motherboards come with more than just temperature sensors for | ||
44 | health monitoring. They also have voltage and fan rotation speed | ||
45 | sensors. This means that temperature-only chips are usually used as | ||
46 | secondary chips coupled with another chip such as an IT8705F or similar | ||
47 | chip, which provides more features. Since systems usually need three | ||
48 | temperature sensors (motherboard, processor, power supply) and primary | ||
49 | chips provide some temperature sensors, the secondary chip, if needed, | ||
50 | won't have to handle more than two temperatures. Thus, ADM1021 clones | ||
51 | are sufficient, and there is no need for a four temperatures sensor | ||
52 | chip such as the LM83. The only case where using an LM83 would make | ||
53 | sense is on SMP systems, such as the above-mentioned Iwill MPX2, | ||
54 | because you want an additional temperature sensor for each additional | ||
55 | CPU. | ||
56 | |||
57 | On the SBS P014, this is different, since the LM83 is the only hardware | ||
58 | monitoring chipset. One temperature sensor is used for the motherboard | ||
59 | (actually measuring the LM83's own temperature), one is used for the | ||
60 | CPU. The two other sensors must be used to measure the temperature of | ||
61 | two other points of the motherboard. We suspect these points to be the | ||
62 | north and south bridges, but this couldn't be confirmed. | ||
63 | |||
64 | All temperature values are given in degrees Celsius. Local temperature | ||
65 | is given within a range of 0 to +85 degrees. Remote temperatures are | ||
66 | given within a range of 0 to +125 degrees. Resolution is 1.0 degree, | ||
67 | accuracy is guaranteed to 3.0 degrees (see the datasheet for more | ||
68 | details). | ||
69 | |||
70 | Each sensor has its own high limit, but the critical limit is common to | ||
71 | all four sensors. There is no hysteresis mechanism as found on most | ||
72 | recent temperature sensors. | ||
73 | |||
74 | The lm83 driver will not update its values more frequently than every | ||
75 | other second; reading them more often will do no harm, but will return | ||
76 | 'old' values. | ||
diff --git a/Documentation/i2c/chips/lm85 b/Documentation/i2c/chips/lm85 new file mode 100644 index 000000000000..9549237530cf --- /dev/null +++ b/Documentation/i2c/chips/lm85 | |||
@@ -0,0 +1,221 @@ | |||
1 | Kernel driver lm85 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor LM85 (B and C versions) | ||
6 | Prefix: 'lm85' | ||
7 | Addresses scanned: I2C 0x2c, 0x2d, 0x2e | ||
8 | Datasheet: http://www.national.com/pf/LM/LM85.html | ||
9 | * Analog Devices ADM1027 | ||
10 | Prefix: 'adm1027' | ||
11 | Addresses scanned: I2C 0x2c, 0x2d, 0x2e | ||
12 | Datasheet: http://www.analog.com/en/prod/0,,766_825_ADM1027,00.html | ||
13 | * Analog Devices ADT7463 | ||
14 | Prefix: 'adt7463' | ||
15 | Addresses scanned: I2C 0x2c, 0x2d, 0x2e | ||
16 | Datasheet: http://www.analog.com/en/prod/0,,766_825_ADT7463,00.html | ||
17 | * SMSC EMC6D100, SMSC EMC6D101 | ||
18 | Prefix: 'emc6d100' | ||
19 | Addresses scanned: I2C 0x2c, 0x2d, 0x2e | ||
20 | Datasheet: http://www.smsc.com/main/tools/discontinued/6d100.pdf | ||
21 | * SMSC EMC6D102 | ||
22 | Prefix: 'emc6d102' | ||
23 | Addresses scanned: I2C 0x2c, 0x2d, 0x2e | ||
24 | Datasheet: http://www.smsc.com/main/catalog/emc6d102.html | ||
25 | |||
26 | Authors: | ||
27 | Philip Pokorny <ppokorny@penguincomputing.com>, | ||
28 | Frodo Looijaard <frodol@dds.nl>, | ||
29 | Richard Barrington <rich_b_nz@clear.net.nz>, | ||
30 | Margit Schubert-While <margitsw@t-online.de>, | ||
31 | Justin Thiessen <jthiessen@penguincomputing.com> | ||
32 | |||
33 | Description | ||
34 | ----------- | ||
35 | |||
36 | This driver implements support for the National Semiconductor LM85 and | ||
37 | compatible chips including the Analog Devices ADM1027, ADT7463 and | ||
38 | SMSC EMC6D10x chips family. | ||
39 | |||
40 | The LM85 uses the 2-wire interface compatible with the SMBUS 2.0 | ||
41 | specification. Using an analog to digital converter it measures three (3) | ||
42 | temperatures and five (5) voltages. It has four (4) 16-bit counters for | ||
43 | measuring fan speed. Five (5) digital inputs are provided for sampling the | ||
44 | VID signals from the processor to the VRM. Lastly, there are three (3) PWM | ||
45 | outputs that can be used to control fan speed. | ||
46 | |||
47 | The voltage inputs have internal scaling resistors so that the following | ||
48 | voltage can be measured without external resistors: | ||
49 | |||
50 | 2.5V, 3.3V, 5V, 12V, and CPU core voltage (2.25V) | ||
51 | |||
52 | The temperatures measured are one internal diode, and two remote diodes. | ||
53 | Remote 1 is generally the CPU temperature. These inputs are designed to | ||
54 | measure a thermal diode like the one in a Pentium 4 processor in a socket | ||
55 | 423 or socket 478 package. They can also measure temperature using a | ||
56 | transistor like the 2N3904. | ||
57 | |||
58 | A sophisticated control system for the PWM outputs is designed into the | ||
59 | LM85 that allows fan speed to be adjusted automatically based on any of the | ||
60 | three temperature sensors. Each PWM output is individually adjustable and | ||
61 | programmable. Once configured, the LM85 will adjust the PWM outputs in | ||
62 | response to the measured temperatures without further host intervention. | ||
63 | This feature can also be disabled for manual control of the PWM's. | ||
64 | |||
65 | Each of the measured inputs (voltage, temperature, fan speed) has | ||
66 | corresponding high/low limit values. The LM85 will signal an ALARM if any | ||
67 | measured value exceeds either limit. | ||
68 | |||
69 | The LM85 samples all inputs continuously. The lm85 driver will not read | ||
70 | the registers more often than once a second. Further, configuration data is | ||
71 | only read once each 5 minutes. There is twice as much config data as | ||
72 | measurements, so this would seem to be a worthwhile optimization. | ||
73 | |||
74 | Special Features | ||
75 | ---------------- | ||
76 | |||
77 | The LM85 has four fan speed monitoring modes. The ADM1027 has only two. | ||
78 | Both have special circuitry to compensate for PWM interactions with the | ||
79 | TACH signal from the fans. The ADM1027 can be configured to measure the | ||
80 | speed of a two wire fan, but the input conditioning circuitry is different | ||
81 | for 3-wire and 2-wire mode. For this reason, the 2-wire fan modes are not | ||
82 | exposed to user control. The BIOS should initialize them to the correct | ||
83 | mode. If you've designed your own ADM1027, you'll have to modify the | ||
84 | init_client function and add an insmod parameter to set this up. | ||
85 | |||
86 | To smooth the response of fans to changes in temperature, the LM85 has an | ||
87 | optional filter for smoothing temperatures. The ADM1027 has the same | ||
88 | config option but uses it to rate limit the changes to fan speed instead. | ||
89 | |||
90 | The ADM1027 and ADT7463 have a 10-bit ADC and can therefore measure | ||
91 | temperatures with 0.25 degC resolution. They also provide an offset to the | ||
92 | temperature readings that is automatically applied during measurement. | ||
93 | This offset can be used to zero out any errors due to traces and placement. | ||
94 | The documentation says that the offset is in 0.25 degC steps, but in | ||
95 | initial testing of the ADM1027 it was 1.00 degC steps. Analog Devices has | ||
96 | confirmed this "bug". The ADT7463 is reported to work as described in the | ||
97 | documentation. The current lm85 driver does not show the offset register. | ||
98 | |||
99 | The ADT7463 has a THERM asserted counter. This counter has a 22.76ms | ||
100 | resolution and a range of 5.8 seconds. The driver implements a 32-bit | ||
101 | accumulator of the counter value to extend the range to over a year. The | ||
102 | counter will stay at it's max value until read. | ||
103 | |||
104 | See the vendor datasheets for more information. There is application note | ||
105 | from National (AN-1260) with some additional information about the LM85. | ||
106 | The Analog Devices datasheet is very detailed and describes a procedure for | ||
107 | determining an optimal configuration for the automatic PWM control. | ||
108 | |||
109 | The SMSC EMC6D100 & EMC6D101 monitor external voltages, temperatures, and | ||
110 | fan speeds. They use this monitoring capability to alert the system to out | ||
111 | of limit conditions and can automatically control the speeds of multiple | ||
112 | fans in a PC or embedded system. The EMC6D101, available in a 24-pin SSOP | ||
113 | package, and the EMC6D100, available in a 28-pin SSOP package, are designed | ||
114 | to be register compatible. The EMC6D100 offers all the features of the | ||
115 | EMC6D101 plus additional voltage monitoring and system control features. | ||
116 | Unfortunately it is not possible to distinguish between the package | ||
117 | versions on register level so these additional voltage inputs may read | ||
118 | zero. The EMC6D102 features addtional ADC bits thus extending precision | ||
119 | of voltage and temperature channels. | ||
120 | |||
121 | |||
122 | Hardware Configurations | ||
123 | ----------------------- | ||
124 | |||
125 | The LM85 can be jumpered for 3 different SMBus addresses. There are | ||
126 | no other hardware configuration options for the LM85. | ||
127 | |||
128 | The lm85 driver detects both LM85B and LM85C revisions of the chip. See the | ||
129 | datasheet for a complete description of the differences. Other than | ||
130 | identifying the chip, the driver behaves no differently with regard to | ||
131 | these two chips. The LM85B is recommended for new designs. | ||
132 | |||
133 | The ADM1027 and ADT7463 chips have an optional SMBALERT output that can be | ||
134 | used to signal the chipset in case a limit is exceeded or the temperature | ||
135 | sensors fail. Individual sensor interrupts can be masked so they won't | ||
136 | trigger SMBALERT. The SMBALERT output if configured replaces one of the other | ||
137 | functions (PWM2 or IN0). This functionality is not implemented in current | ||
138 | driver. | ||
139 | |||
140 | The ADT7463 also has an optional THERM output/input which can be connected | ||
141 | to the processor PROC_HOT output. If available, the autofan control | ||
142 | dynamic Tmin feature can be enabled to keep the system temperature within | ||
143 | spec (just?!) with the least possible fan noise. | ||
144 | |||
145 | Configuration Notes | ||
146 | ------------------- | ||
147 | |||
148 | Besides standard interfaces driver adds following: | ||
149 | |||
150 | * Temperatures and Zones | ||
151 | |||
152 | Each temperature sensor is associated with a Zone. There are three | ||
153 | sensors and therefore three zones (# 1, 2 and 3). Each zone has the following | ||
154 | temperature configuration points: | ||
155 | |||
156 | * temp#_auto_temp_off - temperature below which fans should be off or spinning very low. | ||
157 | * temp#_auto_temp_min - temperature over which fans start to spin. | ||
158 | * temp#_auto_temp_max - temperature when fans spin at full speed. | ||
159 | * temp#_auto_temp_crit - temperature when all fans will run full speed. | ||
160 | |||
161 | * PWM Control | ||
162 | |||
163 | There are three PWM outputs. The LM85 datasheet suggests that the | ||
164 | pwm3 output control both fan3 and fan4. Each PWM can be individually | ||
165 | configured and assigned to a zone for it's control value. Each PWM can be | ||
166 | configured individually according to the following options. | ||
167 | |||
168 | * pwm#_auto_pwm_min - this specifies the PWM value for temp#_auto_temp_off | ||
169 | temperature. (PWM value from 0 to 255) | ||
170 | |||
171 | * pwm#_auto_pwm_freq - select base frequency of PWM output. You can select | ||
172 | in range of 10.0 to 94.0 Hz in .1 Hz units. | ||
173 | (Values 100 to 940). | ||
174 | |||
175 | The pwm#_auto_pwm_freq can be set to one of the following 8 values. Setting the | ||
176 | frequency to a value not on this list, will result in the next higher frequency | ||
177 | being selected. The actual device frequency may vary slightly from this | ||
178 | specification as designed by the manufacturer. Consult the datasheet for more | ||
179 | details. (PWM Frequency values: 100, 150, 230, 300, 380, 470, 620, 940) | ||
180 | |||
181 | * pwm#_auto_pwm_minctl - this flags selects for temp#_auto_temp_off temperature | ||
182 | the bahaviour of fans. Write 1 to let fans spinning at | ||
183 | pwm#_auto_pwm_min or write 0 to let them off. | ||
184 | |||
185 | NOTE: It has been reported that there is a bug in the LM85 that causes the flag | ||
186 | to be associated with the zones not the PWMs. This contradicts all the | ||
187 | published documentation. Setting pwm#_min_ctl in this case actually affects all | ||
188 | PWMs controlled by zone '#'. | ||
189 | |||
190 | * PWM Controlling Zone selection | ||
191 | |||
192 | * pwm#_auto_channels - controls zone that is associated with PWM | ||
193 | |||
194 | Configuration choices: | ||
195 | |||
196 | Value Meaning | ||
197 | ------ ------------------------------------------------ | ||
198 | 1 Controlled by Zone 1 | ||
199 | 2 Controlled by Zone 2 | ||
200 | 3 Controlled by Zone 3 | ||
201 | 23 Controlled by higher temp of Zone 2 or 3 | ||
202 | 123 Controlled by highest temp of Zone 1, 2 or 3 | ||
203 | 0 PWM always 0% (off) | ||
204 | -1 PWM always 100% (full on) | ||
205 | -2 Manual control (write to 'pwm#' to set) | ||
206 | |||
207 | The National LM85's have two vendor specific configuration | ||
208 | features. Tach. mode and Spinup Control. For more details on these, | ||
209 | see the LM85 datasheet or Application Note AN-1260. | ||
210 | |||
211 | The Analog Devices ADM1027 has several vendor specific enhancements. | ||
212 | The number of pulses-per-rev of the fans can be set, Tach monitoring | ||
213 | can be optimized for PWM operation, and an offset can be applied to | ||
214 | the temperatures to compensate for systemic errors in the | ||
215 | measurements. | ||
216 | |||
217 | In addition to the ADM1027 features, the ADT7463 also has Tmin control | ||
218 | and THERM asserted counts. Automatic Tmin control acts to adjust the | ||
219 | Tmin value to maintain the measured temperature sensor at a specified | ||
220 | temperature. There isn't much documentation on this feature in the | ||
221 | ADT7463 data sheet. This is not supported by current driver. | ||
diff --git a/Documentation/i2c/chips/lm87 b/Documentation/i2c/chips/lm87 new file mode 100644 index 000000000000..c952c57f0e11 --- /dev/null +++ b/Documentation/i2c/chips/lm87 | |||
@@ -0,0 +1,73 @@ | |||
1 | Kernel driver lm87 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor LM87 | ||
6 | Prefix: 'lm87' | ||
7 | Addresses scanned: I2C 0x2c - 0x2f | ||
8 | Datasheet: http://www.national.com/pf/LM/LM87.html | ||
9 | |||
10 | Authors: | ||
11 | Frodo Looijaard <frodol@dds.nl>, | ||
12 | Philip Edelbrock <phil@netroedge.com>, | ||
13 | Mark Studebaker <mdsxyz123@yahoo.com>, | ||
14 | Stephen Rousset <stephen.rousset@rocketlogix.com>, | ||
15 | Dan Eaton <dan.eaton@rocketlogix.com>, | ||
16 | Jean Delvare <khali@linux-fr.org>, | ||
17 | Original 2.6 port Jeff Oliver | ||
18 | |||
19 | Description | ||
20 | ----------- | ||
21 | |||
22 | This driver implements support for the National Semiconductor LM87. | ||
23 | |||
24 | The LM87 implements up to three temperature sensors, up to two fan | ||
25 | rotation speed sensors, up to seven voltage sensors, alarms, and some | ||
26 | miscellaneous stuff. | ||
27 | |||
28 | Temperatures are measured in degrees Celsius. Each input has a high | ||
29 | and low alarm settings. A high limit produces an alarm when the value | ||
30 | goes above it, and an alarm is also produced when the value goes below | ||
31 | the low limit. | ||
32 | |||
33 | Fan rotation speeds are reported in RPM (rotations per minute). An alarm is | ||
34 | triggered if the rotation speed has dropped below a programmable limit. Fan | ||
35 | readings can be divided by a programmable divider (1, 2, 4 or 8) to give | ||
36 | the readings more range or accuracy. Not all RPM values can accurately be | ||
37 | represented, so some rounding is done. With a divider of 2, the lowest | ||
38 | representable value is around 2600 RPM. | ||
39 | |||
40 | Voltage sensors (also known as IN sensors) report their values in | ||
41 | volts. An alarm is triggered if the voltage has crossed a programmable | ||
42 | minimum or maximum limit. Note that minimum in this case always means | ||
43 | 'closest to zero'; this is important for negative voltage measurements. | ||
44 | |||
45 | If an alarm triggers, it will remain triggered until the hardware register | ||
46 | is read at least once. This means that the cause for the alarm may | ||
47 | already have disappeared! Note that in the current implementation, all | ||
48 | hardware registers are read whenever any data is read (unless it is less | ||
49 | than 1.0 seconds since the last update). This means that you can easily | ||
50 | miss once-only alarms. | ||
51 | |||
52 | The lm87 driver only updates its values each 1.0 seconds; reading it more | ||
53 | often will do no harm, but will return 'old' values. | ||
54 | |||
55 | |||
56 | Hardware Configurations | ||
57 | ----------------------- | ||
58 | |||
59 | The LM87 has four pins which can serve one of two possible functions, | ||
60 | depending on the hardware configuration. | ||
61 | |||
62 | Some functions share pins, so not all functions are available at the same | ||
63 | time. Which are depends on the hardware setup. This driver assumes that | ||
64 | the BIOS configured the chip correctly. In that respect, it differs from | ||
65 | the original driver (from lm_sensors for Linux 2.4), which would force the | ||
66 | LM87 to an arbitrary, compile-time chosen mode, regardless of the actual | ||
67 | chipset wiring. | ||
68 | |||
69 | For reference, here is the list of exclusive functions: | ||
70 | - in0+in5 (default) or temp3 | ||
71 | - fan1 (default) or in6 | ||
72 | - fan2 (default) or in7 | ||
73 | - VID lines (default) or IRQ lines (not handled by this driver) | ||
diff --git a/Documentation/i2c/chips/lm90 b/Documentation/i2c/chips/lm90 new file mode 100644 index 000000000000..2c4cf39471f4 --- /dev/null +++ b/Documentation/i2c/chips/lm90 | |||
@@ -0,0 +1,121 @@ | |||
1 | Kernel driver lm90 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor LM90 | ||
6 | Prefix: 'lm90' | ||
7 | Addresses scanned: I2C 0x4c | ||
8 | Datasheet: Publicly available at the National Semiconductor website | ||
9 | http://www.national.com/pf/LM/LM90.html | ||
10 | * National Semiconductor LM89 | ||
11 | Prefix: 'lm99' | ||
12 | Addresses scanned: I2C 0x4c and 0x4d | ||
13 | Datasheet: Publicly available at the National Semiconductor website | ||
14 | http://www.national.com/pf/LM/LM89.html | ||
15 | * National Semiconductor LM99 | ||
16 | Prefix: 'lm99' | ||
17 | Addresses scanned: I2C 0x4c and 0x4d | ||
18 | Datasheet: Publicly available at the National Semiconductor website | ||
19 | http://www.national.com/pf/LM/LM99.html | ||
20 | * National Semiconductor LM86 | ||
21 | Prefix: 'lm86' | ||
22 | Addresses scanned: I2C 0x4c | ||
23 | Datasheet: Publicly available at the National Semiconductor website | ||
24 | http://www.national.com/pf/LM/LM86.html | ||
25 | * Analog Devices ADM1032 | ||
26 | Prefix: 'adm1032' | ||
27 | Addresses scanned: I2C 0x4c | ||
28 | Datasheet: Publicly available at the Analog Devices website | ||
29 | http://products.analog.com/products/info.asp?product=ADM1032 | ||
30 | * Analog Devices ADT7461 | ||
31 | Prefix: 'adt7461' | ||
32 | Addresses scanned: I2C 0x4c | ||
33 | Datasheet: Publicly available at the Analog Devices website | ||
34 | http://products.analog.com/products/info.asp?product=ADT7461 | ||
35 | Note: Only if in ADM1032 compatibility mode | ||
36 | * Maxim MAX6657 | ||
37 | Prefix: 'max6657' | ||
38 | Addresses scanned: I2C 0x4c | ||
39 | Datasheet: Publicly available at the Maxim website | ||
40 | http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 | ||
41 | * Maxim MAX6658 | ||
42 | Prefix: 'max6657' | ||
43 | Addresses scanned: I2C 0x4c | ||
44 | Datasheet: Publicly available at the Maxim website | ||
45 | http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 | ||
46 | * Maxim MAX6659 | ||
47 | Prefix: 'max6657' | ||
48 | Addresses scanned: I2C 0x4c, 0x4d (unsupported 0x4e) | ||
49 | Datasheet: Publicly available at the Maxim website | ||
50 | http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 | ||
51 | |||
52 | |||
53 | Author: Jean Delvare <khali@linux-fr.org> | ||
54 | |||
55 | |||
56 | Description | ||
57 | ----------- | ||
58 | |||
59 | The LM90 is a digital temperature sensor. It senses its own temperature as | ||
60 | well as the temperature of up to one external diode. It is compatible | ||
61 | with many other devices such as the LM86, the LM89, the LM99, the ADM1032, | ||
62 | the MAX6657, MAX6658 and the MAX6659 all of which are supported by this driver. | ||
63 | Note that there is no easy way to differentiate between the last three | ||
64 | variants. The extra address and features of the MAX6659 are not supported by | ||
65 | this driver. Additionally, the ADT7461 is supported if found in ADM1032 | ||
66 | compatibility mode. | ||
67 | |||
68 | The specificity of this family of chipsets over the ADM1021/LM84 | ||
69 | family is that it features critical limits with hysteresis, and an | ||
70 | increased resolution of the remote temperature measurement. | ||
71 | |||
72 | The different chipsets of the family are not strictly identical, although | ||
73 | very similar. This driver doesn't handle any specific feature for now, | ||
74 | but could if there ever was a need for it. For reference, here comes a | ||
75 | non-exhaustive list of specific features: | ||
76 | |||
77 | LM90: | ||
78 | * Filter and alert configuration register at 0xBF. | ||
79 | * ALERT is triggered by temperatures over critical limits. | ||
80 | |||
81 | LM86 and LM89: | ||
82 | * Same as LM90 | ||
83 | * Better external channel accuracy | ||
84 | |||
85 | LM99: | ||
86 | * Same as LM89 | ||
87 | * External temperature shifted by 16 degrees down | ||
88 | |||
89 | ADM1032: | ||
90 | * Consecutive alert register at 0x22. | ||
91 | * Conversion averaging. | ||
92 | * Up to 64 conversions/s. | ||
93 | * ALERT is triggered by open remote sensor. | ||
94 | |||
95 | ADT7461 | ||
96 | * Extended temperature range (breaks compatibility) | ||
97 | * Lower resolution for remote temperature | ||
98 | |||
99 | MAX6657 and MAX6658: | ||
100 | * Remote sensor type selection | ||
101 | |||
102 | MAX6659 | ||
103 | * Selectable address | ||
104 | * Second critical temperature limit | ||
105 | * Remote sensor type selection | ||
106 | |||
107 | All temperature values are given in degrees Celsius. Resolution | ||
108 | is 1.0 degree for the local temperature, 0.125 degree for the remote | ||
109 | temperature. | ||
110 | |||
111 | Each sensor has its own high and low limits, plus a critical limit. | ||
112 | Additionally, there is a relative hysteresis value common to both critical | ||
113 | values. To make life easier to user-space applications, two absolute values | ||
114 | are exported, one for each channel, but these values are of course linked. | ||
115 | Only the local hysteresis can be set from user-space, and the same delta | ||
116 | applies to the remote hysteresis. | ||
117 | |||
118 | The lm90 driver will not update its values more frequently than every | ||
119 | other second; reading them more often will do no harm, but will return | ||
120 | 'old' values. | ||
121 | |||
diff --git a/Documentation/i2c/chips/lm92 b/Documentation/i2c/chips/lm92 new file mode 100644 index 000000000000..7705bfaa0708 --- /dev/null +++ b/Documentation/i2c/chips/lm92 | |||
@@ -0,0 +1,37 @@ | |||
1 | Kernel driver lm92 | ||
2 | ================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor LM92 | ||
6 | Prefix: 'lm92' | ||
7 | Addresses scanned: I2C 0x48 - 0x4b | ||
8 | Datasheet: http://www.national.com/pf/LM/LM92.html | ||
9 | * National Semiconductor LM76 | ||
10 | Prefix: 'lm92' | ||
11 | Addresses scanned: none, force parameter needed | ||
12 | Datasheet: http://www.national.com/pf/LM/LM76.html | ||
13 | * Maxim MAX6633/MAX6634/MAX6635 | ||
14 | Prefix: 'lm92' | ||
15 | Addresses scanned: I2C 0x48 - 0x4b | ||
16 | MAX6633 with address in 0x40 - 0x47, 0x4c - 0x4f needs force parameter | ||
17 | and MAX6634 with address in 0x4c - 0x4f needs force parameter | ||
18 | Datasheet: http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3074 | ||
19 | |||
20 | Authors: | ||
21 | Abraham van der Merwe <abraham@2d3d.co.za> | ||
22 | Jean Delvare <khali@linux-fr.org> | ||
23 | |||
24 | |||
25 | Description | ||
26 | ----------- | ||
27 | |||
28 | This driver implements support for the National Semiconductor LM92 | ||
29 | temperature sensor. | ||
30 | |||
31 | Each LM92 temperature sensor supports a single temperature sensor. There are | ||
32 | alarms for high, low, and critical thresholds. There's also an hysteresis to | ||
33 | control the thresholds for resetting alarms. | ||
34 | |||
35 | Support was added later for the LM76 and Maxim MAX6633/MAX6634/MAX6635, | ||
36 | which are mostly compatible. They have not all been tested, so you | ||
37 | may need to use the force parameter. | ||
diff --git a/Documentation/i2c/chips/max1619 b/Documentation/i2c/chips/max1619 new file mode 100644 index 000000000000..d6f8d9cd7d7f --- /dev/null +++ b/Documentation/i2c/chips/max1619 | |||
@@ -0,0 +1,29 @@ | |||
1 | Kernel driver max1619 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Maxim MAX1619 | ||
6 | Prefix: 'max1619' | ||
7 | Addresses scanned: I2C 0x18-0x1a, 0x29-0x2b, 0x4c-0x4e | ||
8 | Datasheet: Publicly available at the Maxim website | ||
9 | http://pdfserv.maxim-ic.com/en/ds/MAX1619.pdf | ||
10 | |||
11 | Authors: | ||
12 | Alexey Fisher <fishor@mail.ru>, | ||
13 | Jean Delvare <khali@linux-fr.org> | ||
14 | |||
15 | Description | ||
16 | ----------- | ||
17 | |||
18 | The MAX1619 is a digital temperature sensor. It senses its own temperature as | ||
19 | well as the temperature of up to one external diode. | ||
20 | |||
21 | All temperature values are given in degrees Celsius. Resolution | ||
22 | is 1.0 degree for the local temperature and for the remote temperature. | ||
23 | |||
24 | Only the external sensor has high and low limits. | ||
25 | |||
26 | The max1619 driver will not update its values more frequently than every | ||
27 | other second; reading them more often will do no harm, but will return | ||
28 | 'old' values. | ||
29 | |||
diff --git a/Documentation/i2c/chips/max6875 b/Documentation/i2c/chips/max6875 new file mode 100644 index 000000000000..b4fb49b41813 --- /dev/null +++ b/Documentation/i2c/chips/max6875 | |||
@@ -0,0 +1,54 @@ | |||
1 | Kernel driver max6875 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Maxim max6874, max6875 | ||
6 | Prefixes: 'max6875' | ||
7 | Addresses scanned: 0x50, 0x52 | ||
8 | Datasheets: | ||
9 | http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf | ||
10 | |||
11 | Author: Ben Gardner <bgardner@wabtec.com> | ||
12 | |||
13 | |||
14 | Module Parameters | ||
15 | ----------------- | ||
16 | |||
17 | * allow_write int | ||
18 | Set to non-zero to enable write permission: | ||
19 | *0: Read only | ||
20 | 1: Read and write | ||
21 | |||
22 | |||
23 | Description | ||
24 | ----------- | ||
25 | |||
26 | The MAXIM max6875 is a EEPROM-programmable power-supply sequencer/supervisor. | ||
27 | It provides timed outputs that can be used as a watchdog, if properly wired. | ||
28 | It also provides 512 bytes of user EEPROM. | ||
29 | |||
30 | At reset, the max6875 reads the configuration eeprom into its configuration | ||
31 | registers. The chip then begins to operate according to the values in the | ||
32 | registers. | ||
33 | |||
34 | See the datasheet for details on how to program the EEPROM. | ||
35 | |||
36 | |||
37 | Sysfs entries | ||
38 | ------------- | ||
39 | |||
40 | eeprom_user - 512 bytes of user-defined EEPROM space. Only writable if | ||
41 | allow_write was set and register 0x43 is 0. | ||
42 | |||
43 | eeprom_config - 70 bytes of config EEPROM. Note that changes will not get | ||
44 | loaded into register space until a power cycle or device reset. | ||
45 | |||
46 | reg_config - 70 bytes of register space. Any changes take affect immediately. | ||
47 | |||
48 | |||
49 | General Remarks | ||
50 | --------------- | ||
51 | |||
52 | A typical application will require that the EEPROMs be programmed once and | ||
53 | never altered afterwards. | ||
54 | |||
diff --git a/Documentation/i2c/chips/pc87360 b/Documentation/i2c/chips/pc87360 new file mode 100644 index 000000000000..89a8fcfa78df --- /dev/null +++ b/Documentation/i2c/chips/pc87360 | |||
@@ -0,0 +1,189 @@ | |||
1 | Kernel driver pc87360 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * National Semiconductor PC87360, PC87363, PC87364, PC87365 and PC87366 | ||
6 | Prefixes: 'pc87360', 'pc87363', 'pc87364', 'pc87365', 'pc87366' | ||
7 | Addresses scanned: none, address read from Super I/O config space | ||
8 | Datasheets: | ||
9 | http://www.national.com/pf/PC/PC87360.html | ||
10 | http://www.national.com/pf/PC/PC87363.html | ||
11 | http://www.national.com/pf/PC/PC87364.html | ||
12 | http://www.national.com/pf/PC/PC87365.html | ||
13 | http://www.national.com/pf/PC/PC87366.html | ||
14 | |||
15 | Authors: Jean Delvare <khali@linux-fr.org> | ||
16 | |||
17 | Thanks to Sandeep Mehta, Tonko de Rooy and Daniel Ceregatti for testing. | ||
18 | Thanks to Rudolf Marek for helping me investigate conversion issues. | ||
19 | |||
20 | |||
21 | Module Parameters | ||
22 | ----------------- | ||
23 | |||
24 | * init int | ||
25 | Chip initialization level: | ||
26 | 0: None | ||
27 | *1: Forcibly enable internal voltage and temperature channels, except in9 | ||
28 | 2: Forcibly enable all voltage and temperature channels, except in9 | ||
29 | 3: Forcibly enable all voltage and temperature channels, including in9 | ||
30 | |||
31 | Note that this parameter has no effect for the PC87360, PC87363 and PC87364 | ||
32 | chips. | ||
33 | |||
34 | Also note that for the PC87366, initialization levels 2 and 3 don't enable | ||
35 | all temperature channels, because some of them share pins with each other, | ||
36 | so they can't be used at the same time. | ||
37 | |||
38 | |||
39 | Description | ||
40 | ----------- | ||
41 | |||
42 | The National Semiconductor PC87360 Super I/O chip contains monitoring and | ||
43 | PWM control circuitry for two fans. The PC87363 chip is similar, and the | ||
44 | PC87364 chip has monitoring and PWM control for a third fan. | ||
45 | |||
46 | The National Semiconductor PC87365 and PC87366 Super I/O chips are complete | ||
47 | hardware monitoring chipsets, not only controlling and monitoring three fans, | ||
48 | but also monitoring eleven voltage inputs and two (PC87365) or up to four | ||
49 | (PC87366) temperatures. | ||
50 | |||
51 | Chip #vin #fan #pwm #temp devid | ||
52 | |||
53 | PC87360 - 2 2 - 0xE1 | ||
54 | PC87363 - 2 2 - 0xE8 | ||
55 | PC87364 - 3 3 - 0xE4 | ||
56 | PC87365 11 3 3 2 0xE5 | ||
57 | PC87366 11 3 3 3-4 0xE9 | ||
58 | |||
59 | The driver assumes that no more than one chip is present, and one of the | ||
60 | standard Super I/O addresses is used (0x2E/0x2F or 0x4E/0x4F) | ||
61 | |||
62 | Fan Monitoring | ||
63 | -------------- | ||
64 | |||
65 | Fan rotation speeds are reported in RPM (revolutions per minute). An alarm | ||
66 | is triggered if the rotation speed has dropped below a programmable limit. | ||
67 | A different alarm is triggered if the fan speed is too low to be measured. | ||
68 | |||
69 | Fan readings are affected by a programmable clock divider, giving the | ||
70 | readings more range or accuracy. Usually, users have to learn how it works, | ||
71 | but this driver implements dynamic clock divider selection, so you don't | ||
72 | have to care no more. | ||
73 | |||
74 | For reference, here are a few values about clock dividers: | ||
75 | |||
76 | slowest accuracy highest | ||
77 | measurable around 3000 accurate | ||
78 | divider speed (RPM) RPM (RPM) speed (RPM) | ||
79 | 1 1882 18 6928 | ||
80 | 2 941 37 4898 | ||
81 | 4 470 74 3464 | ||
82 | 8 235 150 2449 | ||
83 | |||
84 | For the curious, here is how the values above were computed: | ||
85 | * slowest measurable speed: clock/(255*divider) | ||
86 | * accuracy around 3000 RPM: 3000^2/clock | ||
87 | * highest accurate speed: sqrt(clock*100) | ||
88 | The clock speed for the PC87360 family is 480 kHz. I arbitrarily chose 100 | ||
89 | RPM as the lowest acceptable accuracy. | ||
90 | |||
91 | As mentioned above, you don't have to care about this no more. | ||
92 | |||
93 | Note that not all RPM values can be represented, even when the best clock | ||
94 | divider is selected. This is not only true for the measured speeds, but | ||
95 | also for the programmable low limits, so don't be surprised if you try to | ||
96 | set, say, fan1_min to 2900 and it finally reads 2909. | ||
97 | |||
98 | |||
99 | Fan Control | ||
100 | ----------- | ||
101 | |||
102 | PWM (pulse width modulation) values range from 0 to 255, with 0 meaning | ||
103 | that the fan is stopped, and 255 meaning that the fan goes at full speed. | ||
104 | |||
105 | Be extremely careful when changing PWM values. Low PWM values, even | ||
106 | non-zero, can stop the fan, which may cause irreversible damage to your | ||
107 | hardware if temperature increases too much. When changing PWM values, go | ||
108 | step by step and keep an eye on temperatures. | ||
109 | |||
110 | One user reported problems with PWM. Changing PWM values would break fan | ||
111 | speed readings. No explanation nor fix could be found. | ||
112 | |||
113 | |||
114 | Temperature Monitoring | ||
115 | ---------------------- | ||
116 | |||
117 | Temperatures are reported in degrees Celsius. Each temperature measured has | ||
118 | associated low, high and overtemperature limits, each of which triggers an | ||
119 | alarm when crossed. | ||
120 | |||
121 | The first two temperature channels are external. The third one (PC87366 | ||
122 | only) is internal. | ||
123 | |||
124 | The PC87366 has three additional temperature channels, based on | ||
125 | thermistors (as opposed to thermal diodes for the first three temperature | ||
126 | channels). For technical reasons, these channels are held by the VLM | ||
127 | (voltage level monitor) logical device, not the TMS (temperature | ||
128 | measurement) one. As a consequence, these temperatures are exported as | ||
129 | voltages, and converted into temperatures in user-space. | ||
130 | |||
131 | Note that these three additional channels share their pins with the | ||
132 | external thermal diode channels, so you (physically) can't use them all at | ||
133 | the same time. Although it should be possible to mix the two sensor types, | ||
134 | the documents from National Semiconductor suggest that motherboard | ||
135 | manufacturers should choose one type and stick to it. So you will more | ||
136 | likely have either channels 1 to 3 (thermal diodes) or 3 to 6 (internal | ||
137 | thermal diode, and thermistors). | ||
138 | |||
139 | |||
140 | Voltage Monitoring | ||
141 | ------------------ | ||
142 | |||
143 | Voltages are reported relatively to a reference voltage, either internal or | ||
144 | external. Some of them (in7:Vsb, in8:Vdd and in10:AVdd) are divided by two | ||
145 | internally, you will have to compensate in sensors.conf. Others (in0 to in6) | ||
146 | are likely to be divided externally. The meaning of each of these inputs as | ||
147 | well as the values of the resistors used for division is left to the | ||
148 | motherboard manufacturers, so you will have to document yourself and edit | ||
149 | sensors.conf accordingly. National Semiconductor has a document with | ||
150 | recommended resistor values for some voltages, but this still leaves much | ||
151 | room for per motherboard specificities, unfortunately. Even worse, | ||
152 | motherboard manufacturers don't seem to care about National Semiconductor's | ||
153 | recommendations. | ||
154 | |||
155 | Each voltage measured has associated low and high limits, each of which | ||
156 | triggers an alarm when crossed. | ||
157 | |||
158 | When available, VID inputs are used to provide the nominal CPU Core voltage. | ||
159 | The driver will default to VRM 9.0, but this can be changed from user-space. | ||
160 | The chipsets can handle two sets of VID inputs (on dual-CPU systems), but | ||
161 | the driver will only export one for now. This may change later if there is | ||
162 | a need. | ||
163 | |||
164 | |||
165 | General Remarks | ||
166 | --------------- | ||
167 | |||
168 | If an alarm triggers, it will remain triggered until the hardware register | ||
169 | is read at least once. This means that the cause for the alarm may already | ||
170 | have disappeared! Note that all hardware registers are read whenever any | ||
171 | data is read (unless it is less than 2 seconds since the last update, in | ||
172 | which case cached values are returned instead). As a consequence, when | ||
173 | a once-only alarm triggers, it may take 2 seconds for it to show, and 2 | ||
174 | more seconds for it to disappear. | ||
175 | |||
176 | Monitoring of in9 isn't enabled at lower init levels (<3) because that | ||
177 | channel measures the battery voltage (Vbat). It is a known fact that | ||
178 | repeatedly sampling the battery voltage reduces its lifetime. National | ||
179 | Semiconductor smartly designed their chipset so that in9 is sampled only | ||
180 | once every 1024 sampling cycles (that is every 34 minutes at the default | ||
181 | sampling rate), so the effect is attenuated, but still present. | ||
182 | |||
183 | |||
184 | Limitations | ||
185 | ----------- | ||
186 | |||
187 | The datasheets suggests that some values (fan mins, fan dividers) | ||
188 | shouldn't be changed once the monitoring has started, but we ignore that | ||
189 | recommendation. We'll reconsider if it actually causes trouble. | ||
diff --git a/Documentation/i2c/chips/pca9539 b/Documentation/i2c/chips/pca9539 new file mode 100644 index 000000000000..c4fce6a13537 --- /dev/null +++ b/Documentation/i2c/chips/pca9539 | |||
@@ -0,0 +1,47 @@ | |||
1 | Kernel driver pca9539 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Philips PCA9539 | ||
6 | Prefix: 'pca9539' | ||
7 | Addresses scanned: 0x74 - 0x77 | ||
8 | Datasheet: | ||
9 | http://www.semiconductors.philips.com/acrobat/datasheets/PCA9539_2.pdf | ||
10 | |||
11 | Author: Ben Gardner <bgardner@wabtec.com> | ||
12 | |||
13 | |||
14 | Description | ||
15 | ----------- | ||
16 | |||
17 | The Philips PCA9539 is a 16 bit low power I/O device. | ||
18 | All 16 lines can be individually configured as an input or output. | ||
19 | The input sense can also be inverted. | ||
20 | The 16 lines are split between two bytes. | ||
21 | |||
22 | |||
23 | Sysfs entries | ||
24 | ------------- | ||
25 | |||
26 | Each is a byte that maps to the 8 I/O bits. | ||
27 | A '0' suffix is for bits 0-7, while '1' is for bits 8-15. | ||
28 | |||
29 | input[01] - read the current value | ||
30 | output[01] - sets the output value | ||
31 | direction[01] - direction of each bit: 1=input, 0=output | ||
32 | invert[01] - toggle the input bit sense | ||
33 | |||
34 | input reads the actual state of the line and is always available. | ||
35 | The direction defaults to input for all channels. | ||
36 | |||
37 | |||
38 | General Remarks | ||
39 | --------------- | ||
40 | |||
41 | Note that each output, direction, and invert entry controls 8 lines. | ||
42 | You should use the read, modify, write sequence. | ||
43 | For example. to set output bit 0 of 1. | ||
44 | val=$(cat output0) | ||
45 | val=$(( $val | 1 )) | ||
46 | echo $val > output0 | ||
47 | |||
diff --git a/Documentation/i2c/chips/pcf8574 b/Documentation/i2c/chips/pcf8574 new file mode 100644 index 000000000000..2752c8ce3167 --- /dev/null +++ b/Documentation/i2c/chips/pcf8574 | |||
@@ -0,0 +1,69 @@ | |||
1 | Kernel driver pcf8574 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Philips PCF8574 | ||
6 | Prefix: 'pcf8574' | ||
7 | Addresses scanned: I2C 0x20 - 0x27 | ||
8 | Datasheet: Publicly available at the Philips Semiconductors website | ||
9 | http://www.semiconductors.philips.com/pip/PCF8574P.html | ||
10 | |||
11 | * Philips PCF8574A | ||
12 | Prefix: 'pcf8574a' | ||
13 | Addresses scanned: I2C 0x38 - 0x3f | ||
14 | Datasheet: Publicly available at the Philips Semiconductors website | ||
15 | http://www.semiconductors.philips.com/pip/PCF8574P.html | ||
16 | |||
17 | Authors: | ||
18 | Frodo Looijaard <frodol@dds.nl>, | ||
19 | Philip Edelbrock <phil@netroedge.com>, | ||
20 | Dan Eaton <dan.eaton@rocketlogix.com>, | ||
21 | Aurelien Jarno <aurelien@aurel32.net>, | ||
22 | Jean Delvare <khali@linux-fr.org>, | ||
23 | |||
24 | |||
25 | Description | ||
26 | ----------- | ||
27 | The PCF8574(A) is an 8-bit I/O expander for the I2C bus produced by Philips | ||
28 | Semiconductors. It is designed to provide a byte I2C interface to up to 16 | ||
29 | separate devices (8 x PCF8574 and 8 x PCF8574A). | ||
30 | |||
31 | This device consists of a quasi-bidirectional port. Each of the eight I/Os | ||
32 | can be independently used as an input or output. To setup an I/O as an | ||
33 | input, you have to write a 1 to the corresponding output. | ||
34 | |||
35 | For more informations see the datasheet. | ||
36 | |||
37 | |||
38 | Accessing PCF8574(A) via /sys interface | ||
39 | ------------------------------------- | ||
40 | |||
41 | ! Be careful ! | ||
42 | The PCF8574(A) is plainly impossible to detect ! Stupid chip. | ||
43 | So every chip with address in the interval [20..27] and [38..3f] are | ||
44 | detected as PCF8574(A). If you have other chips in this address | ||
45 | range, the workaround is to load this module after the one | ||
46 | for your others chips. | ||
47 | |||
48 | On detection (i.e. insmod, modprobe et al.), directories are being | ||
49 | created for each detected PCF8574(A): | ||
50 | |||
51 | /sys/bus/i2c/devices/<0>-<1>/ | ||
52 | where <0> is the bus the chip was detected on (e. g. i2c-0) | ||
53 | and <1> the chip address ([20..27] or [38..3f]): | ||
54 | |||
55 | (example: /sys/bus/i2c/devices/1-0020/) | ||
56 | |||
57 | Inside these directories, there are two files each: | ||
58 | read and write (and one file with chip name). | ||
59 | |||
60 | The read file is read-only. Reading gives you the current I/O input | ||
61 | if the corresponding output is set as 1, otherwise the current output | ||
62 | value, that is to say 0. | ||
63 | |||
64 | The write file is read/write. Writing a value outputs it on the I/O | ||
65 | port. Reading returns the last written value. | ||
66 | |||
67 | On module initialization the chip is configured as eight inputs (all | ||
68 | outputs to 1), so you can connect any circuit to the PCF8574(A) without | ||
69 | being afraid of short-circuit. | ||
diff --git a/Documentation/i2c/chips/pcf8591 b/Documentation/i2c/chips/pcf8591 new file mode 100644 index 000000000000..5628fcf4207f --- /dev/null +++ b/Documentation/i2c/chips/pcf8591 | |||
@@ -0,0 +1,90 @@ | |||
1 | Kernel driver pcf8591 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Philips PCF8591 | ||
6 | Prefix: 'pcf8591' | ||
7 | Addresses scanned: I2C 0x48 - 0x4f | ||
8 | Datasheet: Publicly available at the Philips Semiconductor website | ||
9 | http://www.semiconductors.philips.com/pip/PCF8591P.html | ||
10 | |||
11 | Authors: | ||
12 | Aurelien Jarno <aurelien@aurel32.net> | ||
13 | valuable contributions by Jan M. Sendler <sendler@sendler.de>, | ||
14 | Jean Delvare <khali@linux-fr.org> | ||
15 | |||
16 | |||
17 | Description | ||
18 | ----------- | ||
19 | The PCF8591 is an 8-bit A/D and D/A converter (4 analog inputs and one | ||
20 | analog output) for the I2C bus produced by Philips Semiconductors. It | ||
21 | is designed to provide a byte I2C interface to up to 4 separate devices. | ||
22 | |||
23 | The PCF8591 has 4 analog inputs programmable as single-ended or | ||
24 | differential inputs : | ||
25 | - mode 0 : four single ended inputs | ||
26 | Pins AIN0 to AIN3 are single ended inputs for channels 0 to 3 | ||
27 | |||
28 | - mode 1 : three differential inputs | ||
29 | Pins AIN3 is the common negative differential input | ||
30 | Pins AIN0 to AIN2 are positive differential inputs for channels 0 to 2 | ||
31 | |||
32 | - mode 2 : single ended and differential mixed | ||
33 | Pins AIN0 and AIN1 are single ended inputs for channels 0 and 1 | ||
34 | Pins AIN2 is the positive differential input for channel 3 | ||
35 | Pins AIN3 is the negative differential input for channel 3 | ||
36 | |||
37 | - mode 3 : two differential inputs | ||
38 | Pins AIN0 is the positive differential input for channel 0 | ||
39 | Pins AIN1 is the negative differential input for channel 0 | ||
40 | Pins AIN2 is the positive differential input for channel 1 | ||
41 | Pins AIN3 is the negative differential input for channel 1 | ||
42 | |||
43 | See the datasheet for details. | ||
44 | |||
45 | Module parameters | ||
46 | ----------------- | ||
47 | |||
48 | * input_mode int | ||
49 | |||
50 | Analog input mode: | ||
51 | 0 = four single ended inputs | ||
52 | 1 = three differential inputs | ||
53 | 2 = single ended and differential mixed | ||
54 | 3 = two differential inputs | ||
55 | |||
56 | |||
57 | Accessing PCF8591 via /sys interface | ||
58 | ------------------------------------- | ||
59 | |||
60 | ! Be careful ! | ||
61 | The PCF8591 is plainly impossible to detect ! Stupid chip. | ||
62 | So every chip with address in the interval [48..4f] is | ||
63 | detected as PCF8591. If you have other chips in this address | ||
64 | range, the workaround is to load this module after the one | ||
65 | for your others chips. | ||
66 | |||
67 | On detection (i.e. insmod, modprobe et al.), directories are being | ||
68 | created for each detected PCF8591: | ||
69 | |||
70 | /sys/bus/devices/<0>-<1>/ | ||
71 | where <0> is the bus the chip was detected on (e. g. i2c-0) | ||
72 | and <1> the chip address ([48..4f]) | ||
73 | |||
74 | Inside these directories, there are such files: | ||
75 | in0, in1, in2, in3, out0_enable, out0_output, name | ||
76 | |||
77 | Name contains chip name. | ||
78 | |||
79 | The in0, in1, in2 and in3 files are RO. Reading gives the value of the | ||
80 | corresponding channel. Depending on the current analog inputs configuration, | ||
81 | files in2 and/or in3 do not exist. Values range are from 0 to 255 for single | ||
82 | ended inputs and -128 to +127 for differential inputs (8-bit ADC). | ||
83 | |||
84 | The out0_enable file is RW. Reading gives "1" for analog output enabled and | ||
85 | "0" for analog output disabled. Writing accepts "0" and "1" accordingly. | ||
86 | |||
87 | The out0_output file is RW. Writing a number between 0 and 255 (8-bit DAC), send | ||
88 | the value to the digital-to-analog converter. Note that a voltage will | ||
89 | only appears on AOUT pin if aout0_enable equals 1. Reading returns the last | ||
90 | value written. | ||
diff --git a/Documentation/i2c/chips/sis5595 b/Documentation/i2c/chips/sis5595 new file mode 100644 index 000000000000..b7ae36b8cdf5 --- /dev/null +++ b/Documentation/i2c/chips/sis5595 | |||
@@ -0,0 +1,106 @@ | |||
1 | Kernel driver sis5595 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Silicon Integrated Systems Corp. SiS5595 Southbridge Hardware Monitor | ||
6 | Prefix: 'sis5595' | ||
7 | Addresses scanned: ISA in PCI-space encoded address | ||
8 | Datasheet: Publicly available at the Silicon Integrated Systems Corp. site. | ||
9 | |||
10 | Authors: | ||
11 | Kyösti Mälkki <kmalkki@cc.hut.fi>, | ||
12 | Mark D. Studebaker <mdsxyz123@yahoo.com>, | ||
13 | Aurelien Jarno <aurelien@aurel32.net> 2.6 port | ||
14 | |||
15 | SiS southbridge has a LM78-like chip integrated on the same IC. | ||
16 | This driver is a customized copy of lm78.c | ||
17 | |||
18 | Supports following revisions: | ||
19 | Version PCI ID PCI Revision | ||
20 | 1 1039/0008 AF or less | ||
21 | 2 1039/0008 B0 or greater | ||
22 | |||
23 | Note: these chips contain a 0008 device which is incompatible with the | ||
24 | 5595. We recognize these by the presence of the listed | ||
25 | "blacklist" PCI ID and refuse to load. | ||
26 | |||
27 | NOT SUPPORTED PCI ID BLACKLIST PCI ID | ||
28 | 540 0008 0540 | ||
29 | 550 0008 0550 | ||
30 | 5513 0008 5511 | ||
31 | 5581 0008 5597 | ||
32 | 5582 0008 5597 | ||
33 | 5597 0008 5597 | ||
34 | 630 0008 0630 | ||
35 | 645 0008 0645 | ||
36 | 730 0008 0730 | ||
37 | 735 0008 0735 | ||
38 | |||
39 | |||
40 | Module Parameters | ||
41 | ----------------- | ||
42 | force_addr=0xaddr Set the I/O base address. Useful for boards | ||
43 | that don't set the address in the BIOS. Does not do a | ||
44 | PCI force; the device must still be present in lspci. | ||
45 | Don't use this unless the driver complains that the | ||
46 | base address is not set. | ||
47 | Example: 'modprobe sis5595 force_addr=0x290' | ||
48 | |||
49 | |||
50 | Description | ||
51 | ----------- | ||
52 | |||
53 | The SiS5595 southbridge has integrated hardware monitor functions. It also | ||
54 | has an I2C bus, but this driver only supports the hardware monitor. For the | ||
55 | I2C bus driver see i2c-sis5595. | ||
56 | |||
57 | The SiS5595 implements zero or one temperature sensor, two fan speed | ||
58 | sensors, four or five voltage sensors, and alarms. | ||
59 | |||
60 | On the first version of the chip, there are four voltage sensors and one | ||
61 | temperature sensor. | ||
62 | |||
63 | On the second version of the chip, the temperature sensor (temp) and the | ||
64 | fifth voltage sensor (in4) share a pin which is configurable, but not | ||
65 | through the driver. Sorry. The driver senses the configuration of the pin, | ||
66 | which was hopefully set by the BIOS. | ||
67 | |||
68 | Temperatures are measured in degrees Celsius. An alarm is triggered once | ||
69 | when the max is crossed; it is also triggered when it drops below the min | ||
70 | value. Measurements are guaranteed between -55 and +125 degrees, with a | ||
71 | resolution of 1 degree. | ||
72 | |||
73 | Fan rotation speeds are reported in RPM (rotations per minute). An alarm is | ||
74 | triggered if the rotation speed has dropped below a programmable limit. Fan | ||
75 | readings can be divided by a programmable divider (1, 2, 4 or 8) to give | ||
76 | the readings more range or accuracy. Not all RPM values can accurately be | ||
77 | represented, so some rounding is done. With a divider of 2, the lowest | ||
78 | representable value is around 2600 RPM. | ||
79 | |||
80 | Voltage sensors (also known as IN sensors) report their values in volts. An | ||
81 | alarm is triggered if the voltage has crossed a programmable minimum or | ||
82 | maximum limit. Note that minimum in this case always means 'closest to | ||
83 | zero'; this is important for negative voltage measurements. All voltage | ||
84 | inputs can measure voltages between 0 and 4.08 volts, with a resolution of | ||
85 | 0.016 volt. | ||
86 | |||
87 | In addition to the alarms described above, there is a BTI alarm, which gets | ||
88 | triggered when an external chip has crossed its limits. Usually, this is | ||
89 | connected to some LM75-like chip; if at least one crosses its limits, this | ||
90 | bit gets set. | ||
91 | |||
92 | If an alarm triggers, it will remain triggered until the hardware register | ||
93 | is read at least once. This means that the cause for the alarm may already | ||
94 | have disappeared! Note that in the current implementation, all hardware | ||
95 | registers are read whenever any data is read (unless it is less than 1.5 | ||
96 | seconds since the last update). This means that you can easily miss | ||
97 | once-only alarms. | ||
98 | |||
99 | The SiS5595 only updates its values each 1.5 seconds; reading it more often | ||
100 | will do no harm, but will return 'old' values. | ||
101 | |||
102 | Problems | ||
103 | -------- | ||
104 | Some chips refuse to be enabled. We don't know why. | ||
105 | The driver will recognize this and print a message in dmesg. | ||
106 | |||
diff --git a/Documentation/i2c/chips/smsc47b397.txt b/Documentation/i2c/chips/smsc47b397 index 389edae7f8df..da9d80c96432 100644 --- a/Documentation/i2c/chips/smsc47b397.txt +++ b/Documentation/i2c/chips/smsc47b397 | |||
@@ -1,7 +1,19 @@ | |||
1 | Kernel driver smsc47b397 | ||
2 | ======================== | ||
3 | |||
4 | Supported chips: | ||
5 | * SMSC LPC47B397-NC | ||
6 | Prefix: 'smsc47b397' | ||
7 | Addresses scanned: none, address read from Super I/O config space | ||
8 | Datasheet: In this file | ||
9 | |||
10 | Authors: Mark M. Hoffman <mhoffman@lightlink.com> | ||
11 | Utilitek Systems, Inc. | ||
12 | |||
1 | November 23, 2004 | 13 | November 23, 2004 |
2 | 14 | ||
3 | The following specification describes the SMSC LPC47B397-NC sensor chip | 15 | The following specification describes the SMSC LPC47B397-NC sensor chip |
4 | (for which there is no public datasheet available). This document was | 16 | (for which there is no public datasheet available). This document was |
5 | provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected | 17 | provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected |
6 | by Mark M. Hoffman <mhoffman@lightlink.com>. | 18 | by Mark M. Hoffman <mhoffman@lightlink.com>. |
7 | 19 | ||
@@ -10,10 +22,10 @@ by Mark M. Hoffman <mhoffman@lightlink.com>. | |||
10 | Methods for detecting the HP SIO and reading the thermal data on a dc7100. | 22 | Methods for detecting the HP SIO and reading the thermal data on a dc7100. |
11 | 23 | ||
12 | The thermal information on the dc7100 is contained in the SIO Hardware Monitor | 24 | The thermal information on the dc7100 is contained in the SIO Hardware Monitor |
13 | (HWM). The information is accessed through an index/data pair. The index/data | 25 | (HWM). The information is accessed through an index/data pair. The index/data |
14 | pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The | 26 | pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The |
15 | HWM Base address can be obtained from Logical Device 8, registers 0x60 (MSB) | 27 | HWM Base address can be obtained from Logical Device 8, registers 0x60 (MSB) |
16 | and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and | 28 | and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and |
17 | 0x480 and 0x481 for the index/data pair. | 29 | 0x480 and 0x481 for the index/data pair. |
18 | 30 | ||
19 | Reading temperature information. | 31 | Reading temperature information. |
@@ -50,7 +62,7 @@ Reading the tach LSB locks the tach MSB. | |||
50 | The LSB Must be read first. | 62 | The LSB Must be read first. |
51 | 63 | ||
52 | How to convert the tach reading to RPM. | 64 | How to convert the tach reading to RPM. |
53 | The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB) | 65 | The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB) |
54 | The SIO counts the number of 90kHz (11.111us) pulses per revolution. | 66 | The SIO counts the number of 90kHz (11.111us) pulses per revolution. |
55 | RPM = 60/(TCount * 11.111us) | 67 | RPM = 60/(TCount * 11.111us) |
56 | 68 | ||
@@ -72,20 +84,20 @@ To program the configuration registers, the following sequence must be followed: | |||
72 | 84 | ||
73 | Enter Configuration Mode | 85 | Enter Configuration Mode |
74 | To place the chip into the Configuration State The config key (0x55) is written | 86 | To place the chip into the Configuration State The config key (0x55) is written |
75 | to the CONFIG PORT (0x2E). | 87 | to the CONFIG PORT (0x2E). |
76 | 88 | ||
77 | Configuration Mode | 89 | Configuration Mode |
78 | In configuration mode, the INDEX PORT is located at the CONFIG PORT address and | 90 | In configuration mode, the INDEX PORT is located at the CONFIG PORT address and |
79 | the DATA PORT is at INDEX PORT address + 1. | 91 | the DATA PORT is at INDEX PORT address + 1. |
80 | 92 | ||
81 | The desired configuration registers are accessed in two steps: | 93 | The desired configuration registers are accessed in two steps: |
82 | a. Write the index of the Logical Device Number Configuration Register | 94 | a. Write the index of the Logical Device Number Configuration Register |
83 | (i.e., 0x07) to the INDEX PORT and then write the number of the | 95 | (i.e., 0x07) to the INDEX PORT and then write the number of the |
84 | desired logical device to the DATA PORT. | 96 | desired logical device to the DATA PORT. |
85 | 97 | ||
86 | b. Write the address of the desired configuration register within the | 98 | b. Write the address of the desired configuration register within the |
87 | logical device to the INDEX PORT and then write or read the config- | 99 | logical device to the INDEX PORT and then write or read the config- |
88 | uration register through the DATA PORT. | 100 | uration register through the DATA PORT. |
89 | 101 | ||
90 | Note: If accessing the Global Configuration Registers, step (a) is not required. | 102 | Note: If accessing the Global Configuration Registers, step (a) is not required. |
91 | 103 | ||
@@ -96,18 +108,18 @@ The chip returns to the RUN State. (This is important). | |||
96 | Programming Example | 108 | Programming Example |
97 | The following is an example of how to read the SIO Device ID located at 0x20 | 109 | The following is an example of how to read the SIO Device ID located at 0x20 |
98 | 110 | ||
99 | ; ENTER CONFIGURATION MODE | 111 | ; ENTER CONFIGURATION MODE |
100 | MOV DX,02EH | 112 | MOV DX,02EH |
101 | MOV AX,055H | 113 | MOV AX,055H |
102 | OUT DX,AL | 114 | OUT DX,AL |
103 | ; GLOBAL CONFIGURATION REGISTER | 115 | ; GLOBAL CONFIGURATION REGISTER |
104 | MOV DX,02EH | 116 | MOV DX,02EH |
105 | MOV AL,20H | 117 | MOV AL,20H |
106 | OUT DX,AL | 118 | OUT DX,AL |
107 | ; READ THE DATA | 119 | ; READ THE DATA |
108 | MOV DX,02FH | 120 | MOV DX,02FH |
109 | IN AL,DX | 121 | IN AL,DX |
110 | ; EXIT CONFIGURATION MODE | 122 | ; EXIT CONFIGURATION MODE |
111 | MOV DX,02EH | 123 | MOV DX,02EH |
112 | MOV AX,0AAH | 124 | MOV AX,0AAH |
113 | OUT DX,AL | 125 | OUT DX,AL |
@@ -122,12 +134,12 @@ Obtaining the HWM Base Address. | |||
122 | The following is an example of how to read the HWM Base Address located in | 134 | The following is an example of how to read the HWM Base Address located in |
123 | Logical Device 8. | 135 | Logical Device 8. |
124 | 136 | ||
125 | ; ENTER CONFIGURATION MODE | 137 | ; ENTER CONFIGURATION MODE |
126 | MOV DX,02EH | 138 | MOV DX,02EH |
127 | MOV AX,055H | 139 | MOV AX,055H |
128 | OUT DX,AL | 140 | OUT DX,AL |
129 | ; CONFIGURE REGISTER CRE0, | 141 | ; CONFIGURE REGISTER CRE0, |
130 | ; LOGICAL DEVICE 8 | 142 | ; LOGICAL DEVICE 8 |
131 | MOV DX,02EH | 143 | MOV DX,02EH |
132 | MOV AL,07H | 144 | MOV AL,07H |
133 | OUT DX,AL ;Point to LD# Config Reg | 145 | OUT DX,AL ;Point to LD# Config Reg |
@@ -135,12 +147,12 @@ MOV DX,02FH | |||
135 | MOV AL, 08H | 147 | MOV AL, 08H |
136 | OUT DX,AL;Point to Logical Device 8 | 148 | OUT DX,AL;Point to Logical Device 8 |
137 | ; | 149 | ; |
138 | MOV DX,02EH | 150 | MOV DX,02EH |
139 | MOV AL,60H | 151 | MOV AL,60H |
140 | OUT DX,AL ; Point to HWM Base Addr MSB | 152 | OUT DX,AL ; Point to HWM Base Addr MSB |
141 | MOV DX,02FH | 153 | MOV DX,02FH |
142 | IN AL,DX ; Get MSB of HWM Base Addr | 154 | IN AL,DX ; Get MSB of HWM Base Addr |
143 | ; EXIT CONFIGURATION MODE | 155 | ; EXIT CONFIGURATION MODE |
144 | MOV DX,02EH | 156 | MOV DX,02EH |
145 | MOV AX,0AAH | 157 | MOV AX,0AAH |
146 | OUT DX,AL | 158 | OUT DX,AL |
diff --git a/Documentation/i2c/chips/smsc47m1 b/Documentation/i2c/chips/smsc47m1 new file mode 100644 index 000000000000..34e6478c1425 --- /dev/null +++ b/Documentation/i2c/chips/smsc47m1 | |||
@@ -0,0 +1,52 @@ | |||
1 | Kernel driver smsc47m1 | ||
2 | ====================== | ||
3 | |||
4 | Supported chips: | ||
5 | * SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 | ||
6 | Addresses scanned: none, address read from Super I/O config space | ||
7 | Prefix: 'smsc47m1' | ||
8 | Datasheets: | ||
9 | http://www.smsc.com/main/datasheets/47b27x.pdf | ||
10 | http://www.smsc.com/main/datasheets/47m10x.pdf | ||
11 | http://www.smsc.com/main/tools/discontinued/47m13x.pdf | ||
12 | http://www.smsc.com/main/datasheets/47m14x.pdf | ||
13 | http://www.smsc.com/main/tools/discontinued/47m15x.pdf | ||
14 | http://www.smsc.com/main/datasheets/47m192.pdf | ||
15 | |||
16 | Authors: | ||
17 | Mark D. Studebaker <mdsxyz123@yahoo.com>, | ||
18 | With assistance from Bruce Allen <ballen@uwm.edu>, and his | ||
19 | fan.c program: http://www.lsc-group.phys.uwm.edu/%7Eballen/driver/ | ||
20 | Gabriele Gorla <gorlik@yahoo.com>, | ||
21 | Jean Delvare <khali@linux-fr.org> | ||
22 | |||
23 | Description | ||
24 | ----------- | ||
25 | |||
26 | The Standard Microsystems Corporation (SMSC) 47M1xx Super I/O chips | ||
27 | contain monitoring and PWM control circuitry for two fans. | ||
28 | |||
29 | The 47M15x and 47M192 chips contain a full 'hardware monitoring block' | ||
30 | in addition to the fan monitoring and control. The hardware monitoring | ||
31 | block is not supported by the driver. | ||
32 | |||
33 | Fan rotation speeds are reported in RPM (rotations per minute). An alarm is | ||
34 | triggered if the rotation speed has dropped below a programmable limit. Fan | ||
35 | readings can be divided by a programmable divider (1, 2, 4 or 8) to give | ||
36 | the readings more range or accuracy. Not all RPM values can accurately be | ||
37 | represented, so some rounding is done. With a divider of 2, the lowest | ||
38 | representable value is around 2600 RPM. | ||
39 | |||
40 | PWM values are from 0 to 255. | ||
41 | |||
42 | If an alarm triggers, it will remain triggered until the hardware register | ||
43 | is read at least once. This means that the cause for the alarm may | ||
44 | already have disappeared! Note that in the current implementation, all | ||
45 | hardware registers are read whenever any data is read (unless it is less | ||
46 | than 1.5 seconds since the last update). This means that you can easily | ||
47 | miss once-only alarms. | ||
48 | |||
49 | |||
50 | ********************** | ||
51 | The lm_sensors project gratefully acknowledges the support of | ||
52 | Intel in the development of this driver. | ||
diff --git a/Documentation/i2c/chips/via686a b/Documentation/i2c/chips/via686a new file mode 100644 index 000000000000..b82014cb7c53 --- /dev/null +++ b/Documentation/i2c/chips/via686a | |||
@@ -0,0 +1,65 @@ | |||
1 | Kernel driver via686a | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Via VT82C686A, VT82C686B Southbridge Integrated Hardware Monitor | ||
6 | Prefix: 'via686a' | ||
7 | Addresses scanned: ISA in PCI-space encoded address | ||
8 | Datasheet: On request through web form (http://www.via.com.tw/en/support/datasheets/) | ||
9 | |||
10 | Authors: | ||
11 | Kyösti Mälkki <kmalkki@cc.hut.fi>, | ||
12 | Mark D. Studebaker <mdsxyz123@yahoo.com> | ||
13 | Bob Dougherty <bobd@stanford.edu> | ||
14 | (Some conversion-factor data were contributed by | ||
15 | Jonathan Teh Soon Yew <j.teh@iname.com> | ||
16 | and Alex van Kaam <darkside@chello.nl>.) | ||
17 | |||
18 | Module Parameters | ||
19 | ----------------- | ||
20 | |||
21 | force_addr=0xaddr Set the I/O base address. Useful for Asus A7V boards | ||
22 | that don't set the address in the BIOS. Does not do a | ||
23 | PCI force; the via686a must still be present in lspci. | ||
24 | Don't use this unless the driver complains that the | ||
25 | base address is not set. | ||
26 | Example: 'modprobe via686a force_addr=0x6000' | ||
27 | |||
28 | Description | ||
29 | ----------- | ||
30 | |||
31 | The driver does not distinguish between the chips and reports | ||
32 | all as a 686A. | ||
33 | |||
34 | The Via 686a southbridge has integrated hardware monitor functionality. | ||
35 | It also has an I2C bus, but this driver only supports the hardware monitor. | ||
36 | For the I2C bus driver, see <file:Documentation/i2c/busses/i2c-viapro> | ||
37 | |||
38 | The Via 686a implements three temperature sensors, two fan rotation speed | ||
39 | sensors, five voltage sensors and alarms. | ||
40 | |||
41 | Temperatures are measured in degrees Celsius. An alarm is triggered once | ||
42 | when the Overtemperature Shutdown limit is crossed; it is triggered again | ||
43 | as soon as it drops below the hysteresis value. | ||
44 | |||
45 | Fan rotation speeds are reported in RPM (rotations per minute). An alarm is | ||
46 | triggered if the rotation speed has dropped below a programmable limit. Fan | ||
47 | readings can be divided by a programmable divider (1, 2, 4 or 8) to give | ||
48 | the readings more range or accuracy. Not all RPM values can accurately be | ||
49 | represented, so some rounding is done. With a divider of 2, the lowest | ||
50 | representable value is around 2600 RPM. | ||
51 | |||
52 | Voltage sensors (also known as IN sensors) report their values in volts. | ||
53 | An alarm is triggered if the voltage has crossed a programmable minimum | ||
54 | or maximum limit. Voltages are internally scalled, so each voltage channel | ||
55 | has a different resolution and range. | ||
56 | |||
57 | If an alarm triggers, it will remain triggered until the hardware register | ||
58 | is read at least once. This means that the cause for the alarm may | ||
59 | already have disappeared! Note that in the current implementation, all | ||
60 | hardware registers are read whenever any data is read (unless it is less | ||
61 | than 1.5 seconds since the last update). This means that you can easily | ||
62 | miss once-only alarms. | ||
63 | |||
64 | The driver only updates its values each 1.5 seconds; reading it more often | ||
65 | will do no harm, but will return 'old' values. | ||
diff --git a/Documentation/i2c/chips/w83627hf b/Documentation/i2c/chips/w83627hf new file mode 100644 index 000000000000..78f37c2d602e --- /dev/null +++ b/Documentation/i2c/chips/w83627hf | |||
@@ -0,0 +1,66 @@ | |||
1 | Kernel driver w83627hf | ||
2 | ====================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Winbond W83627HF (ISA accesses ONLY) | ||
6 | Prefix: 'w83627hf' | ||
7 | Addresses scanned: ISA address retrieved from Super I/O registers | ||
8 | Datasheet: http://www.winbond.com/PDF/sheet/w83627hf.pdf | ||
9 | * Winbond W83627THF | ||
10 | Prefix: 'w83627thf' | ||
11 | Addresses scanned: ISA address retrieved from Super I/O registers | ||
12 | Datasheet: http://www.winbond.com/PDF/sheet/w83627thf.pdf | ||
13 | * Winbond W83697HF | ||
14 | Prefix: 'w83697hf' | ||
15 | Addresses scanned: ISA address retrieved from Super I/O registers | ||
16 | Datasheet: http://www.winbond.com/PDF/sheet/697hf.pdf | ||
17 | * Winbond W83637HF | ||
18 | Prefix: 'w83637hf' | ||
19 | Addresses scanned: ISA address retrieved from Super I/O registers | ||
20 | Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf | ||
21 | |||
22 | Authors: | ||
23 | Frodo Looijaard <frodol@dds.nl>, | ||
24 | Philip Edelbrock <phil@netroedge.com>, | ||
25 | Mark Studebaker <mdsxyz123@yahoo.com>, | ||
26 | Bernhard C. Schrenk <clemy@clemy.org> | ||
27 | |||
28 | Module Parameters | ||
29 | ----------------- | ||
30 | |||
31 | * force_addr: int | ||
32 | Initialize the ISA address of the sensors | ||
33 | * force_i2c: int | ||
34 | Initialize the I2C address of the sensors | ||
35 | * init: int | ||
36 | (default is 1) | ||
37 | Use 'init=0' to bypass initializing the chip. | ||
38 | Try this if your computer crashes when you load the module. | ||
39 | |||
40 | Description | ||
41 | ----------- | ||
42 | |||
43 | This driver implements support for ISA accesses *only* for | ||
44 | the Winbond W83627HF, W83627THF, W83697HF and W83637HF Super I/O chips. | ||
45 | We will refer to them collectively as Winbond chips. | ||
46 | |||
47 | This driver supports ISA accesses, which should be more reliable | ||
48 | than i2c accesses. Also, for Tyan boards which contain both a | ||
49 | Super I/O chip and a second i2c-only Winbond chip (often a W83782D), | ||
50 | using this driver will avoid i2c address conflicts and complex | ||
51 | initialization that were required in the w83781d driver. | ||
52 | |||
53 | If you really want i2c accesses for these Super I/O chips, | ||
54 | use the w83781d driver. However this is not the preferred method | ||
55 | now that this ISA driver has been developed. | ||
56 | |||
57 | Technically, the w83627thf does not support a VID reading. However, it's | ||
58 | possible or even likely that your mainboard maker has routed these signals | ||
59 | to a specific set of general purpose IO pins (the Asus P4C800-E is one such | ||
60 | board). The w83627thf driver now interprets these as VID. If the VID on | ||
61 | your board doesn't work, first see doc/vid in the lm_sensors package. If | ||
62 | that still doesn't help, email us at lm-sensors@lm-sensors.org. | ||
63 | |||
64 | For further information on this driver see the w83781d driver | ||
65 | documentation. | ||
66 | |||
diff --git a/Documentation/i2c/chips/w83781d b/Documentation/i2c/chips/w83781d new file mode 100644 index 000000000000..e5459333ba68 --- /dev/null +++ b/Documentation/i2c/chips/w83781d | |||
@@ -0,0 +1,402 @@ | |||
1 | Kernel driver w83781d | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Winbond W83781D | ||
6 | Prefix: 'w83781d' | ||
7 | Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) | ||
8 | Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/w83781d.pdf | ||
9 | * Winbond W83782D | ||
10 | Prefix: 'w83782d' | ||
11 | Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) | ||
12 | Datasheet: http://www.winbond.com/PDF/sheet/w83782d.pdf | ||
13 | * Winbond W83783S | ||
14 | Prefix: 'w83783s' | ||
15 | Addresses scanned: I2C 0x2d | ||
16 | Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/w83783s.pdf | ||
17 | * Winbond W83627HF | ||
18 | Prefix: 'w83627hf' | ||
19 | Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) | ||
20 | Datasheet: http://www.winbond.com/PDF/sheet/w83627hf.pdf | ||
21 | * Asus AS99127F | ||
22 | Prefix: 'as99127f' | ||
23 | Addresses scanned: I2C 0x28 - 0x2f | ||
24 | Datasheet: Unavailable from Asus | ||
25 | |||
26 | Authors: | ||
27 | Frodo Looijaard <frodol@dds.nl>, | ||
28 | Philip Edelbrock <phil@netroedge.com>, | ||
29 | Mark Studebaker <mdsxyz123@yahoo.com> | ||
30 | |||
31 | Module parameters | ||
32 | ----------------- | ||
33 | |||
34 | * init int | ||
35 | (default 1) | ||
36 | Use 'init=0' to bypass initializing the chip. | ||
37 | Try this if your computer crashes when you load the module. | ||
38 | |||
39 | force_subclients=bus,caddr,saddr,saddr | ||
40 | This is used to force the i2c addresses for subclients of | ||
41 | a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b' | ||
42 | to force the subclients of chip 0x2d on bus 0 to i2c addresses | ||
43 | 0x4a and 0x4b. This parameter is useful for certain Tyan boards. | ||
44 | |||
45 | Description | ||
46 | ----------- | ||
47 | |||
48 | This driver implements support for the Winbond W83781D, W83782D, W83783S, | ||
49 | W83627HF chips, and the Asus AS99127F chips. We will refer to them | ||
50 | collectively as W8378* chips. | ||
51 | |||
52 | There is quite some difference between these chips, but they are similar | ||
53 | enough that it was sensible to put them together in one driver. | ||
54 | The W83627HF chip is assumed to be identical to the ISA W83782D. | ||
55 | The Asus chips are similar to an I2C-only W83782D. | ||
56 | |||
57 | Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA | ||
58 | as99127f 7 3 0 3 0x31 0x12c3 yes no | ||
59 | as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no | ||
60 | w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes | ||
61 | w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC) | ||
62 | w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes | ||
63 | w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no | ||
64 | |||
65 | Detection of these chips can sometimes be foiled because they can be in | ||
66 | an internal state that allows no clean access. If you know the address | ||
67 | of the chip, use a 'force' parameter; this will put them into a more | ||
68 | well-behaved state first. | ||
69 | |||
70 | The W8378* implements temperature sensors (three on the W83781D and W83782D, | ||
71 | two on the W83783S), three fan rotation speed sensors, voltage sensors | ||
72 | (seven on the W83781D, nine on the W83782D and six on the W83783S), VID | ||
73 | lines, alarms with beep warnings, and some miscellaneous stuff. | ||
74 | |||
75 | Temperatures are measured in degrees Celsius. There is always one main | ||
76 | temperature sensor, and one (W83783S) or two (W83781D and W83782D) other | ||
77 | sensors. An alarm is triggered for the main sensor once when the | ||
78 | Overtemperature Shutdown limit is crossed; it is triggered again as soon as | ||
79 | it drops below the Hysteresis value. A more useful behavior | ||
80 | can be found by setting the Hysteresis value to +127 degrees Celsius; in | ||
81 | this case, alarms are issued during all the time when the actual temperature | ||
82 | is above the Overtemperature Shutdown value. The driver sets the | ||
83 | hysteresis value for temp1 to 127 at initialization. | ||
84 | |||
85 | For the other temperature sensor(s), an alarm is triggered when the | ||
86 | temperature gets higher then the Overtemperature Shutdown value; it stays | ||
87 | on until the temperature falls below the Hysteresis value. But on the | ||
88 | W83781D, there is only one alarm that functions for both other sensors! | ||
89 | Temperatures are guaranteed within a range of -55 to +125 degrees. The | ||
90 | main temperature sensors has a resolution of 1 degree; the other sensor(s) | ||
91 | of 0.5 degree. | ||
92 | |||
93 | Fan rotation speeds are reported in RPM (rotations per minute). An alarm is | ||
94 | triggered if the rotation speed has dropped below a programmable limit. Fan | ||
95 | readings can be divided by a programmable divider (1, 2, 4 or 8 for the | ||
96 | W83781D; 1, 2, 4, 8, 16, 32, 64 or 128 for the others) to give | ||
97 | the readings more range or accuracy. Not all RPM values can accurately | ||
98 | be represented, so some rounding is done. With a divider of 2, the lowest | ||
99 | representable value is around 2600 RPM. | ||
100 | |||
101 | Voltage sensors (also known as IN sensors) report their values in volts. | ||
102 | An alarm is triggered if the voltage has crossed a programmable minimum | ||
103 | or maximum limit. Note that minimum in this case always means 'closest to | ||
104 | zero'; this is important for negative voltage measurements. All voltage | ||
105 | inputs can measure voltages between 0 and 4.08 volts, with a resolution | ||
106 | of 0.016 volt. | ||
107 | |||
108 | The VID lines encode the core voltage value: the voltage level your processor | ||
109 | should work with. This is hardcoded by the mainboard and/or processor itself. | ||
110 | It is a value in volts. When it is unconnected, you will often find the | ||
111 | value 3.50 V here. | ||
112 | |||
113 | The W83782D and W83783S temperature conversion machine understands about | ||
114 | several kinds of temperature probes. You can program the so-called | ||
115 | beta value in the sensor files. '1' is the PII/Celeron diode, '2' is the | ||
116 | TN3904 transistor, and 3435 the default thermistor value. Other values | ||
117 | are (not yet) supported. | ||
118 | |||
119 | In addition to the alarms described above, there is a CHAS alarm on the | ||
120 | chips which triggers if your computer case is open. | ||
121 | |||
122 | When an alarm goes off, you can be warned by a beeping signal through | ||
123 | your computer speaker. It is possible to enable all beeping globally, | ||
124 | or only the beeping for some alarms. | ||
125 | |||
126 | If an alarm triggers, it will remain triggered until the hardware register | ||
127 | is read at least once. This means that the cause for the alarm may | ||
128 | already have disappeared! Note that in the current implementation, all | ||
129 | hardware registers are read whenever any data is read (unless it is less | ||
130 | than 1.5 seconds since the last update). This means that you can easily | ||
131 | miss once-only alarms. | ||
132 | |||
133 | The chips only update values each 1.5 seconds; reading them more often | ||
134 | will do no harm, but will return 'old' values. | ||
135 | |||
136 | AS99127F PROBLEMS | ||
137 | ----------------- | ||
138 | The as99127f support was developed without the benefit of a datasheet. | ||
139 | In most cases it is treated as a w83781d (although revision 2 of the | ||
140 | AS99127F looks more like a w83782d). | ||
141 | This support will be BETA until a datasheet is released. | ||
142 | One user has reported problems with fans stopping | ||
143 | occasionally. | ||
144 | |||
145 | Note that the individual beep bits are inverted from the other chips. | ||
146 | The driver now takes care of this so that user-space applications | ||
147 | don't have to know about it. | ||
148 | |||
149 | Known problems: | ||
150 | - Problems with diode/thermistor settings (supported?) | ||
151 | - One user reports fans stopping under high server load. | ||
152 | - Revision 2 seems to have 2 PWM registers but we don't know | ||
153 | how to handle them. More details below. | ||
154 | |||
155 | These will not be fixed unless we get a datasheet. | ||
156 | If you have problems, please lobby Asus to release a datasheet. | ||
157 | Unfortunately several others have without success. | ||
158 | Please do not send mail to us asking for better as99127f support. | ||
159 | We have done the best we can without a datasheet. | ||
160 | Please do not send mail to the author or the sensors group asking for | ||
161 | a datasheet or ideas on how to convince Asus. We can't help. | ||
162 | |||
163 | |||
164 | NOTES: | ||
165 | ----- | ||
166 | 783s has no in1 so that in[2-6] are compatible with the 781d/782d. | ||
167 | |||
168 | 783s pin is programmable for -5V or temp1; defaults to -5V, | ||
169 | no control in driver so temp1 doesn't work. | ||
170 | |||
171 | 782d and 783s datasheets differ on which is pwm1 and which is pwm2. | ||
172 | We chose to follow 782d. | ||
173 | |||
174 | 782d and 783s pin is programmable for fan3 input or pwm2 output; | ||
175 | defaults to fan3 input. | ||
176 | If pwm2 is enabled (with echo 255 1 > pwm2), then | ||
177 | fan3 will report 0. | ||
178 | |||
179 | 782d has pwm1-2 for ISA, pwm1-4 for i2c. (pwm3-4 share pins with | ||
180 | the ISA pins) | ||
181 | |||
182 | Data sheet updates: | ||
183 | ------------------ | ||
184 | - PWM clock registers: | ||
185 | |||
186 | 000: master / 512 | ||
187 | 001: master / 1024 | ||
188 | 010: master / 2048 | ||
189 | 011: master / 4096 | ||
190 | 100: master / 8192 | ||
191 | |||
192 | |||
193 | Answers from Winbond tech support | ||
194 | --------------------------------- | ||
195 | > | ||
196 | > 1) In the W83781D data sheet section 7.2 last paragraph, it talks about | ||
197 | > reprogramming the R-T table if the Beta of the thermistor is not | ||
198 | > 3435K. The R-T table is described briefly in section 8.20. | ||
199 | > What formulas do I use to program a new R-T table for a given Beta? | ||
200 | > | ||
201 | We are sorry that the calculation for R-T table value is | ||
202 | confidential. If you have another Beta value of thermistor, we can help | ||
203 | to calculate the R-T table for you. But you should give us real R-T | ||
204 | Table which can be gotten by thermistor vendor. Therefore we will calculate | ||
205 | them and obtain 32-byte data, and you can fill the 32-byte data to the | ||
206 | register in Bank0.CR51 of W83781D. | ||
207 | |||
208 | |||
209 | > 2) In the W83782D data sheet, it mentions that pins 38, 39, and 40 are | ||
210 | > programmable to be either thermistor or Pentium II diode inputs. | ||
211 | > How do I program them for diode inputs? I can't find any register | ||
212 | > to program these to be diode inputs. | ||
213 | --> You may program Bank0 CR[5Dh] and CR[59h] registers. | ||
214 | |||
215 | CR[5Dh] bit 1(VTIN1) bit 2(VTIN2) bit 3(VTIN3) | ||
216 | |||
217 | thermistor 0 0 0 | ||
218 | diode 1 1 1 | ||
219 | |||
220 | |||
221 | (error) CR[59h] bit 4(VTIN1) bit 2(VTIN2) bit 3(VTIN3) | ||
222 | (right) CR[59h] bit 4(VTIN1) bit 5(VTIN2) bit 6(VTIN3) | ||
223 | |||
224 | PII thermal diode 1 1 1 | ||
225 | 2N3904 diode 0 0 0 | ||
226 | |||
227 | |||
228 | Asus Clones | ||
229 | ----------- | ||
230 | |||
231 | We have no datasheets for the Asus clones (AS99127F and ASB100 Bach). | ||
232 | Here are some very useful information that were given to us by Alex Van | ||
233 | Kaam about how to detect these chips, and how to read their values. He | ||
234 | also gives advice for another Asus chipset, the Mozart-2 (which we | ||
235 | don't support yet). Thanks Alex! | ||
236 | I reworded some parts and added personal comments. | ||
237 | |||
238 | # Detection: | ||
239 | |||
240 | AS99127F rev.1, AS99127F rev.2 and ASB100: | ||
241 | - I2C address range: 0x29 - 0x2F | ||
242 | - If register 0x58 holds 0x31 then we have an Asus (either ASB100 or | ||
243 | AS99127F) | ||
244 | - Which one depends on register 0x4F (manufacturer ID): | ||
245 | 0x06 or 0x94: ASB100 | ||
246 | 0x12 or 0xC3: AS99127F rev.1 | ||
247 | 0x5C or 0xA3: AS99127F rev.2 | ||
248 | Note that 0x5CA3 is Winbond's ID (WEC), which let us think Asus get their | ||
249 | AS99127F rev.2 direct from Winbond. The other codes mean ATT and DVC, | ||
250 | respectively. ATT could stand for Asustek something (although it would be | ||
251 | very badly chosen IMHO), I don't know what DVC could stand for. Maybe | ||
252 | these codes simply aren't meant to be decoded that way. | ||
253 | |||
254 | Mozart-2: | ||
255 | - I2C address: 0x77 | ||
256 | - If register 0x58 holds 0x56 or 0x10 then we have a Mozart-2 | ||
257 | - Of the Mozart there are 3 types: | ||
258 | 0x58=0x56, 0x4E=0x94, 0x4F=0x36: Asus ASM58 Mozart-2 | ||
259 | 0x58=0x56, 0x4E=0x94, 0x4F=0x06: Asus AS2K129R Mozart-2 | ||
260 | 0x58=0x10, 0x4E=0x5C, 0x4F=0xA3: Asus ??? Mozart-2 | ||
261 | You can handle all 3 the exact same way :) | ||
262 | |||
263 | # Temperature sensors: | ||
264 | |||
265 | ASB100: | ||
266 | - sensor 1: register 0x27 | ||
267 | - sensor 2 & 3 are the 2 LM75's on the SMBus | ||
268 | - sensor 4: register 0x17 | ||
269 | Remark: I noticed that on Intel boards sensor 2 is used for the CPU | ||
270 | and 4 is ignored/stuck, on AMD boards sensor 4 is the CPU and sensor 2 is | ||
271 | either ignored or a socket temperature. | ||
272 | |||
273 | AS99127F (rev.1 and 2 alike): | ||
274 | - sensor 1: register 0x27 | ||
275 | - sensor 2 & 3 are the 2 LM75's on the SMBus | ||
276 | Remark: Register 0x5b is suspected to be temperature type selector. Bit 1 | ||
277 | would control temp1, bit 3 temp2 and bit 5 temp3. | ||
278 | |||
279 | Mozart-2: | ||
280 | - sensor 1: register 0x27 | ||
281 | - sensor 2: register 0x13 | ||
282 | |||
283 | # Fan sensors: | ||
284 | |||
285 | ASB100, AS99127F (rev.1 and 2 alike): | ||
286 | - 3 fans, identical to the W83781D | ||
287 | |||
288 | Mozart-2: | ||
289 | - 2 fans only, 1350000/RPM/div | ||
290 | - fan 1: register 0x28, divisor on register 0xA1 (bits 4-5) | ||
291 | - fan 2: register 0x29, divisor on register 0xA1 (bits 6-7) | ||
292 | |||
293 | # Voltages: | ||
294 | |||
295 | This is where there is a difference between AS99127F rev.1 and 2. | ||
296 | Remark: The difference is similar to the difference between | ||
297 | W83781D and W83782D. | ||
298 | |||
299 | ASB100: | ||
300 | in0=r(0x20)*0.016 | ||
301 | in1=r(0x21)*0.016 | ||
302 | in2=r(0x22)*0.016 | ||
303 | in3=r(0x23)*0.016*1.68 | ||
304 | in4=r(0x24)*0.016*3.8 | ||
305 | in5=r(0x25)*(-0.016)*3.97 | ||
306 | in6=r(0x26)*(-0.016)*1.666 | ||
307 | |||
308 | AS99127F rev.1: | ||
309 | in0=r(0x20)*0.016 | ||
310 | in1=r(0x21)*0.016 | ||
311 | in2=r(0x22)*0.016 | ||
312 | in3=r(0x23)*0.016*1.68 | ||
313 | in4=r(0x24)*0.016*3.8 | ||
314 | in5=r(0x25)*(-0.016)*3.97 | ||
315 | in6=r(0x26)*(-0.016)*1.503 | ||
316 | |||
317 | AS99127F rev.2: | ||
318 | in0=r(0x20)*0.016 | ||
319 | in1=r(0x21)*0.016 | ||
320 | in2=r(0x22)*0.016 | ||
321 | in3=r(0x23)*0.016*1.68 | ||
322 | in4=r(0x24)*0.016*3.8 | ||
323 | in5=(r(0x25)*0.016-3.6)*5.14+3.6 | ||
324 | in6=(r(0x26)*0.016-3.6)*3.14+3.6 | ||
325 | |||
326 | Mozart-2: | ||
327 | in0=r(0x20)*0.016 | ||
328 | in1=255 | ||
329 | in2=r(0x22)*0.016 | ||
330 | in3=r(0x23)*0.016*1.68 | ||
331 | in4=r(0x24)*0.016*4 | ||
332 | in5=255 | ||
333 | in6=255 | ||
334 | |||
335 | |||
336 | # PWM | ||
337 | |||
338 | Additional info about PWM on the AS99127F (may apply to other Asus | ||
339 | chips as well) by Jean Delvare as of 2004-04-09: | ||
340 | |||
341 | AS99127F revision 2 seems to have two PWM registers at 0x59 and 0x5A, | ||
342 | and a temperature sensor type selector at 0x5B (which basically means | ||
343 | that they swapped registers 0x59 and 0x5B when you compare with Winbond | ||
344 | chips). | ||
345 | Revision 1 of the chip also has the temperature sensor type selector at | ||
346 | 0x5B, but PWM registers have no effect. | ||
347 | |||
348 | We don't know exactly how the temperature sensor type selection works. | ||
349 | Looks like bits 1-0 are for temp1, bits 3-2 for temp2 and bits 5-4 for | ||
350 | temp3, although it is possible that only the most significant bit matters | ||
351 | each time. So far, values other than 0 always broke the readings. | ||
352 | |||
353 | PWM registers seem to be split in two parts: bit 7 is a mode selector, | ||
354 | while the other bits seem to define a value or threshold. | ||
355 | |||
356 | When bit 7 is clear, bits 6-0 seem to hold a threshold value. If the value | ||
357 | is below a given limit, the fan runs at low speed. If the value is above | ||
358 | the limit, the fan runs at full speed. We have no clue as to what the limit | ||
359 | represents. Note that there seem to be some inertia in this mode, speed | ||
360 | changes may need some time to trigger. Also, an hysteresis mechanism is | ||
361 | suspected since walking through all the values increasingly and then | ||
362 | decreasingly led to slightly different limits. | ||
363 | |||
364 | When bit 7 is set, bits 3-0 seem to hold a threshold value, while bits 6-4 | ||
365 | would not be significant. If the value is below a given limit, the fan runs | ||
366 | at full speed, while if it is above the limit it runs at low speed (so this | ||
367 | is the contrary of the other mode, in a way). Here again, we don't know | ||
368 | what the limit is supposed to represent. | ||
369 | |||
370 | One remarkable thing is that the fans would only have two or three | ||
371 | different speeds (transitional states left apart), not a whole range as | ||
372 | you usually get with PWM. | ||
373 | |||
374 | As a conclusion, you can write 0x00 or 0x8F to the PWM registers to make | ||
375 | fans run at low speed, and 0x7F or 0x80 to make them run at full speed. | ||
376 | |||
377 | Please contact us if you can figure out how it is supposed to work. As | ||
378 | long as we don't know more, the w83781d driver doesn't handle PWM on | ||
379 | AS99127F chips at all. | ||
380 | |||
381 | Additional info about PWM on the AS99127F rev.1 by Hector Martin: | ||
382 | |||
383 | I've been fiddling around with the (in)famous 0x59 register and | ||
384 | found out the following values do work as a form of coarse pwm: | ||
385 | |||
386 | 0x80 - seems to turn fans off after some time(1-2 minutes)... might be | ||
387 | some form of auto-fan-control based on temp? hmm (Qfan? this mobo is an | ||
388 | old ASUS, it isn't marketed as Qfan. Maybe some beta pre-attemp at Qfan | ||
389 | that was dropped at the BIOS) | ||
390 | 0x81 - off | ||
391 | 0x82 - slightly "on-ner" than off, but my fans do not get to move. I can | ||
392 | hear the high-pitched PWM sound that motors give off at too-low-pwm. | ||
393 | 0x83 - now they do move. Estimate about 70% speed or so. | ||
394 | 0x84-0x8f - full on | ||
395 | |||
396 | Changing the high nibble doesn't seem to do much except the high bit | ||
397 | (0x80) must be set for PWM to work, else the current pwm doesn't seem to | ||
398 | change. | ||
399 | |||
400 | My mobo is an ASUS A7V266-E. This behavior is similar to what I got | ||
401 | with speedfan under Windows, where 0-15% would be off, 15-2x% (can't | ||
402 | remember the exact value) would be 70% and higher would be full on. | ||
diff --git a/Documentation/i2c/chips/w83l785ts b/Documentation/i2c/chips/w83l785ts new file mode 100644 index 000000000000..1841cedc25b2 --- /dev/null +++ b/Documentation/i2c/chips/w83l785ts | |||
@@ -0,0 +1,39 @@ | |||
1 | Kernel driver w83l785ts | ||
2 | ======================= | ||
3 | |||
4 | Supported chips: | ||
5 | * Winbond W83L785TS-S | ||
6 | Prefix: 'w83l785ts' | ||
7 | Addresses scanned: I2C 0x2e | ||
8 | Datasheet: Publicly available at the Winbond USA website | ||
9 | http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/W83L785TS-S.pdf | ||
10 | |||
11 | Authors: | ||
12 | Jean Delvare <khali@linux-fr.org> | ||
13 | |||
14 | Description | ||
15 | ----------- | ||
16 | |||
17 | The W83L785TS-S is a digital temperature sensor. It senses the | ||
18 | temperature of a single external diode. The high limit is | ||
19 | theoretically defined as 85 or 100 degrees C through a combination | ||
20 | of external resistors, so the user cannot change it. Values seen so | ||
21 | far suggest that the two possible limits are actually 95 and 110 | ||
22 | degrees C. The datasheet is rather poor and obviously inaccurate | ||
23 | on several points including this one. | ||
24 | |||
25 | All temperature values are given in degrees Celsius. Resolution | ||
26 | is 1.0 degree. See the datasheet for details. | ||
27 | |||
28 | The w83l785ts driver will not update its values more frequently than | ||
29 | every other second; reading them more often will do no harm, but will | ||
30 | return 'old' values. | ||
31 | |||
32 | Known Issues | ||
33 | ------------ | ||
34 | |||
35 | On some systems (Asus), the BIOS is known to interfere with the driver | ||
36 | and cause read errors. The driver will retry a given number of times | ||
37 | (5 by default) and then give up, returning the old value (or 0 if | ||
38 | there is no old value). It seems to work well enough so that you should | ||
39 | not notice anything. Thanks to James Bolt for helping test this feature. | ||
diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index 56404918eabc..a7adbdd9ea8a 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients | |||
@@ -57,7 +57,7 @@ Technical changes: | |||
57 | Documentation/i2c/sysfs-interface for the individual files. Also | 57 | Documentation/i2c/sysfs-interface for the individual files. Also |
58 | convert the units these files read and write to the specified ones. | 58 | convert the units these files read and write to the specified ones. |
59 | If you need to add a new type of file, please discuss it on the | 59 | If you need to add a new type of file, please discuss it on the |
60 | sensors mailing list <sensors@stimpy.netroedge.com> by providing a | 60 | sensors mailing list <lm-sensors@lm-sensors.org> by providing a |
61 | patch to the Documentation/i2c/sysfs-interface file. | 61 | patch to the Documentation/i2c/sysfs-interface file. |
62 | 62 | ||
63 | * [Attach] For I2C drivers, the attach function should make sure | 63 | * [Attach] For I2C drivers, the attach function should make sure |
diff --git a/Documentation/i2c/userspace-tools b/Documentation/i2c/userspace-tools new file mode 100644 index 000000000000..2622aac65422 --- /dev/null +++ b/Documentation/i2c/userspace-tools | |||
@@ -0,0 +1,39 @@ | |||
1 | Introduction | ||
2 | ------------ | ||
3 | |||
4 | Most mainboards have sensor chips to monitor system health (like temperatures, | ||
5 | voltages, fans speed). They are often connected through an I2C bus, but some | ||
6 | are also connected directly through the ISA bus. | ||
7 | |||
8 | The kernel drivers make the data from the sensor chips available in the /sys | ||
9 | virtual filesystem. Userspace tools are then used to display or set or the | ||
10 | data in a more friendly manner. | ||
11 | |||
12 | Lm-sensors | ||
13 | ---------- | ||
14 | |||
15 | Core set of utilites that will allow you to obtain health information, | ||
16 | setup monitoring limits etc. You can get them on their homepage | ||
17 | http://www.lm-sensors.nu/ or as a package from your Linux distribution. | ||
18 | |||
19 | If from website: | ||
20 | Get lmsensors from project web site. Please note, you need only userspace | ||
21 | part, so compile with "make user_install" target. | ||
22 | |||
23 | General hints to get things working: | ||
24 | |||
25 | 0) get lm-sensors userspace utils | ||
26 | 1) compile all drivers in I2C section as modules in your kernel | ||
27 | 2) run sensors-detect script, it will tell you what modules you need to load. | ||
28 | 3) load them and run "sensors" command, you should see some results. | ||
29 | 4) fix sensors.conf, labels, limits, fan divisors | ||
30 | 5) if any more problems consult FAQ, or documentation | ||
31 | |||
32 | Other utilites | ||
33 | -------------- | ||
34 | |||
35 | If you want some graphical indicators of system health look for applications | ||
36 | like: gkrellm, ksensors, xsensors, wmtemp, wmsensors, wmgtemp, ksysguardd, | ||
37 | hardware-monitor | ||
38 | |||
39 | If you are server administrator you can try snmpd or mrtgutils. | ||
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index ad27511e3c7d..f482dae81de3 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients | |||
@@ -171,45 +171,31 @@ The following lists are used internally: | |||
171 | 171 | ||
172 | normal_i2c: filled in by the module writer. | 172 | normal_i2c: filled in by the module writer. |
173 | A list of I2C addresses which should normally be examined. | 173 | A list of I2C addresses which should normally be examined. |
174 | normal_i2c_range: filled in by the module writer. | ||
175 | A list of pairs of I2C addresses, each pair being an inclusive range of | ||
176 | addresses which should normally be examined. | ||
177 | probe: insmod parameter. | 174 | probe: insmod parameter. |
178 | A list of pairs. The first value is a bus number (-1 for any I2C bus), | 175 | A list of pairs. The first value is a bus number (-1 for any I2C bus), |
179 | the second is the address. These addresses are also probed, as if they | 176 | the second is the address. These addresses are also probed, as if they |
180 | were in the 'normal' list. | 177 | were in the 'normal' list. |
181 | probe_range: insmod parameter. | ||
182 | A list of triples. The first value is a bus number (-1 for any I2C bus), | ||
183 | the second and third are addresses. These form an inclusive range of | ||
184 | addresses that are also probed, as if they were in the 'normal' list. | ||
185 | ignore: insmod parameter. | 178 | ignore: insmod parameter. |
186 | A list of pairs. The first value is a bus number (-1 for any I2C bus), | 179 | A list of pairs. The first value is a bus number (-1 for any I2C bus), |
187 | the second is the I2C address. These addresses are never probed. | 180 | the second is the I2C address. These addresses are never probed. |
188 | This parameter overrules 'normal' and 'probe', but not the 'force' lists. | 181 | This parameter overrules 'normal' and 'probe', but not the 'force' lists. |
189 | ignore_range: insmod parameter. | ||
190 | A list of triples. The first value is a bus number (-1 for any I2C bus), | ||
191 | the second and third are addresses. These form an inclusive range of | ||
192 | I2C addresses that are never probed. | ||
193 | This parameter overrules 'normal' and 'probe', but not the 'force' lists. | ||
194 | force: insmod parameter. | 182 | force: insmod parameter. |
195 | A list of pairs. The first value is a bus number (-1 for any I2C bus), | 183 | A list of pairs. The first value is a bus number (-1 for any I2C bus), |
196 | the second is the I2C address. A device is blindly assumed to be on | 184 | the second is the I2C address. A device is blindly assumed to be on |
197 | the given address, no probing is done. | 185 | the given address, no probing is done. |
198 | 186 | ||
199 | Fortunately, as a module writer, you just have to define the `normal' | 187 | Fortunately, as a module writer, you just have to define the `normal_i2c' |
200 | and/or `normal_range' parameters. The complete declaration could look | 188 | parameter. The complete declaration could look like this: |
201 | like this: | ||
202 | 189 | ||
203 | /* Scan 0x20 to 0x2f, 0x37, and 0x40 to 0x4f */ | 190 | /* Scan 0x37, and 0x48 to 0x4f */ |
204 | static unsigned short normal_i2c[] = { 0x37,I2C_CLIENT_END }; | 191 | static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
205 | static unsigned short normal_i2c_range[] = { 0x20, 0x2f, 0x40, 0x4f, | 192 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; |
206 | I2C_CLIENT_END }; | ||
207 | 193 | ||
208 | /* Magic definition of all other variables and things */ | 194 | /* Magic definition of all other variables and things */ |
209 | I2C_CLIENT_INSMOD; | 195 | I2C_CLIENT_INSMOD; |
210 | 196 | ||
211 | Note that you *have* to call the two defined variables `normal_i2c' and | 197 | Note that you *have* to call the defined variable `normal_i2c', |
212 | `normal_i2c_range', without any prefix! | 198 | without any prefix! |
213 | 199 | ||
214 | 200 | ||
215 | Probing classes (sensors) | 201 | Probing classes (sensors) |
@@ -223,39 +209,17 @@ The following lists are used internally. They are all lists of integers. | |||
223 | 209 | ||
224 | normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END. | 210 | normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END. |
225 | A list of I2C addresses which should normally be examined. | 211 | A list of I2C addresses which should normally be examined. |
226 | normal_i2c_range: filled in by the module writer. Terminated by | ||
227 | SENSORS_I2C_END | ||
228 | A list of pairs of I2C addresses, each pair being an inclusive range of | ||
229 | addresses which should normally be examined. | ||
230 | normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END. | 212 | normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END. |
231 | A list of ISA addresses which should normally be examined. | 213 | A list of ISA addresses which should normally be examined. |
232 | normal_isa_range: filled in by the module writer. Terminated by | ||
233 | SENSORS_ISA_END | ||
234 | A list of triples. The first two elements are ISA addresses, being an | ||
235 | range of addresses which should normally be examined. The third is the | ||
236 | modulo parameter: only addresses which are 0 module this value relative | ||
237 | to the first address of the range are actually considered. | ||
238 | probe: insmod parameter. Initialize this list with SENSORS_I2C_END values. | 214 | probe: insmod parameter. Initialize this list with SENSORS_I2C_END values. |
239 | A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for | 215 | A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for |
240 | the ISA bus, -1 for any I2C bus), the second is the address. These | 216 | the ISA bus, -1 for any I2C bus), the second is the address. These |
241 | addresses are also probed, as if they were in the 'normal' list. | 217 | addresses are also probed, as if they were in the 'normal' list. |
242 | probe_range: insmod parameter. Initialize this list with SENSORS_I2C_END | ||
243 | values. | ||
244 | A list of triples. The first value is a bus number (SENSORS_ISA_BUS for | ||
245 | the ISA bus, -1 for any I2C bus), the second and third are addresses. | ||
246 | These form an inclusive range of addresses that are also probed, as | ||
247 | if they were in the 'normal' list. | ||
248 | ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values. | 218 | ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values. |
249 | A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for | 219 | A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for |
250 | the ISA bus, -1 for any I2C bus), the second is the I2C address. These | 220 | the ISA bus, -1 for any I2C bus), the second is the I2C address. These |
251 | addresses are never probed. This parameter overrules 'normal' and | 221 | addresses are never probed. This parameter overrules 'normal' and |
252 | 'probe', but not the 'force' lists. | 222 | 'probe', but not the 'force' lists. |
253 | ignore_range: insmod parameter. Initialize this list with SENSORS_I2C_END | ||
254 | values. | ||
255 | A list of triples. The first value is a bus number (SENSORS_ISA_BUS for | ||
256 | the ISA bus, -1 for any I2C bus), the second and third are addresses. | ||
257 | These form an inclusive range of I2C addresses that are never probed. | ||
258 | This parameter overrules 'normal' and 'probe', but not the 'force' lists. | ||
259 | 223 | ||
260 | Also used is a list of pointers to sensors_force_data structures: | 224 | Also used is a list of pointers to sensors_force_data structures: |
261 | force_data: insmod parameters. A list, ending with an element of which | 225 | force_data: insmod parameters. A list, ending with an element of which |
@@ -269,16 +233,14 @@ Also used is a list of pointers to sensors_force_data structures: | |||
269 | So we have a generic insmod variabled `force', and chip-specific variables | 233 | So we have a generic insmod variabled `force', and chip-specific variables |
270 | `force_CHIPNAME'. | 234 | `force_CHIPNAME'. |
271 | 235 | ||
272 | Fortunately, as a module writer, you just have to define the `normal' | 236 | Fortunately, as a module writer, you just have to define the `normal_i2c' |
273 | and/or `normal_range' parameters, and define what chip names are used. | 237 | and `normal_isa' parameters, and define what chip names are used. |
274 | The complete declaration could look like this: | 238 | The complete declaration could look like this: |
275 | /* Scan i2c addresses 0x20 to 0x2f, 0x37, and 0x40 to 0x4f | 239 | /* Scan i2c addresses 0x37, and 0x48 to 0x4f */ |
276 | static unsigned short normal_i2c[] = {0x37,SENSORS_I2C_END}; | 240 | static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
277 | static unsigned short normal_i2c_range[] = {0x20,0x2f,0x40,0x4f, | 241 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; |
278 | SENSORS_I2C_END}; | ||
279 | /* Scan ISA address 0x290 */ | 242 | /* Scan ISA address 0x290 */ |
280 | static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END}; | 243 | static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END}; |
281 | static unsigned int normal_isa_range[] = {SENSORS_ISA_END}; | ||
282 | 244 | ||
283 | /* Define chips foo and bar, as well as all module parameters and things */ | 245 | /* Define chips foo and bar, as well as all module parameters and things */ |
284 | SENSORS_INSMOD_2(foo,bar); | 246 | SENSORS_INSMOD_2(foo,bar); |
diff --git a/MAINTAINERS b/MAINTAINERS index 0f88a70a15d8..4d44824884ef 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -194,7 +194,7 @@ S: Maintained | |||
194 | ADM1025 HARDWARE MONITOR DRIVER | 194 | ADM1025 HARDWARE MONITOR DRIVER |
195 | P: Jean Delvare | 195 | P: Jean Delvare |
196 | M: khali@linux-fr.org | 196 | M: khali@linux-fr.org |
197 | L: sensors@stimpy.netroedge.com | 197 | L: lm-sensors@lm-sensors.org |
198 | S: Maintained | 198 | S: Maintained |
199 | 199 | ||
200 | ADT746X FAN DRIVER | 200 | ADT746X FAN DRIVER |
@@ -242,7 +242,7 @@ S: Maintained | |||
242 | ALI1563 I2C DRIVER | 242 | ALI1563 I2C DRIVER |
243 | P: Rudolf Marek | 243 | P: Rudolf Marek |
244 | M: r.marek@sh.cvut.cz | 244 | M: r.marek@sh.cvut.cz |
245 | L: sensors@stimpy.netroedge.com | 245 | L: lm-sensors@lm-sensors.org |
246 | S: Maintained | 246 | S: Maintained |
247 | 247 | ||
248 | ALPHA PORT | 248 | ALPHA PORT |
@@ -1002,7 +1002,7 @@ P: Greg Kroah-Hartman | |||
1002 | M: greg@kroah.com | 1002 | M: greg@kroah.com |
1003 | P: Jean Delvare | 1003 | P: Jean Delvare |
1004 | M: khali@linux-fr.org | 1004 | M: khali@linux-fr.org |
1005 | L: sensors@stimpy.netroedge.com | 1005 | L: lm-sensors@lm-sensors.org |
1006 | W: http://www.lm-sensors.nu/ | 1006 | W: http://www.lm-sensors.nu/ |
1007 | S: Maintained | 1007 | S: Maintained |
1008 | 1008 | ||
@@ -1430,13 +1430,13 @@ S: Supported | |||
1430 | LM83 HARDWARE MONITOR DRIVER | 1430 | LM83 HARDWARE MONITOR DRIVER |
1431 | P: Jean Delvare | 1431 | P: Jean Delvare |
1432 | M: khali@linux-fr.org | 1432 | M: khali@linux-fr.org |
1433 | L: sensors@stimpy.netroedge.com | 1433 | L: lm-sensors@lm-sensors.org |
1434 | S: Maintained | 1434 | S: Maintained |
1435 | 1435 | ||
1436 | LM90 HARDWARE MONITOR DRIVER | 1436 | LM90 HARDWARE MONITOR DRIVER |
1437 | P: Jean Delvare | 1437 | P: Jean Delvare |
1438 | M: khali@linux-fr.org | 1438 | M: khali@linux-fr.org |
1439 | L: sensors@stimpy.netroedge.com | 1439 | L: lm-sensors@lm-sensors.org |
1440 | S: Maintained | 1440 | S: Maintained |
1441 | 1441 | ||
1442 | LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP Dynamic Disks) | 1442 | LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP Dynamic Disks) |
@@ -2075,7 +2075,7 @@ S: Maintained | |||
2075 | SMSC47M1 HARDWARE MONITOR DRIVER | 2075 | SMSC47M1 HARDWARE MONITOR DRIVER |
2076 | P: Jean Delvare | 2076 | P: Jean Delvare |
2077 | M: khali@linux-fr.org | 2077 | M: khali@linux-fr.org |
2078 | L: sensors@stimpy.netroedge.com | 2078 | L: lm-sensors@lm-sensors.org |
2079 | S: Odd Fixes | 2079 | S: Odd Fixes |
2080 | 2080 | ||
2081 | SMB FILESYSTEM | 2081 | SMB FILESYSTEM |
@@ -2614,7 +2614,7 @@ S: Orphan | |||
2614 | W1 DALLAS'S 1-WIRE BUS | 2614 | W1 DALLAS'S 1-WIRE BUS |
2615 | P: Evgeniy Polyakov | 2615 | P: Evgeniy Polyakov |
2616 | M: johnpol@2ka.mipt.ru | 2616 | M: johnpol@2ka.mipt.ru |
2617 | L: sensors@stimpy.netroedge.com | 2617 | L: lm-sensors@lm-sensors.org |
2618 | S: Maintained | 2618 | S: Maintained |
2619 | 2619 | ||
2620 | W83L51xD SD/MMC CARD INTERFACE DRIVER | 2620 | W83L51xD SD/MMC CARD INTERFACE DRIVER |
@@ -2627,7 +2627,7 @@ S: Maintained | |||
2627 | W83L785TS HARDWARE MONITOR DRIVER | 2627 | W83L785TS HARDWARE MONITOR DRIVER |
2628 | P: Jean Delvare | 2628 | P: Jean Delvare |
2629 | M: khali@linux-fr.org | 2629 | M: khali@linux-fr.org |
2630 | L: sensors@stimpy.netroedge.com | 2630 | L: lm-sensors@lm-sensors.org |
2631 | S: Odd Fixes | 2631 | S: Odd Fixes |
2632 | 2632 | ||
2633 | WAN ROUTER & SANGOMA WANPIPE DRIVERS & API (X.25, FRAME RELAY, PPP, CISCO HDLC) | 2633 | WAN ROUTER & SANGOMA WANPIPE DRIVERS & API (X.25, FRAME RELAY, PPP, CISCO HDLC) |
diff --git a/arch/ppc/platforms/83xx/mpc834x_sys.c b/arch/ppc/platforms/83xx/mpc834x_sys.c index 86ca5cf81263..37ece1542799 100644 --- a/arch/ppc/platforms/83xx/mpc834x_sys.c +++ b/arch/ppc/platforms/83xx/mpc834x_sys.c | |||
@@ -185,6 +185,26 @@ mpc834x_sys_init_IRQ(void) | |||
185 | ipic_set_default_priority(); | 185 | ipic_set_default_priority(); |
186 | } | 186 | } |
187 | 187 | ||
188 | #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374) | ||
189 | extern ulong ds1374_get_rtc_time(void); | ||
190 | extern int ds1374_set_rtc_time(ulong); | ||
191 | |||
192 | static int __init | ||
193 | mpc834x_rtc_hookup(void) | ||
194 | { | ||
195 | struct timespec tv; | ||
196 | |||
197 | ppc_md.get_rtc_time = ds1374_get_rtc_time; | ||
198 | ppc_md.set_rtc_time = ds1374_set_rtc_time; | ||
199 | |||
200 | tv.tv_nsec = 0; | ||
201 | tv.tv_sec = (ppc_md.get_rtc_time)(); | ||
202 | do_settimeofday(&tv); | ||
203 | |||
204 | return 0; | ||
205 | } | ||
206 | late_initcall(mpc834x_rtc_hookup); | ||
207 | #endif | ||
188 | static __inline__ void | 208 | static __inline__ void |
189 | mpc834x_sys_set_bat(void) | 209 | mpc834x_sys_set_bat(void) |
190 | { | 210 | { |
diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c index ad7ae7ab8920..141b4c237a50 100644 --- a/drivers/acorn/char/pcf8583.c +++ b/drivers/acorn/char/pcf8583.c | |||
@@ -26,11 +26,8 @@ static unsigned short normal_addr[] = { 0x50, I2C_CLIENT_END }; | |||
26 | 26 | ||
27 | static struct i2c_client_address_data addr_data = { | 27 | static struct i2c_client_address_data addr_data = { |
28 | .normal_i2c = normal_addr, | 28 | .normal_i2c = normal_addr, |
29 | .normal_i2c_range = ignore, | ||
30 | .probe = ignore, | 29 | .probe = ignore, |
31 | .probe_range = ignore, | ||
32 | .ignore = ignore, | 30 | .ignore = ignore, |
33 | .ignore_range = ignore, | ||
34 | .force = ignore, | 31 | .force = ignore, |
35 | }; | 32 | }; |
36 | 33 | ||
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index c3d912cbbbc3..cc3a952401f2 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c | |||
@@ -49,7 +49,7 @@ static int i2c_debug=0; | |||
49 | /* | 49 | /* |
50 | * Generate a start condition on the i2c bus. | 50 | * Generate a start condition on the i2c bus. |
51 | * | 51 | * |
52 | * returns after the start condition has occured | 52 | * returns after the start condition has occurred |
53 | */ | 53 | */ |
54 | static void pca_start(struct i2c_algo_pca_data *adap) | 54 | static void pca_start(struct i2c_algo_pca_data *adap) |
55 | { | 55 | { |
@@ -62,9 +62,9 @@ static void pca_start(struct i2c_algo_pca_data *adap) | |||
62 | } | 62 | } |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * Generate a repeated start condition on the i2c bus | 65 | * Generate a repeated start condition on the i2c bus |
66 | * | 66 | * |
67 | * return after the repeated start condition has occured | 67 | * return after the repeated start condition has occurred |
68 | */ | 68 | */ |
69 | static void pca_repeated_start(struct i2c_algo_pca_data *adap) | 69 | static void pca_repeated_start(struct i2c_algo_pca_data *adap) |
70 | { | 70 | { |
@@ -82,7 +82,7 @@ static void pca_repeated_start(struct i2c_algo_pca_data *adap) | |||
82 | * returns after the stop condition has been generated | 82 | * returns after the stop condition has been generated |
83 | * | 83 | * |
84 | * STOPs do not generate an interrupt or set the SI flag, since the | 84 | * STOPs do not generate an interrupt or set the SI flag, since the |
85 | * part returns the the idle state (0xf8). Hence we don't need to | 85 | * part returns the idle state (0xf8). Hence we don't need to |
86 | * pca_wait here. | 86 | * pca_wait here. |
87 | */ | 87 | */ |
88 | static void pca_stop(struct i2c_algo_pca_data *adap) | 88 | static void pca_stop(struct i2c_algo_pca_data *adap) |
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c index 35789bb7126a..f2785499237b 100644 --- a/drivers/i2c/algos/i2c-algo-sibyte.c +++ b/drivers/i2c/algos/i2c-algo-sibyte.c | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | /* Ported for SiByte SOCs by Broadcom Corporation. */ | 25 | /* Ported for SiByte SOCs by Broadcom Corporation. */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index a0018de3bef4..916ba5e40a96 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -7,7 +7,7 @@ menu "I2C Hardware Bus support" | |||
7 | 7 | ||
8 | config I2C_ALI1535 | 8 | config I2C_ALI1535 |
9 | tristate "ALI 1535" | 9 | tristate "ALI 1535" |
10 | depends on I2C && PCI && EXPERIMENTAL | 10 | depends on I2C && PCI |
11 | help | 11 | help |
12 | If you say yes to this option, support will be included for the SMB | 12 | If you say yes to this option, support will be included for the SMB |
13 | Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB | 13 | Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB |
@@ -31,7 +31,7 @@ config I2C_ALI1563 | |||
31 | 31 | ||
32 | config I2C_ALI15X3 | 32 | config I2C_ALI15X3 |
33 | tristate "ALI 15x3" | 33 | tristate "ALI 15x3" |
34 | depends on I2C && PCI && EXPERIMENTAL | 34 | depends on I2C && PCI |
35 | help | 35 | help |
36 | If you say yes to this option, support will be included for the | 36 | If you say yes to this option, support will be included for the |
37 | Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces. | 37 | Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces. |
@@ -41,7 +41,7 @@ config I2C_ALI15X3 | |||
41 | 41 | ||
42 | config I2C_AMD756 | 42 | config I2C_AMD756 |
43 | tristate "AMD 756/766/768/8111 and nVidia nForce" | 43 | tristate "AMD 756/766/768/8111 and nVidia nForce" |
44 | depends on I2C && PCI && EXPERIMENTAL | 44 | depends on I2C && PCI |
45 | help | 45 | help |
46 | If you say yes to this option, support will be included for the AMD | 46 | If you say yes to this option, support will be included for the AMD |
47 | 756/766/768 mainboard I2C interfaces. The driver also includes | 47 | 756/766/768 mainboard I2C interfaces. The driver also includes |
@@ -66,7 +66,7 @@ config I2C_AMD756_S4882 | |||
66 | 66 | ||
67 | config I2C_AMD8111 | 67 | config I2C_AMD8111 |
68 | tristate "AMD 8111" | 68 | tristate "AMD 8111" |
69 | depends on I2C && PCI && EXPERIMENTAL | 69 | depends on I2C && PCI |
70 | help | 70 | help |
71 | If you say yes to this option, support will be included for the | 71 | If you say yes to this option, support will be included for the |
72 | second (SMBus 2.0) AMD 8111 mainboard I2C interface. | 72 | second (SMBus 2.0) AMD 8111 mainboard I2C interface. |
@@ -109,7 +109,7 @@ config I2C_HYDRA | |||
109 | 109 | ||
110 | config I2C_I801 | 110 | config I2C_I801 |
111 | tristate "Intel 82801 (ICH)" | 111 | tristate "Intel 82801 (ICH)" |
112 | depends on I2C && PCI && EXPERIMENTAL | 112 | depends on I2C && PCI |
113 | help | 113 | help |
114 | If you say yes to this option, support will be included for the Intel | 114 | If you say yes to this option, support will be included for the Intel |
115 | 801 family of mainboard I2C interfaces. Specifically, the following | 115 | 801 family of mainboard I2C interfaces. Specifically, the following |
@@ -130,7 +130,7 @@ config I2C_I801 | |||
130 | 130 | ||
131 | config I2C_I810 | 131 | config I2C_I810 |
132 | tristate "Intel 810/815" | 132 | tristate "Intel 810/815" |
133 | depends on I2C && PCI && EXPERIMENTAL | 133 | depends on I2C && PCI |
134 | select I2C_ALGOBIT | 134 | select I2C_ALGOBIT |
135 | help | 135 | help |
136 | If you say yes to this option, support will be included for the Intel | 136 | If you say yes to this option, support will be included for the Intel |
@@ -183,7 +183,7 @@ config I2C_IOP3XX | |||
183 | 183 | ||
184 | config I2C_ISA | 184 | config I2C_ISA |
185 | tristate "ISA Bus support" | 185 | tristate "ISA Bus support" |
186 | depends on I2C && EXPERIMENTAL | 186 | depends on I2C |
187 | help | 187 | help |
188 | If you say yes to this option, support will be included for i2c | 188 | If you say yes to this option, support will be included for i2c |
189 | interfaces that are on the ISA bus. | 189 | interfaces that are on the ISA bus. |
@@ -248,12 +248,11 @@ config I2C_MPC | |||
248 | will be called i2c-mpc. | 248 | will be called i2c-mpc. |
249 | 249 | ||
250 | config I2C_NFORCE2 | 250 | config I2C_NFORCE2 |
251 | tristate "Nvidia Nforce2" | 251 | tristate "Nvidia nForce2, nForce3 and nForce4" |
252 | depends on I2C && PCI && EXPERIMENTAL | 252 | depends on I2C && PCI |
253 | help | 253 | help |
254 | If you say yes to this option, support will be included for the Nvidia | 254 | If you say yes to this option, support will be included for the Nvidia |
255 | Nforce2 family of mainboard I2C interfaces. | 255 | nForce2, nForce3 and nForce4 families of mainboard I2C interfaces. |
256 | This driver also supports the nForce3 Pro 150 MCP. | ||
257 | 256 | ||
258 | This driver can also be built as a module. If so, the module | 257 | This driver can also be built as a module. If so, the module |
259 | will be called i2c-nforce2. | 258 | will be called i2c-nforce2. |
@@ -305,7 +304,7 @@ config I2C_PARPORT_LIGHT | |||
305 | 304 | ||
306 | config I2C_PROSAVAGE | 305 | config I2C_PROSAVAGE |
307 | tristate "S3/VIA (Pro)Savage" | 306 | tristate "S3/VIA (Pro)Savage" |
308 | depends on I2C && PCI && EXPERIMENTAL | 307 | depends on I2C && PCI |
309 | select I2C_ALGOBIT | 308 | select I2C_ALGOBIT |
310 | help | 309 | help |
311 | If you say yes to this option, support will be included for the | 310 | If you say yes to this option, support will be included for the |
@@ -388,7 +387,7 @@ config SCx200_ACB | |||
388 | 387 | ||
389 | config I2C_SIS5595 | 388 | config I2C_SIS5595 |
390 | tristate "SiS 5595" | 389 | tristate "SiS 5595" |
391 | depends on I2C && PCI && EXPERIMENTAL | 390 | depends on I2C && PCI |
392 | help | 391 | help |
393 | If you say yes to this option, support will be included for the | 392 | If you say yes to this option, support will be included for the |
394 | SiS5595 SMBus (a subset of I2C) interface. | 393 | SiS5595 SMBus (a subset of I2C) interface. |
@@ -398,7 +397,7 @@ config I2C_SIS5595 | |||
398 | 397 | ||
399 | config I2C_SIS630 | 398 | config I2C_SIS630 |
400 | tristate "SiS 630/730" | 399 | tristate "SiS 630/730" |
401 | depends on I2C && PCI && EXPERIMENTAL | 400 | depends on I2C && PCI |
402 | help | 401 | help |
403 | If you say yes to this option, support will be included for the | 402 | If you say yes to this option, support will be included for the |
404 | SiS630 and SiS730 SMBus (a subset of I2C) interface. | 403 | SiS630 and SiS730 SMBus (a subset of I2C) interface. |
@@ -408,7 +407,7 @@ config I2C_SIS630 | |||
408 | 407 | ||
409 | config I2C_SIS96X | 408 | config I2C_SIS96X |
410 | tristate "SiS 96x" | 409 | tristate "SiS 96x" |
411 | depends on I2C && PCI && EXPERIMENTAL | 410 | depends on I2C && PCI |
412 | help | 411 | help |
413 | If you say yes to this option, support will be included for the SiS | 412 | If you say yes to this option, support will be included for the SiS |
414 | 96x SMBus (a subset of I2C) interfaces. Specifically, the following | 413 | 96x SMBus (a subset of I2C) interfaces. Specifically, the following |
@@ -419,6 +418,7 @@ config I2C_SIS96X | |||
419 | 648/961 | 418 | 648/961 |
420 | 650/961 | 419 | 650/961 |
421 | 735 | 420 | 735 |
421 | 745 | ||
422 | 422 | ||
423 | This driver can also be built as a module. If so, the module | 423 | This driver can also be built as a module. If so, the module |
424 | will be called i2c-sis96x. | 424 | will be called i2c-sis96x. |
@@ -449,7 +449,7 @@ config I2C_VIA | |||
449 | 449 | ||
450 | config I2C_VIAPRO | 450 | config I2C_VIAPRO |
451 | tristate "VIA 82C596/82C686/823x" | 451 | tristate "VIA 82C596/82C686/823x" |
452 | depends on I2C && PCI && EXPERIMENTAL | 452 | depends on I2C && PCI |
453 | help | 453 | help |
454 | If you say yes to this option, support will be included for the VIA | 454 | If you say yes to this option, support will be included for the VIA |
455 | 82C596/82C686/823x I2C interfaces. Specifically, the following | 455 | 82C596/82C686/823x I2C interfaces. Specifically, the following |
@@ -467,7 +467,7 @@ config I2C_VIAPRO | |||
467 | 467 | ||
468 | config I2C_VOODOO3 | 468 | config I2C_VOODOO3 |
469 | tristate "Voodoo 3" | 469 | tristate "Voodoo 3" |
470 | depends on I2C && PCI && EXPERIMENTAL | 470 | depends on I2C && PCI |
471 | select I2C_ALGOBIT | 471 | select I2C_ALGOBIT |
472 | help | 472 | help |
473 | If you say yes to this option, support will be included for the | 473 | If you say yes to this option, support will be included for the |
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index b00cd4098221..f634a0780cf0 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -53,7 +53,6 @@ | |||
53 | 53 | ||
54 | /* Note: we assume there can only be one ALI1535, with one SMBus interface */ | 54 | /* Note: we assume there can only be one ALI1535, with one SMBus interface */ |
55 | 55 | ||
56 | #include <linux/config.h> | ||
57 | #include <linux/module.h> | 56 | #include <linux/module.h> |
58 | #include <linux/pci.h> | 57 | #include <linux/pci.h> |
59 | #include <linux/kernel.h> | 58 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 5bd6a4a77c1e..0f781a1a3323 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c | |||
@@ -60,7 +60,6 @@ | |||
60 | 60 | ||
61 | /* Note: we assume there can only be one ALI15X3, with one SMBus interface */ | 61 | /* Note: we assume there can only be one ALI15X3, with one SMBus interface */ |
62 | 62 | ||
63 | #include <linux/config.h> | ||
64 | #include <linux/module.h> | 63 | #include <linux/module.h> |
65 | #include <linux/pci.h> | 64 | #include <linux/pci.h> |
66 | #include <linux/kernel.h> | 65 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index eca5ed3738b8..6347ebc6fb53 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c | |||
@@ -37,7 +37,6 @@ | |||
37 | Note: we assume there can only be one device, with one SMBus interface. | 37 | Note: we assume there can only be one device, with one SMBus interface. |
38 | */ | 38 | */ |
39 | 39 | ||
40 | #include <linux/config.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
43 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index af22b401a38b..d6644481d2a0 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * the Free Software Foundation version 2. | 8 | * the Free Software Foundation version 2. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/config.h> | ||
12 | #include <linux/module.h> | 11 | #include <linux/module.h> |
13 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
14 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c index 75831a20b0bd..a7ff112e49bf 100644 --- a/drivers/i2c/busses/i2c-au1550.c +++ b/drivers/i2c/busses/i2c-au1550.c | |||
@@ -27,7 +27,6 @@ | |||
27 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 27 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
32 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
33 | #include <linux/module.h> | 32 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c index 0a7720000a0c..6930b660e508 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c | |||
@@ -25,7 +25,6 @@ | |||
25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of | 25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of |
26 | for Alpha Processor Inc. UP-2000(+) boards */ | 26 | for Alpha Processor Inc. UP-2000(+) boards */ |
27 | 27 | ||
28 | #include <linux/config.h> | ||
29 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
30 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
31 | #include <linux/module.h> | 30 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-frodo.c b/drivers/i2c/busses/i2c-frodo.c index e093829a0bf7..b6f52f5a4138 100644 --- a/drivers/i2c/busses/i2c-frodo.c +++ b/drivers/i2c/busses/i2c-frodo.c | |||
@@ -12,7 +12,6 @@ | |||
12 | * version 2 as published by the Free Software Foundation. | 12 | * version 2 as published by the Free Software Foundation. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/config.h> | ||
16 | #include <linux/module.h> | 15 | #include <linux/module.h> |
17 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
18 | #include <linux/init.h> | 17 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 59c238c42e8c..45e6efb1dcd1 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -41,7 +41,6 @@ | |||
41 | 41 | ||
42 | /* Note: we assume there can only be one I801, with one SMBus interface */ | 42 | /* Note: we assume there can only be one I801, with one SMBus interface */ |
43 | 43 | ||
44 | #include <linux/config.h> | ||
45 | #include <linux/module.h> | 44 | #include <linux/module.h> |
46 | #include <linux/pci.h> | 45 | #include <linux/pci.h> |
47 | #include <linux/kernel.h> | 46 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c index ef358bd9c3da..0ff7016e0629 100644 --- a/drivers/i2c/busses/i2c-i810.c +++ b/drivers/i2c/busses/i2c-i810.c | |||
@@ -34,7 +34,6 @@ | |||
34 | i815 1132 | 34 | i815 1132 |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include <linux/config.h> | ||
38 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
39 | #include <linux/module.h> | 38 | #include <linux/module.h> |
40 | #include <linux/init.h> | 39 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index bb885215c08d..93ca36dc777e 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
@@ -695,7 +695,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ | |||
695 | 695 | ||
696 | dev->irq = iic_force_poll ? -1 : ocp->def->irq; | 696 | dev->irq = iic_force_poll ? -1 : ocp->def->irq; |
697 | if (dev->irq >= 0){ | 697 | if (dev->irq >= 0){ |
698 | /* Disable interrupts until we finish intialization, | 698 | /* Disable interrupts until we finish initialization, |
699 | assumes level-sensitive IRQ setup... | 699 | assumes level-sensitive IRQ setup... |
700 | */ | 700 | */ |
701 | iic_interrupt_mode(dev, 0); | 701 | iic_interrupt_mode(dev, 0); |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.h b/drivers/i2c/busses/i2c-ibm_iic.h index d819a955d890..2b3219d00e92 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.h +++ b/drivers/i2c/busses/i2c-ibm_iic.h | |||
@@ -22,7 +22,6 @@ | |||
22 | #ifndef __I2C_IBM_IIC_H_ | 22 | #ifndef __I2C_IBM_IIC_H_ |
23 | #define __I2C_IBM_IIC_H_ | 23 | #define __I2C_IBM_IIC_H_ |
24 | 24 | ||
25 | #include <linux/config.h> | ||
26 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
27 | 26 | ||
28 | struct iic_regs { | 27 | struct iic_regs { |
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index c961ba4cfb32..6b682e903f09 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c | |||
@@ -85,7 +85,7 @@ iop3xx_i2c_enable(struct i2c_algo_iop3xx_data *iop3xx_adap) | |||
85 | u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE; | 85 | u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE; |
86 | 86 | ||
87 | /* | 87 | /* |
88 | * Everytime unit enable is asserted, GPOD needs to be cleared | 88 | * Every time unit enable is asserted, GPOD needs to be cleared |
89 | * on IOP321 to avoid data corruption on the bus. | 89 | * on IOP321 to avoid data corruption on the bus. |
90 | */ | 90 | */ |
91 | #ifdef CONFIG_ARCH_IOP321 | 91 | #ifdef CONFIG_ARCH_IOP321 |
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 0f54a2a0afa5..00e7f7157b75 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -24,7 +24,6 @@ | |||
24 | the SMBus and the ISA bus very much easier. See lm78.c for an example | 24 | the SMBus and the ISA bus very much easier. See lm78.c for an example |
25 | of this. */ | 25 | of this. */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c index 702e3def1b81..5f5d2944808b 100644 --- a/drivers/i2c/busses/i2c-ite.c +++ b/drivers/i2c/busses/i2c-ite.c | |||
@@ -33,7 +33,6 @@ | |||
33 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even | 33 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even |
34 | Frodo Looijaard <frodol@dds.nl> */ | 34 | Frodo Looijaard <frodol@dds.nl> */ |
35 | 35 | ||
36 | #include <linux/config.h> | ||
37 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
38 | #include <linux/ioport.h> | 37 | #include <linux/ioport.h> |
39 | #include <linux/module.h> | 38 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c index 21cd54d02302..ec943cad2314 100644 --- a/drivers/i2c/busses/i2c-ixp2000.c +++ b/drivers/i2c/busses/i2c-ixp2000.c | |||
@@ -26,11 +26,6 @@ | |||
26 | * 'enabled' to drive the GPIOs. | 26 | * 'enabled' to drive the GPIOs. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #ifdef CONFIG_I2C_DEBUG_BUS | ||
31 | #define DEBUG 1 | ||
32 | #endif | ||
33 | |||
34 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
35 | #include <linux/init.h> | 30 | #include <linux/init.h> |
36 | #include <linux/device.h> | 31 | #include <linux/device.h> |
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index 8c55eafc3a09..f6f5ca31fdba 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -26,11 +26,6 @@ | |||
26 | * that is passed as the platform_data to this driver. | 26 | * that is passed as the platform_data to this driver. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #ifdef CONFIG_I2C_DEBUG_BUS | ||
31 | #define DEBUG 1 | ||
32 | #endif | ||
33 | |||
34 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
35 | #include <linux/init.h> | 30 | #include <linux/init.h> |
36 | #include <linux/device.h> | 31 | #include <linux/device.h> |
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index 867d443e7133..363e545fc01f 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c | |||
@@ -46,7 +46,6 @@ | |||
46 | sound driver to be happy | 46 | sound driver to be happy |
47 | */ | 47 | */ |
48 | 48 | ||
49 | #include <linux/config.h> | ||
50 | #include <linux/module.h> | 49 | #include <linux/module.h> |
51 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
52 | #include <linux/ioport.h> | 51 | #include <linux/ioport.h> |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 6f33496d31c3..d41ca31dbcb2 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -325,7 +325,7 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
325 | if (i2c->irq != OCP_IRQ_NA) | 325 | if (i2c->irq != OCP_IRQ_NA) |
326 | { | 326 | { |
327 | if ((result = request_irq(ocp->def->irq, mpc_i2c_isr, | 327 | if ((result = request_irq(ocp->def->irq, mpc_i2c_isr, |
328 | 0, "i2c-mpc", i2c)) < 0) { | 328 | SA_SHIRQ, "i2c-mpc", i2c)) < 0) { |
329 | printk(KERN_ERR | 329 | printk(KERN_ERR |
330 | "i2c-mpc - failed to attach interrupt\n"); | 330 | "i2c-mpc - failed to attach interrupt\n"); |
331 | goto fail_irq; | 331 | goto fail_irq; |
@@ -333,6 +333,9 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
333 | } else | 333 | } else |
334 | i2c->irq = 0; | 334 | i2c->irq = 0; |
335 | 335 | ||
336 | mpc_i2c_setclock(i2c); | ||
337 | ocp_set_drvdata(ocp, i2c); | ||
338 | |||
336 | i2c->adap = mpc_ops; | 339 | i2c->adap = mpc_ops; |
337 | i2c_set_adapdata(&i2c->adap, i2c); | 340 | i2c_set_adapdata(&i2c->adap, i2c); |
338 | 341 | ||
@@ -341,8 +344,6 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
341 | goto fail_add; | 344 | goto fail_add; |
342 | } | 345 | } |
343 | 346 | ||
344 | mpc_i2c_setclock(i2c); | ||
345 | ocp_set_drvdata(ocp, i2c); | ||
346 | return result; | 347 | return result; |
347 | 348 | ||
348 | fail_add: | 349 | fail_add: |
@@ -358,8 +359,8 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
358 | static void __devexit mpc_i2c_remove(struct ocp_device *ocp) | 359 | static void __devexit mpc_i2c_remove(struct ocp_device *ocp) |
359 | { | 360 | { |
360 | struct mpc_i2c *i2c = ocp_get_drvdata(ocp); | 361 | struct mpc_i2c *i2c = ocp_get_drvdata(ocp); |
361 | ocp_set_drvdata(ocp, NULL); | ||
362 | i2c_del_adapter(&i2c->adap); | 362 | i2c_del_adapter(&i2c->adap); |
363 | ocp_set_drvdata(ocp, NULL); | ||
363 | 364 | ||
364 | if (ocp->def->irq != OCP_IRQ_NA) | 365 | if (ocp->def->irq != OCP_IRQ_NA) |
365 | free_irq(i2c->irq, i2c); | 366 | free_irq(i2c->irq, i2c); |
@@ -424,12 +425,15 @@ static int fsl_i2c_probe(struct device *device) | |||
424 | 425 | ||
425 | if (i2c->irq != 0) | 426 | if (i2c->irq != 0) |
426 | if ((result = request_irq(i2c->irq, mpc_i2c_isr, | 427 | if ((result = request_irq(i2c->irq, mpc_i2c_isr, |
427 | 0, "fsl-i2c", i2c)) < 0) { | 428 | SA_SHIRQ, "i2c-mpc", i2c)) < 0) { |
428 | printk(KERN_ERR | 429 | printk(KERN_ERR |
429 | "i2c-mpc - failed to attach interrupt\n"); | 430 | "i2c-mpc - failed to attach interrupt\n"); |
430 | goto fail_irq; | 431 | goto fail_irq; |
431 | } | 432 | } |
432 | 433 | ||
434 | mpc_i2c_setclock(i2c); | ||
435 | dev_set_drvdata(device, i2c); | ||
436 | |||
433 | i2c->adap = mpc_ops; | 437 | i2c->adap = mpc_ops; |
434 | i2c_set_adapdata(&i2c->adap, i2c); | 438 | i2c_set_adapdata(&i2c->adap, i2c); |
435 | i2c->adap.dev.parent = &pdev->dev; | 439 | i2c->adap.dev.parent = &pdev->dev; |
@@ -438,8 +442,6 @@ static int fsl_i2c_probe(struct device *device) | |||
438 | goto fail_add; | 442 | goto fail_add; |
439 | } | 443 | } |
440 | 444 | ||
441 | mpc_i2c_setclock(i2c); | ||
442 | dev_set_drvdata(device, i2c); | ||
443 | return result; | 445 | return result; |
444 | 446 | ||
445 | fail_add: | 447 | fail_add: |
@@ -456,8 +458,8 @@ static int fsl_i2c_remove(struct device *device) | |||
456 | { | 458 | { |
457 | struct mpc_i2c *i2c = dev_get_drvdata(device); | 459 | struct mpc_i2c *i2c = dev_get_drvdata(device); |
458 | 460 | ||
459 | dev_set_drvdata(device, NULL); | ||
460 | i2c_del_adapter(&i2c->adap); | 461 | i2c_del_adapter(&i2c->adap); |
462 | dev_set_drvdata(device, NULL); | ||
461 | 463 | ||
462 | if (i2c->irq != 0) | 464 | if (i2c->irq != 0) |
463 | free_irq(i2c->irq, i2c); | 465 | free_irq(i2c->irq, i2c); |
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 6d13127c8c4e..74eb89aa9350 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -37,7 +37,6 @@ | |||
37 | 37 | ||
38 | /* Note: we assume there can only be one nForce2, with two SMBus interfaces */ | 38 | /* Note: we assume there can only be one nForce2, with two SMBus interfaces */ |
39 | 39 | ||
40 | #include <linux/config.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
43 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c index cb5e722301d8..3e5eba9fcacb 100644 --- a/drivers/i2c/busses/i2c-parport-light.c +++ b/drivers/i2c/busses/i2c-parport-light.c | |||
@@ -24,7 +24,6 @@ | |||
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | * ------------------------------------------------------------------------ */ | 25 | * ------------------------------------------------------------------------ */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index e9560bab51c4..71a2502fe069 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -24,7 +24,6 @@ | |||
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | * ------------------------------------------------------------------------ */ | 25 | * ------------------------------------------------------------------------ */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
@@ -131,7 +130,7 @@ static int parport_getsda(void *data) | |||
131 | /* Encapsulate the functions above in the correct structure. | 130 | /* Encapsulate the functions above in the correct structure. |
132 | Note that this is only a template, from which the real structures are | 131 | Note that this is only a template, from which the real structures are |
133 | copied. The attaching code will set getscl to NULL for adapters that | 132 | copied. The attaching code will set getscl to NULL for adapters that |
134 | cannot read SCL back, and will also make the the data field point to | 133 | cannot read SCL back, and will also make the data field point to |
135 | the parallel port structure. */ | 134 | the parallel port structure. */ |
136 | static struct i2c_algo_bit_data parport_algo_data = { | 135 | static struct i2c_algo_bit_data parport_algo_data = { |
137 | .setsda = parport_setsda, | 136 | .setsda = parport_setsda, |
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c index 9c611134db9c..d9b4ddbad7e0 100644 --- a/drivers/i2c/busses/i2c-pca-isa.c +++ b/drivers/i2c/busses/i2c-pca-isa.c | |||
@@ -17,7 +17,6 @@ | |||
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/config.h> | ||
21 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
22 | #include <linux/ioport.h> | 21 | #include <linux/ioport.h> |
23 | #include <linux/module.h> | 22 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 646381b6b3bf..1f80ba9da6f1 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -28,7 +28,6 @@ | |||
28 | Note: we assume there can only be one device, with one SMBus interface. | 28 | Note: we assume there can only be one device, with one SMBus interface. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/config.h> | ||
32 | #include <linux/module.h> | 31 | #include <linux/module.h> |
33 | #include <linux/moduleparam.h> | 32 | #include <linux/moduleparam.h> |
34 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c index 13d66289933b..83fd16d61ce5 100644 --- a/drivers/i2c/busses/i2c-prosavage.c +++ b/drivers/i2c/busses/i2c-prosavage.c | |||
@@ -54,7 +54,6 @@ | |||
54 | * (Additional documentation needed :( | 54 | * (Additional documentation needed :( |
55 | */ | 55 | */ |
56 | 56 | ||
57 | #include <linux/config.h> | ||
58 | #include <linux/module.h> | 57 | #include <linux/module.h> |
59 | #include <linux/init.h> | 58 | #include <linux/init.h> |
60 | #include <linux/pci.h> | 59 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-rpx.c b/drivers/i2c/busses/i2c-rpx.c index 9497b1b6852f..0ebec3c1a54e 100644 --- a/drivers/i2c/busses/i2c-rpx.c +++ b/drivers/i2c/busses/i2c-rpx.c | |||
@@ -11,7 +11,6 @@ | |||
11 | * changed to eliminate RPXLite references. | 11 | * changed to eliminate RPXLite references. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/config.h> | ||
15 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
16 | #include <linux/module.h> | 15 | #include <linux/module.h> |
17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index fcfa51c1436b..a3b38257cc3d 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -20,6 +20,7 @@ | |||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/config.h> | ||
23 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | 26 | ||
@@ -533,7 +534,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int | |||
533 | /* s3c24xx_i2c_xfer | 534 | /* s3c24xx_i2c_xfer |
534 | * | 535 | * |
535 | * first port of call from the i2c bus code when an message needs | 536 | * first port of call from the i2c bus code when an message needs |
536 | * transfering across the i2c bus. | 537 | * transferring across the i2c bus. |
537 | */ | 538 | */ |
538 | 539 | ||
539 | static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, | 540 | static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, |
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c index 092d0323c6c6..0c8518298e4d 100644 --- a/drivers/i2c/busses/i2c-savage4.c +++ b/drivers/i2c/busses/i2c-savage4.c | |||
@@ -29,7 +29,6 @@ | |||
29 | it easier to add later. | 29 | it easier to add later. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <linux/config.h> | ||
33 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/init.h> | 34 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c index e5dd90bdb04a..1c99536b673b 100644 --- a/drivers/i2c/busses/i2c-sibyte.c +++ b/drivers/i2c/busses/i2c-sibyte.c | |||
@@ -17,7 +17,6 @@ | |||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/config.h> | ||
21 | #include <linux/module.h> | 20 | #include <linux/module.h> |
22 | #include <linux/i2c-algo-sibyte.h> | 21 | #include <linux/i2c-algo-sibyte.h> |
23 | #include <asm/sibyte/sb1250_regs.h> | 22 | #include <asm/sibyte/sb1250_regs.h> |
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 425733b019b6..2b5911cfb7b5 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c | |||
@@ -55,7 +55,6 @@ | |||
55 | * Add adapter resets | 55 | * Add adapter resets |
56 | */ | 56 | */ |
57 | 57 | ||
58 | #include <linux/config.h> | ||
59 | #include <linux/kernel.h> | 58 | #include <linux/kernel.h> |
60 | #include <linux/module.h> | 59 | #include <linux/module.h> |
61 | #include <linux/delay.h> | 60 | #include <linux/delay.h> |
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index 58df63df1540..f58455e7689e 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -48,7 +48,6 @@ | |||
48 | Note: we assume there can only be one device, with one SMBus interface. | 48 | Note: we assume there can only be one device, with one SMBus interface. |
49 | */ | 49 | */ |
50 | 50 | ||
51 | #include <linux/config.h> | ||
52 | #include <linux/kernel.h> | 51 | #include <linux/kernel.h> |
53 | #include <linux/module.h> | 52 | #include <linux/module.h> |
54 | #include <linux/delay.h> | 53 | #include <linux/delay.h> |
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index 3cac6d43bce5..6484792e23a1 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c | |||
@@ -32,7 +32,6 @@ | |||
32 | We assume there can only be one SiS96x with one SMBus interface. | 32 | We assume there can only be one SiS96x with one SMBus interface. |
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/config.h> | ||
36 | #include <linux/module.h> | 35 | #include <linux/module.h> |
37 | #include <linux/pci.h> | 36 | #include <linux/pci.h> |
38 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c index 19c805ead4d8..00d94e886955 100644 --- a/drivers/i2c/busses/i2c-stub.c +++ b/drivers/i2c/busses/i2c-stub.c | |||
@@ -21,7 +21,6 @@ | |||
21 | 21 | ||
22 | #define DEBUG 1 | 22 | #define DEBUG 1 |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/init.h> | 24 | #include <linux/init.h> |
26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
27 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c index 2cbc4cd22366..040b8abeabba 100644 --- a/drivers/i2c/busses/i2c-via.c +++ b/drivers/i2c/busses/i2c-via.c | |||
@@ -21,7 +21,6 @@ | |||
21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
27 | #include <linux/pci.h> | 26 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 0bb60a636e16..6b5008005c6f 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -33,7 +33,6 @@ | |||
33 | Note: we assume there can only be one device, with one SMBus interface. | 33 | Note: we assume there can only be one device, with one SMBus interface. |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <linux/config.h> | ||
37 | #include <linux/module.h> | 36 | #include <linux/module.h> |
38 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
39 | #include <linux/pci.h> | 38 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c index 3edf0e34155e..b675773b0cc1 100644 --- a/drivers/i2c/busses/i2c-voodoo3.c +++ b/drivers/i2c/busses/i2c-voodoo3.c | |||
@@ -27,7 +27,6 @@ | |||
27 | /* This interfaces to the I2C bus of the Voodoo3 to gain access to | 27 | /* This interfaces to the I2C bus of the Voodoo3 to gain access to |
28 | the BT869 and possibly other I2C devices. */ | 28 | the BT869 and possibly other I2C devices. */ |
29 | 29 | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
32 | #include <linux/module.h> | 31 | #include <linux/module.h> |
33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 1c4159a93623..a18bdd9aa7ba 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/module.h> | 27 | #include <linux/module.h> |
29 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
30 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 74d23cfce2a3..a0982da09803 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig | |||
@@ -1,5 +1,5 @@ | |||
1 | # | 1 | # |
2 | # I2C Sensor device configuration | 2 | # I2C Sensor and "other" chip configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Hardware Sensors Chip support" | 5 | menu "Hardware Sensors Chip support" |
@@ -11,7 +11,7 @@ config I2C_SENSOR | |||
11 | 11 | ||
12 | config SENSORS_ADM1021 | 12 | config SENSORS_ADM1021 |
13 | tristate "Analog Devices ADM1021 and compatibles" | 13 | tristate "Analog Devices ADM1021 and compatibles" |
14 | depends on I2C && EXPERIMENTAL | 14 | depends on I2C |
15 | select I2C_SENSOR | 15 | select I2C_SENSOR |
16 | help | 16 | help |
17 | If you say yes here you get support for Analog Devices ADM1021 | 17 | If you say yes here you get support for Analog Devices ADM1021 |
@@ -29,6 +29,7 @@ config SENSORS_ADM1025 | |||
29 | help | 29 | help |
30 | If you say yes here you get support for Analog Devices ADM1025 | 30 | If you say yes here you get support for Analog Devices ADM1025 |
31 | and Philips NE1619 sensor chips. | 31 | and Philips NE1619 sensor chips. |
32 | |||
32 | This driver can also be built as a module. If so, the module | 33 | This driver can also be built as a module. If so, the module |
33 | will be called adm1025. | 34 | will be called adm1025. |
34 | 35 | ||
@@ -38,6 +39,8 @@ config SENSORS_ADM1026 | |||
38 | select I2C_SENSOR | 39 | select I2C_SENSOR |
39 | help | 40 | help |
40 | If you say yes here you get support for Analog Devices ADM1026 | 41 | If you say yes here you get support for Analog Devices ADM1026 |
42 | sensor chip. | ||
43 | |||
41 | This driver can also be built as a module. If so, the module | 44 | This driver can also be built as a module. If so, the module |
42 | will be called adm1026. | 45 | will be called adm1026. |
43 | 46 | ||
@@ -48,9 +51,21 @@ config SENSORS_ADM1031 | |||
48 | help | 51 | help |
49 | If you say yes here you get support for Analog Devices ADM1031 | 52 | If you say yes here you get support for Analog Devices ADM1031 |
50 | and ADM1030 sensor chips. | 53 | and ADM1030 sensor chips. |
54 | |||
51 | This driver can also be built as a module. If so, the module | 55 | This driver can also be built as a module. If so, the module |
52 | will be called adm1031. | 56 | will be called adm1031. |
53 | 57 | ||
58 | config SENSORS_ADM9240 | ||
59 | tristate "Analog Devices ADM9240 and compatibles" | ||
60 | depends on I2C && EXPERIMENTAL | ||
61 | select I2C_SENSOR | ||
62 | help | ||
63 | If you say yes here you get support for Analog Devices ADM9240, | ||
64 | Dallas DS1780, National Semiconductor LM81 sensor chips. | ||
65 | |||
66 | This driver can also be built as a module. If so, the module | ||
67 | will be called adm9240. | ||
68 | |||
54 | config SENSORS_ASB100 | 69 | config SENSORS_ASB100 |
55 | tristate "Asus ASB100 Bach" | 70 | tristate "Asus ASB100 Bach" |
56 | depends on I2C && EXPERIMENTAL | 71 | depends on I2C && EXPERIMENTAL |
@@ -62,6 +77,19 @@ config SENSORS_ASB100 | |||
62 | This driver can also be built as a module. If so, the module | 77 | This driver can also be built as a module. If so, the module |
63 | will be called asb100. | 78 | will be called asb100. |
64 | 79 | ||
80 | config SENSORS_ATXP1 | ||
81 | tristate "Attansic ATXP1 VID controller" | ||
82 | depends on I2C && EXPERIMENTAL | ||
83 | help | ||
84 | If you say yes here you get support for the Attansic ATXP1 VID | ||
85 | controller. | ||
86 | |||
87 | If your board have such a chip, you are able to control your CPU | ||
88 | core and other voltages. | ||
89 | |||
90 | This driver can also be built as a module. If so, the module | ||
91 | will be called atxp1. | ||
92 | |||
65 | config SENSORS_DS1621 | 93 | config SENSORS_DS1621 |
66 | tristate "Dallas Semiconductor DS1621 and DS1625" | 94 | tristate "Dallas Semiconductor DS1621 and DS1625" |
67 | depends on I2C && EXPERIMENTAL | 95 | depends on I2C && EXPERIMENTAL |
@@ -97,7 +125,7 @@ config SENSORS_FSCPOS | |||
97 | 125 | ||
98 | config SENSORS_GL518SM | 126 | config SENSORS_GL518SM |
99 | tristate "Genesys Logic GL518SM" | 127 | tristate "Genesys Logic GL518SM" |
100 | depends on I2C && EXPERIMENTAL | 128 | depends on I2C |
101 | select I2C_SENSOR | 129 | select I2C_SENSOR |
102 | help | 130 | help |
103 | If you say yes here you get support for Genesys Logic GL518SM | 131 | If you say yes here you get support for Genesys Logic GL518SM |
@@ -119,7 +147,7 @@ config SENSORS_GL520SM | |||
119 | 147 | ||
120 | config SENSORS_IT87 | 148 | config SENSORS_IT87 |
121 | tristate "ITE IT87xx and compatibles" | 149 | tristate "ITE IT87xx and compatibles" |
122 | depends on I2C && EXPERIMENTAL | 150 | depends on I2C |
123 | select I2C_SENSOR | 151 | select I2C_SENSOR |
124 | help | 152 | help |
125 | If you say yes here you get support for ITE IT87xx sensor chips | 153 | If you say yes here you get support for ITE IT87xx sensor chips |
@@ -143,7 +171,7 @@ config SENSORS_LM63 | |||
143 | 171 | ||
144 | config SENSORS_LM75 | 172 | config SENSORS_LM75 |
145 | tristate "National Semiconductor LM75 and compatibles" | 173 | tristate "National Semiconductor LM75 and compatibles" |
146 | depends on I2C && EXPERIMENTAL | 174 | depends on I2C |
147 | select I2C_SENSOR | 175 | select I2C_SENSOR |
148 | help | 176 | help |
149 | If you say yes here you get support for National Semiconductor LM75 | 177 | If you say yes here you get support for National Semiconductor LM75 |
@@ -174,8 +202,7 @@ config SENSORS_LM78 | |||
174 | select I2C_SENSOR | 202 | select I2C_SENSOR |
175 | help | 203 | help |
176 | If you say yes here you get support for National Semiconductor LM78, | 204 | If you say yes here you get support for National Semiconductor LM78, |
177 | LM78-J and LM79. This can also be built as a module which can be | 205 | LM78-J and LM79. |
178 | inserted and removed while the kernel is running. | ||
179 | 206 | ||
180 | This driver can also be built as a module. If so, the module | 207 | This driver can also be built as a module. If so, the module |
181 | will be called lm78. | 208 | will be called lm78. |
@@ -208,7 +235,7 @@ config SENSORS_LM85 | |||
208 | select I2C_SENSOR | 235 | select I2C_SENSOR |
209 | help | 236 | help |
210 | If you say yes here you get support for National Semiconductor LM85 | 237 | If you say yes here you get support for National Semiconductor LM85 |
211 | sensor chips and clones: ADT7463 and ADM1027. | 238 | sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027. |
212 | 239 | ||
213 | This driver can also be built as a module. If so, the module | 240 | This driver can also be built as a module. If so, the module |
214 | will be called lm85. | 241 | will be called lm85. |
@@ -307,14 +334,14 @@ config SENSORS_SMSC47M1 | |||
307 | help | 334 | help |
308 | If you say yes here you get support for the integrated fan | 335 | If you say yes here you get support for the integrated fan |
309 | monitoring and control capabilities of the SMSC LPC47B27x, | 336 | monitoring and control capabilities of the SMSC LPC47B27x, |
310 | LPC47M10x, LPC47M13x and LPC47M14x chips. | 337 | LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 chips. |
311 | 338 | ||
312 | This driver can also be built as a module. If so, the module | 339 | This driver can also be built as a module. If so, the module |
313 | will be called smsc47m1. | 340 | will be called smsc47m1. |
314 | 341 | ||
315 | config SENSORS_VIA686A | 342 | config SENSORS_VIA686A |
316 | tristate "VIA686A" | 343 | tristate "VIA686A" |
317 | depends on I2C && PCI && EXPERIMENTAL | 344 | depends on I2C && PCI |
318 | select I2C_SENSOR | 345 | select I2C_SENSOR |
319 | select I2C_ISA | 346 | select I2C_ISA |
320 | help | 347 | help |
@@ -326,7 +353,7 @@ config SENSORS_VIA686A | |||
326 | 353 | ||
327 | config SENSORS_W83781D | 354 | config SENSORS_W83781D |
328 | tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" | 355 | tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" |
329 | depends on I2C && EXPERIMENTAL | 356 | depends on I2C |
330 | select I2C_SENSOR | 357 | select I2C_SENSOR |
331 | help | 358 | help |
332 | If you say yes here you get support for the Winbond W8378x series | 359 | If you say yes here you get support for the Winbond W8378x series |
@@ -360,22 +387,47 @@ config SENSORS_W83627HF | |||
360 | This driver can also be built as a module. If so, the module | 387 | This driver can also be built as a module. If so, the module |
361 | will be called w83627hf. | 388 | will be called w83627hf. |
362 | 389 | ||
390 | config SENSORS_W83627EHF | ||
391 | tristate "Winbond W83627EHF" | ||
392 | depends on I2C && EXPERIMENTAL | ||
393 | select I2C_SENSOR | ||
394 | select I2C_ISA | ||
395 | help | ||
396 | If you say yes here you get preliminary support for the hardware | ||
397 | monitoring functionality of the Winbond W83627EHF Super-I/O chip. | ||
398 | Only fan and temperature inputs are supported at the moment, while | ||
399 | the chip does much more than that. | ||
400 | |||
401 | This driver can also be built as a module. If so, the module | ||
402 | will be called w83627ehf. | ||
403 | |||
363 | endmenu | 404 | endmenu |
364 | 405 | ||
365 | menu "Other I2C Chip support" | 406 | menu "Other I2C Chip support" |
366 | depends on I2C | 407 | depends on I2C |
367 | 408 | ||
368 | config SENSORS_DS1337 | 409 | config SENSORS_DS1337 |
369 | tristate "Dallas Semiconductor DS1337 Real Time Clock" | 410 | tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock" |
370 | depends on I2C && EXPERIMENTAL | 411 | depends on I2C && EXPERIMENTAL |
371 | select I2C_SENSOR | 412 | select I2C_SENSOR |
372 | help | 413 | help |
373 | If you say yes here you get support for Dallas Semiconductor | 414 | If you say yes here you get support for Dallas Semiconductor |
374 | DS1337 real-time clock chips. | 415 | DS1337 and DS1339 real-time clock chips. |
375 | 416 | ||
376 | This driver can also be built as a module. If so, the module | 417 | This driver can also be built as a module. If so, the module |
377 | will be called ds1337. | 418 | will be called ds1337. |
378 | 419 | ||
420 | config SENSORS_DS1374 | ||
421 | tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock" | ||
422 | depends on I2C && EXPERIMENTAL | ||
423 | select I2C_SENSOR | ||
424 | help | ||
425 | If you say yes here you get support for Dallas Semiconductor | ||
426 | DS1374 real-time clock chips. | ||
427 | |||
428 | This driver can also be built as a module. If so, the module | ||
429 | will be called ds1374. | ||
430 | |||
379 | config SENSORS_EEPROM | 431 | config SENSORS_EEPROM |
380 | tristate "EEPROM reader" | 432 | tristate "EEPROM reader" |
381 | depends on I2C && EXPERIMENTAL | 433 | depends on I2C && EXPERIMENTAL |
@@ -399,6 +451,16 @@ config SENSORS_PCF8574 | |||
399 | This driver can also be built as a module. If so, the module | 451 | This driver can also be built as a module. If so, the module |
400 | will be called pcf8574. | 452 | will be called pcf8574. |
401 | 453 | ||
454 | config SENSORS_PCA9539 | ||
455 | tristate "Philips PCA9539 16-bit I/O port" | ||
456 | depends on I2C && EXPERIMENTAL | ||
457 | help | ||
458 | If you say yes here you get support for the Philips PCA9539 | ||
459 | 16-bit I/O port. | ||
460 | |||
461 | This driver can also be built as a module. If so, the module | ||
462 | will be called pca9539. | ||
463 | |||
402 | config SENSORS_PCF8591 | 464 | config SENSORS_PCF8591 |
403 | tristate "Philips PCF8591" | 465 | tristate "Philips PCF8591" |
404 | depends on I2C && EXPERIMENTAL | 466 | depends on I2C && EXPERIMENTAL |
@@ -431,6 +493,23 @@ config ISP1301_OMAP | |||
431 | This driver can also be built as a module. If so, the module | 493 | This driver can also be built as a module. If so, the module |
432 | will be called isp1301_omap. | 494 | will be called isp1301_omap. |
433 | 495 | ||
496 | # NOTE: This isn't really OMAP-specific, except for the current | ||
497 | # interface location in <include/asm-arm/arch-omap/tps65010.h> | ||
498 | # and having mostly OMAP-specific board support | ||
499 | config TPS65010 | ||
500 | tristate "TPS6501x Power Management chips" | ||
501 | depends on I2C && ARCH_OMAP | ||
502 | default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK | ||
503 | help | ||
504 | If you say yes here you get support for the TPS6501x series of | ||
505 | Power Management chips. These include voltage regulators, | ||
506 | lithium ion/polymer battery charging, and other features that | ||
507 | are often used in portable devices like cell phones and cameras. | ||
508 | |||
509 | This driver can also be built as a module. If so, the module | ||
510 | will be called tps65010. | ||
511 | |||
512 | |||
434 | config SENSORS_M41T00 | 513 | config SENSORS_M41T00 |
435 | tristate "ST M41T00 RTC chip" | 514 | tristate "ST M41T00 RTC chip" |
436 | depends on I2C && PPC32 | 515 | depends on I2C && PPC32 |
@@ -440,4 +519,16 @@ config SENSORS_M41T00 | |||
440 | This driver can also be built as a module. If so, the module | 519 | This driver can also be built as a module. If so, the module |
441 | will be called m41t00. | 520 | will be called m41t00. |
442 | 521 | ||
522 | config SENSORS_MAX6875 | ||
523 | tristate "MAXIM MAX6875 Power supply supervisor" | ||
524 | depends on I2C && EXPERIMENTAL | ||
525 | help | ||
526 | If you say yes here you get support for the MAX6875 | ||
527 | EEPROM-Programmable, Hex/Quad, Power-Suppy Sequencers/Supervisors. | ||
528 | |||
529 | This provides a interface to program the EEPROM and reset the chip. | ||
530 | |||
531 | This driver can also be built as a module. If so, the module | ||
532 | will be called max6875. | ||
533 | |||
443 | endmenu | 534 | endmenu |
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index 65599161a172..b5e6d2f84f97 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | # | 1 | # |
2 | # Makefile for the kernel hardware sensors chip drivers. | 2 | # Makefile for sensor and "other" I2C chip drivers. |
3 | # | 3 | # |
4 | 4 | ||
5 | # asb100, then w83781d go first, as they can override other drivers' addresses. | 5 | # asb100, then w83781d go first, as they can override other drivers' addresses. |
@@ -11,7 +11,10 @@ obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o | |||
11 | obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o | 11 | obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o |
12 | obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o | 12 | obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o |
13 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o | 13 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o |
14 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o | ||
15 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o | ||
14 | obj-$(CONFIG_SENSORS_DS1337) += ds1337.o | 16 | obj-$(CONFIG_SENSORS_DS1337) += ds1337.o |
17 | obj-$(CONFIG_SENSORS_DS1374) += ds1374.o | ||
15 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o | 18 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o |
16 | obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o | 19 | obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o |
17 | obj-$(CONFIG_SENSORS_FSCHER) += fscher.o | 20 | obj-$(CONFIG_SENSORS_FSCHER) += fscher.o |
@@ -30,8 +33,10 @@ obj-$(CONFIG_SENSORS_LM87) += lm87.o | |||
30 | obj-$(CONFIG_SENSORS_LM90) += lm90.o | 33 | obj-$(CONFIG_SENSORS_LM90) += lm90.o |
31 | obj-$(CONFIG_SENSORS_LM92) += lm92.o | 34 | obj-$(CONFIG_SENSORS_LM92) += lm92.o |
32 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o | 35 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o |
36 | obj-$(CONFIG_SENSORS_MAX6875) += max6875.o | ||
33 | obj-$(CONFIG_SENSORS_M41T00) += m41t00.o | 37 | obj-$(CONFIG_SENSORS_M41T00) += m41t00.o |
34 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o | 38 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o |
39 | obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o | ||
35 | obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o | 40 | obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o |
36 | obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o | 41 | obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o |
37 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o | 42 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o |
@@ -39,8 +44,11 @@ obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o | |||
39 | obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o | 44 | obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o |
40 | obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o | 45 | obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o |
41 | obj-$(CONFIG_SENSORS_VIA686A) += via686a.o | 46 | obj-$(CONFIG_SENSORS_VIA686A) += via686a.o |
47 | obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o | ||
42 | obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o | 48 | obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o |
49 | |||
43 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o | 50 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o |
51 | obj-$(CONFIG_TPS65010) += tps65010.o | ||
44 | 52 | ||
45 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) | 53 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) |
46 | EXTRA_CFLAGS += -DDEBUG | 54 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c index 9058c3956710..d2c774c32f45 100644 --- a/drivers/i2c/chips/adm1021.c +++ b/drivers/i2c/chips/adm1021.c | |||
@@ -19,7 +19,6 @@ | |||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/config.h> | ||
23 | #include <linux/module.h> | 22 | #include <linux/module.h> |
24 | #include <linux/init.h> | 23 | #include <linux/init.h> |
25 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
@@ -103,8 +102,6 @@ struct adm1021_data { | |||
103 | u8 remote_temp_hyst; | 102 | u8 remote_temp_hyst; |
104 | u8 remote_temp_input; | 103 | u8 remote_temp_input; |
105 | u8 alarms; | 104 | u8 alarms; |
106 | /* special values for ADM1021 only */ | ||
107 | u8 die_code; | ||
108 | /* Special values for ADM1023 only */ | 105 | /* Special values for ADM1023 only */ |
109 | u8 remote_temp_prec; | 106 | u8 remote_temp_prec; |
110 | u8 remote_temp_os_prec; | 107 | u8 remote_temp_os_prec; |
@@ -156,7 +153,6 @@ static ssize_t show_##value(struct device *dev, struct device_attribute *attr, c | |||
156 | return sprintf(buf, "%d\n", data->value); \ | 153 | return sprintf(buf, "%d\n", data->value); \ |
157 | } | 154 | } |
158 | show2(alarms); | 155 | show2(alarms); |
159 | show2(die_code); | ||
160 | 156 | ||
161 | #define set(value, reg) \ | 157 | #define set(value, reg) \ |
162 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ | 158 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
@@ -183,7 +179,6 @@ static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_remote_temp_max, set_remot | |||
183 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst); | 179 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst); |
184 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL); | 180 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL); |
185 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 181 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
186 | static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL); | ||
187 | 182 | ||
188 | 183 | ||
189 | static int adm1021_attach_adapter(struct i2c_adapter *adapter) | 184 | static int adm1021_attach_adapter(struct i2c_adapter *adapter) |
@@ -307,8 +302,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | |||
307 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 302 | device_create_file(&new_client->dev, &dev_attr_temp2_min); |
308 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 303 | device_create_file(&new_client->dev, &dev_attr_temp2_input); |
309 | device_create_file(&new_client->dev, &dev_attr_alarms); | 304 | device_create_file(&new_client->dev, &dev_attr_alarms); |
310 | if (data->type == adm1021) | ||
311 | device_create_file(&new_client->dev, &dev_attr_die_code); | ||
312 | 305 | ||
313 | return 0; | 306 | return 0; |
314 | 307 | ||
@@ -371,8 +364,6 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
371 | data->remote_temp_max = adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R); | 364 | data->remote_temp_max = adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R); |
372 | data->remote_temp_hyst = adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R); | 365 | data->remote_temp_hyst = adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R); |
373 | data->alarms = adm1021_read_value(client, ADM1021_REG_STATUS) & 0x7c; | 366 | data->alarms = adm1021_read_value(client, ADM1021_REG_STATUS) & 0x7c; |
374 | if (data->type == adm1021) | ||
375 | data->die_code = adm1021_read_value(client, ADM1021_REG_DIE_CODE); | ||
376 | if (data->type == adm1023) { | 367 | if (data->type == adm1023) { |
377 | data->remote_temp_prec = adm1021_read_value(client, ADM1021_REG_REM_TEMP_PREC); | 368 | data->remote_temp_prec = adm1021_read_value(client, ADM1021_REG_REM_TEMP_PREC); |
378 | data->remote_temp_os_prec = adm1021_read_value(client, ADM1021_REG_REM_TOS_PREC); | 369 | data->remote_temp_os_prec = adm1021_read_value(client, ADM1021_REG_REM_TOS_PREC); |
diff --git a/drivers/i2c/chips/adm1025.c b/drivers/i2c/chips/adm1025.c index 111f0c86c933..e452d0daf906 100644 --- a/drivers/i2c/chips/adm1025.c +++ b/drivers/i2c/chips/adm1025.c | |||
@@ -45,7 +45,6 @@ | |||
45 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 45 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
46 | */ | 46 | */ |
47 | 47 | ||
48 | #include <linux/config.h> | ||
49 | #include <linux/module.h> | 48 | #include <linux/module.h> |
50 | #include <linux/init.h> | 49 | #include <linux/init.h> |
51 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
@@ -287,7 +286,9 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char | |||
287 | struct adm1025_data *data = adm1025_update_device(dev); | 286 | struct adm1025_data *data = adm1025_update_device(dev); |
288 | return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); | 287 | return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); |
289 | } | 288 | } |
289 | /* in1_ref is deprecated in favour of cpu0_vid, remove after 2005-11-11 */ | ||
290 | static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); | 290 | static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); |
291 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | ||
291 | 292 | ||
292 | static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) | 293 | static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) |
293 | { | 294 | { |
@@ -437,7 +438,9 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
437 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 438 | device_create_file(&new_client->dev, &dev_attr_temp1_max); |
438 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 439 | device_create_file(&new_client->dev, &dev_attr_temp2_max); |
439 | device_create_file(&new_client->dev, &dev_attr_alarms); | 440 | device_create_file(&new_client->dev, &dev_attr_alarms); |
441 | /* in1_ref is deprecated, remove after 2005-11-11 */ | ||
440 | device_create_file(&new_client->dev, &dev_attr_in1_ref); | 442 | device_create_file(&new_client->dev, &dev_attr_in1_ref); |
443 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
441 | device_create_file(&new_client->dev, &dev_attr_vrm); | 444 | device_create_file(&new_client->dev, &dev_attr_vrm); |
442 | 445 | ||
443 | /* Pin 11 is either in4 (+12V) or VID4 */ | 446 | /* Pin 11 is either in4 (+12V) or VID4 */ |
diff --git a/drivers/i2c/chips/adm1026.c b/drivers/i2c/chips/adm1026.c index b15fafe8f111..3c85fe150cd7 100644 --- a/drivers/i2c/chips/adm1026.c +++ b/drivers/i2c/chips/adm1026.c | |||
@@ -23,15 +23,14 @@ | |||
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/config.h> | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
30 | #include <linux/jiffies.h> | 29 | #include <linux/jiffies.h> |
31 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
32 | #include <linux/i2c-sensor.h> | 31 | #include <linux/i2c-sensor.h> |
33 | #include <linux/i2c-sysfs.h> | ||
34 | #include <linux/i2c-vid.h> | 32 | #include <linux/i2c-vid.h> |
33 | #include <linux/hwmon-sysfs.h> | ||
35 | 34 | ||
36 | /* Addresses to scan */ | 35 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 36 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
@@ -1225,8 +1224,9 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, c | |||
1225 | struct adm1026_data *data = adm1026_update_device(dev); | 1224 | struct adm1026_data *data = adm1026_update_device(dev); |
1226 | return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); | 1225 | return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); |
1227 | } | 1226 | } |
1228 | 1227 | /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ | |
1229 | static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); | 1228 | static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); |
1229 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); | ||
1230 | 1230 | ||
1231 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1231 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1232 | { | 1232 | { |
@@ -1666,7 +1666,9 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1666 | device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); | 1666 | device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); |
1667 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); | 1667 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); |
1668 | device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); | 1668 | device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); |
1669 | /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ | ||
1669 | device_create_file(&new_client->dev, &dev_attr_vid); | 1670 | device_create_file(&new_client->dev, &dev_attr_vid); |
1671 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
1670 | device_create_file(&new_client->dev, &dev_attr_vrm); | 1672 | device_create_file(&new_client->dev, &dev_attr_vrm); |
1671 | device_create_file(&new_client->dev, &dev_attr_alarms); | 1673 | device_create_file(&new_client->dev, &dev_attr_alarms); |
1672 | device_create_file(&new_client->dev, &dev_attr_alarm_mask); | 1674 | device_create_file(&new_client->dev, &dev_attr_alarm_mask); |
diff --git a/drivers/i2c/chips/adm1031.c b/drivers/i2c/chips/adm1031.c index 2163dba467c4..9168e983ca1d 100644 --- a/drivers/i2c/chips/adm1031.c +++ b/drivers/i2c/chips/adm1031.c | |||
@@ -440,7 +440,7 @@ pwm_reg(2); | |||
440 | 440 | ||
441 | /* | 441 | /* |
442 | * That function checks the cases where the fan reading is not | 442 | * That function checks the cases where the fan reading is not |
443 | * relevent. It is used to provide 0 as fan reading when the fan is | 443 | * relevant. It is used to provide 0 as fan reading when the fan is |
444 | * not supposed to run | 444 | * not supposed to run |
445 | */ | 445 | */ |
446 | static int trust_fan_readings(struct adm1031_data *data, int chan) | 446 | static int trust_fan_readings(struct adm1031_data *data, int chan) |
diff --git a/drivers/i2c/chips/adm9240.c b/drivers/i2c/chips/adm9240.c new file mode 100644 index 000000000000..5c68e9c311aa --- /dev/null +++ b/drivers/i2c/chips/adm9240.c | |||
@@ -0,0 +1,791 @@ | |||
1 | /* | ||
2 | * adm9240.c Part of lm_sensors, Linux kernel modules for hardware | ||
3 | * monitoring | ||
4 | * | ||
5 | * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl> | ||
6 | * Philip Edelbrock <phil@netroedge.com> | ||
7 | * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl> | ||
8 | * Copyright (C) 2005 Grant Coady <gcoady@gmail.com> with valuable | ||
9 | * guidance from Jean Delvare | ||
10 | * | ||
11 | * Driver supports Analog Devices ADM9240 | ||
12 | * Dallas Semiconductor DS1780 | ||
13 | * National Semiconductor LM81 | ||
14 | * | ||
15 | * ADM9240 is the reference, DS1780 and LM81 are register compatibles | ||
16 | * | ||
17 | * Voltage Six inputs are scaled by chip, VID also reported | ||
18 | * Temperature Chip temperature to 0.5'C, maximum and max_hysteris | ||
19 | * Fans 2 fans, low speed alarm, automatic fan clock divider | ||
20 | * Alarms 16-bit map of active alarms | ||
21 | * Analog Out 0..1250 mV output | ||
22 | * | ||
23 | * Chassis Intrusion: clear CI latch with 'echo 1 > chassis_clear' | ||
24 | * | ||
25 | * Test hardware: Intel SE440BX-2 desktop motherboard --Grant | ||
26 | * | ||
27 | * LM81 extended temp reading not implemented | ||
28 | * | ||
29 | * This program is free software; you can redistribute it and/or modify | ||
30 | * it under the terms of the GNU General Public License as published by | ||
31 | * the Free Software Foundation; either version 2 of the License, or | ||
32 | * (at your option) any later version. | ||
33 | * | ||
34 | * This program is distributed in the hope that it will be useful, | ||
35 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
36 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
37 | * GNU General Public License for more details. | ||
38 | * | ||
39 | * You should have received a copy of the GNU General Public License | ||
40 | * along with this program; if not, write to the Free Software | ||
41 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
42 | */ | ||
43 | |||
44 | #include <linux/init.h> | ||
45 | #include <linux/module.h> | ||
46 | #include <linux/slab.h> | ||
47 | #include <linux/i2c.h> | ||
48 | #include <linux/i2c-sensor.h> | ||
49 | #include <linux/i2c-vid.h> | ||
50 | |||
51 | /* Addresses to scan */ | ||
52 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, | ||
53 | I2C_CLIENT_END }; | ||
54 | |||
55 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
56 | |||
57 | /* Insmod parameters */ | ||
58 | SENSORS_INSMOD_3(adm9240, ds1780, lm81); | ||
59 | |||
60 | /* ADM9240 registers */ | ||
61 | #define ADM9240_REG_MAN_ID 0x3e | ||
62 | #define ADM9240_REG_DIE_REV 0x3f | ||
63 | #define ADM9240_REG_CONFIG 0x40 | ||
64 | |||
65 | #define ADM9240_REG_IN(nr) (0x20 + (nr)) /* 0..5 */ | ||
66 | #define ADM9240_REG_IN_MAX(nr) (0x2b + (nr) * 2) | ||
67 | #define ADM9240_REG_IN_MIN(nr) (0x2c + (nr) * 2) | ||
68 | #define ADM9240_REG_FAN(nr) (0x28 + (nr)) /* 0..1 */ | ||
69 | #define ADM9240_REG_FAN_MIN(nr) (0x3b + (nr)) | ||
70 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) | ||
71 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) | ||
72 | #define ADM9240_REG_TEMP 0x27 | ||
73 | #define ADM9240_REG_TEMP_HIGH 0x39 | ||
74 | #define ADM9240_REG_TEMP_HYST 0x3a | ||
75 | #define ADM9240_REG_ANALOG_OUT 0x19 | ||
76 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 | ||
77 | #define ADM9240_REG_VID_FAN_DIV 0x47 | ||
78 | #define ADM9240_REG_I2C_ADDR 0x48 | ||
79 | #define ADM9240_REG_VID4 0x49 | ||
80 | #define ADM9240_REG_TEMP_CONF 0x4b | ||
81 | |||
82 | /* generalised scaling with integer rounding */ | ||
83 | static inline int SCALE(long val, int mul, int div) | ||
84 | { | ||
85 | if (val < 0) | ||
86 | return (val * mul - div / 2) / div; | ||
87 | else | ||
88 | return (val * mul + div / 2) / div; | ||
89 | } | ||
90 | |||
91 | /* adm9240 internally scales voltage measurements */ | ||
92 | static const u16 nom_mv[] = { 2500, 2700, 3300, 5000, 12000, 2700 }; | ||
93 | |||
94 | static inline unsigned int IN_FROM_REG(u8 reg, int n) | ||
95 | { | ||
96 | return SCALE(reg, nom_mv[n], 192); | ||
97 | } | ||
98 | |||
99 | static inline u8 IN_TO_REG(unsigned long val, int n) | ||
100 | { | ||
101 | return SENSORS_LIMIT(SCALE(val, 192, nom_mv[n]), 0, 255); | ||
102 | } | ||
103 | |||
104 | /* temperature range: -40..125, 127 disables temperature alarm */ | ||
105 | static inline s8 TEMP_TO_REG(long val) | ||
106 | { | ||
107 | return SENSORS_LIMIT(SCALE(val, 1, 1000), -40, 127); | ||
108 | } | ||
109 | |||
110 | /* two fans, each with low fan speed limit */ | ||
111 | static inline unsigned int FAN_FROM_REG(u8 reg, u8 div) | ||
112 | { | ||
113 | if (!reg) /* error */ | ||
114 | return -1; | ||
115 | |||
116 | if (reg == 255) | ||
117 | return 0; | ||
118 | |||
119 | return SCALE(1350000, 1, reg * div); | ||
120 | } | ||
121 | |||
122 | /* analog out 0..1250mV */ | ||
123 | static inline u8 AOUT_TO_REG(unsigned long val) | ||
124 | { | ||
125 | return SENSORS_LIMIT(SCALE(val, 255, 1250), 0, 255); | ||
126 | } | ||
127 | |||
128 | static inline unsigned int AOUT_FROM_REG(u8 reg) | ||
129 | { | ||
130 | return SCALE(reg, 1250, 255); | ||
131 | } | ||
132 | |||
133 | static int adm9240_attach_adapter(struct i2c_adapter *adapter); | ||
134 | static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind); | ||
135 | static void adm9240_init_client(struct i2c_client *client); | ||
136 | static int adm9240_detach_client(struct i2c_client *client); | ||
137 | static struct adm9240_data *adm9240_update_device(struct device *dev); | ||
138 | |||
139 | /* driver data */ | ||
140 | static struct i2c_driver adm9240_driver = { | ||
141 | .owner = THIS_MODULE, | ||
142 | .name = "adm9240", | ||
143 | .id = I2C_DRIVERID_ADM9240, | ||
144 | .flags = I2C_DF_NOTIFY, | ||
145 | .attach_adapter = adm9240_attach_adapter, | ||
146 | .detach_client = adm9240_detach_client, | ||
147 | }; | ||
148 | |||
149 | /* per client data */ | ||
150 | struct adm9240_data { | ||
151 | enum chips type; | ||
152 | struct i2c_client client; | ||
153 | struct semaphore update_lock; | ||
154 | char valid; | ||
155 | unsigned long last_updated_measure; | ||
156 | unsigned long last_updated_config; | ||
157 | |||
158 | u8 in[6]; /* ro in0_input */ | ||
159 | u8 in_max[6]; /* rw in0_max */ | ||
160 | u8 in_min[6]; /* rw in0_min */ | ||
161 | u8 fan[2]; /* ro fan1_input */ | ||
162 | u8 fan_min[2]; /* rw fan1_min */ | ||
163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ | ||
164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ | ||
165 | s8 temp_high; /* rw temp1_max */ | ||
166 | s8 temp_hyst; /* rw temp1_max_hyst */ | ||
167 | u16 alarms; /* ro alarms */ | ||
168 | u8 aout; /* rw aout_output */ | ||
169 | u8 vid; /* ro vid */ | ||
170 | u8 vrm; /* -- vrm set on startup, no accessor */ | ||
171 | }; | ||
172 | |||
173 | /* i2c byte read/write interface */ | ||
174 | static int adm9240_read_value(struct i2c_client *client, u8 reg) | ||
175 | { | ||
176 | return i2c_smbus_read_byte_data(client, reg); | ||
177 | } | ||
178 | |||
179 | static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value) | ||
180 | { | ||
181 | return i2c_smbus_write_byte_data(client, reg, value); | ||
182 | } | ||
183 | |||
184 | /*** sysfs accessors ***/ | ||
185 | |||
186 | /* temperature */ | ||
187 | #define show_temp(value, scale) \ | ||
188 | static ssize_t show_##value(struct device *dev, \ | ||
189 | struct device_attribute *attr, \ | ||
190 | char *buf) \ | ||
191 | { \ | ||
192 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
193 | return sprintf(buf, "%d\n", data->value * scale); \ | ||
194 | } | ||
195 | show_temp(temp_high, 1000); | ||
196 | show_temp(temp_hyst, 1000); | ||
197 | show_temp(temp, 500); /* 0.5'C per bit */ | ||
198 | |||
199 | #define set_temp(value, reg) \ | ||
200 | static ssize_t set_##value(struct device *dev, \ | ||
201 | struct device_attribute *attr, \ | ||
202 | const char *buf, size_t count) \ | ||
203 | { \ | ||
204 | struct i2c_client *client = to_i2c_client(dev); \ | ||
205 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
206 | long temp = simple_strtoul(buf, NULL, 10); \ | ||
207 | \ | ||
208 | down(&data->update_lock); \ | ||
209 | data->value = TEMP_TO_REG(temp); \ | ||
210 | adm9240_write_value(client, reg, data->value); \ | ||
211 | up(&data->update_lock); \ | ||
212 | return count; \ | ||
213 | } | ||
214 | |||
215 | set_temp(temp_high, ADM9240_REG_TEMP_HIGH); | ||
216 | set_temp(temp_hyst, ADM9240_REG_TEMP_HYST); | ||
217 | |||
218 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
219 | show_temp_high, set_temp_high); | ||
220 | static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
221 | show_temp_hyst, set_temp_hyst); | ||
222 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); | ||
223 | |||
224 | /* voltage */ | ||
225 | static ssize_t show_in(struct device *dev, char *buf, int nr) | ||
226 | { | ||
227 | struct adm9240_data *data = adm9240_update_device(dev); | ||
228 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr)); | ||
229 | } | ||
230 | |||
231 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | ||
232 | { | ||
233 | struct adm9240_data *data = adm9240_update_device(dev); | ||
234 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr)); | ||
235 | } | ||
236 | |||
237 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | ||
238 | { | ||
239 | struct adm9240_data *data = adm9240_update_device(dev); | ||
240 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr)); | ||
241 | } | ||
242 | |||
243 | static ssize_t set_in_min(struct device *dev, const char *buf, | ||
244 | size_t count, int nr) | ||
245 | { | ||
246 | struct i2c_client *client = to_i2c_client(dev); | ||
247 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
248 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
249 | |||
250 | down(&data->update_lock); | ||
251 | data->in_min[nr] = IN_TO_REG(val, nr); | ||
252 | adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]); | ||
253 | up(&data->update_lock); | ||
254 | return count; | ||
255 | } | ||
256 | |||
257 | static ssize_t set_in_max(struct device *dev, const char *buf, | ||
258 | size_t count, int nr) | ||
259 | { | ||
260 | struct i2c_client *client = to_i2c_client(dev); | ||
261 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
262 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
263 | |||
264 | down(&data->update_lock); | ||
265 | data->in_max[nr] = IN_TO_REG(val, nr); | ||
266 | adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]); | ||
267 | up(&data->update_lock); | ||
268 | return count; | ||
269 | } | ||
270 | |||
271 | #define show_in_offset(offset) \ | ||
272 | static ssize_t show_in##offset(struct device *dev, \ | ||
273 | struct device_attribute *attr, \ | ||
274 | char *buf) \ | ||
275 | { \ | ||
276 | return show_in(dev, buf, offset); \ | ||
277 | } \ | ||
278 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ | ||
279 | static ssize_t show_in##offset##_min(struct device *dev, \ | ||
280 | struct device_attribute *attr, \ | ||
281 | char *buf) \ | ||
282 | { \ | ||
283 | return show_in_min(dev, buf, offset); \ | ||
284 | } \ | ||
285 | static ssize_t show_in##offset##_max(struct device *dev, \ | ||
286 | struct device_attribute *attr, \ | ||
287 | char *buf) \ | ||
288 | { \ | ||
289 | return show_in_max(dev, buf, offset); \ | ||
290 | } \ | ||
291 | static ssize_t \ | ||
292 | set_in##offset##_min(struct device *dev, \ | ||
293 | struct device_attribute *attr, const char *buf, \ | ||
294 | size_t count) \ | ||
295 | { \ | ||
296 | return set_in_min(dev, buf, count, offset); \ | ||
297 | } \ | ||
298 | static ssize_t \ | ||
299 | set_in##offset##_max(struct device *dev, \ | ||
300 | struct device_attribute *attr, const char *buf, \ | ||
301 | size_t count) \ | ||
302 | { \ | ||
303 | return set_in_max(dev, buf, count, offset); \ | ||
304 | } \ | ||
305 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
306 | show_in##offset##_min, set_in##offset##_min); \ | ||
307 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
308 | show_in##offset##_max, set_in##offset##_max); | ||
309 | |||
310 | show_in_offset(0); | ||
311 | show_in_offset(1); | ||
312 | show_in_offset(2); | ||
313 | show_in_offset(3); | ||
314 | show_in_offset(4); | ||
315 | show_in_offset(5); | ||
316 | |||
317 | /* fans */ | ||
318 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | ||
319 | { | ||
320 | struct adm9240_data *data = adm9240_update_device(dev); | ||
321 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], | ||
322 | 1 << data->fan_div[nr])); | ||
323 | } | ||
324 | |||
325 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | ||
326 | { | ||
327 | struct adm9240_data *data = adm9240_update_device(dev); | ||
328 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], | ||
329 | 1 << data->fan_div[nr])); | ||
330 | } | ||
331 | |||
332 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | ||
333 | { | ||
334 | struct adm9240_data *data = adm9240_update_device(dev); | ||
335 | return sprintf(buf, "%d\n", 1 << data->fan_div[nr]); | ||
336 | } | ||
337 | |||
338 | /* write new fan div, callers must hold data->update_lock */ | ||
339 | static void adm9240_write_fan_div(struct i2c_client *client, int nr, | ||
340 | u8 fan_div) | ||
341 | { | ||
342 | u8 reg, old, shift = (nr + 2) * 2; | ||
343 | |||
344 | reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | ||
345 | old = (reg >> shift) & 3; | ||
346 | reg &= ~(3 << shift); | ||
347 | reg |= (fan_div << shift); | ||
348 | adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg); | ||
349 | dev_dbg(&client->dev, "fan%d clock divider changed from %u " | ||
350 | "to %u\n", nr + 1, 1 << old, 1 << fan_div); | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | * set fan speed low limit: | ||
355 | * | ||
356 | * - value is zero: disable fan speed low limit alarm | ||
357 | * | ||
358 | * - value is below fan speed measurement range: enable fan speed low | ||
359 | * limit alarm to be asserted while fan speed too slow to measure | ||
360 | * | ||
361 | * - otherwise: select fan clock divider to suit fan speed low limit, | ||
362 | * measurement code may adjust registers to ensure fan speed reading | ||
363 | */ | ||
364 | static ssize_t set_fan_min(struct device *dev, const char *buf, | ||
365 | size_t count, int nr) | ||
366 | { | ||
367 | struct i2c_client *client = to_i2c_client(dev); | ||
368 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
369 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
370 | u8 new_div; | ||
371 | |||
372 | down(&data->update_lock); | ||
373 | |||
374 | if (!val) { | ||
375 | data->fan_min[nr] = 255; | ||
376 | new_div = data->fan_div[nr]; | ||
377 | |||
378 | dev_dbg(&client->dev, "fan%u low limit set disabled\n", | ||
379 | nr + 1); | ||
380 | |||
381 | } else if (val < 1350000 / (8 * 254)) { | ||
382 | new_div = 3; | ||
383 | data->fan_min[nr] = 254; | ||
384 | |||
385 | dev_dbg(&client->dev, "fan%u low limit set minimum %u\n", | ||
386 | nr + 1, FAN_FROM_REG(254, 1 << new_div)); | ||
387 | |||
388 | } else { | ||
389 | unsigned int new_min = 1350000 / val; | ||
390 | |||
391 | new_div = 0; | ||
392 | while (new_min > 192 && new_div < 3) { | ||
393 | new_div++; | ||
394 | new_min /= 2; | ||
395 | } | ||
396 | if (!new_min) /* keep > 0 */ | ||
397 | new_min++; | ||
398 | |||
399 | data->fan_min[nr] = new_min; | ||
400 | |||
401 | dev_dbg(&client->dev, "fan%u low limit set fan speed %u\n", | ||
402 | nr + 1, FAN_FROM_REG(new_min, 1 << new_div)); | ||
403 | } | ||
404 | |||
405 | if (new_div != data->fan_div[nr]) { | ||
406 | data->fan_div[nr] = new_div; | ||
407 | adm9240_write_fan_div(client, nr, new_div); | ||
408 | } | ||
409 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr), | ||
410 | data->fan_min[nr]); | ||
411 | |||
412 | up(&data->update_lock); | ||
413 | return count; | ||
414 | } | ||
415 | |||
416 | #define show_fan_offset(offset) \ | ||
417 | static ssize_t show_fan_##offset (struct device *dev, \ | ||
418 | struct device_attribute *attr, \ | ||
419 | char *buf) \ | ||
420 | { \ | ||
421 | return show_fan(dev, buf, offset - 1); \ | ||
422 | } \ | ||
423 | static ssize_t show_fan_##offset##_div (struct device *dev, \ | ||
424 | struct device_attribute *attr, \ | ||
425 | char *buf) \ | ||
426 | { \ | ||
427 | return show_fan_div(dev, buf, offset - 1); \ | ||
428 | } \ | ||
429 | static ssize_t show_fan_##offset##_min (struct device *dev, \ | ||
430 | struct device_attribute *attr, \ | ||
431 | char *buf) \ | ||
432 | { \ | ||
433 | return show_fan_min(dev, buf, offset - 1); \ | ||
434 | } \ | ||
435 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | ||
436 | struct device_attribute *attr, \ | ||
437 | const char *buf, size_t count) \ | ||
438 | { \ | ||
439 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
440 | } \ | ||
441 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
442 | show_fan_##offset, NULL); \ | ||
443 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | ||
444 | show_fan_##offset##_div, NULL); \ | ||
445 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
446 | show_fan_##offset##_min, set_fan_##offset##_min); | ||
447 | |||
448 | show_fan_offset(1); | ||
449 | show_fan_offset(2); | ||
450 | |||
451 | /* alarms */ | ||
452 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | ||
453 | { | ||
454 | struct adm9240_data *data = adm9240_update_device(dev); | ||
455 | return sprintf(buf, "%u\n", data->alarms); | ||
456 | } | ||
457 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | ||
458 | |||
459 | /* vid */ | ||
460 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | ||
461 | { | ||
462 | struct adm9240_data *data = adm9240_update_device(dev); | ||
463 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); | ||
464 | } | ||
465 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | ||
466 | |||
467 | /* analog output */ | ||
468 | static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf) | ||
469 | { | ||
470 | struct adm9240_data *data = adm9240_update_device(dev); | ||
471 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); | ||
472 | } | ||
473 | |||
474 | static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
475 | { | ||
476 | struct i2c_client *client = to_i2c_client(dev); | ||
477 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
478 | unsigned long val = simple_strtol(buf, NULL, 10); | ||
479 | |||
480 | down(&data->update_lock); | ||
481 | data->aout = AOUT_TO_REG(val); | ||
482 | adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout); | ||
483 | up(&data->update_lock); | ||
484 | return count; | ||
485 | } | ||
486 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | ||
487 | |||
488 | /* chassis_clear */ | ||
489 | static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
490 | { | ||
491 | struct i2c_client *client = to_i2c_client(dev); | ||
492 | unsigned long val = simple_strtol(buf, NULL, 10); | ||
493 | |||
494 | if (val == 1) { | ||
495 | adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80); | ||
496 | dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); | ||
497 | } | ||
498 | return count; | ||
499 | } | ||
500 | static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear); | ||
501 | |||
502 | |||
503 | /*** sensor chip detect and driver install ***/ | ||
504 | |||
505 | static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | ||
506 | { | ||
507 | struct i2c_client *new_client; | ||
508 | struct adm9240_data *data; | ||
509 | int err = 0; | ||
510 | const char *name = ""; | ||
511 | u8 man_id, die_rev; | ||
512 | |||
513 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
514 | goto exit; | ||
515 | |||
516 | if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) { | ||
517 | err = -ENOMEM; | ||
518 | goto exit; | ||
519 | } | ||
520 | memset(data, 0, sizeof(struct adm9240_data)); | ||
521 | |||
522 | new_client = &data->client; | ||
523 | i2c_set_clientdata(new_client, data); | ||
524 | new_client->addr = address; | ||
525 | new_client->adapter = adapter; | ||
526 | new_client->driver = &adm9240_driver; | ||
527 | new_client->flags = 0; | ||
528 | |||
529 | if (kind == 0) { | ||
530 | kind = adm9240; | ||
531 | } | ||
532 | |||
533 | if (kind < 0) { | ||
534 | |||
535 | /* verify chip: reg address should match i2c address */ | ||
536 | if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR) | ||
537 | != address) { | ||
538 | dev_err(&adapter->dev, "detect fail: address match, " | ||
539 | "0x%02x\n", address); | ||
540 | goto exit_free; | ||
541 | } | ||
542 | |||
543 | /* check known chip manufacturer */ | ||
544 | man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID); | ||
545 | |||
546 | if (man_id == 0x23) { | ||
547 | kind = adm9240; | ||
548 | } else if (man_id == 0xda) { | ||
549 | kind = ds1780; | ||
550 | } else if (man_id == 0x01) { | ||
551 | kind = lm81; | ||
552 | } else { | ||
553 | dev_err(&adapter->dev, "detect fail: unknown manuf, " | ||
554 | "0x%02x\n", man_id); | ||
555 | goto exit_free; | ||
556 | } | ||
557 | |||
558 | /* successful detect, print chip info */ | ||
559 | die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV); | ||
560 | dev_info(&adapter->dev, "found %s revision %u\n", | ||
561 | man_id == 0x23 ? "ADM9240" : | ||
562 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | ||
563 | } | ||
564 | |||
565 | /* either forced or detected chip kind */ | ||
566 | if (kind == adm9240) { | ||
567 | name = "adm9240"; | ||
568 | } else if (kind == ds1780) { | ||
569 | name = "ds1780"; | ||
570 | } else if (kind == lm81) { | ||
571 | name = "lm81"; | ||
572 | } | ||
573 | |||
574 | /* fill in the remaining client fields and attach */ | ||
575 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | ||
576 | data->type = kind; | ||
577 | init_MUTEX(&data->update_lock); | ||
578 | |||
579 | if ((err = i2c_attach_client(new_client))) | ||
580 | goto exit_free; | ||
581 | |||
582 | adm9240_init_client(new_client); | ||
583 | |||
584 | /* populate sysfs filesystem */ | ||
585 | device_create_file(&new_client->dev, &dev_attr_in0_input); | ||
586 | device_create_file(&new_client->dev, &dev_attr_in0_min); | ||
587 | device_create_file(&new_client->dev, &dev_attr_in0_max); | ||
588 | device_create_file(&new_client->dev, &dev_attr_in1_input); | ||
589 | device_create_file(&new_client->dev, &dev_attr_in1_min); | ||
590 | device_create_file(&new_client->dev, &dev_attr_in1_max); | ||
591 | device_create_file(&new_client->dev, &dev_attr_in2_input); | ||
592 | device_create_file(&new_client->dev, &dev_attr_in2_min); | ||
593 | device_create_file(&new_client->dev, &dev_attr_in2_max); | ||
594 | device_create_file(&new_client->dev, &dev_attr_in3_input); | ||
595 | device_create_file(&new_client->dev, &dev_attr_in3_min); | ||
596 | device_create_file(&new_client->dev, &dev_attr_in3_max); | ||
597 | device_create_file(&new_client->dev, &dev_attr_in4_input); | ||
598 | device_create_file(&new_client->dev, &dev_attr_in4_min); | ||
599 | device_create_file(&new_client->dev, &dev_attr_in4_max); | ||
600 | device_create_file(&new_client->dev, &dev_attr_in5_input); | ||
601 | device_create_file(&new_client->dev, &dev_attr_in5_min); | ||
602 | device_create_file(&new_client->dev, &dev_attr_in5_max); | ||
603 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | ||
604 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | ||
605 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | ||
606 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | ||
607 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | ||
608 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | ||
609 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | ||
610 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | ||
611 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | ||
612 | device_create_file(&new_client->dev, &dev_attr_alarms); | ||
613 | device_create_file(&new_client->dev, &dev_attr_aout_output); | ||
614 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); | ||
615 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
616 | |||
617 | return 0; | ||
618 | exit_free: | ||
619 | kfree(new_client); | ||
620 | exit: | ||
621 | return err; | ||
622 | } | ||
623 | |||
624 | static int adm9240_attach_adapter(struct i2c_adapter *adapter) | ||
625 | { | ||
626 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
627 | return 0; | ||
628 | return i2c_detect(adapter, &addr_data, adm9240_detect); | ||
629 | } | ||
630 | |||
631 | static int adm9240_detach_client(struct i2c_client *client) | ||
632 | { | ||
633 | int err; | ||
634 | |||
635 | if ((err = i2c_detach_client(client))) { | ||
636 | dev_err(&client->dev, "Client deregistration failed, " | ||
637 | "client not detached.\n"); | ||
638 | return err; | ||
639 | } | ||
640 | |||
641 | kfree(i2c_get_clientdata(client)); | ||
642 | return 0; | ||
643 | } | ||
644 | |||
645 | static void adm9240_init_client(struct i2c_client *client) | ||
646 | { | ||
647 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
648 | u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); | ||
649 | u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; | ||
650 | |||
651 | data->vrm = i2c_which_vrm(); /* need this to report vid as mV */ | ||
652 | |||
653 | dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10, | ||
654 | data->vrm % 10); | ||
655 | |||
656 | if (conf & 1) { /* measurement cycle running: report state */ | ||
657 | |||
658 | dev_info(&client->dev, "status: config 0x%02x mode %u\n", | ||
659 | conf, mode); | ||
660 | |||
661 | } else { /* cold start: open limits before starting chip */ | ||
662 | int i; | ||
663 | |||
664 | for (i = 0; i < 6; i++) | ||
665 | { | ||
666 | adm9240_write_value(client, | ||
667 | ADM9240_REG_IN_MIN(i), 0); | ||
668 | adm9240_write_value(client, | ||
669 | ADM9240_REG_IN_MAX(i), 255); | ||
670 | } | ||
671 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255); | ||
672 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255); | ||
673 | adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127); | ||
674 | adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127); | ||
675 | |||
676 | /* start measurement cycle */ | ||
677 | adm9240_write_value(client, ADM9240_REG_CONFIG, 1); | ||
678 | |||
679 | dev_info(&client->dev, "cold start: config was 0x%02x " | ||
680 | "mode %u\n", conf, mode); | ||
681 | } | ||
682 | } | ||
683 | |||
684 | static struct adm9240_data *adm9240_update_device(struct device *dev) | ||
685 | { | ||
686 | struct i2c_client *client = to_i2c_client(dev); | ||
687 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
688 | int i; | ||
689 | |||
690 | down(&data->update_lock); | ||
691 | |||
692 | /* minimum measurement cycle: 1.75 seconds */ | ||
693 | if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) | ||
694 | || !data->valid) { | ||
695 | |||
696 | for (i = 0; i < 6; i++) /* read voltages */ | ||
697 | { | ||
698 | data->in[i] = adm9240_read_value(client, | ||
699 | ADM9240_REG_IN(i)); | ||
700 | } | ||
701 | data->alarms = adm9240_read_value(client, | ||
702 | ADM9240_REG_INT(0)) | | ||
703 | adm9240_read_value(client, | ||
704 | ADM9240_REG_INT(1)) << 8; | ||
705 | |||
706 | /* read temperature: assume temperature changes less than | ||
707 | * 0.5'C per two measurement cycles thus ignore possible | ||
708 | * but unlikely aliasing error on lsb reading. --Grant */ | ||
709 | data->temp = ((adm9240_read_value(client, | ||
710 | ADM9240_REG_TEMP) << 8) | | ||
711 | adm9240_read_value(client, | ||
712 | ADM9240_REG_TEMP_CONF)) / 128; | ||
713 | |||
714 | for (i = 0; i < 2; i++) /* read fans */ | ||
715 | { | ||
716 | data->fan[i] = adm9240_read_value(client, | ||
717 | ADM9240_REG_FAN(i)); | ||
718 | |||
719 | /* adjust fan clock divider on overflow */ | ||
720 | if (data->valid && data->fan[i] == 255 && | ||
721 | data->fan_div[i] < 3) { | ||
722 | |||
723 | adm9240_write_fan_div(client, i, | ||
724 | ++data->fan_div[i]); | ||
725 | |||
726 | /* adjust fan_min if active, but not to 0 */ | ||
727 | if (data->fan_min[i] < 255 && | ||
728 | data->fan_min[i] >= 2) | ||
729 | data->fan_min[i] /= 2; | ||
730 | } | ||
731 | } | ||
732 | data->last_updated_measure = jiffies; | ||
733 | } | ||
734 | |||
735 | /* minimum config reading cycle: 300 seconds */ | ||
736 | if (time_after(jiffies, data->last_updated_config + (HZ * 300)) | ||
737 | || !data->valid) { | ||
738 | |||
739 | for (i = 0; i < 6; i++) | ||
740 | { | ||
741 | data->in_min[i] = adm9240_read_value(client, | ||
742 | ADM9240_REG_IN_MIN(i)); | ||
743 | data->in_max[i] = adm9240_read_value(client, | ||
744 | ADM9240_REG_IN_MAX(i)); | ||
745 | } | ||
746 | for (i = 0; i < 2; i++) | ||
747 | { | ||
748 | data->fan_min[i] = adm9240_read_value(client, | ||
749 | ADM9240_REG_FAN_MIN(i)); | ||
750 | } | ||
751 | data->temp_high = adm9240_read_value(client, | ||
752 | ADM9240_REG_TEMP_HIGH); | ||
753 | data->temp_hyst = adm9240_read_value(client, | ||
754 | ADM9240_REG_TEMP_HYST); | ||
755 | |||
756 | /* read fan divs and 5-bit VID */ | ||
757 | i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | ||
758 | data->fan_div[0] = (i >> 4) & 3; | ||
759 | data->fan_div[1] = (i >> 6) & 3; | ||
760 | data->vid = i & 0x0f; | ||
761 | data->vid |= (adm9240_read_value(client, | ||
762 | ADM9240_REG_VID4) & 1) << 4; | ||
763 | /* read analog out */ | ||
764 | data->aout = adm9240_read_value(client, | ||
765 | ADM9240_REG_ANALOG_OUT); | ||
766 | |||
767 | data->last_updated_config = jiffies; | ||
768 | data->valid = 1; | ||
769 | } | ||
770 | up(&data->update_lock); | ||
771 | return data; | ||
772 | } | ||
773 | |||
774 | static int __init sensors_adm9240_init(void) | ||
775 | { | ||
776 | return i2c_add_driver(&adm9240_driver); | ||
777 | } | ||
778 | |||
779 | static void __exit sensors_adm9240_exit(void) | ||
780 | { | ||
781 | i2c_del_driver(&adm9240_driver); | ||
782 | } | ||
783 | |||
784 | MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, " | ||
785 | "Grant Coady <gcoady@gmail.com> and others"); | ||
786 | MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver"); | ||
787 | MODULE_LICENSE("GPL"); | ||
788 | |||
789 | module_init(sensors_adm9240_init); | ||
790 | module_exit(sensors_adm9240_exit); | ||
791 | |||
diff --git a/drivers/i2c/chips/asb100.c b/drivers/i2c/chips/asb100.c index 4a47b4493e34..70d996d6fe0a 100644 --- a/drivers/i2c/chips/asb100.c +++ b/drivers/i2c/chips/asb100.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/i2c-sensor.h> | 42 | #include <linux/i2c-sensor.h> |
43 | #include <linux/i2c-vid.h> | 43 | #include <linux/i2c-vid.h> |
44 | #include <linux/init.h> | 44 | #include <linux/init.h> |
45 | #include <linux/jiffies.h> | ||
45 | #include "lm75.h" | 46 | #include "lm75.h" |
46 | 47 | ||
47 | /* | 48 | /* |
@@ -168,8 +169,6 @@ static int ASB100_PWM_FROM_REG(u8 reg) | |||
168 | return reg * 16; | 169 | return reg * 16; |
169 | } | 170 | } |
170 | 171 | ||
171 | #define ALARMS_FROM_REG(val) (val) | ||
172 | |||
173 | #define DIV_FROM_REG(val) (1 << (val)) | 172 | #define DIV_FROM_REG(val) (1 << (val)) |
174 | 173 | ||
175 | /* FAN DIV: 1, 2, 4, or 8 (defaults to 2) | 174 | /* FAN DIV: 1, 2, 4, or 8 (defaults to 2) |
@@ -556,7 +555,7 @@ device_create_file(&client->dev, &dev_attr_vrm); | |||
556 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 555 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
557 | { | 556 | { |
558 | struct asb100_data *data = asb100_update_device(dev); | 557 | struct asb100_data *data = asb100_update_device(dev); |
559 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms)); | 558 | return sprintf(buf, "%u\n", data->alarms); |
560 | } | 559 | } |
561 | 560 | ||
562 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 561 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
diff --git a/drivers/i2c/chips/atxp1.c b/drivers/i2c/chips/atxp1.c new file mode 100644 index 000000000000..5c6597aa2c7f --- /dev/null +++ b/drivers/i2c/chips/atxp1.c | |||
@@ -0,0 +1,361 @@ | |||
1 | /* | ||
2 | atxp1.c - kernel module for setting CPU VID and general purpose | ||
3 | I/Os using the Attansic ATXP1 chip. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | |||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/i2c.h> | ||
25 | #include <linux/i2c-sensor.h> | ||
26 | #include <linux/i2c-vid.h> | ||
27 | |||
28 | MODULE_LICENSE("GPL"); | ||
29 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); | ||
30 | MODULE_VERSION("0.6.2"); | ||
31 | MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>"); | ||
32 | |||
33 | #define ATXP1_VID 0x00 | ||
34 | #define ATXP1_CVID 0x01 | ||
35 | #define ATXP1_GPIO1 0x06 | ||
36 | #define ATXP1_GPIO2 0x0a | ||
37 | #define ATXP1_VIDENA 0x20 | ||
38 | #define ATXP1_VIDMASK 0x1f | ||
39 | #define ATXP1_GPIO1MASK 0x0f | ||
40 | |||
41 | static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; | ||
42 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
43 | |||
44 | SENSORS_INSMOD_1(atxp1); | ||
45 | |||
46 | static int atxp1_attach_adapter(struct i2c_adapter * adapter); | ||
47 | static int atxp1_detach_client(struct i2c_client * client); | ||
48 | static struct atxp1_data * atxp1_update_device(struct device *dev); | ||
49 | static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind); | ||
50 | |||
51 | static struct i2c_driver atxp1_driver = { | ||
52 | .owner = THIS_MODULE, | ||
53 | .name = "atxp1", | ||
54 | .flags = I2C_DF_NOTIFY, | ||
55 | .attach_adapter = atxp1_attach_adapter, | ||
56 | .detach_client = atxp1_detach_client, | ||
57 | }; | ||
58 | |||
59 | struct atxp1_data { | ||
60 | struct i2c_client client; | ||
61 | struct semaphore update_lock; | ||
62 | unsigned long last_updated; | ||
63 | u8 valid; | ||
64 | struct { | ||
65 | u8 vid; /* VID output register */ | ||
66 | u8 cpu_vid; /* VID input from CPU */ | ||
67 | u8 gpio1; /* General purpose I/O register 1 */ | ||
68 | u8 gpio2; /* General purpose I/O register 2 */ | ||
69 | } reg; | ||
70 | u8 vrm; /* Detected CPU VRM */ | ||
71 | }; | ||
72 | |||
73 | static struct atxp1_data * atxp1_update_device(struct device *dev) | ||
74 | { | ||
75 | struct i2c_client *client; | ||
76 | struct atxp1_data *data; | ||
77 | |||
78 | client = to_i2c_client(dev); | ||
79 | data = i2c_get_clientdata(client); | ||
80 | |||
81 | down(&data->update_lock); | ||
82 | |||
83 | if ((jiffies - data->last_updated > HZ) || | ||
84 | (jiffies < data->last_updated) || | ||
85 | !data->valid) { | ||
86 | |||
87 | /* Update local register data */ | ||
88 | data->reg.vid = i2c_smbus_read_byte_data(client, ATXP1_VID); | ||
89 | data->reg.cpu_vid = i2c_smbus_read_byte_data(client, ATXP1_CVID); | ||
90 | data->reg.gpio1 = i2c_smbus_read_byte_data(client, ATXP1_GPIO1); | ||
91 | data->reg.gpio2 = i2c_smbus_read_byte_data(client, ATXP1_GPIO2); | ||
92 | |||
93 | data->valid = 1; | ||
94 | } | ||
95 | |||
96 | up(&data->update_lock); | ||
97 | |||
98 | return(data); | ||
99 | } | ||
100 | |||
101 | /* sys file functions for cpu0_vid */ | ||
102 | static ssize_t atxp1_showvcore(struct device *dev, struct device_attribute *attr, char *buf) | ||
103 | { | ||
104 | int size; | ||
105 | struct atxp1_data *data; | ||
106 | |||
107 | data = atxp1_update_device(dev); | ||
108 | |||
109 | size = sprintf(buf, "%d\n", vid_from_reg(data->reg.vid & ATXP1_VIDMASK, data->vrm)); | ||
110 | |||
111 | return size; | ||
112 | } | ||
113 | |||
114 | static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
115 | { | ||
116 | struct atxp1_data *data; | ||
117 | struct i2c_client *client; | ||
118 | char vid; | ||
119 | char cvid; | ||
120 | unsigned int vcore; | ||
121 | |||
122 | client = to_i2c_client(dev); | ||
123 | data = atxp1_update_device(dev); | ||
124 | |||
125 | vcore = simple_strtoul(buf, NULL, 10); | ||
126 | vcore /= 25; | ||
127 | vcore *= 25; | ||
128 | |||
129 | /* Calculate VID */ | ||
130 | vid = vid_to_reg(vcore, data->vrm); | ||
131 | |||
132 | if (vid < 0) { | ||
133 | dev_err(dev, "VID calculation failed.\n"); | ||
134 | return -1; | ||
135 | } | ||
136 | |||
137 | /* If output enabled, use control register value. Otherwise original CPU VID */ | ||
138 | if (data->reg.vid & ATXP1_VIDENA) | ||
139 | cvid = data->reg.vid & ATXP1_VIDMASK; | ||
140 | else | ||
141 | cvid = data->reg.cpu_vid; | ||
142 | |||
143 | /* Nothing changed, aborting */ | ||
144 | if (vid == cvid) | ||
145 | return count; | ||
146 | |||
147 | dev_info(dev, "Setting VCore to %d mV (0x%02x)\n", vcore, vid); | ||
148 | |||
149 | /* Write every 25 mV step to increase stability */ | ||
150 | if (cvid > vid) { | ||
151 | for (; cvid >= vid; cvid--) { | ||
152 | i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA); | ||
153 | } | ||
154 | } | ||
155 | else { | ||
156 | for (; cvid <= vid; cvid++) { | ||
157 | i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | data->valid = 0; | ||
162 | |||
163 | return count; | ||
164 | } | ||
165 | |||
166 | /* CPU core reference voltage | ||
167 | unit: millivolt | ||
168 | */ | ||
169 | static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore); | ||
170 | |||
171 | /* sys file functions for GPIO1 */ | ||
172 | static ssize_t atxp1_showgpio1(struct device *dev, struct device_attribute *attr, char *buf) | ||
173 | { | ||
174 | int size; | ||
175 | struct atxp1_data *data; | ||
176 | |||
177 | data = atxp1_update_device(dev); | ||
178 | |||
179 | size = sprintf(buf, "0x%02x\n", data->reg.gpio1 & ATXP1_GPIO1MASK); | ||
180 | |||
181 | return size; | ||
182 | } | ||
183 | |||
184 | static ssize_t atxp1_storegpio1(struct device *dev, struct device_attribute *attr, const char*buf, size_t count) | ||
185 | { | ||
186 | struct atxp1_data *data; | ||
187 | struct i2c_client *client; | ||
188 | unsigned int value; | ||
189 | |||
190 | client = to_i2c_client(dev); | ||
191 | data = atxp1_update_device(dev); | ||
192 | |||
193 | value = simple_strtoul(buf, NULL, 16); | ||
194 | |||
195 | value &= ATXP1_GPIO1MASK; | ||
196 | |||
197 | if (value != (data->reg.gpio1 & ATXP1_GPIO1MASK)) { | ||
198 | dev_info(dev, "Writing 0x%x to GPIO1.\n", value); | ||
199 | |||
200 | i2c_smbus_write_byte_data(client, ATXP1_GPIO1, value); | ||
201 | |||
202 | data->valid = 0; | ||
203 | } | ||
204 | |||
205 | return count; | ||
206 | } | ||
207 | |||
208 | /* GPIO1 data register | ||
209 | unit: Four bit as hex (e.g. 0x0f) | ||
210 | */ | ||
211 | static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1); | ||
212 | |||
213 | /* sys file functions for GPIO2 */ | ||
214 | static ssize_t atxp1_showgpio2(struct device *dev, struct device_attribute *attr, char *buf) | ||
215 | { | ||
216 | int size; | ||
217 | struct atxp1_data *data; | ||
218 | |||
219 | data = atxp1_update_device(dev); | ||
220 | |||
221 | size = sprintf(buf, "0x%02x\n", data->reg.gpio2); | ||
222 | |||
223 | return size; | ||
224 | } | ||
225 | |||
226 | static ssize_t atxp1_storegpio2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
227 | { | ||
228 | struct atxp1_data *data; | ||
229 | struct i2c_client *client; | ||
230 | unsigned int value; | ||
231 | |||
232 | client = to_i2c_client(dev); | ||
233 | data = atxp1_update_device(dev); | ||
234 | |||
235 | value = simple_strtoul(buf, NULL, 16) & 0xff; | ||
236 | |||
237 | if (value != data->reg.gpio2) { | ||
238 | dev_info(dev, "Writing 0x%x to GPIO1.\n", value); | ||
239 | |||
240 | i2c_smbus_write_byte_data(client, ATXP1_GPIO2, value); | ||
241 | |||
242 | data->valid = 0; | ||
243 | } | ||
244 | |||
245 | return count; | ||
246 | } | ||
247 | |||
248 | /* GPIO2 data register | ||
249 | unit: Eight bit as hex (e.g. 0xff) | ||
250 | */ | ||
251 | static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); | ||
252 | |||
253 | |||
254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) | ||
255 | { | ||
256 | return i2c_detect(adapter, &addr_data, &atxp1_detect); | ||
257 | }; | ||
258 | |||
259 | static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | ||
260 | { | ||
261 | struct i2c_client * new_client; | ||
262 | struct atxp1_data * data; | ||
263 | int err = 0; | ||
264 | u8 temp; | ||
265 | |||
266 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
267 | goto exit; | ||
268 | |||
269 | if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { | ||
270 | err = -ENOMEM; | ||
271 | goto exit; | ||
272 | } | ||
273 | |||
274 | memset(data, 0, sizeof(struct atxp1_data)); | ||
275 | new_client = &data->client; | ||
276 | i2c_set_clientdata(new_client, data); | ||
277 | |||
278 | new_client->addr = address; | ||
279 | new_client->adapter = adapter; | ||
280 | new_client->driver = &atxp1_driver; | ||
281 | new_client->flags = 0; | ||
282 | |||
283 | /* Detect ATXP1, checking if vendor ID registers are all zero */ | ||
284 | if (!((i2c_smbus_read_byte_data(new_client, 0x3e) == 0) && | ||
285 | (i2c_smbus_read_byte_data(new_client, 0x3f) == 0) && | ||
286 | (i2c_smbus_read_byte_data(new_client, 0xfe) == 0) && | ||
287 | (i2c_smbus_read_byte_data(new_client, 0xff) == 0) )) { | ||
288 | |||
289 | /* No vendor ID, now checking if registers 0x10,0x11 (non-existent) | ||
290 | * showing the same as register 0x00 */ | ||
291 | temp = i2c_smbus_read_byte_data(new_client, 0x00); | ||
292 | |||
293 | if (!((i2c_smbus_read_byte_data(new_client, 0x10) == temp) && | ||
294 | (i2c_smbus_read_byte_data(new_client, 0x11) == temp) )) | ||
295 | goto exit_free; | ||
296 | } | ||
297 | |||
298 | /* Get VRM */ | ||
299 | data->vrm = i2c_which_vrm(); | ||
300 | |||
301 | if ((data->vrm != 90) && (data->vrm != 91)) { | ||
302 | dev_err(&new_client->dev, "Not supporting VRM %d.%d\n", | ||
303 | data->vrm / 10, data->vrm % 10); | ||
304 | goto exit_free; | ||
305 | } | ||
306 | |||
307 | strncpy(new_client->name, "atxp1", I2C_NAME_SIZE); | ||
308 | |||
309 | data->valid = 0; | ||
310 | |||
311 | init_MUTEX(&data->update_lock); | ||
312 | |||
313 | err = i2c_attach_client(new_client); | ||
314 | |||
315 | if (err) | ||
316 | { | ||
317 | dev_err(&new_client->dev, "Attach client error.\n"); | ||
318 | goto exit_free; | ||
319 | } | ||
320 | |||
321 | device_create_file(&new_client->dev, &dev_attr_gpio1); | ||
322 | device_create_file(&new_client->dev, &dev_attr_gpio2); | ||
323 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
324 | |||
325 | dev_info(&new_client->dev, "Using VRM: %d.%d\n", | ||
326 | data->vrm / 10, data->vrm % 10); | ||
327 | |||
328 | return 0; | ||
329 | |||
330 | exit_free: | ||
331 | kfree(data); | ||
332 | exit: | ||
333 | return err; | ||
334 | }; | ||
335 | |||
336 | static int atxp1_detach_client(struct i2c_client * client) | ||
337 | { | ||
338 | int err; | ||
339 | |||
340 | err = i2c_detach_client(client); | ||
341 | |||
342 | if (err) | ||
343 | dev_err(&client->dev, "Failed to detach client.\n"); | ||
344 | else | ||
345 | kfree(i2c_get_clientdata(client)); | ||
346 | |||
347 | return err; | ||
348 | }; | ||
349 | |||
350 | static int __init atxp1_init(void) | ||
351 | { | ||
352 | return i2c_add_driver(&atxp1_driver); | ||
353 | }; | ||
354 | |||
355 | static void __exit atxp1_exit(void) | ||
356 | { | ||
357 | i2c_del_driver(&atxp1_driver); | ||
358 | }; | ||
359 | |||
360 | module_init(atxp1_init); | ||
361 | module_exit(atxp1_exit); | ||
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 07f16c3fb084..74ece8ac1c23 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c | |||
@@ -3,17 +3,16 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2005 James Chapman <jchapman@katalix.com> | 4 | * Copyright (C) 2005 James Chapman <jchapman@katalix.com> |
5 | * | 5 | * |
6 | * based on linux/drivers/acron/char/pcf8583.c | 6 | * based on linux/drivers/acorn/char/pcf8583.c |
7 | * Copyright (C) 2000 Russell King | 7 | * Copyright (C) 2000 Russell King |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License version 2 as | 10 | * it under the terms of the GNU General Public License version 2 as |
11 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
12 | * | 12 | * |
13 | * Driver for Dallas Semiconductor DS1337 real time clock chip | 13 | * Driver for Dallas Semiconductor DS1337 and DS1339 real time clock chip |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/config.h> | ||
17 | #include <linux/module.h> | 16 | #include <linux/module.h> |
18 | #include <linux/init.h> | 17 | #include <linux/init.h> |
19 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
@@ -69,13 +68,11 @@ static struct i2c_driver ds1337_driver = { | |||
69 | struct ds1337_data { | 68 | struct ds1337_data { |
70 | struct i2c_client client; | 69 | struct i2c_client client; |
71 | struct list_head list; | 70 | struct list_head list; |
72 | int id; | ||
73 | }; | 71 | }; |
74 | 72 | ||
75 | /* | 73 | /* |
76 | * Internal variables | 74 | * Internal variables |
77 | */ | 75 | */ |
78 | static int ds1337_id; | ||
79 | static LIST_HEAD(ds1337_clients); | 76 | static LIST_HEAD(ds1337_clients); |
80 | 77 | ||
81 | static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) | 78 | static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) |
@@ -95,7 +92,6 @@ static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) | |||
95 | */ | 92 | */ |
96 | static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) | 93 | static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) |
97 | { | 94 | { |
98 | struct ds1337_data *data = i2c_get_clientdata(client); | ||
99 | int result; | 95 | int result; |
100 | u8 buf[7]; | 96 | u8 buf[7]; |
101 | u8 val; | 97 | u8 val; |
@@ -103,9 +99,7 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) | |||
103 | u8 offs = 0; | 99 | u8 offs = 0; |
104 | 100 | ||
105 | if (!dt) { | 101 | if (!dt) { |
106 | dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n", | 102 | dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__); |
107 | __FUNCTION__); | ||
108 | |||
109 | return -EINVAL; | 103 | return -EINVAL; |
110 | } | 104 | } |
111 | 105 | ||
@@ -119,98 +113,86 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) | |||
119 | msg[1].len = sizeof(buf); | 113 | msg[1].len = sizeof(buf); |
120 | msg[1].buf = &buf[0]; | 114 | msg[1].buf = &buf[0]; |
121 | 115 | ||
122 | result = client->adapter->algo->master_xfer(client->adapter, | 116 | result = i2c_transfer(client->adapter, msg, 2); |
123 | &msg[0], 2); | ||
124 | 117 | ||
125 | dev_dbg(&client->adapter->dev, | 118 | dev_dbg(&client->dev, "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n", |
126 | "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n", | ||
127 | __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3], | 119 | __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3], |
128 | buf[4], buf[5], buf[6]); | 120 | buf[4], buf[5], buf[6]); |
129 | 121 | ||
130 | if (result >= 0) { | 122 | if (result == 2) { |
131 | dt->tm_sec = BCD_TO_BIN(buf[0]); | 123 | dt->tm_sec = BCD2BIN(buf[0]); |
132 | dt->tm_min = BCD_TO_BIN(buf[1]); | 124 | dt->tm_min = BCD2BIN(buf[1]); |
133 | val = buf[2] & 0x3f; | 125 | val = buf[2] & 0x3f; |
134 | dt->tm_hour = BCD_TO_BIN(val); | 126 | dt->tm_hour = BCD2BIN(val); |
135 | dt->tm_wday = BCD_TO_BIN(buf[3]) - 1; | 127 | dt->tm_wday = BCD2BIN(buf[3]) - 1; |
136 | dt->tm_mday = BCD_TO_BIN(buf[4]); | 128 | dt->tm_mday = BCD2BIN(buf[4]); |
137 | val = buf[5] & 0x7f; | 129 | val = buf[5] & 0x7f; |
138 | dt->tm_mon = BCD_TO_BIN(val); | 130 | dt->tm_mon = BCD2BIN(val) - 1; |
139 | dt->tm_year = 1900 + BCD_TO_BIN(buf[6]); | 131 | dt->tm_year = BCD2BIN(buf[6]); |
140 | if (buf[5] & 0x80) | 132 | if (buf[5] & 0x80) |
141 | dt->tm_year += 100; | 133 | dt->tm_year += 100; |
142 | 134 | ||
143 | dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, " | 135 | dev_dbg(&client->dev, "%s: secs=%d, mins=%d, " |
144 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", | 136 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", |
145 | __FUNCTION__, dt->tm_sec, dt->tm_min, | 137 | __FUNCTION__, dt->tm_sec, dt->tm_min, |
146 | dt->tm_hour, dt->tm_mday, | 138 | dt->tm_hour, dt->tm_mday, |
147 | dt->tm_mon, dt->tm_year, dt->tm_wday); | 139 | dt->tm_mon, dt->tm_year, dt->tm_wday); |
148 | } else { | 140 | |
149 | dev_err(&client->adapter->dev, "ds1337[%d]: error reading " | 141 | return 0; |
150 | "data! %d\n", data->id, result); | ||
151 | result = -EIO; | ||
152 | } | 142 | } |
153 | 143 | ||
154 | return result; | 144 | dev_err(&client->dev, "error reading data! %d\n", result); |
145 | return -EIO; | ||
155 | } | 146 | } |
156 | 147 | ||
157 | static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) | 148 | static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) |
158 | { | 149 | { |
159 | struct ds1337_data *data = i2c_get_clientdata(client); | ||
160 | int result; | 150 | int result; |
161 | u8 buf[8]; | 151 | u8 buf[8]; |
162 | u8 val; | 152 | u8 val; |
163 | struct i2c_msg msg[1]; | 153 | struct i2c_msg msg[1]; |
164 | 154 | ||
165 | if (!dt) { | 155 | if (!dt) { |
166 | dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n", | 156 | dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__); |
167 | __FUNCTION__); | ||
168 | |||
169 | return -EINVAL; | 157 | return -EINVAL; |
170 | } | 158 | } |
171 | 159 | ||
172 | dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, hours=%d, " | 160 | dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " |
173 | "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__, | 161 | "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__, |
174 | dt->tm_sec, dt->tm_min, dt->tm_hour, | 162 | dt->tm_sec, dt->tm_min, dt->tm_hour, |
175 | dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday); | 163 | dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday); |
176 | 164 | ||
177 | buf[0] = 0; /* reg offset */ | 165 | buf[0] = 0; /* reg offset */ |
178 | buf[1] = BIN_TO_BCD(dt->tm_sec); | 166 | buf[1] = BIN2BCD(dt->tm_sec); |
179 | buf[2] = BIN_TO_BCD(dt->tm_min); | 167 | buf[2] = BIN2BCD(dt->tm_min); |
180 | buf[3] = BIN_TO_BCD(dt->tm_hour) | (1 << 6); | 168 | buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6); |
181 | buf[4] = BIN_TO_BCD(dt->tm_wday) + 1; | 169 | buf[4] = BIN2BCD(dt->tm_wday) + 1; |
182 | buf[5] = BIN_TO_BCD(dt->tm_mday); | 170 | buf[5] = BIN2BCD(dt->tm_mday); |
183 | buf[6] = BIN_TO_BCD(dt->tm_mon); | 171 | buf[6] = BIN2BCD(dt->tm_mon) + 1; |
184 | if (dt->tm_year >= 2000) { | 172 | val = dt->tm_year; |
185 | val = dt->tm_year - 2000; | 173 | if (val >= 100) { |
174 | val -= 100; | ||
186 | buf[6] |= (1 << 7); | 175 | buf[6] |= (1 << 7); |
187 | } else { | ||
188 | val = dt->tm_year - 1900; | ||
189 | } | 176 | } |
190 | buf[7] = BIN_TO_BCD(val); | 177 | buf[7] = BIN2BCD(val); |
191 | 178 | ||
192 | msg[0].addr = client->addr; | 179 | msg[0].addr = client->addr; |
193 | msg[0].flags = 0; | 180 | msg[0].flags = 0; |
194 | msg[0].len = sizeof(buf); | 181 | msg[0].len = sizeof(buf); |
195 | msg[0].buf = &buf[0]; | 182 | msg[0].buf = &buf[0]; |
196 | 183 | ||
197 | result = client->adapter->algo->master_xfer(client->adapter, | 184 | result = i2c_transfer(client->adapter, msg, 1); |
198 | &msg[0], 1); | 185 | if (result == 1) |
199 | if (result < 0) { | 186 | return 0; |
200 | dev_err(&client->adapter->dev, "ds1337[%d]: error " | ||
201 | "writing data! %d\n", data->id, result); | ||
202 | result = -EIO; | ||
203 | } else { | ||
204 | result = 0; | ||
205 | } | ||
206 | 187 | ||
207 | return result; | 188 | dev_err(&client->dev, "error writing data! %d\n", result); |
189 | return -EIO; | ||
208 | } | 190 | } |
209 | 191 | ||
210 | static int ds1337_command(struct i2c_client *client, unsigned int cmd, | 192 | static int ds1337_command(struct i2c_client *client, unsigned int cmd, |
211 | void *arg) | 193 | void *arg) |
212 | { | 194 | { |
213 | dev_dbg(&client->adapter->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); | 195 | dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); |
214 | 196 | ||
215 | switch (cmd) { | 197 | switch (cmd) { |
216 | case DS1337_GET_DATE: | 198 | case DS1337_GET_DATE: |
@@ -228,7 +210,7 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd, | |||
228 | * Public API for access to specific device. Useful for low-level | 210 | * Public API for access to specific device. Useful for low-level |
229 | * RTC access from kernel code. | 211 | * RTC access from kernel code. |
230 | */ | 212 | */ |
231 | int ds1337_do_command(int id, int cmd, void *arg) | 213 | int ds1337_do_command(int bus, int cmd, void *arg) |
232 | { | 214 | { |
233 | struct list_head *walk; | 215 | struct list_head *walk; |
234 | struct list_head *tmp; | 216 | struct list_head *tmp; |
@@ -236,7 +218,7 @@ int ds1337_do_command(int id, int cmd, void *arg) | |||
236 | 218 | ||
237 | list_for_each_safe(walk, tmp, &ds1337_clients) { | 219 | list_for_each_safe(walk, tmp, &ds1337_clients) { |
238 | data = list_entry(walk, struct ds1337_data, list); | 220 | data = list_entry(walk, struct ds1337_data, list); |
239 | if (data->id == id) | 221 | if (data->client.adapter->nr == bus) |
240 | return ds1337_command(&data->client, cmd, arg); | 222 | return ds1337_command(&data->client, cmd, arg); |
241 | } | 223 | } |
242 | 224 | ||
@@ -346,7 +328,6 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind) | |||
346 | ds1337_init_client(new_client); | 328 | ds1337_init_client(new_client); |
347 | 329 | ||
348 | /* Add client to local list */ | 330 | /* Add client to local list */ |
349 | data->id = ds1337_id++; | ||
350 | list_add(&data->list, &ds1337_clients); | 331 | list_add(&data->list, &ds1337_clients); |
351 | 332 | ||
352 | return 0; | 333 | return 0; |
@@ -398,5 +379,7 @@ MODULE_AUTHOR("James Chapman <jchapman@katalix.com>"); | |||
398 | MODULE_DESCRIPTION("DS1337 RTC driver"); | 379 | MODULE_DESCRIPTION("DS1337 RTC driver"); |
399 | MODULE_LICENSE("GPL"); | 380 | MODULE_LICENSE("GPL"); |
400 | 381 | ||
382 | EXPORT_SYMBOL_GPL(ds1337_do_command); | ||
383 | |||
401 | module_init(ds1337_init); | 384 | module_init(ds1337_init); |
402 | module_exit(ds1337_exit); | 385 | module_exit(ds1337_exit); |
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c new file mode 100644 index 000000000000..a445736d8838 --- /dev/null +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -0,0 +1,260 @@ | |||
1 | /* | ||
2 | * drivers/i2c/chips/ds1374.c | ||
3 | * | ||
4 | * I2C client/driver for the Maxim/Dallas DS1374 Real-Time Clock | ||
5 | * | ||
6 | * Author: Randy Vinson <rvinson@mvista.com> | ||
7 | * | ||
8 | * Based on the m41t00.c by Mark Greer <mgreer@mvista.com> | ||
9 | * | ||
10 | * 2005 (c) MontaVista Software, Inc. This file is licensed under | ||
11 | * the terms of the GNU General Public License version 2. This program | ||
12 | * is licensed "as is" without any warranty of any kind, whether express | ||
13 | * or implied. | ||
14 | */ | ||
15 | /* | ||
16 | * This i2c client/driver wedges between the drivers/char/genrtc.c RTC | ||
17 | * interface and the SMBus interface of the i2c subsystem. | ||
18 | * It would be more efficient to use i2c msgs/i2c_transfer directly but, as | ||
19 | * recommened in .../Documentation/i2c/writing-clients section | ||
20 | * "Sending and receiving", using SMBus level communication is preferred. | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | #include <linux/i2c.h> | ||
27 | #include <linux/rtc.h> | ||
28 | #include <linux/bcd.h> | ||
29 | |||
30 | #define DS1374_REG_TOD0 0x00 | ||
31 | #define DS1374_REG_TOD1 0x01 | ||
32 | #define DS1374_REG_TOD2 0x02 | ||
33 | #define DS1374_REG_TOD3 0x03 | ||
34 | #define DS1374_REG_WDALM0 0x04 | ||
35 | #define DS1374_REG_WDALM1 0x05 | ||
36 | #define DS1374_REG_WDALM2 0x06 | ||
37 | #define DS1374_REG_CR 0x07 | ||
38 | #define DS1374_REG_SR 0x08 | ||
39 | #define DS1374_REG_SR_OSF 0x80 | ||
40 | #define DS1374_REG_TCR 0x09 | ||
41 | |||
42 | #define DS1374_DRV_NAME "ds1374" | ||
43 | |||
44 | static DECLARE_MUTEX(ds1374_mutex); | ||
45 | |||
46 | static struct i2c_driver ds1374_driver; | ||
47 | static struct i2c_client *save_client; | ||
48 | |||
49 | static unsigned short ignore[] = { I2C_CLIENT_END }; | ||
50 | static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END }; | ||
51 | |||
52 | static struct i2c_client_address_data addr_data = { | ||
53 | .normal_i2c = normal_addr, | ||
54 | .probe = ignore, | ||
55 | .ignore = ignore, | ||
56 | .force = ignore, | ||
57 | }; | ||
58 | |||
59 | static ulong ds1374_read_rtc(void) | ||
60 | { | ||
61 | ulong time = 0; | ||
62 | int reg = DS1374_REG_WDALM0; | ||
63 | |||
64 | while (reg--) { | ||
65 | s32 tmp; | ||
66 | if ((tmp = i2c_smbus_read_byte_data(save_client, reg)) < 0) { | ||
67 | dev_warn(&save_client->dev, | ||
68 | "can't read from rtc chip\n"); | ||
69 | return 0; | ||
70 | } | ||
71 | time = (time << 8) | (tmp & 0xff); | ||
72 | } | ||
73 | return time; | ||
74 | } | ||
75 | |||
76 | static void ds1374_write_rtc(ulong time) | ||
77 | { | ||
78 | int reg; | ||
79 | |||
80 | for (reg = DS1374_REG_TOD0; reg < DS1374_REG_WDALM0; reg++) { | ||
81 | if (i2c_smbus_write_byte_data(save_client, reg, time & 0xff) | ||
82 | < 0) { | ||
83 | dev_warn(&save_client->dev, | ||
84 | "can't write to rtc chip\n"); | ||
85 | break; | ||
86 | } | ||
87 | time = time >> 8; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | static void ds1374_check_rtc_status(void) | ||
92 | { | ||
93 | s32 tmp; | ||
94 | |||
95 | tmp = i2c_smbus_read_byte_data(save_client, DS1374_REG_SR); | ||
96 | if (tmp < 0) { | ||
97 | dev_warn(&save_client->dev, | ||
98 | "can't read status from rtc chip\n"); | ||
99 | return; | ||
100 | } | ||
101 | if (tmp & DS1374_REG_SR_OSF) { | ||
102 | dev_warn(&save_client->dev, | ||
103 | "oscillator discontinuity flagged, time unreliable\n"); | ||
104 | tmp &= ~DS1374_REG_SR_OSF; | ||
105 | tmp = i2c_smbus_write_byte_data(save_client, DS1374_REG_SR, | ||
106 | tmp & 0xff); | ||
107 | if (tmp < 0) | ||
108 | dev_warn(&save_client->dev, | ||
109 | "can't clear discontinuity notification\n"); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | ulong ds1374_get_rtc_time(void) | ||
114 | { | ||
115 | ulong t1, t2; | ||
116 | int limit = 10; /* arbitrary retry limit */ | ||
117 | |||
118 | down(&ds1374_mutex); | ||
119 | |||
120 | /* | ||
121 | * Since the reads are being performed one byte at a time using | ||
122 | * the SMBus vs a 4-byte i2c transfer, there is a chance that a | ||
123 | * carry will occur during the read. To detect this, 2 reads are | ||
124 | * performed and compared. | ||
125 | */ | ||
126 | do { | ||
127 | t1 = ds1374_read_rtc(); | ||
128 | t2 = ds1374_read_rtc(); | ||
129 | } while (t1 != t2 && limit--); | ||
130 | |||
131 | up(&ds1374_mutex); | ||
132 | |||
133 | if (t1 != t2) { | ||
134 | dev_warn(&save_client->dev, | ||
135 | "can't get consistent time from rtc chip\n"); | ||
136 | t1 = 0; | ||
137 | } | ||
138 | |||
139 | return t1; | ||
140 | } | ||
141 | |||
142 | static void ds1374_set_tlet(ulong arg) | ||
143 | { | ||
144 | ulong t1, t2; | ||
145 | int limit = 10; /* arbitrary retry limit */ | ||
146 | |||
147 | t1 = *(ulong *) arg; | ||
148 | |||
149 | down(&ds1374_mutex); | ||
150 | |||
151 | /* | ||
152 | * Since the writes are being performed one byte at a time using | ||
153 | * the SMBus vs a 4-byte i2c transfer, there is a chance that a | ||
154 | * carry will occur during the write. To detect this, the write | ||
155 | * value is read back and compared. | ||
156 | */ | ||
157 | do { | ||
158 | ds1374_write_rtc(t1); | ||
159 | t2 = ds1374_read_rtc(); | ||
160 | } while (t1 != t2 && limit--); | ||
161 | |||
162 | up(&ds1374_mutex); | ||
163 | |||
164 | if (t1 != t2) | ||
165 | dev_warn(&save_client->dev, | ||
166 | "can't confirm time set from rtc chip\n"); | ||
167 | } | ||
168 | |||
169 | ulong new_time; | ||
170 | |||
171 | DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time); | ||
172 | |||
173 | int ds1374_set_rtc_time(ulong nowtime) | ||
174 | { | ||
175 | new_time = nowtime; | ||
176 | |||
177 | if (in_interrupt()) | ||
178 | tasklet_schedule(&ds1374_tasklet); | ||
179 | else | ||
180 | ds1374_set_tlet((ulong) & new_time); | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | ***************************************************************************** | ||
187 | * | ||
188 | * Driver Interface | ||
189 | * | ||
190 | ***************************************************************************** | ||
191 | */ | ||
192 | static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind) | ||
193 | { | ||
194 | struct i2c_client *client; | ||
195 | int rc; | ||
196 | |||
197 | client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
198 | if (!client) | ||
199 | return -ENOMEM; | ||
200 | |||
201 | memset(client, 0, sizeof(struct i2c_client)); | ||
202 | strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE); | ||
203 | client->flags = I2C_DF_NOTIFY; | ||
204 | client->addr = addr; | ||
205 | client->adapter = adap; | ||
206 | client->driver = &ds1374_driver; | ||
207 | |||
208 | if ((rc = i2c_attach_client(client)) != 0) { | ||
209 | kfree(client); | ||
210 | return rc; | ||
211 | } | ||
212 | |||
213 | save_client = client; | ||
214 | |||
215 | ds1374_check_rtc_status(); | ||
216 | |||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static int ds1374_attach(struct i2c_adapter *adap) | ||
221 | { | ||
222 | return i2c_probe(adap, &addr_data, ds1374_probe); | ||
223 | } | ||
224 | |||
225 | static int ds1374_detach(struct i2c_client *client) | ||
226 | { | ||
227 | int rc; | ||
228 | |||
229 | if ((rc = i2c_detach_client(client)) == 0) { | ||
230 | kfree(i2c_get_clientdata(client)); | ||
231 | tasklet_kill(&ds1374_tasklet); | ||
232 | } | ||
233 | return rc; | ||
234 | } | ||
235 | |||
236 | static struct i2c_driver ds1374_driver = { | ||
237 | .owner = THIS_MODULE, | ||
238 | .name = DS1374_DRV_NAME, | ||
239 | .id = I2C_DRIVERID_DS1374, | ||
240 | .flags = I2C_DF_NOTIFY, | ||
241 | .attach_adapter = ds1374_attach, | ||
242 | .detach_client = ds1374_detach, | ||
243 | }; | ||
244 | |||
245 | static int __init ds1374_init(void) | ||
246 | { | ||
247 | return i2c_add_driver(&ds1374_driver); | ||
248 | } | ||
249 | |||
250 | static void __exit ds1374_exit(void) | ||
251 | { | ||
252 | i2c_del_driver(&ds1374_driver); | ||
253 | } | ||
254 | |||
255 | module_init(ds1374_init); | ||
256 | module_exit(ds1374_exit); | ||
257 | |||
258 | MODULE_AUTHOR("Randy Vinson <rvinson@mvista.com>"); | ||
259 | MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC I2C Client Driver"); | ||
260 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/i2c/chips/ds1621.c b/drivers/i2c/chips/ds1621.c index 4ae15bd5dcfb..5360d58804f6 100644 --- a/drivers/i2c/chips/ds1621.c +++ b/drivers/i2c/chips/ds1621.c | |||
@@ -121,7 +121,7 @@ static int ds1621_write_value(struct i2c_client *client, u8 reg, u16 value) | |||
121 | static void ds1621_init_client(struct i2c_client *client) | 121 | static void ds1621_init_client(struct i2c_client *client) |
122 | { | 122 | { |
123 | int reg = ds1621_read_value(client, DS1621_REG_CONF); | 123 | int reg = ds1621_read_value(client, DS1621_REG_CONF); |
124 | /* switch to continous conversion mode */ | 124 | /* switch to continuous conversion mode */ |
125 | reg &= ~ DS1621_REG_CONFIG_1SHOT; | 125 | reg &= ~ DS1621_REG_CONFIG_1SHOT; |
126 | 126 | ||
127 | /* setup output polarity */ | 127 | /* setup output polarity */ |
@@ -303,7 +303,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
303 | data->temp_max = ds1621_read_value(client, | 303 | data->temp_max = ds1621_read_value(client, |
304 | DS1621_REG_TEMP_MAX); | 304 | DS1621_REG_TEMP_MAX); |
305 | 305 | ||
306 | /* reset alarms if neccessary */ | 306 | /* reset alarms if necessary */ |
307 | new_conf = data->conf; | 307 | new_conf = data->conf; |
308 | if (data->temp < data->temp_min) | 308 | if (data->temp < data->temp_min) |
309 | new_conf &= ~DS1621_ALARM_TEMP_LOW; | 309 | new_conf &= ~DS1621_ALARM_TEMP_LOW; |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index cbdfa2db6f7c..addf0adc24d4 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -26,7 +26,6 @@ | |||
26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/module.h> | 31 | #include <linux/module.h> |
diff --git a/drivers/i2c/chips/fscher.c b/drivers/i2c/chips/fscher.c index c3f37dbec11a..da411741c2c5 100644 --- a/drivers/i2c/chips/fscher.c +++ b/drivers/i2c/chips/fscher.c | |||
@@ -26,7 +26,6 @@ | |||
26 | * and Philip Edelbrock <phil@netroedge.com> | 26 | * and Philip Edelbrock <phil@netroedge.com> |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #include <linux/module.h> | 29 | #include <linux/module.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/gl518sm.c b/drivers/i2c/chips/gl518sm.c index 4316a1562251..6bedf729dcf5 100644 --- a/drivers/i2c/chips/gl518sm.c +++ b/drivers/i2c/chips/gl518sm.c | |||
@@ -36,7 +36,6 @@ | |||
36 | * 2004-01-31 Code review and approval. (Jean Delvare) | 36 | * 2004-01-31 Code review and approval. (Jean Delvare) |
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include <linux/config.h> | ||
40 | #include <linux/module.h> | 39 | #include <linux/module.h> |
41 | #include <linux/init.h> | 40 | #include <linux/init.h> |
42 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 7f29a8aff165..354a26295672 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -145,7 +145,6 @@ static inline void notresponding(struct isp1301 *isp) | |||
145 | static unsigned short normal_i2c[] = { | 145 | static unsigned short normal_i2c[] = { |
146 | ISP_BASE, ISP_BASE + 1, | 146 | ISP_BASE, ISP_BASE + 1, |
147 | I2C_CLIENT_END }; | 147 | I2C_CLIENT_END }; |
148 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
149 | 148 | ||
150 | I2C_CLIENT_INSMOD; | 149 | I2C_CLIENT_INSMOD; |
151 | 150 | ||
diff --git a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c index 007bdf9e7e2a..db20c9e47393 100644 --- a/drivers/i2c/chips/it87.c +++ b/drivers/i2c/chips/it87.c | |||
@@ -31,7 +31,6 @@ | |||
31 | type at module load time. | 31 | type at module load time. |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/config.h> | ||
35 | #include <linux/module.h> | 34 | #include <linux/module.h> |
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
37 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
@@ -39,6 +38,7 @@ | |||
39 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
40 | #include <linux/i2c-sensor.h> | 39 | #include <linux/i2c-sensor.h> |
41 | #include <linux/i2c-vid.h> | 40 | #include <linux/i2c-vid.h> |
41 | #include <linux/hwmon-sysfs.h> | ||
42 | #include <asm/io.h> | 42 | #include <asm/io.h> |
43 | 43 | ||
44 | 44 | ||
@@ -173,8 +173,6 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
173 | ((val)+500)/1000),-128,127)) | 173 | ((val)+500)/1000),-128,127)) |
174 | #define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000) | 174 | #define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000) |
175 | 175 | ||
176 | #define ALARMS_FROM_REG(val) (val) | ||
177 | |||
178 | #define PWM_TO_REG(val) ((val) >> 1) | 176 | #define PWM_TO_REG(val) ((val) >> 1) |
179 | #define PWM_FROM_REG(val) (((val)&0x7f) << 1) | 177 | #define PWM_FROM_REG(val) (((val)&0x7f) << 1) |
180 | 178 | ||
@@ -241,27 +239,42 @@ static struct i2c_driver it87_driver = { | |||
241 | .detach_client = it87_detach_client, | 239 | .detach_client = it87_detach_client, |
242 | }; | 240 | }; |
243 | 241 | ||
244 | static ssize_t show_in(struct device *dev, char *buf, int nr) | 242 | static ssize_t show_in(struct device *dev, struct device_attribute *attr, |
243 | char *buf) | ||
245 | { | 244 | { |
245 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
246 | int nr = sensor_attr->index; | ||
247 | |||
246 | struct it87_data *data = it87_update_device(dev); | 248 | struct it87_data *data = it87_update_device(dev); |
247 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); | 249 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); |
248 | } | 250 | } |
249 | 251 | ||
250 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | 252 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, |
253 | char *buf) | ||
251 | { | 254 | { |
255 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
256 | int nr = sensor_attr->index; | ||
257 | |||
252 | struct it87_data *data = it87_update_device(dev); | 258 | struct it87_data *data = it87_update_device(dev); |
253 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])); | 259 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])); |
254 | } | 260 | } |
255 | 261 | ||
256 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 262 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
263 | char *buf) | ||
257 | { | 264 | { |
265 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
266 | int nr = sensor_attr->index; | ||
267 | |||
258 | struct it87_data *data = it87_update_device(dev); | 268 | struct it87_data *data = it87_update_device(dev); |
259 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])); | 269 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])); |
260 | } | 270 | } |
261 | 271 | ||
262 | static ssize_t set_in_min(struct device *dev, const char *buf, | 272 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
263 | size_t count, int nr) | 273 | const char *buf, size_t count) |
264 | { | 274 | { |
275 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
276 | int nr = sensor_attr->index; | ||
277 | |||
265 | struct i2c_client *client = to_i2c_client(dev); | 278 | struct i2c_client *client = to_i2c_client(dev); |
266 | struct it87_data *data = i2c_get_clientdata(client); | 279 | struct it87_data *data = i2c_get_clientdata(client); |
267 | unsigned long val = simple_strtoul(buf, NULL, 10); | 280 | unsigned long val = simple_strtoul(buf, NULL, 10); |
@@ -273,9 +286,12 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
273 | up(&data->update_lock); | 286 | up(&data->update_lock); |
274 | return count; | 287 | return count; |
275 | } | 288 | } |
276 | static ssize_t set_in_max(struct device *dev, const char *buf, | 289 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
277 | size_t count, int nr) | 290 | const char *buf, size_t count) |
278 | { | 291 | { |
292 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
293 | int nr = sensor_attr->index; | ||
294 | |||
279 | struct i2c_client *client = to_i2c_client(dev); | 295 | struct i2c_client *client = to_i2c_client(dev); |
280 | struct it87_data *data = i2c_get_clientdata(client); | 296 | struct it87_data *data = i2c_get_clientdata(client); |
281 | unsigned long val = simple_strtoul(buf, NULL, 10); | 297 | unsigned long val = simple_strtoul(buf, NULL, 10); |
@@ -289,38 +305,14 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
289 | } | 305 | } |
290 | 306 | ||
291 | #define show_in_offset(offset) \ | 307 | #define show_in_offset(offset) \ |
292 | static ssize_t \ | 308 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
293 | show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | 309 | show_in, NULL, offset); |
294 | { \ | ||
295 | return show_in(dev, buf, offset); \ | ||
296 | } \ | ||
297 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); | ||
298 | 310 | ||
299 | #define limit_in_offset(offset) \ | 311 | #define limit_in_offset(offset) \ |
300 | static ssize_t \ | 312 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ |
301 | show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ | 313 | show_in_min, set_in_min, offset); \ |
302 | { \ | 314 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ |
303 | return show_in_min(dev, buf, offset); \ | 315 | show_in_max, set_in_max, offset); |
304 | } \ | ||
305 | static ssize_t \ | ||
306 | show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ | ||
307 | { \ | ||
308 | return show_in_max(dev, buf, offset); \ | ||
309 | } \ | ||
310 | static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \ | ||
311 | const char *buf, size_t count) \ | ||
312 | { \ | ||
313 | return set_in_min(dev, buf, count, offset); \ | ||
314 | } \ | ||
315 | static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \ | ||
316 | const char *buf, size_t count) \ | ||
317 | { \ | ||
318 | return set_in_max(dev, buf, count, offset); \ | ||
319 | } \ | ||
320 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
321 | show_in##offset##_min, set_in##offset##_min); \ | ||
322 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
323 | show_in##offset##_max, set_in##offset##_max); | ||
324 | 316 | ||
325 | show_in_offset(0); | 317 | show_in_offset(0); |
326 | limit_in_offset(0); | 318 | limit_in_offset(0); |
@@ -341,24 +333,39 @@ limit_in_offset(7); | |||
341 | show_in_offset(8); | 333 | show_in_offset(8); |
342 | 334 | ||
343 | /* 3 temperatures */ | 335 | /* 3 temperatures */ |
344 | static ssize_t show_temp(struct device *dev, char *buf, int nr) | 336 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, |
337 | char *buf) | ||
345 | { | 338 | { |
339 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
340 | int nr = sensor_attr->index; | ||
341 | |||
346 | struct it87_data *data = it87_update_device(dev); | 342 | struct it87_data *data = it87_update_device(dev); |
347 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); | 343 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); |
348 | } | 344 | } |
349 | static ssize_t show_temp_max(struct device *dev, char *buf, int nr) | 345 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
346 | char *buf) | ||
350 | { | 347 | { |
348 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
349 | int nr = sensor_attr->index; | ||
350 | |||
351 | struct it87_data *data = it87_update_device(dev); | 351 | struct it87_data *data = it87_update_device(dev); |
352 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])); | 352 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])); |
353 | } | 353 | } |
354 | static ssize_t show_temp_min(struct device *dev, char *buf, int nr) | 354 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, |
355 | char *buf) | ||
355 | { | 356 | { |
357 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
358 | int nr = sensor_attr->index; | ||
359 | |||
356 | struct it87_data *data = it87_update_device(dev); | 360 | struct it87_data *data = it87_update_device(dev); |
357 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])); | 361 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])); |
358 | } | 362 | } |
359 | static ssize_t set_temp_max(struct device *dev, const char *buf, | 363 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
360 | size_t count, int nr) | 364 | const char *buf, size_t count) |
361 | { | 365 | { |
366 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
367 | int nr = sensor_attr->index; | ||
368 | |||
362 | struct i2c_client *client = to_i2c_client(dev); | 369 | struct i2c_client *client = to_i2c_client(dev); |
363 | struct it87_data *data = i2c_get_clientdata(client); | 370 | struct it87_data *data = i2c_get_clientdata(client); |
364 | int val = simple_strtol(buf, NULL, 10); | 371 | int val = simple_strtol(buf, NULL, 10); |
@@ -369,9 +376,12 @@ static ssize_t set_temp_max(struct device *dev, const char *buf, | |||
369 | up(&data->update_lock); | 376 | up(&data->update_lock); |
370 | return count; | 377 | return count; |
371 | } | 378 | } |
372 | static ssize_t set_temp_min(struct device *dev, const char *buf, | 379 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
373 | size_t count, int nr) | 380 | const char *buf, size_t count) |
374 | { | 381 | { |
382 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
383 | int nr = sensor_attr->index; | ||
384 | |||
375 | struct i2c_client *client = to_i2c_client(dev); | 385 | struct i2c_client *client = to_i2c_client(dev); |
376 | struct it87_data *data = i2c_get_clientdata(client); | 386 | struct it87_data *data = i2c_get_clientdata(client); |
377 | int val = simple_strtol(buf, NULL, 10); | 387 | int val = simple_strtol(buf, NULL, 10); |
@@ -383,42 +393,23 @@ static ssize_t set_temp_min(struct device *dev, const char *buf, | |||
383 | return count; | 393 | return count; |
384 | } | 394 | } |
385 | #define show_temp_offset(offset) \ | 395 | #define show_temp_offset(offset) \ |
386 | static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | 396 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ |
387 | { \ | 397 | show_temp, NULL, offset - 1); \ |
388 | return show_temp(dev, buf, offset - 1); \ | 398 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
389 | } \ | 399 | show_temp_max, set_temp_max, offset - 1); \ |
390 | static ssize_t \ | 400 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
391 | show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ | 401 | show_temp_min, set_temp_min, offset - 1); |
392 | { \ | ||
393 | return show_temp_max(dev, buf, offset - 1); \ | ||
394 | } \ | ||
395 | static ssize_t \ | ||
396 | show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ | ||
397 | { \ | ||
398 | return show_temp_min(dev, buf, offset - 1); \ | ||
399 | } \ | ||
400 | static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \ | ||
401 | const char *buf, size_t count) \ | ||
402 | { \ | ||
403 | return set_temp_max(dev, buf, count, offset - 1); \ | ||
404 | } \ | ||
405 | static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \ | ||
406 | const char *buf, size_t count) \ | ||
407 | { \ | ||
408 | return set_temp_min(dev, buf, count, offset - 1); \ | ||
409 | } \ | ||
410 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \ | ||
411 | static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | ||
412 | show_temp_##offset##_max, set_temp_##offset##_max); \ | ||
413 | static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ | ||
414 | show_temp_##offset##_min, set_temp_##offset##_min); | ||
415 | 402 | ||
416 | show_temp_offset(1); | 403 | show_temp_offset(1); |
417 | show_temp_offset(2); | 404 | show_temp_offset(2); |
418 | show_temp_offset(3); | 405 | show_temp_offset(3); |
419 | 406 | ||
420 | static ssize_t show_sensor(struct device *dev, char *buf, int nr) | 407 | static ssize_t show_sensor(struct device *dev, struct device_attribute *attr, |
408 | char *buf) | ||
421 | { | 409 | { |
410 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
411 | int nr = sensor_attr->index; | ||
412 | |||
422 | struct it87_data *data = it87_update_device(dev); | 413 | struct it87_data *data = it87_update_device(dev); |
423 | u8 reg = data->sensor; /* In case the value is updated while we use it */ | 414 | u8 reg = data->sensor; /* In case the value is updated while we use it */ |
424 | 415 | ||
@@ -428,9 +419,12 @@ static ssize_t show_sensor(struct device *dev, char *buf, int nr) | |||
428 | return sprintf(buf, "2\n"); /* thermistor */ | 419 | return sprintf(buf, "2\n"); /* thermistor */ |
429 | return sprintf(buf, "0\n"); /* disabled */ | 420 | return sprintf(buf, "0\n"); /* disabled */ |
430 | } | 421 | } |
431 | static ssize_t set_sensor(struct device *dev, const char *buf, | 422 | static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, |
432 | size_t count, int nr) | 423 | const char *buf, size_t count) |
433 | { | 424 | { |
425 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
426 | int nr = sensor_attr->index; | ||
427 | |||
434 | struct i2c_client *client = to_i2c_client(dev); | 428 | struct i2c_client *client = to_i2c_client(dev); |
435 | struct it87_data *data = i2c_get_clientdata(client); | 429 | struct it87_data *data = i2c_get_clientdata(client); |
436 | int val = simple_strtol(buf, NULL, 10); | 430 | int val = simple_strtol(buf, NULL, 10); |
@@ -453,53 +447,67 @@ static ssize_t set_sensor(struct device *dev, const char *buf, | |||
453 | return count; | 447 | return count; |
454 | } | 448 | } |
455 | #define show_sensor_offset(offset) \ | 449 | #define show_sensor_offset(offset) \ |
456 | static ssize_t show_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | 450 | static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \ |
457 | { \ | 451 | show_sensor, set_sensor, offset - 1); |
458 | return show_sensor(dev, buf, offset - 1); \ | ||
459 | } \ | ||
460 | static ssize_t set_sensor_##offset (struct device *dev, struct device_attribute *attr, \ | ||
461 | const char *buf, size_t count) \ | ||
462 | { \ | ||
463 | return set_sensor(dev, buf, count, offset - 1); \ | ||
464 | } \ | ||
465 | static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \ | ||
466 | show_sensor_##offset, set_sensor_##offset); | ||
467 | 452 | ||
468 | show_sensor_offset(1); | 453 | show_sensor_offset(1); |
469 | show_sensor_offset(2); | 454 | show_sensor_offset(2); |
470 | show_sensor_offset(3); | 455 | show_sensor_offset(3); |
471 | 456 | ||
472 | /* 3 Fans */ | 457 | /* 3 Fans */ |
473 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | 458 | static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
459 | char *buf) | ||
474 | { | 460 | { |
461 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
462 | int nr = sensor_attr->index; | ||
463 | |||
475 | struct it87_data *data = it87_update_device(dev); | 464 | struct it87_data *data = it87_update_device(dev); |
476 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], | 465 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], |
477 | DIV_FROM_REG(data->fan_div[nr]))); | 466 | DIV_FROM_REG(data->fan_div[nr]))); |
478 | } | 467 | } |
479 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | 468 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
469 | char *buf) | ||
480 | { | 470 | { |
471 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
472 | int nr = sensor_attr->index; | ||
473 | |||
481 | struct it87_data *data = it87_update_device(dev); | 474 | struct it87_data *data = it87_update_device(dev); |
482 | return sprintf(buf,"%d\n", | 475 | return sprintf(buf,"%d\n", |
483 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]))); | 476 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]))); |
484 | } | 477 | } |
485 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | 478 | static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, |
479 | char *buf) | ||
486 | { | 480 | { |
481 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
482 | int nr = sensor_attr->index; | ||
483 | |||
487 | struct it87_data *data = it87_update_device(dev); | 484 | struct it87_data *data = it87_update_device(dev); |
488 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); | 485 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); |
489 | } | 486 | } |
490 | static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) | 487 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, |
488 | char *buf) | ||
491 | { | 489 | { |
490 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
491 | int nr = sensor_attr->index; | ||
492 | |||
492 | struct it87_data *data = it87_update_device(dev); | 493 | struct it87_data *data = it87_update_device(dev); |
493 | return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0); | 494 | return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0); |
494 | } | 495 | } |
495 | static ssize_t show_pwm(struct device *dev, char *buf, int nr) | 496 | static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, |
497 | char *buf) | ||
496 | { | 498 | { |
499 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
500 | int nr = sensor_attr->index; | ||
501 | |||
497 | struct it87_data *data = it87_update_device(dev); | 502 | struct it87_data *data = it87_update_device(dev); |
498 | return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]); | 503 | return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]); |
499 | } | 504 | } |
500 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 505 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
501 | size_t count, int nr) | 506 | const char *buf, size_t count) |
502 | { | 507 | { |
508 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
509 | int nr = sensor_attr->index; | ||
510 | |||
503 | struct i2c_client *client = to_i2c_client(dev); | 511 | struct i2c_client *client = to_i2c_client(dev); |
504 | struct it87_data *data = i2c_get_clientdata(client); | 512 | struct it87_data *data = i2c_get_clientdata(client); |
505 | int val = simple_strtol(buf, NULL, 10); | 513 | int val = simple_strtol(buf, NULL, 10); |
@@ -510,9 +518,12 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
510 | up(&data->update_lock); | 518 | up(&data->update_lock); |
511 | return count; | 519 | return count; |
512 | } | 520 | } |
513 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 521 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
514 | size_t count, int nr) | 522 | const char *buf, size_t count) |
515 | { | 523 | { |
524 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
525 | int nr = sensor_attr->index; | ||
526 | |||
516 | struct i2c_client *client = to_i2c_client(dev); | 527 | struct i2c_client *client = to_i2c_client(dev); |
517 | struct it87_data *data = i2c_get_clientdata(client); | 528 | struct it87_data *data = i2c_get_clientdata(client); |
518 | int val = simple_strtol(buf, NULL, 10); | 529 | int val = simple_strtol(buf, NULL, 10); |
@@ -550,9 +561,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
550 | up(&data->update_lock); | 561 | up(&data->update_lock); |
551 | return count; | 562 | return count; |
552 | } | 563 | } |
553 | static ssize_t set_pwm_enable(struct device *dev, const char *buf, | 564 | static ssize_t set_pwm_enable(struct device *dev, |
554 | size_t count, int nr) | 565 | struct device_attribute *attr, const char *buf, size_t count) |
555 | { | 566 | { |
567 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
568 | int nr = sensor_attr->index; | ||
569 | |||
556 | struct i2c_client *client = to_i2c_client(dev); | 570 | struct i2c_client *client = to_i2c_client(dev); |
557 | struct it87_data *data = i2c_get_clientdata(client); | 571 | struct it87_data *data = i2c_get_clientdata(client); |
558 | int val = simple_strtol(buf, NULL, 10); | 572 | int val = simple_strtol(buf, NULL, 10); |
@@ -581,9 +595,12 @@ static ssize_t set_pwm_enable(struct device *dev, const char *buf, | |||
581 | up(&data->update_lock); | 595 | up(&data->update_lock); |
582 | return count; | 596 | return count; |
583 | } | 597 | } |
584 | static ssize_t set_pwm(struct device *dev, const char *buf, | 598 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
585 | size_t count, int nr) | 599 | const char *buf, size_t count) |
586 | { | 600 | { |
601 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
602 | int nr = sensor_attr->index; | ||
603 | |||
587 | struct i2c_client *client = to_i2c_client(dev); | 604 | struct i2c_client *client = to_i2c_client(dev); |
588 | struct it87_data *data = i2c_get_clientdata(client); | 605 | struct it87_data *data = i2c_get_clientdata(client); |
589 | int val = simple_strtol(buf, NULL, 10); | 606 | int val = simple_strtol(buf, NULL, 10); |
@@ -599,64 +616,23 @@ static ssize_t set_pwm(struct device *dev, const char *buf, | |||
599 | return count; | 616 | return count; |
600 | } | 617 | } |
601 | 618 | ||
602 | #define show_fan_offset(offset) \ | 619 | #define show_fan_offset(offset) \ |
603 | static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | 620 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ |
604 | { \ | 621 | show_fan, NULL, offset - 1); \ |
605 | return show_fan(dev, buf, offset - 1); \ | 622 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
606 | } \ | 623 | show_fan_min, set_fan_min, offset - 1); \ |
607 | static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ | 624 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ |
608 | { \ | 625 | show_fan_div, set_fan_div, offset - 1); |
609 | return show_fan_min(dev, buf, offset - 1); \ | ||
610 | } \ | ||
611 | static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ | ||
612 | { \ | ||
613 | return show_fan_div(dev, buf, offset - 1); \ | ||
614 | } \ | ||
615 | static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ | ||
616 | const char *buf, size_t count) \ | ||
617 | { \ | ||
618 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
619 | } \ | ||
620 | static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \ | ||
621 | const char *buf, size_t count) \ | ||
622 | { \ | ||
623 | return set_fan_div(dev, buf, count, offset - 1); \ | ||
624 | } \ | ||
625 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \ | ||
626 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
627 | show_fan_##offset##_min, set_fan_##offset##_min); \ | ||
628 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | ||
629 | show_fan_##offset##_div, set_fan_##offset##_div); | ||
630 | 626 | ||
631 | show_fan_offset(1); | 627 | show_fan_offset(1); |
632 | show_fan_offset(2); | 628 | show_fan_offset(2); |
633 | show_fan_offset(3); | 629 | show_fan_offset(3); |
634 | 630 | ||
635 | #define show_pwm_offset(offset) \ | 631 | #define show_pwm_offset(offset) \ |
636 | static ssize_t show_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \ | 632 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ |
637 | char *buf) \ | 633 | show_pwm_enable, set_pwm_enable, offset - 1); \ |
638 | { \ | 634 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ |
639 | return show_pwm_enable(dev, buf, offset - 1); \ | 635 | show_pwm, set_pwm, offset - 1); |
640 | } \ | ||
641 | static ssize_t show_pwm##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | ||
642 | { \ | ||
643 | return show_pwm(dev, buf, offset - 1); \ | ||
644 | } \ | ||
645 | static ssize_t set_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \ | ||
646 | const char *buf, size_t count) \ | ||
647 | { \ | ||
648 | return set_pwm_enable(dev, buf, count, offset - 1); \ | ||
649 | } \ | ||
650 | static ssize_t set_pwm##offset (struct device *dev, struct device_attribute *attr, \ | ||
651 | const char *buf, size_t count) \ | ||
652 | { \ | ||
653 | return set_pwm(dev, buf, count, offset - 1); \ | ||
654 | } \ | ||
655 | static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ | ||
656 | show_pwm##offset##_enable, \ | ||
657 | set_pwm##offset##_enable); \ | ||
658 | static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ | ||
659 | show_pwm##offset , set_pwm##offset ); | ||
660 | 636 | ||
661 | show_pwm_offset(1); | 637 | show_pwm_offset(1); |
662 | show_pwm_offset(2); | 638 | show_pwm_offset(2); |
@@ -666,7 +642,7 @@ show_pwm_offset(3); | |||
666 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 642 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
667 | { | 643 | { |
668 | struct it87_data *data = it87_update_device(dev); | 644 | struct it87_data *data = it87_update_device(dev); |
669 | return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); | 645 | return sprintf(buf, "%u\n", data->alarms); |
670 | } | 646 | } |
671 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 647 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
672 | 648 | ||
@@ -864,60 +840,60 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
864 | it87_init_client(new_client, data); | 840 | it87_init_client(new_client, data); |
865 | 841 | ||
866 | /* Register sysfs hooks */ | 842 | /* Register sysfs hooks */ |
867 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 843 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); |
868 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 844 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); |
869 | device_create_file(&new_client->dev, &dev_attr_in2_input); | 845 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); |
870 | device_create_file(&new_client->dev, &dev_attr_in3_input); | 846 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); |
871 | device_create_file(&new_client->dev, &dev_attr_in4_input); | 847 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); |
872 | device_create_file(&new_client->dev, &dev_attr_in5_input); | 848 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); |
873 | device_create_file(&new_client->dev, &dev_attr_in6_input); | 849 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); |
874 | device_create_file(&new_client->dev, &dev_attr_in7_input); | 850 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); |
875 | device_create_file(&new_client->dev, &dev_attr_in8_input); | 851 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); |
876 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 852 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); |
877 | device_create_file(&new_client->dev, &dev_attr_in1_min); | 853 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr); |
878 | device_create_file(&new_client->dev, &dev_attr_in2_min); | 854 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr); |
879 | device_create_file(&new_client->dev, &dev_attr_in3_min); | 855 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr); |
880 | device_create_file(&new_client->dev, &dev_attr_in4_min); | 856 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr); |
881 | device_create_file(&new_client->dev, &dev_attr_in5_min); | 857 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr); |
882 | device_create_file(&new_client->dev, &dev_attr_in6_min); | 858 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr); |
883 | device_create_file(&new_client->dev, &dev_attr_in7_min); | 859 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr); |
884 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 860 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); |
885 | device_create_file(&new_client->dev, &dev_attr_in1_max); | 861 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr); |
886 | device_create_file(&new_client->dev, &dev_attr_in2_max); | 862 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr); |
887 | device_create_file(&new_client->dev, &dev_attr_in3_max); | 863 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr); |
888 | device_create_file(&new_client->dev, &dev_attr_in4_max); | 864 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr); |
889 | device_create_file(&new_client->dev, &dev_attr_in5_max); | 865 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr); |
890 | device_create_file(&new_client->dev, &dev_attr_in6_max); | 866 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr); |
891 | device_create_file(&new_client->dev, &dev_attr_in7_max); | 867 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr); |
892 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 868 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); |
893 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 869 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); |
894 | device_create_file(&new_client->dev, &dev_attr_temp3_input); | 870 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr); |
895 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 871 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); |
896 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 872 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); |
897 | device_create_file(&new_client->dev, &dev_attr_temp3_max); | 873 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr); |
898 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | 874 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); |
899 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 875 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); |
900 | device_create_file(&new_client->dev, &dev_attr_temp3_min); | 876 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr); |
901 | device_create_file(&new_client->dev, &dev_attr_temp1_type); | 877 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_type.dev_attr); |
902 | device_create_file(&new_client->dev, &dev_attr_temp2_type); | 878 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_type.dev_attr); |
903 | device_create_file(&new_client->dev, &dev_attr_temp3_type); | 879 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_type.dev_attr); |
904 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 880 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr); |
905 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | 881 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_input.dev_attr); |
906 | device_create_file(&new_client->dev, &dev_attr_fan3_input); | 882 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_input.dev_attr); |
907 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 883 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_min.dev_attr); |
908 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | 884 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_min.dev_attr); |
909 | device_create_file(&new_client->dev, &dev_attr_fan3_min); | 885 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_min.dev_attr); |
910 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 886 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_div.dev_attr); |
911 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | 887 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_div.dev_attr); |
912 | device_create_file(&new_client->dev, &dev_attr_fan3_div); | 888 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_div.dev_attr); |
913 | device_create_file(&new_client->dev, &dev_attr_alarms); | 889 | device_create_file(&new_client->dev, &dev_attr_alarms); |
914 | if (enable_pwm_interface) { | 890 | if (enable_pwm_interface) { |
915 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); | 891 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm1_enable.dev_attr); |
916 | device_create_file(&new_client->dev, &dev_attr_pwm2_enable); | 892 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm2_enable.dev_attr); |
917 | device_create_file(&new_client->dev, &dev_attr_pwm3_enable); | 893 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm3_enable.dev_attr); |
918 | device_create_file(&new_client->dev, &dev_attr_pwm1); | 894 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr); |
919 | device_create_file(&new_client->dev, &dev_attr_pwm2); | 895 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr); |
920 | device_create_file(&new_client->dev, &dev_attr_pwm3); | 896 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr); |
921 | } | 897 | } |
922 | 898 | ||
923 | if (data->type == it8712) { | 899 | if (data->type == it8712) { |
@@ -954,7 +930,7 @@ static int it87_detach_client(struct i2c_client *client) | |||
954 | return 0; | 930 | return 0; |
955 | } | 931 | } |
956 | 932 | ||
957 | /* The SMBus locks itself, but ISA access must be locked explicitely! | 933 | /* The SMBus locks itself, but ISA access must be locked explicitly! |
958 | We don't want to lock the whole ISA bus, so we lock each client | 934 | We don't want to lock the whole ISA bus, so we lock each client |
959 | separately. | 935 | separately. |
960 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, | 936 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, |
@@ -974,7 +950,7 @@ static int it87_read_value(struct i2c_client *client, u8 reg) | |||
974 | return i2c_smbus_read_byte_data(client, reg); | 950 | return i2c_smbus_read_byte_data(client, reg); |
975 | } | 951 | } |
976 | 952 | ||
977 | /* The SMBus locks itself, but ISA access muse be locked explicitely! | 953 | /* The SMBus locks itself, but ISA access muse be locked explicitly! |
978 | We don't want to lock the whole ISA bus, so we lock each client | 954 | We don't want to lock the whole ISA bus, so we lock each client |
979 | separately. | 955 | separately. |
980 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, | 956 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, |
diff --git a/drivers/i2c/chips/lm63.c b/drivers/i2c/chips/lm63.c index bc68e031392b..7c6f9ea5a254 100644 --- a/drivers/i2c/chips/lm63.c +++ b/drivers/i2c/chips/lm63.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm63.c - driver for the National Semiconductor LM63 temperature sensor | 2 | * lm63.c - driver for the National Semiconductor LM63 temperature sensor |
3 | * with integrated fan control | 3 | * with integrated fan control |
4 | * Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2004-2005 Jean Delvare <khali@linux-fr.org> |
5 | * Based on the lm90 driver. | 5 | * Based on the lm90 driver. |
6 | * | 6 | * |
7 | * The LM63 is a sensor chip made by National Semiconductor. It measures | 7 | * The LM63 is a sensor chip made by National Semiconductor. It measures |
@@ -37,13 +37,13 @@ | |||
37 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 37 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
38 | */ | 38 | */ |
39 | 39 | ||
40 | #include <linux/config.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/init.h> | 41 | #include <linux/init.h> |
43 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
44 | #include <linux/jiffies.h> | 43 | #include <linux/jiffies.h> |
45 | #include <linux/i2c.h> | 44 | #include <linux/i2c.h> |
46 | #include <linux/i2c-sensor.h> | 45 | #include <linux/i2c-sensor.h> |
46 | #include <linux/hwmon-sysfs.h> | ||
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Addresses to scan | 49 | * Addresses to scan |
@@ -99,9 +99,9 @@ SENSORS_INSMOD_1(lm63); | |||
99 | * Conversions and various macros | 99 | * Conversions and various macros |
100 | * For tachometer counts, the LM63 uses 16-bit values. | 100 | * For tachometer counts, the LM63 uses 16-bit values. |
101 | * For local temperature and high limit, remote critical limit and hysteresis | 101 | * For local temperature and high limit, remote critical limit and hysteresis |
102 | * value, it uses signed 8-bit values with LSB = 1 degree Celcius. | 102 | * value, it uses signed 8-bit values with LSB = 1 degree Celsius. |
103 | * For remote temperature, low and high limits, it uses signed 11-bit values | 103 | * For remote temperature, low and high limits, it uses signed 11-bit values |
104 | * with LSB = 0.125 degree Celcius, left-justified in 16-bit registers. | 104 | * with LSB = 0.125 degree Celsius, left-justified in 16-bit registers. |
105 | */ | 105 | */ |
106 | 106 | ||
107 | #define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \ | 107 | #define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \ |
@@ -158,16 +158,16 @@ struct lm63_data { | |||
158 | 158 | ||
159 | /* registers values */ | 159 | /* registers values */ |
160 | u8 config, config_fan; | 160 | u8 config, config_fan; |
161 | u16 fan1_input; | 161 | u16 fan[2]; /* 0: input |
162 | u16 fan1_low; | 162 | 1: low limit */ |
163 | u8 pwm1_freq; | 163 | u8 pwm1_freq; |
164 | u8 pwm1_value; | 164 | u8 pwm1_value; |
165 | s8 temp1_input; | 165 | s8 temp8[3]; /* 0: local input |
166 | s8 temp1_high; | 166 | 1: local high limit |
167 | s16 temp2_input; | 167 | 2: remote critical limit */ |
168 | s16 temp2_high; | 168 | s16 temp11[3]; /* 0: remote input |
169 | s16 temp2_low; | 169 | 1: remote low limit |
170 | s8 temp2_crit; | 170 | 2: remote high limit */ |
171 | u8 temp2_crit_hyst; | 171 | u8 temp2_crit_hyst; |
172 | u8 alarms; | 172 | u8 alarms; |
173 | }; | 173 | }; |
@@ -176,33 +176,33 @@ struct lm63_data { | |||
176 | * Sysfs callback functions and files | 176 | * Sysfs callback functions and files |
177 | */ | 177 | */ |
178 | 178 | ||
179 | #define show_fan(value) \ | 179 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, |
180 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | 180 | char *buf) |
181 | { \ | 181 | { |
182 | struct lm63_data *data = lm63_update_device(dev); \ | 182 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
183 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->value)); \ | 183 | struct lm63_data *data = lm63_update_device(dev); |
184 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index])); | ||
184 | } | 185 | } |
185 | show_fan(fan1_input); | ||
186 | show_fan(fan1_low); | ||
187 | 186 | ||
188 | static ssize_t set_fan1_low(struct device *dev, struct device_attribute *attr, const char *buf, | 187 | static ssize_t set_fan(struct device *dev, struct device_attribute *dummy, |
189 | size_t count) | 188 | const char *buf, size_t count) |
190 | { | 189 | { |
191 | struct i2c_client *client = to_i2c_client(dev); | 190 | struct i2c_client *client = to_i2c_client(dev); |
192 | struct lm63_data *data = i2c_get_clientdata(client); | 191 | struct lm63_data *data = i2c_get_clientdata(client); |
193 | unsigned long val = simple_strtoul(buf, NULL, 10); | 192 | unsigned long val = simple_strtoul(buf, NULL, 10); |
194 | 193 | ||
195 | down(&data->update_lock); | 194 | down(&data->update_lock); |
196 | data->fan1_low = FAN_TO_REG(val); | 195 | data->fan[1] = FAN_TO_REG(val); |
197 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, | 196 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, |
198 | data->fan1_low & 0xFF); | 197 | data->fan[1] & 0xFF); |
199 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, | 198 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, |
200 | data->fan1_low >> 8); | 199 | data->fan[1] >> 8); |
201 | up(&data->update_lock); | 200 | up(&data->update_lock); |
202 | return count; | 201 | return count; |
203 | } | 202 | } |
204 | 203 | ||
205 | static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf) | 204 | static ssize_t show_pwm1(struct device *dev, struct device_attribute *dummy, |
205 | char *buf) | ||
206 | { | 206 | { |
207 | struct lm63_data *data = lm63_update_device(dev); | 207 | struct lm63_data *data = lm63_update_device(dev); |
208 | return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ? | 208 | return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ? |
@@ -210,7 +210,8 @@ static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char | |||
210 | (2 * data->pwm1_freq)); | 210 | (2 * data->pwm1_freq)); |
211 | } | 211 | } |
212 | 212 | ||
213 | static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 213 | static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy, |
214 | const char *buf, size_t count) | ||
214 | { | 215 | { |
215 | struct i2c_client *client = to_i2c_client(dev); | 216 | struct i2c_client *client = to_i2c_client(dev); |
216 | struct lm63_data *data = i2c_get_clientdata(client); | 217 | struct lm63_data *data = i2c_get_clientdata(client); |
@@ -229,77 +230,83 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const | |||
229 | return count; | 230 | return count; |
230 | } | 231 | } |
231 | 232 | ||
232 | static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *attr, char *buf) | 233 | static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *dummy, |
234 | char *buf) | ||
233 | { | 235 | { |
234 | struct lm63_data *data = lm63_update_device(dev); | 236 | struct lm63_data *data = lm63_update_device(dev); |
235 | return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); | 237 | return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); |
236 | } | 238 | } |
237 | 239 | ||
238 | #define show_temp8(value) \ | 240 | static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, |
239 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | 241 | char *buf) |
240 | { \ | 242 | { |
241 | struct lm63_data *data = lm63_update_device(dev); \ | 243 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
242 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->value)); \ | 244 | struct lm63_data *data = lm63_update_device(dev); |
245 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index])); | ||
243 | } | 246 | } |
244 | #define show_temp11(value) \ | 247 | |
245 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | 248 | static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy, |
246 | { \ | 249 | const char *buf, size_t count) |
247 | struct lm63_data *data = lm63_update_device(dev); \ | 250 | { |
248 | return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->value)); \ | 251 | struct i2c_client *client = to_i2c_client(dev); |
252 | struct lm63_data *data = i2c_get_clientdata(client); | ||
253 | long val = simple_strtol(buf, NULL, 10); | ||
254 | |||
255 | down(&data->update_lock); | ||
256 | data->temp8[1] = TEMP8_TO_REG(val); | ||
257 | i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); | ||
258 | up(&data->update_lock); | ||
259 | return count; | ||
249 | } | 260 | } |
250 | show_temp8(temp1_input); | 261 | |
251 | show_temp8(temp1_high); | 262 | static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr, |
252 | show_temp11(temp2_input); | 263 | char *buf) |
253 | show_temp11(temp2_high); | 264 | { |
254 | show_temp11(temp2_low); | 265 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
255 | show_temp8(temp2_crit); | 266 | struct lm63_data *data = lm63_update_device(dev); |
256 | 267 | return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->temp11[attr->index])); | |
257 | #define set_temp8(value, reg) \ | ||
258 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ | ||
259 | size_t count) \ | ||
260 | { \ | ||
261 | struct i2c_client *client = to_i2c_client(dev); \ | ||
262 | struct lm63_data *data = i2c_get_clientdata(client); \ | ||
263 | long val = simple_strtol(buf, NULL, 10); \ | ||
264 | \ | ||
265 | down(&data->update_lock); \ | ||
266 | data->value = TEMP8_TO_REG(val); \ | ||
267 | i2c_smbus_write_byte_data(client, reg, data->value); \ | ||
268 | up(&data->update_lock); \ | ||
269 | return count; \ | ||
270 | } | 268 | } |
271 | #define set_temp11(value, reg_msb, reg_lsb) \ | 269 | |
272 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ | 270 | static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, |
273 | size_t count) \ | 271 | const char *buf, size_t count) |
274 | { \ | 272 | { |
275 | struct i2c_client *client = to_i2c_client(dev); \ | 273 | static const u8 reg[4] = { |
276 | struct lm63_data *data = i2c_get_clientdata(client); \ | 274 | LM63_REG_REMOTE_LOW_MSB, |
277 | long val = simple_strtol(buf, NULL, 10); \ | 275 | LM63_REG_REMOTE_LOW_LSB, |
278 | \ | 276 | LM63_REG_REMOTE_HIGH_MSB, |
279 | down(&data->update_lock); \ | 277 | LM63_REG_REMOTE_HIGH_LSB, |
280 | data->value = TEMP11_TO_REG(val); \ | 278 | }; |
281 | i2c_smbus_write_byte_data(client, reg_msb, data->value >> 8); \ | 279 | |
282 | i2c_smbus_write_byte_data(client, reg_lsb, data->value & 0xff); \ | 280 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
283 | up(&data->update_lock); \ | 281 | struct i2c_client *client = to_i2c_client(dev); |
284 | return count; \ | 282 | struct lm63_data *data = i2c_get_clientdata(client); |
283 | long val = simple_strtol(buf, NULL, 10); | ||
284 | int nr = attr->index; | ||
285 | |||
286 | down(&data->update_lock); | ||
287 | data->temp11[nr] = TEMP11_TO_REG(val); | ||
288 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], | ||
289 | data->temp11[nr] >> 8); | ||
290 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | ||
291 | data->temp11[nr] & 0xff); | ||
292 | up(&data->update_lock); | ||
293 | return count; | ||
285 | } | 294 | } |
286 | set_temp8(temp1_high, LM63_REG_LOCAL_HIGH); | ||
287 | set_temp11(temp2_high, LM63_REG_REMOTE_HIGH_MSB, LM63_REG_REMOTE_HIGH_LSB); | ||
288 | set_temp11(temp2_low, LM63_REG_REMOTE_LOW_MSB, LM63_REG_REMOTE_LOW_LSB); | ||
289 | 295 | ||
290 | /* Hysteresis register holds a relative value, while we want to present | 296 | /* Hysteresis register holds a relative value, while we want to present |
291 | an absolute to user-space */ | 297 | an absolute to user-space */ |
292 | static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf) | 298 | static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy, |
299 | char *buf) | ||
293 | { | 300 | { |
294 | struct lm63_data *data = lm63_update_device(dev); | 301 | struct lm63_data *data = lm63_update_device(dev); |
295 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp2_crit) | 302 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[2]) |
296 | - TEMP8_FROM_REG(data->temp2_crit_hyst)); | 303 | - TEMP8_FROM_REG(data->temp2_crit_hyst)); |
297 | } | 304 | } |
298 | 305 | ||
299 | /* And now the other way around, user-space provides an absolute | 306 | /* And now the other way around, user-space provides an absolute |
300 | hysteresis value and we have to store a relative one */ | 307 | hysteresis value and we have to store a relative one */ |
301 | static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf, | 308 | static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy, |
302 | size_t count) | 309 | const char *buf, size_t count) |
303 | { | 310 | { |
304 | struct i2c_client *client = to_i2c_client(dev); | 311 | struct i2c_client *client = to_i2c_client(dev); |
305 | struct lm63_data *data = i2c_get_clientdata(client); | 312 | struct lm63_data *data = i2c_get_clientdata(client); |
@@ -307,36 +314,37 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute * | |||
307 | long hyst; | 314 | long hyst; |
308 | 315 | ||
309 | down(&data->update_lock); | 316 | down(&data->update_lock); |
310 | hyst = TEMP8_FROM_REG(data->temp2_crit) - val; | 317 | hyst = TEMP8_FROM_REG(data->temp8[2]) - val; |
311 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, | 318 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, |
312 | HYST_TO_REG(hyst)); | 319 | HYST_TO_REG(hyst)); |
313 | up(&data->update_lock); | 320 | up(&data->update_lock); |
314 | return count; | 321 | return count; |
315 | } | 322 | } |
316 | 323 | ||
317 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 324 | static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, |
325 | char *buf) | ||
318 | { | 326 | { |
319 | struct lm63_data *data = lm63_update_device(dev); | 327 | struct lm63_data *data = lm63_update_device(dev); |
320 | return sprintf(buf, "%u\n", data->alarms); | 328 | return sprintf(buf, "%u\n", data->alarms); |
321 | } | 329 | } |
322 | 330 | ||
323 | static DEVICE_ATTR(fan1_input, S_IRUGO, show_fan1_input, NULL); | 331 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); |
324 | static DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan1_low, | 332 | static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan, |
325 | set_fan1_low); | 333 | set_fan, 1); |
326 | 334 | ||
327 | static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); | 335 | static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); |
328 | static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); | 336 | static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); |
329 | 337 | ||
330 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL); | 338 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); |
331 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp1_high, | 339 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, |
332 | set_temp1_high); | 340 | set_temp8, 1); |
333 | 341 | ||
334 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp2_input, NULL); | 342 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); |
335 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp2_low, | 343 | static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, |
336 | set_temp2_low); | 344 | set_temp11, 1); |
337 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp2_high, | 345 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, |
338 | set_temp2_high); | 346 | set_temp11, 2); |
339 | static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp2_crit, NULL); | 347 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp8, NULL, 2); |
340 | static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, | 348 | static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, |
341 | set_temp2_crit_hyst); | 349 | set_temp2_crit_hyst); |
342 | 350 | ||
@@ -430,17 +438,25 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
430 | 438 | ||
431 | /* Register sysfs hooks */ | 439 | /* Register sysfs hooks */ |
432 | if (data->config & 0x04) { /* tachometer enabled */ | 440 | if (data->config & 0x04) { /* tachometer enabled */ |
433 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 441 | device_create_file(&new_client->dev, |
434 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 442 | &sensor_dev_attr_fan1_input.dev_attr); |
443 | device_create_file(&new_client->dev, | ||
444 | &sensor_dev_attr_fan1_min.dev_attr); | ||
435 | } | 445 | } |
436 | device_create_file(&new_client->dev, &dev_attr_pwm1); | 446 | device_create_file(&new_client->dev, &dev_attr_pwm1); |
437 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); | 447 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); |
438 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 448 | device_create_file(&new_client->dev, |
439 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 449 | &sensor_dev_attr_temp1_input.dev_attr); |
440 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 450 | device_create_file(&new_client->dev, |
441 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 451 | &sensor_dev_attr_temp2_input.dev_attr); |
442 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 452 | device_create_file(&new_client->dev, |
443 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | 453 | &sensor_dev_attr_temp2_min.dev_attr); |
454 | device_create_file(&new_client->dev, | ||
455 | &sensor_dev_attr_temp1_max.dev_attr); | ||
456 | device_create_file(&new_client->dev, | ||
457 | &sensor_dev_attr_temp2_max.dev_attr); | ||
458 | device_create_file(&new_client->dev, | ||
459 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
444 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); | 460 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); |
445 | device_create_file(&new_client->dev, &dev_attr_alarms); | 461 | device_create_file(&new_client->dev, &dev_attr_alarms); |
446 | 462 | ||
@@ -511,14 +527,14 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
511 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 527 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
512 | if (data->config & 0x04) { /* tachometer enabled */ | 528 | if (data->config & 0x04) { /* tachometer enabled */ |
513 | /* order matters for fan1_input */ | 529 | /* order matters for fan1_input */ |
514 | data->fan1_input = i2c_smbus_read_byte_data(client, | 530 | data->fan[0] = i2c_smbus_read_byte_data(client, |
515 | LM63_REG_TACH_COUNT_LSB) & 0xFC; | 531 | LM63_REG_TACH_COUNT_LSB) & 0xFC; |
516 | data->fan1_input |= i2c_smbus_read_byte_data(client, | 532 | data->fan[0] |= i2c_smbus_read_byte_data(client, |
517 | LM63_REG_TACH_COUNT_MSB) << 8; | 533 | LM63_REG_TACH_COUNT_MSB) << 8; |
518 | data->fan1_low = (i2c_smbus_read_byte_data(client, | 534 | data->fan[1] = (i2c_smbus_read_byte_data(client, |
519 | LM63_REG_TACH_LIMIT_LSB) & 0xFC) | 535 | LM63_REG_TACH_LIMIT_LSB) & 0xFC) |
520 | | (i2c_smbus_read_byte_data(client, | 536 | | (i2c_smbus_read_byte_data(client, |
521 | LM63_REG_TACH_LIMIT_MSB) << 8); | 537 | LM63_REG_TACH_LIMIT_MSB) << 8); |
522 | } | 538 | } |
523 | 539 | ||
524 | data->pwm1_freq = i2c_smbus_read_byte_data(client, | 540 | data->pwm1_freq = i2c_smbus_read_byte_data(client, |
@@ -528,26 +544,26 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
528 | data->pwm1_value = i2c_smbus_read_byte_data(client, | 544 | data->pwm1_value = i2c_smbus_read_byte_data(client, |
529 | LM63_REG_PWM_VALUE); | 545 | LM63_REG_PWM_VALUE); |
530 | 546 | ||
531 | data->temp1_input = i2c_smbus_read_byte_data(client, | 547 | data->temp8[0] = i2c_smbus_read_byte_data(client, |
532 | LM63_REG_LOCAL_TEMP); | 548 | LM63_REG_LOCAL_TEMP); |
533 | data->temp1_high = i2c_smbus_read_byte_data(client, | 549 | data->temp8[1] = i2c_smbus_read_byte_data(client, |
534 | LM63_REG_LOCAL_HIGH); | 550 | LM63_REG_LOCAL_HIGH); |
535 | 551 | ||
536 | /* order matters for temp2_input */ | 552 | /* order matters for temp2_input */ |
537 | data->temp2_input = i2c_smbus_read_byte_data(client, | 553 | data->temp11[0] = i2c_smbus_read_byte_data(client, |
538 | LM63_REG_REMOTE_TEMP_MSB) << 8; | 554 | LM63_REG_REMOTE_TEMP_MSB) << 8; |
539 | data->temp2_input |= i2c_smbus_read_byte_data(client, | 555 | data->temp11[0] |= i2c_smbus_read_byte_data(client, |
540 | LM63_REG_REMOTE_TEMP_LSB); | 556 | LM63_REG_REMOTE_TEMP_LSB); |
541 | data->temp2_high = (i2c_smbus_read_byte_data(client, | 557 | data->temp11[1] = (i2c_smbus_read_byte_data(client, |
542 | LM63_REG_REMOTE_HIGH_MSB) << 8) | ||
543 | | i2c_smbus_read_byte_data(client, | ||
544 | LM63_REG_REMOTE_HIGH_LSB); | ||
545 | data->temp2_low = (i2c_smbus_read_byte_data(client, | ||
546 | LM63_REG_REMOTE_LOW_MSB) << 8) | 558 | LM63_REG_REMOTE_LOW_MSB) << 8) |
547 | | i2c_smbus_read_byte_data(client, | 559 | | i2c_smbus_read_byte_data(client, |
548 | LM63_REG_REMOTE_LOW_LSB); | 560 | LM63_REG_REMOTE_LOW_LSB); |
549 | data->temp2_crit = i2c_smbus_read_byte_data(client, | 561 | data->temp11[2] = (i2c_smbus_read_byte_data(client, |
550 | LM63_REG_REMOTE_TCRIT); | 562 | LM63_REG_REMOTE_HIGH_MSB) << 8) |
563 | | i2c_smbus_read_byte_data(client, | ||
564 | LM63_REG_REMOTE_HIGH_LSB); | ||
565 | data->temp8[2] = i2c_smbus_read_byte_data(client, | ||
566 | LM63_REG_REMOTE_TCRIT); | ||
551 | data->temp2_crit_hyst = i2c_smbus_read_byte_data(client, | 567 | data->temp2_crit_hyst = i2c_smbus_read_byte_data(client, |
552 | LM63_REG_REMOTE_TCRIT_HYST); | 568 | LM63_REG_REMOTE_TCRIT_HYST); |
553 | 569 | ||
diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c index 57c51ac37c04..5be164ed278e 100644 --- a/drivers/i2c/chips/lm75.c +++ b/drivers/i2c/chips/lm75.c | |||
@@ -18,7 +18,6 @@ | |||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/config.h> | ||
22 | #include <linux/module.h> | 21 | #include <linux/module.h> |
23 | #include <linux/init.h> | 22 | #include <linux/init.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/lm77.c b/drivers/i2c/chips/lm77.c index 9d15cd5189f6..b98f44952997 100644 --- a/drivers/i2c/chips/lm77.c +++ b/drivers/i2c/chips/lm77.c | |||
@@ -25,7 +25,6 @@ | |||
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <linux/config.h> | ||
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
31 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/lm78.c b/drivers/i2c/chips/lm78.c index 21b195ff3871..29241469dcba 100644 --- a/drivers/i2c/chips/lm78.c +++ b/drivers/i2c/chips/lm78.c | |||
@@ -18,7 +18,6 @@ | |||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/config.h> | ||
22 | #include <linux/module.h> | 21 | #include <linux/module.h> |
23 | #include <linux/init.h> | 22 | #include <linux/init.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
@@ -671,7 +670,7 @@ static int lm78_detach_client(struct i2c_client *client) | |||
671 | return 0; | 670 | return 0; |
672 | } | 671 | } |
673 | 672 | ||
674 | /* The SMBus locks itself, but ISA access must be locked explicitely! | 673 | /* The SMBus locks itself, but ISA access must be locked explicitly! |
675 | We don't want to lock the whole ISA bus, so we lock each client | 674 | We don't want to lock the whole ISA bus, so we lock each client |
676 | separately. | 675 | separately. |
677 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, | 676 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, |
@@ -690,7 +689,7 @@ static int lm78_read_value(struct i2c_client *client, u8 reg) | |||
690 | return i2c_smbus_read_byte_data(client, reg); | 689 | return i2c_smbus_read_byte_data(client, reg); |
691 | } | 690 | } |
692 | 691 | ||
693 | /* The SMBus locks itself, but ISA access muse be locked explicitely! | 692 | /* The SMBus locks itself, but ISA access muse be locked explicitly! |
694 | We don't want to lock the whole ISA bus, so we lock each client | 693 | We don't want to lock the whole ISA bus, so we lock each client |
695 | separately. | 694 | separately. |
696 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, | 695 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, |
diff --git a/drivers/i2c/chips/lm80.c b/drivers/i2c/chips/lm80.c index 404057b70e90..8100595feb44 100644 --- a/drivers/i2c/chips/lm80.c +++ b/drivers/i2c/chips/lm80.c | |||
@@ -21,7 +21,6 @@ | |||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | #include <linux/init.h> | 25 | #include <linux/init.h> |
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c index 4d6d7d21e14b..a49008b444c8 100644 --- a/drivers/i2c/chips/lm83.c +++ b/drivers/i2c/chips/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 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2003-2005 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 |
@@ -27,13 +27,13 @@ | |||
27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/module.h> | 30 | #include <linux/module.h> |
32 | #include <linux/init.h> | 31 | #include <linux/init.h> |
33 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
34 | #include <linux/jiffies.h> | 33 | #include <linux/jiffies.h> |
35 | #include <linux/i2c.h> | 34 | #include <linux/i2c.h> |
36 | #include <linux/i2c-sensor.h> | 35 | #include <linux/i2c-sensor.h> |
36 | #include <linux/hwmon-sysfs.h> | ||
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Addresses to scan | 39 | * Addresses to scan |
@@ -81,7 +81,7 @@ SENSORS_INSMOD_1(lm83); | |||
81 | 81 | ||
82 | /* | 82 | /* |
83 | * Conversions and various macros | 83 | * Conversions and various macros |
84 | * The LM83 uses signed 8-bit values with LSB = 1 degree Celcius. | 84 | * The LM83 uses signed 8-bit values with LSB = 1 degree Celsius. |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #define TEMP_FROM_REG(val) ((val) * 1000) | 87 | #define TEMP_FROM_REG(val) ((val) * 1000) |
@@ -94,21 +94,20 @@ static const u8 LM83_REG_R_TEMP[] = { | |||
94 | LM83_REG_R_LOCAL_TEMP, | 94 | LM83_REG_R_LOCAL_TEMP, |
95 | LM83_REG_R_REMOTE1_TEMP, | 95 | LM83_REG_R_REMOTE1_TEMP, |
96 | LM83_REG_R_REMOTE2_TEMP, | 96 | LM83_REG_R_REMOTE2_TEMP, |
97 | LM83_REG_R_REMOTE3_TEMP | 97 | LM83_REG_R_REMOTE3_TEMP, |
98 | }; | ||
99 | |||
100 | static const u8 LM83_REG_R_HIGH[] = { | ||
101 | LM83_REG_R_LOCAL_HIGH, | 98 | LM83_REG_R_LOCAL_HIGH, |
102 | LM83_REG_R_REMOTE1_HIGH, | 99 | LM83_REG_R_REMOTE1_HIGH, |
103 | LM83_REG_R_REMOTE2_HIGH, | 100 | LM83_REG_R_REMOTE2_HIGH, |
104 | LM83_REG_R_REMOTE3_HIGH | 101 | LM83_REG_R_REMOTE3_HIGH, |
102 | LM83_REG_R_TCRIT, | ||
105 | }; | 103 | }; |
106 | 104 | ||
107 | static const u8 LM83_REG_W_HIGH[] = { | 105 | static const u8 LM83_REG_W_HIGH[] = { |
108 | LM83_REG_W_LOCAL_HIGH, | 106 | LM83_REG_W_LOCAL_HIGH, |
109 | LM83_REG_W_REMOTE1_HIGH, | 107 | LM83_REG_W_REMOTE1_HIGH, |
110 | LM83_REG_W_REMOTE2_HIGH, | 108 | LM83_REG_W_REMOTE2_HIGH, |
111 | LM83_REG_W_REMOTE3_HIGH | 109 | LM83_REG_W_REMOTE3_HIGH, |
110 | LM83_REG_W_TCRIT, | ||
112 | }; | 111 | }; |
113 | 112 | ||
114 | /* | 113 | /* |
@@ -144,9 +143,9 @@ struct lm83_data { | |||
144 | unsigned long last_updated; /* in jiffies */ | 143 | unsigned long last_updated; /* in jiffies */ |
145 | 144 | ||
146 | /* registers values */ | 145 | /* registers values */ |
147 | s8 temp_input[4]; | 146 | s8 temp[9]; /* 0..3: input 1-4, |
148 | s8 temp_high[4]; | 147 | 4..7: high limit 1-4, |
149 | s8 temp_crit; | 148 | 8 : critical limit */ |
150 | u16 alarms; /* bitvector, combined */ | 149 | u16 alarms; /* bitvector, combined */ |
151 | }; | 150 | }; |
152 | 151 | ||
@@ -154,65 +153,55 @@ struct lm83_data { | |||
154 | * Sysfs stuff | 153 | * Sysfs stuff |
155 | */ | 154 | */ |
156 | 155 | ||
157 | #define show_temp(suffix, value) \ | 156 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
158 | static ssize_t show_temp_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ | 157 | char *buf) |
159 | { \ | 158 | { |
160 | struct lm83_data *data = lm83_update_device(dev); \ | 159 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
161 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ | 160 | struct lm83_data *data = lm83_update_device(dev); |
161 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); | ||
162 | } | 162 | } |
163 | show_temp(input1, temp_input[0]); | 163 | |
164 | show_temp(input2, temp_input[1]); | 164 | static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, |
165 | show_temp(input3, temp_input[2]); | 165 | const char *buf, size_t count) |
166 | show_temp(input4, temp_input[3]); | 166 | { |
167 | show_temp(high1, temp_high[0]); | 167 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
168 | show_temp(high2, temp_high[1]); | 168 | struct i2c_client *client = to_i2c_client(dev); |
169 | show_temp(high3, temp_high[2]); | 169 | struct lm83_data *data = i2c_get_clientdata(client); |
170 | show_temp(high4, temp_high[3]); | 170 | long val = simple_strtol(buf, NULL, 10); |
171 | show_temp(crit, temp_crit); | 171 | int nr = attr->index; |
172 | 172 | ||
173 | #define set_temp(suffix, value, reg) \ | 173 | down(&data->update_lock); |
174 | static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ | 174 | data->temp[nr] = TEMP_TO_REG(val); |
175 | size_t count) \ | 175 | i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], |
176 | { \ | 176 | data->temp[nr]); |
177 | struct i2c_client *client = to_i2c_client(dev); \ | 177 | up(&data->update_lock); |
178 | struct lm83_data *data = i2c_get_clientdata(client); \ | 178 | return count; |
179 | long val = simple_strtol(buf, NULL, 10); \ | ||
180 | \ | ||
181 | down(&data->update_lock); \ | ||
182 | data->value = TEMP_TO_REG(val); \ | ||
183 | i2c_smbus_write_byte_data(client, reg, data->value); \ | ||
184 | up(&data->update_lock); \ | ||
185 | return count; \ | ||
186 | } | 179 | } |
187 | set_temp(high1, temp_high[0], LM83_REG_W_LOCAL_HIGH); | ||
188 | set_temp(high2, temp_high[1], LM83_REG_W_REMOTE1_HIGH); | ||
189 | set_temp(high3, temp_high[2], LM83_REG_W_REMOTE2_HIGH); | ||
190 | set_temp(high4, temp_high[3], LM83_REG_W_REMOTE3_HIGH); | ||
191 | set_temp(crit, temp_crit, LM83_REG_W_TCRIT); | ||
192 | 180 | ||
193 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 181 | static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, |
182 | char *buf) | ||
194 | { | 183 | { |
195 | struct lm83_data *data = lm83_update_device(dev); | 184 | struct lm83_data *data = lm83_update_device(dev); |
196 | return sprintf(buf, "%d\n", data->alarms); | 185 | return sprintf(buf, "%d\n", data->alarms); |
197 | } | 186 | } |
198 | 187 | ||
199 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); | 188 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
200 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); | 189 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); |
201 | static DEVICE_ATTR(temp3_input, S_IRUGO, show_temp_input3, NULL); | 190 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); |
202 | static DEVICE_ATTR(temp4_input, S_IRUGO, show_temp_input4, NULL); | 191 | static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); |
203 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, | 192 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, |
204 | set_temp_high1); | 193 | set_temp, 4); |
205 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, | 194 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp, |
206 | set_temp_high2); | 195 | set_temp, 5); |
207 | static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_high3, | 196 | static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp, |
208 | set_temp_high3); | 197 | set_temp, 6); |
209 | static DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp_high4, | 198 | static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp, |
210 | set_temp_high4); | 199 | set_temp, 7); |
211 | static DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit, NULL); | 200 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, 8); |
212 | static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit, NULL); | 201 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp, NULL, 8); |
213 | static DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp_crit, | 202 | static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp, |
214 | set_temp_crit); | 203 | set_temp, 8); |
215 | static DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp_crit, NULL); | 204 | static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8); |
216 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 205 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
217 | 206 | ||
218 | /* | 207 | /* |
@@ -323,18 +312,30 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
323 | */ | 312 | */ |
324 | 313 | ||
325 | /* Register sysfs hooks */ | 314 | /* Register sysfs hooks */ |
326 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 315 | device_create_file(&new_client->dev, |
327 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 316 | &sensor_dev_attr_temp1_input.dev_attr); |
328 | device_create_file(&new_client->dev, &dev_attr_temp3_input); | 317 | device_create_file(&new_client->dev, |
329 | device_create_file(&new_client->dev, &dev_attr_temp4_input); | 318 | &sensor_dev_attr_temp2_input.dev_attr); |
330 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 319 | device_create_file(&new_client->dev, |
331 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 320 | &sensor_dev_attr_temp3_input.dev_attr); |
332 | device_create_file(&new_client->dev, &dev_attr_temp3_max); | 321 | device_create_file(&new_client->dev, |
333 | device_create_file(&new_client->dev, &dev_attr_temp4_max); | 322 | &sensor_dev_attr_temp4_input.dev_attr); |
334 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); | 323 | device_create_file(&new_client->dev, |
335 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | 324 | &sensor_dev_attr_temp1_max.dev_attr); |
336 | device_create_file(&new_client->dev, &dev_attr_temp3_crit); | 325 | device_create_file(&new_client->dev, |
337 | device_create_file(&new_client->dev, &dev_attr_temp4_crit); | 326 | &sensor_dev_attr_temp2_max.dev_attr); |
327 | device_create_file(&new_client->dev, | ||
328 | &sensor_dev_attr_temp3_max.dev_attr); | ||
329 | device_create_file(&new_client->dev, | ||
330 | &sensor_dev_attr_temp4_max.dev_attr); | ||
331 | device_create_file(&new_client->dev, | ||
332 | &sensor_dev_attr_temp1_crit.dev_attr); | ||
333 | device_create_file(&new_client->dev, | ||
334 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
335 | device_create_file(&new_client->dev, | ||
336 | &sensor_dev_attr_temp3_crit.dev_attr); | ||
337 | device_create_file(&new_client->dev, | ||
338 | &sensor_dev_attr_temp4_crit.dev_attr); | ||
338 | device_create_file(&new_client->dev, &dev_attr_alarms); | 339 | device_create_file(&new_client->dev, &dev_attr_alarms); |
339 | 340 | ||
340 | return 0; | 341 | return 0; |
@@ -370,16 +371,11 @@ static struct lm83_data *lm83_update_device(struct device *dev) | |||
370 | int nr; | 371 | int nr; |
371 | 372 | ||
372 | dev_dbg(&client->dev, "Updating lm83 data.\n"); | 373 | dev_dbg(&client->dev, "Updating lm83 data.\n"); |
373 | for (nr = 0; nr < 4 ; nr++) { | 374 | for (nr = 0; nr < 9; nr++) { |
374 | data->temp_input[nr] = | 375 | data->temp[nr] = |
375 | i2c_smbus_read_byte_data(client, | 376 | i2c_smbus_read_byte_data(client, |
376 | LM83_REG_R_TEMP[nr]); | 377 | LM83_REG_R_TEMP[nr]); |
377 | data->temp_high[nr] = | ||
378 | i2c_smbus_read_byte_data(client, | ||
379 | LM83_REG_R_HIGH[nr]); | ||
380 | } | 378 | } |
381 | data->temp_crit = | ||
382 | i2c_smbus_read_byte_data(client, LM83_REG_R_TCRIT); | ||
383 | data->alarms = | 379 | data->alarms = |
384 | i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1) | 380 | i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1) |
385 | + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2) | 381 | + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2) |
diff --git a/drivers/i2c/chips/lm85.c b/drivers/i2c/chips/lm85.c index b1976775b4ba..b4d7fd418264 100644 --- a/drivers/i2c/chips/lm85.c +++ b/drivers/i2c/chips/lm85.c | |||
@@ -23,7 +23,6 @@ | |||
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/config.h> | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
@@ -285,8 +284,6 @@ static int ZONE_TO_REG( int zone ) | |||
285 | /* i2c-vid.h defines vid_from_reg() */ | 284 | /* i2c-vid.h defines vid_from_reg() */ |
286 | #define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) | 285 | #define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) |
287 | 286 | ||
288 | #define ALARMS_FROM_REG(val) (val) | ||
289 | |||
290 | /* Unlike some other drivers we DO NOT set initial limits. Use | 287 | /* Unlike some other drivers we DO NOT set initial limits. Use |
291 | * the config file to set limits. Some users have reported | 288 | * the config file to set limits. Some users have reported |
292 | * motherboards shutting down when we set limits in a previous | 289 | * motherboards shutting down when we set limits in a previous |
@@ -481,7 +478,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); | |||
481 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | 478 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) |
482 | { | 479 | { |
483 | struct lm85_data *data = lm85_update_device(dev); | 480 | struct lm85_data *data = lm85_update_device(dev); |
484 | return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); | 481 | return sprintf(buf, "%u\n", data->alarms); |
485 | } | 482 | } |
486 | 483 | ||
487 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | 484 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); |
diff --git a/drivers/i2c/chips/lm87.c b/drivers/i2c/chips/lm87.c index 4372b61a0882..1921ed1af182 100644 --- a/drivers/i2c/chips/lm87.c +++ b/drivers/i2c/chips/lm87.c | |||
@@ -52,7 +52,6 @@ | |||
52 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 52 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
53 | */ | 53 | */ |
54 | 54 | ||
55 | #include <linux/config.h> | ||
56 | #include <linux/module.h> | 55 | #include <linux/module.h> |
57 | #include <linux/init.h> | 56 | #include <linux/init.h> |
58 | #include <linux/slab.h> | 57 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/lm90.c b/drivers/i2c/chips/lm90.c index 9b127a07f56b..a67dcadf7cb0 100644 --- a/drivers/i2c/chips/lm90.c +++ b/drivers/i2c/chips/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-2004 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2003-2005 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 |
@@ -19,7 +19,7 @@ | |||
19 | * Complete datasheets can be obtained from National's website at: | 19 | * Complete datasheets can be obtained from National's website at: |
20 | * http://www.national.com/pf/LM/LM89.html | 20 | * http://www.national.com/pf/LM/LM89.html |
21 | * http://www.national.com/pf/LM/LM99.html | 21 | * http://www.national.com/pf/LM/LM99.html |
22 | * Note that there is no way to differenciate between both chips. | 22 | * Note that there is no way to differentiate between both chips. |
23 | * | 23 | * |
24 | * This driver also supports the LM86, another sensor chip made by | 24 | * This driver also supports the LM86, another sensor chip made by |
25 | * National Semiconductor. It is exactly similar to the LM90 except it | 25 | * National Semiconductor. It is exactly similar to the LM90 except it |
@@ -39,7 +39,7 @@ | |||
39 | * chips made by Maxim. These chips are similar to the LM86. Complete | 39 | * chips made by Maxim. These chips are similar to the LM86. Complete |
40 | * datasheet can be obtained at Maxim's website at: | 40 | * datasheet can be obtained at Maxim's website at: |
41 | * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 | 41 | * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 |
42 | * Note that there is no easy way to differenciate between the three | 42 | * Note that there is no easy way to differentiate between the three |
43 | * variants. The extra address and features of the MAX6659 are not | 43 | * variants. The extra address and features of the MAX6659 are not |
44 | * supported by this driver. | 44 | * supported by this driver. |
45 | * | 45 | * |
@@ -70,13 +70,13 @@ | |||
70 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 70 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
71 | */ | 71 | */ |
72 | 72 | ||
73 | #include <linux/config.h> | ||
74 | #include <linux/module.h> | 73 | #include <linux/module.h> |
75 | #include <linux/init.h> | 74 | #include <linux/init.h> |
76 | #include <linux/slab.h> | 75 | #include <linux/slab.h> |
77 | #include <linux/jiffies.h> | 76 | #include <linux/jiffies.h> |
78 | #include <linux/i2c.h> | 77 | #include <linux/i2c.h> |
79 | #include <linux/i2c-sensor.h> | 78 | #include <linux/i2c-sensor.h> |
79 | #include <linux/hwmon-sysfs.h> | ||
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Addresses to scan | 82 | * Addresses to scan |
@@ -139,9 +139,9 @@ SENSORS_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461); | |||
139 | /* | 139 | /* |
140 | * Conversions and various macros | 140 | * Conversions and various macros |
141 | * For local temperatures and limits, critical limits and the hysteresis | 141 | * For local temperatures and limits, critical limits and the hysteresis |
142 | * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celcius. | 142 | * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celsius. |
143 | * For remote temperatures and limits, it uses signed 11-bit values with | 143 | * For remote temperatures and limits, it uses signed 11-bit values with |
144 | * LSB = 0.125 degree Celcius, left-justified in 16-bit registers. | 144 | * LSB = 0.125 degree Celsius, left-justified in 16-bit registers. |
145 | */ | 145 | */ |
146 | 146 | ||
147 | #define TEMP1_FROM_REG(val) ((val) * 1000) | 147 | #define TEMP1_FROM_REG(val) ((val) * 1000) |
@@ -206,9 +206,14 @@ struct lm90_data { | |||
206 | int kind; | 206 | int kind; |
207 | 207 | ||
208 | /* registers values */ | 208 | /* registers values */ |
209 | s8 temp_input1, temp_low1, temp_high1; /* local */ | 209 | s8 temp8[5]; /* 0: local input |
210 | s16 temp_input2, temp_low2, temp_high2; /* remote, combined */ | 210 | 1: local low limit |
211 | s8 temp_crit1, temp_crit2; | 211 | 2: local high limit |
212 | 3: local critical limit | ||
213 | 4: remote critical limit */ | ||
214 | s16 temp11[3]; /* 0: remote input | ||
215 | 1: remote low limit | ||
216 | 2: remote high limit */ | ||
212 | u8 temp_hyst; | 217 | u8 temp_hyst; |
213 | u8 alarms; /* bitvector */ | 218 | u8 alarms; /* bitvector */ |
214 | }; | 219 | }; |
@@ -217,75 +222,88 @@ struct lm90_data { | |||
217 | * Sysfs stuff | 222 | * Sysfs stuff |
218 | */ | 223 | */ |
219 | 224 | ||
220 | #define show_temp(value, converter) \ | 225 | static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, |
221 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | 226 | char *buf) |
222 | { \ | 227 | { |
223 | struct lm90_data *data = lm90_update_device(dev); \ | 228 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
224 | return sprintf(buf, "%d\n", converter(data->value)); \ | 229 | struct lm90_data *data = lm90_update_device(dev); |
230 | return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index])); | ||
231 | } | ||
232 | |||
233 | static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, | ||
234 | const char *buf, size_t count) | ||
235 | { | ||
236 | static const u8 reg[4] = { | ||
237 | LM90_REG_W_LOCAL_LOW, | ||
238 | LM90_REG_W_LOCAL_HIGH, | ||
239 | LM90_REG_W_LOCAL_CRIT, | ||
240 | LM90_REG_W_REMOTE_CRIT, | ||
241 | }; | ||
242 | |||
243 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
244 | struct i2c_client *client = to_i2c_client(dev); | ||
245 | struct lm90_data *data = i2c_get_clientdata(client); | ||
246 | long val = simple_strtol(buf, NULL, 10); | ||
247 | int nr = attr->index; | ||
248 | |||
249 | down(&data->update_lock); | ||
250 | if (data->kind == adt7461) | ||
251 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); | ||
252 | else | ||
253 | data->temp8[nr] = TEMP1_TO_REG(val); | ||
254 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); | ||
255 | up(&data->update_lock); | ||
256 | return count; | ||
225 | } | 257 | } |
226 | show_temp(temp_input1, TEMP1_FROM_REG); | 258 | |
227 | show_temp(temp_input2, TEMP2_FROM_REG); | 259 | static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr, |
228 | show_temp(temp_low1, TEMP1_FROM_REG); | 260 | char *buf) |
229 | show_temp(temp_low2, TEMP2_FROM_REG); | 261 | { |
230 | show_temp(temp_high1, TEMP1_FROM_REG); | 262 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
231 | show_temp(temp_high2, TEMP2_FROM_REG); | 263 | struct lm90_data *data = lm90_update_device(dev); |
232 | show_temp(temp_crit1, TEMP1_FROM_REG); | 264 | return sprintf(buf, "%d\n", TEMP2_FROM_REG(data->temp11[attr->index])); |
233 | show_temp(temp_crit2, TEMP1_FROM_REG); | ||
234 | |||
235 | #define set_temp1(value, reg) \ | ||
236 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ | ||
237 | size_t count) \ | ||
238 | { \ | ||
239 | struct i2c_client *client = to_i2c_client(dev); \ | ||
240 | struct lm90_data *data = i2c_get_clientdata(client); \ | ||
241 | long val = simple_strtol(buf, NULL, 10); \ | ||
242 | \ | ||
243 | down(&data->update_lock); \ | ||
244 | if (data->kind == adt7461) \ | ||
245 | data->value = TEMP1_TO_REG_ADT7461(val); \ | ||
246 | else \ | ||
247 | data->value = TEMP1_TO_REG(val); \ | ||
248 | i2c_smbus_write_byte_data(client, reg, data->value); \ | ||
249 | up(&data->update_lock); \ | ||
250 | return count; \ | ||
251 | } | 265 | } |
252 | #define set_temp2(value, regh, regl) \ | 266 | |
253 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ | 267 | static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, |
254 | size_t count) \ | 268 | const char *buf, size_t count) |
255 | { \ | 269 | { |
256 | struct i2c_client *client = to_i2c_client(dev); \ | 270 | static const u8 reg[4] = { |
257 | struct lm90_data *data = i2c_get_clientdata(client); \ | 271 | LM90_REG_W_REMOTE_LOWH, |
258 | long val = simple_strtol(buf, NULL, 10); \ | 272 | LM90_REG_W_REMOTE_LOWL, |
259 | \ | 273 | LM90_REG_W_REMOTE_HIGHH, |
260 | down(&data->update_lock); \ | 274 | LM90_REG_W_REMOTE_HIGHL, |
261 | if (data->kind == adt7461) \ | 275 | }; |
262 | data->value = TEMP2_TO_REG_ADT7461(val); \ | 276 | |
263 | else \ | 277 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
264 | data->value = TEMP2_TO_REG(val); \ | 278 | struct i2c_client *client = to_i2c_client(dev); |
265 | i2c_smbus_write_byte_data(client, regh, data->value >> 8); \ | 279 | struct lm90_data *data = i2c_get_clientdata(client); |
266 | i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \ | 280 | long val = simple_strtol(buf, NULL, 10); |
267 | up(&data->update_lock); \ | 281 | int nr = attr->index; |
268 | return count; \ | 282 | |
283 | down(&data->update_lock); | ||
284 | if (data->kind == adt7461) | ||
285 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); | ||
286 | else | ||
287 | data->temp11[nr] = TEMP2_TO_REG(val); | ||
288 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], | ||
289 | data->temp11[nr] >> 8); | ||
290 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | ||
291 | data->temp11[nr] & 0xff); | ||
292 | up(&data->update_lock); | ||
293 | return count; | ||
269 | } | 294 | } |
270 | set_temp1(temp_low1, LM90_REG_W_LOCAL_LOW); | 295 | |
271 | set_temp2(temp_low2, LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL); | 296 | static ssize_t show_temphyst(struct device *dev, struct device_attribute *devattr, |
272 | set_temp1(temp_high1, LM90_REG_W_LOCAL_HIGH); | 297 | char *buf) |
273 | set_temp2(temp_high2, LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL); | 298 | { |
274 | set_temp1(temp_crit1, LM90_REG_W_LOCAL_CRIT); | 299 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
275 | set_temp1(temp_crit2, LM90_REG_W_REMOTE_CRIT); | 300 | struct lm90_data *data = lm90_update_device(dev); |
276 | 301 | return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index]) | |
277 | #define show_temp_hyst(value, basereg) \ | 302 | - TEMP1_FROM_REG(data->temp_hyst)); |
278 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | ||
279 | { \ | ||
280 | struct lm90_data *data = lm90_update_device(dev); \ | ||
281 | return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \ | ||
282 | - TEMP1_FROM_REG(data->temp_hyst)); \ | ||
283 | } | 303 | } |
284 | show_temp_hyst(temp_hyst1, temp_crit1); | ||
285 | show_temp_hyst(temp_hyst2, temp_crit2); | ||
286 | 304 | ||
287 | static ssize_t set_temp_hyst1(struct device *dev, struct device_attribute *attr, const char *buf, | 305 | static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, |
288 | size_t count) | 306 | const char *buf, size_t count) |
289 | { | 307 | { |
290 | struct i2c_client *client = to_i2c_client(dev); | 308 | struct i2c_client *client = to_i2c_client(dev); |
291 | struct lm90_data *data = i2c_get_clientdata(client); | 309 | struct lm90_data *data = i2c_get_clientdata(client); |
@@ -293,36 +311,37 @@ static ssize_t set_temp_hyst1(struct device *dev, struct device_attribute *attr, | |||
293 | long hyst; | 311 | long hyst; |
294 | 312 | ||
295 | down(&data->update_lock); | 313 | down(&data->update_lock); |
296 | hyst = TEMP1_FROM_REG(data->temp_crit1) - val; | 314 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; |
297 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, | 315 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, |
298 | HYST_TO_REG(hyst)); | 316 | HYST_TO_REG(hyst)); |
299 | up(&data->update_lock); | 317 | up(&data->update_lock); |
300 | return count; | 318 | return count; |
301 | } | 319 | } |
302 | 320 | ||
303 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 321 | static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, |
322 | char *buf) | ||
304 | { | 323 | { |
305 | struct lm90_data *data = lm90_update_device(dev); | 324 | struct lm90_data *data = lm90_update_device(dev); |
306 | return sprintf(buf, "%d\n", data->alarms); | 325 | return sprintf(buf, "%d\n", data->alarms); |
307 | } | 326 | } |
308 | 327 | ||
309 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); | 328 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); |
310 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); | 329 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); |
311 | static DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_low1, | 330 | static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp8, |
312 | set_temp_low1); | 331 | set_temp8, 1); |
313 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_low2, | 332 | static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, |
314 | set_temp_low2); | 333 | set_temp11, 1); |
315 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, | 334 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, |
316 | set_temp_high1); | 335 | set_temp8, 2); |
317 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, | 336 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, |
318 | set_temp_high2); | 337 | set_temp11, 2); |
319 | static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit1, | 338 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp8, |
320 | set_temp_crit1); | 339 | set_temp8, 3); |
321 | static DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit2, | 340 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp8, |
322 | set_temp_crit2); | 341 | set_temp8, 4); |
323 | static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst1, | 342 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, |
324 | set_temp_hyst1); | 343 | set_temphyst, 3); |
325 | static DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_hyst2, NULL); | 344 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); |
326 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 345 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
327 | 346 | ||
328 | /* | 347 | /* |
@@ -481,16 +500,26 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
481 | lm90_init_client(new_client); | 500 | lm90_init_client(new_client); |
482 | 501 | ||
483 | /* Register sysfs hooks */ | 502 | /* Register sysfs hooks */ |
484 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 503 | device_create_file(&new_client->dev, |
485 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 504 | &sensor_dev_attr_temp1_input.dev_attr); |
486 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | 505 | device_create_file(&new_client->dev, |
487 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 506 | &sensor_dev_attr_temp2_input.dev_attr); |
488 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 507 | device_create_file(&new_client->dev, |
489 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 508 | &sensor_dev_attr_temp1_min.dev_attr); |
490 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); | 509 | device_create_file(&new_client->dev, |
491 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | 510 | &sensor_dev_attr_temp2_min.dev_attr); |
492 | device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); | 511 | device_create_file(&new_client->dev, |
493 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); | 512 | &sensor_dev_attr_temp1_max.dev_attr); |
513 | device_create_file(&new_client->dev, | ||
514 | &sensor_dev_attr_temp2_max.dev_attr); | ||
515 | device_create_file(&new_client->dev, | ||
516 | &sensor_dev_attr_temp1_crit.dev_attr); | ||
517 | device_create_file(&new_client->dev, | ||
518 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
519 | device_create_file(&new_client->dev, | ||
520 | &sensor_dev_attr_temp1_crit_hyst.dev_attr); | ||
521 | device_create_file(&new_client->dev, | ||
522 | &sensor_dev_attr_temp2_crit_hyst.dev_attr); | ||
494 | device_create_file(&new_client->dev, &dev_attr_alarms); | 523 | device_create_file(&new_client->dev, &dev_attr_alarms); |
495 | 524 | ||
496 | return 0; | 525 | return 0; |
@@ -541,16 +570,16 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
541 | u8 oldh, newh; | 570 | u8 oldh, newh; |
542 | 571 | ||
543 | dev_dbg(&client->dev, "Updating lm90 data.\n"); | 572 | dev_dbg(&client->dev, "Updating lm90 data.\n"); |
544 | data->temp_input1 = i2c_smbus_read_byte_data(client, | 573 | data->temp8[0] = i2c_smbus_read_byte_data(client, |
545 | LM90_REG_R_LOCAL_TEMP); | 574 | LM90_REG_R_LOCAL_TEMP); |
546 | data->temp_high1 = i2c_smbus_read_byte_data(client, | 575 | data->temp8[1] = i2c_smbus_read_byte_data(client, |
547 | LM90_REG_R_LOCAL_HIGH); | 576 | LM90_REG_R_LOCAL_LOW); |
548 | data->temp_low1 = i2c_smbus_read_byte_data(client, | 577 | data->temp8[2] = i2c_smbus_read_byte_data(client, |
549 | LM90_REG_R_LOCAL_LOW); | 578 | LM90_REG_R_LOCAL_HIGH); |
550 | data->temp_crit1 = i2c_smbus_read_byte_data(client, | 579 | data->temp8[3] = i2c_smbus_read_byte_data(client, |
551 | LM90_REG_R_LOCAL_CRIT); | 580 | LM90_REG_R_LOCAL_CRIT); |
552 | data->temp_crit2 = i2c_smbus_read_byte_data(client, | 581 | data->temp8[4] = i2c_smbus_read_byte_data(client, |
553 | LM90_REG_R_REMOTE_CRIT); | 582 | LM90_REG_R_REMOTE_CRIT); |
554 | data->temp_hyst = i2c_smbus_read_byte_data(client, | 583 | data->temp_hyst = i2c_smbus_read_byte_data(client, |
555 | LM90_REG_R_TCRIT_HYST); | 584 | LM90_REG_R_TCRIT_HYST); |
556 | 585 | ||
@@ -570,13 +599,13 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
570 | */ | 599 | */ |
571 | oldh = i2c_smbus_read_byte_data(client, | 600 | oldh = i2c_smbus_read_byte_data(client, |
572 | LM90_REG_R_REMOTE_TEMPH); | 601 | LM90_REG_R_REMOTE_TEMPH); |
573 | data->temp_input2 = i2c_smbus_read_byte_data(client, | 602 | data->temp11[0] = i2c_smbus_read_byte_data(client, |
574 | LM90_REG_R_REMOTE_TEMPL); | 603 | LM90_REG_R_REMOTE_TEMPL); |
575 | newh = i2c_smbus_read_byte_data(client, | 604 | newh = i2c_smbus_read_byte_data(client, |
576 | LM90_REG_R_REMOTE_TEMPH); | 605 | LM90_REG_R_REMOTE_TEMPH); |
577 | if (newh != oldh) { | 606 | if (newh != oldh) { |
578 | data->temp_input2 = i2c_smbus_read_byte_data(client, | 607 | data->temp11[0] = i2c_smbus_read_byte_data(client, |
579 | LM90_REG_R_REMOTE_TEMPL); | 608 | LM90_REG_R_REMOTE_TEMPL); |
580 | #ifdef DEBUG | 609 | #ifdef DEBUG |
581 | oldh = i2c_smbus_read_byte_data(client, | 610 | oldh = i2c_smbus_read_byte_data(client, |
582 | LM90_REG_R_REMOTE_TEMPH); | 611 | LM90_REG_R_REMOTE_TEMPH); |
@@ -586,16 +615,16 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
586 | "wrong.\n"); | 615 | "wrong.\n"); |
587 | #endif | 616 | #endif |
588 | } | 617 | } |
589 | data->temp_input2 |= (newh << 8); | 618 | data->temp11[0] |= (newh << 8); |
590 | 619 | ||
591 | data->temp_high2 = (i2c_smbus_read_byte_data(client, | 620 | data->temp11[1] = (i2c_smbus_read_byte_data(client, |
621 | LM90_REG_R_REMOTE_LOWH) << 8) + | ||
622 | i2c_smbus_read_byte_data(client, | ||
623 | LM90_REG_R_REMOTE_LOWL); | ||
624 | data->temp11[2] = (i2c_smbus_read_byte_data(client, | ||
592 | LM90_REG_R_REMOTE_HIGHH) << 8) + | 625 | LM90_REG_R_REMOTE_HIGHH) << 8) + |
593 | i2c_smbus_read_byte_data(client, | 626 | i2c_smbus_read_byte_data(client, |
594 | LM90_REG_R_REMOTE_HIGHL); | 627 | LM90_REG_R_REMOTE_HIGHL); |
595 | data->temp_low2 = (i2c_smbus_read_byte_data(client, | ||
596 | LM90_REG_R_REMOTE_LOWH) << 8) + | ||
597 | i2c_smbus_read_byte_data(client, | ||
598 | LM90_REG_R_REMOTE_LOWL); | ||
599 | data->alarms = i2c_smbus_read_byte_data(client, | 628 | data->alarms = i2c_smbus_read_byte_data(client, |
600 | LM90_REG_R_STATUS); | 629 | LM90_REG_R_STATUS); |
601 | 630 | ||
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index e771566dffa8..5e463c47bfbc 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -40,11 +40,8 @@ static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END }; | |||
40 | 40 | ||
41 | static struct i2c_client_address_data addr_data = { | 41 | static struct i2c_client_address_data addr_data = { |
42 | .normal_i2c = normal_addr, | 42 | .normal_i2c = normal_addr, |
43 | .normal_i2c_range = ignore, | ||
44 | .probe = ignore, | 43 | .probe = ignore, |
45 | .probe_range = ignore, | ||
46 | .ignore = ignore, | 44 | .ignore = ignore, |
47 | .ignore_range = ignore, | ||
48 | .force = ignore, | 45 | .force = ignore, |
49 | }; | 46 | }; |
50 | 47 | ||
diff --git a/drivers/i2c/chips/max1619.c b/drivers/i2c/chips/max1619.c index 30a196155fd9..bf553dcd97d6 100644 --- a/drivers/i2c/chips/max1619.c +++ b/drivers/i2c/chips/max1619.c | |||
@@ -26,7 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #include <linux/module.h> | 29 | #include <linux/module.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c new file mode 100644 index 000000000000..fe6b150ec4c2 --- /dev/null +++ b/drivers/i2c/chips/max6875.c | |||
@@ -0,0 +1,473 @@ | |||
1 | /* | ||
2 | max6875.c - driver for MAX6874/MAX6875 | ||
3 | |||
4 | Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com> | ||
5 | |||
6 | Based on i2c/chips/eeprom.c | ||
7 | |||
8 | The MAX6875 has two EEPROM sections: config and user. | ||
9 | At reset, the config EEPROM is read into the registers. | ||
10 | |||
11 | This driver make 3 binary files available in sysfs: | ||
12 | reg_config - direct access to the registers | ||
13 | eeprom_config - acesses configuration eeprom space | ||
14 | eeprom_user - free for application use | ||
15 | |||
16 | In our application, we put device serial & model numbers in user eeprom. | ||
17 | |||
18 | Notes: | ||
19 | 1) The datasheet says that register 0x44 / EEPROM 0x8044 should NOT | ||
20 | be overwritten, so the driver explicitly prevents that. | ||
21 | 2) It's a good idea to keep the config (0x45) locked in config EEPROM. | ||
22 | You can temporarily enable config writes by changing register 0x45. | ||
23 | |||
24 | This program is free software; you can redistribute it and/or modify | ||
25 | it under the terms of the GNU General Public License as published by | ||
26 | the Free Software Foundation; version 2 of the License. | ||
27 | */ | ||
28 | |||
29 | #include <linux/config.h> | ||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <linux/module.h> | ||
33 | #include <linux/slab.h> | ||
34 | #include <linux/sched.h> | ||
35 | #include <linux/delay.h> | ||
36 | #include <linux/i2c.h> | ||
37 | #include <linux/i2c-sensor.h> | ||
38 | |||
39 | /* Addresses to scan */ | ||
40 | static unsigned short normal_i2c[] = {0x50, 0x52, I2C_CLIENT_END}; | ||
41 | static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; | ||
42 | |||
43 | /* Insmod parameters */ | ||
44 | SENSORS_INSMOD_1(max6875); | ||
45 | |||
46 | /* this param will prevent 'accidental' writes to the eeprom */ | ||
47 | static int allow_write = 0; | ||
48 | module_param(allow_write, int, 0); | ||
49 | MODULE_PARM_DESC(allow_write, | ||
50 | "Enable write access:\n" | ||
51 | "*0: Read only\n" | ||
52 | " 1: Read/Write access"); | ||
53 | |||
54 | /* The MAX6875 can only read/write 16 bytes at a time */ | ||
55 | #define SLICE_SIZE 16 | ||
56 | #define SLICE_BITS 4 | ||
57 | |||
58 | /* CONFIG EEPROM is at addresses 0x8000 - 0x8045, registers are at 0 - 0x45 */ | ||
59 | #define CONFIG_EEPROM_BASE 0x8000 | ||
60 | #define CONFIG_EEPROM_SIZE 0x0046 | ||
61 | #define CONFIG_EEPROM_SLICES 5 | ||
62 | |||
63 | /* USER EEPROM is at addresses 0x8100 - 0x82FF */ | ||
64 | #define USER_EEPROM_BASE 0x8100 | ||
65 | #define USER_EEPROM_SIZE 0x0200 | ||
66 | #define USER_EEPROM_SLICES 32 | ||
67 | |||
68 | /* MAX6875 commands */ | ||
69 | #define MAX6875_CMD_BLOCK_WRITE 0x83 | ||
70 | #define MAX6875_CMD_BLOCK_READ 0x84 | ||
71 | #define MAX6875_CMD_REBOOT 0x88 | ||
72 | |||
73 | enum max6875_area_type { | ||
74 | max6875_register_config=0, | ||
75 | max6875_eeprom_config, | ||
76 | max6875_eeprom_user, | ||
77 | max6857_max | ||
78 | }; | ||
79 | |||
80 | struct eeprom_block { | ||
81 | enum max6875_area_type type; | ||
82 | u8 slices; | ||
83 | u32 size; | ||
84 | u32 valid; | ||
85 | u32 base; | ||
86 | unsigned long *updated; | ||
87 | u8 *data; | ||
88 | }; | ||
89 | |||
90 | /* Each client has this additional data */ | ||
91 | struct max6875_data { | ||
92 | struct i2c_client client; | ||
93 | struct semaphore update_lock; | ||
94 | struct eeprom_block blocks[max6857_max]; | ||
95 | /* the above structs point into the arrays below */ | ||
96 | u8 data[USER_EEPROM_SIZE + (CONFIG_EEPROM_SIZE*2)]; | ||
97 | unsigned long last_updated[USER_EEPROM_SLICES + (CONFIG_EEPROM_SLICES*2)]; | ||
98 | }; | ||
99 | |||
100 | static int max6875_attach_adapter(struct i2c_adapter *adapter); | ||
101 | static int max6875_detect(struct i2c_adapter *adapter, int address, int kind); | ||
102 | static int max6875_detach_client(struct i2c_client *client); | ||
103 | |||
104 | /* This is the driver that will be inserted */ | ||
105 | static struct i2c_driver max6875_driver = { | ||
106 | .owner = THIS_MODULE, | ||
107 | .name = "max6875", | ||
108 | .flags = I2C_DF_NOTIFY, | ||
109 | .attach_adapter = max6875_attach_adapter, | ||
110 | .detach_client = max6875_detach_client, | ||
111 | }; | ||
112 | |||
113 | static int max6875_update_slice(struct i2c_client *client, | ||
114 | struct eeprom_block *blk, | ||
115 | int slice) | ||
116 | { | ||
117 | struct max6875_data *data = i2c_get_clientdata(client); | ||
118 | int i, j, addr, count; | ||
119 | u8 rdbuf[SLICE_SIZE]; | ||
120 | int retval = 0; | ||
121 | |||
122 | if (slice >= blk->slices) | ||
123 | return -1; | ||
124 | |||
125 | down(&data->update_lock); | ||
126 | |||
127 | if (!(blk->valid & (1 << slice)) || | ||
128 | (jiffies - blk->updated[slice] > 300 * HZ) || | ||
129 | (jiffies < blk->updated[slice])) { | ||
130 | dev_dbg(&client->dev, "Starting eeprom update, slice %u, base %u\n", | ||
131 | slice, blk->base); | ||
132 | |||
133 | addr = blk->base + (slice << SLICE_BITS); | ||
134 | count = blk->size - (slice << SLICE_BITS); | ||
135 | if (count > SLICE_SIZE) { | ||
136 | count = SLICE_SIZE; | ||
137 | } | ||
138 | |||
139 | /* Preset the read address */ | ||
140 | if (addr < 0x100) { | ||
141 | /* select the register */ | ||
142 | if (i2c_smbus_write_byte(client, addr & 0xFF)) { | ||
143 | dev_dbg(&client->dev, "max6875 register select has failed!\n"); | ||
144 | retval = -1; | ||
145 | goto exit; | ||
146 | } | ||
147 | } else { | ||
148 | /* select the eeprom */ | ||
149 | if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) { | ||
150 | dev_dbg(&client->dev, "max6875 address set has failed!\n"); | ||
151 | retval = -1; | ||
152 | goto exit; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { | ||
157 | if (i2c_smbus_read_i2c_block_data(client, MAX6875_CMD_BLOCK_READ, | ||
158 | rdbuf) != SLICE_SIZE) | ||
159 | { | ||
160 | retval = -1; | ||
161 | goto exit; | ||
162 | } | ||
163 | |||
164 | memcpy(&blk->data[slice << SLICE_BITS], rdbuf, count); | ||
165 | } else { | ||
166 | for (i = 0; i < count; i++) { | ||
167 | j = i2c_smbus_read_byte(client); | ||
168 | if (j < 0) | ||
169 | { | ||
170 | retval = -1; | ||
171 | goto exit; | ||
172 | } | ||
173 | blk->data[(slice << SLICE_BITS) + i] = (u8) j; | ||
174 | } | ||
175 | } | ||
176 | blk->updated[slice] = jiffies; | ||
177 | blk->valid |= (1 << slice); | ||
178 | } | ||
179 | exit: | ||
180 | up(&data->update_lock); | ||
181 | return retval; | ||
182 | } | ||
183 | |||
184 | static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, size_t count, | ||
185 | enum max6875_area_type area_type) | ||
186 | { | ||
187 | struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); | ||
188 | struct max6875_data *data = i2c_get_clientdata(client); | ||
189 | struct eeprom_block *blk; | ||
190 | int slice; | ||
191 | |||
192 | blk = &data->blocks[area_type]; | ||
193 | |||
194 | if (off > blk->size) | ||
195 | return 0; | ||
196 | if (off + count > blk->size) | ||
197 | count = blk->size - off; | ||
198 | |||
199 | /* Only refresh slices which contain requested bytes */ | ||
200 | for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) | ||
201 | max6875_update_slice(client, blk, slice); | ||
202 | |||
203 | memcpy(buf, &blk->data[off], count); | ||
204 | |||
205 | return count; | ||
206 | } | ||
207 | |||
208 | static ssize_t max6875_user_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
209 | { | ||
210 | return max6875_read(kobj, buf, off, count, max6875_eeprom_user); | ||
211 | } | ||
212 | |||
213 | static ssize_t max6875_config_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
214 | { | ||
215 | return max6875_read(kobj, buf, off, count, max6875_eeprom_config); | ||
216 | } | ||
217 | |||
218 | static ssize_t max6875_cfgreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
219 | { | ||
220 | return max6875_read(kobj, buf, off, count, max6875_register_config); | ||
221 | } | ||
222 | |||
223 | |||
224 | static ssize_t max6875_write(struct kobject *kobj, char *buf, loff_t off, size_t count, | ||
225 | enum max6875_area_type area_type) | ||
226 | { | ||
227 | struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); | ||
228 | struct max6875_data *data = i2c_get_clientdata(client); | ||
229 | struct eeprom_block *blk; | ||
230 | int slice, addr, retval; | ||
231 | ssize_t sent = 0; | ||
232 | |||
233 | blk = &data->blocks[area_type]; | ||
234 | |||
235 | if (off > blk->size) | ||
236 | return 0; | ||
237 | if ((off + count) > blk->size) | ||
238 | count = blk->size - off; | ||
239 | |||
240 | if (down_interruptible(&data->update_lock)) | ||
241 | return -EAGAIN; | ||
242 | |||
243 | /* writing to a register is done with i2c_smbus_write_byte_data() */ | ||
244 | if (blk->type == max6875_register_config) { | ||
245 | for (sent = 0; sent < count; sent++) { | ||
246 | addr = off + sent; | ||
247 | if (addr == 0x44) | ||
248 | continue; | ||
249 | |||
250 | retval = i2c_smbus_write_byte_data(client, addr, buf[sent]); | ||
251 | } | ||
252 | } else { | ||
253 | int cmd, val; | ||
254 | |||
255 | /* We are writing to EEPROM */ | ||
256 | for (sent = 0; sent < count; sent++) { | ||
257 | addr = blk->base + off + sent; | ||
258 | cmd = addr >> 8; | ||
259 | val = (addr & 0xff) | (buf[sent] << 8); // reversed | ||
260 | |||
261 | if (addr == 0x8044) | ||
262 | continue; | ||
263 | |||
264 | retval = i2c_smbus_write_word_data(client, cmd, val); | ||
265 | |||
266 | if (retval) { | ||
267 | goto error_exit; | ||
268 | } | ||
269 | |||
270 | /* A write takes up to 11 ms */ | ||
271 | msleep(11); | ||
272 | } | ||
273 | } | ||
274 | |||
275 | /* Invalidate the scratch buffer */ | ||
276 | for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) | ||
277 | blk->valid &= ~(1 << slice); | ||
278 | |||
279 | error_exit: | ||
280 | up(&data->update_lock); | ||
281 | |||
282 | return sent; | ||
283 | } | ||
284 | |||
285 | static ssize_t max6875_user_write(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
286 | { | ||
287 | return max6875_write(kobj, buf, off, count, max6875_eeprom_user); | ||
288 | } | ||
289 | |||
290 | static ssize_t max6875_config_write(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
291 | { | ||
292 | return max6875_write(kobj, buf, off, count, max6875_eeprom_config); | ||
293 | } | ||
294 | |||
295 | static ssize_t max6875_cfgreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
296 | { | ||
297 | return max6875_write(kobj, buf, off, count, max6875_register_config); | ||
298 | } | ||
299 | |||
300 | static struct bin_attribute user_eeprom_attr = { | ||
301 | .attr = { | ||
302 | .name = "eeprom_user", | ||
303 | .mode = S_IRUGO | S_IWUSR | S_IWGRP, | ||
304 | .owner = THIS_MODULE, | ||
305 | }, | ||
306 | .size = USER_EEPROM_SIZE, | ||
307 | .read = max6875_user_read, | ||
308 | .write = max6875_user_write, | ||
309 | }; | ||
310 | |||
311 | static struct bin_attribute config_eeprom_attr = { | ||
312 | .attr = { | ||
313 | .name = "eeprom_config", | ||
314 | .mode = S_IRUGO | S_IWUSR, | ||
315 | .owner = THIS_MODULE, | ||
316 | }, | ||
317 | .size = CONFIG_EEPROM_SIZE, | ||
318 | .read = max6875_config_read, | ||
319 | .write = max6875_config_write, | ||
320 | }; | ||
321 | |||
322 | static struct bin_attribute config_register_attr = { | ||
323 | .attr = { | ||
324 | .name = "reg_config", | ||
325 | .mode = S_IRUGO | S_IWUSR, | ||
326 | .owner = THIS_MODULE, | ||
327 | }, | ||
328 | .size = CONFIG_EEPROM_SIZE, | ||
329 | .read = max6875_cfgreg_read, | ||
330 | .write = max6875_cfgreg_write, | ||
331 | }; | ||
332 | |||
333 | static int max6875_attach_adapter(struct i2c_adapter *adapter) | ||
334 | { | ||
335 | return i2c_detect(adapter, &addr_data, max6875_detect); | ||
336 | } | ||
337 | |||
338 | /* This function is called by i2c_detect */ | ||
339 | static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) | ||
340 | { | ||
341 | struct i2c_client *new_client; | ||
342 | struct max6875_data *data; | ||
343 | int err = 0; | ||
344 | |||
345 | /* There are three ways we can read the EEPROM data: | ||
346 | (1) I2C block reads (faster, but unsupported by most adapters) | ||
347 | (2) Consecutive byte reads (100% overhead) | ||
348 | (3) Regular byte data reads (200% overhead) | ||
349 | The third method is not implemented by this driver because all | ||
350 | known adapters support at least the second. */ | ||
351 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA | | ||
352 | I2C_FUNC_SMBUS_BYTE | | ||
353 | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) | ||
354 | goto exit; | ||
355 | |||
356 | /* OK. For now, we presume we have a valid client. We now create the | ||
357 | client structure, even though we cannot fill it completely yet. | ||
358 | But it allows us to access eeprom_{read,write}_value. */ | ||
359 | if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) { | ||
360 | err = -ENOMEM; | ||
361 | goto exit; | ||
362 | } | ||
363 | memset(data, 0, sizeof(struct max6875_data)); | ||
364 | |||
365 | new_client = &data->client; | ||
366 | i2c_set_clientdata(new_client, data); | ||
367 | new_client->addr = address; | ||
368 | new_client->adapter = adapter; | ||
369 | new_client->driver = &max6875_driver; | ||
370 | new_client->flags = 0; | ||
371 | |||
372 | /* Setup the user section */ | ||
373 | data->blocks[max6875_eeprom_user].type = max6875_eeprom_user; | ||
374 | data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES; | ||
375 | data->blocks[max6875_eeprom_user].size = USER_EEPROM_SIZE; | ||
376 | data->blocks[max6875_eeprom_user].base = USER_EEPROM_BASE; | ||
377 | data->blocks[max6875_eeprom_user].data = data->data; | ||
378 | data->blocks[max6875_eeprom_user].updated = data->last_updated; | ||
379 | |||
380 | /* Setup the config section */ | ||
381 | data->blocks[max6875_eeprom_config].type = max6875_eeprom_config; | ||
382 | data->blocks[max6875_eeprom_config].slices = CONFIG_EEPROM_SLICES; | ||
383 | data->blocks[max6875_eeprom_config].size = CONFIG_EEPROM_SIZE; | ||
384 | data->blocks[max6875_eeprom_config].base = CONFIG_EEPROM_BASE; | ||
385 | data->blocks[max6875_eeprom_config].data = &data->data[USER_EEPROM_SIZE]; | ||
386 | data->blocks[max6875_eeprom_config].updated = &data->last_updated[USER_EEPROM_SLICES]; | ||
387 | |||
388 | /* Setup the register section */ | ||
389 | data->blocks[max6875_register_config].type = max6875_register_config; | ||
390 | data->blocks[max6875_register_config].slices = CONFIG_EEPROM_SLICES; | ||
391 | data->blocks[max6875_register_config].size = CONFIG_EEPROM_SIZE; | ||
392 | data->blocks[max6875_register_config].base = 0; | ||
393 | data->blocks[max6875_register_config].data = &data->data[USER_EEPROM_SIZE+CONFIG_EEPROM_SIZE]; | ||
394 | data->blocks[max6875_register_config].updated = &data->last_updated[USER_EEPROM_SLICES+CONFIG_EEPROM_SLICES]; | ||
395 | |||
396 | /* Init the data */ | ||
397 | memset(data->data, 0xff, sizeof(data->data)); | ||
398 | |||
399 | /* Fill in the remaining client fields */ | ||
400 | strlcpy(new_client->name, "max6875", I2C_NAME_SIZE); | ||
401 | init_MUTEX(&data->update_lock); | ||
402 | |||
403 | /* Verify that the chip is really what we think it is */ | ||
404 | if ((max6875_update_slice(new_client, &data->blocks[max6875_eeprom_config], 4) < 0) || | ||
405 | (max6875_update_slice(new_client, &data->blocks[max6875_register_config], 4) < 0)) | ||
406 | goto exit_kfree; | ||
407 | |||
408 | /* 0x41,0x42 must be zero and 0x40 must match in eeprom and registers */ | ||
409 | if ((data->blocks[max6875_eeprom_config].data[0x41] != 0) || | ||
410 | (data->blocks[max6875_eeprom_config].data[0x42] != 0) || | ||
411 | (data->blocks[max6875_register_config].data[0x41] != 0) || | ||
412 | (data->blocks[max6875_register_config].data[0x42] != 0) || | ||
413 | (data->blocks[max6875_eeprom_config].data[0x40] != | ||
414 | data->blocks[max6875_register_config].data[0x40])) | ||
415 | goto exit_kfree; | ||
416 | |||
417 | /* Tell the I2C layer a new client has arrived */ | ||
418 | if ((err = i2c_attach_client(new_client))) | ||
419 | goto exit_kfree; | ||
420 | |||
421 | /* create the sysfs eeprom files with the correct permissions */ | ||
422 | if (allow_write == 0) { | ||
423 | user_eeprom_attr.attr.mode &= ~S_IWUGO; | ||
424 | user_eeprom_attr.write = NULL; | ||
425 | config_eeprom_attr.attr.mode &= ~S_IWUGO; | ||
426 | config_eeprom_attr.write = NULL; | ||
427 | config_register_attr.attr.mode &= ~S_IWUGO; | ||
428 | config_register_attr.write = NULL; | ||
429 | } | ||
430 | sysfs_create_bin_file(&new_client->dev.kobj, &user_eeprom_attr); | ||
431 | sysfs_create_bin_file(&new_client->dev.kobj, &config_eeprom_attr); | ||
432 | sysfs_create_bin_file(&new_client->dev.kobj, &config_register_attr); | ||
433 | |||
434 | return 0; | ||
435 | |||
436 | exit_kfree: | ||
437 | kfree(data); | ||
438 | exit: | ||
439 | return err; | ||
440 | } | ||
441 | |||
442 | static int max6875_detach_client(struct i2c_client *client) | ||
443 | { | ||
444 | int err; | ||
445 | |||
446 | err = i2c_detach_client(client); | ||
447 | if (err) { | ||
448 | dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); | ||
449 | return err; | ||
450 | } | ||
451 | |||
452 | kfree(i2c_get_clientdata(client)); | ||
453 | |||
454 | return 0; | ||
455 | } | ||
456 | |||
457 | static int __init max6875_init(void) | ||
458 | { | ||
459 | return i2c_add_driver(&max6875_driver); | ||
460 | } | ||
461 | |||
462 | static void __exit max6875_exit(void) | ||
463 | { | ||
464 | i2c_del_driver(&max6875_driver); | ||
465 | } | ||
466 | |||
467 | |||
468 | MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>"); | ||
469 | MODULE_DESCRIPTION("MAX6875 driver"); | ||
470 | MODULE_LICENSE("GPL"); | ||
471 | |||
472 | module_init(max6875_init); | ||
473 | module_exit(max6875_exit); | ||
diff --git a/drivers/i2c/chips/pc87360.c b/drivers/i2c/chips/pc87360.c index 65637b2cd170..876c68f3af31 100644 --- a/drivers/i2c/chips/pc87360.c +++ b/drivers/i2c/chips/pc87360.c | |||
@@ -33,7 +33,6 @@ | |||
33 | * the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F). | 33 | * the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F). |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <linux/config.h> | ||
37 | #include <linux/module.h> | 36 | #include <linux/module.h> |
38 | #include <linux/init.h> | 37 | #include <linux/init.h> |
39 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c new file mode 100644 index 000000000000..9f3ad45daae2 --- /dev/null +++ b/drivers/i2c/chips/pca9539.c | |||
@@ -0,0 +1,192 @@ | |||
1 | /* | ||
2 | pca9539.c - 16-bit I/O port with interrupt and reset | ||
3 | |||
4 | Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com> | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; version 2 of the License. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/i2c.h> | ||
15 | #include <linux/hwmon-sysfs.h> | ||
16 | #include <linux/i2c-sensor.h> | ||
17 | |||
18 | /* Addresses to scan */ | ||
19 | static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END}; | ||
20 | static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; | ||
21 | |||
22 | /* Insmod parameters */ | ||
23 | SENSORS_INSMOD_1(pca9539); | ||
24 | |||
25 | enum pca9539_cmd | ||
26 | { | ||
27 | PCA9539_INPUT_0 = 0, | ||
28 | PCA9539_INPUT_1 = 1, | ||
29 | PCA9539_OUTPUT_0 = 2, | ||
30 | PCA9539_OUTPUT_1 = 3, | ||
31 | PCA9539_INVERT_0 = 4, | ||
32 | PCA9539_INVERT_1 = 5, | ||
33 | PCA9539_DIRECTION_0 = 6, | ||
34 | PCA9539_DIRECTION_1 = 7, | ||
35 | }; | ||
36 | |||
37 | static int pca9539_attach_adapter(struct i2c_adapter *adapter); | ||
38 | static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind); | ||
39 | static int pca9539_detach_client(struct i2c_client *client); | ||
40 | |||
41 | /* This is the driver that will be inserted */ | ||
42 | static struct i2c_driver pca9539_driver = { | ||
43 | .owner = THIS_MODULE, | ||
44 | .name = "pca9539", | ||
45 | .flags = I2C_DF_NOTIFY, | ||
46 | .attach_adapter = pca9539_attach_adapter, | ||
47 | .detach_client = pca9539_detach_client, | ||
48 | }; | ||
49 | |||
50 | struct pca9539_data { | ||
51 | struct i2c_client client; | ||
52 | }; | ||
53 | |||
54 | /* following are the sysfs callback functions */ | ||
55 | static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr, | ||
56 | char *buf) | ||
57 | { | ||
58 | struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); | ||
59 | struct i2c_client *client = to_i2c_client(dev); | ||
60 | return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(client, | ||
61 | psa->index)); | ||
62 | } | ||
63 | |||
64 | static ssize_t pca9539_store(struct device *dev, struct device_attribute *attr, | ||
65 | const char *buf, size_t count) | ||
66 | { | ||
67 | struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); | ||
68 | struct i2c_client *client = to_i2c_client(dev); | ||
69 | unsigned long val = simple_strtoul(buf, NULL, 0); | ||
70 | if (val > 0xff) | ||
71 | return -EINVAL; | ||
72 | i2c_smbus_write_byte_data(client, psa->index, val); | ||
73 | return count; | ||
74 | } | ||
75 | |||
76 | /* Define the device attributes */ | ||
77 | |||
78 | #define PCA9539_ENTRY_RO(name, cmd_idx) \ | ||
79 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, pca9539_show, NULL, cmd_idx) | ||
80 | |||
81 | #define PCA9539_ENTRY_RW(name, cmd_idx) \ | ||
82 | static SENSOR_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, pca9539_show, \ | ||
83 | pca9539_store, cmd_idx) | ||
84 | |||
85 | PCA9539_ENTRY_RO(input0, PCA9539_INPUT_0); | ||
86 | PCA9539_ENTRY_RO(input1, PCA9539_INPUT_1); | ||
87 | PCA9539_ENTRY_RW(output0, PCA9539_OUTPUT_0); | ||
88 | PCA9539_ENTRY_RW(output1, PCA9539_OUTPUT_1); | ||
89 | PCA9539_ENTRY_RW(invert0, PCA9539_INVERT_0); | ||
90 | PCA9539_ENTRY_RW(invert1, PCA9539_INVERT_1); | ||
91 | PCA9539_ENTRY_RW(direction0, PCA9539_DIRECTION_0); | ||
92 | PCA9539_ENTRY_RW(direction1, PCA9539_DIRECTION_1); | ||
93 | |||
94 | static struct attribute *pca9539_attributes[] = { | ||
95 | &sensor_dev_attr_input0.dev_attr.attr, | ||
96 | &sensor_dev_attr_input1.dev_attr.attr, | ||
97 | &sensor_dev_attr_output0.dev_attr.attr, | ||
98 | &sensor_dev_attr_output1.dev_attr.attr, | ||
99 | &sensor_dev_attr_invert0.dev_attr.attr, | ||
100 | &sensor_dev_attr_invert1.dev_attr.attr, | ||
101 | &sensor_dev_attr_direction0.dev_attr.attr, | ||
102 | &sensor_dev_attr_direction1.dev_attr.attr, | ||
103 | NULL | ||
104 | }; | ||
105 | |||
106 | static struct attribute_group pca9539_defattr_group = { | ||
107 | .attrs = pca9539_attributes, | ||
108 | }; | ||
109 | |||
110 | static int pca9539_attach_adapter(struct i2c_adapter *adapter) | ||
111 | { | ||
112 | return i2c_detect(adapter, &addr_data, pca9539_detect); | ||
113 | } | ||
114 | |||
115 | /* This function is called by i2c_detect */ | ||
116 | static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind) | ||
117 | { | ||
118 | struct i2c_client *new_client; | ||
119 | struct pca9539_data *data; | ||
120 | int err = 0; | ||
121 | |||
122 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
123 | goto exit; | ||
124 | |||
125 | /* OK. For now, we presume we have a valid client. We now create the | ||
126 | client structure, even though we cannot fill it completely yet. */ | ||
127 | if (!(data = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { | ||
128 | err = -ENOMEM; | ||
129 | goto exit; | ||
130 | } | ||
131 | memset(data, 0, sizeof(struct pca9539_data)); | ||
132 | |||
133 | new_client = &data->client; | ||
134 | i2c_set_clientdata(new_client, data); | ||
135 | new_client->addr = address; | ||
136 | new_client->adapter = adapter; | ||
137 | new_client->driver = &pca9539_driver; | ||
138 | new_client->flags = 0; | ||
139 | |||
140 | /* Detection: the pca9539 only has 8 registers (0-7). | ||
141 | A read of 7 should succeed, but a read of 8 should fail. */ | ||
142 | if ((i2c_smbus_read_byte_data(new_client, 7) < 0) || | ||
143 | (i2c_smbus_read_byte_data(new_client, 8) >= 0)) | ||
144 | goto exit_kfree; | ||
145 | |||
146 | strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE); | ||
147 | |||
148 | /* Tell the I2C layer a new client has arrived */ | ||
149 | if ((err = i2c_attach_client(new_client))) | ||
150 | goto exit_kfree; | ||
151 | |||
152 | /* Register sysfs hooks (don't care about failure) */ | ||
153 | sysfs_create_group(&new_client->dev.kobj, &pca9539_defattr_group); | ||
154 | |||
155 | return 0; | ||
156 | |||
157 | exit_kfree: | ||
158 | kfree(data); | ||
159 | exit: | ||
160 | return err; | ||
161 | } | ||
162 | |||
163 | static int pca9539_detach_client(struct i2c_client *client) | ||
164 | { | ||
165 | int err; | ||
166 | |||
167 | if ((err = i2c_detach_client(client))) { | ||
168 | dev_err(&client->dev, "Client deregistration failed.\n"); | ||
169 | return err; | ||
170 | } | ||
171 | |||
172 | kfree(i2c_get_clientdata(client)); | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static int __init pca9539_init(void) | ||
177 | { | ||
178 | return i2c_add_driver(&pca9539_driver); | ||
179 | } | ||
180 | |||
181 | static void __exit pca9539_exit(void) | ||
182 | { | ||
183 | i2c_del_driver(&pca9539_driver); | ||
184 | } | ||
185 | |||
186 | MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>"); | ||
187 | MODULE_DESCRIPTION("PCA9539 driver"); | ||
188 | MODULE_LICENSE("GPL"); | ||
189 | |||
190 | module_init(pca9539_init); | ||
191 | module_exit(pca9539_exit); | ||
192 | |||
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index 4956e9effd75..cfcf64654080 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c | |||
@@ -57,7 +57,7 @@ SENSORS_INSMOD_2(pcf8574, pcf8574a); | |||
57 | struct pcf8574_data { | 57 | struct pcf8574_data { |
58 | struct i2c_client client; | 58 | struct i2c_client client; |
59 | 59 | ||
60 | u8 read, write; /* Register values */ | 60 | u8 write; /* Remember last written value */ |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static int pcf8574_attach_adapter(struct i2c_adapter *adapter); | 63 | static int pcf8574_attach_adapter(struct i2c_adapter *adapter); |
@@ -79,9 +79,7 @@ static struct i2c_driver pcf8574_driver = { | |||
79 | static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf) | 79 | static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf) |
80 | { | 80 | { |
81 | struct i2c_client *client = to_i2c_client(dev); | 81 | struct i2c_client *client = to_i2c_client(dev); |
82 | struct pcf8574_data *data = i2c_get_clientdata(client); | 82 | return sprintf(buf, "%u\n", i2c_smbus_read_byte(client)); |
83 | data->read = i2c_smbus_read_byte(client); | ||
84 | return sprintf(buf, "%u\n", data->read); | ||
85 | } | 83 | } |
86 | 84 | ||
87 | static DEVICE_ATTR(read, S_IRUGO, show_read, NULL); | 85 | static DEVICE_ATTR(read, S_IRUGO, show_read, NULL); |
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 5a9deddb626b..588fc2261a91 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/rtc.h> /* get the user-level API */ | 20 | #include <linux/rtc.h> /* get the user-level API */ |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/init.h> | ||
23 | 22 | ||
24 | #include "rtc8564.h" | 23 | #include "rtc8564.h" |
25 | 24 | ||
@@ -66,11 +65,8 @@ static unsigned short normal_addr[] = { 0x51, I2C_CLIENT_END }; | |||
66 | 65 | ||
67 | static struct i2c_client_address_data addr_data = { | 66 | static struct i2c_client_address_data addr_data = { |
68 | .normal_i2c = normal_addr, | 67 | .normal_i2c = normal_addr, |
69 | .normal_i2c_range = ignore, | ||
70 | .probe = ignore, | 68 | .probe = ignore, |
71 | .probe_range = ignore, | ||
72 | .ignore = ignore, | 69 | .ignore = ignore, |
73 | .ignore_range = ignore, | ||
74 | .force = ignore, | 70 | .force = ignore, |
75 | }; | 71 | }; |
76 | 72 | ||
diff --git a/drivers/i2c/chips/sis5595.c b/drivers/i2c/chips/sis5595.c index c6650727a27d..6bbfc8fb4f13 100644 --- a/drivers/i2c/chips/sis5595.c +++ b/drivers/i2c/chips/sis5595.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #include <linux/i2c.h> | 57 | #include <linux/i2c.h> |
58 | #include <linux/i2c-sensor.h> | 58 | #include <linux/i2c-sensor.h> |
59 | #include <linux/init.h> | 59 | #include <linux/init.h> |
60 | #include <linux/jiffies.h> | ||
60 | #include <asm/io.h> | 61 | #include <asm/io.h> |
61 | 62 | ||
62 | 63 | ||
diff --git a/drivers/i2c/chips/smsc47m1.c b/drivers/i2c/chips/smsc47m1.c index 13d6d4a8bc7d..897117a7213f 100644 --- a/drivers/i2c/chips/smsc47m1.c +++ b/drivers/i2c/chips/smsc47m1.c | |||
@@ -372,14 +372,16 @@ static int smsc47m1_find(int *address) | |||
372 | * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id | 372 | * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id |
373 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. | 373 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. |
374 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" | 374 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" |
375 | * can do much more besides (device id 0x60, unsupported). | 375 | * can do much more besides (device id 0x60). |
376 | */ | 376 | */ |
377 | if (val == 0x51) | 377 | if (val == 0x51) |
378 | printk(KERN_INFO "smsc47m1: Found SMSC47B27x\n"); | 378 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); |
379 | else if (val == 0x59) | 379 | else if (val == 0x59) |
380 | printk(KERN_INFO "smsc47m1: Found SMSC47M10x/SMSC47M13x\n"); | 380 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M10x/LPC47M13x\n"); |
381 | else if (val == 0x5F) | 381 | else if (val == 0x5F) |
382 | printk(KERN_INFO "smsc47m1: Found SMSC47M14x\n"); | 382 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); |
383 | else if (val == 0x60) | ||
384 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n"); | ||
383 | else { | 385 | else { |
384 | superio_exit(); | 386 | superio_exit(); |
385 | return -ENODEV; | 387 | return -ENODEV; |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c new file mode 100644 index 000000000000..c0ac01b60039 --- /dev/null +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -0,0 +1,1072 @@ | |||
1 | /* | ||
2 | * tps65010 - driver for tps6501x power management chips | ||
3 | * | ||
4 | * Copyright (C) 2004 Texas Instruments | ||
5 | * Copyright (C) 2004-2005 David Brownell | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | #undef DEBUG | ||
22 | |||
23 | #include <linux/config.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/device.h> | ||
30 | #include <linux/i2c.h> | ||
31 | #include <linux/delay.h> | ||
32 | #include <linux/workqueue.h> | ||
33 | #include <linux/suspend.h> | ||
34 | #include <linux/debugfs.h> | ||
35 | #include <linux/seq_file.h> | ||
36 | |||
37 | #include <asm/irq.h> | ||
38 | #include <asm/mach-types.h> | ||
39 | |||
40 | #include <asm/arch/gpio.h> | ||
41 | #include <asm/arch/mux.h> | ||
42 | #include <asm/arch/tps65010.h> | ||
43 | |||
44 | /*-------------------------------------------------------------------------*/ | ||
45 | |||
46 | #define DRIVER_VERSION "2 May 2005" | ||
47 | #define DRIVER_NAME (tps65010_driver.name) | ||
48 | |||
49 | MODULE_DESCRIPTION("TPS6501x Power Management Driver"); | ||
50 | MODULE_LICENSE("GPL"); | ||
51 | |||
52 | /* only two addresses possible */ | ||
53 | #define TPS_BASE 0x48 | ||
54 | static unsigned short normal_i2c[] = { | ||
55 | TPS_BASE, | ||
56 | I2C_CLIENT_END }; | ||
57 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
58 | |||
59 | I2C_CLIENT_INSMOD; | ||
60 | |||
61 | static struct i2c_driver tps65010_driver; | ||
62 | |||
63 | /*-------------------------------------------------------------------------*/ | ||
64 | |||
65 | /* This driver handles a family of multipurpose chips, which incorporate | ||
66 | * voltage regulators, lithium ion/polymer battery charging, GPIOs, LEDs, | ||
67 | * and other features often needed in portable devices like cell phones | ||
68 | * or digital cameras. | ||
69 | * | ||
70 | * The tps65011 and tps65013 have different voltage settings compared | ||
71 | * to tps65010 and tps65012. The tps65013 has a NO_CHG status/irq. | ||
72 | * All except tps65010 have "wait" mode, possibly defaulted so that | ||
73 | * battery-insert != device-on. | ||
74 | * | ||
75 | * We could distinguish between some models by checking VDCDC1.UVLO or | ||
76 | * other registers, unless they've been changed already after powerup | ||
77 | * as part of board setup by a bootloader. | ||
78 | */ | ||
79 | enum tps_model { | ||
80 | TPS_UNKNOWN = 0, | ||
81 | TPS65010, | ||
82 | TPS65011, | ||
83 | TPS65012, | ||
84 | TPS65013, | ||
85 | }; | ||
86 | |||
87 | struct tps65010 { | ||
88 | struct i2c_client client; | ||
89 | struct semaphore lock; | ||
90 | int irq; | ||
91 | struct work_struct work; | ||
92 | struct dentry *file; | ||
93 | unsigned charging:1; | ||
94 | unsigned por:1; | ||
95 | unsigned model:8; | ||
96 | u16 vbus; | ||
97 | unsigned long flags; | ||
98 | #define FLAG_VBUS_CHANGED 0 | ||
99 | #define FLAG_IRQ_ENABLE 1 | ||
100 | |||
101 | /* copies of last register state */ | ||
102 | u8 chgstatus, regstatus, chgconf; | ||
103 | u8 nmask1, nmask2; | ||
104 | |||
105 | /* plus four GPIOs, probably used to switch power */ | ||
106 | }; | ||
107 | |||
108 | #define POWER_POLL_DELAY msecs_to_jiffies(800) | ||
109 | |||
110 | /*-------------------------------------------------------------------------*/ | ||
111 | |||
112 | #if defined(DEBUG) || defined(CONFIG_DEBUG_FS) | ||
113 | |||
114 | static void dbg_chgstat(char *buf, size_t len, u8 chgstatus) | ||
115 | { | ||
116 | snprintf(buf, len, "%02x%s%s%s%s%s%s%s%s\n", | ||
117 | chgstatus, | ||
118 | (chgstatus & TPS_CHG_USB) ? " USB" : "", | ||
119 | (chgstatus & TPS_CHG_AC) ? " AC" : "", | ||
120 | (chgstatus & TPS_CHG_THERM) ? " therm" : "", | ||
121 | (chgstatus & TPS_CHG_TERM) ? " done" : | ||
122 | ((chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) | ||
123 | ? " (charging)" : ""), | ||
124 | (chgstatus & TPS_CHG_TAPER_TMO) ? " taper_tmo" : "", | ||
125 | (chgstatus & TPS_CHG_CHG_TMO) ? " charge_tmo" : "", | ||
126 | (chgstatus & TPS_CHG_PRECHG_TMO) ? " prechg_tmo" : "", | ||
127 | (chgstatus & TPS_CHG_TEMP_ERR) ? " temp_err" : ""); | ||
128 | } | ||
129 | |||
130 | static void dbg_regstat(char *buf, size_t len, u8 regstatus) | ||
131 | { | ||
132 | snprintf(buf, len, "%02x %s%s%s%s%s%s%s%s\n", | ||
133 | regstatus, | ||
134 | (regstatus & TPS_REG_ONOFF) ? "off" : "(on)", | ||
135 | (regstatus & TPS_REG_COVER) ? " uncover" : "", | ||
136 | (regstatus & TPS_REG_UVLO) ? " UVLO" : "", | ||
137 | (regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "", | ||
138 | (regstatus & TPS_REG_PG_LD02) ? " ld01_bad" : "", | ||
139 | (regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "", | ||
140 | (regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "", | ||
141 | (regstatus & TPS_REG_PG_CORE) ? " core_bad" : ""); | ||
142 | } | ||
143 | |||
144 | static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig) | ||
145 | { | ||
146 | char *hibit; | ||
147 | |||
148 | if (por) | ||
149 | hibit = (chgconfig & TPS_CHARGE_POR) | ||
150 | ? "POR=69ms" : "POR=1sec"; | ||
151 | else | ||
152 | hibit = (chgconfig & TPS65013_AUA) ? "AUA" : ""; | ||
153 | |||
154 | snprintf(buf, len, "%02x %s%s%s AC=%d%% USB=%dmA %sCharge\n", | ||
155 | chgconfig, hibit, | ||
156 | (chgconfig & TPS_CHARGE_RESET) ? " reset" : "", | ||
157 | (chgconfig & TPS_CHARGE_FAST) ? " fast" : "", | ||
158 | ({int p; switch ((chgconfig >> 3) & 3) { | ||
159 | case 3: p = 100; break; | ||
160 | case 2: p = 75; break; | ||
161 | case 1: p = 50; break; | ||
162 | default: p = 25; break; | ||
163 | }; p; }), | ||
164 | (chgconfig & TPS_VBUS_CHARGING) | ||
165 | ? ((chgconfig & TPS_VBUS_500MA) ? 500 : 100) | ||
166 | : 0, | ||
167 | (chgconfig & TPS_CHARGE_ENABLE) ? "" : "No"); | ||
168 | } | ||
169 | |||
170 | #endif | ||
171 | |||
172 | #ifdef DEBUG | ||
173 | |||
174 | static void show_chgstatus(const char *label, u8 chgstatus) | ||
175 | { | ||
176 | char buf [100]; | ||
177 | |||
178 | dbg_chgstat(buf, sizeof buf, chgstatus); | ||
179 | pr_debug("%s: %s %s", DRIVER_NAME, label, buf); | ||
180 | } | ||
181 | |||
182 | static void show_regstatus(const char *label, u8 regstatus) | ||
183 | { | ||
184 | char buf [100]; | ||
185 | |||
186 | dbg_regstat(buf, sizeof buf, regstatus); | ||
187 | pr_debug("%s: %s %s", DRIVER_NAME, label, buf); | ||
188 | } | ||
189 | |||
190 | static void show_chgconfig(int por, const char *label, u8 chgconfig) | ||
191 | { | ||
192 | char buf [100]; | ||
193 | |||
194 | dbg_chgconf(por, buf, sizeof buf, chgconfig); | ||
195 | pr_debug("%s: %s %s", DRIVER_NAME, label, buf); | ||
196 | } | ||
197 | |||
198 | #else | ||
199 | |||
200 | static inline void show_chgstatus(const char *label, u8 chgstatus) { } | ||
201 | static inline void show_regstatus(const char *label, u8 chgstatus) { } | ||
202 | static inline void show_chgconfig(int por, const char *label, u8 chgconfig) { } | ||
203 | |||
204 | #endif | ||
205 | |||
206 | #ifdef CONFIG_DEBUG_FS | ||
207 | |||
208 | static int dbg_show(struct seq_file *s, void *_) | ||
209 | { | ||
210 | struct tps65010 *tps = s->private; | ||
211 | u8 value, v2; | ||
212 | unsigned i; | ||
213 | char buf[100]; | ||
214 | const char *chip; | ||
215 | |||
216 | switch (tps->model) { | ||
217 | case TPS65010: chip = "tps65010"; break; | ||
218 | case TPS65011: chip = "tps65011"; break; | ||
219 | case TPS65012: chip = "tps65012"; break; | ||
220 | case TPS65013: chip = "tps65013"; break; | ||
221 | default: chip = NULL; break; | ||
222 | } | ||
223 | seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", | ||
224 | DRIVER_NAME, DRIVER_VERSION, chip); | ||
225 | |||
226 | down(&tps->lock); | ||
227 | |||
228 | /* FIXME how can we tell whether a battery is present? | ||
229 | * likely involves a charge gauging chip (like BQ26501). | ||
230 | */ | ||
231 | |||
232 | seq_printf(s, "%scharging\n\n", tps->charging ? "" : "(not) "); | ||
233 | |||
234 | |||
235 | /* registers for monitoring battery charging and status; note | ||
236 | * that reading chgstat and regstat may ack IRQs... | ||
237 | */ | ||
238 | value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); | ||
239 | dbg_chgconf(tps->por, buf, sizeof buf, value); | ||
240 | seq_printf(s, "chgconfig %s", buf); | ||
241 | |||
242 | value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS); | ||
243 | dbg_chgstat(buf, sizeof buf, value); | ||
244 | seq_printf(s, "chgstat %s", buf); | ||
245 | value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK1); | ||
246 | dbg_chgstat(buf, sizeof buf, value); | ||
247 | seq_printf(s, "mask1 %s", buf); | ||
248 | /* ignore ackint1 */ | ||
249 | |||
250 | value = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS); | ||
251 | dbg_regstat(buf, sizeof buf, value); | ||
252 | seq_printf(s, "regstat %s", buf); | ||
253 | value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK2); | ||
254 | dbg_regstat(buf, sizeof buf, value); | ||
255 | seq_printf(s, "mask2 %s\n", buf); | ||
256 | /* ignore ackint2 */ | ||
257 | |||
258 | (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY); | ||
259 | |||
260 | |||
261 | /* VMAIN voltage, enable lowpower, etc */ | ||
262 | value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1); | ||
263 | seq_printf(s, "vdcdc1 %02x\n", value); | ||
264 | |||
265 | /* VCORE voltage, vibrator on/off */ | ||
266 | value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2); | ||
267 | seq_printf(s, "vdcdc2 %02x\n", value); | ||
268 | |||
269 | /* both LD0s, and their lowpower behavior */ | ||
270 | value = i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1); | ||
271 | seq_printf(s, "vregs1 %02x\n\n", value); | ||
272 | |||
273 | |||
274 | /* LEDs and GPIOs */ | ||
275 | value = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_ON); | ||
276 | v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_PER); | ||
277 | seq_printf(s, "led1 %s, on=%02x, per=%02x, %d/%d msec\n", | ||
278 | (value & 0x80) | ||
279 | ? ((v2 & 0x80) ? "on" : "off") | ||
280 | : ((v2 & 0x80) ? "blink" : "(nPG)"), | ||
281 | value, v2, | ||
282 | (value & 0x7f) * 10, (v2 & 0x7f) * 100); | ||
283 | |||
284 | value = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_ON); | ||
285 | v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_PER); | ||
286 | seq_printf(s, "led2 %s, on=%02x, per=%02x, %d/%d msec\n", | ||
287 | (value & 0x80) | ||
288 | ? ((v2 & 0x80) ? "on" : "off") | ||
289 | : ((v2 & 0x80) ? "blink" : "off"), | ||
290 | value, v2, | ||
291 | (value & 0x7f) * 10, (v2 & 0x7f) * 100); | ||
292 | |||
293 | value = i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO); | ||
294 | v2 = i2c_smbus_read_byte_data(&tps->client, TPS_MASK3); | ||
295 | seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2); | ||
296 | |||
297 | for (i = 0; i < 4; i++) { | ||
298 | if (value & (1 << (4 +i))) | ||
299 | seq_printf(s, " gpio%d-out %s\n", i + 1, | ||
300 | (value & (1 << i)) ? "low" : "hi "); | ||
301 | else | ||
302 | seq_printf(s, " gpio%d-in %s %s %s\n", i + 1, | ||
303 | (value & (1 << i)) ? "hi " : "low", | ||
304 | (v2 & (1 << i)) ? "no-irq" : "irq", | ||
305 | (v2 & (1 << (4 + i))) ? "rising" : "falling"); | ||
306 | } | ||
307 | |||
308 | up(&tps->lock); | ||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | static int dbg_tps_open(struct inode *inode, struct file *file) | ||
313 | { | ||
314 | return single_open(file, dbg_show, inode->u.generic_ip); | ||
315 | } | ||
316 | |||
317 | static struct file_operations debug_fops = { | ||
318 | .open = dbg_tps_open, | ||
319 | .read = seq_read, | ||
320 | .llseek = seq_lseek, | ||
321 | .release = single_release, | ||
322 | }; | ||
323 | |||
324 | #define DEBUG_FOPS &debug_fops | ||
325 | |||
326 | #else | ||
327 | #define DEBUG_FOPS NULL | ||
328 | #endif | ||
329 | |||
330 | /*-------------------------------------------------------------------------*/ | ||
331 | |||
332 | /* handle IRQS in a task context, so we can use I2C calls */ | ||
333 | static void tps65010_interrupt(struct tps65010 *tps) | ||
334 | { | ||
335 | u8 tmp = 0, mask, poll; | ||
336 | |||
337 | /* IRQs won't trigger irqs for certain events, but we can get | ||
338 | * others by polling (normally, with external power applied). | ||
339 | */ | ||
340 | poll = 0; | ||
341 | |||
342 | /* regstatus irqs */ | ||
343 | if (tps->nmask2) { | ||
344 | tmp = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS); | ||
345 | mask = tmp ^ tps->regstatus; | ||
346 | tps->regstatus = tmp; | ||
347 | mask &= tps->nmask2; | ||
348 | } else | ||
349 | mask = 0; | ||
350 | if (mask) { | ||
351 | tps->regstatus = tmp; | ||
352 | /* may need to shut something down ... */ | ||
353 | |||
354 | /* "off" usually means deep sleep */ | ||
355 | if (tmp & TPS_REG_ONOFF) { | ||
356 | pr_info("%s: power off button\n", DRIVER_NAME); | ||
357 | #if 0 | ||
358 | /* REVISIT: this might need its own workqueue | ||
359 | * plus tweaks including deadlock avoidance ... | ||
360 | */ | ||
361 | software_suspend(); | ||
362 | #endif | ||
363 | poll = 1; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | /* chgstatus irqs */ | ||
368 | if (tps->nmask1) { | ||
369 | tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS); | ||
370 | mask = tmp ^ tps->chgstatus; | ||
371 | tps->chgstatus = tmp; | ||
372 | mask &= tps->nmask1; | ||
373 | } else | ||
374 | mask = 0; | ||
375 | if (mask) { | ||
376 | unsigned charging = 0; | ||
377 | |||
378 | show_chgstatus("chg/irq", tmp); | ||
379 | if (tmp & (TPS_CHG_USB|TPS_CHG_AC)) | ||
380 | show_chgconfig(tps->por, "conf", tps->chgconf); | ||
381 | |||
382 | /* Unless it was turned off or disabled, we charge any | ||
383 | * battery whenever there's power available for it | ||
384 | * and the charger hasn't been disabled. | ||
385 | */ | ||
386 | if (!(tps->chgstatus & ~(TPS_CHG_USB|TPS_CHG_AC)) | ||
387 | && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) | ||
388 | && (tps->chgconf & TPS_CHARGE_ENABLE) | ||
389 | ) { | ||
390 | if (tps->chgstatus & TPS_CHG_USB) { | ||
391 | /* VBUS options are readonly until reconnect */ | ||
392 | if (mask & TPS_CHG_USB) | ||
393 | set_bit(FLAG_VBUS_CHANGED, &tps->flags); | ||
394 | charging = 1; | ||
395 | } else if (tps->chgstatus & TPS_CHG_AC) | ||
396 | charging = 1; | ||
397 | } | ||
398 | if (charging != tps->charging) { | ||
399 | tps->charging = charging; | ||
400 | pr_info("%s: battery %scharging\n", | ||
401 | DRIVER_NAME, charging ? "" : | ||
402 | ((tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) | ||
403 | ? "NOT " : "dis")); | ||
404 | } | ||
405 | } | ||
406 | |||
407 | /* always poll to detect (a) power removal, without tps65013 | ||
408 | * NO_CHG IRQ; or (b) restart of charging after stop. | ||
409 | */ | ||
410 | if ((tps->model != TPS65013 || !tps->charging) | ||
411 | && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))) | ||
412 | poll = 1; | ||
413 | if (poll) | ||
414 | (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY); | ||
415 | |||
416 | /* also potentially gpio-in rise or fall */ | ||
417 | } | ||
418 | |||
419 | /* handle IRQs and polling using keventd for now */ | ||
420 | static void tps65010_work(void *_tps) | ||
421 | { | ||
422 | struct tps65010 *tps = _tps; | ||
423 | |||
424 | down(&tps->lock); | ||
425 | |||
426 | tps65010_interrupt(tps); | ||
427 | |||
428 | if (test_and_clear_bit(FLAG_VBUS_CHANGED, &tps->flags)) { | ||
429 | int status; | ||
430 | u8 chgconfig, tmp; | ||
431 | |||
432 | chgconfig = i2c_smbus_read_byte_data(&tps->client, | ||
433 | TPS_CHGCONFIG); | ||
434 | chgconfig &= ~(TPS_VBUS_500MA | TPS_VBUS_CHARGING); | ||
435 | if (tps->vbus == 500) | ||
436 | chgconfig |= TPS_VBUS_500MA | TPS_VBUS_CHARGING; | ||
437 | else if (tps->vbus >= 100) | ||
438 | chgconfig |= TPS_VBUS_CHARGING; | ||
439 | |||
440 | status = i2c_smbus_write_byte_data(&tps->client, | ||
441 | TPS_CHGCONFIG, chgconfig); | ||
442 | |||
443 | /* vbus update fails unless VBUS is connected! */ | ||
444 | tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); | ||
445 | tps->chgconf = tmp; | ||
446 | show_chgconfig(tps->por, "update vbus", tmp); | ||
447 | } | ||
448 | |||
449 | if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) | ||
450 | enable_irq(tps->irq); | ||
451 | |||
452 | up(&tps->lock); | ||
453 | } | ||
454 | |||
455 | static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) | ||
456 | { | ||
457 | struct tps65010 *tps = _tps; | ||
458 | |||
459 | disable_irq_nosync(irq); | ||
460 | set_bit(FLAG_IRQ_ENABLE, &tps->flags); | ||
461 | (void) schedule_work(&tps->work); | ||
462 | return IRQ_HANDLED; | ||
463 | } | ||
464 | |||
465 | /*-------------------------------------------------------------------------*/ | ||
466 | |||
467 | static struct tps65010 *the_tps; | ||
468 | |||
469 | static int __exit tps65010_detach_client(struct i2c_client *client) | ||
470 | { | ||
471 | struct tps65010 *tps; | ||
472 | |||
473 | tps = container_of(client, struct tps65010, client); | ||
474 | #ifdef CONFIG_ARM | ||
475 | if (machine_is_omap_h2()) | ||
476 | omap_free_gpio(58); | ||
477 | if (machine_is_omap_osk()) | ||
478 | omap_free_gpio(OMAP_MPUIO(1)); | ||
479 | #endif | ||
480 | free_irq(tps->irq, tps); | ||
481 | debugfs_remove(tps->file); | ||
482 | if (i2c_detach_client(client) == 0) | ||
483 | kfree(tps); | ||
484 | the_tps = 0; | ||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | static int tps65010_noscan(struct i2c_adapter *bus) | ||
489 | { | ||
490 | /* pure paranoia, in case someone adds another i2c bus | ||
491 | * after our init section's gone... | ||
492 | */ | ||
493 | return -ENODEV; | ||
494 | } | ||
495 | |||
496 | /* no error returns, they'd just make bus scanning stop */ | ||
497 | static int __init | ||
498 | tps65010_probe(struct i2c_adapter *bus, int address, int kind) | ||
499 | { | ||
500 | struct tps65010 *tps; | ||
501 | int status; | ||
502 | |||
503 | if (the_tps) { | ||
504 | dev_dbg(&bus->dev, "only one %s for now\n", DRIVER_NAME); | ||
505 | return 0; | ||
506 | } | ||
507 | |||
508 | tps = kmalloc(sizeof *tps, GFP_KERNEL); | ||
509 | if (!tps) | ||
510 | return 0; | ||
511 | |||
512 | memset(tps, 0, sizeof *tps); | ||
513 | init_MUTEX(&tps->lock); | ||
514 | INIT_WORK(&tps->work, tps65010_work, tps); | ||
515 | tps->irq = -1; | ||
516 | tps->client.addr = address; | ||
517 | i2c_set_clientdata(&tps->client, tps); | ||
518 | tps->client.adapter = bus; | ||
519 | tps->client.driver = &tps65010_driver; | ||
520 | strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE); | ||
521 | |||
522 | status = i2c_attach_client(&tps->client); | ||
523 | if (status < 0) { | ||
524 | dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n", | ||
525 | DRIVER_NAME, address, status); | ||
526 | fail1: | ||
527 | kfree(tps); | ||
528 | return 0; | ||
529 | } | ||
530 | |||
531 | #ifdef CONFIG_ARM | ||
532 | if (machine_is_omap_h2()) { | ||
533 | tps->model = TPS65010; | ||
534 | omap_cfg_reg(W4_GPIO58); | ||
535 | tps->irq = OMAP_GPIO_IRQ(58); | ||
536 | omap_request_gpio(58); | ||
537 | omap_set_gpio_direction(58, 1); | ||
538 | omap_set_gpio_edge_ctrl(58, OMAP_GPIO_FALLING_EDGE); | ||
539 | } | ||
540 | if (machine_is_omap_osk()) { | ||
541 | tps->model = TPS65010; | ||
542 | // omap_cfg_reg(U19_1610_MPUIO1); | ||
543 | tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)); | ||
544 | omap_request_gpio(OMAP_MPUIO(1)); | ||
545 | omap_set_gpio_direction(OMAP_MPUIO(1), 1); | ||
546 | omap_set_gpio_edge_ctrl(OMAP_MPUIO(1), OMAP_GPIO_FALLING_EDGE); | ||
547 | } | ||
548 | if (machine_is_omap_h3()) { | ||
549 | tps->model = TPS65013; | ||
550 | |||
551 | // FIXME set up this board's IRQ ... | ||
552 | } | ||
553 | #else | ||
554 | #define set_irq_type(num,trigger) do{}while(0) | ||
555 | #endif | ||
556 | |||
557 | if (tps->irq > 0) { | ||
558 | set_irq_type(tps->irq, IRQT_LOW); | ||
559 | status = request_irq(tps->irq, tps65010_irq, | ||
560 | SA_SAMPLE_RANDOM, DRIVER_NAME, tps); | ||
561 | if (status < 0) { | ||
562 | dev_dbg(&tps->client.dev, "can't get IRQ %d, err %d\n", | ||
563 | tps->irq, status); | ||
564 | i2c_detach_client(&tps->client); | ||
565 | goto fail1; | ||
566 | } | ||
567 | #ifdef CONFIG_ARM | ||
568 | /* annoying race here, ideally we'd have an option | ||
569 | * to claim the irq now and enable it later. | ||
570 | */ | ||
571 | disable_irq(tps->irq); | ||
572 | set_bit(FLAG_IRQ_ENABLE, &tps->flags); | ||
573 | #endif | ||
574 | } else | ||
575 | printk(KERN_WARNING "%s: IRQ not configured!\n", | ||
576 | DRIVER_NAME); | ||
577 | |||
578 | |||
579 | switch (tps->model) { | ||
580 | case TPS65010: | ||
581 | case TPS65012: | ||
582 | tps->por = 1; | ||
583 | break; | ||
584 | case TPS_UNKNOWN: | ||
585 | printk(KERN_WARNING "%s: unknown TPS chip\n", DRIVER_NAME); | ||
586 | break; | ||
587 | /* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */ | ||
588 | } | ||
589 | tps->chgconf = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); | ||
590 | show_chgconfig(tps->por, "conf/init", tps->chgconf); | ||
591 | |||
592 | show_chgstatus("chg/init", | ||
593 | i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS)); | ||
594 | show_regstatus("reg/init", | ||
595 | i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS)); | ||
596 | |||
597 | pr_debug("%s: vdcdc1 0x%02x, vdcdc2 %02x, vregs1 %02x\n", DRIVER_NAME, | ||
598 | i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1), | ||
599 | i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2), | ||
600 | i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1)); | ||
601 | pr_debug("%s: defgpio 0x%02x, mask3 0x%02x\n", DRIVER_NAME, | ||
602 | i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO), | ||
603 | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); | ||
604 | |||
605 | tps65010_driver.attach_adapter = tps65010_noscan; | ||
606 | the_tps = tps; | ||
607 | |||
608 | #if defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG) | ||
609 | /* USB hosts can't draw VBUS. OTG devices could, later | ||
610 | * when OTG infrastructure enables it. USB peripherals | ||
611 | * could be relying on VBUS while booting, though. | ||
612 | */ | ||
613 | tps->vbus = 100; | ||
614 | #endif | ||
615 | |||
616 | /* unmask the "interesting" irqs, then poll once to | ||
617 | * kickstart monitoring, initialize shadowed status | ||
618 | * registers, and maybe disable VBUS draw. | ||
619 | */ | ||
620 | tps->nmask1 = ~0; | ||
621 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK1, ~tps->nmask1); | ||
622 | |||
623 | tps->nmask2 = TPS_REG_ONOFF; | ||
624 | if (tps->model == TPS65013) | ||
625 | tps->nmask2 |= TPS_REG_NO_CHG; | ||
626 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK2, ~tps->nmask2); | ||
627 | |||
628 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f | ||
629 | | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); | ||
630 | |||
631 | tps65010_work(tps); | ||
632 | |||
633 | tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, | ||
634 | tps, DEBUG_FOPS); | ||
635 | return 0; | ||
636 | } | ||
637 | |||
638 | static int __init tps65010_scan_bus(struct i2c_adapter *bus) | ||
639 | { | ||
640 | if (!i2c_check_functionality(bus, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
641 | return -EINVAL; | ||
642 | return i2c_probe(bus, &addr_data, tps65010_probe); | ||
643 | } | ||
644 | |||
645 | static struct i2c_driver tps65010_driver = { | ||
646 | .owner = THIS_MODULE, | ||
647 | .name = "tps65010", | ||
648 | .id = 888, /* FIXME assign "official" value */ | ||
649 | .flags = I2C_DF_NOTIFY, | ||
650 | .attach_adapter = tps65010_scan_bus, | ||
651 | .detach_client = __exit_p(tps65010_detach_client), | ||
652 | }; | ||
653 | |||
654 | /*-------------------------------------------------------------------------*/ | ||
655 | |||
656 | /* Draw from VBUS: | ||
657 | * 0 mA -- DON'T DRAW (might supply power instead) | ||
658 | * 100 mA -- usb unit load (slowest charge rate) | ||
659 | * 500 mA -- usb high power (fast battery charge) | ||
660 | */ | ||
661 | int tps65010_set_vbus_draw(unsigned mA) | ||
662 | { | ||
663 | unsigned long flags; | ||
664 | |||
665 | if (!the_tps) | ||
666 | return -ENODEV; | ||
667 | |||
668 | /* assumes non-SMP */ | ||
669 | local_irq_save(flags); | ||
670 | if (mA >= 500) | ||
671 | mA = 500; | ||
672 | else if (mA >= 100) | ||
673 | mA = 100; | ||
674 | else | ||
675 | mA = 0; | ||
676 | the_tps->vbus = mA; | ||
677 | if ((the_tps->chgstatus & TPS_CHG_USB) | ||
678 | && test_and_set_bit( | ||
679 | FLAG_VBUS_CHANGED, &the_tps->flags)) { | ||
680 | /* gadget drivers call this in_irq() */ | ||
681 | (void) schedule_work(&the_tps->work); | ||
682 | } | ||
683 | local_irq_restore(flags); | ||
684 | |||
685 | return 0; | ||
686 | } | ||
687 | EXPORT_SYMBOL(tps65010_set_vbus_draw); | ||
688 | |||
689 | /*-------------------------------------------------------------------------*/ | ||
690 | /* tps65010_set_gpio_out_value parameter: | ||
691 | * gpio: GPIO1, GPIO2, GPIO3 or GPIO4 | ||
692 | * value: LOW or HIGH | ||
693 | */ | ||
694 | int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) | ||
695 | { | ||
696 | int status; | ||
697 | unsigned defgpio; | ||
698 | |||
699 | if (!the_tps) | ||
700 | return -ENODEV; | ||
701 | if ((gpio < GPIO1) || (gpio > GPIO4)) | ||
702 | return -EINVAL; | ||
703 | |||
704 | down(&the_tps->lock); | ||
705 | |||
706 | defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); | ||
707 | |||
708 | /* Configure GPIO for output */ | ||
709 | defgpio |= 1 << (gpio + 3); | ||
710 | |||
711 | /* Writing 1 forces a logic 0 on that GPIO and vice versa */ | ||
712 | switch (value) { | ||
713 | case LOW: | ||
714 | defgpio |= 1 << (gpio - 1); /* set GPIO low by writing 1 */ | ||
715 | break; | ||
716 | /* case HIGH: */ | ||
717 | default: | ||
718 | defgpio &= ~(1 << (gpio - 1)); /* set GPIO high by writing 0 */ | ||
719 | break; | ||
720 | } | ||
721 | |||
722 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
723 | TPS_DEFGPIO, defgpio); | ||
724 | |||
725 | pr_debug("%s: gpio%dout = %s, defgpio 0x%02x\n", DRIVER_NAME, | ||
726 | gpio, value ? "high" : "low", | ||
727 | i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); | ||
728 | |||
729 | up(&the_tps->lock); | ||
730 | return status; | ||
731 | } | ||
732 | EXPORT_SYMBOL(tps65010_set_gpio_out_value); | ||
733 | |||
734 | /*-------------------------------------------------------------------------*/ | ||
735 | /* tps65010_set_led parameter: | ||
736 | * led: LED1 or LED2 | ||
737 | * mode: ON, OFF or BLINK | ||
738 | */ | ||
739 | int tps65010_set_led(unsigned led, unsigned mode) | ||
740 | { | ||
741 | int status; | ||
742 | unsigned led_on, led_per, offs; | ||
743 | |||
744 | if (!the_tps) | ||
745 | return -ENODEV; | ||
746 | |||
747 | if(led == LED1) | ||
748 | offs = 0; | ||
749 | else { | ||
750 | offs = 2; | ||
751 | led = LED2; | ||
752 | } | ||
753 | |||
754 | down(&the_tps->lock); | ||
755 | |||
756 | dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, | ||
757 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); | ||
758 | |||
759 | dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, | ||
760 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); | ||
761 | |||
762 | switch (mode) { | ||
763 | case OFF: | ||
764 | led_on = 1 << 7; | ||
765 | led_per = 0 << 7; | ||
766 | break; | ||
767 | case ON: | ||
768 | led_on = 1 << 7; | ||
769 | led_per = 1 << 7; | ||
770 | break; | ||
771 | case BLINK: | ||
772 | led_on = 0x30 | (0 << 7); | ||
773 | led_per = 0x08 | (1 << 7); | ||
774 | break; | ||
775 | default: | ||
776 | printk(KERN_ERR "%s: Wrong mode parameter for tps65010_set_led()\n", | ||
777 | DRIVER_NAME); | ||
778 | up(&the_tps->lock); | ||
779 | return -EINVAL; | ||
780 | } | ||
781 | |||
782 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
783 | TPS_LED1_ON + offs, led_on); | ||
784 | |||
785 | if (status != 0) { | ||
786 | printk(KERN_ERR "%s: Failed to write led%i_on register\n", | ||
787 | DRIVER_NAME, led); | ||
788 | up(&the_tps->lock); | ||
789 | return status; | ||
790 | } | ||
791 | |||
792 | dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, | ||
793 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); | ||
794 | |||
795 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
796 | TPS_LED1_PER + offs, led_per); | ||
797 | |||
798 | if (status != 0) { | ||
799 | printk(KERN_ERR "%s: Failed to write led%i_per register\n", | ||
800 | DRIVER_NAME, led); | ||
801 | up(&the_tps->lock); | ||
802 | return status; | ||
803 | } | ||
804 | |||
805 | dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, | ||
806 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); | ||
807 | |||
808 | up(&the_tps->lock); | ||
809 | |||
810 | return status; | ||
811 | } | ||
812 | EXPORT_SYMBOL(tps65010_set_led); | ||
813 | |||
814 | /*-------------------------------------------------------------------------*/ | ||
815 | /* tps65010_set_vib parameter: | ||
816 | * value: ON or OFF | ||
817 | */ | ||
818 | int tps65010_set_vib(unsigned value) | ||
819 | { | ||
820 | int status; | ||
821 | unsigned vdcdc2; | ||
822 | |||
823 | if (!the_tps) | ||
824 | return -ENODEV; | ||
825 | |||
826 | down(&the_tps->lock); | ||
827 | |||
828 | vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); | ||
829 | vdcdc2 &= ~(1 << 1); | ||
830 | if (value) | ||
831 | vdcdc2 |= (1 << 1); | ||
832 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
833 | TPS_VDCDC2, vdcdc2); | ||
834 | |||
835 | pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); | ||
836 | |||
837 | up(&the_tps->lock); | ||
838 | return status; | ||
839 | } | ||
840 | EXPORT_SYMBOL(tps65010_set_vib); | ||
841 | |||
842 | /*-------------------------------------------------------------------------*/ | ||
843 | /* tps65010_set_low_pwr parameter: | ||
844 | * mode: ON or OFF | ||
845 | */ | ||
846 | int tps65010_set_low_pwr(unsigned mode) | ||
847 | { | ||
848 | int status; | ||
849 | unsigned vdcdc1; | ||
850 | |||
851 | if (!the_tps) | ||
852 | return -ENODEV; | ||
853 | |||
854 | down(&the_tps->lock); | ||
855 | |||
856 | pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, | ||
857 | mode ? "enable" : "disable", | ||
858 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
859 | |||
860 | vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1); | ||
861 | |||
862 | switch (mode) { | ||
863 | case OFF: | ||
864 | vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */ | ||
865 | break; | ||
866 | /* case ON: */ | ||
867 | default: | ||
868 | vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */ | ||
869 | break; | ||
870 | } | ||
871 | |||
872 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
873 | TPS_VDCDC1, vdcdc1); | ||
874 | |||
875 | if (status != 0) | ||
876 | printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", | ||
877 | DRIVER_NAME); | ||
878 | else | ||
879 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | ||
880 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
881 | |||
882 | up(&the_tps->lock); | ||
883 | |||
884 | return status; | ||
885 | } | ||
886 | EXPORT_SYMBOL(tps65010_set_low_pwr); | ||
887 | |||
888 | /*-------------------------------------------------------------------------*/ | ||
889 | /* tps65010_config_vregs1 parameter: | ||
890 | * value to be written to VREGS1 register | ||
891 | * Note: The complete register is written, set all bits you need | ||
892 | */ | ||
893 | int tps65010_config_vregs1(unsigned value) | ||
894 | { | ||
895 | int status; | ||
896 | |||
897 | if (!the_tps) | ||
898 | return -ENODEV; | ||
899 | |||
900 | down(&the_tps->lock); | ||
901 | |||
902 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | ||
903 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | ||
904 | |||
905 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
906 | TPS_VREGS1, value); | ||
907 | |||
908 | if (status != 0) | ||
909 | printk(KERN_ERR "%s: Failed to write vregs1 register\n", | ||
910 | DRIVER_NAME); | ||
911 | else | ||
912 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | ||
913 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | ||
914 | |||
915 | up(&the_tps->lock); | ||
916 | |||
917 | return status; | ||
918 | } | ||
919 | EXPORT_SYMBOL(tps65010_config_vregs1); | ||
920 | |||
921 | /*-------------------------------------------------------------------------*/ | ||
922 | /* tps65013_set_low_pwr parameter: | ||
923 | * mode: ON or OFF | ||
924 | */ | ||
925 | |||
926 | /* FIXME: Assumes AC or USB power is present. Setting AUA bit is not | ||
927 | required if power supply is through a battery */ | ||
928 | |||
929 | int tps65013_set_low_pwr(unsigned mode) | ||
930 | { | ||
931 | int status; | ||
932 | unsigned vdcdc1, chgconfig; | ||
933 | |||
934 | if (!the_tps || the_tps->por) | ||
935 | return -ENODEV; | ||
936 | |||
937 | down(&the_tps->lock); | ||
938 | |||
939 | pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", | ||
940 | DRIVER_NAME, | ||
941 | mode ? "enable" : "disable", | ||
942 | i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG), | ||
943 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
944 | |||
945 | chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG); | ||
946 | vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1); | ||
947 | |||
948 | switch (mode) { | ||
949 | case OFF: | ||
950 | chgconfig &= ~TPS65013_AUA; /* disable AUA bit */ | ||
951 | vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */ | ||
952 | break; | ||
953 | /* case ON: */ | ||
954 | default: | ||
955 | chgconfig |= TPS65013_AUA; /* enable AUA bit */ | ||
956 | vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */ | ||
957 | break; | ||
958 | } | ||
959 | |||
960 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
961 | TPS_CHGCONFIG, chgconfig); | ||
962 | if (status != 0) { | ||
963 | printk(KERN_ERR "%s: Failed to write chconfig register\n", | ||
964 | DRIVER_NAME); | ||
965 | up(&the_tps->lock); | ||
966 | return status; | ||
967 | } | ||
968 | |||
969 | chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG); | ||
970 | the_tps->chgconf = chgconfig; | ||
971 | show_chgconfig(0, "chgconf", chgconfig); | ||
972 | |||
973 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
974 | TPS_VDCDC1, vdcdc1); | ||
975 | |||
976 | if (status != 0) | ||
977 | printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", | ||
978 | DRIVER_NAME); | ||
979 | else | ||
980 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | ||
981 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
982 | |||
983 | up(&the_tps->lock); | ||
984 | |||
985 | return status; | ||
986 | } | ||
987 | EXPORT_SYMBOL(tps65013_set_low_pwr); | ||
988 | |||
989 | /*-------------------------------------------------------------------------*/ | ||
990 | |||
991 | static int __init tps_init(void) | ||
992 | { | ||
993 | u32 tries = 3; | ||
994 | int status = -ENODEV; | ||
995 | |||
996 | printk(KERN_INFO "%s: version %s\n", DRIVER_NAME, DRIVER_VERSION); | ||
997 | |||
998 | /* some boards have startup glitches */ | ||
999 | while (tries--) { | ||
1000 | status = i2c_add_driver(&tps65010_driver); | ||
1001 | if (the_tps) | ||
1002 | break; | ||
1003 | i2c_del_driver(&tps65010_driver); | ||
1004 | if (!tries) { | ||
1005 | printk(KERN_ERR "%s: no chip?\n", DRIVER_NAME); | ||
1006 | return -ENODEV; | ||
1007 | } | ||
1008 | pr_debug("%s: re-probe ...\n", DRIVER_NAME); | ||
1009 | msleep(10); | ||
1010 | } | ||
1011 | |||
1012 | #if defined(CONFIG_ARM) | ||
1013 | if (machine_is_omap_osk()) { | ||
1014 | |||
1015 | // FIXME: More should be placed in the initialization code | ||
1016 | // of the submodules (DSP, ethernet, power management, | ||
1017 | // board-osk.c). Careful: I2C is initialized "late". | ||
1018 | |||
1019 | /* Let LED1 (D9) blink */ | ||
1020 | tps65010_set_led(LED1, BLINK); | ||
1021 | |||
1022 | /* Disable LED 2 (D2) */ | ||
1023 | tps65010_set_led(LED2, OFF); | ||
1024 | |||
1025 | /* Set GPIO 1 HIGH to disable VBUS power supply; | ||
1026 | * OHCI driver powers it up/down as needed. | ||
1027 | */ | ||
1028 | tps65010_set_gpio_out_value(GPIO1, HIGH); | ||
1029 | |||
1030 | /* Set GPIO 2 low to turn on LED D3 */ | ||
1031 | tps65010_set_gpio_out_value(GPIO2, HIGH); | ||
1032 | |||
1033 | /* Set GPIO 3 low to take ethernet out of reset */ | ||
1034 | tps65010_set_gpio_out_value(GPIO3, LOW); | ||
1035 | |||
1036 | /* gpio4 for VDD_DSP */ | ||
1037 | |||
1038 | /* Enable LOW_PWR */ | ||
1039 | tps65010_set_low_pwr(ON); | ||
1040 | |||
1041 | /* Switch VLDO2 to 3.0V for AIC23 */ | ||
1042 | tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V | TPS_LDO1_ENABLE); | ||
1043 | |||
1044 | } else if (machine_is_omap_h2()) { | ||
1045 | /* gpio3 for SD, gpio4 for VDD_DSP */ | ||
1046 | |||
1047 | /* Enable LOW_PWR */ | ||
1048 | tps65010_set_low_pwr(ON); | ||
1049 | } else if (machine_is_omap_h3()) { | ||
1050 | /* gpio4 for SD, gpio3 for VDD_DSP */ | ||
1051 | #ifdef CONFIG_PM | ||
1052 | /* Enable LOW_PWR */ | ||
1053 | tps65013_set_low_pwr(ON); | ||
1054 | #endif | ||
1055 | } | ||
1056 | #endif | ||
1057 | |||
1058 | return status; | ||
1059 | } | ||
1060 | /* NOTE: this MUST be initialized before the other parts of the system | ||
1061 | * that rely on it ... but after the i2c bus on which this relies. | ||
1062 | * That is, much earlier than on PC-type systems, which don't often use | ||
1063 | * I2C as a core system bus. | ||
1064 | */ | ||
1065 | subsys_initcall(tps_init); | ||
1066 | |||
1067 | static void __exit tps_exit(void) | ||
1068 | { | ||
1069 | i2c_del_driver(&tps65010_driver); | ||
1070 | } | ||
1071 | module_exit(tps_exit); | ||
1072 | |||
diff --git a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c index fefc24a9251a..137d9b7cacd4 100644 --- a/drivers/i2c/chips/via686a.c +++ b/drivers/i2c/chips/via686a.c | |||
@@ -1,12 +1,12 @@ | |||
1 | /* | 1 | /* |
2 | via686a.c - Part of lm_sensors, Linux kernel modules | 2 | via686a.c - Part of lm_sensors, Linux kernel modules |
3 | for hardware monitoring | 3 | for hardware monitoring |
4 | 4 | ||
5 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, | 5 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, |
6 | Kyösti Mälkki <kmalkki@cc.hut.fi>, | 6 | Kyösti Mälkki <kmalkki@cc.hut.fi>, |
7 | Mark Studebaker <mdsxyz123@yahoo.com>, | 7 | Mark Studebaker <mdsxyz123@yahoo.com>, |
8 | and Bob Dougherty <bobd@stanford.edu> | 8 | and Bob Dougherty <bobd@stanford.edu> |
9 | (Some conversion-factor data were contributed by Jonathan Teh Soon Yew | 9 | (Some conversion-factor data were contributed by Jonathan Teh Soon Yew |
10 | <j.teh@iname.com> and Alex van Kaam <darkside@chello.nl>.) | 10 | <j.teh@iname.com> and Alex van Kaam <darkside@chello.nl>.) |
11 | 11 | ||
12 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
@@ -30,11 +30,9 @@ | |||
30 | Warning - only supports a single device. | 30 | Warning - only supports a single device. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/config.h> | ||
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
36 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
37 | #include <linux/delay.h> | ||
38 | #include <linux/jiffies.h> | 36 | #include <linux/jiffies.h> |
39 | #include <linux/i2c.h> | 37 | #include <linux/i2c.h> |
40 | #include <linux/i2c-sensor.h> | 38 | #include <linux/i2c-sensor.h> |
@@ -66,49 +64,46 @@ SENSORS_INSMOD_1(via686a); | |||
66 | /* Many VIA686A constants specified below */ | 64 | /* Many VIA686A constants specified below */ |
67 | 65 | ||
68 | /* Length of ISA address segment */ | 66 | /* Length of ISA address segment */ |
69 | #define VIA686A_EXTENT 0x80 | 67 | #define VIA686A_EXTENT 0x80 |
70 | #define VIA686A_BASE_REG 0x70 | 68 | #define VIA686A_BASE_REG 0x70 |
71 | #define VIA686A_ENABLE_REG 0x74 | 69 | #define VIA686A_ENABLE_REG 0x74 |
72 | 70 | ||
73 | /* The VIA686A registers */ | 71 | /* The VIA686A registers */ |
74 | /* ins numbered 0-4 */ | 72 | /* ins numbered 0-4 */ |
75 | #define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2)) | 73 | #define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2)) |
76 | #define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2)) | 74 | #define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2)) |
77 | #define VIA686A_REG_IN(nr) (0x22 + (nr)) | 75 | #define VIA686A_REG_IN(nr) (0x22 + (nr)) |
78 | 76 | ||
79 | /* fans numbered 1-2 */ | 77 | /* fans numbered 1-2 */ |
80 | #define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr)) | 78 | #define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr)) |
81 | #define VIA686A_REG_FAN(nr) (0x28 + (nr)) | 79 | #define VIA686A_REG_FAN(nr) (0x28 + (nr)) |
82 | |||
83 | /* the following values are as speced by VIA: */ | ||
84 | static const u8 regtemp[] = { 0x20, 0x21, 0x1f }; | ||
85 | static const u8 regover[] = { 0x39, 0x3d, 0x1d }; | ||
86 | static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e }; | ||
87 | 80 | ||
88 | /* temps numbered 1-3 */ | 81 | /* temps numbered 1-3 */ |
89 | #define VIA686A_REG_TEMP(nr) (regtemp[nr]) | 82 | static const u8 VIA686A_REG_TEMP[] = { 0x20, 0x21, 0x1f }; |
90 | #define VIA686A_REG_TEMP_OVER(nr) (regover[nr]) | 83 | static const u8 VIA686A_REG_TEMP_OVER[] = { 0x39, 0x3d, 0x1d }; |
91 | #define VIA686A_REG_TEMP_HYST(nr) (reghyst[nr]) | 84 | static const u8 VIA686A_REG_TEMP_HYST[] = { 0x3a, 0x3e, 0x1e }; |
92 | #define VIA686A_REG_TEMP_LOW1 0x4b // bits 7-6 | 85 | /* bits 7-6 */ |
93 | #define VIA686A_REG_TEMP_LOW23 0x49 // 2 = bits 5-4, 3 = bits 7-6 | 86 | #define VIA686A_REG_TEMP_LOW1 0x4b |
94 | 87 | /* 2 = bits 5-4, 3 = bits 7-6 */ | |
95 | #define VIA686A_REG_ALARM1 0x41 | 88 | #define VIA686A_REG_TEMP_LOW23 0x49 |
96 | #define VIA686A_REG_ALARM2 0x42 | 89 | |
97 | #define VIA686A_REG_FANDIV 0x47 | 90 | #define VIA686A_REG_ALARM1 0x41 |
98 | #define VIA686A_REG_CONFIG 0x40 | 91 | #define VIA686A_REG_ALARM2 0x42 |
99 | /* The following register sets temp interrupt mode (bits 1-0 for temp1, | 92 | #define VIA686A_REG_FANDIV 0x47 |
93 | #define VIA686A_REG_CONFIG 0x40 | ||
94 | /* The following register sets temp interrupt mode (bits 1-0 for temp1, | ||
100 | 3-2 for temp2, 5-4 for temp3). Modes are: | 95 | 3-2 for temp2, 5-4 for temp3). Modes are: |
101 | 00 interrupt stays as long as value is out-of-range | 96 | 00 interrupt stays as long as value is out-of-range |
102 | 01 interrupt is cleared once register is read (default) | 97 | 01 interrupt is cleared once register is read (default) |
103 | 10 comparator mode- like 00, but ignores hysteresis | 98 | 10 comparator mode- like 00, but ignores hysteresis |
104 | 11 same as 00 */ | 99 | 11 same as 00 */ |
105 | #define VIA686A_REG_TEMP_MODE 0x4b | 100 | #define VIA686A_REG_TEMP_MODE 0x4b |
106 | /* We'll just assume that you want to set all 3 simultaneously: */ | 101 | /* We'll just assume that you want to set all 3 simultaneously: */ |
107 | #define VIA686A_TEMP_MODE_MASK 0x3F | 102 | #define VIA686A_TEMP_MODE_MASK 0x3F |
108 | #define VIA686A_TEMP_MODE_CONTINUOUS (0x00) | 103 | #define VIA686A_TEMP_MODE_CONTINUOUS 0x00 |
109 | 104 | ||
110 | /* Conversions. Limit checking is only done on the TO_REG | 105 | /* Conversions. Limit checking is only done on the TO_REG |
111 | variants. | 106 | variants. |
112 | 107 | ||
113 | ********* VOLTAGE CONVERSIONS (Bob Dougherty) ******** | 108 | ********* VOLTAGE CONVERSIONS (Bob Dougherty) ******** |
114 | From HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew): | 109 | From HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew): |
@@ -121,7 +116,7 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e }; | |||
121 | That is: | 116 | That is: |
122 | volts = (25*regVal+133)*factor | 117 | volts = (25*regVal+133)*factor |
123 | regVal = (volts/factor-133)/25 | 118 | regVal = (volts/factor-133)/25 |
124 | (These conversions were contributed by Jonathan Teh Soon Yew | 119 | (These conversions were contributed by Jonathan Teh Soon Yew |
125 | <j.teh@iname.com>) */ | 120 | <j.teh@iname.com>) */ |
126 | static inline u8 IN_TO_REG(long val, int inNum) | 121 | static inline u8 IN_TO_REG(long val, int inNum) |
127 | { | 122 | { |
@@ -182,55 +177,55 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
182 | else | 177 | else |
183 | return double(temp)*0.924-127.33; | 178 | return double(temp)*0.924-127.33; |
184 | 179 | ||
185 | A fifth-order polynomial fits the unofficial data (provided by Alex van | 180 | A fifth-order polynomial fits the unofficial data (provided by Alex van |
186 | Kaam <darkside@chello.nl>) a bit better. It also give more reasonable | 181 | Kaam <darkside@chello.nl>) a bit better. It also give more reasonable |
187 | numbers on my machine (ie. they agree with what my BIOS tells me). | 182 | numbers on my machine (ie. they agree with what my BIOS tells me). |
188 | Here's the fifth-order fit to the 8-bit data: | 183 | Here's the fifth-order fit to the 8-bit data: |
189 | temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - | 184 | temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - |
190 | 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0. | 185 | 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0. |
191 | 186 | ||
192 | (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for | 187 | (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for |
193 | finding my typos in this formula!) | 188 | finding my typos in this formula!) |
194 | 189 | ||
195 | Alas, none of the elegant function-fit solutions will work because we | 190 | Alas, none of the elegant function-fit solutions will work because we |
196 | aren't allowed to use floating point in the kernel and doing it with | 191 | aren't allowed to use floating point in the kernel and doing it with |
197 | integers doesn't rpovide enough precision. So we'll do boring old | 192 | integers doesn't provide enough precision. So we'll do boring old |
198 | look-up table stuff. The unofficial data (see below) have effectively | 193 | look-up table stuff. The unofficial data (see below) have effectively |
199 | 7-bit resolution (they are rounded to the nearest degree). I'm assuming | 194 | 7-bit resolution (they are rounded to the nearest degree). I'm assuming |
200 | that the transfer function of the device is monotonic and smooth, so a | 195 | that the transfer function of the device is monotonic and smooth, so a |
201 | smooth function fit to the data will allow us to get better precision. | 196 | smooth function fit to the data will allow us to get better precision. |
202 | I used the 5th-order poly fit described above and solved for | 197 | I used the 5th-order poly fit described above and solved for |
203 | VIA register values 0-255. I *10 before rounding, so we get tenth-degree | 198 | VIA register values 0-255. I *10 before rounding, so we get tenth-degree |
204 | precision. (I could have done all 1024 values for our 10-bit readings, | 199 | precision. (I could have done all 1024 values for our 10-bit readings, |
205 | but the function is very linear in the useful range (0-80 deg C), so | 200 | but the function is very linear in the useful range (0-80 deg C), so |
206 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT | 201 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT |
207 | is the temp at via register values 0-255: */ | 202 | is the temp at via register values 0-255: */ |
208 | static const long tempLUT[] = | 203 | static const long tempLUT[] = |
209 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, | 204 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, |
210 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, | 205 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, |
211 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, | 206 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, |
212 | -255, -246, -237, -229, -220, -212, -204, -196, -188, -180, | 207 | -255, -246, -237, -229, -220, -212, -204, -196, -188, -180, |
213 | -173, -166, -159, -152, -145, -139, -132, -126, -120, -114, | 208 | -173, -166, -159, -152, -145, -139, -132, -126, -120, -114, |
214 | -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49, | 209 | -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49, |
215 | -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16, | 210 | -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16, |
216 | 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84, | 211 | 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84, |
217 | 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138, | 212 | 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138, |
218 | 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189, | 213 | 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189, |
219 | 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241, | 214 | 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241, |
220 | 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294, | 215 | 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294, |
221 | 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348, | 216 | 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348, |
222 | 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404, | 217 | 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404, |
223 | 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464, | 218 | 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464, |
224 | 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532, | 219 | 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532, |
225 | 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614, | 220 | 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614, |
226 | 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718, | 221 | 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718, |
227 | 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856, | 222 | 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856, |
228 | 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044, | 223 | 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044, |
229 | 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252, | 224 | 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252, |
230 | 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462 | 225 | 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462 |
231 | }; | 226 | }; |
232 | 227 | ||
233 | /* the original LUT values from Alex van Kaam <darkside@chello.nl> | 228 | /* the original LUT values from Alex van Kaam <darkside@chello.nl> |
234 | (for via register values 12-240): | 229 | (for via register values 12-240): |
235 | {-50,-49,-47,-45,-43,-41,-39,-38,-37,-35,-34,-33,-32,-31, | 230 | {-50,-49,-47,-45,-43,-41,-39,-38,-37,-35,-34,-33,-32,-31, |
236 | -30,-29,-28,-27,-26,-25,-24,-24,-23,-22,-21,-20,-20,-19,-18,-17,-17,-16,-15, | 231 | -30,-29,-28,-27,-26,-25,-24,-24,-23,-22,-21,-20,-20,-19,-18,-17,-17,-16,-15, |
@@ -245,26 +240,26 @@ static const long tempLUT[] = | |||
245 | 240 | ||
246 | 241 | ||
247 | Here's the reverse LUT. I got it by doing a 6-th order poly fit (needed | 242 | Here's the reverse LUT. I got it by doing a 6-th order poly fit (needed |
248 | an extra term for a good fit to these inverse data!) and then | 243 | an extra term for a good fit to these inverse data!) and then |
249 | solving for each temp value from -50 to 110 (the useable range for | 244 | solving for each temp value from -50 to 110 (the useable range for |
250 | this chip). Here's the fit: | 245 | this chip). Here's the fit: |
251 | viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4 | 246 | viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4 |
252 | - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01) | 247 | - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01) |
253 | Note that n=161: */ | 248 | Note that n=161: */ |
254 | static const u8 viaLUT[] = | 249 | static const u8 viaLUT[] = |
255 | { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23, | 250 | { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23, |
256 | 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, | 251 | 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, |
257 | 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66, | 252 | 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66, |
258 | 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100, | 253 | 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100, |
259 | 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129, | 254 | 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129, |
260 | 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156, | 255 | 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156, |
261 | 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, | 256 | 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, |
262 | 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199, | 257 | 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199, |
263 | 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, | 258 | 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, |
264 | 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224, | 259 | 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224, |
265 | 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, | 260 | 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, |
266 | 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, | 261 | 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, |
267 | 239, 240 | 262 | 239, 240 |
268 | }; | 263 | }; |
269 | 264 | ||
270 | /* Converting temps to (8-bit) hyst and over registers | 265 | /* Converting temps to (8-bit) hyst and over registers |
@@ -272,7 +267,7 @@ static const u8 viaLUT[] = | |||
272 | The +50 is because the temps start at -50 */ | 267 | The +50 is because the temps start at -50 */ |
273 | static inline u8 TEMP_TO_REG(long val) | 268 | static inline u8 TEMP_TO_REG(long val) |
274 | { | 269 | { |
275 | return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 : | 270 | return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 : |
276 | (val < 0 ? val - 500 : val + 500) / 1000 + 50]; | 271 | (val < 0 ? val - 500 : val + 500) / 1000 + 50]; |
277 | } | 272 | } |
278 | 273 | ||
@@ -291,11 +286,9 @@ static inline long TEMP_FROM_REG10(u16 val) | |||
291 | 286 | ||
292 | /* do some linear interpolation */ | 287 | /* do some linear interpolation */ |
293 | return (tempLUT[eightBits] * (4 - twoBits) + | 288 | return (tempLUT[eightBits] * (4 - twoBits) + |
294 | tempLUT[eightBits + 1] * twoBits) * 25; | 289 | tempLUT[eightBits + 1] * twoBits) * 25; |
295 | } | 290 | } |
296 | 291 | ||
297 | #define ALARMS_FROM_REG(val) (val) | ||
298 | |||
299 | #define DIV_FROM_REG(val) (1 << (val)) | 292 | #define DIV_FROM_REG(val) (1 << (val)) |
300 | #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) | 293 | #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) |
301 | 294 | ||
@@ -358,28 +351,28 @@ static ssize_t show_in_max(struct device *dev, char *buf, int nr) { | |||
358 | return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr)); | 351 | return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr)); |
359 | } | 352 | } |
360 | 353 | ||
361 | static ssize_t set_in_min(struct device *dev, const char *buf, | 354 | static ssize_t set_in_min(struct device *dev, const char *buf, |
362 | size_t count, int nr) { | 355 | size_t count, int nr) { |
363 | struct i2c_client *client = to_i2c_client(dev); | 356 | struct i2c_client *client = to_i2c_client(dev); |
364 | struct via686a_data *data = i2c_get_clientdata(client); | 357 | struct via686a_data *data = i2c_get_clientdata(client); |
365 | unsigned long val = simple_strtoul(buf, NULL, 10); | 358 | unsigned long val = simple_strtoul(buf, NULL, 10); |
366 | 359 | ||
367 | down(&data->update_lock); | 360 | down(&data->update_lock); |
368 | data->in_min[nr] = IN_TO_REG(val,nr); | 361 | data->in_min[nr] = IN_TO_REG(val, nr); |
369 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), | 362 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), |
370 | data->in_min[nr]); | 363 | data->in_min[nr]); |
371 | up(&data->update_lock); | 364 | up(&data->update_lock); |
372 | return count; | 365 | return count; |
373 | } | 366 | } |
374 | static ssize_t set_in_max(struct device *dev, const char *buf, | 367 | static ssize_t set_in_max(struct device *dev, const char *buf, |
375 | size_t count, int nr) { | 368 | size_t count, int nr) { |
376 | struct i2c_client *client = to_i2c_client(dev); | 369 | struct i2c_client *client = to_i2c_client(dev); |
377 | struct via686a_data *data = i2c_get_clientdata(client); | 370 | struct via686a_data *data = i2c_get_clientdata(client); |
378 | unsigned long val = simple_strtoul(buf, NULL, 10); | 371 | unsigned long val = simple_strtoul(buf, NULL, 10); |
379 | 372 | ||
380 | down(&data->update_lock); | 373 | down(&data->update_lock); |
381 | data->in_max[nr] = IN_TO_REG(val,nr); | 374 | data->in_max[nr] = IN_TO_REG(val, nr); |
382 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), | 375 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), |
383 | data->in_max[nr]); | 376 | data->in_max[nr]); |
384 | up(&data->update_lock); | 377 | up(&data->update_lock); |
385 | return count; | 378 | return count; |
@@ -435,7 +428,7 @@ static ssize_t show_temp_hyst(struct device *dev, char *buf, int nr) { | |||
435 | struct via686a_data *data = via686a_update_device(dev); | 428 | struct via686a_data *data = via686a_update_device(dev); |
436 | return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr])); | 429 | return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr])); |
437 | } | 430 | } |
438 | static ssize_t set_temp_over(struct device *dev, const char *buf, | 431 | static ssize_t set_temp_over(struct device *dev, const char *buf, |
439 | size_t count, int nr) { | 432 | size_t count, int nr) { |
440 | struct i2c_client *client = to_i2c_client(dev); | 433 | struct i2c_client *client = to_i2c_client(dev); |
441 | struct via686a_data *data = i2c_get_clientdata(client); | 434 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -443,11 +436,12 @@ static ssize_t set_temp_over(struct device *dev, const char *buf, | |||
443 | 436 | ||
444 | down(&data->update_lock); | 437 | down(&data->update_lock); |
445 | data->temp_over[nr] = TEMP_TO_REG(val); | 438 | data->temp_over[nr] = TEMP_TO_REG(val); |
446 | via686a_write_value(client, VIA686A_REG_TEMP_OVER(nr), data->temp_over[nr]); | 439 | via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], |
440 | data->temp_over[nr]); | ||
447 | up(&data->update_lock); | 441 | up(&data->update_lock); |
448 | return count; | 442 | return count; |
449 | } | 443 | } |
450 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, | 444 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, |
451 | size_t count, int nr) { | 445 | size_t count, int nr) { |
452 | struct i2c_client *client = to_i2c_client(dev); | 446 | struct i2c_client *client = to_i2c_client(dev); |
453 | struct via686a_data *data = i2c_get_clientdata(client); | 447 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -455,7 +449,8 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf, | |||
455 | 449 | ||
456 | down(&data->update_lock); | 450 | down(&data->update_lock); |
457 | data->temp_hyst[nr] = TEMP_TO_REG(val); | 451 | data->temp_hyst[nr] = TEMP_TO_REG(val); |
458 | via686a_write_value(client, VIA686A_REG_TEMP_HYST(nr), data->temp_hyst[nr]); | 452 | via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], |
453 | data->temp_hyst[nr]); | ||
459 | up(&data->update_lock); | 454 | up(&data->update_lock); |
460 | return count; | 455 | return count; |
461 | } | 456 | } |
@@ -488,7 +483,7 @@ static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);\ | |||
488 | static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | 483 | static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
489 | show_temp_##offset##_over, set_temp_##offset##_over); \ | 484 | show_temp_##offset##_over, set_temp_##offset##_over); \ |
490 | static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ | 485 | static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ |
491 | show_temp_##offset##_hyst, set_temp_##offset##_hyst); | 486 | show_temp_##offset##_hyst, set_temp_##offset##_hyst); |
492 | 487 | ||
493 | show_temp_offset(1); | 488 | show_temp_offset(1); |
494 | show_temp_offset(2); | 489 | show_temp_offset(2); |
@@ -497,19 +492,19 @@ show_temp_offset(3); | |||
497 | /* 2 Fans */ | 492 | /* 2 Fans */ |
498 | static ssize_t show_fan(struct device *dev, char *buf, int nr) { | 493 | static ssize_t show_fan(struct device *dev, char *buf, int nr) { |
499 | struct via686a_data *data = via686a_update_device(dev); | 494 | struct via686a_data *data = via686a_update_device(dev); |
500 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], | 495 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], |
501 | DIV_FROM_REG(data->fan_div[nr])) ); | 496 | DIV_FROM_REG(data->fan_div[nr])) ); |
502 | } | 497 | } |
503 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { | 498 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { |
504 | struct via686a_data *data = via686a_update_device(dev); | 499 | struct via686a_data *data = via686a_update_device(dev); |
505 | return sprintf(buf,"%d\n", | 500 | return sprintf(buf, "%d\n", |
506 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) ); | 501 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) ); |
507 | } | 502 | } |
508 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { | 503 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { |
509 | struct via686a_data *data = via686a_update_device(dev); | 504 | struct via686a_data *data = via686a_update_device(dev); |
510 | return sprintf(buf,"%d\n", DIV_FROM_REG(data->fan_div[nr]) ); | 505 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]) ); |
511 | } | 506 | } |
512 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 507 | static ssize_t set_fan_min(struct device *dev, const char *buf, |
513 | size_t count, int nr) { | 508 | size_t count, int nr) { |
514 | struct i2c_client *client = to_i2c_client(dev); | 509 | struct i2c_client *client = to_i2c_client(dev); |
515 | struct via686a_data *data = i2c_get_clientdata(client); | 510 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -521,7 +516,7 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
521 | up(&data->update_lock); | 516 | up(&data->update_lock); |
522 | return count; | 517 | return count; |
523 | } | 518 | } |
524 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 519 | static ssize_t set_fan_div(struct device *dev, const char *buf, |
525 | size_t count, int nr) { | 520 | size_t count, int nr) { |
526 | struct i2c_client *client = to_i2c_client(dev); | 521 | struct i2c_client *client = to_i2c_client(dev); |
527 | struct via686a_data *data = i2c_get_clientdata(client); | 522 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -572,7 +567,7 @@ show_fan_offset(2); | |||
572 | /* Alarms */ | 567 | /* Alarms */ |
573 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) { | 568 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) { |
574 | struct via686a_data *data = via686a_update_device(dev); | 569 | struct via686a_data *data = via686a_update_device(dev); |
575 | return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); | 570 | return sprintf(buf, "%u\n", data->alarms); |
576 | } | 571 | } |
577 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 572 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
578 | 573 | ||
@@ -612,11 +607,12 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
612 | } | 607 | } |
613 | 608 | ||
614 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ | 609 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ |
615 | if(force_addr) | 610 | if (force_addr) |
616 | address = force_addr & 0xFF00; | 611 | address = force_addr & 0xFF00; |
617 | 612 | ||
618 | if(force_addr) { | 613 | if (force_addr) { |
619 | dev_warn(&adapter->dev,"forcing ISA address 0x%04X\n", address); | 614 | dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", |
615 | address); | ||
620 | if (PCIBIOS_SUCCESSFUL != | 616 | if (PCIBIOS_SUCCESSFUL != |
621 | pci_write_config_word(s_bridge, VIA686A_BASE_REG, address)) | 617 | pci_write_config_word(s_bridge, VIA686A_BASE_REG, address)) |
622 | return -ENODEV; | 618 | return -ENODEV; |
@@ -625,17 +621,17 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
625 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) | 621 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) |
626 | return -ENODEV; | 622 | return -ENODEV; |
627 | if (!(val & 0x0001)) { | 623 | if (!(val & 0x0001)) { |
628 | dev_warn(&adapter->dev,"enabling sensors\n"); | 624 | dev_warn(&adapter->dev, "enabling sensors\n"); |
629 | if (PCIBIOS_SUCCESSFUL != | 625 | if (PCIBIOS_SUCCESSFUL != |
630 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, | 626 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, |
631 | val | 0x0001)) | 627 | val | 0x0001)) |
632 | return -ENODEV; | 628 | return -ENODEV; |
633 | } | 629 | } |
634 | 630 | ||
635 | /* Reserve the ISA region */ | 631 | /* Reserve the ISA region */ |
636 | if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { | 632 | if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { |
637 | dev_err(&adapter->dev,"region 0x%x already in use!\n", | 633 | dev_err(&adapter->dev, "region 0x%x already in use!\n", |
638 | address); | 634 | address); |
639 | return -ENODEV; | 635 | return -ENODEV; |
640 | } | 636 | } |
641 | 637 | ||
@@ -660,7 +656,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
660 | /* Tell the I2C layer a new client has arrived */ | 656 | /* Tell the I2C layer a new client has arrived */ |
661 | if ((err = i2c_attach_client(new_client))) | 657 | if ((err = i2c_attach_client(new_client))) |
662 | goto ERROR3; | 658 | goto ERROR3; |
663 | 659 | ||
664 | /* Initialize the VIA686A chip */ | 660 | /* Initialize the VIA686A chip */ |
665 | via686a_init_client(new_client); | 661 | via686a_init_client(new_client); |
666 | 662 | ||
@@ -699,9 +695,9 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
699 | 695 | ||
700 | return 0; | 696 | return 0; |
701 | 697 | ||
702 | ERROR3: | 698 | ERROR3: |
703 | kfree(data); | 699 | kfree(data); |
704 | ERROR0: | 700 | ERROR0: |
705 | release_region(address, VIA686A_EXTENT); | 701 | release_region(address, VIA686A_EXTENT); |
706 | return err; | 702 | return err; |
707 | } | 703 | } |
@@ -732,7 +728,7 @@ static void via686a_init_client(struct i2c_client *client) | |||
732 | via686a_write_value(client, VIA686A_REG_CONFIG, (reg|0x01)&0x7F); | 728 | via686a_write_value(client, VIA686A_REG_CONFIG, (reg|0x01)&0x7F); |
733 | 729 | ||
734 | /* Configure temp interrupt mode for continuous-interrupt operation */ | 730 | /* Configure temp interrupt mode for continuous-interrupt operation */ |
735 | via686a_write_value(client, VIA686A_REG_TEMP_MODE, | 731 | via686a_write_value(client, VIA686A_REG_TEMP_MODE, |
736 | via686a_read_value(client, VIA686A_REG_TEMP_MODE) & | 732 | via686a_read_value(client, VIA686A_REG_TEMP_MODE) & |
737 | !(VIA686A_TEMP_MODE_MASK | VIA686A_TEMP_MODE_CONTINUOUS)); | 733 | !(VIA686A_TEMP_MODE_MASK | VIA686A_TEMP_MODE_CONTINUOUS)); |
738 | } | 734 | } |
@@ -764,15 +760,15 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
764 | } | 760 | } |
765 | for (i = 0; i <= 2; i++) { | 761 | for (i = 0; i <= 2; i++) { |
766 | data->temp[i] = via686a_read_value(client, | 762 | data->temp[i] = via686a_read_value(client, |
767 | VIA686A_REG_TEMP(i)) << 2; | 763 | VIA686A_REG_TEMP[i]) << 2; |
768 | data->temp_over[i] = | 764 | data->temp_over[i] = |
769 | via686a_read_value(client, | 765 | via686a_read_value(client, |
770 | VIA686A_REG_TEMP_OVER(i)); | 766 | VIA686A_REG_TEMP_OVER[i]); |
771 | data->temp_hyst[i] = | 767 | data->temp_hyst[i] = |
772 | via686a_read_value(client, | 768 | via686a_read_value(client, |
773 | VIA686A_REG_TEMP_HYST(i)); | 769 | VIA686A_REG_TEMP_HYST[i]); |
774 | } | 770 | } |
775 | /* add in lower 2 bits | 771 | /* add in lower 2 bits |
776 | temp1 uses bits 7-6 of VIA686A_REG_TEMP_LOW1 | 772 | temp1 uses bits 7-6 of VIA686A_REG_TEMP_LOW1 |
777 | temp2 uses bits 5-4 of VIA686A_REG_TEMP_LOW23 | 773 | temp2 uses bits 5-4 of VIA686A_REG_TEMP_LOW23 |
778 | temp3 uses bits 7-6 of VIA686A_REG_TEMP_LOW23 | 774 | temp3 uses bits 7-6 of VIA686A_REG_TEMP_LOW23 |
@@ -804,35 +800,36 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
804 | } | 800 | } |
805 | 801 | ||
806 | static struct pci_device_id via686a_pci_ids[] = { | 802 | static struct pci_device_id via686a_pci_ids[] = { |
807 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, | 803 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, |
808 | { 0, } | 804 | { 0, } |
809 | }; | 805 | }; |
810 | 806 | ||
811 | MODULE_DEVICE_TABLE(pci, via686a_pci_ids); | 807 | MODULE_DEVICE_TABLE(pci, via686a_pci_ids); |
812 | 808 | ||
813 | static int __devinit via686a_pci_probe(struct pci_dev *dev, | 809 | static int __devinit via686a_pci_probe(struct pci_dev *dev, |
814 | const struct pci_device_id *id) | 810 | const struct pci_device_id *id) |
815 | { | 811 | { |
816 | u16 val; | 812 | u16 val; |
817 | int addr = 0; | 813 | int addr = 0; |
818 | 814 | ||
819 | if (PCIBIOS_SUCCESSFUL != | 815 | if (PCIBIOS_SUCCESSFUL != |
820 | pci_read_config_word(dev, VIA686A_BASE_REG, &val)) | 816 | pci_read_config_word(dev, VIA686A_BASE_REG, &val)) |
821 | return -ENODEV; | 817 | return -ENODEV; |
822 | 818 | ||
823 | addr = val & ~(VIA686A_EXTENT - 1); | 819 | addr = val & ~(VIA686A_EXTENT - 1); |
824 | if (addr == 0 && force_addr == 0) { | 820 | if (addr == 0 && force_addr == 0) { |
825 | dev_err(&dev->dev,"base address not set - upgrade BIOS or use force_addr=0xaddr\n"); | 821 | dev_err(&dev->dev, "base address not set - upgrade BIOS " |
826 | return -ENODEV; | 822 | "or use force_addr=0xaddr\n"); |
827 | } | 823 | return -ENODEV; |
828 | if (force_addr) | 824 | } |
829 | addr = force_addr; /* so detect will get called */ | 825 | if (force_addr) |
830 | 826 | addr = force_addr; /* so detect will get called */ | |
831 | if (!addr) { | 827 | |
832 | dev_err(&dev->dev,"No Via 686A sensors found.\n"); | 828 | if (!addr) { |
833 | return -ENODEV; | 829 | dev_err(&dev->dev, "No Via 686A sensors found.\n"); |
834 | } | 830 | return -ENODEV; |
835 | normal_isa[0] = addr; | 831 | } |
832 | normal_isa[0] = addr; | ||
836 | 833 | ||
837 | s_bridge = pci_dev_get(dev); | 834 | s_bridge = pci_dev_get(dev); |
838 | if (i2c_add_driver(&via686a_driver)) { | 835 | if (i2c_add_driver(&via686a_driver)) { |
@@ -848,14 +845,14 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev, | |||
848 | } | 845 | } |
849 | 846 | ||
850 | static struct pci_driver via686a_pci_driver = { | 847 | static struct pci_driver via686a_pci_driver = { |
851 | .name = "via686a", | 848 | .name = "via686a", |
852 | .id_table = via686a_pci_ids, | 849 | .id_table = via686a_pci_ids, |
853 | .probe = via686a_pci_probe, | 850 | .probe = via686a_pci_probe, |
854 | }; | 851 | }; |
855 | 852 | ||
856 | static int __init sm_via686a_init(void) | 853 | static int __init sm_via686a_init(void) |
857 | { | 854 | { |
858 | return pci_register_driver(&via686a_pci_driver); | 855 | return pci_register_driver(&via686a_pci_driver); |
859 | } | 856 | } |
860 | 857 | ||
861 | static void __exit sm_via686a_exit(void) | 858 | static void __exit sm_via686a_exit(void) |
@@ -869,8 +866,8 @@ static void __exit sm_via686a_exit(void) | |||
869 | } | 866 | } |
870 | 867 | ||
871 | MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>, " | 868 | MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>, " |
872 | "Mark Studebaker <mdsxyz123@yahoo.com> " | 869 | "Mark Studebaker <mdsxyz123@yahoo.com> " |
873 | "and Bob Dougherty <bobd@stanford.edu>"); | 870 | "and Bob Dougherty <bobd@stanford.edu>"); |
874 | MODULE_DESCRIPTION("VIA 686A Sensor device"); | 871 | MODULE_DESCRIPTION("VIA 686A Sensor device"); |
875 | MODULE_LICENSE("GPL"); | 872 | MODULE_LICENSE("GPL"); |
876 | 873 | ||
diff --git a/drivers/i2c/chips/w83627ehf.c b/drivers/i2c/chips/w83627ehf.c new file mode 100644 index 000000000000..8a40b6976e1a --- /dev/null +++ b/drivers/i2c/chips/w83627ehf.c | |||
@@ -0,0 +1,846 @@ | |||
1 | /* | ||
2 | w83627ehf - Driver for the hardware monitoring functionality of | ||
3 | the Winbond W83627EHF Super-I/O chip | ||
4 | Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> | ||
5 | |||
6 | Shamelessly ripped from the w83627hf driver | ||
7 | Copyright (C) 2003 Mark Studebaker | ||
8 | |||
9 | Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help | ||
10 | in testing and debugging this driver. | ||
11 | |||
12 | This program is free software; you can redistribute it and/or modify | ||
13 | it under the terms of the GNU General Public License as published by | ||
14 | the Free Software Foundation; either version 2 of the License, or | ||
15 | (at your option) any later version. | ||
16 | |||
17 | This program is distributed in the hope that it will be useful, | ||
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | GNU General Public License for more details. | ||
21 | |||
22 | You should have received a copy of the GNU General Public License | ||
23 | along with this program; if not, write to the Free Software | ||
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | |||
26 | |||
27 | Supports the following chips: | ||
28 | |||
29 | Chip #vin #fan #pwm #temp chip_id man_id | ||
30 | w83627ehf - 5 - 3 0x88 0x5ca3 | ||
31 | |||
32 | This is a preliminary version of the driver, only supporting the | ||
33 | fan and temperature inputs. The chip does much more than that. | ||
34 | */ | ||
35 | |||
36 | #include <linux/module.h> | ||
37 | #include <linux/init.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/i2c.h> | ||
40 | #include <linux/i2c-sensor.h> | ||
41 | #include <asm/io.h> | ||
42 | #include "lm75.h" | ||
43 | |||
44 | /* Addresses to scan | ||
45 | The actual ISA address is read from Super-I/O configuration space */ | ||
46 | static unsigned short normal_i2c[] = { I2C_CLIENT_END }; | ||
47 | static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END }; | ||
48 | |||
49 | /* Insmod parameters */ | ||
50 | SENSORS_INSMOD_1(w83627ehf); | ||
51 | |||
52 | /* | ||
53 | * Super-I/O constants and functions | ||
54 | */ | ||
55 | |||
56 | static int REG; /* The register to read/write */ | ||
57 | static int VAL; /* The value to read/write */ | ||
58 | |||
59 | #define W83627EHF_LD_HWM 0x0b | ||
60 | |||
61 | #define SIO_REG_LDSEL 0x07 /* Logical device select */ | ||
62 | #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ | ||
63 | #define SIO_REG_ENABLE 0x30 /* Logical device enable */ | ||
64 | #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ | ||
65 | |||
66 | #define SIO_W83627EHF_ID 0x8840 | ||
67 | #define SIO_ID_MASK 0xFFC0 | ||
68 | |||
69 | static inline void | ||
70 | superio_outb(int reg, int val) | ||
71 | { | ||
72 | outb(reg, REG); | ||
73 | outb(val, VAL); | ||
74 | } | ||
75 | |||
76 | static inline int | ||
77 | superio_inb(int reg) | ||
78 | { | ||
79 | outb(reg, REG); | ||
80 | return inb(VAL); | ||
81 | } | ||
82 | |||
83 | static inline void | ||
84 | superio_select(int ld) | ||
85 | { | ||
86 | outb(SIO_REG_LDSEL, REG); | ||
87 | outb(ld, VAL); | ||
88 | } | ||
89 | |||
90 | static inline void | ||
91 | superio_enter(void) | ||
92 | { | ||
93 | outb(0x87, REG); | ||
94 | outb(0x87, REG); | ||
95 | } | ||
96 | |||
97 | static inline void | ||
98 | superio_exit(void) | ||
99 | { | ||
100 | outb(0x02, REG); | ||
101 | outb(0x02, VAL); | ||
102 | } | ||
103 | |||
104 | /* | ||
105 | * ISA constants | ||
106 | */ | ||
107 | |||
108 | #define REGION_LENGTH 8 | ||
109 | #define ADDR_REG_OFFSET 5 | ||
110 | #define DATA_REG_OFFSET 6 | ||
111 | |||
112 | #define W83627EHF_REG_BANK 0x4E | ||
113 | #define W83627EHF_REG_CONFIG 0x40 | ||
114 | #define W83627EHF_REG_CHIP_ID 0x49 | ||
115 | #define W83627EHF_REG_MAN_ID 0x4F | ||
116 | |||
117 | static const u16 W83627EHF_REG_FAN[] = { 0x28, 0x29, 0x2a, 0x3f, 0x553 }; | ||
118 | static const u16 W83627EHF_REG_FAN_MIN[] = { 0x3b, 0x3c, 0x3d, 0x3e, 0x55c }; | ||
119 | |||
120 | #define W83627EHF_REG_TEMP1 0x27 | ||
121 | #define W83627EHF_REG_TEMP1_HYST 0x3a | ||
122 | #define W83627EHF_REG_TEMP1_OVER 0x39 | ||
123 | static const u16 W83627EHF_REG_TEMP[] = { 0x150, 0x250 }; | ||
124 | static const u16 W83627EHF_REG_TEMP_HYST[] = { 0x153, 0x253 }; | ||
125 | static const u16 W83627EHF_REG_TEMP_OVER[] = { 0x155, 0x255 }; | ||
126 | static const u16 W83627EHF_REG_TEMP_CONFIG[] = { 0x152, 0x252 }; | ||
127 | |||
128 | /* Fan clock dividers are spread over the following five registers */ | ||
129 | #define W83627EHF_REG_FANDIV1 0x47 | ||
130 | #define W83627EHF_REG_FANDIV2 0x4B | ||
131 | #define W83627EHF_REG_VBAT 0x5D | ||
132 | #define W83627EHF_REG_DIODE 0x59 | ||
133 | #define W83627EHF_REG_SMI_OVT 0x4C | ||
134 | |||
135 | /* | ||
136 | * Conversions | ||
137 | */ | ||
138 | |||
139 | static inline unsigned int | ||
140 | fan_from_reg(u8 reg, unsigned int div) | ||
141 | { | ||
142 | if (reg == 0 || reg == 255) | ||
143 | return 0; | ||
144 | return 1350000U / (reg * div); | ||
145 | } | ||
146 | |||
147 | static inline unsigned int | ||
148 | div_from_reg(u8 reg) | ||
149 | { | ||
150 | return 1 << reg; | ||
151 | } | ||
152 | |||
153 | static inline int | ||
154 | temp1_from_reg(s8 reg) | ||
155 | { | ||
156 | return reg * 1000; | ||
157 | } | ||
158 | |||
159 | static inline s8 | ||
160 | temp1_to_reg(int temp) | ||
161 | { | ||
162 | if (temp <= -128000) | ||
163 | return -128; | ||
164 | if (temp >= 127000) | ||
165 | return 127; | ||
166 | if (temp < 0) | ||
167 | return (temp - 500) / 1000; | ||
168 | return (temp + 500) / 1000; | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * Data structures and manipulation thereof | ||
173 | */ | ||
174 | |||
175 | struct w83627ehf_data { | ||
176 | struct i2c_client client; | ||
177 | struct semaphore lock; | ||
178 | |||
179 | struct semaphore update_lock; | ||
180 | char valid; /* !=0 if following fields are valid */ | ||
181 | unsigned long last_updated; /* In jiffies */ | ||
182 | |||
183 | /* Register values */ | ||
184 | u8 fan[5]; | ||
185 | u8 fan_min[5]; | ||
186 | u8 fan_div[5]; | ||
187 | u8 has_fan; /* some fan inputs can be disabled */ | ||
188 | s8 temp1; | ||
189 | s8 temp1_max; | ||
190 | s8 temp1_max_hyst; | ||
191 | s16 temp[2]; | ||
192 | s16 temp_max[2]; | ||
193 | s16 temp_max_hyst[2]; | ||
194 | }; | ||
195 | |||
196 | static inline int is_word_sized(u16 reg) | ||
197 | { | ||
198 | return (((reg & 0xff00) == 0x100 | ||
199 | || (reg & 0xff00) == 0x200) | ||
200 | && ((reg & 0x00ff) == 0x50 | ||
201 | || (reg & 0x00ff) == 0x53 | ||
202 | || (reg & 0x00ff) == 0x55)); | ||
203 | } | ||
204 | |||
205 | /* We assume that the default bank is 0, thus the following two functions do | ||
206 | nothing for registers which live in bank 0. For others, they respectively | ||
207 | set the bank register to the correct value (before the register is | ||
208 | accessed), and back to 0 (afterwards). */ | ||
209 | static inline void w83627ehf_set_bank(struct i2c_client *client, u16 reg) | ||
210 | { | ||
211 | if (reg & 0xff00) { | ||
212 | outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET); | ||
213 | outb_p(reg >> 8, client->addr + DATA_REG_OFFSET); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | static inline void w83627ehf_reset_bank(struct i2c_client *client, u16 reg) | ||
218 | { | ||
219 | if (reg & 0xff00) { | ||
220 | outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET); | ||
221 | outb_p(0, client->addr + DATA_REG_OFFSET); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | ||
226 | { | ||
227 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
228 | int res, word_sized = is_word_sized(reg); | ||
229 | |||
230 | down(&data->lock); | ||
231 | |||
232 | w83627ehf_set_bank(client, reg); | ||
233 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | ||
234 | res = inb_p(client->addr + DATA_REG_OFFSET); | ||
235 | if (word_sized) { | ||
236 | outb_p((reg & 0xff) + 1, | ||
237 | client->addr + ADDR_REG_OFFSET); | ||
238 | res = (res << 8) + inb_p(client->addr + DATA_REG_OFFSET); | ||
239 | } | ||
240 | w83627ehf_reset_bank(client, reg); | ||
241 | |||
242 | up(&data->lock); | ||
243 | |||
244 | return res; | ||
245 | } | ||
246 | |||
247 | static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | ||
248 | { | ||
249 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
250 | int word_sized = is_word_sized(reg); | ||
251 | |||
252 | down(&data->lock); | ||
253 | |||
254 | w83627ehf_set_bank(client, reg); | ||
255 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | ||
256 | if (word_sized) { | ||
257 | outb_p(value >> 8, client->addr + DATA_REG_OFFSET); | ||
258 | outb_p((reg & 0xff) + 1, | ||
259 | client->addr + ADDR_REG_OFFSET); | ||
260 | } | ||
261 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); | ||
262 | w83627ehf_reset_bank(client, reg); | ||
263 | |||
264 | up(&data->lock); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | /* This function assumes that the caller holds data->update_lock */ | ||
269 | static void w83627ehf_write_fan_div(struct i2c_client *client, int nr) | ||
270 | { | ||
271 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
272 | u8 reg; | ||
273 | |||
274 | switch (nr) { | ||
275 | case 0: | ||
276 | reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0xcf) | ||
277 | | ((data->fan_div[0] & 0x03) << 4); | ||
278 | w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); | ||
279 | reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xdf) | ||
280 | | ((data->fan_div[0] & 0x04) << 3); | ||
281 | w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); | ||
282 | break; | ||
283 | case 1: | ||
284 | reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0x3f) | ||
285 | | ((data->fan_div[1] & 0x03) << 6); | ||
286 | w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); | ||
287 | reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xbf) | ||
288 | | ((data->fan_div[1] & 0x04) << 4); | ||
289 | w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); | ||
290 | break; | ||
291 | case 2: | ||
292 | reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV2) & 0x3f) | ||
293 | | ((data->fan_div[2] & 0x03) << 6); | ||
294 | w83627ehf_write_value(client, W83627EHF_REG_FANDIV2, reg); | ||
295 | reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0x7f) | ||
296 | | ((data->fan_div[2] & 0x04) << 5); | ||
297 | w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); | ||
298 | break; | ||
299 | case 3: | ||
300 | reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0xfc) | ||
301 | | (data->fan_div[3] & 0x03); | ||
302 | w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg); | ||
303 | reg = (w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT) & 0x7f) | ||
304 | | ((data->fan_div[3] & 0x04) << 5); | ||
305 | w83627ehf_write_value(client, W83627EHF_REG_SMI_OVT, reg); | ||
306 | break; | ||
307 | case 4: | ||
308 | reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0x73) | ||
309 | | ((data->fan_div[4] & 0x03) << 3) | ||
310 | | ((data->fan_div[4] & 0x04) << 5); | ||
311 | w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg); | ||
312 | break; | ||
313 | } | ||
314 | } | ||
315 | |||
316 | static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | ||
317 | { | ||
318 | struct i2c_client *client = to_i2c_client(dev); | ||
319 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
320 | int i; | ||
321 | |||
322 | down(&data->update_lock); | ||
323 | |||
324 | if (time_after(jiffies, data->last_updated + HZ) | ||
325 | || !data->valid) { | ||
326 | /* Fan clock dividers */ | ||
327 | i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1); | ||
328 | data->fan_div[0] = (i >> 4) & 0x03; | ||
329 | data->fan_div[1] = (i >> 6) & 0x03; | ||
330 | i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV2); | ||
331 | data->fan_div[2] = (i >> 6) & 0x03; | ||
332 | i = w83627ehf_read_value(client, W83627EHF_REG_VBAT); | ||
333 | data->fan_div[0] |= (i >> 3) & 0x04; | ||
334 | data->fan_div[1] |= (i >> 4) & 0x04; | ||
335 | data->fan_div[2] |= (i >> 5) & 0x04; | ||
336 | if (data->has_fan & ((1 << 3) | (1 << 4))) { | ||
337 | i = w83627ehf_read_value(client, W83627EHF_REG_DIODE); | ||
338 | data->fan_div[3] = i & 0x03; | ||
339 | data->fan_div[4] = ((i >> 2) & 0x03) | ||
340 | | ((i >> 5) & 0x04); | ||
341 | } | ||
342 | if (data->has_fan & (1 << 3)) { | ||
343 | i = w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT); | ||
344 | data->fan_div[3] |= (i >> 5) & 0x04; | ||
345 | } | ||
346 | |||
347 | /* Measured fan speeds and limits */ | ||
348 | for (i = 0; i < 5; i++) { | ||
349 | if (!(data->has_fan & (1 << i))) | ||
350 | continue; | ||
351 | |||
352 | data->fan[i] = w83627ehf_read_value(client, | ||
353 | W83627EHF_REG_FAN[i]); | ||
354 | data->fan_min[i] = w83627ehf_read_value(client, | ||
355 | W83627EHF_REG_FAN_MIN[i]); | ||
356 | |||
357 | /* If we failed to measure the fan speed and clock | ||
358 | divider can be increased, let's try that for next | ||
359 | time */ | ||
360 | if (data->fan[i] == 0xff | ||
361 | && data->fan_div[i] < 0x07) { | ||
362 | dev_dbg(&client->dev, "Increasing fan %d " | ||
363 | "clock divider from %u to %u\n", | ||
364 | i, div_from_reg(data->fan_div[i]), | ||
365 | div_from_reg(data->fan_div[i] + 1)); | ||
366 | data->fan_div[i]++; | ||
367 | w83627ehf_write_fan_div(client, i); | ||
368 | /* Preserve min limit if possible */ | ||
369 | if (data->fan_min[i] >= 2 | ||
370 | && data->fan_min[i] != 255) | ||
371 | w83627ehf_write_value(client, | ||
372 | W83627EHF_REG_FAN_MIN[i], | ||
373 | (data->fan_min[i] /= 2)); | ||
374 | } | ||
375 | } | ||
376 | |||
377 | /* Measured temperatures and limits */ | ||
378 | data->temp1 = w83627ehf_read_value(client, | ||
379 | W83627EHF_REG_TEMP1); | ||
380 | data->temp1_max = w83627ehf_read_value(client, | ||
381 | W83627EHF_REG_TEMP1_OVER); | ||
382 | data->temp1_max_hyst = w83627ehf_read_value(client, | ||
383 | W83627EHF_REG_TEMP1_HYST); | ||
384 | for (i = 0; i < 2; i++) { | ||
385 | data->temp[i] = w83627ehf_read_value(client, | ||
386 | W83627EHF_REG_TEMP[i]); | ||
387 | data->temp_max[i] = w83627ehf_read_value(client, | ||
388 | W83627EHF_REG_TEMP_OVER[i]); | ||
389 | data->temp_max_hyst[i] = w83627ehf_read_value(client, | ||
390 | W83627EHF_REG_TEMP_HYST[i]); | ||
391 | } | ||
392 | |||
393 | data->last_updated = jiffies; | ||
394 | data->valid = 1; | ||
395 | } | ||
396 | |||
397 | up(&data->update_lock); | ||
398 | return data; | ||
399 | } | ||
400 | |||
401 | /* | ||
402 | * Sysfs callback functions | ||
403 | */ | ||
404 | |||
405 | #define show_fan_reg(reg) \ | ||
406 | static ssize_t \ | ||
407 | show_##reg(struct device *dev, char *buf, int nr) \ | ||
408 | { \ | ||
409 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | ||
410 | return sprintf(buf, "%d\n", \ | ||
411 | fan_from_reg(data->reg[nr], \ | ||
412 | div_from_reg(data->fan_div[nr]))); \ | ||
413 | } | ||
414 | show_fan_reg(fan); | ||
415 | show_fan_reg(fan_min); | ||
416 | |||
417 | static ssize_t | ||
418 | show_fan_div(struct device *dev, char *buf, int nr) | ||
419 | { | ||
420 | struct w83627ehf_data *data = w83627ehf_update_device(dev); | ||
421 | return sprintf(buf, "%u\n", | ||
422 | div_from_reg(data->fan_div[nr])); | ||
423 | } | ||
424 | |||
425 | static ssize_t | ||
426 | store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | ||
427 | { | ||
428 | struct i2c_client *client = to_i2c_client(dev); | ||
429 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
430 | unsigned int val = simple_strtoul(buf, NULL, 10); | ||
431 | unsigned int reg; | ||
432 | u8 new_div; | ||
433 | |||
434 | down(&data->update_lock); | ||
435 | if (!val) { | ||
436 | /* No min limit, alarm disabled */ | ||
437 | data->fan_min[nr] = 255; | ||
438 | new_div = data->fan_div[nr]; /* No change */ | ||
439 | dev_info(dev, "fan%u low limit and alarm disabled\n", nr + 1); | ||
440 | } else if ((reg = 1350000U / val) >= 128 * 255) { | ||
441 | /* Speed below this value cannot possibly be represented, | ||
442 | even with the highest divider (128) */ | ||
443 | data->fan_min[nr] = 254; | ||
444 | new_div = 7; /* 128 == (1 << 7) */ | ||
445 | dev_warn(dev, "fan%u low limit %u below minimum %u, set to " | ||
446 | "minimum\n", nr + 1, val, fan_from_reg(254, 128)); | ||
447 | } else if (!reg) { | ||
448 | /* Speed above this value cannot possibly be represented, | ||
449 | even with the lowest divider (1) */ | ||
450 | data->fan_min[nr] = 1; | ||
451 | new_div = 0; /* 1 == (1 << 0) */ | ||
452 | dev_warn(dev, "fan%u low limit %u above maximum %u, set to " | ||
453 | "maximum\n", nr + 1, val, fan_from_reg(1, 1)); | ||
454 | } else { | ||
455 | /* Automatically pick the best divider, i.e. the one such | ||
456 | that the min limit will correspond to a register value | ||
457 | in the 96..192 range */ | ||
458 | new_div = 0; | ||
459 | while (reg > 192 && new_div < 7) { | ||
460 | reg >>= 1; | ||
461 | new_div++; | ||
462 | } | ||
463 | data->fan_min[nr] = reg; | ||
464 | } | ||
465 | |||
466 | /* Write both the fan clock divider (if it changed) and the new | ||
467 | fan min (unconditionally) */ | ||
468 | if (new_div != data->fan_div[nr]) { | ||
469 | if (new_div > data->fan_div[nr]) | ||
470 | data->fan[nr] >>= (data->fan_div[nr] - new_div); | ||
471 | else | ||
472 | data->fan[nr] <<= (new_div - data->fan_div[nr]); | ||
473 | |||
474 | dev_dbg(dev, "fan%u clock divider changed from %u to %u\n", | ||
475 | nr + 1, div_from_reg(data->fan_div[nr]), | ||
476 | div_from_reg(new_div)); | ||
477 | data->fan_div[nr] = new_div; | ||
478 | w83627ehf_write_fan_div(client, nr); | ||
479 | } | ||
480 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], | ||
481 | data->fan_min[nr]); | ||
482 | up(&data->update_lock); | ||
483 | |||
484 | return count; | ||
485 | } | ||
486 | |||
487 | #define sysfs_fan_offset(offset) \ | ||
488 | static ssize_t \ | ||
489 | show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \ | ||
490 | char *buf) \ | ||
491 | { \ | ||
492 | return show_fan(dev, buf, offset-1); \ | ||
493 | } \ | ||
494 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
495 | show_reg_fan_##offset, NULL); | ||
496 | |||
497 | #define sysfs_fan_min_offset(offset) \ | ||
498 | static ssize_t \ | ||
499 | show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | ||
500 | char *buf) \ | ||
501 | { \ | ||
502 | return show_fan_min(dev, buf, offset-1); \ | ||
503 | } \ | ||
504 | static ssize_t \ | ||
505 | store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | ||
506 | const char *buf, size_t count) \ | ||
507 | { \ | ||
508 | return store_fan_min(dev, buf, count, offset-1); \ | ||
509 | } \ | ||
510 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
511 | show_reg_fan##offset##_min, \ | ||
512 | store_reg_fan##offset##_min); | ||
513 | |||
514 | #define sysfs_fan_div_offset(offset) \ | ||
515 | static ssize_t \ | ||
516 | show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \ | ||
517 | char *buf) \ | ||
518 | { \ | ||
519 | return show_fan_div(dev, buf, offset - 1); \ | ||
520 | } \ | ||
521 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | ||
522 | show_reg_fan##offset##_div, NULL); | ||
523 | |||
524 | sysfs_fan_offset(1); | ||
525 | sysfs_fan_min_offset(1); | ||
526 | sysfs_fan_div_offset(1); | ||
527 | sysfs_fan_offset(2); | ||
528 | sysfs_fan_min_offset(2); | ||
529 | sysfs_fan_div_offset(2); | ||
530 | sysfs_fan_offset(3); | ||
531 | sysfs_fan_min_offset(3); | ||
532 | sysfs_fan_div_offset(3); | ||
533 | sysfs_fan_offset(4); | ||
534 | sysfs_fan_min_offset(4); | ||
535 | sysfs_fan_div_offset(4); | ||
536 | sysfs_fan_offset(5); | ||
537 | sysfs_fan_min_offset(5); | ||
538 | sysfs_fan_div_offset(5); | ||
539 | |||
540 | #define show_temp1_reg(reg) \ | ||
541 | static ssize_t \ | ||
542 | show_##reg(struct device *dev, struct device_attribute *attr, \ | ||
543 | char *buf) \ | ||
544 | { \ | ||
545 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | ||
546 | return sprintf(buf, "%d\n", temp1_from_reg(data->reg)); \ | ||
547 | } | ||
548 | show_temp1_reg(temp1); | ||
549 | show_temp1_reg(temp1_max); | ||
550 | show_temp1_reg(temp1_max_hyst); | ||
551 | |||
552 | #define store_temp1_reg(REG, reg) \ | ||
553 | static ssize_t \ | ||
554 | store_temp1_##reg(struct device *dev, struct device_attribute *attr, \ | ||
555 | const char *buf, size_t count) \ | ||
556 | { \ | ||
557 | struct i2c_client *client = to_i2c_client(dev); \ | ||
558 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | ||
559 | u32 val = simple_strtoul(buf, NULL, 10); \ | ||
560 | \ | ||
561 | down(&data->update_lock); \ | ||
562 | data->temp1_##reg = temp1_to_reg(val); \ | ||
563 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ | ||
564 | data->temp1_##reg); \ | ||
565 | up(&data->update_lock); \ | ||
566 | return count; \ | ||
567 | } | ||
568 | store_temp1_reg(OVER, max); | ||
569 | store_temp1_reg(HYST, max_hyst); | ||
570 | |||
571 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL); | ||
572 | static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR, | ||
573 | show_temp1_max, store_temp1_max); | ||
574 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR, | ||
575 | show_temp1_max_hyst, store_temp1_max_hyst); | ||
576 | |||
577 | #define show_temp_reg(reg) \ | ||
578 | static ssize_t \ | ||
579 | show_##reg (struct device *dev, char *buf, int nr) \ | ||
580 | { \ | ||
581 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | ||
582 | return sprintf(buf, "%d\n", \ | ||
583 | LM75_TEMP_FROM_REG(data->reg[nr])); \ | ||
584 | } | ||
585 | show_temp_reg(temp); | ||
586 | show_temp_reg(temp_max); | ||
587 | show_temp_reg(temp_max_hyst); | ||
588 | |||
589 | #define store_temp_reg(REG, reg) \ | ||
590 | static ssize_t \ | ||
591 | store_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | ||
592 | { \ | ||
593 | struct i2c_client *client = to_i2c_client(dev); \ | ||
594 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | ||
595 | u32 val = simple_strtoul(buf, NULL, 10); \ | ||
596 | \ | ||
597 | down(&data->update_lock); \ | ||
598 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ | ||
599 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ | ||
600 | data->reg[nr]); \ | ||
601 | up(&data->update_lock); \ | ||
602 | return count; \ | ||
603 | } | ||
604 | store_temp_reg(OVER, temp_max); | ||
605 | store_temp_reg(HYST, temp_max_hyst); | ||
606 | |||
607 | #define sysfs_temp_offset(offset) \ | ||
608 | static ssize_t \ | ||
609 | show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \ | ||
610 | char *buf) \ | ||
611 | { \ | ||
612 | return show_temp(dev, buf, offset - 2); \ | ||
613 | } \ | ||
614 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | ||
615 | show_reg_temp##offset, NULL); | ||
616 | |||
617 | #define sysfs_temp_reg_offset(reg, offset) \ | ||
618 | static ssize_t \ | ||
619 | show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | ||
620 | char *buf) \ | ||
621 | { \ | ||
622 | return show_temp_##reg(dev, buf, offset - 2); \ | ||
623 | } \ | ||
624 | static ssize_t \ | ||
625 | store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | ||
626 | const char *buf, size_t count) \ | ||
627 | { \ | ||
628 | return store_temp_##reg(dev, buf, count, offset - 2); \ | ||
629 | } \ | ||
630 | static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \ | ||
631 | show_reg_temp##offset##_##reg, \ | ||
632 | store_reg_temp##offset##_##reg); | ||
633 | |||
634 | sysfs_temp_offset(2); | ||
635 | sysfs_temp_reg_offset(max, 2); | ||
636 | sysfs_temp_reg_offset(max_hyst, 2); | ||
637 | sysfs_temp_offset(3); | ||
638 | sysfs_temp_reg_offset(max, 3); | ||
639 | sysfs_temp_reg_offset(max_hyst, 3); | ||
640 | |||
641 | /* | ||
642 | * Driver and client management | ||
643 | */ | ||
644 | |||
645 | static struct i2c_driver w83627ehf_driver; | ||
646 | |||
647 | static void w83627ehf_init_client(struct i2c_client *client) | ||
648 | { | ||
649 | int i; | ||
650 | u8 tmp; | ||
651 | |||
652 | /* Start monitoring is needed */ | ||
653 | tmp = w83627ehf_read_value(client, W83627EHF_REG_CONFIG); | ||
654 | if (!(tmp & 0x01)) | ||
655 | w83627ehf_write_value(client, W83627EHF_REG_CONFIG, | ||
656 | tmp | 0x01); | ||
657 | |||
658 | /* Enable temp2 and temp3 if needed */ | ||
659 | for (i = 0; i < 2; i++) { | ||
660 | tmp = w83627ehf_read_value(client, | ||
661 | W83627EHF_REG_TEMP_CONFIG[i]); | ||
662 | if (tmp & 0x01) | ||
663 | w83627ehf_write_value(client, | ||
664 | W83627EHF_REG_TEMP_CONFIG[i], | ||
665 | tmp & 0xfe); | ||
666 | } | ||
667 | } | ||
668 | |||
669 | static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) | ||
670 | { | ||
671 | struct i2c_client *client; | ||
672 | struct w83627ehf_data *data; | ||
673 | int i, err = 0; | ||
674 | |||
675 | if (!i2c_is_isa_adapter(adapter)) | ||
676 | return 0; | ||
677 | |||
678 | if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { | ||
679 | err = -EBUSY; | ||
680 | goto exit; | ||
681 | } | ||
682 | |||
683 | if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { | ||
684 | err = -ENOMEM; | ||
685 | goto exit_release; | ||
686 | } | ||
687 | memset(data, 0, sizeof(struct w83627ehf_data)); | ||
688 | |||
689 | client = &data->client; | ||
690 | i2c_set_clientdata(client, data); | ||
691 | client->addr = address; | ||
692 | init_MUTEX(&data->lock); | ||
693 | client->adapter = adapter; | ||
694 | client->driver = &w83627ehf_driver; | ||
695 | client->flags = 0; | ||
696 | |||
697 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); | ||
698 | data->valid = 0; | ||
699 | init_MUTEX(&data->update_lock); | ||
700 | |||
701 | /* Tell the i2c layer a new client has arrived */ | ||
702 | if ((err = i2c_attach_client(client))) | ||
703 | goto exit_free; | ||
704 | |||
705 | /* Initialize the chip */ | ||
706 | w83627ehf_init_client(client); | ||
707 | |||
708 | /* A few vars need to be filled upon startup */ | ||
709 | for (i = 0; i < 5; i++) | ||
710 | data->fan_min[i] = w83627ehf_read_value(client, | ||
711 | W83627EHF_REG_FAN_MIN[i]); | ||
712 | |||
713 | /* It looks like fan4 and fan5 pins can be alternatively used | ||
714 | as fan on/off switches */ | ||
715 | data->has_fan = 0x07; /* fan1, fan2 and fan3 */ | ||
716 | i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1); | ||
717 | if (i & (1 << 2)) | ||
718 | data->has_fan |= (1 << 3); | ||
719 | if (i & (1 << 0)) | ||
720 | data->has_fan |= (1 << 4); | ||
721 | |||
722 | /* Register sysfs hooks */ | ||
723 | device_create_file(&client->dev, &dev_attr_fan1_input); | ||
724 | device_create_file(&client->dev, &dev_attr_fan1_min); | ||
725 | device_create_file(&client->dev, &dev_attr_fan1_div); | ||
726 | device_create_file(&client->dev, &dev_attr_fan2_input); | ||
727 | device_create_file(&client->dev, &dev_attr_fan2_min); | ||
728 | device_create_file(&client->dev, &dev_attr_fan2_div); | ||
729 | device_create_file(&client->dev, &dev_attr_fan3_input); | ||
730 | device_create_file(&client->dev, &dev_attr_fan3_min); | ||
731 | device_create_file(&client->dev, &dev_attr_fan3_div); | ||
732 | |||
733 | if (data->has_fan & (1 << 3)) { | ||
734 | device_create_file(&client->dev, &dev_attr_fan4_input); | ||
735 | device_create_file(&client->dev, &dev_attr_fan4_min); | ||
736 | device_create_file(&client->dev, &dev_attr_fan4_div); | ||
737 | } | ||
738 | if (data->has_fan & (1 << 4)) { | ||
739 | device_create_file(&client->dev, &dev_attr_fan5_input); | ||
740 | device_create_file(&client->dev, &dev_attr_fan5_min); | ||
741 | device_create_file(&client->dev, &dev_attr_fan5_div); | ||
742 | } | ||
743 | |||
744 | device_create_file(&client->dev, &dev_attr_temp1_input); | ||
745 | device_create_file(&client->dev, &dev_attr_temp1_max); | ||
746 | device_create_file(&client->dev, &dev_attr_temp1_max_hyst); | ||
747 | device_create_file(&client->dev, &dev_attr_temp2_input); | ||
748 | device_create_file(&client->dev, &dev_attr_temp2_max); | ||
749 | device_create_file(&client->dev, &dev_attr_temp2_max_hyst); | ||
750 | device_create_file(&client->dev, &dev_attr_temp3_input); | ||
751 | device_create_file(&client->dev, &dev_attr_temp3_max); | ||
752 | device_create_file(&client->dev, &dev_attr_temp3_max_hyst); | ||
753 | |||
754 | return 0; | ||
755 | |||
756 | exit_free: | ||
757 | kfree(data); | ||
758 | exit_release: | ||
759 | release_region(address, REGION_LENGTH); | ||
760 | exit: | ||
761 | return err; | ||
762 | } | ||
763 | |||
764 | static int w83627ehf_attach_adapter(struct i2c_adapter *adapter) | ||
765 | { | ||
766 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
767 | return 0; | ||
768 | return i2c_detect(adapter, &addr_data, w83627ehf_detect); | ||
769 | } | ||
770 | |||
771 | static int w83627ehf_detach_client(struct i2c_client *client) | ||
772 | { | ||
773 | int err; | ||
774 | |||
775 | if ((err = i2c_detach_client(client))) { | ||
776 | dev_err(&client->dev, "Client deregistration failed, " | ||
777 | "client not detached.\n"); | ||
778 | return err; | ||
779 | } | ||
780 | release_region(client->addr, REGION_LENGTH); | ||
781 | kfree(i2c_get_clientdata(client)); | ||
782 | |||
783 | return 0; | ||
784 | } | ||
785 | |||
786 | static struct i2c_driver w83627ehf_driver = { | ||
787 | .owner = THIS_MODULE, | ||
788 | .name = "w83627ehf", | ||
789 | .flags = I2C_DF_NOTIFY, | ||
790 | .attach_adapter = w83627ehf_attach_adapter, | ||
791 | .detach_client = w83627ehf_detach_client, | ||
792 | }; | ||
793 | |||
794 | static int __init w83627ehf_find(int sioaddr, int *address) | ||
795 | { | ||
796 | u16 val; | ||
797 | |||
798 | REG = sioaddr; | ||
799 | VAL = sioaddr + 1; | ||
800 | superio_enter(); | ||
801 | |||
802 | val = (superio_inb(SIO_REG_DEVID) << 8) | ||
803 | | superio_inb(SIO_REG_DEVID + 1); | ||
804 | if ((val & SIO_ID_MASK) != SIO_W83627EHF_ID) { | ||
805 | superio_exit(); | ||
806 | return -ENODEV; | ||
807 | } | ||
808 | |||
809 | superio_select(W83627EHF_LD_HWM); | ||
810 | val = (superio_inb(SIO_REG_ADDR) << 8) | ||
811 | | superio_inb(SIO_REG_ADDR + 1); | ||
812 | *address = val & ~(REGION_LENGTH - 1); | ||
813 | if (*address == 0) { | ||
814 | superio_exit(); | ||
815 | return -ENODEV; | ||
816 | } | ||
817 | |||
818 | /* Activate logical device if needed */ | ||
819 | val = superio_inb(SIO_REG_ENABLE); | ||
820 | if (!(val & 0x01)) | ||
821 | superio_outb(SIO_REG_ENABLE, val | 0x01); | ||
822 | |||
823 | superio_exit(); | ||
824 | return 0; | ||
825 | } | ||
826 | |||
827 | static int __init sensors_w83627ehf_init(void) | ||
828 | { | ||
829 | if (w83627ehf_find(0x2e, &normal_isa[0]) | ||
830 | && w83627ehf_find(0x4e, &normal_isa[0])) | ||
831 | return -ENODEV; | ||
832 | |||
833 | return i2c_add_driver(&w83627ehf_driver); | ||
834 | } | ||
835 | |||
836 | static void __exit sensors_w83627ehf_exit(void) | ||
837 | { | ||
838 | i2c_del_driver(&w83627ehf_driver); | ||
839 | } | ||
840 | |||
841 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); | ||
842 | MODULE_DESCRIPTION("W83627EHF driver"); | ||
843 | MODULE_LICENSE("GPL"); | ||
844 | |||
845 | module_init(sensors_w83627ehf_init); | ||
846 | module_exit(sensors_w83627ehf_exit); | ||
diff --git a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c index 4f1bff572c1c..bd87a42e068a 100644 --- a/drivers/i2c/chips/w83627hf.c +++ b/drivers/i2c/chips/w83627hf.c | |||
@@ -264,7 +264,7 @@ static inline u8 DIV_TO_REG(long val) | |||
264 | { | 264 | { |
265 | int i; | 265 | int i; |
266 | val = SENSORS_LIMIT(val, 1, 128) >> 1; | 266 | val = SENSORS_LIMIT(val, 1, 128) >> 1; |
267 | for (i = 0; i < 6; i++) { | 267 | for (i = 0; i < 7; i++) { |
268 | if (val == 0) | 268 | if (val == 0) |
269 | break; | 269 | break; |
270 | val >>= 1; | 270 | val >>= 1; |
diff --git a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c index c3926d2d8ac6..0bb131ce09eb 100644 --- a/drivers/i2c/chips/w83781d.c +++ b/drivers/i2c/chips/w83781d.c | |||
@@ -28,14 +28,11 @@ | |||
28 | as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no | 28 | as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no |
29 | w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes | 29 | w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes |
30 | w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC) | 30 | w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC) |
31 | w83627thf 9 3 2 3 0x90 0x5ca3 no yes(LPC) | ||
32 | w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes | 31 | w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes |
33 | w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no | 32 | w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no |
34 | w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) | ||
35 | 33 | ||
36 | */ | 34 | */ |
37 | 35 | ||
38 | #include <linux/config.h> | ||
39 | #include <linux/module.h> | 36 | #include <linux/module.h> |
40 | #include <linux/init.h> | 37 | #include <linux/init.h> |
41 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
@@ -53,7 +50,7 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, | |||
53 | static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; | 50 | static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; |
54 | 51 | ||
55 | /* Insmod parameters */ | 52 | /* Insmod parameters */ |
56 | SENSORS_INSMOD_6(w83781d, w83782d, w83783s, w83627hf, as99127f, w83697hf); | 53 | SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); |
57 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " | 54 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " |
58 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); | 55 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); |
59 | 56 | ||
@@ -173,7 +170,6 @@ FAN_TO_REG(long rpm, int div) | |||
173 | : (val)) / 1000, 0, 0xff)) | 170 | : (val)) / 1000, 0, 0xff)) |
174 | #define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000) | 171 | #define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000) |
175 | 172 | ||
176 | #define ALARMS_FROM_REG(val) (val) | ||
177 | #define PWM_FROM_REG(val) (val) | 173 | #define PWM_FROM_REG(val) (val) |
178 | #define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255)) | 174 | #define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255)) |
179 | #define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \ | 175 | #define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \ |
@@ -193,7 +189,7 @@ DIV_TO_REG(long val, enum chips type) | |||
193 | val = SENSORS_LIMIT(val, 1, | 189 | val = SENSORS_LIMIT(val, 1, |
194 | ((type == w83781d | 190 | ((type == w83781d |
195 | || type == as99127f) ? 8 : 128)) >> 1; | 191 | || type == as99127f) ? 8 : 128)) >> 1; |
196 | for (i = 0; i < 6; i++) { | 192 | for (i = 0; i < 7; i++) { |
197 | if (val == 0) | 193 | if (val == 0) |
198 | break; | 194 | break; |
199 | val >>= 1; | 195 | val >>= 1; |
@@ -524,7 +520,7 @@ static ssize_t | |||
524 | show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | 520 | show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) |
525 | { | 521 | { |
526 | struct w83781d_data *data = w83781d_update_device(dev); | 522 | struct w83781d_data *data = w83781d_update_device(dev); |
527 | return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); | 523 | return sprintf(buf, "%u\n", data->alarms); |
528 | } | 524 | } |
529 | 525 | ||
530 | static | 526 | static |
@@ -1000,13 +996,6 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1000 | err = -EINVAL; | 996 | err = -EINVAL; |
1001 | goto ERROR0; | 997 | goto ERROR0; |
1002 | } | 998 | } |
1003 | if (!is_isa && kind == w83697hf) { | ||
1004 | dev_err(&adapter->dev, | ||
1005 | "Cannot force ISA-only chip for I2C address 0x%02x.\n", | ||
1006 | address); | ||
1007 | err = -EINVAL; | ||
1008 | goto ERROR0; | ||
1009 | } | ||
1010 | 999 | ||
1011 | if (is_isa) | 1000 | if (is_isa) |
1012 | if (!request_region(address, W83781D_EXTENT, | 1001 | if (!request_region(address, W83781D_EXTENT, |
@@ -1139,12 +1128,10 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1139 | else if (val1 == 0x40 && vendid == winbond && !is_isa | 1128 | else if (val1 == 0x40 && vendid == winbond && !is_isa |
1140 | && address == 0x2d) | 1129 | && address == 0x2d) |
1141 | kind = w83783s; | 1130 | kind = w83783s; |
1142 | else if ((val1 == 0x21 || val1 == 0x90) && vendid == winbond) | 1131 | else if (val1 == 0x21 && vendid == winbond) |
1143 | kind = w83627hf; | 1132 | kind = w83627hf; |
1144 | else if (val1 == 0x31 && !is_isa && address >= 0x28) | 1133 | else if (val1 == 0x31 && !is_isa && address >= 0x28) |
1145 | kind = as99127f; | 1134 | kind = as99127f; |
1146 | else if (val1 == 0x60 && vendid == winbond && is_isa) | ||
1147 | kind = w83697hf; | ||
1148 | else { | 1135 | else { |
1149 | if (kind == 0) | 1136 | if (kind == 0) |
1150 | dev_warn(&new_client->dev, "Ignoring 'force' " | 1137 | dev_warn(&new_client->dev, "Ignoring 'force' " |
@@ -1163,14 +1150,9 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1163 | } else if (kind == w83783s) { | 1150 | } else if (kind == w83783s) { |
1164 | client_name = "w83783s"; | 1151 | client_name = "w83783s"; |
1165 | } else if (kind == w83627hf) { | 1152 | } else if (kind == w83627hf) { |
1166 | if (val1 == 0x90) | 1153 | client_name = "w83627hf"; |
1167 | client_name = "w83627thf"; | ||
1168 | else | ||
1169 | client_name = "w83627hf"; | ||
1170 | } else if (kind == as99127f) { | 1154 | } else if (kind == as99127f) { |
1171 | client_name = "as99127f"; | 1155 | client_name = "as99127f"; |
1172 | } else if (kind == w83697hf) { | ||
1173 | client_name = "w83697hf"; | ||
1174 | } | 1156 | } |
1175 | 1157 | ||
1176 | /* Fill in the remaining client fields and put into the global list */ | 1158 | /* Fill in the remaining client fields and put into the global list */ |
@@ -1208,7 +1190,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1208 | 1190 | ||
1209 | /* Register sysfs hooks */ | 1191 | /* Register sysfs hooks */ |
1210 | device_create_file_in(new_client, 0); | 1192 | device_create_file_in(new_client, 0); |
1211 | if (kind != w83783s && kind != w83697hf) | 1193 | if (kind != w83783s) |
1212 | device_create_file_in(new_client, 1); | 1194 | device_create_file_in(new_client, 1); |
1213 | device_create_file_in(new_client, 2); | 1195 | device_create_file_in(new_client, 2); |
1214 | device_create_file_in(new_client, 3); | 1196 | device_create_file_in(new_client, 3); |
@@ -1222,24 +1204,19 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1222 | 1204 | ||
1223 | device_create_file_fan(new_client, 1); | 1205 | device_create_file_fan(new_client, 1); |
1224 | device_create_file_fan(new_client, 2); | 1206 | device_create_file_fan(new_client, 2); |
1225 | if (kind != w83697hf) | 1207 | device_create_file_fan(new_client, 3); |
1226 | device_create_file_fan(new_client, 3); | ||
1227 | 1208 | ||
1228 | device_create_file_temp(new_client, 1); | 1209 | device_create_file_temp(new_client, 1); |
1229 | device_create_file_temp(new_client, 2); | 1210 | device_create_file_temp(new_client, 2); |
1230 | if (kind != w83783s && kind != w83697hf) | 1211 | if (kind != w83783s) |
1231 | device_create_file_temp(new_client, 3); | 1212 | device_create_file_temp(new_client, 3); |
1232 | 1213 | ||
1233 | if (kind != w83697hf) | 1214 | device_create_file_vid(new_client); |
1234 | device_create_file_vid(new_client); | 1215 | device_create_file_vrm(new_client); |
1235 | |||
1236 | if (kind != w83697hf) | ||
1237 | device_create_file_vrm(new_client); | ||
1238 | 1216 | ||
1239 | device_create_file_fan_div(new_client, 1); | 1217 | device_create_file_fan_div(new_client, 1); |
1240 | device_create_file_fan_div(new_client, 2); | 1218 | device_create_file_fan_div(new_client, 2); |
1241 | if (kind != w83697hf) | 1219 | device_create_file_fan_div(new_client, 3); |
1242 | device_create_file_fan_div(new_client, 3); | ||
1243 | 1220 | ||
1244 | device_create_file_alarms(new_client); | 1221 | device_create_file_alarms(new_client); |
1245 | 1222 | ||
@@ -1258,7 +1235,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1258 | if (kind != as99127f && kind != w83781d) { | 1235 | if (kind != as99127f && kind != w83781d) { |
1259 | device_create_file_sensor(new_client, 1); | 1236 | device_create_file_sensor(new_client, 1); |
1260 | device_create_file_sensor(new_client, 2); | 1237 | device_create_file_sensor(new_client, 2); |
1261 | if (kind != w83783s && kind != w83697hf) | 1238 | if (kind != w83783s) |
1262 | device_create_file_sensor(new_client, 3); | 1239 | device_create_file_sensor(new_client, 3); |
1263 | } | 1240 | } |
1264 | 1241 | ||
@@ -1481,7 +1458,7 @@ w83781d_init_client(struct i2c_client *client) | |||
1481 | else | 1458 | else |
1482 | data->sens[i - 1] = 2; | 1459 | data->sens[i - 1] = 2; |
1483 | } | 1460 | } |
1484 | if ((type == w83783s || type == w83697hf) && (i == 2)) | 1461 | if (type == w83783s && i == 2) |
1485 | break; | 1462 | break; |
1486 | } | 1463 | } |
1487 | } | 1464 | } |
@@ -1497,7 +1474,7 @@ w83781d_init_client(struct i2c_client *client) | |||
1497 | } | 1474 | } |
1498 | 1475 | ||
1499 | /* Enable temp3 */ | 1476 | /* Enable temp3 */ |
1500 | if (type != w83783s && type != w83697hf) { | 1477 | if (type != w83783s) { |
1501 | tmp = w83781d_read_value(client, | 1478 | tmp = w83781d_read_value(client, |
1502 | W83781D_REG_TEMP3_CONFIG); | 1479 | W83781D_REG_TEMP3_CONFIG); |
1503 | if (tmp & 0x01) { | 1480 | if (tmp & 0x01) { |
@@ -1538,8 +1515,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1538 | dev_dbg(dev, "Starting device update\n"); | 1515 | dev_dbg(dev, "Starting device update\n"); |
1539 | 1516 | ||
1540 | for (i = 0; i <= 8; i++) { | 1517 | for (i = 0; i <= 8; i++) { |
1541 | if ((data->type == w83783s || data->type == w83697hf) | 1518 | if (data->type == w83783s && i == 1) |
1542 | && (i == 1)) | ||
1543 | continue; /* 783S has no in1 */ | 1519 | continue; /* 783S has no in1 */ |
1544 | data->in[i] = | 1520 | data->in[i] = |
1545 | w83781d_read_value(client, W83781D_REG_IN(i)); | 1521 | w83781d_read_value(client, W83781D_REG_IN(i)); |
@@ -1547,7 +1523,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1547 | w83781d_read_value(client, W83781D_REG_IN_MIN(i)); | 1523 | w83781d_read_value(client, W83781D_REG_IN_MIN(i)); |
1548 | data->in_max[i] = | 1524 | data->in_max[i] = |
1549 | w83781d_read_value(client, W83781D_REG_IN_MAX(i)); | 1525 | w83781d_read_value(client, W83781D_REG_IN_MAX(i)); |
1550 | if ((data->type != w83782d) && (data->type != w83697hf) | 1526 | if ((data->type != w83782d) |
1551 | && (data->type != w83627hf) && (i == 6)) | 1527 | && (data->type != w83627hf) && (i == 6)) |
1552 | break; | 1528 | break; |
1553 | } | 1529 | } |
@@ -1583,7 +1559,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1583 | w83781d_read_value(client, W83781D_REG_TEMP_OVER(2)); | 1559 | w83781d_read_value(client, W83781D_REG_TEMP_OVER(2)); |
1584 | data->temp_max_hyst_add[0] = | 1560 | data->temp_max_hyst_add[0] = |
1585 | w83781d_read_value(client, W83781D_REG_TEMP_HYST(2)); | 1561 | w83781d_read_value(client, W83781D_REG_TEMP_HYST(2)); |
1586 | if (data->type != w83783s && data->type != w83697hf) { | 1562 | if (data->type != w83783s) { |
1587 | data->temp_add[1] = | 1563 | data->temp_add[1] = |
1588 | w83781d_read_value(client, W83781D_REG_TEMP(3)); | 1564 | w83781d_read_value(client, W83781D_REG_TEMP(3)); |
1589 | data->temp_max_add[1] = | 1565 | data->temp_max_add[1] = |
@@ -1594,26 +1570,18 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1594 | W83781D_REG_TEMP_HYST(3)); | 1570 | W83781D_REG_TEMP_HYST(3)); |
1595 | } | 1571 | } |
1596 | i = w83781d_read_value(client, W83781D_REG_VID_FANDIV); | 1572 | i = w83781d_read_value(client, W83781D_REG_VID_FANDIV); |
1597 | if (data->type != w83697hf) { | 1573 | data->vid = i & 0x0f; |
1598 | data->vid = i & 0x0f; | 1574 | data->vid |= (w83781d_read_value(client, |
1599 | data->vid |= | 1575 | W83781D_REG_CHIPID) & 0x01) << 4; |
1600 | (w83781d_read_value(client, W83781D_REG_CHIPID) & | ||
1601 | 0x01) | ||
1602 | << 4; | ||
1603 | } | ||
1604 | data->fan_div[0] = (i >> 4) & 0x03; | 1576 | data->fan_div[0] = (i >> 4) & 0x03; |
1605 | data->fan_div[1] = (i >> 6) & 0x03; | 1577 | data->fan_div[1] = (i >> 6) & 0x03; |
1606 | if (data->type != w83697hf) { | 1578 | data->fan_div[2] = (w83781d_read_value(client, |
1607 | data->fan_div[2] = (w83781d_read_value(client, | 1579 | W83781D_REG_PIN) >> 6) & 0x03; |
1608 | W83781D_REG_PIN) | ||
1609 | >> 6) & 0x03; | ||
1610 | } | ||
1611 | if ((data->type != w83781d) && (data->type != as99127f)) { | 1580 | if ((data->type != w83781d) && (data->type != as99127f)) { |
1612 | i = w83781d_read_value(client, W83781D_REG_VBAT); | 1581 | i = w83781d_read_value(client, W83781D_REG_VBAT); |
1613 | data->fan_div[0] |= (i >> 3) & 0x04; | 1582 | data->fan_div[0] |= (i >> 3) & 0x04; |
1614 | data->fan_div[1] |= (i >> 4) & 0x04; | 1583 | data->fan_div[1] |= (i >> 4) & 0x04; |
1615 | if (data->type != w83697hf) | 1584 | data->fan_div[2] |= (i >> 5) & 0x04; |
1616 | data->fan_div[2] |= (i >> 5) & 0x04; | ||
1617 | } | 1585 | } |
1618 | data->alarms = | 1586 | data->alarms = |
1619 | w83781d_read_value(client, | 1587 | w83781d_read_value(client, |
diff --git a/drivers/i2c/chips/w83l785ts.c b/drivers/i2c/chips/w83l785ts.c index 74d4b58e4237..4469d52aba4c 100644 --- a/drivers/i2c/chips/w83l785ts.c +++ b/drivers/i2c/chips/w83l785ts.c | |||
@@ -30,7 +30,6 @@ | |||
30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/config.h> | ||
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index a22e53badacb..51ce268998cd 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -21,7 +21,6 @@ | |||
21 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> | 21 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> |
22 | SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ | 22 | SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
27 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
@@ -239,7 +238,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
239 | } | 238 | } |
240 | 239 | ||
241 | /* detach any active clients. This must be done first, because | 240 | /* detach any active clients. This must be done first, because |
242 | * it can fail; in which case we give upp. */ | 241 | * it can fail; in which case we give up. */ |
243 | list_for_each_safe(item, _n, &adap->clients) { | 242 | list_for_each_safe(item, _n, &adap->clients) { |
244 | client = list_entry(item, struct i2c_client, list); | 243 | client = list_entry(item, struct i2c_client, list); |
245 | 244 | ||
@@ -612,27 +611,16 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count) | |||
612 | struct i2c_adapter *adap=client->adapter; | 611 | struct i2c_adapter *adap=client->adapter; |
613 | struct i2c_msg msg; | 612 | struct i2c_msg msg; |
614 | 613 | ||
615 | if (client->adapter->algo->master_xfer) { | 614 | msg.addr = client->addr; |
616 | msg.addr = client->addr; | 615 | msg.flags = client->flags & I2C_M_TEN; |
617 | msg.flags = client->flags & I2C_M_TEN; | 616 | msg.len = count; |
618 | msg.len = count; | 617 | msg.buf = (char *)buf; |
619 | msg.buf = (char *)buf; | ||
620 | 618 | ||
621 | dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n", | 619 | ret = i2c_transfer(adap, &msg, 1); |
622 | count); | ||
623 | |||
624 | down(&adap->bus_lock); | ||
625 | ret = adap->algo->master_xfer(adap,&msg,1); | ||
626 | up(&adap->bus_lock); | ||
627 | 620 | ||
628 | /* if everything went ok (i.e. 1 msg transmitted), return #bytes | 621 | /* If everything went ok (i.e. 1 msg transmitted), return #bytes |
629 | * transmitted, else error code. | 622 | transmitted, else error code. */ |
630 | */ | 623 | return (ret == 1) ? count : ret; |
631 | return (ret == 1 )? count : ret; | ||
632 | } else { | ||
633 | dev_err(&client->adapter->dev, "I2C level transfers not supported\n"); | ||
634 | return -ENOSYS; | ||
635 | } | ||
636 | } | 624 | } |
637 | 625 | ||
638 | int i2c_master_recv(struct i2c_client *client, char *buf ,int count) | 626 | int i2c_master_recv(struct i2c_client *client, char *buf ,int count) |
@@ -640,31 +628,18 @@ int i2c_master_recv(struct i2c_client *client, char *buf ,int count) | |||
640 | struct i2c_adapter *adap=client->adapter; | 628 | struct i2c_adapter *adap=client->adapter; |
641 | struct i2c_msg msg; | 629 | struct i2c_msg msg; |
642 | int ret; | 630 | int ret; |
643 | if (client->adapter->algo->master_xfer) { | 631 | |
644 | msg.addr = client->addr; | 632 | msg.addr = client->addr; |
645 | msg.flags = client->flags & I2C_M_TEN; | 633 | msg.flags = client->flags & I2C_M_TEN; |
646 | msg.flags |= I2C_M_RD; | 634 | msg.flags |= I2C_M_RD; |
647 | msg.len = count; | 635 | msg.len = count; |
648 | msg.buf = buf; | 636 | msg.buf = buf; |
649 | 637 | ||
650 | dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n", | 638 | ret = i2c_transfer(adap, &msg, 1); |
651 | count); | 639 | |
652 | 640 | /* If everything went ok (i.e. 1 msg transmitted), return #bytes | |
653 | down(&adap->bus_lock); | 641 | transmitted, else error code. */ |
654 | ret = adap->algo->master_xfer(adap,&msg,1); | 642 | return (ret == 1) ? count : ret; |
655 | up(&adap->bus_lock); | ||
656 | |||
657 | dev_dbg(&client->adapter->dev, "master_recv: return:%d (count:%d, addr:0x%02x)\n", | ||
658 | ret, count, client->addr); | ||
659 | |||
660 | /* if everything went ok (i.e. 1 msg transmitted), return #bytes | ||
661 | * transmitted, else error code. | ||
662 | */ | ||
663 | return (ret == 1 )? count : ret; | ||
664 | } else { | ||
665 | dev_err(&client->adapter->dev, "I2C level transfers not supported\n"); | ||
666 | return -ENOSYS; | ||
667 | } | ||
668 | } | 643 | } |
669 | 644 | ||
670 | 645 | ||
@@ -742,18 +717,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
742 | found = 1; | 717 | found = 1; |
743 | } | 718 | } |
744 | } | 719 | } |
745 | for (i = 0; | ||
746 | !found && (address_data->ignore_range[i] != I2C_CLIENT_END); | ||
747 | i += 3) { | ||
748 | if (((adap_id == address_data->ignore_range[i]) || | ||
749 | ((address_data->ignore_range[i]==ANY_I2C_BUS))) && | ||
750 | (addr >= address_data->ignore_range[i+1]) && | ||
751 | (addr <= address_data->ignore_range[i+2])) { | ||
752 | dev_dbg(&adapter->dev, "found ignore_range parameter for adapter %d, " | ||
753 | "addr %04x\n", adap_id,addr); | ||
754 | found = 1; | ||
755 | } | ||
756 | } | ||
757 | if (found) | 720 | if (found) |
758 | continue; | 721 | continue; |
759 | 722 | ||
@@ -770,17 +733,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
770 | } | 733 | } |
771 | 734 | ||
772 | for (i = 0; | 735 | for (i = 0; |
773 | !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END); | ||
774 | i += 2) { | ||
775 | if ((addr >= address_data->normal_i2c_range[i]) && | ||
776 | (addr <= address_data->normal_i2c_range[i+1])) { | ||
777 | found = 1; | ||
778 | dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, " | ||
779 | "addr %04x\n", adap_id,addr); | ||
780 | } | ||
781 | } | ||
782 | |||
783 | for (i = 0; | ||
784 | !found && (address_data->probe[i] != I2C_CLIENT_END); | 736 | !found && (address_data->probe[i] != I2C_CLIENT_END); |
785 | i += 2) { | 737 | i += 2) { |
786 | if (((adap_id == address_data->probe[i]) || | 738 | if (((adap_id == address_data->probe[i]) || |
@@ -791,18 +743,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
791 | "addr %04x\n", adap_id,addr); | 743 | "addr %04x\n", adap_id,addr); |
792 | } | 744 | } |
793 | } | 745 | } |
794 | for (i = 0; | ||
795 | !found && (address_data->probe_range[i] != I2C_CLIENT_END); | ||
796 | i += 3) { | ||
797 | if (((adap_id == address_data->probe_range[i]) || | ||
798 | (address_data->probe_range[i] == ANY_I2C_BUS)) && | ||
799 | (addr >= address_data->probe_range[i+1]) && | ||
800 | (addr <= address_data->probe_range[i+2])) { | ||
801 | found = 1; | ||
802 | dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, " | ||
803 | "addr %04x\n", adap_id,addr); | ||
804 | } | ||
805 | } | ||
806 | if (!found) | 746 | if (!found) |
807 | continue; | 747 | continue; |
808 | 748 | ||
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 86c4d0149e82..bc5d557e5dd9 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -29,7 +29,6 @@ | |||
29 | /* The devfs code is contributed by Philipp Matthias Hahn | 29 | /* The devfs code is contributed by Philipp Matthias Hahn |
30 | <pmhahn@titan.lahn.de> */ | 30 | <pmhahn@titan.lahn.de> */ |
31 | 31 | ||
32 | #include <linux/config.h> | ||
33 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/fs.h> | 34 | #include <linux/fs.h> |
@@ -214,7 +213,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
214 | sizeof(rdwr_arg))) | 213 | sizeof(rdwr_arg))) |
215 | return -EFAULT; | 214 | return -EFAULT; |
216 | 215 | ||
217 | /* Put an arbritrary limit on the number of messages that can | 216 | /* Put an arbitrary limit on the number of messages that can |
218 | * be sent at once */ | 217 | * be sent at once */ |
219 | if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) | 218 | if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) |
220 | return -EINVAL; | 219 | return -EINVAL; |
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index 0bdb47f08c2a..61400f04015e 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c | |||
@@ -51,8 +51,10 @@ | |||
51 | static int do_probe( struct i2c_adapter *adapter, int addr, int kind); | 51 | static int do_probe( struct i2c_adapter *adapter, int addr, int kind); |
52 | 52 | ||
53 | /* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */ | 53 | /* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */ |
54 | static unsigned short normal_i2c[] = { 0x49, 0x2c, I2C_CLIENT_END }; | 54 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, |
55 | static unsigned short normal_i2c_range[] = { 0x48, 0x4f, 0x2c, 0x2f, I2C_CLIENT_END }; | 55 | 0x4c, 0x4d, 0x4e, 0x4f, |
56 | 0x2c, 0x2d, 0x2e, 0x2f, | ||
57 | I2C_CLIENT_END }; | ||
56 | 58 | ||
57 | I2C_CLIENT_INSMOD; | 59 | I2C_CLIENT_INSMOD; |
58 | 60 | ||
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 80254caa444c..48989eda2400 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
@@ -384,22 +384,14 @@ static unsigned short normal_i2c[] = | |||
384 | I2C_ADV7171 >> 1, (I2C_ADV7171 >> 1) + 1, | 384 | I2C_ADV7171 >> 1, (I2C_ADV7171 >> 1) + 1, |
385 | I2C_CLIENT_END | 385 | I2C_CLIENT_END |
386 | }; | 386 | }; |
387 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
388 | 387 | ||
389 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 388 | static unsigned short ignore = I2C_CLIENT_END; |
390 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
391 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
392 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
393 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
394 | 389 | ||
395 | static struct i2c_client_address_data addr_data = { | 390 | static struct i2c_client_address_data addr_data = { |
396 | .normal_i2c = normal_i2c, | 391 | .normal_i2c = normal_i2c, |
397 | .normal_i2c_range = normal_i2c_range, | 392 | .probe = &ignore, |
398 | .probe = probe, | 393 | .ignore = &ignore, |
399 | .probe_range = probe_range, | 394 | .force = &ignore, |
400 | .ignore = ignore, | ||
401 | .ignore_range = ignore_range, | ||
402 | .force = force | ||
403 | }; | 395 | }; |
404 | 396 | ||
405 | static struct i2c_driver i2c_driver_adv7170; | 397 | static struct i2c_driver i2c_driver_adv7170; |
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 95d0974b0ab5..f898b6586374 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c | |||
@@ -434,22 +434,14 @@ static unsigned short normal_i2c[] = | |||
434 | I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, | 434 | I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, |
435 | I2C_CLIENT_END | 435 | I2C_CLIENT_END |
436 | }; | 436 | }; |
437 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
438 | 437 | ||
439 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 438 | static unsigned short ignore = I2C_CLIENT_END; |
440 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
441 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
442 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
443 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
444 | 439 | ||
445 | static struct i2c_client_address_data addr_data = { | 440 | static struct i2c_client_address_data addr_data = { |
446 | .normal_i2c = normal_i2c, | 441 | .normal_i2c = normal_i2c, |
447 | .normal_i2c_range = normal_i2c_range, | 442 | .probe = &ignore, |
448 | .probe = probe, | 443 | .ignore = &ignore, |
449 | .probe_range = probe_range, | 444 | .force = &ignore, |
450 | .ignore = ignore, | ||
451 | .ignore_range = ignore_range, | ||
452 | .force = force | ||
453 | }; | 445 | }; |
454 | 446 | ||
455 | static struct i2c_driver i2c_driver_adv7175; | 447 | static struct i2c_driver i2c_driver_adv7175; |
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index cf0db2554a80..8733588f6db3 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c | |||
@@ -500,22 +500,14 @@ static unsigned short normal_i2c[] = { | |||
500 | I2C_BT819 >> 1, | 500 | I2C_BT819 >> 1, |
501 | I2C_CLIENT_END, | 501 | I2C_CLIENT_END, |
502 | }; | 502 | }; |
503 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
504 | 503 | ||
505 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 504 | static unsigned short ignore = I2C_CLIENT_END; |
506 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
507 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
508 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
509 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
510 | 505 | ||
511 | static struct i2c_client_address_data addr_data = { | 506 | static struct i2c_client_address_data addr_data = { |
512 | .normal_i2c = normal_i2c, | 507 | .normal_i2c = normal_i2c, |
513 | .normal_i2c_range = normal_i2c_range, | 508 | .probe = &ignore, |
514 | .probe = probe, | 509 | .ignore = &ignore, |
515 | .probe_range = probe_range, | 510 | .force = &ignore, |
516 | .ignore = ignore, | ||
517 | .ignore_range = ignore_range, | ||
518 | .force = force | ||
519 | }; | 511 | }; |
520 | 512 | ||
521 | static struct i2c_driver i2c_driver_bt819; | 513 | static struct i2c_driver i2c_driver_bt819; |
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c index efe605a113a1..07f72f64c5f7 100644 --- a/drivers/media/video/bt832.c +++ b/drivers/media/video/bt832.c | |||
@@ -39,8 +39,8 @@ | |||
39 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
40 | 40 | ||
41 | /* Addresses to scan */ | 41 | /* Addresses to scan */ |
42 | static unsigned short normal_i2c[] = {I2C_CLIENT_END}; | 42 | static unsigned short normal_i2c[] = { I2C_BT832_ALT1>>1, I2C_BT832_ALT2>>1, |
43 | static unsigned short normal_i2c_range[] = {I2C_BT832_ALT1>>1,I2C_BT832_ALT2>>1,I2C_CLIENT_END}; | 43 | I2C_CLIENT_END }; |
44 | I2C_CLIENT_INSMOD; | 44 | I2C_CLIENT_INSMOD; |
45 | 45 | ||
46 | /* ---------------------------------------------------------------------- */ | 46 | /* ---------------------------------------------------------------------- */ |
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 72c7eb0f8c24..a5d529ccf3ad 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c | |||
@@ -288,22 +288,14 @@ bt856_command (struct i2c_client *client, | |||
288 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | 288 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' |
289 | */ | 289 | */ |
290 | static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; | 290 | static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; |
291 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
292 | 291 | ||
293 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 292 | static unsigned short ignore = I2C_CLIENT_END; |
294 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
295 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
296 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
297 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
298 | 293 | ||
299 | static struct i2c_client_address_data addr_data = { | 294 | static struct i2c_client_address_data addr_data = { |
300 | .normal_i2c = normal_i2c, | 295 | .normal_i2c = normal_i2c, |
301 | .normal_i2c_range = normal_i2c_range, | 296 | .probe = &ignore, |
302 | .probe = probe, | 297 | .ignore = &ignore, |
303 | .probe_range = probe_range, | 298 | .force = &ignore, |
304 | .ignore = ignore, | ||
305 | .ignore_range = ignore_range, | ||
306 | .force = force | ||
307 | }; | 299 | }; |
308 | 300 | ||
309 | static struct i2c_driver i2c_driver_bt856; | 301 | static struct i2c_driver i2c_driver_bt856; |
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index 7fbb8581a87d..09464d624a6b 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c | |||
@@ -147,7 +147,6 @@ static unsigned short normal_i2c[] = { | |||
147 | I2C_MSP3400C_ALT >> 1, | 147 | I2C_MSP3400C_ALT >> 1, |
148 | I2C_CLIENT_END | 148 | I2C_CLIENT_END |
149 | }; | 149 | }; |
150 | static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END}; | ||
151 | I2C_CLIENT_INSMOD; | 150 | I2C_CLIENT_INSMOD; |
152 | 151 | ||
153 | /* ----------------------------------------------------------------------- */ | 152 | /* ----------------------------------------------------------------------- */ |
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c index ba69f09cbdd1..b8054da31ffd 100644 --- a/drivers/media/video/saa5246a.c +++ b/drivers/media/video/saa5246a.c | |||
@@ -64,7 +64,6 @@ static struct video_device saa_template; /* Declared near bottom */ | |||
64 | 64 | ||
65 | /* Addresses to scan */ | 65 | /* Addresses to scan */ |
66 | static unsigned short normal_i2c[] = { I2C_ADDRESS, I2C_CLIENT_END }; | 66 | static unsigned short normal_i2c[] = { I2C_ADDRESS, I2C_CLIENT_END }; |
67 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
68 | I2C_CLIENT_INSMOD; | 67 | I2C_CLIENT_INSMOD; |
69 | 68 | ||
70 | static struct i2c_client client_template; | 69 | static struct i2c_client client_template; |
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index d74caa139f0a..7ffa2e9a9bf3 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c | |||
@@ -132,7 +132,6 @@ static struct video_device saa_template; /* Declared near bottom */ | |||
132 | 132 | ||
133 | /* Addresses to scan */ | 133 | /* Addresses to scan */ |
134 | static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END}; | 134 | static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END}; |
135 | static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; | ||
136 | I2C_CLIENT_INSMOD; | 135 | I2C_CLIENT_INSMOD; |
137 | 136 | ||
138 | static struct i2c_client client_template; | 137 | static struct i2c_client client_template; |
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 64273b438530..22d055d8a695 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c | |||
@@ -463,22 +463,14 @@ static unsigned short normal_i2c[] = { | |||
463 | (I2C_SAA7110 >> 1) + 1, | 463 | (I2C_SAA7110 >> 1) + 1, |
464 | I2C_CLIENT_END | 464 | I2C_CLIENT_END |
465 | }; | 465 | }; |
466 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
467 | 466 | ||
468 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 467 | static unsigned short ignore = I2C_CLIENT_END; |
469 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
470 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
471 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
472 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
473 | 468 | ||
474 | static struct i2c_client_address_data addr_data = { | 469 | static struct i2c_client_address_data addr_data = { |
475 | .normal_i2c = normal_i2c, | 470 | .normal_i2c = normal_i2c, |
476 | .normal_i2c_range = normal_i2c_range, | 471 | .probe = &ignore, |
477 | .probe = probe, | 472 | .ignore = &ignore, |
478 | .probe_range = probe_range, | 473 | .force = &ignore, |
479 | .ignore = ignore, | ||
480 | .ignore_range = ignore_range, | ||
481 | .force = force | ||
482 | }; | 474 | }; |
483 | 475 | ||
484 | static struct i2c_driver i2c_driver_saa7110; | 476 | static struct i2c_driver i2c_driver_saa7110; |
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 0a873112ae23..fcd897382fcf 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c | |||
@@ -482,22 +482,14 @@ saa7111_command (struct i2c_client *client, | |||
482 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | 482 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' |
483 | */ | 483 | */ |
484 | static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; | 484 | static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; |
485 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
486 | 485 | ||
487 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 486 | static unsigned short ignore = I2C_CLIENT_END; |
488 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
489 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
490 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
491 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
492 | 487 | ||
493 | static struct i2c_client_address_data addr_data = { | 488 | static struct i2c_client_address_data addr_data = { |
494 | .normal_i2c = normal_i2c, | 489 | .normal_i2c = normal_i2c, |
495 | .normal_i2c_range = normal_i2c_range, | 490 | .probe = &ignore, |
496 | .probe = probe, | 491 | .ignore = &ignore, |
497 | .probe_range = probe_range, | 492 | .force = &ignore, |
498 | .ignore = ignore, | ||
499 | .ignore_range = ignore_range, | ||
500 | .force = force | ||
501 | }; | 493 | }; |
502 | 494 | ||
503 | static struct i2c_driver i2c_driver_saa7111; | 495 | static struct i2c_driver i2c_driver_saa7111; |
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index e73023695e58..2ba997f5ef1d 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c | |||
@@ -820,22 +820,14 @@ saa7114_command (struct i2c_client *client, | |||
820 | */ | 820 | */ |
821 | static unsigned short normal_i2c[] = | 821 | static unsigned short normal_i2c[] = |
822 | { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; | 822 | { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; |
823 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
824 | 823 | ||
825 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 824 | static unsigned short ignore = I2C_CLIENT_END; |
826 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
827 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
828 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
829 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
830 | 825 | ||
831 | static struct i2c_client_address_data addr_data = { | 826 | static struct i2c_client_address_data addr_data = { |
832 | .normal_i2c = normal_i2c, | 827 | .normal_i2c = normal_i2c, |
833 | .normal_i2c_range = normal_i2c_range, | 828 | .probe = &ignore, |
834 | .probe = probe, | 829 | .ignore = &ignore, |
835 | .probe_range = probe_range, | 830 | .force = &ignore, |
836 | .ignore = ignore, | ||
837 | .ignore_range = ignore_range, | ||
838 | .force = force | ||
839 | }; | 831 | }; |
840 | 832 | ||
841 | static struct i2c_driver i2c_driver_saa7114; | 833 | static struct i2c_driver i2c_driver_saa7114; |
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 1db022682980..42c2b565c9fe 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c | |||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | /* Addresses to scan */ | 23 | /* Addresses to scan */ |
24 | static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END}; | 24 | static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END}; |
25 | static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; | ||
26 | I2C_CLIENT_INSMOD; | 25 | I2C_CLIENT_INSMOD; |
27 | 26 | ||
28 | MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); | 27 | MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); |
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 5f0b224c3cb6..108e7a4a0273 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c | |||
@@ -380,22 +380,14 @@ saa7185_command (struct i2c_client *client, | |||
380 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | 380 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' |
381 | */ | 381 | */ |
382 | static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; | 382 | static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; |
383 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
384 | 383 | ||
385 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 384 | static unsigned short ignore = I2C_CLIENT_END; |
386 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
387 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
388 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
389 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
390 | 385 | ||
391 | static struct i2c_client_address_data addr_data = { | 386 | static struct i2c_client_address_data addr_data = { |
392 | .normal_i2c = normal_i2c, | 387 | .normal_i2c = normal_i2c, |
393 | .normal_i2c_range = normal_i2c_range, | 388 | .probe = &ignore, |
394 | .probe = probe, | 389 | .ignore = &ignore, |
395 | .probe_range = probe_range, | 390 | .force = &ignore, |
396 | .ignore = ignore, | ||
397 | .ignore_range = ignore_range, | ||
398 | .force = force | ||
399 | }; | 391 | }; |
400 | 392 | ||
401 | static struct i2c_driver i2c_driver_saa7185; | 393 | static struct i2c_driver i2c_driver_saa7185; |
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c index 376a4a439e9b..07ba6d3ed08c 100644 --- a/drivers/media/video/tda7432.c +++ b/drivers/media/video/tda7432.c | |||
@@ -74,7 +74,6 @@ static unsigned short normal_i2c[] = { | |||
74 | I2C_TDA7432 >> 1, | 74 | I2C_TDA7432 >> 1, |
75 | I2C_CLIENT_END, | 75 | I2C_CLIENT_END, |
76 | }; | 76 | }; |
77 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
78 | I2C_CLIENT_INSMOD; | 77 | I2C_CLIENT_INSMOD; |
79 | 78 | ||
80 | /* Structure of address and subaddresses for the tda7432 */ | 79 | /* Structure of address and subaddresses for the tda7432 */ |
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index b5177c6f54f6..c29bdfc3244e 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c | |||
@@ -43,7 +43,6 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); | |||
43 | 43 | ||
44 | /* addresses to scan, found only at 0x42 (7-Bit) */ | 44 | /* addresses to scan, found only at 0x42 (7-Bit) */ |
45 | static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END }; | 45 | static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END }; |
46 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
47 | 46 | ||
48 | /* magic definition of all other variables and things */ | 47 | /* magic definition of all other variables and things */ |
49 | I2C_CLIENT_INSMOD; | 48 | I2C_CLIENT_INSMOD; |
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index 4f1114c033a1..97b113e070f3 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c | |||
@@ -44,7 +44,6 @@ static unsigned short normal_i2c[] = { | |||
44 | I2C_TDA9875 >> 1, | 44 | I2C_TDA9875 >> 1, |
45 | I2C_CLIENT_END | 45 | I2C_CLIENT_END |
46 | }; | 46 | }; |
47 | static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; | ||
48 | I2C_CLIENT_INSMOD; | 47 | I2C_CLIENT_INSMOD; |
49 | 48 | ||
50 | /* This is a superset of the TDA9875 */ | 49 | /* This is a superset of the TDA9875 */ |
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index debef1910c37..7e6e6dd966a2 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c | |||
@@ -33,7 +33,6 @@ static unsigned short normal_i2c[] = { | |||
33 | 0x96 >>1, | 33 | 0x96 >>1, |
34 | I2C_CLIENT_END, | 34 | I2C_CLIENT_END, |
35 | }; | 35 | }; |
36 | static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END}; | ||
37 | I2C_CLIENT_INSMOD; | 36 | I2C_CLIENT_INSMOD; |
38 | 37 | ||
39 | /* insmod options */ | 38 | /* insmod options */ |
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index 3ec39550bf46..b44db8a7b94d 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c | |||
@@ -43,7 +43,6 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); | |||
43 | 43 | ||
44 | /* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */ | 44 | /* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */ |
45 | static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END }; | 45 | static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END }; |
46 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
47 | 46 | ||
48 | /* magic definition of all other variables and things */ | 47 | /* magic definition of all other variables and things */ |
49 | I2C_CLIENT_INSMOD; | 48 | I2C_CLIENT_INSMOD; |
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index bd10710fd909..48d4db7d507b 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c | |||
@@ -40,7 +40,6 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); | |||
40 | 40 | ||
41 | /* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ | 41 | /* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ |
42 | static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END }; | 42 | static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END }; |
43 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
44 | 43 | ||
45 | /* magic definition of all other variables and things */ | 44 | /* magic definition of all other variables and things */ |
46 | I2C_CLIENT_INSMOD; | 45 | I2C_CLIENT_INSMOD; |
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c index 6b20aa902a8f..51748c6578d1 100644 --- a/drivers/media/video/tuner-3036.c +++ b/drivers/media/video/tuner-3036.c | |||
@@ -34,19 +34,14 @@ static int this_adap; | |||
34 | static struct i2c_client client_template; | 34 | static struct i2c_client client_template; |
35 | 35 | ||
36 | /* Addresses to scan */ | 36 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = {I2C_CLIENT_END}; | 37 | static unsigned short normal_i2c[] = { 0x60, 0x61, I2C_CLIENT_END }; |
38 | static unsigned short normal_i2c_range[] = {0x60, 0x61, I2C_CLIENT_END}; | 38 | static unsigned short ignore = I2C_CLIENT_END; |
39 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
40 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
41 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
42 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
43 | static unsigned short force[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
44 | 39 | ||
45 | static struct i2c_client_address_data addr_data = { | 40 | static struct i2c_client_address_data addr_data = { |
46 | normal_i2c, normal_i2c_range, | 41 | .normal_i2c = normal_i2c, |
47 | probe, probe_range, | 42 | .probe = &ignore, |
48 | ignore, ignore_range, | 43 | .ignore = &ignore, |
49 | force | 44 | .force = &ignore, |
50 | }; | 45 | }; |
51 | 46 | ||
52 | /* ---------------------------------------------------------------------- */ | 47 | /* ---------------------------------------------------------------------- */ |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 6212388edb75..81882ddab859 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -28,10 +28,8 @@ | |||
28 | /* standard i2c insmod options */ | 28 | /* standard i2c insmod options */ |
29 | static unsigned short normal_i2c[] = { | 29 | static unsigned short normal_i2c[] = { |
30 | 0x4b, /* tda8290 */ | 30 | 0x4b, /* tda8290 */ |
31 | I2C_CLIENT_END | 31 | 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, |
32 | }; | 32 | 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, |
33 | static unsigned short normal_i2c_range[] = { | ||
34 | 0x60, 0x6f, | ||
35 | I2C_CLIENT_END | 33 | I2C_CLIENT_END |
36 | }; | 34 | }; |
37 | I2C_CLIENT_INSMOD; | 35 | I2C_CLIENT_INSMOD; |
@@ -225,9 +223,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) | |||
225 | static int tuner_probe(struct i2c_adapter *adap) | 223 | static int tuner_probe(struct i2c_adapter *adap) |
226 | { | 224 | { |
227 | if (0 != addr) { | 225 | if (0 != addr) { |
228 | normal_i2c[0] = addr; | 226 | normal_i2c[0] = addr; |
229 | normal_i2c_range[0] = addr; | 227 | normal_i2c[1] = I2C_CLIENT_END; |
230 | normal_i2c_range[1] = addr; | ||
231 | } | 228 | } |
232 | this_adap = 0; | 229 | this_adap = 0; |
233 | 230 | ||
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 80dc34f18c2c..41b635e0d3c6 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -148,7 +148,6 @@ static unsigned short normal_i2c[] = { | |||
148 | I2C_TDA9874 >> 1, | 148 | I2C_TDA9874 >> 1, |
149 | I2C_PIC16C54 >> 1, | 149 | I2C_PIC16C54 >> 1, |
150 | I2C_CLIENT_END }; | 150 | I2C_CLIENT_END }; |
151 | static unsigned short normal_i2c_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
152 | I2C_CLIENT_INSMOD; | 151 | I2C_CLIENT_INSMOD; |
153 | 152 | ||
154 | static struct i2c_driver driver; | 153 | static struct i2c_driver driver; |
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index e1443a0937e3..3d216973798c 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c | |||
@@ -482,7 +482,6 @@ static unsigned short normal_i2c[] = { | |||
482 | 0xa0 >> 1, | 482 | 0xa0 >> 1, |
483 | I2C_CLIENT_END, | 483 | I2C_CLIENT_END, |
484 | }; | 484 | }; |
485 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
486 | I2C_CLIENT_INSMOD; | 485 | I2C_CLIENT_INSMOD; |
487 | 486 | ||
488 | struct i2c_driver i2c_driver_tveeprom; | 487 | struct i2c_driver i2c_driver_tveeprom; |
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index 0fd6c9a70917..5dbd9f6bf353 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c | |||
@@ -569,22 +569,14 @@ static unsigned short normal_i2c[] = | |||
569 | { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4, | 569 | { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4, |
570 | I2C_CLIENT_END | 570 | I2C_CLIENT_END |
571 | }; | 571 | }; |
572 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
573 | 572 | ||
574 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 573 | static unsigned short ignore = I2C_CLIENT_END; |
575 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
576 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
577 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
578 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
579 | 574 | ||
580 | static struct i2c_client_address_data addr_data = { | 575 | static struct i2c_client_address_data addr_data = { |
581 | .normal_i2c = normal_i2c, | 576 | .normal_i2c = normal_i2c, |
582 | .normal_i2c_range = normal_i2c_range, | 577 | .probe = &ignore, |
583 | .probe = probe, | 578 | .ignore = &ignore, |
584 | .probe_range = probe_range, | 579 | .force = &ignore, |
585 | .ignore = ignore, | ||
586 | .ignore_range = ignore_range, | ||
587 | .force = force | ||
588 | }; | 580 | }; |
589 | 581 | ||
590 | static struct i2c_driver vpx3220_i2c_driver; | 582 | static struct i2c_driver vpx3220_i2c_driver; |
diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index e529841cd83d..67f85344f0cc 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c | |||
@@ -1230,7 +1230,6 @@ static int maven_shutdown_client(struct i2c_client* clnt) { | |||
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; | 1232 | static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; |
1233 | static unsigned short normal_i2c_range[] = { MAVEN_I2CID, MAVEN_I2CID, I2C_CLIENT_END }; | ||
1234 | I2C_CLIENT_INSMOD; | 1233 | I2C_CLIENT_INSMOD; |
1235 | 1234 | ||
1236 | static struct i2c_driver maven_driver; | 1235 | static struct i2c_driver maven_driver; |
diff --git a/include/asm-arm/arch-omap/tps65010.h b/include/asm-arm/arch-omap/tps65010.h index 0f97bb2e8fce..b9aa2b3a3909 100644 --- a/include/asm-arm/arch-omap/tps65010.h +++ b/include/asm-arm/arch-omap/tps65010.h | |||
@@ -30,6 +30,66 @@ | |||
30 | 30 | ||
31 | /* | 31 | /* |
32 | * ---------------------------------------------------------------------------- | 32 | * ---------------------------------------------------------------------------- |
33 | * Registers, all 8 bits | ||
34 | * ---------------------------------------------------------------------------- | ||
35 | */ | ||
36 | |||
37 | #define TPS_CHGSTATUS 0x01 | ||
38 | # define TPS_CHG_USB (1 << 7) | ||
39 | # define TPS_CHG_AC (1 << 6) | ||
40 | # define TPS_CHG_THERM (1 << 5) | ||
41 | # define TPS_CHG_TERM (1 << 4) | ||
42 | # define TPS_CHG_TAPER_TMO (1 << 3) | ||
43 | # define TPS_CHG_CHG_TMO (1 << 2) | ||
44 | # define TPS_CHG_PRECHG_TMO (1 << 1) | ||
45 | # define TPS_CHG_TEMP_ERR (1 << 0) | ||
46 | #define TPS_REGSTATUS 0x02 | ||
47 | # define TPS_REG_ONOFF (1 << 7) | ||
48 | # define TPS_REG_COVER (1 << 6) | ||
49 | # define TPS_REG_UVLO (1 << 5) | ||
50 | # define TPS_REG_NO_CHG (1 << 4) /* tps65013 */ | ||
51 | # define TPS_REG_PG_LD02 (1 << 3) | ||
52 | # define TPS_REG_PG_LD01 (1 << 2) | ||
53 | # define TPS_REG_PG_MAIN (1 << 1) | ||
54 | # define TPS_REG_PG_CORE (1 << 0) | ||
55 | #define TPS_MASK1 0x03 | ||
56 | #define TPS_MASK2 0x04 | ||
57 | #define TPS_ACKINT1 0x05 | ||
58 | #define TPS_ACKINT2 0x06 | ||
59 | #define TPS_CHGCONFIG 0x07 | ||
60 | # define TPS_CHARGE_POR (1 << 7) /* 65010/65012 */ | ||
61 | # define TPS65013_AUA (1 << 7) /* 65011/65013 */ | ||
62 | # define TPS_CHARGE_RESET (1 << 6) | ||
63 | # define TPS_CHARGE_FAST (1 << 5) | ||
64 | # define TPS_CHARGE_CURRENT (3 << 3) | ||
65 | # define TPS_VBUS_500MA (1 << 2) | ||
66 | # define TPS_VBUS_CHARGING (1 << 1) | ||
67 | # define TPS_CHARGE_ENABLE (1 << 0) | ||
68 | #define TPS_LED1_ON 0x08 | ||
69 | #define TPS_LED1_PER 0x09 | ||
70 | #define TPS_LED2_ON 0x0a | ||
71 | #define TPS_LED2_PER 0x0b | ||
72 | #define TPS_VDCDC1 0x0c | ||
73 | # define TPS_ENABLE_LP (1 << 3) | ||
74 | #define TPS_VDCDC2 0x0d | ||
75 | #define TPS_VREGS1 0x0e | ||
76 | # define TPS_LDO2_ENABLE (1 << 7) | ||
77 | # define TPS_LDO2_OFF (1 << 6) | ||
78 | # define TPS_VLDO2_3_0V (3 << 4) | ||
79 | # define TPS_VLDO2_2_75V (2 << 4) | ||
80 | # define TPS_VLDO2_2_5V (1 << 4) | ||
81 | # define TPS_VLDO2_1_8V (0 << 4) | ||
82 | # define TPS_LDO1_ENABLE (1 << 3) | ||
83 | # define TPS_LDO1_OFF (1 << 2) | ||
84 | # define TPS_VLDO1_3_0V (3 << 0) | ||
85 | # define TPS_VLDO1_2_75V (2 << 0) | ||
86 | # define TPS_VLDO1_2_5V (1 << 0) | ||
87 | # define TPS_VLDO1_ADJ (0 << 0) | ||
88 | #define TPS_MASK3 0x0f | ||
89 | #define TPS_DEFGPIO 0x10 | ||
90 | |||
91 | /* | ||
92 | * ---------------------------------------------------------------------------- | ||
33 | * Macros used by exported functions | 93 | * Macros used by exported functions |
34 | * ---------------------------------------------------------------------------- | 94 | * ---------------------------------------------------------------------------- |
35 | */ | 95 | */ |
@@ -71,10 +131,26 @@ extern int tps65010_set_gpio_out_value(unsigned gpio, unsigned value); | |||
71 | */ | 131 | */ |
72 | extern int tps65010_set_led(unsigned led, unsigned mode); | 132 | extern int tps65010_set_led(unsigned led, unsigned mode); |
73 | 133 | ||
134 | /* tps65010_set_vib parameter: | ||
135 | * value: ON or OFF | ||
136 | */ | ||
137 | extern int tps65010_set_vib(unsigned value); | ||
138 | |||
74 | /* tps65010_set_low_pwr parameter: | 139 | /* tps65010_set_low_pwr parameter: |
75 | * mode: ON or OFF | 140 | * mode: ON or OFF |
76 | */ | 141 | */ |
77 | extern int tps65010_set_low_pwr(unsigned mode); | 142 | extern int tps65010_set_low_pwr(unsigned mode); |
78 | 143 | ||
144 | /* tps65010_config_vregs1 parameter: | ||
145 | * value to be written to VREGS1 register | ||
146 | * Note: The complete register is written, set all bits you need | ||
147 | */ | ||
148 | extern int tps65010_config_vregs1(unsigned value); | ||
149 | |||
150 | /* tps65013_set_low_pwr parameter: | ||
151 | * mode: ON or OFF | ||
152 | */ | ||
153 | extern int tps65013_set_low_pwr(unsigned mode); | ||
154 | |||
79 | #endif /* __ASM_ARCH_TPS65010_H */ | 155 | #endif /* __ASM_ARCH_TPS65010_H */ |
80 | 156 | ||
diff --git a/include/linux/i2c-sysfs.h b/include/linux/hwmon-sysfs.h index d7bf6ce11679..1b5018a965f5 100644 --- a/include/linux/i2c-sysfs.h +++ b/include/linux/hwmon-sysfs.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * i2c-sysfs.h - i2c chip driver sysfs defines | 2 | * hwmon-sysfs.h - hardware monitoring chip driver sysfs defines |
3 | * | 3 | * |
4 | * Copyright (C) 2005 Yani Ioannou <yani.ioannou@gmail.com> | 4 | * Copyright (C) 2005 Yani Ioannou <yani.ioannou@gmail.com> |
5 | * | 5 | * |
@@ -17,8 +17,8 @@ | |||
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | #ifndef _LINUX_I2C_SYSFS_H | 20 | #ifndef _LINUX_HWMON_SYSFS_H |
21 | #define _LINUX_I2C_SYSFS_H | 21 | #define _LINUX_HWMON_SYSFS_H |
22 | 22 | ||
23 | struct sensor_device_attribute{ | 23 | struct sensor_device_attribute{ |
24 | struct device_attribute dev_attr; | 24 | struct device_attribute dev_attr; |
@@ -33,4 +33,4 @@ struct sensor_device_attribute sensor_dev_attr_##_name = { \ | |||
33 | .index = _index, \ | 33 | .index = _index, \ |
34 | } | 34 | } |
35 | 35 | ||
36 | #endif /* _LINUX_I2C_SYSFS_H */ | 36 | #endif /* _LINUX_HWMON_SYSFS_H */ |
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 89270ce51470..33f08258f22b 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h | |||
@@ -108,6 +108,7 @@ | |||
108 | #define I2C_DRIVERID_TDA7313 62 /* TDA7313 audio processor */ | 108 | #define I2C_DRIVERID_TDA7313 62 /* TDA7313 audio processor */ |
109 | #define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */ | 109 | #define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */ |
110 | #define I2C_DRIVERID_SAA7114H 64 /* video decoder */ | 110 | #define I2C_DRIVERID_SAA7114H 64 /* video decoder */ |
111 | #define I2C_DRIVERID_DS1374 65 /* DS1374 real time clock */ | ||
111 | 112 | ||
112 | 113 | ||
113 | #define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */ | 114 | #define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */ |
diff --git a/include/linux/i2c-vid.h b/include/linux/i2c-vid.h index 974835e3530f..41d0635e0ba9 100644 --- a/include/linux/i2c-vid.h +++ b/include/linux/i2c-vid.h | |||
@@ -97,3 +97,15 @@ static inline int vid_from_reg(int val, int vrm) | |||
97 | 2050 - (val) * 50); | 97 | 2050 - (val) * 50); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | |||
101 | static inline int vid_to_reg(int val, int vrm) | ||
102 | { | ||
103 | switch (vrm) { | ||
104 | case 91: /* VRM 9.1 */ | ||
105 | case 90: /* VRM 9.0 */ | ||
106 | return ((val >= 1100) && (val <= 1850) ? | ||
107 | ((18499 - val * 10) / 25 + 5) / 10 : -1); | ||
108 | default: | ||
109 | return -1; | ||
110 | } | ||
111 | } | ||
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index ebcd745f4cd6..be837b13f297 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -290,11 +290,8 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) | |||
290 | */ | 290 | */ |
291 | struct i2c_client_address_data { | 291 | struct i2c_client_address_data { |
292 | unsigned short *normal_i2c; | 292 | unsigned short *normal_i2c; |
293 | unsigned short *normal_i2c_range; | ||
294 | unsigned short *probe; | 293 | unsigned short *probe; |
295 | unsigned short *probe_range; | ||
296 | unsigned short *ignore; | 294 | unsigned short *ignore; |
297 | unsigned short *ignore_range; | ||
298 | unsigned short *force; | 295 | unsigned short *force; |
299 | }; | 296 | }; |
300 | 297 | ||
@@ -563,24 +560,15 @@ union i2c_smbus_data { | |||
563 | #define I2C_CLIENT_INSMOD \ | 560 | #define I2C_CLIENT_INSMOD \ |
564 | I2C_CLIENT_MODULE_PARM(probe, \ | 561 | I2C_CLIENT_MODULE_PARM(probe, \ |
565 | "List of adapter,address pairs to scan additionally"); \ | 562 | "List of adapter,address pairs to scan additionally"); \ |
566 | I2C_CLIENT_MODULE_PARM(probe_range, \ | ||
567 | "List of adapter,start-addr,end-addr triples to scan " \ | ||
568 | "additionally"); \ | ||
569 | I2C_CLIENT_MODULE_PARM(ignore, \ | 563 | I2C_CLIENT_MODULE_PARM(ignore, \ |
570 | "List of adapter,address pairs not to scan"); \ | 564 | "List of adapter,address pairs not to scan"); \ |
571 | I2C_CLIENT_MODULE_PARM(ignore_range, \ | ||
572 | "List of adapter,start-addr,end-addr triples not to " \ | ||
573 | "scan"); \ | ||
574 | I2C_CLIENT_MODULE_PARM(force, \ | 565 | I2C_CLIENT_MODULE_PARM(force, \ |
575 | "List of adapter,address pairs to boldly assume " \ | 566 | "List of adapter,address pairs to boldly assume " \ |
576 | "to be present"); \ | 567 | "to be present"); \ |
577 | static struct i2c_client_address_data addr_data = { \ | 568 | static struct i2c_client_address_data addr_data = { \ |
578 | .normal_i2c = normal_i2c, \ | 569 | .normal_i2c = normal_i2c, \ |
579 | .normal_i2c_range = normal_i2c_range, \ | ||
580 | .probe = probe, \ | 570 | .probe = probe, \ |
581 | .probe_range = probe_range, \ | ||
582 | .ignore = ignore, \ | 571 | .ignore = ignore, \ |
583 | .ignore_range = ignore_range, \ | ||
584 | .force = force, \ | 572 | .force = force, \ |
585 | } | 573 | } |
586 | 574 | ||