1 /* ------------------------------------------------------------------------- */
3 /* i2c.h - definitions for the i2c-bus interface */
5 /* ------------------------------------------------------------------------- */
6 /* Copyright (C) 1995-2000 Simon G. Vogl
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.
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.
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 /* ------------------------------------------------------------------------- */
23 /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and
24 Frodo Looijaard <frodol@dds.nl> */
29 #include <linux/module.h>
30 #include <linux/types.h>
31 #include <linux/i2c-id.h>
32 #include <linux/device.h> /* for struct device */
33 #include <asm/semaphore.h>
35 /* --- For i2c-isa ---------------------------------------------------- */
37 extern void i2c_adapter_dev_release(struct device *dev);
38 extern struct device_driver i2c_adapter_driver;
39 extern struct class i2c_adapter_class;
40 extern struct bus_type i2c_bus_type;
42 /* --- General options ------------------------------------------------ */
52 * The master routines are the ones normally used to transmit data to devices
53 * on a bus (or read from them). Apart from two basic transfer functions to
54 * transmit one message at a time, a more complex version can be used to
55 * transmit an arbitrary number of messages without interruption.
57 extern int i2c_master_send(struct i2c_client *,const char* ,int);
58 extern int i2c_master_recv(struct i2c_client *,char* ,int);
60 /* Transfer num messages.
62 extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
65 * Some adapter types (i.e. PCF 8584 based ones) may support slave behaviuor.
66 * This is not tested/implemented yet and will change in the future.
68 extern int i2c_slave_send(struct i2c_client *,char*,int);
69 extern int i2c_slave_recv(struct i2c_client *,char*,int);
73 /* This is the very generalized SMBus access routine. You probably do not
74 want to use this, though; one of the functions below may be much easier,
75 and probably just as fast.
76 Note that we use i2c_adapter here, because you do not need a specific
77 smbus adapter to call this function. */
78 extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr,
80 char read_write, u8 command, int size,
81 union i2c_smbus_data * data);
83 /* Now follow the 'nice' access routines. These also document the calling
84 conventions of smbus_access. */
86 extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value);
87 extern s32 i2c_smbus_read_byte(struct i2c_client * client);
88 extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value);
89 extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command);
90 extern s32 i2c_smbus_write_byte_data(struct i2c_client * client,
91 u8 command, u8 value);
92 extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command);
93 extern s32 i2c_smbus_write_word_data(struct i2c_client * client,
94 u8 command, u16 value);
95 extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
96 u8 command, u8 length,
98 /* Returns the number of read bytes */
99 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
100 u8 command, u8 *values);
103 * A driver is capable of handling one or more physical devices present on
104 * I2C adapters. This information is used to inform the driver of adapter
109 struct module *owner;
113 unsigned int flags; /* div., see below */
115 /* Notifies the driver that a new bus has appeared. This routine
116 * can be used by the driver to test if the bus meets its conditions
117 * & seek for the presence of the chip(s) it supports. If found, it
118 * registers the client(s) that are on the bus to the i2c admin. via
121 int (*attach_adapter)(struct i2c_adapter *);
122 int (*detach_adapter)(struct i2c_adapter *);
124 /* tells the driver that a client is about to be deleted & gives it
125 * the chance to remove its private data. Also, if the client struct
126 * has been dynamically allocated by the driver in the function above,
127 * it must be freed here.
129 int (*detach_client)(struct i2c_client *);
131 /* a ioctl like command that can be used to perform specific functions
134 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
136 struct device_driver driver;
137 struct list_head list;
139 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
141 #define I2C_NAME_SIZE 50
144 * i2c_client identifies a single device (i.e. chip) that is connected to an
145 * i2c bus. The behaviour is defined by the routines of the driver. This
146 * function is mainly used for lookup & other admin. functions.
149 unsigned int flags; /* div., see below */
150 unsigned short addr; /* chip address - NOTE: 7bit */
151 /* addresses are stored in the */
153 struct i2c_adapter *adapter; /* the adapter we sit on */
154 struct i2c_driver *driver; /* and our access routines */
155 int usage_count; /* How many accesses currently */
157 struct device dev; /* the device structure */
158 struct list_head list;
159 char name[I2C_NAME_SIZE];
160 struct completion released;
162 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
164 static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
166 return to_i2c_client(container_of(kobj, struct device, kobj));
169 static inline void *i2c_get_clientdata (struct i2c_client *dev)
171 return dev_get_drvdata (&dev->dev);
174 static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
176 dev_set_drvdata (&dev->dev, data);
180 * The following structs are for those who like to implement new bus drivers:
181 * i2c_algorithm is the interface to a class of hardware solutions which can
182 * be addressed using the same bus algorithms - i.e. bit-banging or the PCF8584
183 * to name two of the most common.
185 struct i2c_algorithm {
186 /* If an adapter algorithm can't do I2C-level access, set master_xfer
187 to NULL. If an adapter algorithm can do SMBus access, set
188 smbus_xfer. If set to NULL, the SMBus protocol is simulated
189 using common I2C messages */
190 int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs,
192 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,
193 unsigned short flags, char read_write,
194 u8 command, int size, union i2c_smbus_data * data);
196 /* --- these optional/future use for some adapter types.*/
197 int (*slave_send)(struct i2c_adapter *,char*,int);
198 int (*slave_recv)(struct i2c_adapter *,char*,int);
200 /* --- ioctl like call to set div. parameters. */
201 int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long);
203 /* To determine what the adapter supports */
204 u32 (*functionality) (struct i2c_adapter *);
208 * i2c_adapter is the structure used to identify a physical i2c bus along
209 * with the access algorithms necessary to access it.
212 struct module *owner;
215 struct i2c_algorithm *algo;/* the algorithm to access the bus */
218 /* --- administration stuff. */
219 int (*client_register)(struct i2c_client *);
220 int (*client_unregister)(struct i2c_client *);
222 /* data fields that are valid for all devices */
223 struct semaphore bus_lock;
224 struct semaphore clist_lock;
228 struct device dev; /* the adapter device */
229 struct class_device class_dev; /* the class device */
232 struct list_head clients;
233 struct list_head list;
234 char name[I2C_NAME_SIZE];
235 struct completion dev_released;
236 struct completion class_dev_released;
238 #define dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
239 #define class_dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter, class_dev)
241 static inline void *i2c_get_adapdata (struct i2c_adapter *dev)
243 return dev_get_drvdata (&dev->dev);
246 static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
248 dev_set_drvdata (&dev->dev, data);
251 /*flags for the driver struct: */
252 #define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */
254 /* this flag is gone -- there is a (optional) driver->detach_adapter
255 * callback now which can be used instead */
256 # define I2C_DF_DUMMY 0x02
259 /*flags for the client struct: */
260 #define I2C_CLIENT_ALLOW_USE 0x01 /* Client allows access */
261 #define I2C_CLIENT_ALLOW_MULTIPLE_USE 0x02 /* Allow multiple access-locks */
262 /* on an i2c_client */
263 #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */
264 #define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */
265 /* Must equal I2C_M_TEN below */
267 /* i2c adapter classes (bitmask) */
268 #define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */
269 #define I2C_CLASS_TV_ANALOG (1<<1) /* bttv + friends */
270 #define I2C_CLASS_TV_DIGITAL (1<<2) /* dvb cards */
271 #define I2C_CLASS_DDC (1<<3) /* i2c-matroxfb ? */
272 #define I2C_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */
273 #define I2C_CLASS_CAM_DIGITAL (1<<5) /* most webcams */
274 #define I2C_CLASS_SOUND (1<<6) /* sound devices */
275 #define I2C_CLASS_ALL (UINT_MAX) /* all of the above */
277 /* i2c_client_address_data is the struct for holding default client
278 * addresses for a driver and for the parameters supplied on the
281 struct i2c_client_address_data {
282 unsigned short *normal_i2c;
283 unsigned short *probe;
284 unsigned short *ignore;
285 unsigned short **forces;
288 /* Internal numbers to terminate lists */
289 #define I2C_CLIENT_END 0xfffeU
291 /* The numbers to use to set I2C bus address */
292 #define ANY_I2C_BUS 0xffff
293 #define ANY_I2C_ISA_BUS 9191
296 /* ----- functions exported by i2c.o */
300 extern int i2c_add_adapter(struct i2c_adapter *);
301 extern int i2c_del_adapter(struct i2c_adapter *);
303 extern int i2c_add_driver(struct i2c_driver *);
304 extern int i2c_del_driver(struct i2c_driver *);
306 extern int i2c_attach_client(struct i2c_client *);
307 extern int i2c_detach_client(struct i2c_client *);
309 /* New function: This is to get an i2c_client-struct for controlling the
310 client either by using i2c_control-function or having the
311 client-module export functions that can be used with the i2c_client
313 extern struct i2c_client *i2c_get_client(int driver_id, int adapter_id,
314 struct i2c_client *prev);
316 /* Should be used with new function
317 extern struct i2c_client *i2c_get_client(int,int,struct i2c_client *);
318 to make sure that client-struct is valid and that it is okay to access
320 returns -EACCES if client doesn't allow use (default)
321 returns -EBUSY if client doesn't allow multiple use (default) and
323 extern int i2c_use_client(struct i2c_client *);
324 extern int i2c_release_client(struct i2c_client *);
326 /* call the i2c_client->command() of all attached clients with
327 * the given arguments */
328 extern void i2c_clients_command(struct i2c_adapter *adap,
329 unsigned int cmd, void *arg);
331 /* returns -EBUSY if address has been taken, 0 if not. Note that the only
332 other place at which this is called is within i2c_attach_client; so
333 you can cheat by simply not registering. Not recommended, of course! */
334 extern int i2c_check_addr (struct i2c_adapter *adapter, int addr);
336 /* Detect function. It iterates over all possible addresses itself.
337 * It will only call found_proc if some client is connected at the
338 * specific address (unless a 'force' matched);
340 extern int i2c_probe(struct i2c_adapter *adapter,
341 struct i2c_client_address_data *address_data,
342 int (*found_proc) (struct i2c_adapter *, int, int));
344 /* An ioctl like call to set div. parameters of the adapter.
346 extern int i2c_control(struct i2c_client *,unsigned int, unsigned long);
348 extern struct i2c_adapter* i2c_get_adapter(int id);
349 extern void i2c_put_adapter(struct i2c_adapter *adap);
352 /* Return the functionality mask */
353 static inline u32 i2c_get_functionality(struct i2c_adapter *adap)
355 return adap->algo->functionality(adap);
358 /* Return 1 if adapter supports everything we need, 0 if not. */
359 static inline int i2c_check_functionality(struct i2c_adapter *adap, u32 func)
361 return (func & i2c_get_functionality(adap)) == func;
364 /* Return id number for a specific adapter */
365 static inline int i2c_adapter_id(struct i2c_adapter *adap)
371 * I2C Message - used for pure i2c transaction, also from /dev interface
374 __u16 addr; /* slave address */
376 #define I2C_M_TEN 0x10 /* we have a ten bit chip address */
377 #define I2C_M_RD 0x01
378 #define I2C_M_NOSTART 0x4000
379 #define I2C_M_REV_DIR_ADDR 0x2000
380 #define I2C_M_IGNORE_NAK 0x1000
381 #define I2C_M_NO_RD_ACK 0x0800
382 __u16 len; /* msg length */
383 __u8 *buf; /* pointer to msg data */
386 /* To determine what functionality is present */
388 #define I2C_FUNC_I2C 0x00000001
389 #define I2C_FUNC_10BIT_ADDR 0x00000002
390 #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
391 #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */
392 #define I2C_FUNC_SMBUS_READ_WORD_DATA_PEC 0x00000800 /* SMBus 2.0 */
393 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC 0x00001000 /* SMBus 2.0 */
394 #define I2C_FUNC_SMBUS_PROC_CALL_PEC 0x00002000 /* SMBus 2.0 */
395 #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL_PEC 0x00004000 /* SMBus 2.0 */
396 #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
397 #define I2C_FUNC_SMBUS_QUICK 0x00010000
398 #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
399 #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
400 #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
401 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
402 #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
403 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
404 #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
405 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
406 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
407 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
408 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
409 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */
410 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */
411 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC 0x40000000 /* SMBus 2.0 */
412 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC 0x80000000 /* SMBus 2.0 */
414 #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
415 I2C_FUNC_SMBUS_WRITE_BYTE)
416 #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
417 I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
418 #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
419 I2C_FUNC_SMBUS_WRITE_WORD_DATA)
420 #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
421 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
422 #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
423 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
424 #define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \
425 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2)
426 #define I2C_FUNC_SMBUS_BLOCK_DATA_PEC (I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC | \
427 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC)
428 #define I2C_FUNC_SMBUS_WORD_DATA_PEC (I2C_FUNC_SMBUS_READ_WORD_DATA_PEC | \
429 I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC)
431 #define I2C_FUNC_SMBUS_READ_BYTE_PEC I2C_FUNC_SMBUS_READ_BYTE_DATA
432 #define I2C_FUNC_SMBUS_WRITE_BYTE_PEC I2C_FUNC_SMBUS_WRITE_BYTE_DATA
433 #define I2C_FUNC_SMBUS_READ_BYTE_DATA_PEC I2C_FUNC_SMBUS_READ_WORD_DATA
434 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA_PEC I2C_FUNC_SMBUS_WRITE_WORD_DATA
435 #define I2C_FUNC_SMBUS_BYTE_PEC I2C_FUNC_SMBUS_BYTE_DATA
436 #define I2C_FUNC_SMBUS_BYTE_DATA_PEC I2C_FUNC_SMBUS_WORD_DATA
438 #define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \
439 I2C_FUNC_SMBUS_BYTE | \
440 I2C_FUNC_SMBUS_BYTE_DATA | \
441 I2C_FUNC_SMBUS_WORD_DATA | \
442 I2C_FUNC_SMBUS_PROC_CALL | \
443 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
444 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC | \
445 I2C_FUNC_SMBUS_I2C_BLOCK)
448 * Data for SMBus Messages
450 #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
451 #define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */
452 union i2c_smbus_data {
455 __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
456 /* and one more for PEC */
459 /* smbus_access read or write markers */
460 #define I2C_SMBUS_READ 1
461 #define I2C_SMBUS_WRITE 0
463 /* SMBus transaction types (size parameter in the above functions)
464 Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
465 #define I2C_SMBUS_QUICK 0
466 #define I2C_SMBUS_BYTE 1
467 #define I2C_SMBUS_BYTE_DATA 2
468 #define I2C_SMBUS_WORD_DATA 3
469 #define I2C_SMBUS_PROC_CALL 4
470 #define I2C_SMBUS_BLOCK_DATA 5
471 #define I2C_SMBUS_I2C_BLOCK_DATA 6
472 #define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
473 #define I2C_SMBUS_BLOCK_DATA_PEC 8 /* SMBus 2.0 */
474 #define I2C_SMBUS_PROC_CALL_PEC 9 /* SMBus 2.0 */
475 #define I2C_SMBUS_BLOCK_PROC_CALL_PEC 10 /* SMBus 2.0 */
476 #define I2C_SMBUS_WORD_DATA_PEC 11 /* SMBus 2.0 */
479 /* ----- commands for the ioctl like i2c_command call:
480 * note that additional calls are defined in the algorithm and hw
481 * dependent layers - these can be listed here, or see the
482 * corresponding header files.
484 /* -> bit-adapter specific ioctls */
485 #define I2C_RETRIES 0x0701 /* number of times a device address */
486 /* should be polled when not */
488 #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */
491 /* this is for i2c-dev.c */
492 #define I2C_SLAVE 0x0703 /* Change slave address */
493 /* Attn.: Slave address is 7 or 10 bits */
494 #define I2C_SLAVE_FORCE 0x0706 /* Change slave address */
495 /* Attn.: Slave address is 7 or 10 bits */
496 /* This changes the address, even if it */
497 /* is already taken! */
498 #define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */
500 #define I2C_FUNCS 0x0705 /* Get the adapter functionality */
501 #define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/
502 #define I2C_PEC 0x0708 /* != 0 for SMBus PEC */
504 #define I2C_SMBUS 0x0720 /* SMBus-level access */
506 /* ... algo-bit.c recognizes */
507 #define I2C_UDELAY 0x0705 /* set delay in microsecs between each */
508 /* written byte (except address) */
509 #define I2C_MDELAY 0x0706 /* millisec delay between written bytes */
511 /* ----- I2C-DEV: char device interface stuff ------------------------- */
513 #define I2C_MAJOR 89 /* Device major number */
515 /* These defines are used for probing i2c client addresses */
516 /* The length of the option lists */
517 #define I2C_CLIENT_MAX_OPTS 48
519 /* Default fill of many variables */
520 #define I2C_CLIENT_DEFAULTS {I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
521 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
522 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
523 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
524 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
525 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
526 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
527 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
528 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
529 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
530 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
531 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
532 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
533 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
534 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
535 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END}
537 /* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the
540 #define I2C_CLIENT_MODULE_PARM(var,desc) \
541 static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
542 static unsigned int var##_num; \
543 module_param_array(var, short, &var##_num, 0); \
544 MODULE_PARM_DESC(var,desc)
546 #define I2C_CLIENT_MODULE_PARM_FORCE(name) \
547 I2C_CLIENT_MODULE_PARM(force_##name, \
548 "List of adapter,address pairs which are " \
549 "unquestionably assumed to contain a `" \
553 #define I2C_CLIENT_INSMOD_COMMON \
554 I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \
556 I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \
558 static struct i2c_client_address_data addr_data = { \
559 .normal_i2c = normal_i2c, \
565 /* These are the ones you want to use in your own drivers. Pick the one
566 which matches the number of devices the driver differenciates between. */
567 #define I2C_CLIENT_INSMOD \
568 I2C_CLIENT_MODULE_PARM(force, \
569 "List of adapter,address pairs to boldly assume " \
571 static unsigned short *forces[] = { \
575 I2C_CLIENT_INSMOD_COMMON
577 #define I2C_CLIENT_INSMOD_1(chip1) \
578 enum chips { any_chip, chip1 }; \
579 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
580 "boldly assume to be present"); \
581 I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
582 static unsigned short *forces[] = { force, force_##chip1, NULL }; \
583 I2C_CLIENT_INSMOD_COMMON
585 #define I2C_CLIENT_INSMOD_2(chip1, chip2) \
586 enum chips { any_chip, chip1, chip2 }; \
587 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
588 "boldly assume to be present"); \
589 I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
590 I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
591 static unsigned short *forces[] = { force, force_##chip1, \
592 force_##chip2, NULL }; \
593 I2C_CLIENT_INSMOD_COMMON
595 #define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \
596 enum chips { any_chip, chip1, chip2, chip3 }; \
597 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
598 "boldly assume to be present"); \
599 I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
600 I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
601 I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
602 static unsigned short *forces[] = { force, force_##chip1, \
603 force_##chip2, force_##chip3, \
605 I2C_CLIENT_INSMOD_COMMON
607 #define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \
608 enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
609 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
610 "boldly assume to be present"); \
611 I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
612 I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
613 I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
614 I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
615 static unsigned short *forces[] = { force, force_##chip1, \
616 force_##chip2, force_##chip3, \
617 force_##chip4, NULL}; \
618 I2C_CLIENT_INSMOD_COMMON
620 #define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \
621 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
622 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
623 "boldly assume to be present"); \
624 I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
625 I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
626 I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
627 I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
628 I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
629 static unsigned short *forces[] = { force, force_##chip1, \
630 force_##chip2, force_##chip3, \
631 force_##chip4, force_##chip5, \
633 I2C_CLIENT_INSMOD_COMMON
635 #define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \
636 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
637 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
638 "boldly assume to be present"); \
639 I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
640 I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
641 I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
642 I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
643 I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
644 I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
645 static unsigned short *forces[] = { force, force_##chip1, \
646 force_##chip2, force_##chip3, \
647 force_##chip4, force_##chip5, \
648 force_##chip6, NULL }; \
649 I2C_CLIENT_INSMOD_COMMON
651 #define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \
652 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \
654 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
655 "boldly assume to be present"); \
656 I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
657 I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
658 I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
659 I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
660 I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
661 I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
662 I2C_CLIENT_MODULE_PARM_FORCE(chip7); \
663 static unsigned short *forces[] = { force, force_##chip1, \
664 force_##chip2, force_##chip3, \
665 force_##chip4, force_##chip5, \
666 force_##chip6, force_##chip7, \
668 I2C_CLIENT_INSMOD_COMMON
670 #define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \
671 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \
673 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
674 "boldly assume to be present"); \
675 I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
676 I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
677 I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
678 I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
679 I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
680 I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
681 I2C_CLIENT_MODULE_PARM_FORCE(chip7); \
682 I2C_CLIENT_MODULE_PARM_FORCE(chip8); \
683 static unsigned short *forces[] = { force, force_##chip1, \
684 force_##chip2, force_##chip3, \
685 force_##chip4, force_##chip5, \
686 force_##chip6, force_##chip7, \
687 force_##chip8, NULL }; \
688 I2C_CLIENT_INSMOD_COMMON
690 #endif /* _LINUX_I2C_H */