aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/hwmon/lm787
-rw-r--r--Documentation/hwmon/w83792d174
-rw-r--r--Documentation/i2c/chips/max687594
-rw-r--r--Documentation/i2c/functionality2
-rw-r--r--Documentation/i2c/porting-clients25
-rw-r--r--Documentation/i2c/writing-clients114
6 files changed, 290 insertions, 126 deletions
diff --git a/Documentation/hwmon/lm78 b/Documentation/hwmon/lm78
index 357086ed7f64..fd5dc7a19f0e 100644
--- a/Documentation/hwmon/lm78
+++ b/Documentation/hwmon/lm78
@@ -2,16 +2,11 @@ Kernel driver lm78
2================== 2==================
3 3
4Supported chips: 4Supported chips:
5 * National Semiconductor LM78 5 * National Semiconductor LM78 / LM78-J
6 Prefix: 'lm78' 6 Prefix: 'lm78'
7 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) 7 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
8 Datasheet: Publicly available at the National Semiconductor website 8 Datasheet: Publicly available at the National Semiconductor website
9 http://www.national.com/ 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 10 * National Semiconductor LM79
16 Prefix: 'lm79' 11 Prefix: 'lm79'
17 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) 12 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
diff --git a/Documentation/hwmon/w83792d b/Documentation/hwmon/w83792d
new file mode 100644
index 000000000000..8171c285bb55
--- /dev/null
+++ b/Documentation/hwmon/w83792d
@@ -0,0 +1,174 @@
1Kernel driver w83792d
2=====================
3
4Supported chips:
5 * Winbond W83792D
6 Prefix: 'w83792d'
7 Addresses scanned: I2C 0x2c - 0x2f
8 Datasheet: http://www.winbond.com.tw/E-WINBONDHTM/partner/PDFresult.asp?Pname=1035
9
10Author: Chunhao Huang
11Contact: DZShen <DZShen@Winbond.com.tw>
12
13
14Module Parameters
15-----------------
16
17* init int
18 (default 1)
19 Use 'init=0' to bypass initializing the chip.
20 Try this if your computer crashes when you load the module.
21
22* force_subclients=bus,caddr,saddr,saddr
23 This is used to force the i2c addresses for subclients of
24 a certain chip. Example usage is `force_subclients=0,0x2f,0x4a,0x4b'
25 to force the subclients of chip 0x2f on bus 0 to i2c addresses
26 0x4a and 0x4b.
27
28
29Description
30-----------
31
32This driver implements support for the Winbond W83792AD/D.
33
34Detection of the chip can sometimes be foiled because it can be in an
35internal state that allows no clean access (Bank with ID register is not
36currently selected). If you know the address of the chip, use a 'force'
37parameter; this will put it into a more well-behaved state first.
38
39The driver implements three temperature sensors, seven fan rotation speed
40sensors, nine voltage sensors, and two automatic fan regulation
41strategies called: Smart Fan I (Thermal Cruise mode) and Smart Fan II.
42Automatic fan control mode is possible only for fan1-fan3. Fan4-fan7 can run
43synchronized with selected fan (fan1-fan3). This functionality and manual PWM
44control for fan4-fan7 is not yet implemented.
45
46Temperatures are measured in degrees Celsius and measurement resolution is 1
47degC for temp1 and 0.5 degC for temp2 and temp3. An alarm is triggered when
48the temperature gets higher than the Overtemperature Shutdown value; it stays
49on until the temperature falls below the Hysteresis value.
50
51Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
52triggered if the rotation speed has dropped below a programmable limit. Fan
53readings can be divided by a programmable divider (1, 2, 4, 8, 16, 32, 64 or
54128) to give the readings more range or accuracy.
55
56Voltage sensors (also known as IN sensors) report their values in millivolts.
57An alarm is triggered if the voltage has crossed a programmable minimum
58or maximum limit.
59
60Alarms are provided as output from "realtime status register". Following bits
61are defined:
62
63bit - alarm on:
640 - in0
651 - in1
662 - temp1
673 - temp2
684 - temp3
695 - fan1
706 - fan2
717 - fan3
728 - in2
739 - in3
7410 - in4
7511 - in5
7612 - in6
7713 - VID change
7814 - chassis
7915 - fan7
8016 - tart1
8117 - tart2
8218 - tart3
8319 - in7
8420 - in8
8521 - fan4
8622 - fan5
8723 - fan6
88
89Tart will be asserted while target temperature cannot be achieved after 3 minutes
90of full speed rotation of corresponding fan.
91
92In addition to the alarms described above, there is a CHAS alarm on the chips
93which triggers if your computer case is open (This one is latched, contrary
94to realtime alarms).
95
96The chips only update values each 3 seconds; reading them more often will
97do no harm, but will return 'old' values.
98
99
100W83792D PROBLEMS
101----------------
102Known problems:
103 - This driver is only for Winbond W83792D C version device, there
104 are also some motherboards with B version W83792D device. The
105 calculation method to in6-in7(measured value, limits) is a little
106 different between C and B version. C or B version can be identified
107 by CR[0x49h].
108 - The function of vid and vrm has not been finished, because I'm NOT
109 very familiar with them. Adding support is welcome.
110  - The function of chassis open detection needs more tests.
111 - If you have ASUS server board and chip was not found: Then you will
112 need to upgrade to latest (or beta) BIOS. If it does not help please
113 contact us.
114
115Fan control
116-----------
117
118Manual mode
119-----------
120
121Works as expected. You just need to specify desired PWM/DC value (fan speed)
122in appropriate pwm# file.
123
124Thermal cruise
125--------------
126
127In this mode, W83792D provides the Smart Fan system to automatically control
128fan speed to keep the temperatures of CPU and the system within specific
129range. At first a wanted temperature and interval must be set. This is done
130via thermal_cruise# file. The tolerance# file serves to create T +- tolerance
131interval. The fan speed will be lowered as long as the current temperature
132remains below the thermal_cruise# +- tolerance# value. Once the temperature
133exceeds the high limit (T+tolerance), the fan will be turned on with a
134specific speed set by pwm# and automatically controlled its PWM duty cycle
135with the temperature varying. Three conditions may occur:
136
137(1) If the temperature still exceeds the high limit, PWM duty
138cycle will increase slowly.
139
140(2) If the temperature goes below the high limit, but still above the low
141limit (T-tolerance), the fan speed will be fixed at the current speed because
142the temperature is in the target range.
143
144(3) If the temperature goes below the low limit, PWM duty cycle will decrease
145slowly to 0 or a preset stop value until the temperature exceeds the low
146limit. (The preset stop value handling is not yet implemented in driver)
147
148Smart Fan II
149------------
150
151W83792D also provides a special mode for fan. Four temperature points are
152available. When related temperature sensors detects the temperature in preset
153temperature region (sf2_point@_fan# +- tolerance#) it will cause fans to run
154on programmed value from sf2_level@_fan#. You need to set four temperatures
155for each fan.
156
157
158/sys files
159----------
160
161pwm[1-3] - this file stores PWM duty cycle or DC value (fan speed) in range:
162 0 (stop) to 255 (full)
163pwm[1-3]_enable - this file controls mode of fan/temperature control:
164 * 0 Disabled
165 * 1 Manual mode
166 * 2 Smart Fan II
167 * 3 Thermal Cruise
168pwm[1-3]_mode - Select PWM of DC mode
169 * 0 DC
170 * 1 PWM
171thermal_cruise[1-3] - Selects the desired temperature for cruise (degC)
172tolerance[1-3] - Value in degrees of Celsius (degC) for +- T
173sf2_point[1-4]_fan[1-3] - four temperature points for each fan for Smart Fan II
174sf2_level[1-3]_fan[1-3] - three PWM/DC levels for each fan for Smart Fan II
diff --git a/Documentation/i2c/chips/max6875 b/Documentation/i2c/chips/max6875
index b02002898a09..96fec562a8e9 100644
--- a/Documentation/i2c/chips/max6875
+++ b/Documentation/i2c/chips/max6875
@@ -4,22 +4,13 @@ Kernel driver max6875
4Supported chips: 4Supported chips:
5 * Maxim MAX6874, MAX6875 5 * Maxim MAX6874, MAX6875
6 Prefix: 'max6875' 6 Prefix: 'max6875'
7 Addresses scanned: 0x50, 0x52 7 Addresses scanned: None (see below)
8 Datasheet: 8 Datasheet:
9 http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf 9 http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf
10 10
11Author: Ben Gardner <bgardner@wabtec.com> 11Author: Ben Gardner <bgardner@wabtec.com>
12 12
13 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 14Description
24----------- 15-----------
25 16
@@ -33,34 +24,85 @@ registers.
33 24
34The Maxim MAX6874 is a similar, mostly compatible device, with more intputs 25The Maxim MAX6874 is a similar, mostly compatible device, with more intputs
35and outputs: 26and outputs:
36
37 vin gpi vout 27 vin gpi vout
38MAX6874 6 4 8 28MAX6874 6 4 8
39MAX6875 4 3 5 29MAX6875 4 3 5
40 30
41MAX6874 chips can have four different addresses (as opposed to only two for 31See the datasheet for more information.
42the MAX6875). The additional addresses (0x54 and 0x56) are not probed by
43this driver by default, but the probe module parameter can be used if
44needed.
45
46See the datasheet for details on how to program the EEPROM.
47 32
48 33
49Sysfs entries 34Sysfs entries
50------------- 35-------------
51 36
52eeprom_user - 512 bytes of user-defined EEPROM space. Only writable if 37eeprom - 512 bytes of user-defined EEPROM space.
53 allow_write was set and register 0x43 is 0.
54
55eeprom_config - 70 bytes of config EEPROM. Note that changes will not get
56 loaded into register space until a power cycle or device reset.
57
58reg_config - 70 bytes of register space. Any changes take affect immediately.
59 38
60 39
61General Remarks 40General Remarks
62--------------- 41---------------
63 42
64A typical application will require that the EEPROMs be programmed once and 43Valid addresses for the MAX6875 are 0x50 and 0x52.
65never altered afterwards. 44Valid addresses for the MAX6874 are 0x50, 0x52, 0x54 and 0x56.
45The driver does not probe any address, so you must force the address.
46
47Example:
48$ modprobe max6875 force=0,0x50
49
50The MAX6874/MAX6875 ignores address bit 0, so this driver attaches to multiple
51addresses. For example, for address 0x50, it also reserves 0x51.
52The even-address instance is called 'max6875', the odd one is 'max6875 subclient'.
53
54
55Programming the chip using i2c-dev
56----------------------------------
57
58Use the i2c-dev interface to access and program the chips.
59Reads and writes are performed differently depending on the address range.
60
61The configuration registers are at addresses 0x00 - 0x45.
62Use i2c_smbus_write_byte_data() to write a register and
63i2c_smbus_read_byte_data() to read a register.
64The command is the register number.
65
66Examples:
67To write a 1 to register 0x45:
68 i2c_smbus_write_byte_data(fd, 0x45, 1);
69
70To read register 0x45:
71 value = i2c_smbus_read_byte_data(fd, 0x45);
72
73
74The configuration EEPROM is at addresses 0x8000 - 0x8045.
75The user EEPROM is at addresses 0x8100 - 0x82ff.
76
77Use i2c_smbus_write_word_data() to write a byte to EEPROM.
78
79The command is the upper byte of the address: 0x80, 0x81, or 0x82.
80The data word is the lower part of the address or'd with data << 8.
81 cmd = address >> 8;
82 val = (address & 0xff) | (data << 8);
83
84Example:
85To write 0x5a to address 0x8003:
86 i2c_smbus_write_word_data(fd, 0x80, 0x5a03);
87
88
89Reading data from the EEPROM is a little more complicated.
90Use i2c_smbus_write_byte_data() to set the read address and then
91i2c_smbus_read_byte() or i2c_smbus_read_i2c_block_data() to read the data.
92
93Example:
94To read data starting at offset 0x8100, first set the address:
95 i2c_smbus_write_byte_data(fd, 0x81, 0x00);
96
97And then read the data
98 value = i2c_smbus_read_byte(fd);
99
100 or
101
102 count = i2c_smbus_read_i2c_block_data(fd, 0x84, buffer);
103
104The block read should read 16 bytes.
1050x84 is the block read command.
106
107See the datasheet for more details.
66 108
diff --git a/Documentation/i2c/functionality b/Documentation/i2c/functionality
index 8a78a95ae04e..41ffefbdc60c 100644
--- a/Documentation/i2c/functionality
+++ b/Documentation/i2c/functionality
@@ -115,7 +115,7 @@ CHECKING THROUGH /DEV
115If you try to access an adapter from a userspace program, you will have 115If you try to access an adapter from a userspace program, you will have
116to use the /dev interface. You will still have to check whether the 116to use the /dev interface. You will still have to check whether the
117functionality you need is supported, of course. This is done using 117functionality you need is supported, of course. This is done using
118the I2C_FUNCS ioctl. An example, adapted from the lm_sensors i2c_detect 118the I2C_FUNCS ioctl. An example, adapted from the lm_sensors i2cdetect
119program, is below: 119program, is below:
120 120
121 int file; 121 int file;
diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients
index a7adbdd9ea8a..4849dfd6961c 100644
--- a/Documentation/i2c/porting-clients
+++ b/Documentation/i2c/porting-clients
@@ -1,4 +1,4 @@
1Revision 4, 2004-03-30 1Revision 5, 2005-07-29
2Jean Delvare <khali@linux-fr.org> 2Jean Delvare <khali@linux-fr.org>
3Greg KH <greg@kroah.com> 3Greg KH <greg@kroah.com>
4 4
@@ -17,20 +17,22 @@ yours for best results.
17 17
18Technical changes: 18Technical changes:
19 19
20* [Includes] Get rid of "version.h". Replace <linux/i2c-proc.h> with 20* [Includes] Get rid of "version.h" and <linux/i2c-proc.h>.
21 <linux/i2c-sensor.h>. Includes typically look like that: 21 Includes typically look like that:
22 #include <linux/module.h> 22 #include <linux/module.h>
23 #include <linux/init.h> 23 #include <linux/init.h>
24 #include <linux/slab.h> 24 #include <linux/slab.h>
25 #include <linux/i2c.h> 25 #include <linux/i2c.h>
26 #include <linux/i2c-sensor.h> 26 #include <linux/hwmon.h> /* for hardware monitoring drivers */
27 #include <linux/i2c-vid.h> /* if you need VRM support */ 27 #include <linux/hwmon-sysfs.h>
28 #include <linux/hwmon-vid.h> /* if you need VRM support */
28 #include <asm/io.h> /* if you have I/O operations */ 29 #include <asm/io.h> /* if you have I/O operations */
29 Please respect this inclusion order. Some extra headers may be 30 Please respect this inclusion order. Some extra headers may be
30 required for a given driver (e.g. "lm75.h"). 31 required for a given driver (e.g. "lm75.h").
31 32
32* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, SENSORS_ISA_END 33* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, ISA addresses
33 becomes I2C_CLIENT_ISA_END. 34 are no more handled by the i2c core.
35 SENSORS_INSMOD_<n> becomes I2C_CLIENT_INSMOD_<n>.
34 36
35* [Client data] Get rid of sysctl_id. Try using standard names for 37* [Client data] Get rid of sysctl_id. Try using standard names for
36 register values (for example, temp_os becomes temp_max). You're 38 register values (for example, temp_os becomes temp_max). You're
@@ -66,13 +68,15 @@ Technical changes:
66 if (!(adapter->class & I2C_CLASS_HWMON)) 68 if (!(adapter->class & I2C_CLASS_HWMON))
67 return 0; 69 return 0;
68 ISA-only drivers of course don't need this. 70 ISA-only drivers of course don't need this.
71 Call i2c_probe() instead of i2c_detect().
69 72
70* [Detect] As mentioned earlier, the flags parameter is gone. 73* [Detect] As mentioned earlier, the flags parameter is gone.
71 The type_name and client_name strings are replaced by a single 74 The type_name and client_name strings are replaced by a single
72 name string, which will be filled with a lowercase, short string 75 name string, which will be filled with a lowercase, short string
73 (typically the driver name, e.g. "lm75"). 76 (typically the driver name, e.g. "lm75").
74 In i2c-only drivers, drop the i2c_is_isa_adapter check, it's 77 In i2c-only drivers, drop the i2c_is_isa_adapter check, it's
75 useless. 78 useless. Same for isa-only drivers, as the test would always be
79 true. Only hybrid drivers (which are quite rare) still need it.
76 The errorN labels are reduced to the number needed. If that number 80 The errorN labels are reduced to the number needed. If that number
77 is 2 (i2c-only drivers), it is advised that the labels are named 81 is 2 (i2c-only drivers), it is advised that the labels are named
78 exit and exit_free. For i2c+isa drivers, labels should be named 82 exit and exit_free. For i2c+isa drivers, labels should be named
@@ -86,6 +90,8 @@ Technical changes:
86 device_create_file. Move the driver initialization before any 90 device_create_file. Move the driver initialization before any
87 sysfs file creation. 91 sysfs file creation.
88 Drop client->id. 92 Drop client->id.
93 Drop any 24RF08 corruption prevention you find, as this is now done
94 at the i2c-core level, and doing it twice voids it.
89 95
90* [Init] Limits must not be set by the driver (can be done later in 96* [Init] Limits must not be set by the driver (can be done later in
91 user-space). Chip should not be reset default (although a module 97 user-space). Chip should not be reset default (although a module
@@ -93,7 +99,8 @@ Technical changes:
93 limited to the strictly necessary steps. 99 limited to the strictly necessary steps.
94 100
95* [Detach] Get rid of data, remove the call to 101* [Detach] Get rid of data, remove the call to
96 i2c_deregister_entry. 102 i2c_deregister_entry. Do not log an error message if
103 i2c_detach_client fails, as i2c-core will now do it for you.
97 104
98* [Update] Don't access client->data directly, use 105* [Update] Don't access client->data directly, use
99 i2c_get_clientdata(client) instead. 106 i2c_get_clientdata(client) instead.
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index 91664be91ffc..077275722a7c 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -148,15 +148,15 @@ are defined in i2c.h to help you support them, as well as a generic
148detection algorithm. 148detection algorithm.
149 149
150You do not have to use this parameter interface; but don't try to use 150You do not have to use this parameter interface; but don't try to use
151function i2c_probe() (or i2c_detect()) if you don't. 151function i2c_probe() if you don't.
152 152
153NOTE: If you want to write a `sensors' driver, the interface is slightly 153NOTE: If you want to write a `sensors' driver, the interface is slightly
154 different! See below. 154 different! See below.
155 155
156 156
157 157
158Probing classes (i2c) 158Probing classes
159--------------------- 159---------------
160 160
161All parameters are given as lists of unsigned 16-bit integers. Lists are 161All parameters are given as lists of unsigned 16-bit integers. Lists are
162terminated by I2C_CLIENT_END. 162terminated by I2C_CLIENT_END.
@@ -171,12 +171,18 @@ The following lists are used internally:
171 ignore: insmod parameter. 171 ignore: insmod parameter.
172 A list of pairs. The first value is a bus number (-1 for any I2C bus), 172 A list of pairs. The first value is a bus number (-1 for any I2C bus),
173 the second is the I2C address. These addresses are never probed. 173 the second is the I2C address. These addresses are never probed.
174 This parameter overrules 'normal' and 'probe', but not the 'force' lists. 174 This parameter overrules the 'normal_i2c' list only.
175 force: insmod parameter. 175 force: insmod parameter.
176 A list of pairs. The first value is a bus number (-1 for any I2C bus), 176 A list of pairs. The first value is a bus number (-1 for any I2C bus),
177 the second is the I2C address. A device is blindly assumed to be on 177 the second is the I2C address. A device is blindly assumed to be on
178 the given address, no probing is done. 178 the given address, no probing is done.
179 179
180Additionally, kind-specific force lists may optionally be defined if
181the driver supports several chip kinds. They are grouped in a
182NULL-terminated list of pointers named forces, those first element if the
183generic force list mentioned above. Each additional list correspond to an
184insmod parameter of the form force_<kind>.
185
180Fortunately, as a module writer, you just have to define the `normal_i2c' 186Fortunately, as a module writer, you just have to define the `normal_i2c'
181parameter. The complete declaration could look like this: 187parameter. The complete declaration could look like this:
182 188
@@ -186,66 +192,17 @@ parameter. The complete declaration could look like this:
186 192
187 /* Magic definition of all other variables and things */ 193 /* Magic definition of all other variables and things */
188 I2C_CLIENT_INSMOD; 194 I2C_CLIENT_INSMOD;
195 /* Or, if your driver supports, say, 2 kind of devices: */
196 I2C_CLIENT_INSMOD_2(foo, bar);
197
198If you use the multi-kind form, an enum will be defined for you:
199 enum chips { any_chip, foo, bar, ... }
200You can then (and certainly should) use it in the driver code.
189 201
190Note that you *have* to call the defined variable `normal_i2c', 202Note that you *have* to call the defined variable `normal_i2c',
191without any prefix! 203without any prefix!
192 204
193 205
194Probing classes (sensors)
195-------------------------
196
197If you write a `sensors' driver, you use a slightly different interface.
198As well as I2C addresses, we have to cope with ISA addresses. Also, we
199use a enum of chip types. Don't forget to include `sensors.h'.
200
201The following lists are used internally. They are all lists of integers.
202
203 normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END.
204 A list of I2C addresses which should normally be examined.
205 normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.
206 A list of ISA addresses which should normally be examined.
207 probe: insmod parameter. Initialize this list with SENSORS_I2C_END values.
208 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
209 the ISA bus, -1 for any I2C bus), the second is the address. These
210 addresses are also probed, as if they were in the 'normal' list.
211 ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values.
212 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
213 the ISA bus, -1 for any I2C bus), the second is the I2C address. These
214 addresses are never probed. This parameter overrules 'normal' and
215 'probe', but not the 'force' lists.
216
217Also used is a list of pointers to sensors_force_data structures:
218 force_data: insmod parameters. A list, ending with an element of which
219 the force field is NULL.
220 Each element contains the type of chip and a list of pairs.
221 The first value is a bus number (SENSORS_ISA_BUS for the ISA bus,
222 -1 for any I2C bus), the second is the address.
223 These are automatically translated to insmod variables of the form
224 force_foo.
225
226So we have a generic insmod variabled `force', and chip-specific variables
227`force_CHIPNAME'.
228
229Fortunately, as a module writer, you just have to define the `normal_i2c'
230and `normal_isa' parameters, and define what chip names are used.
231The complete declaration could look like this:
232 /* Scan i2c addresses 0x37, and 0x48 to 0x4f */
233 static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c,
234 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
235 /* Scan ISA address 0x290 */
236 static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END};
237
238 /* Define chips foo and bar, as well as all module parameters and things */
239 SENSORS_INSMOD_2(foo,bar);
240
241If you have one chip, you use macro SENSORS_INSMOD_1(chip), if you have 2
242you use macro SENSORS_INSMOD_2(chip1,chip2), etc. If you do not want to
243bother with chip types, you can use SENSORS_INSMOD_0.
244
245A enum is automatically defined as follows:
246 enum chips { any_chip, chip1, chip2, ... }
247
248
249Attaching to an adapter 206Attaching to an adapter
250----------------------- 207-----------------------
251 208
@@ -264,17 +221,10 @@ detected at a specific address, another callback is called.
264 return i2c_probe(adapter,&addr_data,&foo_detect_client); 221 return i2c_probe(adapter,&addr_data,&foo_detect_client);
265 } 222 }
266 223
267For `sensors' drivers, use the i2c_detect function instead:
268
269 int foo_attach_adapter(struct i2c_adapter *adapter)
270 {
271 return i2c_detect(adapter,&addr_data,&foo_detect_client);
272 }
273
274Remember, structure `addr_data' is defined by the macros explained above, 224Remember, structure `addr_data' is defined by the macros explained above,
275so you do not have to define it yourself. 225so you do not have to define it yourself.
276 226
277The i2c_probe or i2c_detect function will call the foo_detect_client 227The i2c_probe function will call the foo_detect_client
278function only for those i2c addresses that actually have a device on 228function only for those i2c addresses that actually have a device on
279them (unless a `force' parameter was used). In addition, addresses that 229them (unless a `force' parameter was used). In addition, addresses that
280are already in use (by some other registered client) are skipped. 230are already in use (by some other registered client) are skipped.
@@ -283,19 +233,18 @@ are already in use (by some other registered client) are skipped.
283The detect client function 233The detect client function
284-------------------------- 234--------------------------
285 235
286The detect client function is called by i2c_probe or i2c_detect. 236The detect client function is called by i2c_probe. The `kind' parameter
287The `kind' parameter contains 0 if this call is due to a `force' 237contains -1 for a probed detection, 0 for a forced detection, or a positive
288parameter, and -1 otherwise (for i2c_detect, it contains 0 if 238number for a forced detection with a chip type forced.
289this call is due to the generic `force' parameter, and the chip type
290number if it is due to a specific `force' parameter).
291 239
292Below, some things are only needed if this is a `sensors' driver. Those 240Below, some things are only needed if this is a `sensors' driver. Those
293parts are between /* SENSORS ONLY START */ and /* SENSORS ONLY END */ 241parts are between /* SENSORS ONLY START */ and /* SENSORS ONLY END */
294markers. 242markers.
295 243
296This function should only return an error (any value != 0) if there is 244Returning an error different from -ENODEV in a detect function will cause
297some reason why no more detection should be done anymore. If the 245the detection to stop: other addresses and adapters won't be scanned.
298detection just fails for this address, return 0. 246This should only be done on fatal or internal errors, such as a memory
247shortage or i2c_attach_client failing.
299 248
300For now, you can ignore the `flags' parameter. It is there for future use. 249For now, you can ignore the `flags' parameter. It is there for future use.
301 250
@@ -320,11 +269,10 @@ For now, you can ignore the `flags' parameter. It is there for future use.
320 const char *type_name = ""; 269 const char *type_name = "";
321 int is_isa = i2c_is_isa_adapter(adapter); 270 int is_isa = i2c_is_isa_adapter(adapter);
322 271
323 if (is_isa) { 272 /* Do this only if the chip can additionally be found on the ISA bus
273 (hybrid chip). */
324 274
325 /* If this client can't be on the ISA bus at all, we can stop now 275 if (is_isa) {
326 (call `goto ERROR0'). But for kicks, we will assume it is all
327 right. */
328 276
329 /* Discard immediately if this ISA range is already used */ 277 /* Discard immediately if this ISA range is already used */
330 if (check_region(address,FOO_EXTENT)) 278 if (check_region(address,FOO_EXTENT))
@@ -495,15 +443,13 @@ much simpler than the attachment code, fortunately!
495 /* SENSORS ONLY END */ 443 /* SENSORS ONLY END */
496 444
497 /* Try to detach the client from i2c space */ 445 /* Try to detach the client from i2c space */
498 if ((err = i2c_detach_client(client))) { 446 if ((err = i2c_detach_client(client)))
499 printk("foo.o: Client deregistration failed, client not detached.\n");
500 return err; 447 return err;
501 }
502 448
503 /* SENSORS ONLY START */ 449 /* HYBRID SENSORS CHIP ONLY START */
504 if i2c_is_isa_client(client) 450 if i2c_is_isa_client(client)
505 release_region(client->addr,LM78_EXTENT); 451 release_region(client->addr,LM78_EXTENT);
506 /* SENSORS ONLY END */ 452 /* HYBRID SENSORS CHIP ONLY END */
507 453
508 kfree(client); /* Frees client data too, if allocated at the same time */ 454 kfree(client); /* Frees client data too, if allocated at the same time */
509 return 0; 455 return 0;