2 i2c-sensor.h - Part of the i2c package
3 was originally sensors.h - Part of lm_sensors, Linux kernel modules
4 for hardware monitoring
5 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
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.
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.
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.
22 #ifndef _LINUX_I2C_SENSOR_H
23 #define _LINUX_I2C_SENSOR_H
25 /* A structure containing the detect information.
26 normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_END.
27 A list of I2C addresses which should normally be examined.
28 probe: insmod parameter. Initialize this list with I2C_CLIENT_END values.
29 A list of pairs. The first value is a bus number (ANY_I2C_BUS for any
30 I2C bus), the second is the address. These addresses are also probed,
31 as if they were in the 'normal' list.
32 ignore: insmod parameter. Initialize this list with I2C_CLIENT_END values.
33 A list of pairs. The first value is a bus number (ANY_I2C_BUS for any
34 I2C bus), the second is the I2C address. These addresses are never
35 probed. This parameter overrules 'normal' and probe', but not the
37 forces: insmod parameters. A list, ending with a NULL element.
38 Force variables overrule all other variables; they force a detection on
39 that place. If a specific chip is given, the module blindly assumes this
40 chip type is present; if a general force (kind == 0) is given, the module
41 will still try to figure out what type of chip is present. This is useful
42 if for some reasons the detect for SMBus address space filled fails.
44 struct i2c_address_data {
45 unsigned short *normal_i2c;
46 unsigned short *probe;
47 unsigned short *ignore;
48 unsigned short **forces;
51 #define SENSORS_MODULE_PARM_FORCE(name) \
52 I2C_CLIENT_MODULE_PARM(force_ ## name, \
53 "List of adapter,address pairs which are unquestionably" \
54 " assumed to contain a `" # name "' chip")
57 /* This defines several insmod variables, and the addr_data structure */
58 #define SENSORS_INSMOD \
59 I2C_CLIENT_MODULE_PARM(probe, \
60 "List of adapter,address pairs to scan additionally"); \
61 I2C_CLIENT_MODULE_PARM(ignore, \
62 "List of adapter,address pairs not to scan"); \
63 static struct i2c_address_data addr_data = { \
64 .normal_i2c = normal_i2c, \
70 /* The following functions create an enum with the chip names as elements.
71 The first element of the enum is any_chip. These are the only macros
72 a module will want to use. */
74 #define SENSORS_INSMOD_0 \
75 enum chips { any_chip }; \
76 I2C_CLIENT_MODULE_PARM(force, \
77 "List of adapter,address pairs to boldly assume " \
79 static unsigned short *forces[] = { force, \
83 #define SENSORS_INSMOD_1(chip1) \
84 enum chips { any_chip, chip1 }; \
85 I2C_CLIENT_MODULE_PARM(force, \
86 "List of adapter,address pairs to boldly assume " \
88 SENSORS_MODULE_PARM_FORCE(chip1); \
89 static unsigned short *forces[] = { force, \
94 #define SENSORS_INSMOD_2(chip1,chip2) \
95 enum chips { any_chip, chip1, chip2 }; \
96 I2C_CLIENT_MODULE_PARM(force, \
97 "List of adapter,address pairs to boldly assume " \
99 SENSORS_MODULE_PARM_FORCE(chip1); \
100 SENSORS_MODULE_PARM_FORCE(chip2); \
101 static unsigned short *forces[] = { force, \
107 #define SENSORS_INSMOD_3(chip1,chip2,chip3) \
108 enum chips { any_chip, chip1, chip2, chip3 }; \
109 I2C_CLIENT_MODULE_PARM(force, \
110 "List of adapter,address pairs to boldly assume " \
112 SENSORS_MODULE_PARM_FORCE(chip1); \
113 SENSORS_MODULE_PARM_FORCE(chip2); \
114 SENSORS_MODULE_PARM_FORCE(chip3); \
115 static unsigned short *forces[] = { force, \
122 #define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \
123 enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
124 I2C_CLIENT_MODULE_PARM(force, \
125 "List of adapter,address pairs to boldly assume " \
127 SENSORS_MODULE_PARM_FORCE(chip1); \
128 SENSORS_MODULE_PARM_FORCE(chip2); \
129 SENSORS_MODULE_PARM_FORCE(chip3); \
130 SENSORS_MODULE_PARM_FORCE(chip4); \
131 static unsigned short *forces[] = { force, \
139 #define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \
140 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
141 I2C_CLIENT_MODULE_PARM(force, \
142 "List of adapter,address pairs to boldly assume " \
144 SENSORS_MODULE_PARM_FORCE(chip1); \
145 SENSORS_MODULE_PARM_FORCE(chip2); \
146 SENSORS_MODULE_PARM_FORCE(chip3); \
147 SENSORS_MODULE_PARM_FORCE(chip4); \
148 SENSORS_MODULE_PARM_FORCE(chip5); \
149 static unsigned short *forces[] = { force, \
158 #define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \
159 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
160 I2C_CLIENT_MODULE_PARM(force, \
161 "List of adapter,address pairs to boldly assume " \
163 SENSORS_MODULE_PARM_FORCE(chip1); \
164 SENSORS_MODULE_PARM_FORCE(chip2); \
165 SENSORS_MODULE_PARM_FORCE(chip3); \
166 SENSORS_MODULE_PARM_FORCE(chip4); \
167 SENSORS_MODULE_PARM_FORCE(chip5); \
168 SENSORS_MODULE_PARM_FORCE(chip6); \
169 static unsigned short *forces[] = { force, \
179 #define SENSORS_INSMOD_7(chip1,chip2,chip3,chip4,chip5,chip6,chip7) \
180 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7 }; \
181 I2C_CLIENT_MODULE_PARM(force, \
182 "List of adapter,address pairs to boldly assume " \
184 SENSORS_MODULE_PARM_FORCE(chip1); \
185 SENSORS_MODULE_PARM_FORCE(chip2); \
186 SENSORS_MODULE_PARM_FORCE(chip3); \
187 SENSORS_MODULE_PARM_FORCE(chip4); \
188 SENSORS_MODULE_PARM_FORCE(chip5); \
189 SENSORS_MODULE_PARM_FORCE(chip6); \
190 SENSORS_MODULE_PARM_FORCE(chip7); \
191 static unsigned short *forces[] = { force, \
202 #define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \
203 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8 }; \
204 I2C_CLIENT_MODULE_PARM(force, \
205 "List of adapter,address pairs to boldly assume " \
207 SENSORS_MODULE_PARM_FORCE(chip1); \
208 SENSORS_MODULE_PARM_FORCE(chip2); \
209 SENSORS_MODULE_PARM_FORCE(chip3); \
210 SENSORS_MODULE_PARM_FORCE(chip4); \
211 SENSORS_MODULE_PARM_FORCE(chip5); \
212 SENSORS_MODULE_PARM_FORCE(chip6); \
213 SENSORS_MODULE_PARM_FORCE(chip7); \
214 SENSORS_MODULE_PARM_FORCE(chip8); \
215 static unsigned short *forces[] = { force, \
227 /* Detect function. It iterates over all possible addresses itself. For
228 SMBus addresses, it will only call found_proc if some client is connected
229 to the SMBus (unless a 'force' matched). */
230 extern int i2c_detect(struct i2c_adapter *adapter,
231 struct i2c_address_data *address_data,
232 int (*found_proc) (struct i2c_adapter *, int, int));
234 #endif /* def _LINUX_I2C_SENSOR_H */