aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/feature-removal-schedule.txt10
-rw-r--r--Documentation/i2c/busses/i2c-sis69x2
-rw-r--r--Documentation/i2c/chips/adm1021111
-rw-r--r--Documentation/i2c/chips/adm102551
-rw-r--r--Documentation/i2c/chips/adm102693
-rw-r--r--Documentation/i2c/chips/adm103135
-rw-r--r--Documentation/i2c/chips/adm9240177
-rw-r--r--Documentation/i2c/chips/asb10072
-rw-r--r--Documentation/i2c/chips/ds1621108
-rw-r--r--Documentation/i2c/chips/eeprom96
-rw-r--r--Documentation/i2c/chips/fscher169
-rw-r--r--Documentation/i2c/chips/gl518sm74
-rw-r--r--Documentation/i2c/chips/it8796
-rw-r--r--Documentation/i2c/chips/lm6357
-rw-r--r--Documentation/i2c/chips/lm7565
-rw-r--r--Documentation/i2c/chips/lm7722
-rw-r--r--Documentation/i2c/chips/lm7882
-rw-r--r--Documentation/i2c/chips/lm8056
-rw-r--r--Documentation/i2c/chips/lm8376
-rw-r--r--Documentation/i2c/chips/lm85221
-rw-r--r--Documentation/i2c/chips/lm8773
-rw-r--r--Documentation/i2c/chips/lm90121
-rw-r--r--Documentation/i2c/chips/lm9237
-rw-r--r--Documentation/i2c/chips/max161929
-rw-r--r--Documentation/i2c/chips/max687554
-rw-r--r--Documentation/i2c/chips/pc87360189
-rw-r--r--Documentation/i2c/chips/pca953947
-rw-r--r--Documentation/i2c/chips/pcf857469
-rw-r--r--Documentation/i2c/chips/pcf859190
-rw-r--r--Documentation/i2c/chips/sis5595106
-rw-r--r--Documentation/i2c/chips/smsc47b397 (renamed from Documentation/i2c/chips/smsc47b397.txt)46
-rw-r--r--Documentation/i2c/chips/smsc47m152
-rw-r--r--Documentation/i2c/chips/via686a65
-rw-r--r--Documentation/i2c/chips/w83627hf66
-rw-r--r--Documentation/i2c/chips/w83781d402
-rw-r--r--Documentation/i2c/chips/w83l785ts39
-rw-r--r--Documentation/i2c/porting-clients2
-rw-r--r--Documentation/i2c/userspace-tools39
-rw-r--r--Documentation/i2c/writing-clients62
-rw-r--r--MAINTAINERS16
-rw-r--r--arch/ppc/platforms/83xx/mpc834x_sys.c20
-rw-r--r--drivers/acorn/char/pcf8583.c3
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c8
-rw-r--r--drivers/i2c/algos/i2c-algo-sibyte.c1
-rw-r--r--drivers/i2c/busses/Kconfig34
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c1
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c1
-rw-r--r--drivers/i2c/busses/i2c-amd756.c1
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c1
-rw-r--r--drivers/i2c/busses/i2c-au1550.c1
-rw-r--r--drivers/i2c/busses/i2c-elektor.c1
-rw-r--r--drivers/i2c/busses/i2c-frodo.c1
-rw-r--r--drivers/i2c/busses/i2c-i801.c1
-rw-r--r--drivers/i2c/busses/i2c-i810.c1
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c2
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.h1
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c2
-rw-r--r--drivers/i2c/busses/i2c-isa.c1
-rw-r--r--drivers/i2c/busses/i2c-ite.c1
-rw-r--r--drivers/i2c/busses/i2c-ixp2000.c5
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c5
-rw-r--r--drivers/i2c/busses/i2c-keywest.c1
-rw-r--r--drivers/i2c/busses/i2c-mpc.c18
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c1
-rw-r--r--drivers/i2c/busses/i2c-parport-light.c1
-rw-r--r--drivers/i2c/busses/i2c-parport.c3
-rw-r--r--drivers/i2c/busses/i2c-pca-isa.c1
-rw-r--r--drivers/i2c/busses/i2c-piix4.c1
-rw-r--r--drivers/i2c/busses/i2c-prosavage.c1
-rw-r--r--drivers/i2c/busses/i2c-rpx.c1
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c3
-rw-r--r--drivers/i2c/busses/i2c-savage4.c1
-rw-r--r--drivers/i2c/busses/i2c-sibyte.c1
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c1
-rw-r--r--drivers/i2c/busses/i2c-sis630.c1
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c1
-rw-r--r--drivers/i2c/busses/i2c-stub.c1
-rw-r--r--drivers/i2c/busses/i2c-via.c1
-rw-r--r--drivers/i2c/busses/i2c-viapro.c1
-rw-r--r--drivers/i2c/busses/i2c-voodoo3.c1
-rw-r--r--drivers/i2c/busses/scx200_acb.c1
-rw-r--r--drivers/i2c/chips/Kconfig117
-rw-r--r--drivers/i2c/chips/Makefile10
-rw-r--r--drivers/i2c/chips/adm1021.c9
-rw-r--r--drivers/i2c/chips/adm1025.c5
-rw-r--r--drivers/i2c/chips/adm1026.c8
-rw-r--r--drivers/i2c/chips/adm1031.c2
-rw-r--r--drivers/i2c/chips/adm9240.c791
-rw-r--r--drivers/i2c/chips/asb100.c5
-rw-r--r--drivers/i2c/chips/atxp1.c361
-rw-r--r--drivers/i2c/chips/ds1337.c97
-rw-r--r--drivers/i2c/chips/ds1374.c260
-rw-r--r--drivers/i2c/chips/ds1621.c4
-rw-r--r--drivers/i2c/chips/eeprom.c1
-rw-r--r--drivers/i2c/chips/fscher.c1
-rw-r--r--drivers/i2c/chips/gl518sm.c1
-rw-r--r--drivers/i2c/chips/isp1301_omap.c1
-rw-r--r--drivers/i2c/chips/it87.c396
-rw-r--r--drivers/i2c/chips/lm63.c262
-rw-r--r--drivers/i2c/chips/lm75.c1
-rw-r--r--drivers/i2c/chips/lm77.c1
-rw-r--r--drivers/i2c/chips/lm78.c5
-rw-r--r--drivers/i2c/chips/lm80.c1
-rw-r--r--drivers/i2c/chips/lm83.c160
-rw-r--r--drivers/i2c/chips/lm85.c5
-rw-r--r--drivers/i2c/chips/lm87.c1
-rw-r--r--drivers/i2c/chips/lm90.c273
-rw-r--r--drivers/i2c/chips/m41t00.c3
-rw-r--r--drivers/i2c/chips/max1619.c1
-rw-r--r--drivers/i2c/chips/max6875.c473
-rw-r--r--drivers/i2c/chips/pc87360.c1
-rw-r--r--drivers/i2c/chips/pca9539.c192
-rw-r--r--drivers/i2c/chips/pcf8574.c6
-rw-r--r--drivers/i2c/chips/rtc8564.c4
-rw-r--r--drivers/i2c/chips/sis5595.c1
-rw-r--r--drivers/i2c/chips/smsc47m1.c10
-rw-r--r--drivers/i2c/chips/tps65010.c1072
-rw-r--r--drivers/i2c/chips/via686a.c305
-rw-r--r--drivers/i2c/chips/w83627ehf.c846
-rw-r--r--drivers/i2c/chips/w83627hf.c2
-rw-r--r--drivers/i2c/chips/w83781d.c78
-rw-r--r--drivers/i2c/chips/w83l785ts.c1
-rw-r--r--drivers/i2c/i2c-core.c102
-rw-r--r--drivers/i2c/i2c-dev.c3
-rw-r--r--drivers/macintosh/therm_windtunnel.c6
-rw-r--r--drivers/media/video/adv7170.c16
-rw-r--r--drivers/media/video/adv7175.c16
-rw-r--r--drivers/media/video/bt819.c16
-rw-r--r--drivers/media/video/bt832.c4
-rw-r--r--drivers/media/video/bt856.c16
-rw-r--r--drivers/media/video/msp3400.c1
-rw-r--r--drivers/media/video/saa5246a.c1
-rw-r--r--drivers/media/video/saa5249.c1
-rw-r--r--drivers/media/video/saa7110.c16
-rw-r--r--drivers/media/video/saa7111.c16
-rw-r--r--drivers/media/video/saa7114.c16
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c1
-rw-r--r--drivers/media/video/saa7185.c16
-rw-r--r--drivers/media/video/tda7432.c1
-rw-r--r--drivers/media/video/tda9840.c1
-rw-r--r--drivers/media/video/tda9875.c1
-rw-r--r--drivers/media/video/tda9887.c1
-rw-r--r--drivers/media/video/tea6415c.c1
-rw-r--r--drivers/media/video/tea6420.c1
-rw-r--r--drivers/media/video/tuner-3036.c17
-rw-r--r--drivers/media/video/tuner-core.c11
-rw-r--r--drivers/media/video/tvaudio.c1
-rw-r--r--drivers/media/video/tveeprom.c1
-rw-r--r--drivers/media/video/vpx3220.c16
-rw-r--r--drivers/video/matrox/matroxfb_maven.c1
-rw-r--r--include/asm-arm/arch-omap/tps65010.h76
-rw-r--r--include/linux/hwmon-sysfs.h (renamed from include/linux/i2c-sysfs.h)8
-rw-r--r--include/linux/i2c-id.h1
-rw-r--r--include/linux/i2c-vid.h12
-rw-r--r--include/linux/i2c.h12
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.
85Who: Jody McIntyre <scjody@steamballoon.com> 85Who: Jody McIntyre <scjody@steamballoon.com>
86
87---------------------------
88
89What: i2c sysfs name change: in1_ref, vid deprecated in favour of cpu0_vid
90When: November 2005
91Files: drivers/i2c/chips/adm1025.c, drivers/i2c/chips/adm1026.c
92Why: Match the other drivers' name for the same function, duplicate names
93 will be available until removal of old names.
94Who: 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
42chipsets as well: 635, and 635T. If anyone owns a board with those chips 42chipsets as well: 635, and 635T. If anyone owns a board with those chips
43AND is willing to risk crashing & burning an otherwise well-behaved kernel 43AND is willing to risk crashing & burning an otherwise well-behaved kernel
44in the name of progress... please contact me at <mhoffman@lightlink.com> or 44in the name of progress... please contact me at <mhoffman@lightlink.com> or
45via the project's mailing list: <sensors@stimpy.netroedge.com>. Please 45via the project's mailing list: <lm-sensors@lm-sensors.org>. Please
46send bug reports and/or success stories as well. 46send 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 @@
1Kernel driver adm1021
2=====================
3
4Supported 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
51Authors:
52 Frodo Looijaard <frodol@dds.nl>,
53 Philip Edelbrock <phil@netroedge.com>
54
55Module Parameters
56-----------------
57
58* read_only: int
59 Don't set any values, read only mode
60
61
62Description
63-----------
64
65The chips supported by this driver are very similar. The Maxim MAX1617 is
66the oldest; it has the problem that it is not very well detectable. The
67MAX1617A solves that. The ADM1021 is a straight clone of the MAX1617A.
68Ditto for the THMC10. From here on, we will refer to all these chips as
69ADM1021-clones.
70
71The ADM1021 and MAX1617A reports a die code, which is a sort of revision
72code. This can help us pinpoint problems; it is not very useful
73otherwise.
74
75ADM1021-clones implement two temperature sensors. One of them is internal,
76and measures the temperature of the chip itself; the other is external and
77is realised in the form of a transistor-like device. A special alarm
78indicates whether the remote sensor is connected.
79
80Each sensor has its own low and high limits. When they are crossed, the
81corresponding alarm is set and remains on as long as the temperature stays
82out of range. Temperatures are measured in degrees Celsius. Measurements
83are possible between -65 and +127 degrees, with a resolution of one degree.
84
85If an alarm triggers, it will remain triggered until the hardware register
86is read at least once. This means that the cause for the alarm may already
87have disappeared!
88
89This driver only updates its values each 1.5 seconds; reading it more often
90will do no harm, but will return 'old' values. It is possible to make
91ADM1021-clones do faster measurements, but there is really no good reason
92for that.
93
94Xeon support
95------------
96
97Some Xeon processors have real max1617, adm1021, or compatible chips
98within them, with two temperature sensors.
99
100Other Xeons have chips with only one sensor.
101
102If you have a Xeon, and the adm1021 module loads, and both temperatures
103appear valid, then things are good.
104
105If 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
109If you have dual Xeons you may have appear to have two separate
110adm1021-compatible chips, or two single-temperature sensors, at distinct
111addresses.
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 @@
1Kernel driver adm1025
2=====================
3
4Supported 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
14The 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
19Authors:
20 Chen-Yuan Wu <gwu@esoft.com>,
21 Jean Delvare <khali@linux-fr.org>
22
23Description
24-----------
25
26(This is from Analog Devices.) The ADM1025 is a complete system hardware
27monitor for microprocessor-based systems, providing measurement and limit
28comparison of various system parameters. Five voltage measurement inputs
29are provided, for monitoring +2.5V, +3.3V, +5V and +12V power supplies and
30the processor core voltage. The ADM1025 can monitor a sixth power-supply
31voltage by measuring its own VCC. One input (two pins) is dedicated to a
32remote temperature-sensing diode and an on-chip temperature sensor allows
33ambient temperature to be monitored.
34
35One specificity of this chip is that the pin 11 can be hardwired in two
36different manners. It can act as the +12V power-supply voltage analog
37input, or as the a fifth digital entry for the VID reading (bit 4). It's
38kind of strange since both are useful, and the reason for designing the
39chip that way is obscure at least to me. The bit 5 of the configuration
40register can be used to define how the chip is hardwired. Please note that
41it is not a choice you have to make as the user. The choice was already
42made by your motherboard's maker. If the configuration bit isn't set
43properly, you'll have a wrong +12V reading or a wrong VID reading. The way
44the driver handles that is to preserve this bit through the initialization
45process, assuming that the BIOS set it up properly beforehand. If it turns
46out not to be true in some cases, we'll provide a module parameter to force
47modes.
48
49This driver also supports the ADM1025A, which differs from the ADM1025
50only in that it has "open-drain VID inputs while the ADM1025 has on-chip
51100k 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 @@
1Kernel driver adm1026
2=====================
3
4Supported 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
11Authors:
12 Philip Pokorny <ppokorny@penguincomputing.com> for Penguin Computing
13 Justin Thiessen <jthiessen@penguincomputing.com>
14
15Module 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
30Description
31-----------
32
33This driver implements support for the Analog Devices ADM1026. Analog
34Devices calls it a "complete thermal system management controller."
35
36The ADM1026 implements three (3) temperature sensors, 17 voltage sensors,
3716 general purpose digital I/O lines, eight (8) fan speed sensors (8-bit),
38an analog output and a PWM output along with limit, alarm and mask bits for
39all of the above. There is even 8k bytes of EEPROM memory on chip.
40
41Temperatures are measured in degrees Celsius. There are two external
42sensor inputs and one internal sensor. Each sensor has a high and low
43limit. If the limit is exceeded, an interrupt (#SMBALERT) can be
44generated. The interrupts can be masked. In addition, there are over-temp
45limits for each sensor. If this limit is exceeded, the #THERM output will
46be asserted. The current temperature and limits have a resolution of 1
47degree.
48
49Fan rotation speeds are reported in RPM (rotations per minute) but measured
50in counts of a 22.5kHz internal clock. Each fan has a high limit which
51corresponds to a minimum fan speed. If the limit is exceeded, an interrupt
52can be generated. Each fan can be programmed to divide the reference clock
53by 1, 2, 4 or 8. Not all RPM values can accurately be represented, so some
54rounding is done. With a divider of 8, the slowest measurable speed of a
55two pulse per revolution fan is 661 RPM.
56
57There are 17 voltage sensors. An alarm is triggered if the voltage has
58crossed a programmable minimum or maximum limit. Note that minimum in this
59case always means 'closest to zero'; this is important for negative voltage
60measurements. Several inputs have integrated attenuators so they can measure
61higher voltages directly. 3.3V, 5V, 12V, -12V and battery voltage all have
62dedicated inputs. There are several inputs scaled to 0-3V full-scale range
63for SCSI terminator power. The remaining inputs are not scaled and have
64a 0-2.5V full-scale range. A 2.5V or 1.82V reference voltage is provided
65for negative voltage measurements.
66
67If an alarm triggers, it will remain triggered until the hardware register
68is read at least once. This means that the cause for the alarm may already
69have disappeared! Note that in the current implementation, all hardware
70registers are read whenever any data is read (unless it is less than 2.0
71seconds since the last update). This means that you can easily miss
72once-only alarms.
73
74The ADM1026 measures continuously. Analog inputs are measured about 4
75times a second. Fan speed measurement time depends on fan speed and
76divisor. It can take as long as 1.5 seconds to measure all fan speeds.
77
78The ADM1026 has the ability to automatically control fan speed based on the
79temperature sensor inputs. Both the PWM output and the DAC output can be
80used to control fan speed. Usually only one of these two outputs will be
81used. Write the minimum PWM or DAC value to the appropriate control
82register. Then set the low temperature limit in the tmin values for each
83temperature sensor. The range of control is fixed at 20 °C, and the
84largest difference between current and tmin of the temperature sensors sets
85the control output. See the datasheet for several example circuits for
86controlling fan speed with the PWM and DAC outputs. The fan speed sensors
87do not have PWM compensation, so it is probably best to control the fan
88voltage from the power lead rather than on the ground lead.
89
90The datasheet shows an example application with VID signals attached to
91GPIO lines. Unfortunately, the chip may not be connected to the VID lines
92in this way. The driver assumes that the chips *is* connected this way to
93get 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 @@
1Kernel driver adm1031
2=====================
3
4Supported 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
17Authors:
18 Alexandre d'Alton <alex@alexdalton.org>
19 Jean Delvare <khali@linux-fr.org>
20
21Description
22-----------
23
24The ADM1030 and ADM1031 are digital temperature sensors and fan controllers.
25They sense their own temperature as well as the temperature of up to one
26(ADM1030) or two (ADM1031) external diodes.
27
28All temperature values are given in degrees Celsius. Resolution is 0.5
29degree for the local temperature, 0.125 degree for the remote temperatures.
30
31Each temperature channel has its own high and low limits, plus a critical
32limit.
33
34The ADM1030 monitors a single fan speed, while the ADM1031 monitors up to
35two. 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 @@
1Kernel driver adm9240
2=====================
3
4Supported 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
23Authors:
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
30Interface
31---------
32The I2C addresses listed above assume BIOS has not changed the
33chip MSB 5-bit address. Each chip reports a unique manufacturer
34identification code as well as the chip revision/stepping level.
35
36Description
37-----------
38[From ADM9240] The ADM9240 is a complete system hardware monitor for
39microprocessor-based systems, providing measurement and limit comparison
40of up to four power supplies and two processor core voltages, plus
41temperature, two fan speeds and chassis intrusion. Measured values can
42be read out via an I2C-compatible serial System Management Bus, and values
43for limit comparisons can be programmed in over the same serial bus. The
44high speed successive approximation ADC allows frequent sampling of all
45analog channels to ensure a fast interrupt response to any out-of-limit
46measurement.
47
48The ADM9240, DS1780 and LM81 are register compatible, the following
49details are common to the three chips. Chip differences are described
50after this section.
51
52
53Measurements
54------------
55The measurement cycle
56
57The adm9240 driver will take a measurement reading no faster than once
58each two seconds. User-space may read sysfs interface faster than the
59measurement update rate and will receive cached data from the most
60recent measurement.
61
62ADM9240 has a very fast 320us temperature and voltage measurement cycle
63with independent fan speed measurement cycles counting alternating rising
64edges of the fan tacho inputs.
65
66DS1780 measurement cycle is about once per second including fan speed.
67
68LM81 measurement cycle is about once per 400ms including fan speed.
69The LM81 12-bit extended temperature measurement mode is not supported.
70
71Temperature
72-----------
73On chip temperature is reported as degrees Celsius as 9-bit signed data
74with resolution of 0.5 degrees Celsius. High and low temperature limits
75are 8-bit signed data with resolution of one degree Celsius.
76
77Temperature alarm is asserted once the temperature exceeds the high limit,
78and is cleared when the temperature falls below the temp1_max_hyst value.
79
80Fan Speed
81---------
82Two fan tacho inputs are provided, the ADM9240 gates an internal 22.5kHz
83clock via a divider to an 8-bit counter. Fan speed (rpm) is calculated by:
84
85rpm = (22500 * 60) / (count * divider)
86
87Automatic 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
117Analog Output
118-------------
119An analog output provides a 0 to 1.25 volt signal intended for an external
120fan speed amplifier circuit. The analog output is set to maximum value on
121power up or reset. This doesn't do much on the test Intel SE440BX-2.
122
123Voltage Monitor
124
125Voltage (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
136The reading is an unsigned 8-bit value, nominal voltage measurement is
137represented by a reading of 192, being 3/4 of the measurement range.
138
139An alarm is asserted for any voltage going below or above the set limits.
140
141The driver reports and accepts voltage limits scaled to the above table.
142
143VID Monitor
144-----------
145The chip has five inputs to read the 5-bit VID and reports the mV value
146based on detected CPU type.
147
148Chassis Intrusion
149-----------------
150An alarm is asserted when the CI pin goes active high. The ADM9240
151Datasheet has an example of an external temperature sensor driving
152this pin. On an Intel SE440BX-2 the Chassis Intrusion header is
153connected to a normally open switch.
154
155The ADM9240 provides an internal open drain on this line, and may output
156a 20 ms active low pulse to reset an external Chassis Intrusion latch.
157
158Clear the CI latch by writing value 1 to the sysfs chassis_clear file.
159
160Alarm 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
175Remaining bits are reserved and thus undefined. It is important to note
176that alarm bits may be cleared on read, user-space may latch alarms and
177provide 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 @@
1Kernel driver asb100
2====================
3
4Supported Chips:
5 * Asus ASB100 and ASB100-A "Bach"
6 Prefix: 'asb100'
7 Addresses scanned: I2C 0x2d
8 Datasheet: none released
9
10Author: Mark M. Hoffman <mhoffman@lightlink.com>
11
12Description
13-----------
14
15This driver implements support for the Asus ASB100 and ASB100-A "Bach".
16These are custom ASICs available only on Asus mainboards. Asus refuses to
17supply a datasheet for these chips. Thanks go to many people who helped
18investigate their hardware, including:
19
20Vitaly V. Bursov
21Alexander van Kaam (author of MBM for Windows)
22Bertrik Sikken
23
24The ASB100 implements seven voltage sensors, three fan rotation speed
25sensors, four temperature sensors, VID lines and alarms. In addition to
26these, the ASB100-A also implements a single PWM controller for fans 2 and
273 (i.e. one setting controls both.) If you have a plain ASB100, the PWM
28controller will simply not work (or maybe it will for you... it doesn't for
29me).
30
31Temperatures are measured and reported in degrees Celsius.
32
33Fan speeds are reported in RPM (rotations per minute). An alarm is
34triggered if the rotation speed has dropped below a programmable limit.
35
36Voltage sensors (also known as IN sensors) report values in volts.
37
38The VID lines encode the core voltage value: the voltage level your
39processor should work with. This is hardcoded by the mainboard and/or
40processor itself. It is a value in volts.
41
42Alarms: (TODO question marks indicate may or may not work)
43
440x0001 => in0 (?)
450x0002 => in1 (?)
460x0004 => in2
470x0008 => in3
480x0010 => temp1 (1)
490x0020 => temp2
500x0040 => fan1
510x0080 => fan2
520x0100 => in4
530x0200 => in5 (?) (2)
540x0400 => in6 (?) (2)
550x0800 => fan3
560x1000 => chassis switch
570x2000 => temp3
58
59Alarm Notes:
60
61(1) This alarm will only trigger if the hysteresis value is 127C.
62I.e. it behaves the same as w83781d.
63
64(2) The min and max registers for these values appear to
65be read-only or otherwise stuck at 0x00.
66
67TODO:
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 @@
1Kernel driver ds1621
2====================
3
4Supported 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
16Authors:
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
22Module Parameters
23------------------
24
25* polarity int
26 Output's polarity: 0 = active high, 1 = active low
27
28Description
29-----------
30
31The DS1621 is a (one instance) digital thermometer and thermostat. It has
32both high and low temperature limits which can be user defined (i.e.
33programmed into non-volatile on-chip registers). Temperature range is -55
34degree Celsius to +125 in 0.5 increments. You may convert this into a
35Fahrenheit range of -67 to +257 degrees with 0.9 steps. If polarity
36parameter is not provided, original value is used.
37
38As for the thermostat, behavior can also be programmed using the polarity
39toggle. On the one hand ("heater"), the thermostat output of the chip,
40Tout, will trigger when the low limit temperature is met or underrun and
41stays 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
44is somewhat misleading in this point since setting the polarity bit does
45not simply invert Tout.
46
47A second thing is that, during extensive testing, Tout showed a tolerance
48of up to +/- 0.5 degrees even when compared against precise temperature
49readings. Be sure to have a high vs. low temperature limit gap of al least
501.0 degree Celsius to avoid Tout "bouncing", though!
51
52As 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
54configuration register of the chip; bit 6 (0x40 or 64) is the high alarm
55bit and bit 5 (0x20 or 32) the low one. These bits are set when the high or
56low limits are met or exceeded and are reset by the module as soon as the
57respective temperature ranges are left.
58
59The alarm registers are in no way suitable to find out about the actual
60status of Tout. They will only tell you about its history, whether or not
61any of the limits have ever been met or exceeded since last power-up or
62reset. Be aware: When testing, it showed that the status of Tout can change
63with neither of the alarms set.
64
65Temperature conversion of the DS1621 takes up to 1000ms; internal access to
66non-volatile registers may last for 10ms or below.
67
68High Accuracy Temperature Reading
69---------------------------------
70
71As said before, the temperature issued via the 9-bit i2c-bus data is
72somewhat arbitrary. Internally, the temperature conversion is of a
73different kind that is explained (not so...) well in the DS1621 data sheet.
74To cut the long story short: Inside the DS1621 there are two oscillators,
75both of them biassed by a temperature coefficient.
76
77Higher resolution of the temperature reading can be achieved using the
78internal projection, which means taking account of REG_COUNT and REG_SLOPE
79(the driver manages them):
80
81Taken from Dallas Semiconductors App Note 068: 'Increasing Temperature
82Resolution on the DS1620' and App Note 105: 'High Resolution Temperature
83Measurement 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
92Note that this is what the DONE bit in the DS1621 configuration register is
93good for: Internally, one temperature conversion takes up to 1000ms. Before
94that conversion is complete you will not be able to read valid things out
95of REG_COUNT and REG_SLOPE. The DONE bit, as you may have guessed by now,
96tells you whether the conversion is complete ("done", in plain English) and
97thus, whether the values you read are good or not.
98
99The DS1621 has two modes of operation: "Continuous" conversion, which can
100be understood as the default stand-alone mode where the chip gets the
101temperature and controls external devices via its Tout pin or tells other
102i2c's about it if they care. The other mode is called "1SHOT", that means
103that it only figures out about the temperature when it is explicitly told
104to do so; this can be seen as power saving mode.
105
106Now if you want to read REG_COUNT and REG_SLOPE, you have to either stop
107the continuous conversions until the contents of these registers are valid,
108or, 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 @@
1Kernel driver eeprom
2====================
3
4Supported 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
38Authors:
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
45Description
46-----------
47
48This is a simple EEPROM module meant to enable reading the first 256 bytes
49of an EEPROM (on a SDRAM DIMM for example). However, it will access serial
50EEPROMs on any I2C adapter. The supported devices are generically called
5124Cxx, and are listed above; however the numbering for these
52industry-standard devices may vary by manufacturer.
53
54This module was a programming exercise to get used to the new project
55organization laid out by Frodo, but it should be at least completely
56effective for decoding the contents of EEPROMs on DIMMs.
57
58DIMMS will typically contain a 24C01A or 24C02, or the 34C02 variants.
59The other devices will not be found on a DIMM because they respond to more
60than one address.
61
62DDC Monitors may contain any device. Often a 24C01, which responds to all 8
63addresses, is found.
64
65Recent Sony Vaio laptops have an EEPROM at 0x57. We couldn't get the
66specification, so it is guess work and far from being complete.
67
68The Microchip 24AA52/24LCS52, ST M34C02, and others support an additional
69software write protect register at 0x30 - 0x37 (0x20 less than the memory
70location). The chip responds to "write quick" detection at this address but
71does not respond to byte reads. If this register is present, the lower 128
72bytes of the memory array are not write protected. Any byte data write to
73this address will write protect the memory array permanently, and the
74device will no longer respond at the 0x30-37 address. The eeprom driver
75does not support this register.
76
77Lacking functionality:
78
79* Full support for larger devices (24C04, 24C08, 24C16). These are not
80typically found on a PC. These devices will appear as separate devices at
81multiple addresses.
82
83* Support for really large devices (24C32, 24C64, 24C128, 24C256, 24C512).
84These devices require two-byte address fields and are not supported.
85
86* Enable Writing. Again, no technical reason why not, but making it easy
87to change the contents of the EEPROMs (on DIMMs anyway) also makes it easy
88to disable the DIMMs (potentially preventing the computer from booting)
89until the values are restored somehow.
90
91Use:
92
93After inserting the module (and any other required SMBus/i2c modules), you
94should have some EEPROM directories in /sys/bus/i2c/devices/* of names such
95as "0-0050". Inside each of these is a series of files, the eeprom file
96contains 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 @@
1Kernel driver fscher
2====================
3
4Supported chips:
5 * Fujitsu-Siemens Hermes chip
6 Prefix: 'fscher'
7 Addresses scanned: I2C 0x73
8
9Authors:
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
15Description
16-----------
17
18This driver implements support for the Fujitsu-Siemens Hermes chip. It is
19described in the 'Register Set Specification BMC Hermes based Systemboard'
20from Fujitsu-Siemens.
21
22The Hermes chip implements a hardware-based system management, e.g. for
23controlling fan speed and core voltage. There is also a watchdog counter on
24the chip which can trigger an alarm and even shut the system down.
25
26The chip provides three temperature values (CPU, motherboard and
27auxiliary), three voltage values (+12V, +5V and battery) and three fans
28(power supply, CPU and auxiliary).
29
30Temperatures are measured in degrees Celsius. The resolution is 1 degree.
31
32Fan rotation speeds are reported in RPM (rotations per minute). The value
33can be divided by a programmable divider (1, 2 or 4) which is stored on
34the chip.
35
36Voltage sensors (also known as "in" sensors) report their values in volts.
37
38All values are reported as final values from the driver. There is no need
39for further calculations.
40
41
42Detailed description
43--------------------
44
45Below you'll find a single line description of all the bit values. With
46this information, you're able to decode e. g. alarms, wdog, etc. To make
47use of the watchdog, you'll need to set the watchdog time and enable the
48watchdog. After that it is necessary to restart the watchdog time within
49the 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
149Limitations
150-----------
151
152* Measuring fan speed
153It seems that the chip counts "ripples" (typical fans produce 2 ripples per
154rotation while VERAX fans produce 18) in a 9-bit register. This register is
155read out every second, then the ripple prescaler (2, 4 or 8) is applied and
156the result is stored in the 8 bit output register. Due to the limitation of
157the counting register to 9 bits, it is impossible to measure a VERAX fan
158properly (even with a prescaler of 8). At its maximum speed of 3500 RPM the
159fan produces 1080 ripples per second which causes the counting register to
160overflow twice, leading to only 186 RPM.
161
162* Measuring input voltages
163in2 ("battery") reports the voltage of the onboard lithium battery and not
164+3.3V from the power supply.
165
166* Undocumented features
167Fujitsu-Siemens Computers has not documented all features of the chip so
168far. Their software, System Guard, shows that there are a still some
169features 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 @@
1Kernel driver gl518sm
2=====================
3
4Supported 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
14Authors:
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
20Description
21-----------
22
23IMPORTANT:
24
25For the revision 0x00 chip, the in0, in1, and in2 values (+5V, +3V,
26and +12V) CANNOT be read. This is a limitation of the chip, not the driver.
27
28This driver supports the Genesys Logic GL518SM chip. There are at least
29two revision of this chip, which we call revision 0x00 and 0x80. Revision
300x80 chips support the reading of all voltages and revision 0x00 only
31for VIN3.
32
33The GL518SM implements one temperature sensor, two fan rotation speed
34sensors, and four voltage sensors. It can report alarms through the
35computer speakers.
36
37Temperatures are measured in degrees Celsius. An alarm goes off while the
38temperature is above the over temperature limit, and has not yet dropped
39below the hysteresis limit. The alarm always reflects the current
40situation. Measurements are guaranteed between -10 degrees and +110
41degrees, with a accuracy of +/-3 degrees.
42
43Rotation speeds are reported in RPM (rotations per minute). An alarm is
44triggered if the rotation speed has dropped below a programmable limit. In
45case when you have selected to turn fan1 off, no fan1 alarm is triggered.
46
47Fan readings can be divided by a programmable divider (1, 2, 4 or 8) to
48give the readings more range or accuracy. Not all RPM values can
49accurately be represented, so some rounding is done. With a divider
50of 2, the lowest representable value is around 1900 RPM.
51
52Voltage sensors (also known as VIN sensors) report their values in volts.
53An alarm is triggered if the voltage has crossed a programmable minimum or
54maximum limit. Note that minimum in this case always means 'closest to
55zero'; this is important for negative voltage measurements. The VDD input
56measures voltages between 0.000 and 5.865 volt, with a resolution of 0.023
57volt. The other inputs measure voltages between 0.000 and 4.845 volt, with
58a resolution of 0.019 volt. Note that revision 0x00 chips do not support
59reading the current voltage of any input except for VIN3; limit setting and
60alarms work fine, though.
61
62When an alarm is triggered, you can be warned by a beeping signal through your
63computer speaker. It is possible to enable all beeping globally, or only the
64beeping for some alarms.
65
66If an alarm triggers, it will remain triggered until the hardware register
67is read at least once (except for temperature alarms). This means that the
68cause for the alarm may already have disappeared! Note that in the current
69implementation, 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
71you can easily miss once-only alarms.
72
73The GL518SM only updates its values each 1.5 seconds; reading it more often
74will 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 @@
1Kernel driver it87
2==================
3
4Supported 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
21Author: Christophe Gauthron <chrisg@0-in.com>
22
23
24Module 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
43Description
44-----------
45
46This driver implements support for the IT8705F, IT8712F and SiS950 chips.
47
48This driver also supports IT8712F, which adds SMBus access, and a VID
49input, used to report the Vcore voltage of the Pentium processor.
50The IT8712F additionally features VID inputs.
51
52These chips are 'Super I/O chips', supporting floppy disks, infrared ports,
53joysticks and other miscellaneous stuff. For hardware monitoring, they
54include an 'environment controller' with 3 temperature sensors, 3 fan
55rotation speed sensors, 8 voltage sensors, and associated alarms.
56
57Temperatures are measured in degrees Celsius. An alarm is triggered once
58when the Overtemperature Shutdown limit is crossed.
59
60Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
61triggered if the rotation speed has dropped below a programmable limit. Fan
62readings can be divided by a programmable divider (1, 2, 4 or 8) to give the
63readings more range or accuracy. Not all RPM values can accurately be
64represented, so some rounding is done. With a divider of 2, the lowest
65representable value is around 2600 RPM.
66
67Voltage sensors (also known as IN sensors) report their values in volts. An
68alarm is triggered if the voltage has crossed a programmable minimum or
69maximum limit. Note that minimum in this case always means 'closest to
70zero'; this is important for negative voltage measurements. All voltage
71inputs can measure voltages between 0 and 4.08 volts, with a resolution of
720.016 volt. The battery voltage in8 does not have limit registers.
73
74The VID lines (IT8712F only) encode the core voltage value: the voltage
75level your processor should work with. This is hardcoded by the mainboard
76and/or processor itself. It is a value in volts.
77
78If an alarm triggers, it will remain triggered until the hardware register
79is read at least once. This means that the cause for the alarm may already
80have disappeared! Note that in the current implementation, all hardware
81registers are read whenever any data is read (unless it is less than 1.5
82seconds since the last update). This means that you can easily miss
83once-only alarms.
84
85The IT87xx only updates its values each 1.5 seconds; reading it more often
86will do no harm, but will return 'old' values.
87
88To change sensor N to a thermistor, 'echo 2 > tempN_type' where N is 1, 2,
89or 3. To change sensor N to a thermal diode, 'echo 3 > tempN_type'.
90Give 0 for unused sensor. Any other value is invalid. To configure this at
91startup, consult lm_sensors's /etc/sensors.conf. (2 = thermistor;
923 = thermal diode)
93
94The fan speed control features are limited to manual PWM mode. Automatic
95"Smart Guardian" mode control handling is not implemented. However
96if 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 @@
1Kernel driver lm63
2==================
3
4Supported 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
11Author: Jean Delvare <khali@linux-fr.org>
12
13Thanks go to Tyan and especially Alex Buckingham for setting up a remote
14access to their S4882 test platform for this driver.
15 http://www.tyan.com/
16
17Description
18-----------
19
20The LM63 is a digital temperature sensor with integrated fan monitoring
21and control.
22
23The LM63 is basically an LM86 with fan speed monitoring and control
24capabilities 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
30The datasheet isn't very clear about what the tachometer reading is.
31
32An explanation from National Semiconductor: The two lower bits of the read
33value have to be masked out. The value is still 16 bit in width.
34
35All temperature values are given in degrees Celsius. Resolution is 1.0
36degree for the local temperature, 0.125 degree for the remote temperature.
37
38The fan speed is measured using a tachometer. Contrary to most chips which
39store the value in an 8-bit register and have a selectable clock divider
40to make sure that the result will fit in the register, the LM63 uses 16-bit
41value for measuring the speed of the fan. It can measure fan speeds down to
4283 RPM, at least in theory.
43
44Note that the pin used for fan monitoring is shared with an alert out
45function. Depending on how the board designer wanted to use the chip, fan
46speed monitoring will or will not be possible. The proper chip configuration
47is left to the BIOS, and the driver will blindly trust it.
48
49A PWM output can be used to control the speed of the fan. The LM63 has two
50PWM 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
52supported either.
53
54The lm63 driver will not update its values more frequently than every
55second; reading them more often will do no harm, but will return 'old'
56values.
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 @@
1Kernel driver lm75
2==================
3
4Supported 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
31Author: Frodo Looijaard <frodol@dds.nl>
32
33Description
34-----------
35
36The LM75 implements one temperature sensor. Limits can be set through the
37Overtemperature Shutdown register and Hysteresis register. Each value can be
38set and read to half-degree accuracy.
39An alarm is issued (usually to a connected LM78) when the temperature
40gets higher then the Overtemperature Shutdown value; it stays on until
41the temperature falls below the Hysteresis value.
42All temperatures are in degrees Celsius, and are guaranteed within a
43range of -55 to +125 degrees.
44
45The LM75 only updates its values each 1.5 seconds; reading it more often
46will do no harm, but will return 'old' values.
47
48The LM75 is usually used in combination with LM78-like chips, to measure
49the temperature of the processor(s).
50
51The DS75, DS1775, MAX6625, and MAX6626 are supported as well.
52They are not distinguished from an LM75. While most of these chips
53have three additional bits of accuracy (12 vs. 9 for the LM75),
54the additional bits are not supported. Not only that, but these chips will
55not be detected if not in 9-bit precision mode (use the force parameter if
56needed).
57
58The TCN75 is supported as well, and is not distinguished from an LM75.
59
60The LM75 is essentially an industry standard; there may be other
61LM75 clones not listed here, with or without various enhancements,
62that are supported.
63
64The LM77 is not supported, contrary to what we pretended for a long time.
65Both 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 @@
1Kernel driver lm77
2==================
3
4Supported 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
11Author: Andras BALI <drewie@freemail.hu>
12
13Description
14-----------
15
16The LM77 implements one temperature sensor. The temperature
17sensor incorporates a band-gap type temperature sensor,
1810-bit ADC, and a digital comparator with user-programmable upper
19and lower limit values.
20
21Limits can be set through the Overtemperature Shutdown register and
22Hysteresis 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 @@
1Kernel driver lm78
2==================
3
4Supported 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
21Author: Frodo Looijaard <frodol@dds.nl>
22
23Description
24-----------
25
26This driver implements support for the National Semiconductor LM78, LM78-J
27and LM79. They are described as 'Microprocessor System Hardware Monitors'.
28
29There is almost no difference between the three supported chips. Functionally,
30the LM78 and LM78-J are exactly identical. The LM79 has one more VID line,
31which is used to report the lower voltages newer Pentium processors use.
32From here on, LM7* means either of these three types.
33
34The LM7* implements one temperature sensor, three fan rotation speed sensors,
35seven voltage sensors, VID lines, alarms, and some miscellaneous stuff.
36
37Temperatures are measured in degrees Celsius. An alarm is triggered once
38when the Overtemperature Shutdown limit is crossed; it is triggered again
39as soon as it drops below the Hysteresis value. A more useful behavior
40can be found by setting the Hysteresis value to +127 degrees Celsius; in
41this case, alarms are issued during all the time when the actual temperature
42is above the Overtemperature Shutdown value. Measurements are guaranteed
43between -55 and +125 degrees, with a resolution of 1 degree.
44
45Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
46triggered if the rotation speed has dropped below a programmable limit. Fan
47readings can be divided by a programmable divider (1, 2, 4 or 8) to give
48the readings more range or accuracy. Not all RPM values can accurately be
49represented, so some rounding is done. With a divider of 2, the lowest
50representable value is around 2600 RPM.
51
52Voltage sensors (also known as IN sensors) report their values in volts.
53An alarm is triggered if the voltage has crossed a programmable minimum
54or maximum limit. Note that minimum in this case always means 'closest to
55zero'; this is important for negative voltage measurements. All voltage
56inputs can measure voltages between 0 and 4.08 volts, with a resolution
57of 0.016 volt.
58
59The VID lines encode the core voltage value: the voltage level your processor
60should work with. This is hardcoded by the mainboard and/or processor itself.
61It is a value in volts. When it is unconnected, you will often find the
62value 3.50 V here.
63
64In addition to the alarms described above, there are a couple of additional
65ones. There is a BTI alarm, which gets triggered when an external chip has
66crossed its limits. Usually, this is connected to all LM75 chips; if at
67least one crosses its limits, this bit gets set. The CHAS alarm triggers
68if your computer case is open. The FIFO alarms should never trigger; it
69indicates an internal error. The SMI_IN alarm indicates some other chip
70has triggered an SMI interrupt. As we do not use SMI interrupts at all,
71this condition usually indicates there is a problem with some other
72device.
73
74If an alarm triggers, it will remain triggered until the hardware register
75is read at least once. This means that the cause for the alarm may
76already have disappeared! Note that in the current implementation, all
77hardware registers are read whenever any data is read (unless it is less
78than 1.5 seconds since the last update). This means that you can easily
79miss once-only alarms.
80
81The LM7* only updates its values each 1.5 seconds; reading it more often
82will 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 @@
1Kernel driver lm80
2==================
3
4Supported 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
11Authors:
12 Frodo Looijaard <frodol@dds.nl>,
13 Philip Edelbrock <phil@netroedge.com>
14
15Description
16-----------
17
18This driver implements support for the National Semiconductor LM80.
19It is described as a 'Serial Interface ACPI-Compatible Microprocessor
20System Hardware Monitor'.
21
22The LM80 implements one temperature sensor, two fan rotation speed sensors,
23seven voltage sensors, alarms, and some miscellaneous stuff.
24
25Temperatures are measured in degrees Celsius. There are two sets of limits
26which operate independently. When the HOT Temperature Limit is crossed,
27this will cause an alarm that will be reasserted until the temperature
28drops below the HOT Hysteresis. The Overtemperature Shutdown (OS) limits
29should work in the same way (but this must be checked; the datasheet
30is unclear about this). Measurements are guaranteed between -55 and
31+125 degrees. The current temperature measurement has a resolution of
320.0625 degrees; the limits have a resolution of 1 degree.
33
34Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
35triggered if the rotation speed has dropped below a programmable limit. Fan
36readings can be divided by a programmable divider (1, 2, 4 or 8) to give
37the readings more range or accuracy. Not all RPM values can accurately be
38represented, so some rounding is done. With a divider of 2, the lowest
39representable value is around 2600 RPM.
40
41Voltage sensors (also known as IN sensors) report their values in volts.
42An alarm is triggered if the voltage has crossed a programmable minimum
43or maximum limit. Note that minimum in this case always means 'closest to
44zero'; this is important for negative voltage measurements. All voltage
45inputs can measure voltages between 0 and 2.55 volts, with a resolution
46of 0.01 volt.
47
48If an alarm triggers, it will remain triggered until the hardware register
49is read at least once. This means that the cause for the alarm may
50already have disappeared! Note that in the current implementation, all
51hardware registers are read whenever any data is read (unless it is less
52than 2.0 seconds since the last update). This means that you can easily
53miss once-only alarms.
54
55The LM80 only updates its values each 1.5 seconds; reading it more often
56will 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 @@
1Kernel driver lm83
2==================
3
4Supported 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
12Author: Jean Delvare <khali@linux-fr.org>
13
14Description
15-----------
16
17The LM83 is a digital temperature sensor. It senses its own temperature as
18well as the temperature of up to three external diodes. It is compatible
19with many other devices such as the LM84 and all other ADM1021 clones.
20The main difference between the LM83 and the LM84 in that the later can
21only sense the temperature of one external diode.
22
23Using the adm1021 driver for a LM83 should work, but only two temperatures
24will be reported instead of four.
25
26The LM83 is only found on a handful of motherboards. Both a confirmed
27list and an unconfirmed list follow. If you can confirm or infirm the
28fact that any of these motherboards do actually have an LM83, please
29contact us. Note that the LM90 can easily be misdetected as a LM83.
30
31Confirmed motherboards:
32 SBS P014
33
34Unconfirmed motherboards:
35 Gigabyte GA-8IK1100
36 Iwill MPX2
37 Soltek SL-75DRV5
38
39The driver has been successfully tested by Magnus Forsström, who I'd
40like to thank here. More testers will be of course welcome.
41
42The fact that the LM83 is only scarcely used can be easily explained.
43Most motherboards come with more than just temperature sensors for
44health monitoring. They also have voltage and fan rotation speed
45sensors. This means that temperature-only chips are usually used as
46secondary chips coupled with another chip such as an IT8705F or similar
47chip, which provides more features. Since systems usually need three
48temperature sensors (motherboard, processor, power supply) and primary
49chips provide some temperature sensors, the secondary chip, if needed,
50won't have to handle more than two temperatures. Thus, ADM1021 clones
51are sufficient, and there is no need for a four temperatures sensor
52chip such as the LM83. The only case where using an LM83 would make
53sense is on SMP systems, such as the above-mentioned Iwill MPX2,
54because you want an additional temperature sensor for each additional
55CPU.
56
57On the SBS P014, this is different, since the LM83 is the only hardware
58monitoring chipset. One temperature sensor is used for the motherboard
59(actually measuring the LM83's own temperature), one is used for the
60CPU. The two other sensors must be used to measure the temperature of
61two other points of the motherboard. We suspect these points to be the
62north and south bridges, but this couldn't be confirmed.
63
64All temperature values are given in degrees Celsius. Local temperature
65is given within a range of 0 to +85 degrees. Remote temperatures are
66given within a range of 0 to +125 degrees. Resolution is 1.0 degree,
67accuracy is guaranteed to 3.0 degrees (see the datasheet for more
68details).
69
70Each sensor has its own high limit, but the critical limit is common to
71all four sensors. There is no hysteresis mechanism as found on most
72recent temperature sensors.
73
74The lm83 driver will not update its values more frequently than every
75other 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 @@
1Kernel driver lm85
2==================
3
4Supported 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
26Authors:
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
33Description
34-----------
35
36This driver implements support for the National Semiconductor LM85 and
37compatible chips including the Analog Devices ADM1027, ADT7463 and
38SMSC EMC6D10x chips family.
39
40The LM85 uses the 2-wire interface compatible with the SMBUS 2.0
41specification. Using an analog to digital converter it measures three (3)
42temperatures and five (5) voltages. It has four (4) 16-bit counters for
43measuring fan speed. Five (5) digital inputs are provided for sampling the
44VID signals from the processor to the VRM. Lastly, there are three (3) PWM
45outputs that can be used to control fan speed.
46
47The voltage inputs have internal scaling resistors so that the following
48voltage can be measured without external resistors:
49
50 2.5V, 3.3V, 5V, 12V, and CPU core voltage (2.25V)
51
52The temperatures measured are one internal diode, and two remote diodes.
53Remote 1 is generally the CPU temperature. These inputs are designed to
54measure a thermal diode like the one in a Pentium 4 processor in a socket
55423 or socket 478 package. They can also measure temperature using a
56transistor like the 2N3904.
57
58A sophisticated control system for the PWM outputs is designed into the
59LM85 that allows fan speed to be adjusted automatically based on any of the
60three temperature sensors. Each PWM output is individually adjustable and
61programmable. Once configured, the LM85 will adjust the PWM outputs in
62response to the measured temperatures without further host intervention.
63This feature can also be disabled for manual control of the PWM's.
64
65Each of the measured inputs (voltage, temperature, fan speed) has
66corresponding high/low limit values. The LM85 will signal an ALARM if any
67measured value exceeds either limit.
68
69The LM85 samples all inputs continuously. The lm85 driver will not read
70the registers more often than once a second. Further, configuration data is
71only read once each 5 minutes. There is twice as much config data as
72measurements, so this would seem to be a worthwhile optimization.
73
74Special Features
75----------------
76
77The LM85 has four fan speed monitoring modes. The ADM1027 has only two.
78Both have special circuitry to compensate for PWM interactions with the
79TACH signal from the fans. The ADM1027 can be configured to measure the
80speed of a two wire fan, but the input conditioning circuitry is different
81for 3-wire and 2-wire mode. For this reason, the 2-wire fan modes are not
82exposed to user control. The BIOS should initialize them to the correct
83mode. If you've designed your own ADM1027, you'll have to modify the
84init_client function and add an insmod parameter to set this up.
85
86To smooth the response of fans to changes in temperature, the LM85 has an
87optional filter for smoothing temperatures. The ADM1027 has the same
88config option but uses it to rate limit the changes to fan speed instead.
89
90The ADM1027 and ADT7463 have a 10-bit ADC and can therefore measure
91temperatures with 0.25 degC resolution. They also provide an offset to the
92temperature readings that is automatically applied during measurement.
93This offset can be used to zero out any errors due to traces and placement.
94The documentation says that the offset is in 0.25 degC steps, but in
95initial testing of the ADM1027 it was 1.00 degC steps. Analog Devices has
96confirmed this "bug". The ADT7463 is reported to work as described in the
97documentation. The current lm85 driver does not show the offset register.
98
99The ADT7463 has a THERM asserted counter. This counter has a 22.76ms
100resolution and a range of 5.8 seconds. The driver implements a 32-bit
101accumulator of the counter value to extend the range to over a year. The
102counter will stay at it's max value until read.
103
104See the vendor datasheets for more information. There is application note
105from National (AN-1260) with some additional information about the LM85.
106The Analog Devices datasheet is very detailed and describes a procedure for
107determining an optimal configuration for the automatic PWM control.
108
109The SMSC EMC6D100 & EMC6D101 monitor external voltages, temperatures, and
110fan speeds. They use this monitoring capability to alert the system to out
111of limit conditions and can automatically control the speeds of multiple
112fans in a PC or embedded system. The EMC6D101, available in a 24-pin SSOP
113package, and the EMC6D100, available in a 28-pin SSOP package, are designed
114to be register compatible. The EMC6D100 offers all the features of the
115EMC6D101 plus additional voltage monitoring and system control features.
116Unfortunately it is not possible to distinguish between the package
117versions on register level so these additional voltage inputs may read
118zero. The EMC6D102 features addtional ADC bits thus extending precision
119of voltage and temperature channels.
120
121
122Hardware Configurations
123-----------------------
124
125The LM85 can be jumpered for 3 different SMBus addresses. There are
126no other hardware configuration options for the LM85.
127
128The lm85 driver detects both LM85B and LM85C revisions of the chip. See the
129datasheet for a complete description of the differences. Other than
130identifying the chip, the driver behaves no differently with regard to
131these two chips. The LM85B is recommended for new designs.
132
133The ADM1027 and ADT7463 chips have an optional SMBALERT output that can be
134used to signal the chipset in case a limit is exceeded or the temperature
135sensors fail. Individual sensor interrupts can be masked so they won't
136trigger SMBALERT. The SMBALERT output if configured replaces one of the other
137functions (PWM2 or IN0). This functionality is not implemented in current
138driver.
139
140The ADT7463 also has an optional THERM output/input which can be connected
141to the processor PROC_HOT output. If available, the autofan control
142dynamic Tmin feature can be enabled to keep the system temperature within
143spec (just?!) with the least possible fan noise.
144
145Configuration Notes
146-------------------
147
148Besides standard interfaces driver adds following:
149
150* Temperatures and Zones
151
152Each temperature sensor is associated with a Zone. There are three
153sensors and therefore three zones (# 1, 2 and 3). Each zone has the following
154temperature 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
163There are three PWM outputs. The LM85 datasheet suggests that the
164pwm3 output control both fan3 and fan4. Each PWM can be individually
165configured and assigned to a zone for it's control value. Each PWM can be
166configured 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
175The pwm#_auto_pwm_freq can be set to one of the following 8 values. Setting the
176frequency to a value not on this list, will result in the next higher frequency
177being selected. The actual device frequency may vary slightly from this
178specification as designed by the manufacturer. Consult the datasheet for more
179details. (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
185NOTE: It has been reported that there is a bug in the LM85 that causes the flag
186to be associated with the zones not the PWMs. This contradicts all the
187published documentation. Setting pwm#_min_ctl in this case actually affects all
188PWMs controlled by zone '#'.
189
190* PWM Controlling Zone selection
191
192* pwm#_auto_channels - controls zone that is associated with PWM
193
194Configuration 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
207The National LM85's have two vendor specific configuration
208features. Tach. mode and Spinup Control. For more details on these,
209see the LM85 datasheet or Application Note AN-1260.
210
211The Analog Devices ADM1027 has several vendor specific enhancements.
212The number of pulses-per-rev of the fans can be set, Tach monitoring
213can be optimized for PWM operation, and an offset can be applied to
214the temperatures to compensate for systemic errors in the
215measurements.
216
217In addition to the ADM1027 features, the ADT7463 also has Tmin control
218and THERM asserted counts. Automatic Tmin control acts to adjust the
219Tmin value to maintain the measured temperature sensor at a specified
220temperature. There isn't much documentation on this feature in the
221ADT7463 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 @@
1Kernel driver lm87
2==================
3
4Supported 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
10Authors:
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
19Description
20-----------
21
22This driver implements support for the National Semiconductor LM87.
23
24The LM87 implements up to three temperature sensors, up to two fan
25rotation speed sensors, up to seven voltage sensors, alarms, and some
26miscellaneous stuff.
27
28Temperatures are measured in degrees Celsius. Each input has a high
29and low alarm settings. A high limit produces an alarm when the value
30goes above it, and an alarm is also produced when the value goes below
31the low limit.
32
33Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
34triggered if the rotation speed has dropped below a programmable limit. Fan
35readings can be divided by a programmable divider (1, 2, 4 or 8) to give
36the readings more range or accuracy. Not all RPM values can accurately be
37represented, so some rounding is done. With a divider of 2, the lowest
38representable value is around 2600 RPM.
39
40Voltage sensors (also known as IN sensors) report their values in
41volts. An alarm is triggered if the voltage has crossed a programmable
42minimum or maximum limit. Note that minimum in this case always means
43'closest to zero'; this is important for negative voltage measurements.
44
45If an alarm triggers, it will remain triggered until the hardware register
46is read at least once. This means that the cause for the alarm may
47already have disappeared! Note that in the current implementation, all
48hardware registers are read whenever any data is read (unless it is less
49than 1.0 seconds since the last update). This means that you can easily
50miss once-only alarms.
51
52The lm87 driver only updates its values each 1.0 seconds; reading it more
53often will do no harm, but will return 'old' values.
54
55
56Hardware Configurations
57-----------------------
58
59The LM87 has four pins which can serve one of two possible functions,
60depending on the hardware configuration.
61
62Some functions share pins, so not all functions are available at the same
63time. Which are depends on the hardware setup. This driver assumes that
64the BIOS configured the chip correctly. In that respect, it differs from
65the original driver (from lm_sensors for Linux 2.4), which would force the
66LM87 to an arbitrary, compile-time chosen mode, regardless of the actual
67chipset wiring.
68
69For 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 @@
1Kernel driver lm90
2==================
3
4Supported 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
53Author: Jean Delvare <khali@linux-fr.org>
54
55
56Description
57-----------
58
59The LM90 is a digital temperature sensor. It senses its own temperature as
60well as the temperature of up to one external diode. It is compatible
61with many other devices such as the LM86, the LM89, the LM99, the ADM1032,
62the MAX6657, MAX6658 and the MAX6659 all of which are supported by this driver.
63Note that there is no easy way to differentiate between the last three
64variants. The extra address and features of the MAX6659 are not supported by
65this driver. Additionally, the ADT7461 is supported if found in ADM1032
66compatibility mode.
67
68The specificity of this family of chipsets over the ADM1021/LM84
69family is that it features critical limits with hysteresis, and an
70increased resolution of the remote temperature measurement.
71
72The different chipsets of the family are not strictly identical, although
73very similar. This driver doesn't handle any specific feature for now,
74but could if there ever was a need for it. For reference, here comes a
75non-exhaustive list of specific features:
76
77LM90:
78 * Filter and alert configuration register at 0xBF.
79 * ALERT is triggered by temperatures over critical limits.
80
81LM86 and LM89:
82 * Same as LM90
83 * Better external channel accuracy
84
85LM99:
86 * Same as LM89
87 * External temperature shifted by 16 degrees down
88
89ADM1032:
90 * Consecutive alert register at 0x22.
91 * Conversion averaging.
92 * Up to 64 conversions/s.
93 * ALERT is triggered by open remote sensor.
94
95ADT7461
96 * Extended temperature range (breaks compatibility)
97 * Lower resolution for remote temperature
98
99MAX6657 and MAX6658:
100 * Remote sensor type selection
101
102MAX6659
103 * Selectable address
104 * Second critical temperature limit
105 * Remote sensor type selection
106
107All temperature values are given in degrees Celsius. Resolution
108is 1.0 degree for the local temperature, 0.125 degree for the remote
109temperature.
110
111Each sensor has its own high and low limits, plus a critical limit.
112Additionally, there is a relative hysteresis value common to both critical
113values. To make life easier to user-space applications, two absolute values
114are exported, one for each channel, but these values are of course linked.
115Only the local hysteresis can be set from user-space, and the same delta
116applies to the remote hysteresis.
117
118The lm90 driver will not update its values more frequently than every
119other 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 @@
1Kernel driver lm92
2==================
3
4Supported 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
20Authors:
21 Abraham van der Merwe <abraham@2d3d.co.za>
22 Jean Delvare <khali@linux-fr.org>
23
24
25Description
26-----------
27
28This driver implements support for the National Semiconductor LM92
29temperature sensor.
30
31Each LM92 temperature sensor supports a single temperature sensor. There are
32alarms for high, low, and critical thresholds. There's also an hysteresis to
33control the thresholds for resetting alarms.
34
35Support was added later for the LM76 and Maxim MAX6633/MAX6634/MAX6635,
36which are mostly compatible. They have not all been tested, so you
37may 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 @@
1Kernel driver max1619
2=====================
3
4Supported 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
11Authors:
12 Alexey Fisher <fishor@mail.ru>,
13 Jean Delvare <khali@linux-fr.org>
14
15Description
16-----------
17
18The MAX1619 is a digital temperature sensor. It senses its own temperature as
19well as the temperature of up to one external diode.
20
21All temperature values are given in degrees Celsius. Resolution
22is 1.0 degree for the local temperature and for the remote temperature.
23
24Only the external sensor has high and low limits.
25
26The max1619 driver will not update its values more frequently than every
27other 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 @@
1Kernel driver max6875
2=====================
3
4Supported 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
11Author: Ben Gardner <bgardner@wabtec.com>
12
13
14Module 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
23Description
24-----------
25
26The MAXIM max6875 is a EEPROM-programmable power-supply sequencer/supervisor.
27It provides timed outputs that can be used as a watchdog, if properly wired.
28It also provides 512 bytes of user EEPROM.
29
30At reset, the max6875 reads the configuration eeprom into its configuration
31registers. The chip then begins to operate according to the values in the
32registers.
33
34See the datasheet for details on how to program the EEPROM.
35
36
37Sysfs entries
38-------------
39
40eeprom_user - 512 bytes of user-defined EEPROM space. Only writable if
41 allow_write was set and register 0x43 is 0.
42
43eeprom_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
46reg_config - 70 bytes of register space. Any changes take affect immediately.
47
48
49General Remarks
50---------------
51
52A typical application will require that the EEPROMs be programmed once and
53never 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 @@
1Kernel driver pc87360
2=====================
3
4Supported 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
15Authors: Jean Delvare <khali@linux-fr.org>
16
17Thanks to Sandeep Mehta, Tonko de Rooy and Daniel Ceregatti for testing.
18Thanks to Rudolf Marek for helping me investigate conversion issues.
19
20
21Module 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
31Note that this parameter has no effect for the PC87360, PC87363 and PC87364
32chips.
33
34Also note that for the PC87366, initialization levels 2 and 3 don't enable
35all temperature channels, because some of them share pins with each other,
36so they can't be used at the same time.
37
38
39Description
40-----------
41
42The National Semiconductor PC87360 Super I/O chip contains monitoring and
43PWM control circuitry for two fans. The PC87363 chip is similar, and the
44PC87364 chip has monitoring and PWM control for a third fan.
45
46The National Semiconductor PC87365 and PC87366 Super I/O chips are complete
47hardware monitoring chipsets, not only controlling and monitoring three fans,
48but 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
59The driver assumes that no more than one chip is present, and one of the
60standard Super I/O addresses is used (0x2E/0x2F or 0x4E/0x4F)
61
62Fan Monitoring
63--------------
64
65Fan rotation speeds are reported in RPM (revolutions per minute). An alarm
66is triggered if the rotation speed has dropped below a programmable limit.
67A different alarm is triggered if the fan speed is too low to be measured.
68
69Fan readings are affected by a programmable clock divider, giving the
70readings more range or accuracy. Usually, users have to learn how it works,
71but this driver implements dynamic clock divider selection, so you don't
72have to care no more.
73
74For 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
84For 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)
88The clock speed for the PC87360 family is 480 kHz. I arbitrarily chose 100
89RPM as the lowest acceptable accuracy.
90
91As mentioned above, you don't have to care about this no more.
92
93Note that not all RPM values can be represented, even when the best clock
94divider is selected. This is not only true for the measured speeds, but
95also for the programmable low limits, so don't be surprised if you try to
96set, say, fan1_min to 2900 and it finally reads 2909.
97
98
99Fan Control
100-----------
101
102PWM (pulse width modulation) values range from 0 to 255, with 0 meaning
103that the fan is stopped, and 255 meaning that the fan goes at full speed.
104
105Be extremely careful when changing PWM values. Low PWM values, even
106non-zero, can stop the fan, which may cause irreversible damage to your
107hardware if temperature increases too much. When changing PWM values, go
108step by step and keep an eye on temperatures.
109
110One user reported problems with PWM. Changing PWM values would break fan
111speed readings. No explanation nor fix could be found.
112
113
114Temperature Monitoring
115----------------------
116
117Temperatures are reported in degrees Celsius. Each temperature measured has
118associated low, high and overtemperature limits, each of which triggers an
119alarm when crossed.
120
121The first two temperature channels are external. The third one (PC87366
122only) is internal.
123
124The PC87366 has three additional temperature channels, based on
125thermistors (as opposed to thermal diodes for the first three temperature
126channels). For technical reasons, these channels are held by the VLM
127(voltage level monitor) logical device, not the TMS (temperature
128measurement) one. As a consequence, these temperatures are exported as
129voltages, and converted into temperatures in user-space.
130
131Note that these three additional channels share their pins with the
132external thermal diode channels, so you (physically) can't use them all at
133the same time. Although it should be possible to mix the two sensor types,
134the documents from National Semiconductor suggest that motherboard
135manufacturers should choose one type and stick to it. So you will more
136likely have either channels 1 to 3 (thermal diodes) or 3 to 6 (internal
137thermal diode, and thermistors).
138
139
140Voltage Monitoring
141------------------
142
143Voltages are reported relatively to a reference voltage, either internal or
144external. Some of them (in7:Vsb, in8:Vdd and in10:AVdd) are divided by two
145internally, you will have to compensate in sensors.conf. Others (in0 to in6)
146are likely to be divided externally. The meaning of each of these inputs as
147well as the values of the resistors used for division is left to the
148motherboard manufacturers, so you will have to document yourself and edit
149sensors.conf accordingly. National Semiconductor has a document with
150recommended resistor values for some voltages, but this still leaves much
151room for per motherboard specificities, unfortunately. Even worse,
152motherboard manufacturers don't seem to care about National Semiconductor's
153recommendations.
154
155Each voltage measured has associated low and high limits, each of which
156triggers an alarm when crossed.
157
158When available, VID inputs are used to provide the nominal CPU Core voltage.
159The driver will default to VRM 9.0, but this can be changed from user-space.
160The chipsets can handle two sets of VID inputs (on dual-CPU systems), but
161the driver will only export one for now. This may change later if there is
162a need.
163
164
165General Remarks
166---------------
167
168If an alarm triggers, it will remain triggered until the hardware register
169is read at least once. This means that the cause for the alarm may already
170have disappeared! Note that all hardware registers are read whenever any
171data is read (unless it is less than 2 seconds since the last update, in
172which case cached values are returned instead). As a consequence, when
173a once-only alarm triggers, it may take 2 seconds for it to show, and 2
174more seconds for it to disappear.
175
176Monitoring of in9 isn't enabled at lower init levels (<3) because that
177channel measures the battery voltage (Vbat). It is a known fact that
178repeatedly sampling the battery voltage reduces its lifetime. National
179Semiconductor smartly designed their chipset so that in9 is sampled only
180once every 1024 sampling cycles (that is every 34 minutes at the default
181sampling rate), so the effect is attenuated, but still present.
182
183
184Limitations
185-----------
186
187The datasheets suggests that some values (fan mins, fan dividers)
188shouldn't be changed once the monitoring has started, but we ignore that
189recommendation. 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 @@
1Kernel driver pca9539
2=====================
3
4Supported 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
11Author: Ben Gardner <bgardner@wabtec.com>
12
13
14Description
15-----------
16
17The Philips PCA9539 is a 16 bit low power I/O device.
18All 16 lines can be individually configured as an input or output.
19The input sense can also be inverted.
20The 16 lines are split between two bytes.
21
22
23Sysfs entries
24-------------
25
26Each is a byte that maps to the 8 I/O bits.
27A '0' suffix is for bits 0-7, while '1' is for bits 8-15.
28
29input[01] - read the current value
30output[01] - sets the output value
31direction[01] - direction of each bit: 1=input, 0=output
32invert[01] - toggle the input bit sense
33
34input reads the actual state of the line and is always available.
35The direction defaults to input for all channels.
36
37
38General Remarks
39---------------
40
41Note that each output, direction, and invert entry controls 8 lines.
42You should use the read, modify, write sequence.
43For 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 @@
1Kernel driver pcf8574
2=====================
3
4Supported 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
17Authors:
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
25Description
26-----------
27The PCF8574(A) is an 8-bit I/O expander for the I2C bus produced by Philips
28Semiconductors. It is designed to provide a byte I2C interface to up to 16
29separate devices (8 x PCF8574 and 8 x PCF8574A).
30
31This device consists of a quasi-bidirectional port. Each of the eight I/Os
32can be independently used as an input or output. To setup an I/O as an
33input, you have to write a 1 to the corresponding output.
34
35For more informations see the datasheet.
36
37
38Accessing PCF8574(A) via /sys interface
39-------------------------------------
40
41! Be careful !
42The PCF8574(A) is plainly impossible to detect ! Stupid chip.
43So every chip with address in the interval [20..27] and [38..3f] are
44detected as PCF8574(A). If you have other chips in this address
45range, the workaround is to load this module after the one
46for your others chips.
47
48On detection (i.e. insmod, modprobe et al.), directories are being
49created for each detected PCF8574(A):
50
51/sys/bus/i2c/devices/<0>-<1>/
52where <0> is the bus the chip was detected on (e. g. i2c-0)
53and <1> the chip address ([20..27] or [38..3f]):
54
55(example: /sys/bus/i2c/devices/1-0020/)
56
57Inside these directories, there are two files each:
58read and write (and one file with chip name).
59
60The read file is read-only. Reading gives you the current I/O input
61if the corresponding output is set as 1, otherwise the current output
62value, that is to say 0.
63
64The write file is read/write. Writing a value outputs it on the I/O
65port. Reading returns the last written value.
66
67On module initialization the chip is configured as eight inputs (all
68outputs to 1), so you can connect any circuit to the PCF8574(A) without
69being 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 @@
1Kernel driver pcf8591
2=====================
3
4Supported 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
11Authors:
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
17Description
18-----------
19The PCF8591 is an 8-bit A/D and D/A converter (4 analog inputs and one
20analog output) for the I2C bus produced by Philips Semiconductors. It
21is designed to provide a byte I2C interface to up to 4 separate devices.
22
23The PCF8591 has 4 analog inputs programmable as single-ended or
24differential 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
43See the datasheet for details.
44
45Module 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
57Accessing PCF8591 via /sys interface
58-------------------------------------
59
60! Be careful !
61The PCF8591 is plainly impossible to detect ! Stupid chip.
62So every chip with address in the interval [48..4f] is
63detected as PCF8591. If you have other chips in this address
64range, the workaround is to load this module after the one
65for your others chips.
66
67On detection (i.e. insmod, modprobe et al.), directories are being
68created for each detected PCF8591:
69
70/sys/bus/devices/<0>-<1>/
71where <0> is the bus the chip was detected on (e. g. i2c-0)
72and <1> the chip address ([48..4f])
73
74Inside these directories, there are such files:
75in0, in1, in2, in3, out0_enable, out0_output, name
76
77Name contains chip name.
78
79The in0, in1, in2 and in3 files are RO. Reading gives the value of the
80corresponding channel. Depending on the current analog inputs configuration,
81files in2 and/or in3 do not exist. Values range are from 0 to 255 for single
82ended inputs and -128 to +127 for differential inputs (8-bit ADC).
83
84The 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
87The out0_output file is RW. Writing a number between 0 and 255 (8-bit DAC), send
88the value to the digital-to-analog converter. Note that a voltage will
89only appears on AOUT pin if aout0_enable equals 1. Reading returns the last
90value 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 @@
1Kernel driver sis5595
2=====================
3
4Supported 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
10Authors:
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
40Module Parameters
41-----------------
42force_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
50Description
51-----------
52
53The SiS5595 southbridge has integrated hardware monitor functions. It also
54has an I2C bus, but this driver only supports the hardware monitor. For the
55I2C bus driver see i2c-sis5595.
56
57The SiS5595 implements zero or one temperature sensor, two fan speed
58sensors, four or five voltage sensors, and alarms.
59
60On the first version of the chip, there are four voltage sensors and one
61temperature sensor.
62
63On the second version of the chip, the temperature sensor (temp) and the
64fifth voltage sensor (in4) share a pin which is configurable, but not
65through the driver. Sorry. The driver senses the configuration of the pin,
66which was hopefully set by the BIOS.
67
68Temperatures are measured in degrees Celsius. An alarm is triggered once
69when the max is crossed; it is also triggered when it drops below the min
70value. Measurements are guaranteed between -55 and +125 degrees, with a
71resolution of 1 degree.
72
73Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
74triggered if the rotation speed has dropped below a programmable limit. Fan
75readings can be divided by a programmable divider (1, 2, 4 or 8) to give
76the readings more range or accuracy. Not all RPM values can accurately be
77represented, so some rounding is done. With a divider of 2, the lowest
78representable value is around 2600 RPM.
79
80Voltage sensors (also known as IN sensors) report their values in volts. An
81alarm is triggered if the voltage has crossed a programmable minimum or
82maximum limit. Note that minimum in this case always means 'closest to
83zero'; this is important for negative voltage measurements. All voltage
84inputs can measure voltages between 0 and 4.08 volts, with a resolution of
850.016 volt.
86
87In addition to the alarms described above, there is a BTI alarm, which gets
88triggered when an external chip has crossed its limits. Usually, this is
89connected to some LM75-like chip; if at least one crosses its limits, this
90bit gets set.
91
92If an alarm triggers, it will remain triggered until the hardware register
93is read at least once. This means that the cause for the alarm may already
94have disappeared! Note that in the current implementation, all hardware
95registers are read whenever any data is read (unless it is less than 1.5
96seconds since the last update). This means that you can easily miss
97once-only alarms.
98
99The SiS5595 only updates its values each 1.5 seconds; reading it more often
100will do no harm, but will return 'old' values.
101
102Problems
103--------
104Some chips refuse to be enabled. We don't know why.
105The 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 @@
1Kernel driver smsc47b397
2========================
3
4Supported 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
10Authors: Mark M. Hoffman <mhoffman@lightlink.com>
11 Utilitek Systems, Inc.
12
1November 23, 2004 13November 23, 2004
2 14
3The following specification describes the SMSC LPC47B397-NC sensor chip 15The 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
5provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected 17provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected
6by Mark M. Hoffman <mhoffman@lightlink.com>. 18by Mark M. Hoffman <mhoffman@lightlink.com>.
7 19
@@ -10,10 +22,10 @@ by Mark M. Hoffman <mhoffman@lightlink.com>.
10Methods for detecting the HP SIO and reading the thermal data on a dc7100. 22Methods for detecting the HP SIO and reading the thermal data on a dc7100.
11 23
12The thermal information on the dc7100 is contained in the SIO Hardware Monitor 24The 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
14pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The 26pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The
15HWM Base address can be obtained from Logical Device 8, registers 0x60 (MSB) 27HWM Base address can be obtained from Logical Device 8, registers 0x60 (MSB)
16and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and 28and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and
170x480 and 0x481 for the index/data pair. 290x480 and 0x481 for the index/data pair.
18 30
19Reading temperature information. 31Reading temperature information.
@@ -50,7 +62,7 @@ Reading the tach LSB locks the tach MSB.
50The LSB Must be read first. 62The LSB Must be read first.
51 63
52How to convert the tach reading to RPM. 64How to convert the tach reading to RPM.
53The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB) 65The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB)
54The SIO counts the number of 90kHz (11.111us) pulses per revolution. 66The SIO counts the number of 90kHz (11.111us) pulses per revolution.
55RPM = 60/(TCount * 11.111us) 67RPM = 60/(TCount * 11.111us)
56 68
@@ -72,20 +84,20 @@ To program the configuration registers, the following sequence must be followed:
72 84
73Enter Configuration Mode 85Enter Configuration Mode
74To place the chip into the Configuration State The config key (0x55) is written 86To place the chip into the Configuration State The config key (0x55) is written
75to the CONFIG PORT (0x2E). 87to the CONFIG PORT (0x2E).
76 88
77Configuration Mode 89Configuration Mode
78In configuration mode, the INDEX PORT is located at the CONFIG PORT address and 90In configuration mode, the INDEX PORT is located at the CONFIG PORT address and
79the DATA PORT is at INDEX PORT address + 1. 91the DATA PORT is at INDEX PORT address + 1.
80 92
81The desired configuration registers are accessed in two steps: 93The desired configuration registers are accessed in two steps:
82a. Write the index of the Logical Device Number Configuration Register 94a. 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
86b. Write the address of the desired configuration register within the 98b. 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
90Note: If accessing the Global Configuration Registers, step (a) is not required. 102Note: 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).
96Programming Example 108Programming Example
97The following is an example of how to read the SIO Device ID located at 0x20 109The 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
100MOV DX,02EH 112MOV DX,02EH
101MOV AX,055H 113MOV AX,055H
102OUT DX,AL 114OUT DX,AL
103; GLOBAL CONFIGURATION REGISTER 115; GLOBAL CONFIGURATION REGISTER
104MOV DX,02EH 116MOV DX,02EH
105MOV AL,20H 117MOV AL,20H
106OUT DX,AL 118OUT DX,AL
107; READ THE DATA 119; READ THE DATA
108MOV DX,02FH 120MOV DX,02FH
109IN AL,DX 121IN AL,DX
110; EXIT CONFIGURATION MODE 122; EXIT CONFIGURATION MODE
111MOV DX,02EH 123MOV DX,02EH
112MOV AX,0AAH 124MOV AX,0AAH
113OUT DX,AL 125OUT DX,AL
@@ -122,12 +134,12 @@ Obtaining the HWM Base Address.
122The following is an example of how to read the HWM Base Address located in 134The following is an example of how to read the HWM Base Address located in
123Logical Device 8. 135Logical Device 8.
124 136
125; ENTER CONFIGURATION MODE 137; ENTER CONFIGURATION MODE
126MOV DX,02EH 138MOV DX,02EH
127MOV AX,055H 139MOV AX,055H
128OUT DX,AL 140OUT DX,AL
129; CONFIGURE REGISTER CRE0, 141; CONFIGURE REGISTER CRE0,
130; LOGICAL DEVICE 8 142; LOGICAL DEVICE 8
131MOV DX,02EH 143MOV DX,02EH
132MOV AL,07H 144MOV AL,07H
133OUT DX,AL ;Point to LD# Config Reg 145OUT DX,AL ;Point to LD# Config Reg
@@ -135,12 +147,12 @@ MOV DX,02FH
135MOV AL, 08H 147MOV AL, 08H
136OUT DX,AL;Point to Logical Device 8 148OUT DX,AL;Point to Logical Device 8
137; 149;
138MOV DX,02EH 150MOV DX,02EH
139MOV AL,60H 151MOV AL,60H
140OUT DX,AL ; Point to HWM Base Addr MSB 152OUT DX,AL ; Point to HWM Base Addr MSB
141MOV DX,02FH 153MOV DX,02FH
142IN AL,DX ; Get MSB of HWM Base Addr 154IN AL,DX ; Get MSB of HWM Base Addr
143; EXIT CONFIGURATION MODE 155; EXIT CONFIGURATION MODE
144MOV DX,02EH 156MOV DX,02EH
145MOV AX,0AAH 157MOV AX,0AAH
146OUT DX,AL 158OUT 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 @@
1Kernel driver smsc47m1
2======================
3
4Supported 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
16Authors:
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
23Description
24-----------
25
26The Standard Microsystems Corporation (SMSC) 47M1xx Super I/O chips
27contain monitoring and PWM control circuitry for two fans.
28
29The 47M15x and 47M192 chips contain a full 'hardware monitoring block'
30in addition to the fan monitoring and control. The hardware monitoring
31block is not supported by the driver.
32
33Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
34triggered if the rotation speed has dropped below a programmable limit. Fan
35readings can be divided by a programmable divider (1, 2, 4 or 8) to give
36the readings more range or accuracy. Not all RPM values can accurately be
37represented, so some rounding is done. With a divider of 2, the lowest
38representable value is around 2600 RPM.
39
40PWM values are from 0 to 255.
41
42If an alarm triggers, it will remain triggered until the hardware register
43is read at least once. This means that the cause for the alarm may
44already have disappeared! Note that in the current implementation, all
45hardware registers are read whenever any data is read (unless it is less
46than 1.5 seconds since the last update). This means that you can easily
47miss once-only alarms.
48
49
50**********************
51The lm_sensors project gratefully acknowledges the support of
52Intel 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 @@
1Kernel driver via686a
2=====================
3
4Supported 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
10Authors:
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
18Module Parameters
19-----------------
20
21force_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
28Description
29-----------
30
31The driver does not distinguish between the chips and reports
32all as a 686A.
33
34The Via 686a southbridge has integrated hardware monitor functionality.
35It also has an I2C bus, but this driver only supports the hardware monitor.
36For the I2C bus driver, see <file:Documentation/i2c/busses/i2c-viapro>
37
38The Via 686a implements three temperature sensors, two fan rotation speed
39sensors, five voltage sensors and alarms.
40
41Temperatures are measured in degrees Celsius. An alarm is triggered once
42when the Overtemperature Shutdown limit is crossed; it is triggered again
43as soon as it drops below the hysteresis value.
44
45Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
46triggered if the rotation speed has dropped below a programmable limit. Fan
47readings can be divided by a programmable divider (1, 2, 4 or 8) to give
48the readings more range or accuracy. Not all RPM values can accurately be
49represented, so some rounding is done. With a divider of 2, the lowest
50representable value is around 2600 RPM.
51
52Voltage sensors (also known as IN sensors) report their values in volts.
53An alarm is triggered if the voltage has crossed a programmable minimum
54or maximum limit. Voltages are internally scalled, so each voltage channel
55has a different resolution and range.
56
57If an alarm triggers, it will remain triggered until the hardware register
58is read at least once. This means that the cause for the alarm may
59already have disappeared! Note that in the current implementation, all
60hardware registers are read whenever any data is read (unless it is less
61than 1.5 seconds since the last update). This means that you can easily
62miss once-only alarms.
63
64The driver only updates its values each 1.5 seconds; reading it more often
65will 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 @@
1Kernel driver w83627hf
2======================
3
4Supported 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
22Authors:
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
28Module 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
40Description
41-----------
42
43This driver implements support for ISA accesses *only* for
44the Winbond W83627HF, W83627THF, W83697HF and W83637HF Super I/O chips.
45We will refer to them collectively as Winbond chips.
46
47This driver supports ISA accesses, which should be more reliable
48than i2c accesses. Also, for Tyan boards which contain both a
49Super I/O chip and a second i2c-only Winbond chip (often a W83782D),
50using this driver will avoid i2c address conflicts and complex
51initialization that were required in the w83781d driver.
52
53If you really want i2c accesses for these Super I/O chips,
54use the w83781d driver. However this is not the preferred method
55now that this ISA driver has been developed.
56
57Technically, the w83627thf does not support a VID reading. However, it's
58possible or even likely that your mainboard maker has routed these signals
59to a specific set of general purpose IO pins (the Asus P4C800-E is one such
60board). The w83627thf driver now interprets these as VID. If the VID on
61your board doesn't work, first see doc/vid in the lm_sensors package. If
62that still doesn't help, email us at lm-sensors@lm-sensors.org.
63
64For further information on this driver see the w83781d driver
65documentation.
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 @@
1Kernel driver w83781d
2=====================
3
4Supported 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
26Authors:
27 Frodo Looijaard <frodol@dds.nl>,
28 Philip Edelbrock <phil@netroedge.com>,
29 Mark Studebaker <mdsxyz123@yahoo.com>
30
31Module 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
39force_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
45Description
46-----------
47
48This driver implements support for the Winbond W83781D, W83782D, W83783S,
49W83627HF chips, and the Asus AS99127F chips. We will refer to them
50collectively as W8378* chips.
51
52There is quite some difference between these chips, but they are similar
53enough that it was sensible to put them together in one driver.
54The W83627HF chip is assumed to be identical to the ISA W83782D.
55The Asus chips are similar to an I2C-only W83782D.
56
57Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
58as99127f 7 3 0 3 0x31 0x12c3 yes no
59as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no
60w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes
61w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC)
62w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes
63w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no
64
65Detection of these chips can sometimes be foiled because they can be in
66an internal state that allows no clean access. If you know the address
67of the chip, use a 'force' parameter; this will put them into a more
68well-behaved state first.
69
70The W8378* implements temperature sensors (three on the W83781D and W83782D,
71two 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
73lines, alarms with beep warnings, and some miscellaneous stuff.
74
75Temperatures are measured in degrees Celsius. There is always one main
76temperature sensor, and one (W83783S) or two (W83781D and W83782D) other
77sensors. An alarm is triggered for the main sensor once when the
78Overtemperature Shutdown limit is crossed; it is triggered again as soon as
79it drops below the Hysteresis value. A more useful behavior
80can be found by setting the Hysteresis value to +127 degrees Celsius; in
81this case, alarms are issued during all the time when the actual temperature
82is above the Overtemperature Shutdown value. The driver sets the
83hysteresis value for temp1 to 127 at initialization.
84
85For the other temperature sensor(s), an alarm is triggered when the
86temperature gets higher then the Overtemperature Shutdown value; it stays
87on until the temperature falls below the Hysteresis value. But on the
88W83781D, there is only one alarm that functions for both other sensors!
89Temperatures are guaranteed within a range of -55 to +125 degrees. The
90main temperature sensors has a resolution of 1 degree; the other sensor(s)
91of 0.5 degree.
92
93Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
94triggered if the rotation speed has dropped below a programmable limit. Fan
95readings can be divided by a programmable divider (1, 2, 4 or 8 for the
96W83781D; 1, 2, 4, 8, 16, 32, 64 or 128 for the others) to give
97the readings more range or accuracy. Not all RPM values can accurately
98be represented, so some rounding is done. With a divider of 2, the lowest
99representable value is around 2600 RPM.
100
101Voltage sensors (also known as IN sensors) report their values in volts.
102An alarm is triggered if the voltage has crossed a programmable minimum
103or maximum limit. Note that minimum in this case always means 'closest to
104zero'; this is important for negative voltage measurements. All voltage
105inputs can measure voltages between 0 and 4.08 volts, with a resolution
106of 0.016 volt.
107
108The VID lines encode the core voltage value: the voltage level your processor
109should work with. This is hardcoded by the mainboard and/or processor itself.
110It is a value in volts. When it is unconnected, you will often find the
111value 3.50 V here.
112
113The W83782D and W83783S temperature conversion machine understands about
114several kinds of temperature probes. You can program the so-called
115beta value in the sensor files. '1' is the PII/Celeron diode, '2' is the
116TN3904 transistor, and 3435 the default thermistor value. Other values
117are (not yet) supported.
118
119In addition to the alarms described above, there is a CHAS alarm on the
120chips which triggers if your computer case is open.
121
122When an alarm goes off, you can be warned by a beeping signal through
123your computer speaker. It is possible to enable all beeping globally,
124or only the beeping for some alarms.
125
126If an alarm triggers, it will remain triggered until the hardware register
127is read at least once. This means that the cause for the alarm may
128already have disappeared! Note that in the current implementation, all
129hardware registers are read whenever any data is read (unless it is less
130than 1.5 seconds since the last update). This means that you can easily
131miss once-only alarms.
132
133The chips only update values each 1.5 seconds; reading them more often
134will do no harm, but will return 'old' values.
135
136AS99127F PROBLEMS
137-----------------
138The as99127f support was developed without the benefit of a datasheet.
139In most cases it is treated as a w83781d (although revision 2 of the
140AS99127F looks more like a w83782d).
141This support will be BETA until a datasheet is released.
142One user has reported problems with fans stopping
143occasionally.
144
145Note that the individual beep bits are inverted from the other chips.
146The driver now takes care of this so that user-space applications
147don't have to know about it.
148
149Known 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
155These will not be fixed unless we get a datasheet.
156If you have problems, please lobby Asus to release a datasheet.
157Unfortunately several others have without success.
158Please do not send mail to us asking for better as99127f support.
159We have done the best we can without a datasheet.
160Please do not send mail to the author or the sensors group asking for
161a datasheet or ideas on how to convince Asus. We can't help.
162
163
164NOTES:
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
182Data 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
193Answers 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
202confidential. If you have another Beta value of thermistor, we can help
203to calculate the R-T table for you. But you should give us real R-T
204Table which can be gotten by thermistor vendor. Therefore we will calculate
205them and obtain 32-byte data, and you can fill the 32-byte data to the
206register 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
228Asus Clones
229-----------
230
231We have no datasheets for the Asus clones (AS99127F and ASB100 Bach).
232Here are some very useful information that were given to us by Alex Van
233Kaam about how to detect these chips, and how to read their values. He
234also gives advice for another Asus chipset, the Mozart-2 (which we
235don't support yet). Thanks Alex!
236I reworded some parts and added personal comments.
237
238# Detection:
239
240AS99127F 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
254Mozart-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
265ASB100:
266- sensor 1: register 0x27
267- sensor 2 & 3 are the 2 LM75's on the SMBus
268- sensor 4: register 0x17
269Remark: 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
273AS99127F (rev.1 and 2 alike):
274- sensor 1: register 0x27
275- sensor 2 & 3 are the 2 LM75's on the SMBus
276Remark: Register 0x5b is suspected to be temperature type selector. Bit 1
277 would control temp1, bit 3 temp2 and bit 5 temp3.
278
279Mozart-2:
280- sensor 1: register 0x27
281- sensor 2: register 0x13
282
283# Fan sensors:
284
285ASB100, AS99127F (rev.1 and 2 alike):
286- 3 fans, identical to the W83781D
287
288Mozart-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
295This is where there is a difference between AS99127F rev.1 and 2.
296Remark: The difference is similar to the difference between
297 W83781D and W83782D.
298
299ASB100:
300in0=r(0x20)*0.016
301in1=r(0x21)*0.016
302in2=r(0x22)*0.016
303in3=r(0x23)*0.016*1.68
304in4=r(0x24)*0.016*3.8
305in5=r(0x25)*(-0.016)*3.97
306in6=r(0x26)*(-0.016)*1.666
307
308AS99127F rev.1:
309in0=r(0x20)*0.016
310in1=r(0x21)*0.016
311in2=r(0x22)*0.016
312in3=r(0x23)*0.016*1.68
313in4=r(0x24)*0.016*3.8
314in5=r(0x25)*(-0.016)*3.97
315in6=r(0x26)*(-0.016)*1.503
316
317AS99127F rev.2:
318in0=r(0x20)*0.016
319in1=r(0x21)*0.016
320in2=r(0x22)*0.016
321in3=r(0x23)*0.016*1.68
322in4=r(0x24)*0.016*3.8
323in5=(r(0x25)*0.016-3.6)*5.14+3.6
324in6=(r(0x26)*0.016-3.6)*3.14+3.6
325
326Mozart-2:
327in0=r(0x20)*0.016
328in1=255
329in2=r(0x22)*0.016
330in3=r(0x23)*0.016*1.68
331in4=r(0x24)*0.016*4
332in5=255
333in6=255
334
335
336# PWM
337
338Additional info about PWM on the AS99127F (may apply to other Asus
339chips as well) by Jean Delvare as of 2004-04-09:
340
341AS99127F revision 2 seems to have two PWM registers at 0x59 and 0x5A,
342and a temperature sensor type selector at 0x5B (which basically means
343that they swapped registers 0x59 and 0x5B when you compare with Winbond
344chips).
345Revision 1 of the chip also has the temperature sensor type selector at
3460x5B, but PWM registers have no effect.
347
348We don't know exactly how the temperature sensor type selection works.
349Looks like bits 1-0 are for temp1, bits 3-2 for temp2 and bits 5-4 for
350temp3, although it is possible that only the most significant bit matters
351each time. So far, values other than 0 always broke the readings.
352
353PWM registers seem to be split in two parts: bit 7 is a mode selector,
354while the other bits seem to define a value or threshold.
355
356When bit 7 is clear, bits 6-0 seem to hold a threshold value. If the value
357is below a given limit, the fan runs at low speed. If the value is above
358the limit, the fan runs at full speed. We have no clue as to what the limit
359represents. Note that there seem to be some inertia in this mode, speed
360changes may need some time to trigger. Also, an hysteresis mechanism is
361suspected since walking through all the values increasingly and then
362decreasingly led to slightly different limits.
363
364When bit 7 is set, bits 3-0 seem to hold a threshold value, while bits 6-4
365would not be significant. If the value is below a given limit, the fan runs
366at full speed, while if it is above the limit it runs at low speed (so this
367is the contrary of the other mode, in a way). Here again, we don't know
368what the limit is supposed to represent.
369
370One remarkable thing is that the fans would only have two or three
371different speeds (transitional states left apart), not a whole range as
372you usually get with PWM.
373
374As a conclusion, you can write 0x00 or 0x8F to the PWM registers to make
375fans run at low speed, and 0x7F or 0x80 to make them run at full speed.
376
377Please contact us if you can figure out how it is supposed to work. As
378long as we don't know more, the w83781d driver doesn't handle PWM on
379AS99127F chips at all.
380
381Additional info about PWM on the AS99127F rev.1 by Hector Martin:
382
383I've been fiddling around with the (in)famous 0x59 register and
384found out the following values do work as a form of coarse pwm:
385
3860x80 - seems to turn fans off after some time(1-2 minutes)... might be
387some form of auto-fan-control based on temp? hmm (Qfan? this mobo is an
388old ASUS, it isn't marketed as Qfan. Maybe some beta pre-attemp at Qfan
389that was dropped at the BIOS)
3900x81 - off
3910x82 - slightly "on-ner" than off, but my fans do not get to move. I can
392hear the high-pitched PWM sound that motors give off at too-low-pwm.
3930x83 - now they do move. Estimate about 70% speed or so.
3940x84-0x8f - full on
395
396Changing 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
398change.
399
400My mobo is an ASUS A7V266-E. This behavior is similar to what I got
401with speedfan under Windows, where 0-15% would be off, 15-2x% (can't
402remember 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 @@
1Kernel driver w83l785ts
2=======================
3
4Supported 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
11Authors:
12 Jean Delvare <khali@linux-fr.org>
13
14Description
15-----------
16
17The W83L785TS-S is a digital temperature sensor. It senses the
18temperature of a single external diode. The high limit is
19theoretically defined as 85 or 100 degrees C through a combination
20of external resistors, so the user cannot change it. Values seen so
21far suggest that the two possible limits are actually 95 and 110
22degrees C. The datasheet is rather poor and obviously inaccurate
23on several points including this one.
24
25All temperature values are given in degrees Celsius. Resolution
26is 1.0 degree. See the datasheet for details.
27
28The w83l785ts driver will not update its values more frequently than
29every other second; reading them more often will do no harm, but will
30return 'old' values.
31
32Known Issues
33------------
34
35On some systems (Asus), the BIOS is known to interfere with the driver
36and 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
38there is no old value). It seems to work well enough so that you should
39not 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 @@
1Introduction
2------------
3
4Most mainboards have sensor chips to monitor system health (like temperatures,
5voltages, fans speed). They are often connected through an I2C bus, but some
6are also connected directly through the ISA bus.
7
8The kernel drivers make the data from the sensor chips available in the /sys
9virtual filesystem. Userspace tools are then used to display or set or the
10data in a more friendly manner.
11
12Lm-sensors
13----------
14
15Core set of utilites that will allow you to obtain health information,
16setup monitoring limits etc. You can get them on their homepage
17http://www.lm-sensors.nu/ or as a package from your Linux distribution.
18
19If from website:
20Get lmsensors from project web site. Please note, you need only userspace
21part, so compile with "make user_install" target.
22
23General hints to get things working:
24
250) get lm-sensors userspace utils
261) compile all drivers in I2C section as modules in your kernel
272) run sensors-detect script, it will tell you what modules you need to load.
283) load them and run "sensors" command, you should see some results.
294) fix sensors.conf, labels, limits, fan divisors
305) if any more problems consult FAQ, or documentation
31
32Other utilites
33--------------
34
35If you want some graphical indicators of system health look for applications
36like: gkrellm, ksensors, xsensors, wmtemp, wmsensors, wmgtemp, ksysguardd,
37hardware-monitor
38
39If 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
199Fortunately, as a module writer, you just have to define the `normal' 187Fortunately, as a module writer, you just have to define the `normal_i2c'
200and/or `normal_range' parameters. The complete declaration could look 188parameter. The complete declaration could look like this:
201like 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
211Note that you *have* to call the two defined variables `normal_i2c' and 197Note that you *have* to call the defined variable `normal_i2c',
212`normal_i2c_range', without any prefix! 198without any prefix!
213 199
214 200
215Probing classes (sensors) 201Probing 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
260Also used is a list of pointers to sensors_force_data structures: 224Also 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:
269So we have a generic insmod variabled `force', and chip-specific variables 233So we have a generic insmod variabled `force', and chip-specific variables
270`force_CHIPNAME'. 234`force_CHIPNAME'.
271 235
272Fortunately, as a module writer, you just have to define the `normal' 236Fortunately, as a module writer, you just have to define the `normal_i2c'
273and/or `normal_range' parameters, and define what chip names are used. 237and `normal_isa' parameters, and define what chip names are used.
274The complete declaration could look like this: 238The 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
194ADM1025 HARDWARE MONITOR DRIVER 194ADM1025 HARDWARE MONITOR DRIVER
195P: Jean Delvare 195P: Jean Delvare
196M: khali@linux-fr.org 196M: khali@linux-fr.org
197L: sensors@stimpy.netroedge.com 197L: lm-sensors@lm-sensors.org
198S: Maintained 198S: Maintained
199 199
200ADT746X FAN DRIVER 200ADT746X FAN DRIVER
@@ -242,7 +242,7 @@ S: Maintained
242ALI1563 I2C DRIVER 242ALI1563 I2C DRIVER
243P: Rudolf Marek 243P: Rudolf Marek
244M: r.marek@sh.cvut.cz 244M: r.marek@sh.cvut.cz
245L: sensors@stimpy.netroedge.com 245L: lm-sensors@lm-sensors.org
246S: Maintained 246S: Maintained
247 247
248ALPHA PORT 248ALPHA PORT
@@ -1002,7 +1002,7 @@ P: Greg Kroah-Hartman
1002M: greg@kroah.com 1002M: greg@kroah.com
1003P: Jean Delvare 1003P: Jean Delvare
1004M: khali@linux-fr.org 1004M: khali@linux-fr.org
1005L: sensors@stimpy.netroedge.com 1005L: lm-sensors@lm-sensors.org
1006W: http://www.lm-sensors.nu/ 1006W: http://www.lm-sensors.nu/
1007S: Maintained 1007S: Maintained
1008 1008
@@ -1430,13 +1430,13 @@ S: Supported
1430LM83 HARDWARE MONITOR DRIVER 1430LM83 HARDWARE MONITOR DRIVER
1431P: Jean Delvare 1431P: Jean Delvare
1432M: khali@linux-fr.org 1432M: khali@linux-fr.org
1433L: sensors@stimpy.netroedge.com 1433L: lm-sensors@lm-sensors.org
1434S: Maintained 1434S: Maintained
1435 1435
1436LM90 HARDWARE MONITOR DRIVER 1436LM90 HARDWARE MONITOR DRIVER
1437P: Jean Delvare 1437P: Jean Delvare
1438M: khali@linux-fr.org 1438M: khali@linux-fr.org
1439L: sensors@stimpy.netroedge.com 1439L: lm-sensors@lm-sensors.org
1440S: Maintained 1440S: Maintained
1441 1441
1442LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP Dynamic Disks) 1442LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP Dynamic Disks)
@@ -2075,7 +2075,7 @@ S: Maintained
2075SMSC47M1 HARDWARE MONITOR DRIVER 2075SMSC47M1 HARDWARE MONITOR DRIVER
2076P: Jean Delvare 2076P: Jean Delvare
2077M: khali@linux-fr.org 2077M: khali@linux-fr.org
2078L: sensors@stimpy.netroedge.com 2078L: lm-sensors@lm-sensors.org
2079S: Odd Fixes 2079S: Odd Fixes
2080 2080
2081SMB FILESYSTEM 2081SMB FILESYSTEM
@@ -2614,7 +2614,7 @@ S: Orphan
2614W1 DALLAS'S 1-WIRE BUS 2614W1 DALLAS'S 1-WIRE BUS
2615P: Evgeniy Polyakov 2615P: Evgeniy Polyakov
2616M: johnpol@2ka.mipt.ru 2616M: johnpol@2ka.mipt.ru
2617L: sensors@stimpy.netroedge.com 2617L: lm-sensors@lm-sensors.org
2618S: Maintained 2618S: Maintained
2619 2619
2620W83L51xD SD/MMC CARD INTERFACE DRIVER 2620W83L51xD SD/MMC CARD INTERFACE DRIVER
@@ -2627,7 +2627,7 @@ S: Maintained
2627W83L785TS HARDWARE MONITOR DRIVER 2627W83L785TS HARDWARE MONITOR DRIVER
2628P: Jean Delvare 2628P: Jean Delvare
2629M: khali@linux-fr.org 2629M: khali@linux-fr.org
2630L: sensors@stimpy.netroedge.com 2630L: lm-sensors@lm-sensors.org
2631S: Odd Fixes 2631S: Odd Fixes
2632 2632
2633WAN ROUTER & SANGOMA WANPIPE DRIVERS & API (X.25, FRAME RELAY, PPP, CISCO HDLC) 2633WAN 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)
189extern ulong ds1374_get_rtc_time(void);
190extern int ds1374_set_rtc_time(ulong);
191
192static int __init
193mpc834x_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}
206late_initcall(mpc834x_rtc_hookup);
207#endif
188static __inline__ void 208static __inline__ void
189mpc834x_sys_set_bat(void) 209mpc834x_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
27static struct i2c_client_address_data addr_data = { 27static 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 */
54static void pca_start(struct i2c_algo_pca_data *adap) 54static 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 */
69static void pca_repeated_start(struct i2c_algo_pca_data *adap) 69static 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 */
88static void pca_stop(struct i2c_algo_pca_data *adap) 88static 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
8config I2C_ALI1535 8config 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
32config I2C_ALI15X3 32config 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
42config I2C_AMD756 42config 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
67config I2C_AMD8111 67config 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
110config I2C_I801 110config 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
131config I2C_I810 131config 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
184config I2C_ISA 184config 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
250config I2C_NFORCE2 250config 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
306config I2C_PROSAVAGE 305config 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
389config I2C_SIS5595 388config 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
399config I2C_SIS630 398config 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
409config I2C_SIS96X 408config 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
450config I2C_VIAPRO 450config 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
468config I2C_VOODOO3 468config 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
28struct iic_regs { 27struct 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)
358static void __devexit mpc_i2c_remove(struct ocp_device *ocp) 359static 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. */
136static struct i2c_algo_bit_data parport_algo_data = { 135static 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
539static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, 540static 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
5menu "Hardware Sensors Chip support" 5menu "Hardware Sensors Chip support"
@@ -11,7 +11,7 @@ config I2C_SENSOR
11 11
12config SENSORS_ADM1021 12config 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
58config 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
54config SENSORS_ASB100 69config 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
80config 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
65config SENSORS_DS1621 93config 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
98config SENSORS_GL518SM 126config 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
120config SENSORS_IT87 148config 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
144config SENSORS_LM75 172config 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
315config SENSORS_VIA686A 342config 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
327config SENSORS_W83781D 354config 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
390config 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
363endmenu 404endmenu
364 405
365menu "Other I2C Chip support" 406menu "Other I2C Chip support"
366 depends on I2C 407 depends on I2C
367 408
368config SENSORS_DS1337 409config 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
420config 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
379config SENSORS_EEPROM 431config 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
454config 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
402config SENSORS_PCF8591 464config 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
499config 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
434config SENSORS_M41T00 513config 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
522config 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
443endmenu 534endmenu
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
11obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o 11obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o
12obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o 12obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
13obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o 13obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
14obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
15obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
14obj-$(CONFIG_SENSORS_DS1337) += ds1337.o 16obj-$(CONFIG_SENSORS_DS1337) += ds1337.o
17obj-$(CONFIG_SENSORS_DS1374) += ds1374.o
15obj-$(CONFIG_SENSORS_DS1621) += ds1621.o 18obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
16obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o 19obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o
17obj-$(CONFIG_SENSORS_FSCHER) += fscher.o 20obj-$(CONFIG_SENSORS_FSCHER) += fscher.o
@@ -30,8 +33,10 @@ obj-$(CONFIG_SENSORS_LM87) += lm87.o
30obj-$(CONFIG_SENSORS_LM90) += lm90.o 33obj-$(CONFIG_SENSORS_LM90) += lm90.o
31obj-$(CONFIG_SENSORS_LM92) += lm92.o 34obj-$(CONFIG_SENSORS_LM92) += lm92.o
32obj-$(CONFIG_SENSORS_MAX1619) += max1619.o 35obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
36obj-$(CONFIG_SENSORS_MAX6875) += max6875.o
33obj-$(CONFIG_SENSORS_M41T00) += m41t00.o 37obj-$(CONFIG_SENSORS_M41T00) += m41t00.o
34obj-$(CONFIG_SENSORS_PC87360) += pc87360.o 38obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
39obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
35obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o 40obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
36obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 41obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
37obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o 42obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
@@ -39,8 +44,11 @@ obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
39obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o 44obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
40obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o 45obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
41obj-$(CONFIG_SENSORS_VIA686A) += via686a.o 46obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
47obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o
42obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o 48obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o
49
43obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 50obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
51obj-$(CONFIG_TPS65010) += tps65010.o
44 52
45ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) 53ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
46EXTRA_CFLAGS += -DDEBUG 54EXTRA_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}
158show2(alarms); 155show2(alarms);
159show2(die_code);
160 156
161#define set(value, reg) \ 157#define set(value, reg) \
162static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ 158static 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
183static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst); 179static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst);
184static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL); 180static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL);
185static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 181static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
186static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL);
187 182
188 183
189static int adm1021_attach_adapter(struct i2c_adapter *adapter) 184static 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 */
290static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); 290static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL);
291static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
291 292
292static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) 293static 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 */
37static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 36static 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 */
1229static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); 1228static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL);
1229static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
1230 1230
1231static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) 1231static 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 */
446static int trust_fan_readings(struct adm1031_data *data, int chan) 446static 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 */
52static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
53 I2C_CLIENT_END };
54
55static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
56
57/* Insmod parameters */
58SENSORS_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 */
83static 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 */
92static const u16 nom_mv[] = { 2500, 2700, 3300, 5000, 12000, 2700 };
93
94static inline unsigned int IN_FROM_REG(u8 reg, int n)
95{
96 return SCALE(reg, nom_mv[n], 192);
97}
98
99static 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 */
105static 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 */
111static 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 */
123static inline u8 AOUT_TO_REG(unsigned long val)
124{
125 return SENSORS_LIMIT(SCALE(val, 255, 1250), 0, 255);
126}
127
128static inline unsigned int AOUT_FROM_REG(u8 reg)
129{
130 return SCALE(reg, 1250, 255);
131}
132
133static int adm9240_attach_adapter(struct i2c_adapter *adapter);
134static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind);
135static void adm9240_init_client(struct i2c_client *client);
136static int adm9240_detach_client(struct i2c_client *client);
137static struct adm9240_data *adm9240_update_device(struct device *dev);
138
139/* driver data */
140static 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 */
150struct 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 */
174static int adm9240_read_value(struct i2c_client *client, u8 reg)
175{
176 return i2c_smbus_read_byte_data(client, reg);
177}
178
179static 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) \
188static 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}
195show_temp(temp_high, 1000);
196show_temp(temp_hyst, 1000);
197show_temp(temp, 500); /* 0.5'C per bit */
198
199#define set_temp(value, reg) \
200static 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
215set_temp(temp_high, ADM9240_REG_TEMP_HIGH);
216set_temp(temp_hyst, ADM9240_REG_TEMP_HYST);
217
218static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
219 show_temp_high, set_temp_high);
220static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,
221 show_temp_hyst, set_temp_hyst);
222static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
223
224/* voltage */
225static 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
231static 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
237static 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
243static 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
257static 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) \
272static 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} \
278static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \
279static 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} \
285static 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} \
291static ssize_t \
292set_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} \
298static ssize_t \
299set_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} \
305static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
306 show_in##offset##_min, set_in##offset##_min); \
307static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
308 show_in##offset##_max, set_in##offset##_max);
309
310show_in_offset(0);
311show_in_offset(1);
312show_in_offset(2);
313show_in_offset(3);
314show_in_offset(4);
315show_in_offset(5);
316
317/* fans */
318static 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
325static 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
332static 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 */
339static 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 */
364static 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) \
417static ssize_t show_fan_##offset (struct device *dev, \
418 struct device_attribute *attr, \
419 char *buf) \
420{ \
421return show_fan(dev, buf, offset - 1); \
422} \
423static ssize_t show_fan_##offset##_div (struct device *dev, \
424 struct device_attribute *attr, \
425 char *buf) \
426{ \
427return show_fan_div(dev, buf, offset - 1); \
428} \
429static ssize_t show_fan_##offset##_min (struct device *dev, \
430 struct device_attribute *attr, \
431 char *buf) \
432{ \
433return show_fan_min(dev, buf, offset - 1); \
434} \
435static ssize_t set_fan_##offset##_min (struct device *dev, \
436 struct device_attribute *attr, \
437 const char *buf, size_t count) \
438{ \
439return set_fan_min(dev, buf, count, offset - 1); \
440} \
441static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
442 show_fan_##offset, NULL); \
443static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
444 show_fan_##offset##_div, NULL); \
445static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
446 show_fan_##offset##_min, set_fan_##offset##_min);
447
448show_fan_offset(1);
449show_fan_offset(2);
450
451/* alarms */
452static 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}
457static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
458
459/* vid */
460static 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}
465static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
466
467/* analog output */
468static 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
474static 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}
486static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
487
488/* chassis_clear */
489static 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}
500static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear);
501
502
503/*** sensor chip detect and driver install ***/
504
505static 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;
618exit_free:
619 kfree(new_client);
620exit:
621 return err;
622}
623
624static 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
631static 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
645static 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
684static 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
774static int __init sensors_adm9240_init(void)
775{
776 return i2c_add_driver(&adm9240_driver);
777}
778
779static void __exit sensors_adm9240_exit(void)
780{
781 i2c_del_driver(&adm9240_driver);
782}
783
784MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, "
785 "Grant Coady <gcoady@gmail.com> and others");
786MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver");
787MODULE_LICENSE("GPL");
788
789module_init(sensors_adm9240_init);
790module_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);
556static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 555static 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
562static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 561static 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
28MODULE_LICENSE("GPL");
29MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
30MODULE_VERSION("0.6.2");
31MODULE_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
41static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END };
42static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
43
44SENSORS_INSMOD_1(atxp1);
45
46static int atxp1_attach_adapter(struct i2c_adapter * adapter);
47static int atxp1_detach_client(struct i2c_client * client);
48static struct atxp1_data * atxp1_update_device(struct device *dev);
49static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind);
50
51static 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
59struct 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
73static 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 */
102static 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
114static 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*/
169static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore);
170
171/* sys file functions for GPIO1 */
172static 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
184static 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*/
211static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1);
212
213/* sys file functions for GPIO2 */
214static 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
226static 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*/
251static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2);
252
253
254static int atxp1_attach_adapter(struct i2c_adapter *adapter)
255{
256 return i2c_detect(adapter, &addr_data, &atxp1_detect);
257};
258
259static 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
330exit_free:
331 kfree(data);
332exit:
333 return err;
334};
335
336static 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
350static int __init atxp1_init(void)
351{
352 return i2c_add_driver(&atxp1_driver);
353};
354
355static void __exit atxp1_exit(void)
356{
357 i2c_del_driver(&atxp1_driver);
358};
359
360module_init(atxp1_init);
361module_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 = {
69struct ds1337_data { 68struct 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 */
78static int ds1337_id;
79static LIST_HEAD(ds1337_clients); 76static LIST_HEAD(ds1337_clients);
80 77
81static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) 78static 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 */
96static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) 93static 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
157static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) 148static 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
210static int ds1337_command(struct i2c_client *client, unsigned int cmd, 192static 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 */
231int ds1337_do_command(int id, int cmd, void *arg) 213int 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>");
398MODULE_DESCRIPTION("DS1337 RTC driver"); 379MODULE_DESCRIPTION("DS1337 RTC driver");
399MODULE_LICENSE("GPL"); 380MODULE_LICENSE("GPL");
400 381
382EXPORT_SYMBOL_GPL(ds1337_do_command);
383
401module_init(ds1337_init); 384module_init(ds1337_init);
402module_exit(ds1337_exit); 385module_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
44static DECLARE_MUTEX(ds1374_mutex);
45
46static struct i2c_driver ds1374_driver;
47static struct i2c_client *save_client;
48
49static unsigned short ignore[] = { I2C_CLIENT_END };
50static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END };
51
52static struct i2c_client_address_data addr_data = {
53 .normal_i2c = normal_addr,
54 .probe = ignore,
55 .ignore = ignore,
56 .force = ignore,
57};
58
59static 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
76static 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
91static 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
113ulong 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
142static 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
169ulong new_time;
170
171DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time);
172
173int 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 */
192static 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
220static int ds1374_attach(struct i2c_adapter *adap)
221{
222 return i2c_probe(adap, &addr_data, ds1374_probe);
223}
224
225static 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
236static 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
245static int __init ds1374_init(void)
246{
247 return i2c_add_driver(&ds1374_driver);
248}
249
250static void __exit ds1374_exit(void)
251{
252 i2c_del_driver(&ds1374_driver);
253}
254
255module_init(ds1374_init);
256module_exit(ds1374_exit);
257
258MODULE_AUTHOR("Randy Vinson <rvinson@mvista.com>");
259MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC I2C Client Driver");
260MODULE_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)
121static void ds1621_init_client(struct i2c_client *client) 121static 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)
145static unsigned short normal_i2c[] = { 145static unsigned short normal_i2c[] = {
146 ISP_BASE, ISP_BASE + 1, 146 ISP_BASE, ISP_BASE + 1,
147 I2C_CLIENT_END }; 147 I2C_CLIENT_END };
148static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
149 148
150I2C_CLIENT_INSMOD; 149I2C_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
244static ssize_t show_in(struct device *dev, char *buf, int nr) 242static 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
250static ssize_t show_in_min(struct device *dev, char *buf, int nr) 252static 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
256static ssize_t show_in_max(struct device *dev, char *buf, int nr) 262static 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
262static ssize_t set_in_min(struct device *dev, const char *buf, 272static 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}
276static ssize_t set_in_max(struct device *dev, const char *buf, 289static 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) \
292static ssize_t \ 308static 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} \
297static 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) \
300static ssize_t \ 312static 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{ \ 314static 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} \
305static 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} \
310static 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} \
315static 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} \
320static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
321 show_in##offset##_min, set_in##offset##_min); \
322static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
323 show_in##offset##_max, set_in##offset##_max);
324 316
325show_in_offset(0); 317show_in_offset(0);
326limit_in_offset(0); 318limit_in_offset(0);
@@ -341,24 +333,39 @@ limit_in_offset(7);
341show_in_offset(8); 333show_in_offset(8);
342 334
343/* 3 temperatures */ 335/* 3 temperatures */
344static ssize_t show_temp(struct device *dev, char *buf, int nr) 336static 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}
349static ssize_t show_temp_max(struct device *dev, char *buf, int nr) 345static 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}
354static ssize_t show_temp_min(struct device *dev, char *buf, int nr) 354static 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}
359static ssize_t set_temp_max(struct device *dev, const char *buf, 363static 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}
372static ssize_t set_temp_min(struct device *dev, const char *buf, 379static 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) \
386static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 396static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
387{ \ 397 show_temp, NULL, offset - 1); \
388 return show_temp(dev, buf, offset - 1); \ 398static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
389} \ 399 show_temp_max, set_temp_max, offset - 1); \
390static ssize_t \ 400static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
391show_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} \
395static ssize_t \
396show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
397{ \
398 return show_temp_min(dev, buf, offset - 1); \
399} \
400static 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} \
405static 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} \
410static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
411static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
412 show_temp_##offset##_max, set_temp_##offset##_max); \
413static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
414 show_temp_##offset##_min, set_temp_##offset##_min);
415 402
416show_temp_offset(1); 403show_temp_offset(1);
417show_temp_offset(2); 404show_temp_offset(2);
418show_temp_offset(3); 405show_temp_offset(3);
419 406
420static ssize_t show_sensor(struct device *dev, char *buf, int nr) 407static 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}
431static ssize_t set_sensor(struct device *dev, const char *buf, 422static 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) \
456static ssize_t show_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 450static 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} \
460static 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} \
465static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
466 show_sensor_##offset, set_sensor_##offset);
467 452
468show_sensor_offset(1); 453show_sensor_offset(1);
469show_sensor_offset(2); 454show_sensor_offset(2);
470show_sensor_offset(3); 455show_sensor_offset(3);
471 456
472/* 3 Fans */ 457/* 3 Fans */
473static ssize_t show_fan(struct device *dev, char *buf, int nr) 458static 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}
479static ssize_t show_fan_min(struct device *dev, char *buf, int nr) 468static 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}
485static ssize_t show_fan_div(struct device *dev, char *buf, int nr) 478static 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}
490static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) 487static 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}
495static ssize_t show_pwm(struct device *dev, char *buf, int nr) 496static 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}
500static ssize_t set_fan_min(struct device *dev, const char *buf, 505static 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}
513static ssize_t set_fan_div(struct device *dev, const char *buf, 521static 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}
553static ssize_t set_pwm_enable(struct device *dev, const char *buf, 564static 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}
584static ssize_t set_pwm(struct device *dev, const char *buf, 598static 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) \
603static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 620static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
604{ \ 621 show_fan, NULL, offset - 1); \
605 return show_fan(dev, buf, offset - 1); \ 622static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
606} \ 623 show_fan_min, set_fan_min, offset - 1); \
607static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 624static 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} \
611static 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} \
615static 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} \
620static 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} \
625static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \
626static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
627 show_fan_##offset##_min, set_fan_##offset##_min); \
628static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
629 show_fan_##offset##_div, set_fan_##offset##_div);
630 626
631show_fan_offset(1); 627show_fan_offset(1);
632show_fan_offset(2); 628show_fan_offset(2);
633show_fan_offset(3); 629show_fan_offset(3);
634 630
635#define show_pwm_offset(offset) \ 631#define show_pwm_offset(offset) \
636static ssize_t show_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \ 632static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
637 char *buf) \ 633 show_pwm_enable, set_pwm_enable, offset - 1); \
638{ \ 634static 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} \
641static ssize_t show_pwm##offset (struct device *dev, struct device_attribute *attr, char *buf) \
642{ \
643 return show_pwm(dev, buf, offset - 1); \
644} \
645static 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} \
650static 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} \
655static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
656 show_pwm##offset##_enable, \
657 set_pwm##offset##_enable); \
658static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
659 show_pwm##offset , set_pwm##offset );
660 636
661show_pwm_offset(1); 637show_pwm_offset(1);
662show_pwm_offset(2); 638show_pwm_offset(2);
@@ -666,7 +642,7 @@ show_pwm_offset(3);
666static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 642static 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}
671static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 647static 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) \ 179static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
180static 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}
185show_fan(fan1_input);
186show_fan(fan1_low);
187 186
188static ssize_t set_fan1_low(struct device *dev, struct device_attribute *attr, const char *buf, 187static 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
205static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf) 204static 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
213static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 213static 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
232static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *attr, char *buf) 233static 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) \ 240static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr,
239static 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
245static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 248static 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}
250show_temp8(temp1_input); 261
251show_temp8(temp1_high); 262static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
252show_temp11(temp2_input); 263 char *buf)
253show_temp11(temp2_high); 264{
254show_temp11(temp2_low); 265 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
255show_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) \
258static 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
272static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ 270static 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}
286set_temp8(temp1_high, LM63_REG_LOCAL_HIGH);
287set_temp11(temp2_high, LM63_REG_REMOTE_HIGH_MSB, LM63_REG_REMOTE_HIGH_LSB);
288set_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 */
292static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf) 298static 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 */
301static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf, 308static 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
317static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 324static 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
323static DEVICE_ATTR(fan1_input, S_IRUGO, show_fan1_input, NULL); 331static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);
324static DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan1_low, 332static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan,
325 set_fan1_low); 333 set_fan, 1);
326 334
327static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); 335static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1);
328static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); 336static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL);
329 337
330static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL); 338static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0);
331static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp1_high, 339static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8,
332 set_temp1_high); 340 set_temp8, 1);
333 341
334static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp2_input, NULL); 342static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0);
335static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp2_low, 343static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11,
336 set_temp2_low); 344 set_temp11, 1);
337static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp2_high, 345static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11,
338 set_temp2_high); 346 set_temp11, 2);
339static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp2_crit, NULL); 347static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp8, NULL, 2);
340static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, 348static 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
100static 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
107static const u8 LM83_REG_W_HIGH[] = { 105static 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) \ 156static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
158static 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}
163show_temp(input1, temp_input[0]); 163
164show_temp(input2, temp_input[1]); 164static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
165show_temp(input3, temp_input[2]); 165 const char *buf, size_t count)
166show_temp(input4, temp_input[3]); 166{
167show_temp(high1, temp_high[0]); 167 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
168show_temp(high2, temp_high[1]); 168 struct i2c_client *client = to_i2c_client(dev);
169show_temp(high3, temp_high[2]); 169 struct lm83_data *data = i2c_get_clientdata(client);
170show_temp(high4, temp_high[3]); 170 long val = simple_strtol(buf, NULL, 10);
171show_temp(crit, temp_crit); 171 int nr = attr->index;
172 172
173#define set_temp(suffix, value, reg) \ 173 down(&data->update_lock);
174static 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}
187set_temp(high1, temp_high[0], LM83_REG_W_LOCAL_HIGH);
188set_temp(high2, temp_high[1], LM83_REG_W_REMOTE1_HIGH);
189set_temp(high3, temp_high[2], LM83_REG_W_REMOTE2_HIGH);
190set_temp(high4, temp_high[3], LM83_REG_W_REMOTE3_HIGH);
191set_temp(crit, temp_crit, LM83_REG_W_TCRIT);
192 180
193static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 181static 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
199static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); 188static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
200static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); 189static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
201static DEVICE_ATTR(temp3_input, S_IRUGO, show_temp_input3, NULL); 190static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
202static DEVICE_ATTR(temp4_input, S_IRUGO, show_temp_input4, NULL); 191static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3);
203static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, 192static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp,
204 set_temp_high1); 193 set_temp, 4);
205static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, 194static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp,
206 set_temp_high2); 195 set_temp, 5);
207static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_high3, 196static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp,
208 set_temp_high3); 197 set_temp, 6);
209static DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp_high4, 198static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp,
210 set_temp_high4); 199 set_temp, 7);
211static DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit, NULL); 200static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, 8);
212static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit, NULL); 201static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp, NULL, 8);
213static DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp_crit, 202static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp,
214 set_temp_crit); 203 set_temp, 8);
215static DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp_crit, NULL); 204static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8);
216static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 205static 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);
481static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 478static 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
487static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); 484static 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) \ 225static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr,
221static 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
233static 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}
226show_temp(temp_input1, TEMP1_FROM_REG); 258
227show_temp(temp_input2, TEMP2_FROM_REG); 259static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
228show_temp(temp_low1, TEMP1_FROM_REG); 260 char *buf)
229show_temp(temp_low2, TEMP2_FROM_REG); 261{
230show_temp(temp_high1, TEMP1_FROM_REG); 262 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
231show_temp(temp_high2, TEMP2_FROM_REG); 263 struct lm90_data *data = lm90_update_device(dev);
232show_temp(temp_crit1, TEMP1_FROM_REG); 264 return sprintf(buf, "%d\n", TEMP2_FROM_REG(data->temp11[attr->index]));
233show_temp(temp_crit2, TEMP1_FROM_REG);
234
235#define set_temp1(value, reg) \
236static 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
253static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ 267static 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}
270set_temp1(temp_low1, LM90_REG_W_LOCAL_LOW); 295
271set_temp2(temp_low2, LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL); 296static ssize_t show_temphyst(struct device *dev, struct device_attribute *devattr,
272set_temp1(temp_high1, LM90_REG_W_LOCAL_HIGH); 297 char *buf)
273set_temp2(temp_high2, LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL); 298{
274set_temp1(temp_crit1, LM90_REG_W_LOCAL_CRIT); 299 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
275set_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));
278static 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}
284show_temp_hyst(temp_hyst1, temp_crit1);
285show_temp_hyst(temp_hyst2, temp_crit2);
286 304
287static ssize_t set_temp_hyst1(struct device *dev, struct device_attribute *attr, const char *buf, 305static 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
303static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 321static 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
309static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); 328static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0);
310static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); 329static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0);
311static DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_low1, 330static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp8,
312 set_temp_low1); 331 set_temp8, 1);
313static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_low2, 332static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11,
314 set_temp_low2); 333 set_temp11, 1);
315static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, 334static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8,
316 set_temp_high1); 335 set_temp8, 2);
317static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, 336static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11,
318 set_temp_high2); 337 set_temp11, 2);
319static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit1, 338static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp8,
320 set_temp_crit1); 339 set_temp8, 3);
321static DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit2, 340static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp8,
322 set_temp_crit2); 341 set_temp8, 4);
323static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst1, 342static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst,
324 set_temp_hyst1); 343 set_temphyst, 3);
325static DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_hyst2, NULL); 344static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4);
326static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 345static 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
41static struct i2c_client_address_data addr_data = { 41static 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 */
40static unsigned short normal_i2c[] = {0x50, 0x52, I2C_CLIENT_END};
41static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};
42
43/* Insmod parameters */
44SENSORS_INSMOD_1(max6875);
45
46/* this param will prevent 'accidental' writes to the eeprom */
47static int allow_write = 0;
48module_param(allow_write, int, 0);
49MODULE_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
73enum max6875_area_type {
74 max6875_register_config=0,
75 max6875_eeprom_config,
76 max6875_eeprom_user,
77 max6857_max
78};
79
80struct 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 */
91struct 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
100static int max6875_attach_adapter(struct i2c_adapter *adapter);
101static int max6875_detect(struct i2c_adapter *adapter, int address, int kind);
102static int max6875_detach_client(struct i2c_client *client);
103
104/* This is the driver that will be inserted */
105static 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
113static 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
184static 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
208static 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
213static 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
218static 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
224static 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
285static 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
290static 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
295static 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
300static 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
311static 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
322static 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
333static 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 */
339static 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
436exit_kfree:
437 kfree(data);
438exit:
439 return err;
440}
441
442static 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
457static int __init max6875_init(void)
458{
459 return i2c_add_driver(&max6875_driver);
460}
461
462static void __exit max6875_exit(void)
463{
464 i2c_del_driver(&max6875_driver);
465}
466
467
468MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
469MODULE_DESCRIPTION("MAX6875 driver");
470MODULE_LICENSE("GPL");
471
472module_init(max6875_init);
473module_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 */
19static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END};
20static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};
21
22/* Insmod parameters */
23SENSORS_INSMOD_1(pca9539);
24
25enum 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
37static int pca9539_attach_adapter(struct i2c_adapter *adapter);
38static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind);
39static int pca9539_detach_client(struct i2c_client *client);
40
41/* This is the driver that will be inserted */
42static 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
50struct pca9539_data {
51 struct i2c_client client;
52};
53
54/* following are the sysfs callback functions */
55static 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
64static 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
85PCA9539_ENTRY_RO(input0, PCA9539_INPUT_0);
86PCA9539_ENTRY_RO(input1, PCA9539_INPUT_1);
87PCA9539_ENTRY_RW(output0, PCA9539_OUTPUT_0);
88PCA9539_ENTRY_RW(output1, PCA9539_OUTPUT_1);
89PCA9539_ENTRY_RW(invert0, PCA9539_INVERT_0);
90PCA9539_ENTRY_RW(invert1, PCA9539_INVERT_1);
91PCA9539_ENTRY_RW(direction0, PCA9539_DIRECTION_0);
92PCA9539_ENTRY_RW(direction1, PCA9539_DIRECTION_1);
93
94static 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
106static struct attribute_group pca9539_defattr_group = {
107 .attrs = pca9539_attributes,
108};
109
110static 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 */
116static 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
157exit_kfree:
158 kfree(data);
159exit:
160 return err;
161}
162
163static 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
176static int __init pca9539_init(void)
177{
178 return i2c_add_driver(&pca9539_driver);
179}
180
181static void __exit pca9539_exit(void)
182{
183 i2c_del_driver(&pca9539_driver);
184}
185
186MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
187MODULE_DESCRIPTION("PCA9539 driver");
188MODULE_LICENSE("GPL");
189
190module_init(pca9539_init);
191module_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);
57struct pcf8574_data { 57struct 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
63static int pcf8574_attach_adapter(struct i2c_adapter *adapter); 63static int pcf8574_attach_adapter(struct i2c_adapter *adapter);
@@ -79,9 +79,7 @@ static struct i2c_driver pcf8574_driver = {
79static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf) 79static 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
87static DEVICE_ATTR(read, S_IRUGO, show_read, NULL); 85static 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
67static struct i2c_client_address_data addr_data = { 66static 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
49MODULE_DESCRIPTION("TPS6501x Power Management Driver");
50MODULE_LICENSE("GPL");
51
52/* only two addresses possible */
53#define TPS_BASE 0x48
54static unsigned short normal_i2c[] = {
55 TPS_BASE,
56 I2C_CLIENT_END };
57static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
58
59I2C_CLIENT_INSMOD;
60
61static 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 */
79enum tps_model {
80 TPS_UNKNOWN = 0,
81 TPS65010,
82 TPS65011,
83 TPS65012,
84 TPS65013,
85};
86
87struct 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
114static 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
130static 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
144static 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
174static 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
182static 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
190static 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
200static inline void show_chgstatus(const char *label, u8 chgstatus) { }
201static inline void show_regstatus(const char *label, u8 chgstatus) { }
202static inline void show_chgconfig(int por, const char *label, u8 chgconfig) { }
203
204#endif
205
206#ifdef CONFIG_DEBUG_FS
207
208static 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
312static int dbg_tps_open(struct inode *inode, struct file *file)
313{
314 return single_open(file, dbg_show, inode->u.generic_ip);
315}
316
317static 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 */
333static 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 */
420static 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
455static 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
467static struct tps65010 *the_tps;
468
469static 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
488static 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 */
497static int __init
498tps65010_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);
526fail1:
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
638static 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
645static 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 */
661int 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}
687EXPORT_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 */
694int 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}
732EXPORT_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 */
739int 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}
812EXPORT_SYMBOL(tps65010_set_led);
813
814/*-------------------------------------------------------------------------*/
815/* tps65010_set_vib parameter:
816 * value: ON or OFF
817 */
818int 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}
840EXPORT_SYMBOL(tps65010_set_vib);
841
842/*-------------------------------------------------------------------------*/
843/* tps65010_set_low_pwr parameter:
844 * mode: ON or OFF
845 */
846int 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}
886EXPORT_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 */
893int 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}
919EXPORT_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
929int 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}
987EXPORT_SYMBOL(tps65013_set_low_pwr);
988
989/*-------------------------------------------------------------------------*/
990
991static 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 */
1065subsys_initcall(tps_init);
1066
1067static void __exit tps_exit(void)
1068{
1069 i2c_del_driver(&tps65010_driver);
1070}
1071module_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: */
84static const u8 regtemp[] = { 0x20, 0x21, 0x1f };
85static const u8 regover[] = { 0x39, 0x3d, 0x1d };
86static 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]) 82static const u8 VIA686A_REG_TEMP[] = { 0x20, 0x21, 0x1f };
90#define VIA686A_REG_TEMP_OVER(nr) (regover[nr]) 83static const u8 VIA686A_REG_TEMP_OVER[] = { 0x39, 0x3d, 0x1d };
91#define VIA686A_REG_TEMP_HYST(nr) (reghyst[nr]) 84static 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>) */
126static inline u8 IN_TO_REG(long val, int inNum) 121static 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: */
208static const long tempLUT[] = 203static 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: */
254static const u8 viaLUT[] = 249static 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 */
273static inline u8 TEMP_TO_REG(long val) 268static 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
361static ssize_t set_in_min(struct device *dev, const char *buf, 354static 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}
374static ssize_t set_in_max(struct device *dev, const char *buf, 367static 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}
438static ssize_t set_temp_over(struct device *dev, const char *buf, 431static 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}
450static ssize_t set_temp_hyst(struct device *dev, const char *buf, 444static 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);\
488static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ 483static 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); \
490static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ 485static 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
493show_temp_offset(1); 488show_temp_offset(1);
494show_temp_offset(2); 489show_temp_offset(2);
@@ -497,19 +492,19 @@ show_temp_offset(3);
497/* 2 Fans */ 492/* 2 Fans */
498static ssize_t show_fan(struct device *dev, char *buf, int nr) { 493static 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}
503static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { 498static 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}
508static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { 503static 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}
512static ssize_t set_fan_min(struct device *dev, const char *buf, 507static 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}
524static ssize_t set_fan_div(struct device *dev, const char *buf, 519static 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 */
573static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) { 568static 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}
577static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 572static 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: 698ERROR3:
703 kfree(data); 699 kfree(data);
704 ERROR0: 700ERROR0:
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
806static struct pci_device_id via686a_pci_ids[] = { 802static 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
811MODULE_DEVICE_TABLE(pci, via686a_pci_ids); 807MODULE_DEVICE_TABLE(pci, via686a_pci_ids);
812 808
813static int __devinit via686a_pci_probe(struct pci_dev *dev, 809static 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
850static struct pci_driver via686a_pci_driver = { 847static 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
856static int __init sm_via686a_init(void) 853static 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
861static void __exit sm_via686a_exit(void) 858static void __exit sm_via686a_exit(void)
@@ -869,8 +866,8 @@ static void __exit sm_via686a_exit(void)
869} 866}
870 867
871MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>, " 868MODULE_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>");
874MODULE_DESCRIPTION("VIA 686A Sensor device"); 871MODULE_DESCRIPTION("VIA 686A Sensor device");
875MODULE_LICENSE("GPL"); 872MODULE_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 */
46static unsigned short normal_i2c[] = { I2C_CLIENT_END };
47static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
48
49/* Insmod parameters */
50SENSORS_INSMOD_1(w83627ehf);
51
52/*
53 * Super-I/O constants and functions
54 */
55
56static int REG; /* The register to read/write */
57static 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
69static inline void
70superio_outb(int reg, int val)
71{
72 outb(reg, REG);
73 outb(val, VAL);
74}
75
76static inline int
77superio_inb(int reg)
78{
79 outb(reg, REG);
80 return inb(VAL);
81}
82
83static inline void
84superio_select(int ld)
85{
86 outb(SIO_REG_LDSEL, REG);
87 outb(ld, VAL);
88}
89
90static inline void
91superio_enter(void)
92{
93 outb(0x87, REG);
94 outb(0x87, REG);
95}
96
97static inline void
98superio_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
117static const u16 W83627EHF_REG_FAN[] = { 0x28, 0x29, 0x2a, 0x3f, 0x553 };
118static 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
123static const u16 W83627EHF_REG_TEMP[] = { 0x150, 0x250 };
124static const u16 W83627EHF_REG_TEMP_HYST[] = { 0x153, 0x253 };
125static const u16 W83627EHF_REG_TEMP_OVER[] = { 0x155, 0x255 };
126static 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
139static inline unsigned int
140fan_from_reg(u8 reg, unsigned int div)
141{
142 if (reg == 0 || reg == 255)
143 return 0;
144 return 1350000U / (reg * div);
145}
146
147static inline unsigned int
148div_from_reg(u8 reg)
149{
150 return 1 << reg;
151}
152
153static inline int
154temp1_from_reg(s8 reg)
155{
156 return reg * 1000;
157}
158
159static inline s8
160temp1_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
175struct 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
196static 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). */
209static 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
217static 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
225static 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
247static 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 */
269static 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
316static 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) \
406static ssize_t \
407show_##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}
414show_fan_reg(fan);
415show_fan_reg(fan_min);
416
417static ssize_t
418show_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
425static ssize_t
426store_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) \
488static ssize_t \
489show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \
490 char *buf) \
491{ \
492 return show_fan(dev, buf, offset-1); \
493} \
494static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
495 show_reg_fan_##offset, NULL);
496
497#define sysfs_fan_min_offset(offset) \
498static ssize_t \
499show_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} \
504static ssize_t \
505store_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} \
510static 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) \
515static ssize_t \
516show_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} \
521static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
522 show_reg_fan##offset##_div, NULL);
523
524sysfs_fan_offset(1);
525sysfs_fan_min_offset(1);
526sysfs_fan_div_offset(1);
527sysfs_fan_offset(2);
528sysfs_fan_min_offset(2);
529sysfs_fan_div_offset(2);
530sysfs_fan_offset(3);
531sysfs_fan_min_offset(3);
532sysfs_fan_div_offset(3);
533sysfs_fan_offset(4);
534sysfs_fan_min_offset(4);
535sysfs_fan_div_offset(4);
536sysfs_fan_offset(5);
537sysfs_fan_min_offset(5);
538sysfs_fan_div_offset(5);
539
540#define show_temp1_reg(reg) \
541static ssize_t \
542show_##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}
548show_temp1_reg(temp1);
549show_temp1_reg(temp1_max);
550show_temp1_reg(temp1_max_hyst);
551
552#define store_temp1_reg(REG, reg) \
553static ssize_t \
554store_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}
568store_temp1_reg(OVER, max);
569store_temp1_reg(HYST, max_hyst);
570
571static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL);
572static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR,
573 show_temp1_max, store_temp1_max);
574static 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) \
578static ssize_t \
579show_##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}
585show_temp_reg(temp);
586show_temp_reg(temp_max);
587show_temp_reg(temp_max_hyst);
588
589#define store_temp_reg(REG, reg) \
590static ssize_t \
591store_##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}
604store_temp_reg(OVER, temp_max);
605store_temp_reg(HYST, temp_max_hyst);
606
607#define sysfs_temp_offset(offset) \
608static ssize_t \
609show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \
610 char *buf) \
611{ \
612 return show_temp(dev, buf, offset - 2); \
613} \
614static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
615 show_reg_temp##offset, NULL);
616
617#define sysfs_temp_reg_offset(reg, offset) \
618static ssize_t \
619show_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} \
624static ssize_t \
625store_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} \
630static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \
631 show_reg_temp##offset##_##reg, \
632 store_reg_temp##offset##_##reg);
633
634sysfs_temp_offset(2);
635sysfs_temp_reg_offset(max, 2);
636sysfs_temp_reg_offset(max_hyst, 2);
637sysfs_temp_offset(3);
638sysfs_temp_reg_offset(max, 3);
639sysfs_temp_reg_offset(max_hyst, 3);
640
641/*
642 * Driver and client management
643 */
644
645static struct i2c_driver w83627ehf_driver;
646
647static 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
669static 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
756exit_free:
757 kfree(data);
758exit_release:
759 release_region(address, REGION_LENGTH);
760exit:
761 return err;
762}
763
764static 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
771static 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
786static 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
794static 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
827static 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
836static void __exit sensors_w83627ehf_exit(void)
837{
838 i2c_del_driver(&w83627ehf_driver);
839}
840
841MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
842MODULE_DESCRIPTION("W83627EHF driver");
843MODULE_LICENSE("GPL");
844
845module_init(sensors_w83627ehf_init);
846module_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,
53static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; 50static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
54 51
55/* Insmod parameters */ 52/* Insmod parameters */
56SENSORS_INSMOD_6(w83781d, w83782d, w83783s, w83627hf, as99127f, w83697hf); 53SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f);
57I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 54I2C_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
524show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 520show_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
530static 526static
@@ -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
638int i2c_master_recv(struct i2c_client *client, char *buf ,int count) 626int 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 @@
51static int do_probe( struct i2c_adapter *adapter, int addr, int kind); 51static 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) */
54static unsigned short normal_i2c[] = { 0x49, 0x2c, I2C_CLIENT_END }; 54static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
55static 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
57I2C_CLIENT_INSMOD; 59I2C_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};
387static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
388 387
389static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 388static unsigned short ignore = I2C_CLIENT_END;
390static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
391static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
392static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
393static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
394 389
395static struct i2c_client_address_data addr_data = { 390static 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
405static struct i2c_driver i2c_driver_adv7170; 397static 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};
437static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
438 437
439static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 438static unsigned short ignore = I2C_CLIENT_END;
440static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
441static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
442static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
443static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
444 439
445static struct i2c_client_address_data addr_data = { 440static 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
455static struct i2c_driver i2c_driver_adv7175; 447static 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};
503static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
504 503
505static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 504static unsigned short ignore = I2C_CLIENT_END;
506static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
507static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
508static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
509static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
510 505
511static struct i2c_client_address_data addr_data = { 506static 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
521static struct i2c_driver i2c_driver_bt819; 513static 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 @@
39MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
40 40
41/* Addresses to scan */ 41/* Addresses to scan */
42static unsigned short normal_i2c[] = {I2C_CLIENT_END}; 42static unsigned short normal_i2c[] = { I2C_BT832_ALT1>>1, I2C_BT832_ALT2>>1,
43static unsigned short normal_i2c_range[] = {I2C_BT832_ALT1>>1,I2C_BT832_ALT2>>1,I2C_CLIENT_END}; 43 I2C_CLIENT_END };
44I2C_CLIENT_INSMOD; 44I2C_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 */
290static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; 290static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END };
291static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
292 291
293static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 292static unsigned short ignore = I2C_CLIENT_END;
294static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
295static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
296static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
297static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
298 293
299static struct i2c_client_address_data addr_data = { 294static 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
309static struct i2c_driver i2c_driver_bt856; 301static 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};
150static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END};
151I2C_CLIENT_INSMOD; 150I2C_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 */
66static unsigned short normal_i2c[] = { I2C_ADDRESS, I2C_CLIENT_END }; 66static unsigned short normal_i2c[] = { I2C_ADDRESS, I2C_CLIENT_END };
67static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
68I2C_CLIENT_INSMOD; 67I2C_CLIENT_INSMOD;
69 68
70static struct i2c_client client_template; 69static 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 */
134static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END}; 134static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END};
135static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
136I2C_CLIENT_INSMOD; 135I2C_CLIENT_INSMOD;
137 136
138static struct i2c_client client_template; 137static 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};
466static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
467 466
468static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 467static unsigned short ignore = I2C_CLIENT_END;
469static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
470static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
471static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
472static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
473 468
474static struct i2c_client_address_data addr_data = { 469static 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
484static struct i2c_driver i2c_driver_saa7110; 476static 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 */
484static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; 484static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END };
485static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
486 485
487static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 486static unsigned short ignore = I2C_CLIENT_END;
488static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
489static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
490static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
491static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
492 487
493static struct i2c_client_address_data addr_data = { 488static 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
503static struct i2c_driver i2c_driver_saa7111; 495static 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 */
821static unsigned short normal_i2c[] = 821static unsigned short normal_i2c[] =
822 { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; 822 { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END };
823static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
824 823
825static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 824static unsigned short ignore = I2C_CLIENT_END;
826static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
827static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
828static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
829static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
830 825
831static struct i2c_client_address_data addr_data = { 826static 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
841static struct i2c_driver i2c_driver_saa7114; 833static 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 */
24static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END}; 24static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END};
25static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
26I2C_CLIENT_INSMOD; 25I2C_CLIENT_INSMOD;
27 26
28MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); 27MODULE_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 */
382static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; 382static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END };
383static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
384 383
385static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 384static unsigned short ignore = I2C_CLIENT_END;
386static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
387static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
388static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
389static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
390 385
391static struct i2c_client_address_data addr_data = { 386static 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
401static struct i2c_driver i2c_driver_saa7185; 393static 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};
77static unsigned short normal_i2c_range[] = { I2C_CLIENT_END, I2C_CLIENT_END };
78I2C_CLIENT_INSMOD; 77I2C_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) */
45static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END }; 45static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END };
46static 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 */
49I2C_CLIENT_INSMOD; 48I2C_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};
47static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
48I2C_CLIENT_INSMOD; 47I2C_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};
36static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END};
37I2C_CLIENT_INSMOD; 36I2C_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) */
45static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END }; 45static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END };
46static 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 */
49I2C_CLIENT_INSMOD; 48I2C_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) */
42static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END }; 42static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END };
43static 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 */
46I2C_CLIENT_INSMOD; 45I2C_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;
34static struct i2c_client client_template; 34static struct i2c_client client_template;
35 35
36/* Addresses to scan */ 36/* Addresses to scan */
37static unsigned short normal_i2c[] = {I2C_CLIENT_END}; 37static unsigned short normal_i2c[] = { 0x60, 0x61, I2C_CLIENT_END };
38static unsigned short normal_i2c_range[] = {0x60, 0x61, I2C_CLIENT_END}; 38static unsigned short ignore = I2C_CLIENT_END;
39static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
40static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
41static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
42static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
43static unsigned short force[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
44 39
45static struct i2c_client_address_data addr_data = { 40static 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 */
29static unsigned short normal_i2c[] = { 29static 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,
33static unsigned short normal_i2c_range[] = {
34 0x60, 0x6f,
35 I2C_CLIENT_END 33 I2C_CLIENT_END
36}; 34};
37I2C_CLIENT_INSMOD; 35I2C_CLIENT_INSMOD;
@@ -225,9 +223,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
225static int tuner_probe(struct i2c_adapter *adap) 223static 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 };
151static unsigned short normal_i2c_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
152I2C_CLIENT_INSMOD; 151I2C_CLIENT_INSMOD;
153 152
154static struct i2c_driver driver; 153static 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};
485static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
486I2C_CLIENT_INSMOD; 485I2C_CLIENT_INSMOD;
487 486
488struct i2c_driver i2c_driver_tveeprom; 487struct 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};
572static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
573 572
574static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 573static unsigned short ignore = I2C_CLIENT_END;
575static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
576static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
577static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
578static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
579 574
580static struct i2c_client_address_data addr_data = { 575static 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
590static struct i2c_driver vpx3220_i2c_driver; 582static 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
1232static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; 1232static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END };
1233static unsigned short normal_i2c_range[] = { MAVEN_I2CID, MAVEN_I2CID, I2C_CLIENT_END };
1234I2C_CLIENT_INSMOD; 1233I2C_CLIENT_INSMOD;
1235 1234
1236static struct i2c_driver maven_driver; 1235static 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 */
72extern int tps65010_set_led(unsigned led, unsigned mode); 132extern int tps65010_set_led(unsigned led, unsigned mode);
73 133
134/* tps65010_set_vib parameter:
135 * value: ON or OFF
136 */
137extern 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 */
77extern int tps65010_set_low_pwr(unsigned mode); 142extern 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 */
148extern int tps65010_config_vregs1(unsigned value);
149
150/* tps65013_set_low_pwr parameter:
151 * mode: ON or OFF
152 */
153extern 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
23struct sensor_device_attribute{ 23struct 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
101static 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 */
291struct i2c_client_address_data { 291struct 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