root/i2c/branches/lk2-4/kernel/i2c.h @ 3799

Revision 3799, 22.4 KB (checked in by mds, 10 years ago)

EINVAL patch from P.P.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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$ */
27
28#ifndef _LINUX_I2C_H
29#define _LINUX_I2C_H
30
31#define I2C_DATE "2003xxxx"
32#define I2C_VERSION "2.8.0-CVS"
33
34#include <linux/module.h>
35#include <linux/types.h>
36#include <linux/errno.h>
37#include <asm/semaphore.h>
38#include "i2c-id.h"
39
40#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10)
41#define MODULE_LICENSE(x)
42#endif
43
44/* --- General options ------------------------------------------------ */
45
46#define I2C_ALGO_MAX    4               /* control memory consumption   */
47#define I2C_ADAP_MAX    16
48#define I2C_DRIVER_MAX  16
49#define I2C_CLIENT_MAX  32
50#define I2C_DUMMY_MAX 4
51
52struct i2c_msg;
53struct i2c_algorithm;
54struct i2c_adapter;
55struct i2c_client;
56struct i2c_driver;
57struct i2c_client_address_data;
58union i2c_smbus_data;
59
60/*
61 * The master routines are the ones normally used to transmit data to devices
62 * on a bus (or read from them). Apart from two basic transfer functions to
63 * transmit one message at a time, a more complex version can be used to
64 * transmit an arbitrary number of messages without interruption.
65 */
66extern int i2c_master_send(struct i2c_client *,const char* ,int);
67extern int i2c_master_recv(struct i2c_client *,char* ,int);
68
69/* Transfer num messages.
70 */
71extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],int num);
72
73/*
74 * Some adapter types (i.e. PCF 8584 based ones) may support slave behaviuor.
75 * This is not tested/implemented yet and will change in the future.
76 */
77extern int i2c_slave_send(struct i2c_client *,char*,int);
78extern int i2c_slave_recv(struct i2c_client *,char*,int);
79
80
81
82/* This is the very generalized SMBus access routine. You probably do not
83   want to use this, though; one of the functions below may be much easier,
84   and probably just as fast.
85   Note that we use i2c_adapter here, because you do not need a specific
86   smbus adapter to call this function. */
87extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, 
88                           unsigned short flags,
89                           char read_write, u8 command, int size,
90                           union i2c_smbus_data * data);
91
92/* Now follow the 'nice' access routines. These also document the calling
93   conventions of smbus_access. */
94
95extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value);
96extern s32 i2c_smbus_read_byte(struct i2c_client * client);
97extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value);
98extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command);
99extern s32 i2c_smbus_write_byte_data(struct i2c_client * client,
100                                     u8 command, u8 value);
101extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command);
102extern s32 i2c_smbus_write_word_data(struct i2c_client * client,
103                                     u8 command, u16 value);
104extern s32 i2c_smbus_process_call(struct i2c_client * client,
105                                  u8 command, u16 value);
106/* Returns the number of read bytes */
107extern s32 i2c_smbus_read_block_data(struct i2c_client * client,
108                                     u8 command, u8 *values);
109extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
110                                      u8 command, u8 length,
111                                      u8 *values);
112extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
113                                         u8 command, u8 *values);
114extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
115                                          u8 command, u8 length,
116                                          u8 *values);
117
118
119/*
120 * A driver is capable of handling one or more physical devices present on
121 * I2C adapters. This information is used to inform the driver of adapter
122 * events.
123 */
124
125struct i2c_driver {
126        struct module *owner;
127        char name[32];
128        int id;
129        unsigned int flags;             /* div., see below              */
130
131        /* Notifies the driver that a new bus has appeared. This routine
132         * can be used by the driver to test if the bus meets its conditions
133         * & seek for the presence of the chip(s) it supports. If found, it
134         * registers the client(s) that are on the bus to the i2c admin. via
135         * i2c_attach_client.
136         */
137        int (*attach_adapter)(struct i2c_adapter *);
138
139        /* tells the driver that a client is about to be deleted & gives it
140         * the chance to remove its private data. Also, if the client struct
141         * has been dynamically allocated by the driver in the function above,
142         * it must be freed here.
143         */
144        int (*detach_client)(struct i2c_client *);
145       
146        /* a ioctl like command that can be used to perform specific functions
147         * with the device.
148         */
149        int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
150};
151
152/*
153 * i2c_client identifies a single device (i.e. chip) that is connected to an
154 * i2c bus. The behaviour is defined by the routines of the driver. This
155 * function is mainly used for lookup & other admin. functions.
156 */
157struct i2c_client {
158        char name[32];
159        int id;
160        unsigned int flags;             /* div., see below              */
161        unsigned int addr;              /* chip address - NOTE: 7bit    */
162                                        /* addresses are stored in the  */
163                                        /* _LOWER_ 7 bits of this char  */
164        /* addr: unsigned int to make lm_sensors i2c-isa adapter work
165          more cleanly. It does not take any more memory space, due to
166          alignment considerations */
167        struct i2c_adapter *adapter;    /* the adapter we sit on        */
168        struct i2c_driver *driver;      /* and our access routines      */
169        void *data;                     /* for the clients              */
170        int usage_count;                /* How many accesses currently  */
171                                        /* to the client                */
172};
173
174
175/*
176 * The following structs are for those who like to implement new bus drivers:
177 * i2c_algorithm is the interface to a class of hardware solutions which can
178 * be addressed using the same bus algorithms - i.e. bit-banging or the PCF8584
179 * to name two of the most common.
180 */
181struct i2c_algorithm {
182        struct module *owner;                   /* future use --km      */
183        char name[32];                          /* textual description  */
184        unsigned int id;
185
186        /* If an adapter algorithm can't to 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 */
211struct i2c_adapter {
212        struct module *owner;
213        char name[32];  /* some useful name to identify the adapter     */
214        unsigned int id;/* == is algo->id | hwdep.struct->id,           */
215                        /* for registered values see below              */
216        struct i2c_algorithm *algo;/* the algorithm to access the bus   */
217        void *algo_data;
218
219        /* --- administration stuff. */
220        int (*client_register)(struct i2c_client *);
221        int (*client_unregister)(struct i2c_client *);
222
223        void *data;     /* private data for the adapter                 */
224                        /* some data fields that are used by all types  */
225                        /* these data fields are readonly to the public */
226                        /* and can be set via the i2c_ioctl call        */
227
228                        /* data fields that are valid for all devices   */
229        struct semaphore bus;
230        struct semaphore list; 
231        unsigned int flags;/* flags specifying div. data                */
232
233        struct i2c_client *clients[I2C_CLIENT_MAX];
234
235        int timeout;
236        int retries;
237
238#ifdef CONFIG_PROC_FS
239        /* No need to set this when you initialize the adapter          */
240        int inode;
241#endif /* def CONFIG_PROC_FS */
242};
243
244/*flags for the driver struct: */
245#define I2C_DF_NOTIFY   0x01            /* notify on bus (de/a)ttaches  */
246#define I2C_DF_DUMMY    0x02            /* do not connect any clients */
247
248/*flags for the client struct: */
249#define I2C_CLIENT_ALLOW_USE            0x01    /* Client allows access */
250#define I2C_CLIENT_ALLOW_MULTIPLE_USE   0x02    /* Allow multiple access-locks */
251                                                /* on an i2c_client */
252#define I2C_CLIENT_PEC  0x04                    /* Use Packet Error Checking */
253#define I2C_CLIENT_TEN  0x10                    /* we have a ten bit chip address       */
254                                                /* Must equal I2C_M_TEN below */
255
256/* i2c_client_address_data is the struct for holding default client
257 * addresses for a driver and for the parameters supplied on the
258 * command line
259 */
260struct i2c_client_address_data {
261        unsigned short *normal_i2c;
262        unsigned short *normal_i2c_range;
263        unsigned short *probe;
264        unsigned short *probe_range;
265        unsigned short *ignore;
266        unsigned short *ignore_range;
267        unsigned short *force;
268};
269
270/* Internal numbers to terminate lists */
271#define I2C_CLIENT_END 0xfffe
272
273/* The numbers to use to set I2C bus address */
274#define ANY_I2C_BUS 0xffff
275
276/* The length of the option lists */
277#define I2C_CLIENT_MAX_OPTS 48
278
279
280/* ----- functions exported by i2c.o */
281
282/* administration...
283 */
284extern int i2c_add_adapter(struct i2c_adapter *);
285extern int i2c_del_adapter(struct i2c_adapter *);
286
287extern int i2c_add_driver(struct i2c_driver *);
288extern int i2c_del_driver(struct i2c_driver *);
289
290extern int i2c_attach_client(struct i2c_client *);
291extern int i2c_detach_client(struct i2c_client *);
292
293/* New function: This is to get an i2c_client-struct for controlling the
294   client either by using i2c_control-function or having the
295   client-module export functions that can be used with the i2c_client
296   -struct. */
297extern struct i2c_client *i2c_get_client(int driver_id, int adapter_id, 
298                                        struct i2c_client *prev);
299
300/* Should be used with new function
301   extern struct i2c_client *i2c_get_client(int,int,struct i2c_client *);
302   to make sure that client-struct is valid and that it is okay to access
303   the i2c-client.
304   returns -EACCES if client doesn't allow use (default)
305   returns -EBUSY if client doesn't allow multiple use (default) and
306   usage_count >0 */
307extern int i2c_use_client(struct i2c_client *);
308extern int i2c_release_client(struct i2c_client *);
309
310/* returns -EBUSY if address has been taken, 0 if not. Note that the only
311   other place at which this is called is within i2c_attach_client; so
312   you can cheat by simply not registering. Not recommended, of course! */
313extern int i2c_check_addr (struct i2c_adapter *adapter, int addr);
314
315/* Detect function. It iterates over all possible addresses itself.
316 * It will only call found_proc if some client is connected at the
317 * specific address (unless a 'force' matched);
318 */
319typedef int i2c_client_found_addr_proc (struct i2c_adapter *adapter,
320                                     int addr, unsigned short flags,int kind);
321
322extern int i2c_probe(struct i2c_adapter *adapter, 
323                struct i2c_client_address_data *address_data,
324                i2c_client_found_addr_proc *found_proc);
325
326static inline int i2c_client_command(struct i2c_client *client,
327                                     unsigned int cmd, void *arg)
328{
329        if (client->driver && client->driver->command)
330                return client->driver->command(client, cmd, arg);
331        else
332                return -EINVAL;
333}
334
335/* An ioctl like call to set div. parameters of the adapter.
336 */
337extern int i2c_control(struct i2c_client *,unsigned int, unsigned long);
338
339/* This call returns a unique low identifier for each registered adapter,
340 * or -1 if the adapter was not registered.
341 */
342extern int i2c_adapter_id(struct i2c_adapter *adap);
343
344
345
346/* Return the functionality mask */
347extern u32 i2c_get_functionality (struct i2c_adapter *adap);
348
349/* Return 1 if adapter supports everything we need, 0 if not. */
350extern int i2c_check_functionality (struct i2c_adapter *adap, u32 func);
351
352/*
353 * I2C Message - used for pure i2c transaction, also from /dev interface
354 */
355struct i2c_msg {
356        __u16 addr;     /* slave address                        */
357        unsigned short flags;           
358#define I2C_M_TEN       0x10    /* we have a ten bit chip address       */
359#define I2C_M_RD        0x01
360#define I2C_M_NOSTART   0x4000
361#define I2C_M_REV_DIR_ADDR      0x2000
362#define I2C_M_IGNORE_NAK        0x1000
363#define I2C_M_NO_RD_ACK         0x0800
364        short len;              /* msg length                           */
365        char *buf;              /* pointer to msg data                  */
366        int err;
367        short done;
368};
369
370/* To determine what functionality is present */
371
372#define I2C_FUNC_I2C                    0x00000001
373#define I2C_FUNC_10BIT_ADDR             0x00000002
374#define I2C_FUNC_PROTOCOL_MANGLING      0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
375#define I2C_FUNC_SMBUS_HWPEC_CALC       0x00000008 /* SMBus 2.0 */
376#define I2C_FUNC_SMBUS_READ_WORD_DATA_PEC  0x00000800 /* SMBus 2.0 */ 
377#define I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC 0x00001000 /* SMBus 2.0 */ 
378#define I2C_FUNC_SMBUS_PROC_CALL_PEC    0x00002000 /* SMBus 2.0 */
379#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL_PEC 0x00004000 /* SMBus 2.0 */
380#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL  0x00008000 /* SMBus 2.0 */
381#define I2C_FUNC_SMBUS_QUICK            0x00010000
382#define I2C_FUNC_SMBUS_READ_BYTE        0x00020000
383#define I2C_FUNC_SMBUS_WRITE_BYTE       0x00040000
384#define I2C_FUNC_SMBUS_READ_BYTE_DATA   0x00080000
385#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA  0x00100000
386#define I2C_FUNC_SMBUS_READ_WORD_DATA   0x00200000
387#define I2C_FUNC_SMBUS_WRITE_WORD_DATA  0x00400000
388#define I2C_FUNC_SMBUS_PROC_CALL        0x00800000
389#define I2C_FUNC_SMBUS_READ_BLOCK_DATA  0x01000000
390#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
391#define I2C_FUNC_SMBUS_READ_I2C_BLOCK   0x04000000 /* I2C-like block xfer  */
392#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK  0x08000000 /* w/ 1-byte reg. addr. */
393#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2  0x10000000 /* I2C-like block xfer  */
394#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */
395#define I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC  0x40000000 /* SMBus 2.0 */
396#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC 0x80000000 /* SMBus 2.0 */
397
398#define I2C_FUNC_SMBUS_BYTE I2C_FUNC_SMBUS_READ_BYTE | \
399                            I2C_FUNC_SMBUS_WRITE_BYTE
400#define I2C_FUNC_SMBUS_BYTE_DATA I2C_FUNC_SMBUS_READ_BYTE_DATA | \
401                                 I2C_FUNC_SMBUS_WRITE_BYTE_DATA
402#define I2C_FUNC_SMBUS_WORD_DATA I2C_FUNC_SMBUS_READ_WORD_DATA | \
403                                 I2C_FUNC_SMBUS_WRITE_WORD_DATA
404#define I2C_FUNC_SMBUS_BLOCK_DATA I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
405                                  I2C_FUNC_SMBUS_WRITE_BLOCK_DATA
406#define I2C_FUNC_SMBUS_I2C_BLOCK I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
407                                  I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
408#define I2C_FUNC_SMBUS_I2C_BLOCK_2 I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \
409                                   I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2
410#define I2C_FUNC_SMBUS_BLOCK_DATA_PEC I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC | \
411                                      I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC
412#define I2C_FUNC_SMBUS_WORD_DATA_PEC  I2C_FUNC_SMBUS_READ_WORD_DATA_PEC | \
413                                      I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC
414
415#define I2C_FUNC_SMBUS_READ_BYTE_PEC            I2C_FUNC_SMBUS_READ_BYTE_DATA
416#define I2C_FUNC_SMBUS_WRITE_BYTE_PEC           I2C_FUNC_SMBUS_WRITE_BYTE_DATA
417#define I2C_FUNC_SMBUS_READ_BYTE_DATA_PEC       I2C_FUNC_SMBUS_READ_WORD_DATA
418#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA_PEC      I2C_FUNC_SMBUS_WRITE_WORD_DATA
419#define I2C_FUNC_SMBUS_BYTE_PEC                 I2C_FUNC_SMBUS_BYTE_DATA
420#define I2C_FUNC_SMBUS_BYTE_DATA_PEC            I2C_FUNC_SMBUS_WORD_DATA
421
422#define I2C_FUNC_SMBUS_EMUL I2C_FUNC_SMBUS_QUICK | \
423                            I2C_FUNC_SMBUS_BYTE | \
424                            I2C_FUNC_SMBUS_BYTE_DATA | \
425                            I2C_FUNC_SMBUS_WORD_DATA | \
426                            I2C_FUNC_SMBUS_PROC_CALL | \
427                            I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
428                            I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC | \
429                            I2C_FUNC_SMBUS_I2C_BLOCK
430
431/*
432 * Data for SMBus Messages
433 */
434#define I2C_SMBUS_BLOCK_MAX     32      /* As specified in SMBus standard */   
435#define I2C_SMBUS_I2C_BLOCK_MAX 32      /* Not specified but we use same structure */
436union i2c_smbus_data {
437        __u8 byte;
438        __u16 word;
439        __u8 block[I2C_SMBUS_BLOCK_MAX + 3]; /* block[0] is used for length */
440                          /* one more for read length in block process call */
441                                                    /* and one more for PEC */
442};
443
444/* smbus_access read or write markers */
445#define I2C_SMBUS_READ  1
446#define I2C_SMBUS_WRITE 0
447
448/* SMBus transaction types (size parameter in the above functions)
449   Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
450#define I2C_SMBUS_QUICK             0
451#define I2C_SMBUS_BYTE              1
452#define I2C_SMBUS_BYTE_DATA         2
453#define I2C_SMBUS_WORD_DATA         3
454#define I2C_SMBUS_PROC_CALL         4
455#define I2C_SMBUS_BLOCK_DATA        5
456#define I2C_SMBUS_I2C_BLOCK_DATA    6
457#define I2C_SMBUS_BLOCK_PROC_CALL   7           /* SMBus 2.0 */
458#define I2C_SMBUS_BLOCK_DATA_PEC    8           /* SMBus 2.0 */
459#define I2C_SMBUS_PROC_CALL_PEC     9           /* SMBus 2.0 */
460#define I2C_SMBUS_BLOCK_PROC_CALL_PEC  10       /* SMBus 2.0 */
461#define I2C_SMBUS_WORD_DATA_PEC    11           /* SMBus 2.0 */
462
463
464/* ----- commands for the ioctl like i2c_command call:
465 * note that additional calls are defined in the algorithm and hw
466 *      dependent layers - these can be listed here, or see the
467 *      corresponding header files.
468 */
469                                /* -> bit-adapter specific ioctls       */
470#define I2C_RETRIES     0x0701  /* number of times a device address      */
471                                /* should be polled when not            */
472                                /* acknowledging                        */
473#define I2C_TIMEOUT     0x0702  /* set timeout - call with int          */
474
475
476/* this is for i2c-dev.c        */
477#define I2C_SLAVE       0x0703  /* Change slave address                 */
478                                /* Attn.: Slave address is 7 or 10 bits */
479#define I2C_SLAVE_FORCE 0x0706  /* Change slave address                 */
480                                /* Attn.: Slave address is 7 or 10 bits */
481                                /* This changes the address, even if it */
482                                /* is already taken!                    */
483#define I2C_TENBIT      0x0704  /* 0 for 7 bit addrs, != 0 for 10 bit   */
484
485#define I2C_FUNCS       0x0705  /* Get the adapter functionality */
486#define I2C_RDWR        0x0707  /* Combined R/W transfer (one stop only)*/
487#define I2C_PEC         0x0708  /* != 0 for SMBus PEC                   */
488#if 0
489#define I2C_ACK_TEST    0x0710  /* See if a slave is at a specific address */
490#endif
491
492#define I2C_SMBUS       0x0720  /* SMBus-level access */
493
494/* ... algo-bit.c recognizes */
495#define I2C_UDELAY      0x0705  /* set delay in microsecs between each  */
496                                /* written byte (except address)        */
497#define I2C_MDELAY      0x0706  /* millisec delay between written bytes */
498
499/* ----- I2C-DEV: char device interface stuff ------------------------- */
500
501#define I2C_MAJOR       89              /* Device major number          */
502
503/* These defines are used for probing i2c client addresses */
504/* Default fill of many variables */
505#define I2C_CLIENT_DEFAULTS {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                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
509                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
510                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
511                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
512                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
513                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
514                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
515                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
516                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
517                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
518                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
519                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
520                          I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END}
521
522/* This is ugly. We need to evaluate I2C_CLIENT_MAX_OPTS before it is
523   stringified */
524#define I2C_CLIENT_MODPARM_AUX1(x) "1-" #x "h"
525#define I2C_CLIENT_MODPARM_AUX(x) I2C_CLIENT_MODPARM_AUX1(x)
526#define I2C_CLIENT_MODPARM I2C_CLIENT_MODPARM_AUX(I2C_CLIENT_MAX_OPTS)
527
528/* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the
529   module header */
530
531#define I2C_CLIENT_MODULE_PARM(var,desc) \
532  static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
533  MODULE_PARM(var,I2C_CLIENT_MODPARM); \
534  MODULE_PARM_DESC(var,desc)
535
536/* This is the one you want to use in your own modules */
537#define I2C_CLIENT_INSMOD \
538  I2C_CLIENT_MODULE_PARM(probe, \
539                      "List of adapter,address pairs to scan additionally"); \
540  I2C_CLIENT_MODULE_PARM(probe_range, \
541                      "List of adapter,start-addr,end-addr triples to scan " \
542                      "additionally"); \
543  I2C_CLIENT_MODULE_PARM(ignore, \
544                      "List of adapter,address pairs not to scan"); \
545  I2C_CLIENT_MODULE_PARM(ignore_range, \
546                      "List of adapter,start-addr,end-addr triples not to " \
547                      "scan"); \
548  I2C_CLIENT_MODULE_PARM(force, \
549                      "List of adapter,address pairs to boldly assume " \
550                      "to be present"); \
551  static struct i2c_client_address_data addr_data = \
552                                       {normal_i2c, normal_i2c_range, \
553                                        probe, probe_range, \
554                                        ignore, ignore_range, \
555                                        force}
556
557/* Detect whether we are on the isa bus. If this returns true, all i2c
558   access will fail! */
559#define i2c_is_isa_client(clientptr) \
560        ((clientptr)->adapter->algo->id == I2C_ALGO_ISA)
561#define i2c_is_isa_adapter(adapptr) \
562        ((adapptr)->algo->id == I2C_ALGO_ISA)
563
564#endif /* _LINUX_I2C_H */
Note: See TracBrowser for help on using the browser.