[PATCH] i2c: SMBus PEC support rewrite, 3 of 3
[pandora-kernel.git] / include / linux / i2c.h
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 #ifndef _LINUX_I2C_H
27 #define _LINUX_I2C_H
28
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>
34
35 /* --- For i2c-isa ---------------------------------------------------- */
36
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;
41
42 /* --- General options ------------------------------------------------ */
43
44 struct i2c_msg;
45 struct i2c_algorithm;
46 struct i2c_adapter;
47 struct i2c_client;
48 struct i2c_driver;
49 union i2c_smbus_data;
50
51 /*
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.
56  */
57 extern int i2c_master_send(struct i2c_client *,const char* ,int);
58 extern int i2c_master_recv(struct i2c_client *,char* ,int);
59
60 /* Transfer num messages.
61  */
62 extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
63
64 /*
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.
67  */
68 extern int i2c_slave_send(struct i2c_client *,char*,int);
69 extern int i2c_slave_recv(struct i2c_client *,char*,int);
70
71
72
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, 
79                            unsigned short flags,
80                            char read_write, u8 command, int size,
81                            union i2c_smbus_data * data);
82
83 /* Now follow the 'nice' access routines. These also document the calling
84    conventions of smbus_access. */
85
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,
97                                       u8 *values);
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);
101
102 /*
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
105  * events.
106  */
107
108 struct i2c_driver {
109         struct module *owner;
110         char name[32];
111         int id;
112         unsigned int class;
113         unsigned int flags;             /* div., see below              */
114
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
119          * i2c_attach_client.
120          */
121         int (*attach_adapter)(struct i2c_adapter *);
122         int (*detach_adapter)(struct i2c_adapter *);
123
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.
128          */
129         int (*detach_client)(struct i2c_client *);
130         
131         /* a ioctl like command that can be used to perform specific functions
132          * with the device.
133          */
134         int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
135
136         struct device_driver driver;
137         struct list_head list;
138 };
139 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
140
141 #define I2C_NAME_SIZE   50
142
143 /*
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.
147  */
148 struct i2c_client {
149         unsigned int flags;             /* div., see below              */
150         unsigned short addr;            /* chip address - NOTE: 7bit    */
151                                         /* addresses are stored in the  */
152                                         /* _LOWER_ 7 bits               */
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  */
156                                         /* to the client                */
157         struct device dev;              /* the device structure         */
158         struct list_head list;
159         char name[I2C_NAME_SIZE];
160         struct completion released;
161 };
162 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
163
164 static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
165 {
166         return to_i2c_client(container_of(kobj, struct device, kobj));
167 }
168
169 static inline void *i2c_get_clientdata (struct i2c_client *dev)
170 {
171         return dev_get_drvdata (&dev->dev);
172 }
173
174 static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
175 {
176         dev_set_drvdata (&dev->dev, data);
177 }
178
179 /*
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.
184  */
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, 
191                            int num);
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);
195
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);
199
200         /* --- ioctl like call to set div. parameters. */
201         int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long);
202
203         /* To determine what the adapter supports */
204         u32 (*functionality) (struct i2c_adapter *);
205 };
206
207 /*
208  * i2c_adapter is the structure used to identify a physical i2c bus along
209  * with the access algorithms necessary to access it.
210  */
211 struct i2c_adapter {
212         struct module *owner;
213         unsigned int id;
214         unsigned int class;
215         struct i2c_algorithm *algo;/* the algorithm to access the bus   */
216         void *algo_data;
217
218         /* --- administration stuff. */
219         int (*client_register)(struct i2c_client *);
220         int (*client_unregister)(struct i2c_client *);
221
222         /* data fields that are valid for all devices   */
223         struct semaphore bus_lock;
224         struct semaphore clist_lock;
225
226         int timeout;
227         int retries;
228         struct device dev;              /* the adapter device */
229         struct class_device class_dev;  /* the class device */
230
231         int nr;
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;
237 };
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)
240
241 static inline void *i2c_get_adapdata (struct i2c_adapter *dev)
242 {
243         return dev_get_drvdata (&dev->dev);
244 }
245
246 static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
247 {
248         dev_set_drvdata (&dev->dev, data);
249 }
250
251 /*flags for the driver struct: */
252 #define I2C_DF_NOTIFY   0x01            /* notify on bus (de/a)ttaches  */
253 #if 0
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
257 #endif
258
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 */
266
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 */
276
277 /* i2c_client_address_data is the struct for holding default client
278  * addresses for a driver and for the parameters supplied on the
279  * command line
280  */
281 struct i2c_client_address_data {
282         unsigned short *normal_i2c;
283         unsigned short *probe;
284         unsigned short *ignore;
285         unsigned short **forces;
286 };
287
288 /* Internal numbers to terminate lists */
289 #define I2C_CLIENT_END          0xfffeU
290
291 /* The numbers to use to set I2C bus address */
292 #define ANY_I2C_BUS             0xffff
293 #define ANY_I2C_ISA_BUS         9191
294
295
296 /* ----- functions exported by i2c.o */
297
298 /* administration...
299  */
300 extern int i2c_add_adapter(struct i2c_adapter *);
301 extern int i2c_del_adapter(struct i2c_adapter *);
302
303 extern int i2c_add_driver(struct i2c_driver *);
304 extern int i2c_del_driver(struct i2c_driver *);
305
306 extern int i2c_attach_client(struct i2c_client *);
307 extern int i2c_detach_client(struct i2c_client *);
308
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
312    -struct. */
313 extern struct i2c_client *i2c_get_client(int driver_id, int adapter_id, 
314                                         struct i2c_client *prev);
315
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
319    the i2c-client. 
320    returns -EACCES if client doesn't allow use (default)
321    returns -EBUSY if client doesn't allow multiple use (default) and 
322    usage_count >0 */
323 extern int i2c_use_client(struct i2c_client *);
324 extern int i2c_release_client(struct i2c_client *);
325
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);
330
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);
335
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);
339  */
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));
343
344 /* An ioctl like call to set div. parameters of the adapter.
345  */
346 extern int i2c_control(struct i2c_client *,unsigned int, unsigned long);
347
348 extern struct i2c_adapter* i2c_get_adapter(int id);
349 extern void i2c_put_adapter(struct i2c_adapter *adap);
350
351
352 /* Return the functionality mask */
353 static inline u32 i2c_get_functionality(struct i2c_adapter *adap)
354 {
355         return adap->algo->functionality(adap);
356 }
357
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)
360 {
361         return (func & i2c_get_functionality(adap)) == func;
362 }
363
364 /* Return id number for a specific adapter */
365 static inline int i2c_adapter_id(struct i2c_adapter *adap)
366 {
367         return adap->nr;
368 }
369
370 /*
371  * I2C Message - used for pure i2c transaction, also from /dev interface
372  */
373 struct i2c_msg {
374         __u16 addr;     /* slave address                        */
375         __u16 flags;            
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                  */
384 };
385
386 /* To determine what functionality is present */
387
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_BLOCK_PROC_CALL  0x00008000 /* SMBus 2.0 */
393 #define I2C_FUNC_SMBUS_QUICK            0x00010000 
394 #define I2C_FUNC_SMBUS_READ_BYTE        0x00020000 
395 #define I2C_FUNC_SMBUS_WRITE_BYTE       0x00040000 
396 #define I2C_FUNC_SMBUS_READ_BYTE_DATA   0x00080000 
397 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA  0x00100000 
398 #define I2C_FUNC_SMBUS_READ_WORD_DATA   0x00200000 
399 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA  0x00400000 
400 #define I2C_FUNC_SMBUS_PROC_CALL        0x00800000 
401 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA  0x01000000 
402 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 
403 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK   0x04000000 /* I2C-like block xfer  */
404 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK  0x08000000 /* w/ 1-byte reg. addr. */
405 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2  0x10000000 /* I2C-like block xfer  */
406 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */
407
408 #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
409                              I2C_FUNC_SMBUS_WRITE_BYTE)
410 #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
411                                   I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
412 #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
413                                   I2C_FUNC_SMBUS_WRITE_WORD_DATA)
414 #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
415                                    I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
416 #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
417                                   I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
418 #define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \
419                                     I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2)
420
421 #define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \
422                              I2C_FUNC_SMBUS_BYTE | \
423                              I2C_FUNC_SMBUS_BYTE_DATA | \
424                              I2C_FUNC_SMBUS_WORD_DATA | \
425                              I2C_FUNC_SMBUS_PROC_CALL | \
426                              I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
427                              I2C_FUNC_SMBUS_I2C_BLOCK)
428
429 /* 
430  * Data for SMBus Messages 
431  */
432 #define I2C_SMBUS_BLOCK_MAX     32      /* As specified in SMBus standard */    
433 union i2c_smbus_data {
434         __u8 byte;
435         __u16 word;
436         __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
437                                /* and one more for user-space compatibility */
438 };
439
440 /* smbus_access read or write markers */
441 #define I2C_SMBUS_READ  1
442 #define I2C_SMBUS_WRITE 0
443
444 /* SMBus transaction types (size parameter in the above functions) 
445    Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
446 #define I2C_SMBUS_QUICK             0
447 #define I2C_SMBUS_BYTE              1
448 #define I2C_SMBUS_BYTE_DATA         2 
449 #define I2C_SMBUS_WORD_DATA         3
450 #define I2C_SMBUS_PROC_CALL         4
451 #define I2C_SMBUS_BLOCK_DATA        5
452 #define I2C_SMBUS_I2C_BLOCK_DATA    6
453 #define I2C_SMBUS_BLOCK_PROC_CALL   7           /* SMBus 2.0 */
454
455
456 /* ----- commands for the ioctl like i2c_command call:
457  * note that additional calls are defined in the algorithm and hw 
458  *      dependent layers - these can be listed here, or see the 
459  *      corresponding header files.
460  */
461                                 /* -> bit-adapter specific ioctls       */
462 #define I2C_RETRIES     0x0701  /* number of times a device address      */
463                                 /* should be polled when not            */
464                                 /* acknowledging                        */
465 #define I2C_TIMEOUT     0x0702  /* set timeout - call with int          */
466
467
468 /* this is for i2c-dev.c        */
469 #define I2C_SLAVE       0x0703  /* Change slave address                 */
470                                 /* Attn.: Slave address is 7 or 10 bits */
471 #define I2C_SLAVE_FORCE 0x0706  /* Change slave address                 */
472                                 /* Attn.: Slave address is 7 or 10 bits */
473                                 /* This changes the address, even if it */
474                                 /* is already taken!                    */
475 #define I2C_TENBIT      0x0704  /* 0 for 7 bit addrs, != 0 for 10 bit   */
476
477 #define I2C_FUNCS       0x0705  /* Get the adapter functionality */
478 #define I2C_RDWR        0x0707  /* Combined R/W transfer (one stop only)*/
479 #define I2C_PEC         0x0708  /* != 0 for SMBus PEC                   */
480
481 #define I2C_SMBUS       0x0720  /* SMBus-level access */
482
483 /* ----- I2C-DEV: char device interface stuff ------------------------- */
484
485 #define I2C_MAJOR       89              /* Device major number          */
486
487 /* These defines are used for probing i2c client addresses */
488 /* The length of the option lists */
489 #define I2C_CLIENT_MAX_OPTS 48
490
491 /* Default fill of many variables */
492 #define I2C_CLIENT_DEFAULTS {I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
493                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
494                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
495                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
496                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
497                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
498                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
499                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
500                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
501                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
502                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
503                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
504                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
505                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
506                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
507                           I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END}
508
509 /* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the
510    module header */
511
512 #define I2C_CLIENT_MODULE_PARM(var,desc) \
513   static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
514   static unsigned int var##_num; \
515   module_param_array(var, short, &var##_num, 0); \
516   MODULE_PARM_DESC(var,desc)
517
518 #define I2C_CLIENT_MODULE_PARM_FORCE(name)                              \
519 I2C_CLIENT_MODULE_PARM(force_##name,                                    \
520                        "List of adapter,address pairs which are "       \
521                        "unquestionably assumed to contain a `"          \
522                        # name "' chip")
523
524
525 #define I2C_CLIENT_INSMOD_COMMON                                        \
526 I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan "  \
527                        "additionally");                                 \
528 I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to "  \
529                        "scan");                                         \
530 static struct i2c_client_address_data addr_data = {                     \
531         .normal_i2c     = normal_i2c,                                   \
532         .probe          = probe,                                        \
533         .ignore         = ignore,                                       \
534         .forces         = forces,                                       \
535 }
536
537 /* These are the ones you want to use in your own drivers. Pick the one
538    which matches the number of devices the driver differenciates between. */
539 #define I2C_CLIENT_INSMOD \
540   I2C_CLIENT_MODULE_PARM(force, \
541                       "List of adapter,address pairs to boldly assume " \
542                       "to be present"); \
543         static unsigned short *forces[] = {                             \
544                         force,                                          \
545                         NULL                                            \
546                 };                                                      \
547 I2C_CLIENT_INSMOD_COMMON
548
549 #define I2C_CLIENT_INSMOD_1(chip1)                                      \
550 enum chips { any_chip, chip1 };                                         \
551 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "       \
552                        "boldly assume to be present");                  \
553 I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                    \
554 static unsigned short *forces[] = { force, force_##chip1, NULL };       \
555 I2C_CLIENT_INSMOD_COMMON
556
557 #define I2C_CLIENT_INSMOD_2(chip1, chip2)                               \
558 enum chips { any_chip, chip1, chip2 };                                  \
559 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "       \
560                        "boldly assume to be present");                  \
561 I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                    \
562 I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                    \
563 static unsigned short *forces[] = { force, force_##chip1,               \
564                                     force_##chip2, NULL };              \
565 I2C_CLIENT_INSMOD_COMMON
566
567 #define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3)                        \
568 enum chips { any_chip, chip1, chip2, chip3 };                           \
569 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "       \
570                        "boldly assume to be present");                  \
571 I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                    \
572 I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                    \
573 I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                    \
574 static unsigned short *forces[] = { force, force_##chip1,               \
575                                     force_##chip2, force_##chip3,       \
576                                     NULL };                             \
577 I2C_CLIENT_INSMOD_COMMON
578
579 #define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4)                 \
580 enum chips { any_chip, chip1, chip2, chip3, chip4 };                    \
581 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "       \
582                        "boldly assume to be present");                  \
583 I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                    \
584 I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                    \
585 I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                    \
586 I2C_CLIENT_MODULE_PARM_FORCE(chip4);                                    \
587 static unsigned short *forces[] = { force, force_##chip1,               \
588                                     force_##chip2, force_##chip3,       \
589                                     force_##chip4, NULL};               \
590 I2C_CLIENT_INSMOD_COMMON
591
592 #define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5)          \
593 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 };             \
594 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "       \
595                        "boldly assume to be present");                  \
596 I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                    \
597 I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                    \
598 I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                    \
599 I2C_CLIENT_MODULE_PARM_FORCE(chip4);                                    \
600 I2C_CLIENT_MODULE_PARM_FORCE(chip5);                                    \
601 static unsigned short *forces[] = { force, force_##chip1,               \
602                                     force_##chip2, force_##chip3,       \
603                                     force_##chip4, force_##chip5,       \
604                                     NULL };                             \
605 I2C_CLIENT_INSMOD_COMMON
606
607 #define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6)   \
608 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 };      \
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 I2C_CLIENT_MODULE_PARM_FORCE(chip5);                                    \
616 I2C_CLIENT_MODULE_PARM_FORCE(chip6);                                    \
617 static unsigned short *forces[] = { force, force_##chip1,               \
618                                     force_##chip2, force_##chip3,       \
619                                     force_##chip4, force_##chip5,       \
620                                     force_##chip6, NULL };              \
621 I2C_CLIENT_INSMOD_COMMON
622
623 #define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \
624 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6,        \
625              chip7 };                                                   \
626 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "       \
627                        "boldly assume to be present");                  \
628 I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                    \
629 I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                    \
630 I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                    \
631 I2C_CLIENT_MODULE_PARM_FORCE(chip4);                                    \
632 I2C_CLIENT_MODULE_PARM_FORCE(chip5);                                    \
633 I2C_CLIENT_MODULE_PARM_FORCE(chip6);                                    \
634 I2C_CLIENT_MODULE_PARM_FORCE(chip7);                                    \
635 static unsigned short *forces[] = { force, force_##chip1,               \
636                                     force_##chip2, force_##chip3,       \
637                                     force_##chip4, force_##chip5,       \
638                                     force_##chip6, force_##chip7,       \
639                                     NULL };                             \
640 I2C_CLIENT_INSMOD_COMMON
641
642 #define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \
643 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6,        \
644              chip7, chip8 };                                            \
645 I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "       \
646                        "boldly assume to be present");                  \
647 I2C_CLIENT_MODULE_PARM_FORCE(chip1);                                    \
648 I2C_CLIENT_MODULE_PARM_FORCE(chip2);                                    \
649 I2C_CLIENT_MODULE_PARM_FORCE(chip3);                                    \
650 I2C_CLIENT_MODULE_PARM_FORCE(chip4);                                    \
651 I2C_CLIENT_MODULE_PARM_FORCE(chip5);                                    \
652 I2C_CLIENT_MODULE_PARM_FORCE(chip6);                                    \
653 I2C_CLIENT_MODULE_PARM_FORCE(chip7);                                    \
654 I2C_CLIENT_MODULE_PARM_FORCE(chip8);                                    \
655 static unsigned short *forces[] = { force, force_##chip1,               \
656                                     force_##chip2, force_##chip3,       \
657                                     force_##chip4, force_##chip5,       \
658                                     force_##chip6, force_##chip7,       \
659                                     force_##chip8, NULL };              \
660 I2C_CLIENT_INSMOD_COMMON
661
662 #endif /* _LINUX_I2C_H */