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 detect information.
26 Force variables overrule all other variables; they force a detection on
27 that place. If a specific chip is given, the module blindly assumes this
28 chip type is present; if a general force (kind == 0) is given, the module
29 will still try to figure out what type of chip is present. This is useful
30 if for some reasons the detect for SMBus address space filled fails.
31 probe: insmod parameter. Initialize this list with I2C_CLIENT_END values.
32 A list of pairs. The first value is a bus number (ANY_I2C_BUS for any
33 I2C bus), the second is the address.
34 kind: The kind of chip. 0 equals any chip.
36 struct i2c_force_data {
37 unsigned short *force;
41 /* A structure containing the detect information.
42 normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_END.
43 A list of I2C addresses which should normally be examined.
44 probe: insmod parameter. Initialize this list with I2C_CLIENT_END values.
45 A list of pairs. The first value is a bus number (ANY_I2C_BUS for any
46 I2C bus), the second is the address. These addresses are also probed,
47 as if they were in the 'normal' list.
48 ignore: insmod parameter. Initialize this list with I2C_CLIENT_END values.
49 A list of pairs. The first value is a bus number (ANY_I2C_BUS for any
50 I2C bus), the second is the I2C address. These addresses are never
51 probed. This parameter overrules 'normal' and probe', but not the
53 force_data: insmod parameters. A list, ending with an element of which
54 the force field is NULL.
56 struct i2c_address_data {
57 unsigned short *normal_i2c;
58 unsigned short *probe;
59 unsigned short *ignore;
60 struct i2c_force_data *forces;
63 #define SENSORS_MODULE_PARM_FORCE(name) \
64 I2C_CLIENT_MODULE_PARM(force_ ## name, \
65 "List of adapter,address pairs which are unquestionably" \
66 " assumed to contain a `" # name "' chip")
69 /* This defines several insmod variables, and the addr_data structure */
70 #define SENSORS_INSMOD \
71 I2C_CLIENT_MODULE_PARM(probe, \
72 "List of adapter,address pairs to scan additionally"); \
73 I2C_CLIENT_MODULE_PARM(ignore, \
74 "List of adapter,address pairs not to scan"); \
75 static struct i2c_address_data addr_data = { \
76 .normal_i2c = normal_i2c, \
82 /* The following functions create an enum with the chip names as elements.
83 The first element of the enum is any_chip. These are the only macros
84 a module will want to use. */
86 #define SENSORS_INSMOD_0 \
87 enum chips { any_chip }; \
88 I2C_CLIENT_MODULE_PARM(force, \
89 "List of adapter,address pairs to boldly assume " \
91 static struct i2c_force_data forces[] = {{force,any_chip},{NULL}}; \
94 #define SENSORS_INSMOD_1(chip1) \
95 enum chips { any_chip, chip1 }; \
96 I2C_CLIENT_MODULE_PARM(force, \
97 "List of adapter,address pairs to boldly assume " \
99 SENSORS_MODULE_PARM_FORCE(chip1); \
100 static struct i2c_force_data forces[] = {{force,any_chip},\
101 {force_ ## chip1,chip1}, \
105 #define SENSORS_INSMOD_2(chip1,chip2) \
106 enum chips { any_chip, chip1, chip2 }; \
107 I2C_CLIENT_MODULE_PARM(force, \
108 "List of adapter,address pairs to boldly assume " \
110 SENSORS_MODULE_PARM_FORCE(chip1); \
111 SENSORS_MODULE_PARM_FORCE(chip2); \
112 static struct i2c_force_data forces[] = {{force,any_chip}, \
113 {force_ ## chip1,chip1}, \
114 {force_ ## chip2,chip2}, \
118 #define SENSORS_INSMOD_3(chip1,chip2,chip3) \
119 enum chips { any_chip, chip1, chip2, chip3 }; \
120 I2C_CLIENT_MODULE_PARM(force, \
121 "List of adapter,address pairs to boldly assume " \
123 SENSORS_MODULE_PARM_FORCE(chip1); \
124 SENSORS_MODULE_PARM_FORCE(chip2); \
125 SENSORS_MODULE_PARM_FORCE(chip3); \
126 static struct i2c_force_data forces[] = {{force,any_chip}, \
127 {force_ ## chip1,chip1}, \
128 {force_ ## chip2,chip2}, \
129 {force_ ## chip3,chip3}, \
133 #define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \
134 enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
135 I2C_CLIENT_MODULE_PARM(force, \
136 "List of adapter,address pairs to boldly assume " \
138 SENSORS_MODULE_PARM_FORCE(chip1); \
139 SENSORS_MODULE_PARM_FORCE(chip2); \
140 SENSORS_MODULE_PARM_FORCE(chip3); \
141 SENSORS_MODULE_PARM_FORCE(chip4); \
142 static struct i2c_force_data forces[] = {{force,any_chip}, \
143 {force_ ## chip1,chip1}, \
144 {force_ ## chip2,chip2}, \
145 {force_ ## chip3,chip3}, \
146 {force_ ## chip4,chip4}, \
150 #define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \
151 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
152 I2C_CLIENT_MODULE_PARM(force, \
153 "List of adapter,address pairs to boldly assume " \
155 SENSORS_MODULE_PARM_FORCE(chip1); \
156 SENSORS_MODULE_PARM_FORCE(chip2); \
157 SENSORS_MODULE_PARM_FORCE(chip3); \
158 SENSORS_MODULE_PARM_FORCE(chip4); \
159 SENSORS_MODULE_PARM_FORCE(chip5); \
160 static struct i2c_force_data forces[] = {{force,any_chip}, \
161 {force_ ## chip1,chip1}, \
162 {force_ ## chip2,chip2}, \
163 {force_ ## chip3,chip3}, \
164 {force_ ## chip4,chip4}, \
165 {force_ ## chip5,chip5}, \
169 #define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \
170 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
171 I2C_CLIENT_MODULE_PARM(force, \
172 "List of adapter,address pairs to boldly assume " \
174 SENSORS_MODULE_PARM_FORCE(chip1); \
175 SENSORS_MODULE_PARM_FORCE(chip2); \
176 SENSORS_MODULE_PARM_FORCE(chip3); \
177 SENSORS_MODULE_PARM_FORCE(chip4); \
178 SENSORS_MODULE_PARM_FORCE(chip5); \
179 SENSORS_MODULE_PARM_FORCE(chip6); \
180 static struct i2c_force_data forces[] = {{force,any_chip}, \
181 {force_ ## chip1,chip1}, \
182 {force_ ## chip2,chip2}, \
183 {force_ ## chip3,chip3}, \
184 {force_ ## chip4,chip4}, \
185 {force_ ## chip5,chip5}, \
186 {force_ ## chip6,chip6}, \
190 #define SENSORS_INSMOD_7(chip1,chip2,chip3,chip4,chip5,chip6,chip7) \
191 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7 }; \
192 I2C_CLIENT_MODULE_PARM(force, \
193 "List of adapter,address pairs to boldly assume " \
195 SENSORS_MODULE_PARM_FORCE(chip1); \
196 SENSORS_MODULE_PARM_FORCE(chip2); \
197 SENSORS_MODULE_PARM_FORCE(chip3); \
198 SENSORS_MODULE_PARM_FORCE(chip4); \
199 SENSORS_MODULE_PARM_FORCE(chip5); \
200 SENSORS_MODULE_PARM_FORCE(chip6); \
201 SENSORS_MODULE_PARM_FORCE(chip7); \
202 static struct i2c_force_data forces[] = {{force,any_chip}, \
203 {force_ ## chip1,chip1}, \
204 {force_ ## chip2,chip2}, \
205 {force_ ## chip3,chip3}, \
206 {force_ ## chip4,chip4}, \
207 {force_ ## chip5,chip5}, \
208 {force_ ## chip6,chip6}, \
209 {force_ ## chip7,chip7}, \
213 #define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \
214 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8 }; \
215 I2C_CLIENT_MODULE_PARM(force, \
216 "List of adapter,address pairs to boldly assume " \
218 SENSORS_MODULE_PARM_FORCE(chip1); \
219 SENSORS_MODULE_PARM_FORCE(chip2); \
220 SENSORS_MODULE_PARM_FORCE(chip3); \
221 SENSORS_MODULE_PARM_FORCE(chip4); \
222 SENSORS_MODULE_PARM_FORCE(chip5); \
223 SENSORS_MODULE_PARM_FORCE(chip6); \
224 SENSORS_MODULE_PARM_FORCE(chip7); \
225 SENSORS_MODULE_PARM_FORCE(chip8); \
226 static struct i2c_force_data forces[] = {{force,any_chip}, \
227 {force_ ## chip1,chip1}, \
228 {force_ ## chip2,chip2}, \
229 {force_ ## chip3,chip3}, \
230 {force_ ## chip4,chip4}, \
231 {force_ ## chip5,chip5}, \
232 {force_ ## chip6,chip6}, \
233 {force_ ## chip7,chip7}, \
234 {force_ ## chip8,chip8}, \
238 /* Detect function. It iterates over all possible addresses itself. For
239 SMBus addresses, it will only call found_proc if some client is connected
240 to the SMBus (unless a 'force' matched). */
241 extern int i2c_detect(struct i2c_adapter *adapter,
242 struct i2c_address_data *address_data,
243 int (*found_proc) (struct i2c_adapter *, int, int));
246 /* This macro is used to scale user-input to sensible values in almost all
248 static inline int SENSORS_LIMIT(long value, long low, long high)
252 else if (value > high)
257 #endif /* def _LINUX_I2C_SENSOR_H */