diff options
Diffstat (limited to 'include/linux/i2c.h')
| -rw-r--r-- | include/linux/i2c.h | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 9b5d04768c2c..71e50d3e492f 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* ------------------------------------------------------------------------- */ | 1 | /* ------------------------------------------------------------------------- */ |
| 2 | /* */ | 2 | /* */ |
| 3 | /* i2c.h - definitions for the i2c-bus interface */ | 3 | /* i2c.h - definitions for the i2c-bus interface */ |
| 4 | /* */ | 4 | /* */ |
| 5 | /* ------------------------------------------------------------------------- */ | 5 | /* ------------------------------------------------------------------------- */ |
| 6 | /* Copyright (C) 1995-2000 Simon G. Vogl | 6 | /* Copyright (C) 1995-2000 Simon G. Vogl |
| 7 | 7 | ||
| @@ -27,7 +27,7 @@ | |||
| 27 | #define _LINUX_I2C_H | 27 | #define _LINUX_I2C_H |
| 28 | 28 | ||
| 29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
| 30 | #ifdef __KERNEL__ | 30 | #ifdef __KERNEL__ |
| 31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
| 32 | #include <linux/i2c-id.h> | 32 | #include <linux/i2c-id.h> |
| 33 | #include <linux/mod_devicetable.h> | 33 | #include <linux/mod_devicetable.h> |
| @@ -53,8 +53,8 @@ union i2c_smbus_data; | |||
| 53 | 53 | ||
| 54 | /* | 54 | /* |
| 55 | * The master routines are the ones normally used to transmit data to devices | 55 | * The master routines are the ones normally used to transmit data to devices |
| 56 | * on a bus (or read from them). Apart from two basic transfer functions to | 56 | * on a bus (or read from them). Apart from two basic transfer functions to |
| 57 | * transmit one message at a time, a more complex version can be used to | 57 | * transmit one message at a time, a more complex version can be used to |
| 58 | * transmit an arbitrary number of messages without interruption. | 58 | * transmit an arbitrary number of messages without interruption. |
| 59 | */ | 59 | */ |
| 60 | extern int i2c_master_send(struct i2c_client *,const char* ,int); | 60 | extern int i2c_master_send(struct i2c_client *,const char* ,int); |
| @@ -67,10 +67,10 @@ extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | |||
| 67 | 67 | ||
| 68 | /* This is the very generalized SMBus access routine. You probably do not | 68 | /* This is the very generalized SMBus access routine. You probably do not |
| 69 | want to use this, though; one of the functions below may be much easier, | 69 | want to use this, though; one of the functions below may be much easier, |
| 70 | and probably just as fast. | 70 | and probably just as fast. |
| 71 | Note that we use i2c_adapter here, because you do not need a specific | 71 | Note that we use i2c_adapter here, because you do not need a specific |
| 72 | smbus adapter to call this function. */ | 72 | smbus adapter to call this function. */ |
| 73 | extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, | 73 | extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, |
| 74 | unsigned short flags, | 74 | unsigned short flags, |
| 75 | char read_write, u8 command, int size, | 75 | char read_write, u8 command, int size, |
| 76 | union i2c_smbus_data * data); | 76 | union i2c_smbus_data * data); |
| @@ -112,14 +112,14 @@ struct i2c_driver { | |||
| 112 | 112 | ||
| 113 | /* Notifies the driver that a new bus has appeared. This routine | 113 | /* Notifies the driver that a new bus has appeared. This routine |
| 114 | * can be used by the driver to test if the bus meets its conditions | 114 | * can be used by the driver to test if the bus meets its conditions |
| 115 | * & seek for the presence of the chip(s) it supports. If found, it | 115 | * & seek for the presence of the chip(s) it supports. If found, it |
| 116 | * registers the client(s) that are on the bus to the i2c admin. via | 116 | * registers the client(s) that are on the bus to the i2c admin. via |
| 117 | * i2c_attach_client. | 117 | * i2c_attach_client. |
| 118 | */ | 118 | */ |
| 119 | int (*attach_adapter)(struct i2c_adapter *); | 119 | int (*attach_adapter)(struct i2c_adapter *); |
| 120 | int (*detach_adapter)(struct i2c_adapter *); | 120 | int (*detach_adapter)(struct i2c_adapter *); |
| 121 | 121 | ||
| 122 | /* tells the driver that a client is about to be deleted & gives it | 122 | /* tells the driver that a client is about to be deleted & gives it |
| 123 | * the chance to remove its private data. Also, if the client struct | 123 | * the chance to remove its private data. Also, if the client struct |
| 124 | * has been dynamically allocated by the driver in the function above, | 124 | * has been dynamically allocated by the driver in the function above, |
| 125 | * it must be freed here. | 125 | * it must be freed here. |
| @@ -139,13 +139,13 @@ struct i2c_driver { | |||
| 139 | #define I2C_NAME_SIZE 50 | 139 | #define I2C_NAME_SIZE 50 |
| 140 | 140 | ||
| 141 | /* | 141 | /* |
| 142 | * i2c_client identifies a single device (i.e. chip) that is connected to an | 142 | * i2c_client identifies a single device (i.e. chip) that is connected to an |
| 143 | * i2c bus. The behaviour is defined by the routines of the driver. This | 143 | * i2c bus. The behaviour is defined by the routines of the driver. This |
| 144 | * function is mainly used for lookup & other admin. functions. | 144 | * function is mainly used for lookup & other admin. functions. |
| 145 | */ | 145 | */ |
| 146 | struct i2c_client { | 146 | struct i2c_client { |
| 147 | unsigned int flags; /* div., see below */ | 147 | unsigned int flags; /* div., see below */ |
| 148 | unsigned short addr; /* chip address - NOTE: 7bit */ | 148 | unsigned short addr; /* chip address - NOTE: 7bit */ |
| 149 | /* addresses are stored in the */ | 149 | /* addresses are stored in the */ |
| 150 | /* _LOWER_ 7 bits */ | 150 | /* _LOWER_ 7 bits */ |
| 151 | struct i2c_adapter *adapter; /* the adapter we sit on */ | 151 | struct i2c_adapter *adapter; /* the adapter we sit on */ |
| @@ -182,14 +182,14 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data) | |||
| 182 | */ | 182 | */ |
| 183 | struct i2c_algorithm { | 183 | struct i2c_algorithm { |
| 184 | /* If an adapter algorithm can't do I2C-level access, set master_xfer | 184 | /* If an adapter algorithm can't do I2C-level access, set master_xfer |
| 185 | to NULL. If an adapter algorithm can do SMBus access, set | 185 | to NULL. If an adapter algorithm can do SMBus access, set |
| 186 | smbus_xfer. If set to NULL, the SMBus protocol is simulated | 186 | smbus_xfer. If set to NULL, the SMBus protocol is simulated |
| 187 | using common I2C messages */ | 187 | using common I2C messages */ |
| 188 | /* master_xfer should return the number of messages successfully | 188 | /* master_xfer should return the number of messages successfully |
| 189 | processed, or a negative value on error */ | 189 | processed, or a negative value on error */ |
| 190 | int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, | 190 | int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, |
| 191 | int num); | 191 | int num); |
| 192 | int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, | 192 | int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, |
| 193 | unsigned short flags, char read_write, | 193 | unsigned short flags, char read_write, |
| 194 | u8 command, int size, union i2c_smbus_data * data); | 194 | u8 command, int size, union i2c_smbus_data * data); |
| 195 | 195 | ||
| @@ -216,6 +216,7 @@ struct i2c_adapter { | |||
| 216 | int (*client_unregister)(struct i2c_client *); | 216 | int (*client_unregister)(struct i2c_client *); |
| 217 | 217 | ||
| 218 | /* data fields that are valid for all devices */ | 218 | /* data fields that are valid for all devices */ |
| 219 | u8 level; /* nesting level for lockdep */ | ||
| 219 | struct mutex bus_lock; | 220 | struct mutex bus_lock; |
| 220 | struct mutex clist_lock; | 221 | struct mutex clist_lock; |
| 221 | 222 | ||
| @@ -316,7 +317,7 @@ extern int i2c_check_addr (struct i2c_adapter *adapter, int addr); | |||
| 316 | * It will only call found_proc if some client is connected at the | 317 | * It will only call found_proc if some client is connected at the |
| 317 | * specific address (unless a 'force' matched); | 318 | * specific address (unless a 'force' matched); |
| 318 | */ | 319 | */ |
| 319 | extern int i2c_probe(struct i2c_adapter *adapter, | 320 | extern int i2c_probe(struct i2c_adapter *adapter, |
| 320 | struct i2c_client_address_data *address_data, | 321 | struct i2c_client_address_data *address_data, |
| 321 | int (*found_proc) (struct i2c_adapter *, int, int)); | 322 | int (*found_proc) (struct i2c_adapter *, int, int)); |
| 322 | 323 | ||
| @@ -352,15 +353,15 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap) | |||
| 352 | */ | 353 | */ |
| 353 | struct i2c_msg { | 354 | struct i2c_msg { |
| 354 | __u16 addr; /* slave address */ | 355 | __u16 addr; /* slave address */ |
| 355 | __u16 flags; | 356 | __u16 flags; |
| 356 | #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ | 357 | #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ |
| 357 | #define I2C_M_RD 0x01 | 358 | #define I2C_M_RD 0x01 |
| 358 | #define I2C_M_NOSTART 0x4000 | 359 | #define I2C_M_NOSTART 0x4000 |
| 359 | #define I2C_M_REV_DIR_ADDR 0x2000 | 360 | #define I2C_M_REV_DIR_ADDR 0x2000 |
| 360 | #define I2C_M_IGNORE_NAK 0x1000 | 361 | #define I2C_M_IGNORE_NAK 0x1000 |
| 361 | #define I2C_M_NO_RD_ACK 0x0800 | 362 | #define I2C_M_NO_RD_ACK 0x0800 |
| 362 | __u16 len; /* msg length */ | 363 | __u16 len; /* msg length */ |
| 363 | __u8 *buf; /* pointer to msg data */ | 364 | __u8 *buf; /* pointer to msg data */ |
| 364 | }; | 365 | }; |
| 365 | 366 | ||
| 366 | /* To determine what functionality is present */ | 367 | /* To determine what functionality is present */ |
| @@ -370,16 +371,16 @@ struct i2c_msg { | |||
| 370 | #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ | 371 | #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ |
| 371 | #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ | 372 | #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ |
| 372 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ | 373 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ |
| 373 | #define I2C_FUNC_SMBUS_QUICK 0x00010000 | 374 | #define I2C_FUNC_SMBUS_QUICK 0x00010000 |
| 374 | #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 | 375 | #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 |
| 375 | #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 | 376 | #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 |
| 376 | #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 | 377 | #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 |
| 377 | #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 | 378 | #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 |
| 378 | #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 | 379 | #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 |
| 379 | #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 | 380 | #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 |
| 380 | #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 | 381 | #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 |
| 381 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 | 382 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 |
| 382 | #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 | 383 | #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 |
| 383 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ | 384 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ |
| 384 | #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ | 385 | #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ |
| 385 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ | 386 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ |
| @@ -406,10 +407,10 @@ struct i2c_msg { | |||
| 406 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ | 407 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ |
| 407 | I2C_FUNC_SMBUS_I2C_BLOCK) | 408 | I2C_FUNC_SMBUS_I2C_BLOCK) |
| 408 | 409 | ||
| 409 | /* | 410 | /* |
| 410 | * Data for SMBus Messages | 411 | * Data for SMBus Messages |
| 411 | */ | 412 | */ |
| 412 | #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ | 413 | #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ |
| 413 | union i2c_smbus_data { | 414 | union i2c_smbus_data { |
| 414 | __u8 byte; | 415 | __u8 byte; |
| 415 | __u16 word; | 416 | __u16 word; |
| @@ -421,11 +422,11 @@ union i2c_smbus_data { | |||
| 421 | #define I2C_SMBUS_READ 1 | 422 | #define I2C_SMBUS_READ 1 |
| 422 | #define I2C_SMBUS_WRITE 0 | 423 | #define I2C_SMBUS_WRITE 0 |
| 423 | 424 | ||
| 424 | /* SMBus transaction types (size parameter in the above functions) | 425 | /* SMBus transaction types (size parameter in the above functions) |
| 425 | Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ | 426 | Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ |
| 426 | #define I2C_SMBUS_QUICK 0 | 427 | #define I2C_SMBUS_QUICK 0 |
| 427 | #define I2C_SMBUS_BYTE 1 | 428 | #define I2C_SMBUS_BYTE 1 |
| 428 | #define I2C_SMBUS_BYTE_DATA 2 | 429 | #define I2C_SMBUS_BYTE_DATA 2 |
| 429 | #define I2C_SMBUS_WORD_DATA 3 | 430 | #define I2C_SMBUS_WORD_DATA 3 |
| 430 | #define I2C_SMBUS_PROC_CALL 4 | 431 | #define I2C_SMBUS_PROC_CALL 4 |
| 431 | #define I2C_SMBUS_BLOCK_DATA 5 | 432 | #define I2C_SMBUS_BLOCK_DATA 5 |
| @@ -434,15 +435,15 @@ union i2c_smbus_data { | |||
| 434 | 435 | ||
| 435 | 436 | ||
| 436 | /* ----- commands for the ioctl like i2c_command call: | 437 | /* ----- commands for the ioctl like i2c_command call: |
| 437 | * note that additional calls are defined in the algorithm and hw | 438 | * note that additional calls are defined in the algorithm and hw |
| 438 | * dependent layers - these can be listed here, or see the | 439 | * dependent layers - these can be listed here, or see the |
| 439 | * corresponding header files. | 440 | * corresponding header files. |
| 440 | */ | 441 | */ |
| 441 | /* -> bit-adapter specific ioctls */ | 442 | /* -> bit-adapter specific ioctls */ |
| 442 | #define I2C_RETRIES 0x0701 /* number of times a device address */ | 443 | #define I2C_RETRIES 0x0701 /* number of times a device address */ |
| 443 | /* should be polled when not */ | 444 | /* should be polled when not */ |
| 444 | /* acknowledging */ | 445 | /* acknowledging */ |
| 445 | #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ | 446 | #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ |
| 446 | 447 | ||
| 447 | 448 | ||
| 448 | /* this is for i2c-dev.c */ | 449 | /* this is for i2c-dev.c */ |
