| 1 | /* ------------------------------------------------------------------------- */ |
|---|
| 2 | /* */ |
|---|
| 3 | /* i2c.h - definitions for the i2c-bus interface */ |
|---|
| 4 | /* */ |
|---|
| 5 | /* ------------------------------------------------------------------------- */ |
|---|
| 6 | /* Copyright (C) 1995-1999 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 | /* $Revision$ $Date$*/ |
|---|
| 23 | /* ------------------------------------------------------------------------- */ |
|---|
| 24 | |
|---|
| 25 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and |
|---|
| 26 | Frodo Looijaard <frodol@dds.nl> */ |
|---|
| 27 | |
|---|
| 28 | #ifndef I2C_H |
|---|
| 29 | #define I2C_H |
|---|
| 30 | |
|---|
| 31 | #ifdef __KERNEL__ |
|---|
| 32 | |
|---|
| 33 | /* --- Includes and compatibility declarations ------------------------ */ |
|---|
| 34 | |
|---|
| 35 | #include <linux/version.h> |
|---|
| 36 | #ifndef KERNEL_VERSION |
|---|
| 37 | #define KERNEL_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c)) |
|---|
| 38 | #endif |
|---|
| 39 | |
|---|
| 40 | #include <asm/page.h> /* for 2.2.xx */ |
|---|
| 41 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,0,25) |
|---|
| 42 | #include <linux/sched.h> |
|---|
| 43 | #else |
|---|
| 44 | #include <asm/semaphore.h> |
|---|
| 45 | #endif |
|---|
| 46 | #include <linux/types.h> |
|---|
| 47 | #include <linux/config.h> |
|---|
| 48 | |
|---|
| 49 | /* --- General options ------------------------------------------------ */ |
|---|
| 50 | |
|---|
| 51 | #define I2C_ALGO_MAX 4 /* control memory consumption */ |
|---|
| 52 | #define I2C_ADAP_MAX 16 |
|---|
| 53 | #define I2C_DRIVER_MAX 16 |
|---|
| 54 | #define I2C_CLIENT_MAX 32 |
|---|
| 55 | #define I2C_DUMMY_MAX 4 |
|---|
| 56 | |
|---|
| 57 | struct i2c_msg; |
|---|
| 58 | struct i2c_algorithm; |
|---|
| 59 | struct i2c_adapter; |
|---|
| 60 | struct i2c_client; |
|---|
| 61 | struct i2c_driver; |
|---|
| 62 | struct i2c_client_address_data; |
|---|
| 63 | union i2c_smbus_data; |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | /* |
|---|
| 67 | * The master routines are the ones normally used to transmit data to devices |
|---|
| 68 | * on a bus (or read from them). Apart from two basic transfer functions to |
|---|
| 69 | * transmit one message at a time, a more complex version can be used to |
|---|
| 70 | * transmit an arbitrary number of messages without interruption. |
|---|
| 71 | */ |
|---|
| 72 | extern int i2c_master_send(struct i2c_client *,const char* ,int); |
|---|
| 73 | extern int i2c_master_recv(struct i2c_client *,char* ,int); |
|---|
| 74 | |
|---|
| 75 | /* Transfer num messages. |
|---|
| 76 | */ |
|---|
| 77 | extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],int num); |
|---|
| 78 | |
|---|
| 79 | /* |
|---|
| 80 | * Some adapter types (i.e. PCF 8584 based ones) may support slave behaviuor. |
|---|
| 81 | * This is not tested/implemented yet and will change in the future. |
|---|
| 82 | */ |
|---|
| 83 | extern int i2c_slave_send(struct i2c_client *,char*,int); |
|---|
| 84 | extern int i2c_slave_recv(struct i2c_client *,char*,int); |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | /* |
|---|
| 88 | * I2C Message - could be used in the current interface to |
|---|
| 89 | */ |
|---|
| 90 | struct i2c_msg { |
|---|
| 91 | unsigned char addr; /* slave address */ |
|---|
| 92 | unsigned short flags; |
|---|
| 93 | #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ |
|---|
| 94 | #define I2C_M_TEN0 0x10 /* herein lie the first 2 bits */ |
|---|
| 95 | #define I2C_M_TEN1 0x12 |
|---|
| 96 | #define I2C_M_TEN2 0x14 |
|---|
| 97 | #define I2C_M_TEN3 0x16 |
|---|
| 98 | #define I2C_M_TENMASK 0x06 |
|---|
| 99 | #define I2C_M_RD 0x01 |
|---|
| 100 | #define I2C_M_PROBE 0x20 |
|---|
| 101 | short len; /* msg length */ |
|---|
| 102 | char *buf; /* pointer to msg data */ |
|---|
| 103 | }; |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | /* This is the very generalized SMBus access routine. You probably do not |
|---|
| 107 | want to use this, though; one of the functions below may be much easier, |
|---|
| 108 | and probably just as fast. |
|---|
| 109 | Note that we use i2c_adapter here, because you do not need a specific |
|---|
| 110 | smbus adapter to call this function. */ |
|---|
| 111 | extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u8 addr, |
|---|
| 112 | char read_write, u8 command, int size, |
|---|
| 113 | union i2c_smbus_data * data); |
|---|
| 114 | |
|---|
| 115 | /* Now follow the 'nice' access routines. These also document the calling |
|---|
| 116 | conventions of smbus_access. */ |
|---|
| 117 | |
|---|
| 118 | extern s32 i2c_smbus_write_quick(struct i2c_adapter * adapter, u8 addr, |
|---|
| 119 | u8 value); |
|---|
| 120 | extern s32 i2c_smbus_read_byte(struct i2c_adapter * adapter,u8 addr); |
|---|
| 121 | extern s32 i2c_smbus_write_byte(struct i2c_adapter * adapter, u8 addr, |
|---|
| 122 | u8 value); |
|---|
| 123 | extern s32 i2c_smbus_read_byte_data(struct i2c_adapter * adapter, |
|---|
| 124 | u8 addr, u8 command); |
|---|
| 125 | extern s32 i2c_smbus_write_byte_data(struct i2c_adapter * adapter, |
|---|
| 126 | u8 addr, u8 command, u8 value); |
|---|
| 127 | extern s32 i2c_smbus_read_word_data(struct i2c_adapter * adapter, |
|---|
| 128 | u8 addr, u8 command); |
|---|
| 129 | extern s32 i2c_smbus_write_word_data(struct i2c_adapter * adapter, |
|---|
| 130 | u8 addr, u8 command, u16 value); |
|---|
| 131 | extern s32 i2c_smbus_process_call(struct i2c_adapter * adapter, |
|---|
| 132 | u8 addr, u8 command, u16 value); |
|---|
| 133 | /* Returns the number of read bytes */ |
|---|
| 134 | extern s32 i2c_smbus_read_block_data(struct i2c_adapter * adapter, |
|---|
| 135 | u8 addr, u8 command, u8 *values); |
|---|
| 136 | extern s32 i2c_smbus_write_block_data(struct i2c_adapter * adapter, |
|---|
| 137 | u8 addr, u8 command, u8 length, |
|---|
| 138 | u8 *values); |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | /* |
|---|
| 142 | * A driver is capable of handling one or more physical devices present on |
|---|
| 143 | * I2C adapters. This information is used to inform the driver of adapter |
|---|
| 144 | * events. |
|---|
| 145 | */ |
|---|
| 146 | |
|---|
| 147 | struct i2c_driver { |
|---|
| 148 | char name[32]; |
|---|
| 149 | int id; |
|---|
| 150 | unsigned int flags; /* div., see below */ |
|---|
| 151 | |
|---|
| 152 | /* Notifies the driver that a new bus has appeared. This routine |
|---|
| 153 | * can be used by the driver to test if the bus meets its conditions |
|---|
| 154 | * & seek for the presence of the chip(s) it supports. If found, it |
|---|
| 155 | * registers the client(s) that are on the bus to the i2c admin. via |
|---|
| 156 | * i2c_attach_client. |
|---|
| 157 | */ |
|---|
| 158 | int (*attach_adapter)(struct i2c_adapter *); |
|---|
| 159 | |
|---|
| 160 | /* tells the driver that a client is about to be deleted & gives it |
|---|
| 161 | * the chance to remove its private data. Also, if the client struct |
|---|
| 162 | * has been dynamically allocated by the driver in the function above, |
|---|
| 163 | * it must be freed here. |
|---|
| 164 | */ |
|---|
| 165 | int (*detach_client)(struct i2c_client *); |
|---|
| 166 | |
|---|
| 167 | /* a ioctl like command that can be used to perform specific functions |
|---|
| 168 | * with the device. |
|---|
| 169 | */ |
|---|
| 170 | int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); |
|---|
| 171 | |
|---|
| 172 | /* These two are mainly used for bookkeeping & dynamic unloading of |
|---|
| 173 | * kernel modules. inc_use tells the driver that a client is being |
|---|
| 174 | * used by another module & that it should increase its ref. counter. |
|---|
| 175 | * dec_use is the inverse operation. |
|---|
| 176 | * NB: Make sure you have no circular dependencies, or else you get a |
|---|
| 177 | * deadlock when trying to unload the modules. |
|---|
| 178 | * You should use the i2c_{inc,dec}_use_client functions instead of |
|---|
| 179 | * calling this function directly. |
|---|
| 180 | */ |
|---|
| 181 | void (*inc_use)(struct i2c_client *client); |
|---|
| 182 | void (*dec_use)(struct i2c_client *client); |
|---|
| 183 | }; |
|---|
| 184 | |
|---|
| 185 | /* |
|---|
| 186 | * i2c_client identifies a single device (i.e. chip) that is connected to an |
|---|
| 187 | * i2c bus. The behaviour is defined by the routines of the driver. This |
|---|
| 188 | * function is mainly used for lookup & other admin. functions. |
|---|
| 189 | */ |
|---|
| 190 | struct i2c_client { |
|---|
| 191 | char name[32]; |
|---|
| 192 | int id; |
|---|
| 193 | unsigned int flags; /* div., see below */ |
|---|
| 194 | unsigned int addr; /* chip address - NOTE: 7bit */ |
|---|
| 195 | /* addresses are stored in the */ |
|---|
| 196 | /* _LOWER_ 7 bits of this char */ |
|---|
| 197 | /* 10 bit addresses use the full*/ |
|---|
| 198 | /* 8 bits & the flags like in */ |
|---|
| 199 | /* i2c_msg */ |
|---|
| 200 | /* addr: unsigned int to make lm_sensors i2c-isa adapter work |
|---|
| 201 | more cleanly. It does not take any more memory space, due to |
|---|
| 202 | alignment considerations */ |
|---|
| 203 | struct i2c_adapter *adapter; /* the adapter we sit on */ |
|---|
| 204 | struct i2c_driver *driver; /* and our access routines */ |
|---|
| 205 | void *data; /* for the clients */ |
|---|
| 206 | }; |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | /* |
|---|
| 210 | * The following structs are for those who like to implement new bus drivers: |
|---|
| 211 | * i2c_algorithm is the interface to a class of hardware solutions which can |
|---|
| 212 | * be addressed using the same bus algorithms - i.e. bit-banging or the PCF8584 |
|---|
| 213 | * to name two of the most common. |
|---|
| 214 | */ |
|---|
| 215 | struct i2c_algorithm { |
|---|
| 216 | char name[32]; /* textual description */ |
|---|
| 217 | unsigned int id; |
|---|
| 218 | |
|---|
| 219 | /* If a adapter algorithm can't to I2C-level access, set master_xfer |
|---|
| 220 | to NULL. If an adapter algorithm can do SMBus access, set |
|---|
| 221 | smbus_xfer. If set to NULL, the SMBus protocol is simulated |
|---|
| 222 | using common I2C messages */ |
|---|
| 223 | int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg msgs[], |
|---|
| 224 | int num); |
|---|
| 225 | int (*smbus_xfer) (struct i2c_adapter *adap, u8 addr, char read_write, |
|---|
| 226 | u8 command, int size, union i2c_smbus_data * data); |
|---|
| 227 | |
|---|
| 228 | /* --- these optional/future use for some adapter types.*/ |
|---|
| 229 | int (*slave_send)(struct i2c_adapter *,char*,int); |
|---|
| 230 | int (*slave_recv)(struct i2c_adapter *,char*,int); |
|---|
| 231 | |
|---|
| 232 | /* --- ioctl like call to set div. parameters. */ |
|---|
| 233 | int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long); |
|---|
| 234 | |
|---|
| 235 | }; |
|---|
| 236 | |
|---|
| 237 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29) |
|---|
| 238 | struct proc_dir_entry; |
|---|
| 239 | #endif |
|---|
| 240 | |
|---|
| 241 | /* |
|---|
| 242 | * i2c_adapter is the structure used to identify a physical i2c bus along |
|---|
| 243 | * with the access algorithms necessary to access it. |
|---|
| 244 | */ |
|---|
| 245 | struct i2c_adapter { |
|---|
| 246 | char name[32]; /* some useful name to identify the adapter */ |
|---|
| 247 | unsigned int id;/* == is algo->id | hwdep.struct->id, */ |
|---|
| 248 | /* for registered values see below */ |
|---|
| 249 | struct i2c_algorithm *algo;/* the algorithm to access the bus */ |
|---|
| 250 | void *algo_data; |
|---|
| 251 | |
|---|
| 252 | /* --- These may be NULL, but should increase the module use count */ |
|---|
| 253 | void (*inc_use)(struct i2c_adapter *); |
|---|
| 254 | void (*dec_use)(struct i2c_adapter *); |
|---|
| 255 | |
|---|
| 256 | /* --- administration stuff. */ |
|---|
| 257 | int (*client_register)(struct i2c_client *); |
|---|
| 258 | int (*client_unregister)(struct i2c_client *); |
|---|
| 259 | |
|---|
| 260 | void *data; /* private data for the adapter */ |
|---|
| 261 | /* some data fields that are used by all types */ |
|---|
| 262 | /* these data fields are readonly to the public */ |
|---|
| 263 | /* and can be set via the i2c_ioctl call */ |
|---|
| 264 | |
|---|
| 265 | /* data fields that are valid for all devices */ |
|---|
| 266 | struct semaphore lock; |
|---|
| 267 | unsigned int flags;/* flags specifying div. data */ |
|---|
| 268 | |
|---|
| 269 | struct i2c_client *clients[I2C_CLIENT_MAX]; |
|---|
| 270 | int client_count; |
|---|
| 271 | |
|---|
| 272 | int timeout; |
|---|
| 273 | int retries; |
|---|
| 274 | |
|---|
| 275 | #ifdef CONFIG_PROC_FS |
|---|
| 276 | /* No need to set this when you initialize the adapter */ |
|---|
| 277 | int inode; |
|---|
| 278 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29) |
|---|
| 279 | struct proc_dir_entry *proc_entry; |
|---|
| 280 | #endif |
|---|
| 281 | #endif /* def CONFIG_PROC_FS */ |
|---|
| 282 | }; |
|---|
| 283 | |
|---|
| 284 | /*flags for the driver struct: */ |
|---|
| 285 | #define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */ |
|---|
| 286 | #define I2C_DF_DUMMY 0x02 /* do not connect any clients */ |
|---|
| 287 | |
|---|
| 288 | /* i2c_client_address_data is the struct for holding default client |
|---|
| 289 | * addresses for a driver and for the parameters supplied on the |
|---|
| 290 | * command line |
|---|
| 291 | */ |
|---|
| 292 | struct i2c_client_address_data { |
|---|
| 293 | unsigned short *normal_i2c; |
|---|
| 294 | unsigned short *normal_i2c_range; |
|---|
| 295 | unsigned short *probe; |
|---|
| 296 | unsigned short *probe_range; |
|---|
| 297 | unsigned short *ignore; |
|---|
| 298 | unsigned short *ignore_range; |
|---|
| 299 | unsigned short *force; |
|---|
| 300 | }; |
|---|
| 301 | |
|---|
| 302 | /* Internal numbers to terminate lists */ |
|---|
| 303 | #define I2C_CLIENT_END 0xfffe |
|---|
| 304 | |
|---|
| 305 | /* The numbers to use to set I2C bus address */ |
|---|
| 306 | #define ANY_I2C_BUS 0xffff |
|---|
| 307 | |
|---|
| 308 | /* The length of the option lists */ |
|---|
| 309 | #define I2C_CLIENT_MAX_OPTS 48 |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | /* ----- functions exported by i2c.o */ |
|---|
| 313 | |
|---|
| 314 | /* administration... |
|---|
| 315 | */ |
|---|
| 316 | extern int i2c_add_adapter(struct i2c_adapter *); |
|---|
| 317 | extern int i2c_del_adapter(struct i2c_adapter *); |
|---|
| 318 | |
|---|
| 319 | extern int i2c_add_driver(struct i2c_driver *); |
|---|
| 320 | extern int i2c_del_driver(struct i2c_driver *); |
|---|
| 321 | |
|---|
| 322 | extern int i2c_attach_client(struct i2c_client *); |
|---|
| 323 | extern int i2c_detach_client(struct i2c_client *); |
|---|
| 324 | |
|---|
| 325 | /* Only call these if you grab a resource that makes unloading the |
|---|
| 326 | client and the adapter it is on completely impossible. Like when a |
|---|
| 327 | /proc directory is entered. */ |
|---|
| 328 | extern void i2c_inc_use_client(struct i2c_client *); |
|---|
| 329 | extern void i2c_dec_use_client(struct i2c_client *); |
|---|
| 330 | |
|---|
| 331 | |
|---|
| 332 | /* Detect function. It itterates over all possible addresses itself. |
|---|
| 333 | * It will only call found_proc if some client is connected at the |
|---|
| 334 | * specific address (unless a 'force' matched); |
|---|
| 335 | */ |
|---|
| 336 | typedef int i2c_client_found_addr_proc (struct i2c_adapter *adapter, |
|---|
| 337 | int addr, int kind); |
|---|
| 338 | |
|---|
| 339 | extern int i2c_probe(struct i2c_adapter *adapter, |
|---|
| 340 | struct i2c_client_address_data *address_data, |
|---|
| 341 | i2c_client_found_addr_proc *found_proc); |
|---|
| 342 | |
|---|
| 343 | /* An ioctl like call to set div. parameters of the adapter. |
|---|
| 344 | */ |
|---|
| 345 | extern int i2c_control(struct i2c_client *,unsigned int, unsigned long); |
|---|
| 346 | |
|---|
| 347 | /* This call returns a unique low identifier for each registered adapter, |
|---|
| 348 | * or -1 if the adapter was not regisitered. |
|---|
| 349 | */ |
|---|
| 350 | extern int i2c_adapter_id(struct i2c_adapter *adap); |
|---|
| 351 | |
|---|
| 352 | #endif /* __KERNEL__ */ |
|---|
| 353 | |
|---|
| 354 | /* |
|---|
| 355 | * Data for SMBus Messages |
|---|
| 356 | */ |
|---|
| 357 | union i2c_smbus_data { |
|---|
| 358 | __u8 byte; |
|---|
| 359 | __u16 word; |
|---|
| 360 | __u8 block[33]; /* block[0] is used for length */ |
|---|
| 361 | }; |
|---|
| 362 | |
|---|
| 363 | /* smbus_access read or write markers */ |
|---|
| 364 | #define I2C_SMBUS_READ 1 |
|---|
| 365 | #define I2C_SMBUS_WRITE 0 |
|---|
| 366 | |
|---|
| 367 | /* SMBus transaction types (size parameter in the above functions) |
|---|
| 368 | Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ |
|---|
| 369 | #define I2C_SMBUS_QUICK 0 |
|---|
| 370 | #define I2C_SMBUS_BYTE 1 |
|---|
| 371 | #define I2C_SMBUS_BYTE_DATA 2 |
|---|
| 372 | #define I2C_SMBUS_WORD_DATA 3 |
|---|
| 373 | #define I2C_SMBUS_PROC_CALL 4 |
|---|
| 374 | #define I2C_SMBUS_BLOCK_DATA 5 |
|---|
| 375 | |
|---|
| 376 | |
|---|
| 377 | /* ----- commands for the ioctl like i2c_command call: |
|---|
| 378 | * note that additional calls are defined in the algorithm and hw |
|---|
| 379 | * dependent layers - these can be listed here, or see the |
|---|
| 380 | * corresponding header files. |
|---|
| 381 | */ |
|---|
| 382 | /* -> bit-adapter specific ioctls */ |
|---|
| 383 | #define I2C_RETRIES 0x0701 /* number times a device adress should */ |
|---|
| 384 | /* be polled when not acknowledging */ |
|---|
| 385 | #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ |
|---|
| 386 | |
|---|
| 387 | |
|---|
| 388 | /* this is for i2c-dev.c */ |
|---|
| 389 | #define I2C_SLAVE 0x0703 /* Change slave address */ |
|---|
| 390 | /* Attn.: Slave address is 7 bits long, */ |
|---|
| 391 | /* these are to be passed as the */ |
|---|
| 392 | /* lowest 7 bits in the arg. */ |
|---|
| 393 | /* for 10-bit addresses pass lower 8bits*/ |
|---|
| 394 | #define I2C_TENBIT 0x0704 /* with 0-3 as arg to this call */ |
|---|
| 395 | /* a value <0 resets to 7 bits */ |
|---|
| 396 | |
|---|
| 397 | #define I2C_ACK_TEST 0x0710 /* See if a slave is at a specific adress */ |
|---|
| 398 | |
|---|
| 399 | #define I2C_SMBUS 0x0720 /* SMBus-level access */ |
|---|
| 400 | |
|---|
| 401 | /* ... algo-bit.c recognizes */ |
|---|
| 402 | #define I2C_UDELAY 0x0705 /* set delay in microsecs between each */ |
|---|
| 403 | /* written byte (except address) */ |
|---|
| 404 | #define I2C_MDELAY 0x0706 /* millisec delay between written bytes */ |
|---|
| 405 | |
|---|
| 406 | |
|---|
| 407 | /* |
|---|
| 408 | * ---- Driver types ----------------------------------------------------- |
|---|
| 409 | * device id name + number function description, i2c address(es) |
|---|
| 410 | * |
|---|
| 411 | * Range 1000-1999 range is defined in sensors/sensors.h |
|---|
| 412 | * Range 0x100 - 0x1ff is for V4L2 Common Components |
|---|
| 413 | */ |
|---|
| 414 | |
|---|
| 415 | #if 0 // v4l2-cc |
|---|
| 416 | #define I2C_DRIVERID_MSP3400 1 |
|---|
| 417 | #define I2C_DRIVERID_TUNER 2 |
|---|
| 418 | #define I2C_DRIVERID_TDA8425 4 /* stereo sound processor */ |
|---|
| 419 | #define I2C_DRIVERID_TDA9840 7 /* stereo sound processor */ |
|---|
| 420 | #define I2C_DRIVERID_BT829 19 /* pc to tv encoder */ |
|---|
| 421 | #endif |
|---|
| 422 | |
|---|
| 423 | /* Seems as we have drivers for the following devices too, |
|---|
| 424 | I'd like to get hold of the source files -- Kyosti */ |
|---|
| 425 | |
|---|
| 426 | #define I2C_DRIVERID_VIDEOTEXT 3 |
|---|
| 427 | #define I2C_DRIVERID_TEA6420 5 /* audio matrix switch */ |
|---|
| 428 | #define I2C_DRIVERID_TEA6415C 6 /* video matrix switch */ |
|---|
| 429 | #define I2C_DRIVERID_SAA7111A 8 /* video input processor */ |
|---|
| 430 | #define I2C_DRIVERID_SAA5281 9 /* videotext decoder */ |
|---|
| 431 | #define I2C_DRIVERID_SAA7112 10 /* video decoder, image scaler */ |
|---|
| 432 | #define I2C_DRIVERID_SAA7120 11 /* video encoder */ |
|---|
| 433 | #define I2C_DRIVERID_SAA7121 12 /* video encoder */ |
|---|
| 434 | #define I2C_DRIVERID_SAA7185B 13 /* video encoder */ |
|---|
| 435 | #define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */ |
|---|
| 436 | #define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */ |
|---|
| 437 | #define I2C_DRIVERID_PCF8582C 16 /* eeprom */ |
|---|
| 438 | #define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */ |
|---|
| 439 | |
|---|
| 440 | #define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */ |
|---|
| 441 | #define I2C_DRIVERID_EXP1 0xF1 |
|---|
| 442 | #define I2C_DRIVERID_EXP2 0xF2 |
|---|
| 443 | #define I2C_DRIVERID_EXP3 0xF3 |
|---|
| 444 | |
|---|
| 445 | #define I2C_DRIVERID_I2CDEV 900 |
|---|
| 446 | #define I2C_DRIVERID_I2CPROC 901 |
|---|
| 447 | |
|---|
| 448 | /* |
|---|
| 449 | * ---- Adapter types ---------------------------------------------------- |
|---|
| 450 | * |
|---|
| 451 | * First, we distinguish between several algorithms to access the hardware |
|---|
| 452 | * interface types, as a PCF 8584 needs other care than a bit adapter. |
|---|
| 453 | */ |
|---|
| 454 | |
|---|
| 455 | #define I2C_ALGO_NONE 0x000000 |
|---|
| 456 | #define I2C_ALGO_BIT 0x010000 /* bit style adapters */ |
|---|
| 457 | #define I2C_ALGO_PCF 0x020000 /* PCF 8584 style adapters */ |
|---|
| 458 | #define I2C_ALGO_ATI 0x030000 /* ATI video card */ |
|---|
| 459 | #define I2C_ALGO_SMBUS 0x040000 |
|---|
| 460 | #define I2C_ALGO_ISA 0x050000 /* lm_sensors ISA pseudo-adapter */ |
|---|
| 461 | #define I2C_ALGO_SAA7146 0x060000 /* SAA 7146 video decoder bus */ |
|---|
| 462 | #define I2C_ALGO_SAA7146A 0x060001 /* SAA 7146A - enhanced version */ |
|---|
| 463 | |
|---|
| 464 | |
|---|
| 465 | #define I2C_ALGO_EXP 0x800000 /* experimental */ |
|---|
| 466 | |
|---|
| 467 | #define I2C_ALGO_MASK 0xff0000 /* Mask for algorithms */ |
|---|
| 468 | #define I2C_ALGO_SHIFT 0x10 /* right shift to get index values */ |
|---|
| 469 | |
|---|
| 470 | #define I2C_HW_ADAPS 0x10000 /* # adapter types */ |
|---|
| 471 | #define I2C_HW_MASK 0xffff |
|---|
| 472 | |
|---|
| 473 | |
|---|
| 474 | /* hw specific modules that are defined per algorithm layer |
|---|
| 475 | */ |
|---|
| 476 | |
|---|
| 477 | /* --- Bit algorithm adapters */ |
|---|
| 478 | #define I2C_HW_B_LP 0x00 /* Parallel port Philips style adapter */ |
|---|
| 479 | #define I2C_HW_B_LPC 0x01 /* Parallel port, over control reg. */ |
|---|
| 480 | #define I2C_HW_B_SER 0x02 /* Serial line interface */ |
|---|
| 481 | #define I2C_HW_B_ELV 0x03 /* ELV Card */ |
|---|
| 482 | #define I2C_HW_B_VELLE 0x04 /* Vellemann K8000 */ |
|---|
| 483 | #define I2C_HW_B_BT848 0x05 /* BT848 video boards */ |
|---|
| 484 | #define I2C_HW_B_WNV 0x06 /* Winnov Videums */ |
|---|
| 485 | #define I2C_HW_B_VIA 0x07 /* Via vt82c586b */ |
|---|
| 486 | #define I2C_HW_B_HYDRA 0x08 /* Apple Hydra Mac I/O */ |
|---|
| 487 | |
|---|
| 488 | /* --- PCF 8584 based algorithms */ |
|---|
| 489 | #define I2C_HW_P_LP 0x00 /* Parallel port interface */ |
|---|
| 490 | #define I2C_HW_P_ISA 0x01 /* generic ISA Bus inteface card */ |
|---|
| 491 | #define I2C_HW_P_ELEK 0x02 /* Elektor ISA Bus inteface card */ |
|---|
| 492 | |
|---|
| 493 | /* --- SMBus only adapters */ |
|---|
| 494 | #define I2C_HW_SMBUS_PIIX4 0x00 |
|---|
| 495 | #define I2C_HW_SMBUS_ALI15X3 0x01 |
|---|
| 496 | #define I2C_HW_SMBUS_VIA2 0x02 |
|---|
| 497 | #define I2C_HW_SMBUS_VOODOO3 0x03 |
|---|
| 498 | #define I2C_HW_SMBUS_I801 0x04 |
|---|
| 499 | |
|---|
| 500 | /* --- ISA pseudo-adapter */ |
|---|
| 501 | #define I2C_HW_ISA 0x00 |
|---|
| 502 | |
|---|
| 503 | /* ----- I2C-DEV: char device interface stuff ------------------------- */ |
|---|
| 504 | |
|---|
| 505 | #define I2C_MAJOR 89 /* Device major number */ |
|---|
| 506 | |
|---|
| 507 | #ifdef __KERNEL__ |
|---|
| 508 | |
|---|
| 509 | # if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) |
|---|
| 510 | /* Hack to make this thing compile under 2.0.xx kernels |
|---|
| 511 | */ |
|---|
| 512 | |
|---|
| 513 | # ifdef MODULE |
|---|
| 514 | # define MODULE_AUTHOR(noone) |
|---|
| 515 | # define MODULE_DESCRIPTION(none) |
|---|
| 516 | # define MODULE_PARM(no,param) |
|---|
| 517 | # define MODULE_PARM_DESC(no,description) |
|---|
| 518 | # define EXPORT_SYMBOL(noexport) |
|---|
| 519 | # define EXPORT_NO_SYMBOLS |
|---|
| 520 | # endif |
|---|
| 521 | |
|---|
| 522 | # ifndef NULL |
|---|
| 523 | # define NULL ( (void *) 0 ) |
|---|
| 524 | # endif |
|---|
| 525 | #endif |
|---|
| 526 | |
|---|
| 527 | # ifndef ENODEV |
|---|
| 528 | # include <asm/errno.h> |
|---|
| 529 | # endif |
|---|
| 530 | |
|---|
| 531 | /* These defines are used for probing i2c client addresses */ |
|---|
| 532 | /* Default fill of many variables */ |
|---|
| 533 | #define I2C_CLIENT_DEFAULTS {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, \ |
|---|
| 536 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 537 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 538 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 539 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 540 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 541 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 542 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 543 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 544 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 545 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 546 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 547 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ |
|---|
| 548 | I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END} |
|---|
| 549 | |
|---|
| 550 | /* This is ugly. We need to evaluate I2C_CLIENT_MAX_OPTS before it is |
|---|
| 551 | stringified */ |
|---|
| 552 | #define I2C_CLIENT_MODPARM_AUX1(x) "1-" #x "h" |
|---|
| 553 | #define I2C_CLIENT_MODPARM_AUX(x) I2C_CLIENT_MODPARM_AUX1(x) |
|---|
| 554 | #define I2C_CLIENT_MODPARM I2C_CLIENT_MODPARM_AUX(I2C_CLIENT_MAX_OPTS) |
|---|
| 555 | |
|---|
| 556 | /* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the |
|---|
| 557 | module header */ |
|---|
| 558 | |
|---|
| 559 | #define I2C_CLIENT_MODULE_PARM(var,desc) \ |
|---|
| 560 | static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \ |
|---|
| 561 | MODULE_PARM(var,I2C_CLIENT_MODPARM); \ |
|---|
| 562 | MODULE_PARM_DESC(var,desc) |
|---|
| 563 | |
|---|
| 564 | /* This is the one you want to use in your own modules */ |
|---|
| 565 | #define I2C_CLIENT_INSMOD \ |
|---|
| 566 | I2C_CLIENT_MODULE_PARM(probe, \ |
|---|
| 567 | "List of adapter,address pairs to scan additionally"); \ |
|---|
| 568 | I2C_CLIENT_MODULE_PARM(probe_range, \ |
|---|
| 569 | "List of adapter,start-addr,end-addr triples to scan " \ |
|---|
| 570 | "additionally"); \ |
|---|
| 571 | I2C_CLIENT_MODULE_PARM(ignore, \ |
|---|
| 572 | "List of adapter,address pairs not to scan"); \ |
|---|
| 573 | I2C_CLIENT_MODULE_PARM(ignore_range, \ |
|---|
| 574 | "List of adapter,start-addr,end-addr triples not to " \ |
|---|
| 575 | "scan"); \ |
|---|
| 576 | I2C_CLIENT_MODULE_PARM(force, \ |
|---|
| 577 | "List of adapter,address pairs to boldly assume " \ |
|---|
| 578 | "to be present"); \ |
|---|
| 579 | static struct i2c_client_address_data addr_data = \ |
|---|
| 580 | {normal_i2c, normal_i2c_range, \ |
|---|
| 581 | probe, probe_range, \ |
|---|
| 582 | ignore, ignore_range, \ |
|---|
| 583 | force} |
|---|
| 584 | |
|---|
| 585 | #endif /* def __KERNEL__ */ |
|---|
| 586 | #endif /* I2C_H */ |
|---|