Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
170 | giacomo | 1 | /* ------------------------------------------------------------------------- */ |
2 | /* */ |
||
3 | /* i2c.h - definitions for the i2c-bus interface */ |
||
4 | /* */ |
||
5 | /* ------------------------------------------------------------------------- */ |
||
6 | /* Copyright (C) 1995-2000 Simon G. Vogl |
||
7 | |||
8 | This program is free software; you can redistribute it and/or modify |
||
9 | it under the terms of the GNU General Public License as published by |
||
10 | the Free Software Foundation; either version 2 of the License, or |
||
11 | (at your option) any later version. |
||
12 | |||
13 | This program is distributed in the hope that it will be useful, |
||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | GNU General Public License for more details. |
||
17 | |||
18 | You should have received a copy of the GNU General Public License |
||
19 | along with this program; if not, write to the Free Software |
||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
||
21 | /* ------------------------------------------------------------------------- */ |
||
22 | |||
23 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and |
||
24 | Frodo Looijaard <frodol@dds.nl> */ |
||
25 | |||
26 | /* $Id: i2c.h,v 1.1 2003-05-22 10:25:25 giacomo Exp $ */ |
||
27 | |||
28 | #ifndef I2C_H |
||
29 | #define I2C_H |
||
30 | |||
31 | #define I2C_DATE "20010830" |
||
32 | #define I2C_VERSION "2.6.1" |
||
33 | |||
34 | #include "drivers/i2c-id.h" /* id values of adapters et. al. */ |
||
35 | #include <sys/types.h> |
||
36 | #include "drivers/compbttv.h" |
||
37 | |||
38 | struct i2c_msg; |
||
39 | |||
40 | /* --- General options ------------------------------------------------ */ |
||
41 | |||
42 | #define I2C_ALGO_MAX 4 /* control memory consumption */ |
||
43 | #define I2C_ADAP_MAX 16 |
||
44 | #define I2C_DRIVER_MAX 16 |
||
45 | #define I2C_CLIENT_MAX 32 |
||
46 | #define I2C_DUMMY_MAX 4 |
||
47 | |||
48 | struct i2c_algorithm; |
||
49 | struct i2c_adapter; |
||
50 | struct i2c_client; |
||
51 | struct i2c_driver; |
||
52 | struct i2c_client_address_data; |
||
53 | union i2c_smbus_data; |
||
54 | |||
55 | |||
56 | /* |
||
57 | * The master routines are the ones normally used to transmit data to devices |
||
58 | * on a bus (or read from them). Apart from two basic transfer functions to |
||
59 | * transmit one message at a time, a more complex version can be used to |
||
60 | * transmit an arbitrary number of messages without interruption. |
||
61 | */ |
||
62 | extern int i2c_master_send(struct i2c_client *,const char* ,int); |
||
63 | extern int i2c_master_recv(struct i2c_client *,char* ,int); |
||
64 | |||
65 | /* Transfer num messages. |
||
66 | */ |
||
67 | extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],int num); |
||
68 | |||
69 | /* |
||
70 | * Some adapter types (i.e. PCF 8584 based ones) may support slave behaviuor. |
||
71 | * This is not tested/implemented yet and will change in the future. |
||
72 | */ |
||
73 | extern int i2c_slave_send(struct i2c_client *,char*,int); |
||
74 | extern int i2c_slave_recv(struct i2c_client *,char*,int); |
||
75 | |||
76 | |||
77 | |||
78 | /* This is the very generalized SMBus access routine. You probably do not |
||
79 | want to use this, though; one of the functions below may be much easier, |
||
80 | and probably just as fast. |
||
81 | Note that we use i2c_adapter here, because you do not need a specific |
||
82 | smbus adapter to call this function. */ |
||
83 | extern __s32 i2c_smbus_xfer (struct i2c_adapter * adapter, __u16 addr, |
||
84 | unsigned short flags, |
||
85 | char read_write, __u8 command, int size, |
||
86 | union i2c_smbus_data * data); |
||
87 | |||
88 | /* Now follow the 'nice' access routines. These also document the calling |
||
89 | conventions of smbus_access. */ |
||
90 | |||
91 | extern __s32 i2c_smbus_write_quick(struct i2c_client * client, __u8 value); |
||
92 | extern __s32 i2c_smbus_read_byte(struct i2c_client * client); |
||
93 | extern __s32 i2c_smbus_write_byte(struct i2c_client * client, __u8 value); |
||
94 | extern __s32 i2c_smbus_read_byte_data(struct i2c_client * client, __u8 command); |
||
95 | extern __s32 i2c_smbus_write_byte_data(struct i2c_client * client, |
||
96 | __u8 command, __u8 value); |
||
97 | extern __s32 i2c_smbus_read_word_data(struct i2c_client * client, __u8 command); |
||
98 | extern __s32 i2c_smbus_write_word_data(struct i2c_client * client, |
||
99 | __u8 command, __u16 value); |
||
100 | extern __s32 i2c_smbus_process_call(struct i2c_client * client, |
||
101 | __u8 command, __u16 value); |
||
102 | /* Returns the number of read bytes */ |
||
103 | extern __s32 i2c_smbus_read_block_data(struct i2c_client * client, |
||
104 | __u8 command, __u8 *values); |
||
105 | extern __s32 i2c_smbus_write_block_data(struct i2c_client * client, |
||
106 | __u8 command, __u8 length, |
||
107 | __u8 *values); |
||
108 | extern __s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, |
||
109 | __u8 command, __u8 length, |
||
110 | __u8 *values); |
||
111 | |||
112 | |||
113 | /* |
||
114 | * A driver is capable of handling one or more physical devices present on |
||
115 | * I2C adapters. This information is used to inform the driver of adapter |
||
116 | * events. |
||
117 | */ |
||
118 | |||
119 | struct i2c_driver { |
||
120 | char name[32]; |
||
121 | int id; |
||
122 | unsigned int flags; /* div., see below */ |
||
123 | |||
124 | /* Notifies the driver that a new bus has appeared. This routine |
||
125 | * can be used by the driver to test if the bus meets its conditions |
||
126 | * & seek for the presence of the chip(s) it supports. If found, it |
||
127 | * registers the client(s) that are on the bus to the i2c admin. via |
||
128 | * i2c_attach_client. |
||
129 | */ |
||
130 | int (*attach_adapter)(struct i2c_adapter *); |
||
131 | |||
132 | /* tells the driver that a client is about to be deleted & gives it |
||
133 | * the chance to remove its private data. Also, if the client struct |
||
134 | * has been dynamically allocated by the driver in the function above, |
||
135 | * it must be freed here. |
||
136 | */ |
||
137 | int (*detach_client)(struct i2c_client *); |
||
138 | |||
139 | /* a ioctl like command that can be used to perform specific functions |
||
140 | * with the device. |
||
141 | */ |
||
142 | int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); |
||
143 | |||
144 | /* These two are mainly used for bookkeeping & dynamic unloading of |
||
145 | * kernel modules. inc_use tells the driver that a client is being |
||
146 | * used by another module & that it should increase its ref. counter. |
||
147 | * dec_use is the inverse operation. |
||
148 | * NB: Make sure you have no circular dependencies, or else you get a |
||
149 | * deadlock when trying to unload the modules. |
||
150 | * You should use the i2c_{inc,dec}_use_client functions instead of |
||
151 | * calling this function directly. |
||
152 | */ |
||
153 | void (*inc_use)(struct i2c_client *client); |
||
154 | void (*dec_use)(struct i2c_client *client); |
||
155 | }; |
||
156 | |||
157 | /* |
||
158 | * i2c_client identifies a single device (i.e. chip) that is connected to an |
||
159 | * i2c bus. The behaviour is defined by the routines of the driver. This |
||
160 | * function is mainly used for lookup & other admin. functions. |
||
161 | */ |
||
162 | struct i2c_client { |
||
163 | char name[32]; |
||
164 | int id; |
||
165 | unsigned int flags; /* div., see below */ |
||
166 | unsigned int addr; /* chip address - NOTE: 7bit */ |
||
167 | /* addresses are stored in the */ |
||
168 | /* _LOWER_ 7 bits of this char */ |
||
169 | /* addr: unsigned int to make lm_sensors i2c-isa adapter work |
||
170 | more cleanly. It does not take any more memory space, due to |
||
171 | alignment considerations */ |
||
172 | struct i2c_adapter *adapter; /* the adapter we sit on */ |
||
173 | struct i2c_driver *driver; /* and our access routines */ |
||
174 | void *data; /* for the clients */ |
||
175 | int usage_count; /* How many accesses currently */ |
||
176 | /* to the client */ |
||
177 | }; |
||
178 | |||
179 | |||
180 | /* |
||
181 | * The following structs are for those who like to implement new bus drivers: |
||
182 | * i2c_algorithm is the interface to a class of hardware solutions which can |
||
183 | * be addressed using the same bus algorithms - i.e. bit-banging or the PCF8584 |
||
184 | * to name two of the most common. |
||
185 | */ |
||
186 | struct i2c_algorithm { |
||
187 | char name[32]; /* textual description */ |
||
188 | unsigned int id; |
||
189 | |||
190 | /* If an adapter algorithm can't to I2C-level access, set master_xfer |
||
191 | to NULL. If an adapter algorithm can do SMBus access, set |
||
192 | smbus_xfer. If set to NULL, the SMBus protocol is simulated |
||
193 | using common I2C messages */ |
||
194 | int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg msgs[], |
||
195 | int num); |
||
196 | int (*smbus_xfer) (struct i2c_adapter *adap, __u16 addr, |
||
197 | unsigned short flags, char read_write, |
||
198 | __u8 command, int size, union i2c_smbus_data * data); |
||
199 | |||
200 | /* --- these optional/future use for some adapter types.*/ |
||
201 | int (*slave_send)(struct i2c_adapter *,char*,int); |
||
202 | int (*slave_recv)(struct i2c_adapter *,char*,int); |
||
203 | |||
204 | /* --- ioctl like call to set div. parameters. */ |
||
205 | int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long); |
||
206 | |||
207 | /* To determine what the adapter supports */ |
||
208 | __u32 (*functionality) (struct i2c_adapter *); |
||
209 | }; |
||
210 | |||
211 | /* |
||
212 | * i2c_adapter is the structure used to identify a physical i2c bus along |
||
213 | * with the access algorithms necessary to access it. |
||
214 | */ |
||
215 | struct i2c_adapter { |
||
216 | char name[32]; /* some useful name to identify the adapter */ |
||
217 | unsigned int id;/* == is algo->id | hwdep.struct->id, */ |
||
218 | /* for registered values see below */ |
||
219 | struct i2c_algorithm *algo;/* the algorithm to access the bus */ |
||
220 | void *algo_data; |
||
221 | |||
222 | /* --- These may be NULL, but should increase the module use count */ |
||
223 | void (*inc_use)(struct i2c_adapter *); |
||
224 | void (*dec_use)(struct i2c_adapter *); |
||
225 | |||
226 | /* --- administration stuff. */ |
||
227 | int (*client_register)(struct i2c_client *); |
||
228 | int (*client_unregister)(struct i2c_client *); |
||
229 | |||
230 | void *data; /* private data for the adapter */ |
||
231 | /* some data fields that are used by all types */ |
||
232 | /* these data fields are readonly to the public */ |
||
233 | /* and can be set via the i2c_ioctl call */ |
||
234 | |||
235 | /* data fields that are valid for all devices */ |
||
236 | unsigned int flags;/* flags specifying div. data */ |
||
237 | |||
238 | struct i2c_client *clients[I2C_CLIENT_MAX]; |
||
239 | int client_count; |
||
240 | |||
241 | int timeout; |
||
242 | int retries; |
||
243 | |||
244 | }; |
||
245 | |||
246 | /*flags for the driver struct: */ |
||
247 | #define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */ |
||
248 | #define I2C_DF_DUMMY 0x02 /* do not connect any clients */ |
||
249 | |||
250 | /*flags for the client struct: */ |
||
251 | #define I2C_CLIENT_ALLOW_USE 0x01 /* Client allows access */ |
||
252 | #define I2C_CLIENT_ALLOW_MULTIPLE_USE 0x02 /* Allow multiple access-locks */ |
||
253 | /* on an i2c_client */ |
||
254 | |||
255 | /* i2c_client_address_data is the struct for holding default client |
||
256 | * addresses for a driver and for the parameters supplied on the |
||
257 | * command line |
||
258 | */ |
||
259 | struct i2c_client_address_data { |
||
260 | unsigned short *normal_i2c; |
||
261 | unsigned short *normal_i2c_range; |
||
262 | unsigned short *probe; |
||
263 | unsigned short *probe_range; |
||
264 | unsigned short *ignore; |
||
265 | unsigned short *ignore_range; |
||
266 | unsigned short *force; |
||
267 | }; |
||
268 | |||
269 | /* Internal numbers to terminate lists */ |
||
270 | #define I2C_CLIENT_END 0xfffe |
||
271 | |||
272 | /* The numbers to use to set I2C bus address */ |
||
273 | #define ANY_I2C_BUS 0xffff |
||
274 | |||
275 | /* The length of the option lists */ |
||
276 | #define I2C_CLIENT_MAX_OPTS 48 |
||
277 | |||
278 | |||
279 | /* ----- functions exported by i2c.o */ |
||
280 | |||
281 | /* administration... |
||
282 | */ |
||
283 | extern int i2c_add_adapter(struct i2c_adapter *); |
||
284 | extern int i2c_del_adapter(struct i2c_adapter *); |
||
285 | |||
286 | extern int i2c_add_driver(struct i2c_driver *); |
||
287 | extern int i2c_del_driver(struct i2c_driver *); |
||
288 | |||
289 | extern int i2c_attach_client(struct i2c_client *); |
||
290 | extern int i2c_detach_client(struct i2c_client *); |
||
291 | |||
292 | /* Only call these if you grab a resource that makes unloading the |
||
293 | client and the adapter it is on completely impossible. Like when a |
||
294 | /proc directory is entered. */ |
||
295 | extern void i2c_inc_use_client(struct i2c_client *); |
||
296 | extern void i2c_dec_use_client(struct i2c_client *); |
||
297 | |||
298 | /* New function: This is to get an i2c_client-struct for controlling the |
||
299 | client either by using i2c_control-function or having the |
||
300 | client-module export functions that can be used with the i2c_client |
||
301 | -struct. */ |
||
302 | extern struct i2c_client *i2c_get_client(int driver_id, int adapter_id, |
||
303 | struct i2c_client *prev); |
||
304 | |||
305 | /* Should be used with new function |
||
306 | extern struct i2c_client *i2c_get_client(int,int,struct i2c_client *); |
||
307 | to make sure that client-struct is valid and that it is okay to access |
||
308 | the i2c-client. |
||
309 | returns -EACCES if client doesn't allow use (default) |
||
310 | returns -EBUSY if client doesn't allow multiple use (default) and |
||
311 | usage_count >0 */ |
||
312 | extern int i2c_use_client(struct i2c_client *); |
||
313 | extern int i2c_release_client(struct i2c_client *); |
||
314 | |||
315 | /* returns -EBUSY if address has been taken, 0 if not. Note that the only |
||
316 | other place at which this is called is within i2c_attach_client; so |
||
317 | you can cheat by simply not registering. Not recommended, of course! */ |
||
318 | extern int i2c_check_addr (struct i2c_adapter *adapter, int addr); |
||
319 | |||
320 | /* Detect function. It iterates over all possible addresses itself. |
||
321 | * It will only call found_proc if some client is connected at the |
||
322 | * specific address (unless a 'force' matched); |
||
323 | */ |
||
324 | typedef int i2c_client_found_addr_proc (struct i2c_adapter *adapter, |
||
325 | int addr, unsigned short flags,int kind); |
||
326 | |||
327 | extern int i2c_probe(struct i2c_adapter *adapter, |
||
328 | struct i2c_client_address_data *address_data, |
||
329 | i2c_client_found_addr_proc *found_proc); |
||
330 | |||
331 | /* An ioctl like call to set div. parameters of the adapter. |
||
332 | */ |
||
333 | extern int i2c_control(struct i2c_client *,unsigned int, unsigned long); |
||
334 | |||
335 | /* This call returns a unique low identifier for each registered adapter, |
||
336 | * or -1 if the adapter was not registered. |
||
337 | */ |
||
338 | extern int i2c_adapter_id(struct i2c_adapter *adap); |
||
339 | |||
340 | |||
341 | |||
342 | /* Return the functionality mask */ |
||
343 | extern __u32 i2c_get_functionality (struct i2c_adapter *adap); |
||
344 | |||
345 | /* Return 1 if adapter supports everything we need, 0 if not. */ |
||
346 | extern int i2c_check_functionality (struct i2c_adapter *adap, __u32 func); |
||
347 | |||
348 | /* |
||
349 | * I2C Message - used for pure i2c transaction, also from /dev interface |
||
350 | */ |
||
351 | struct i2c_msg { |
||
352 | __u16 addr; /* slave address */ |
||
353 | unsigned short flags; |
||
354 | #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ |
||
355 | #define I2C_M_RD 0x01 |
||
356 | #define I2C_M_NOSTART 0x4000 |
||
357 | #define I2C_M_REV_DIR_ADDR 0x2000 |
||
358 | short len; /* msg length */ |
||
359 | char *buf; /* pointer to msg data */ |
||
360 | }; |
||
361 | |||
362 | /* To determine what functionality is present */ |
||
363 | |||
364 | #define I2C_FUNC_I2C 0x00000001 |
||
365 | #define I2C_FUNC_10BIT_ADDR 0x00000002 |
||
366 | #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART} */ |
||
367 | #define I2C_FUNC_SMBUS_QUICK 0x00010000 |
||
368 | #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 |
||
369 | #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 |
||
370 | #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 |
||
371 | #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 |
||
372 | #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 |
||
373 | #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 |
||
374 | #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 |
||
375 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 |
||
376 | #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 |
||
377 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* New I2C-like block */ |
||
378 | #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* transfer */ |
||
379 | |||
380 | #define I2C_FUNC_SMBUS_BYTE I2C_FUNC_SMBUS_READ_BYTE | \ |
||
381 | I2C_FUNC_SMBUS_WRITE_BYTE |
||
382 | #define I2C_FUNC_SMBUS_BYTE_DATA I2C_FUNC_SMBUS_READ_BYTE_DATA | \ |
||
383 | I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
||
384 | #define I2C_FUNC_SMBUS_WORD_DATA I2C_FUNC_SMBUS_READ_WORD_DATA | \ |
||
385 | I2C_FUNC_SMBUS_WRITE_WORD_DATA |
||
386 | #define I2C_FUNC_SMBUS_BLOCK_DATA I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ |
||
387 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA |
||
388 | #define I2C_FUNC_SMBUS_I2C_BLOCK I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ |
||
389 | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |
||
390 | |||
391 | #define I2C_FUNC_SMBUS_EMUL I2C_FUNC_SMBUS_QUICK | \ |
||
392 | I2C_FUNC_SMBUS_BYTE | \ |
||
393 | I2C_FUNC_SMBUS_BYTE_DATA | \ |
||
394 | I2C_FUNC_SMBUS_WORD_DATA | \ |
||
395 | I2C_FUNC_SMBUS_PROC_CALL | \ |
||
396 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA |
||
397 | |||
398 | /* |
||
399 | * Data for SMBus Messages |
||
400 | */ |
||
401 | union i2c_smbus_data { |
||
402 | __u8 byte; |
||
403 | __u16 word; |
||
404 | __u8 block[33]; /* block[0] is used for length */ |
||
405 | }; |
||
406 | |||
407 | /* smbus_access read or write markers */ |
||
408 | #define I2C_SMBUS_READ 1 |
||
409 | #define I2C_SMBUS_WRITE 0 |
||
410 | |||
411 | /* SMBus transaction types (size parameter in the above functions) |
||
412 | Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ |
||
413 | #define I2C_SMBUS_QUICK 0 |
||
414 | #define I2C_SMBUS_BYTE 1 |
||
415 | #define I2C_SMBUS_BYTE_DATA 2 |
||
416 | #define I2C_SMBUS_WORD_DATA 3 |
||
417 | #define I2C_SMBUS_PROC_CALL 4 |
||
418 | #define I2C_SMBUS_BLOCK_DATA 5 |
||
419 | #define I2C_SMBUS_I2C_BLOCK_DATA 6 |
||
420 | |||
421 | |||
422 | /* ----- commands for the ioctl like i2c_command call: |
||
423 | * note that additional calls are defined in the algorithm and hw |
||
424 | * dependent layers - these can be listed here, or see the |
||
425 | * corresponding header files. |
||
426 | */ |
||
427 | /* -> bit-adapter specific ioctls */ |
||
428 | #define I2C_RETRIES 0x0701 /* number of times a device address */ |
||
429 | /* should be polled when not */ |
||
430 | /* acknowledging */ |
||
431 | #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ |
||
432 | |||
433 | |||
434 | /* this is for i2c-dev.c */ |
||
435 | #define I2C_SLAVE 0x0703 /* Change slave address */ |
||
436 | /* Attn.: Slave address is 7 or 10 bits */ |
||
437 | #define I2C_SLAVE_FORCE 0x0706 /* Change slave address */ |
||
438 | /* Attn.: Slave address is 7 or 10 bits */ |
||
439 | /* This changes the address, even if it */ |
||
440 | /* is already taken! */ |
||
441 | #define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ |
||
442 | |||
443 | #define I2C_FUNCS 0x0705 /* Get the adapter functionality */ |
||
444 | #define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/ |
||
445 | #if 0 |
||
446 | #define I2C_ACK_TEST 0x0710 /* See if a slave is at a specific address */ |
||
447 | #endif |
||
448 | |||
449 | #define I2C_SMBUS 0x0720 /* SMBus-level access */ |
||
450 | |||
451 | /* ... algo-bit.c recognizes */ |
||
452 | #define I2C_UDELAY 0x0705 /* set delay in microsecs between each */ |
||
453 | /* written byte (except address) */ |
||
454 | #define I2C_MDELAY 0x0706 /* millisec delay between written bytes */ |
||
455 | |||
456 | /* ----- I2C-DEV: char device interface stuff ------------------------- */ |
||
457 | |||
458 | #define I2C_MAJOR 89 /* Device major number */ |
||
459 | |||
460 | # ifndef NULL |
||
461 | # define NULL ( (void *) 0 ) |
||
462 | # endif |
||
463 | |||
464 | # ifndef ENODEV |
||
465 | # include <asm/errno.h> |
||
466 | # endif |
||
467 | |||
468 | /* These defines are used for probing i2c client addresses */ |
||
469 | /* Default fill of many variables */ |
||
470 | #define I2C_CLIENT_DEFAULTS {I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
471 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
472 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
473 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
474 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
475 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
476 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
477 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
478 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
479 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
480 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
481 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
482 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
483 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
484 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
||
485 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END} |
||
486 | |||
487 | /* This is ugly. We need to evaluate I2C_CLIENT_MAX_OPTS before it is |
||
488 | stringified */ |
||
489 | #define I2C_CLIENT_MODPARM_AUX1(x) "1-" #x "h" |
||
490 | #define I2C_CLIENT_MODPARM_AUX(x) I2C_CLIENT_MODPARM_AUX1(x) |
||
491 | #define I2C_CLIENT_MODPARM I2C_CLIENT_MODPARM_AUX(I2C_CLIENT_MAX_OPTS) |
||
492 | |||
493 | /* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the |
||
494 | module header */ |
||
495 | |||
496 | #define I2C_CLIENT_MODULE_PARM(var,desc) \ |
||
497 | static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \ |
||
498 | MODULE_PARM(var,I2C_CLIENT_MODPARM); \ |
||
499 | MODULE_PARM_DESC(var,desc) |
||
500 | |||
501 | /* This is the one you want to use in your own modules */ |
||
502 | #define I2C_CLIENT_INSMOD \ |
||
503 | I2C_CLIENT_MODULE_PARM(probe, \ |
||
504 | "List of adapter,address pairs to scan additionally"); \ |
||
505 | I2C_CLIENT_MODULE_PARM(probe_range, \ |
||
506 | "List of adapter,start-addr,end-addr triples to scan " \ |
||
507 | "additionally"); \ |
||
508 | I2C_CLIENT_MODULE_PARM(ignore, \ |
||
509 | "List of adapter,address pairs not to scan"); \ |
||
510 | I2C_CLIENT_MODULE_PARM(ignore_range, \ |
||
511 | "List of adapter,start-addr,end-addr triples not to " \ |
||
512 | "scan"); \ |
||
513 | I2C_CLIENT_MODULE_PARM(force, \ |
||
514 | "List of adapter,address pairs to boldly assume " \ |
||
515 | "to be present"); \ |
||
516 | static struct i2c_client_address_data addr_data = \ |
||
517 | {normal_i2c, normal_i2c_range, \ |
||
518 | probe, probe_range, \ |
||
519 | ignore, ignore_range, \ |
||
520 | force} |
||
521 | |||
522 | /* Detect whether we are on the isa bus. If this returns true, all i2c |
||
523 | access will fail! */ |
||
524 | #define i2c_is_isa_client(clientptr) \ |
||
525 | ((clientptr)->adapter->algo->id == I2C_ALGO_ISA) |
||
526 | #define i2c_is_isa_adapter(adapptr) \ |
||
527 | ((adapptr)->algo->id == I2C_ALGO_ISA) |
||
528 | |||
529 | #endif /* I2C_H */ |