diff options
Diffstat (limited to 'include/linux/i2c.h')
| -rw-r--r-- | include/linux/i2c.h | 127 |
1 files changed, 2 insertions, 125 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 5970266930a2..800de224336b 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
| @@ -23,18 +23,16 @@ | |||
| 23 | 23 | ||
| 24 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and | 24 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and |
| 25 | Frodo Looijaard <frodol@dds.nl> */ | 25 | Frodo Looijaard <frodol@dds.nl> */ |
| 26 | |||
| 27 | #ifndef _LINUX_I2C_H | 26 | #ifndef _LINUX_I2C_H |
| 28 | #define _LINUX_I2C_H | 27 | #define _LINUX_I2C_H |
| 29 | 28 | ||
| 30 | #include <linux/types.h> | ||
| 31 | #ifdef __KERNEL__ | ||
| 32 | #include <linux/mod_devicetable.h> | 29 | #include <linux/mod_devicetable.h> |
| 33 | #include <linux/device.h> /* for struct device */ | 30 | #include <linux/device.h> /* for struct device */ |
| 34 | #include <linux/sched.h> /* for completion */ | 31 | #include <linux/sched.h> /* for completion */ |
| 35 | #include <linux/mutex.h> | 32 | #include <linux/mutex.h> |
| 36 | #include <linux/of.h> /* for struct device_node */ | 33 | #include <linux/of.h> /* for struct device_node */ |
| 37 | #include <linux/swab.h> /* for swab16 */ | 34 | #include <linux/swab.h> /* for swab16 */ |
| 35 | #include <uapi/linux/i2c.h> | ||
| 38 | 36 | ||
| 39 | extern struct bus_type i2c_bus_type; | 37 | extern struct bus_type i2c_bus_type; |
| 40 | extern struct device_type i2c_adapter_type; | 38 | extern struct device_type i2c_adapter_type; |
| @@ -144,7 +142,7 @@ extern s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client, | |||
| 144 | * The driver.owner field should be set to the module owner of this driver. | 142 | * The driver.owner field should be set to the module owner of this driver. |
| 145 | * The driver.name field should be set to the name of this driver. | 143 | * The driver.name field should be set to the name of this driver. |
| 146 | * | 144 | * |
| 147 | * For automatic device detection, both @detect and @address_data must | 145 | * For automatic device detection, both @detect and @address_list must |
| 148 | * be defined. @class should also be set, otherwise only devices forced | 146 | * be defined. @class should also be set, otherwise only devices forced |
| 149 | * with module parameters will be created. The detect function must | 147 | * with module parameters will be created. The detect function must |
| 150 | * fill at least the name field of the i2c_board_info structure it is | 148 | * fill at least the name field of the i2c_board_info structure it is |
| @@ -503,125 +501,4 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap) | |||
| 503 | i2c_del_driver) | 501 | i2c_del_driver) |
| 504 | 502 | ||
| 505 | #endif /* I2C */ | 503 | #endif /* I2C */ |
| 506 | #endif /* __KERNEL__ */ | ||
| 507 | |||
| 508 | /** | ||
| 509 | * struct i2c_msg - an I2C transaction segment beginning with START | ||
| 510 | * @addr: Slave address, either seven or ten bits. When this is a ten | ||
| 511 | * bit address, I2C_M_TEN must be set in @flags and the adapter | ||
| 512 | * must support I2C_FUNC_10BIT_ADDR. | ||
| 513 | * @flags: I2C_M_RD is handled by all adapters. No other flags may be | ||
| 514 | * provided unless the adapter exported the relevant I2C_FUNC_* | ||
| 515 | * flags through i2c_check_functionality(). | ||
| 516 | * @len: Number of data bytes in @buf being read from or written to the | ||
| 517 | * I2C slave address. For read transactions where I2C_M_RECV_LEN | ||
| 518 | * is set, the caller guarantees that this buffer can hold up to | ||
| 519 | * 32 bytes in addition to the initial length byte sent by the | ||
| 520 | * slave (plus, if used, the SMBus PEC); and this value will be | ||
| 521 | * incremented by the number of block data bytes received. | ||
| 522 | * @buf: The buffer into which data is read, or from which it's written. | ||
| 523 | * | ||
| 524 | * An i2c_msg is the low level representation of one segment of an I2C | ||
| 525 | * transaction. It is visible to drivers in the @i2c_transfer() procedure, | ||
| 526 | * to userspace from i2c-dev, and to I2C adapter drivers through the | ||
| 527 | * @i2c_adapter.@master_xfer() method. | ||
| 528 | * | ||
| 529 | * Except when I2C "protocol mangling" is used, all I2C adapters implement | ||
| 530 | * the standard rules for I2C transactions. Each transaction begins with a | ||
| 531 | * START. That is followed by the slave address, and a bit encoding read | ||
| 532 | * versus write. Then follow all the data bytes, possibly including a byte | ||
| 533 | * with SMBus PEC. The transfer terminates with a NAK, or when all those | ||
| 534 | * bytes have been transferred and ACKed. If this is the last message in a | ||
| 535 | * group, it is followed by a STOP. Otherwise it is followed by the next | ||
| 536 | * @i2c_msg transaction segment, beginning with a (repeated) START. | ||
| 537 | * | ||
| 538 | * Alternatively, when the adapter supports I2C_FUNC_PROTOCOL_MANGLING then | ||
| 539 | * passing certain @flags may have changed those standard protocol behaviors. | ||
| 540 | * Those flags are only for use with broken/nonconforming slaves, and with | ||
| 541 | * adapters which are known to support the specific mangling options they | ||
| 542 | * need (one or more of IGNORE_NAK, NO_RD_ACK, NOSTART, and REV_DIR_ADDR). | ||
| 543 | */ | ||
| 544 | struct i2c_msg { | ||
| 545 | __u16 addr; /* slave address */ | ||
| 546 | __u16 flags; | ||
| 547 | #define I2C_M_TEN 0x0010 /* this is a ten bit chip address */ | ||
| 548 | #define I2C_M_RD 0x0001 /* read data, from slave to master */ | ||
| 549 | #define I2C_M_STOP 0x8000 /* if I2C_FUNC_PROTOCOL_MANGLING */ | ||
| 550 | #define I2C_M_NOSTART 0x4000 /* if I2C_FUNC_NOSTART */ | ||
| 551 | #define I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */ | ||
| 552 | #define I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */ | ||
| 553 | #define I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */ | ||
| 554 | #define I2C_M_RECV_LEN 0x0400 /* length will be first received byte */ | ||
| 555 | __u16 len; /* msg length */ | ||
| 556 | __u8 *buf; /* pointer to msg data */ | ||
| 557 | }; | ||
| 558 | |||
| 559 | /* To determine what functionality is present */ | ||
| 560 | |||
| 561 | #define I2C_FUNC_I2C 0x00000001 | ||
| 562 | #define I2C_FUNC_10BIT_ADDR 0x00000002 | ||
| 563 | #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_IGNORE_NAK etc. */ | ||
| 564 | #define I2C_FUNC_SMBUS_PEC 0x00000008 | ||
| 565 | #define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */ | ||
| 566 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ | ||
| 567 | #define I2C_FUNC_SMBUS_QUICK 0x00010000 | ||
| 568 | #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 | ||
| 569 | #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 | ||
| 570 | #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 | ||
| 571 | #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 | ||
| 572 | #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 | ||
| 573 | #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 | ||
| 574 | #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 | ||
| 575 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 | ||
| 576 | #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 | ||
| 577 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ | ||
| 578 | #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ | ||
| 579 | |||
| 580 | #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ | ||
| 581 | I2C_FUNC_SMBUS_WRITE_BYTE) | ||
| 582 | #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ | ||
| 583 | I2C_FUNC_SMBUS_WRITE_BYTE_DATA) | ||
| 584 | #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ | ||
| 585 | I2C_FUNC_SMBUS_WRITE_WORD_DATA) | ||
| 586 | #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ | ||
| 587 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) | ||
| 588 | #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ | ||
| 589 | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) | ||
| 590 | |||
| 591 | #define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \ | ||
| 592 | I2C_FUNC_SMBUS_BYTE | \ | ||
| 593 | I2C_FUNC_SMBUS_BYTE_DATA | \ | ||
| 594 | I2C_FUNC_SMBUS_WORD_DATA | \ | ||
| 595 | I2C_FUNC_SMBUS_PROC_CALL | \ | ||
| 596 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ | ||
| 597 | I2C_FUNC_SMBUS_I2C_BLOCK | \ | ||
| 598 | I2C_FUNC_SMBUS_PEC) | ||
| 599 | |||
| 600 | /* | ||
| 601 | * Data for SMBus Messages | ||
| 602 | */ | ||
| 603 | #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ | ||
| 604 | union i2c_smbus_data { | ||
| 605 | __u8 byte; | ||
| 606 | __u16 word; | ||
| 607 | __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ | ||
| 608 | /* and one more for user-space compatibility */ | ||
| 609 | }; | ||
| 610 | |||
| 611 | /* i2c_smbus_xfer read or write markers */ | ||
| 612 | #define I2C_SMBUS_READ 1 | ||
| 613 | #define I2C_SMBUS_WRITE 0 | ||
| 614 | |||
| 615 | /* SMBus transaction types (size parameter in the above functions) | ||
| 616 | Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ | ||
| 617 | #define I2C_SMBUS_QUICK 0 | ||
| 618 | #define I2C_SMBUS_BYTE 1 | ||
| 619 | #define I2C_SMBUS_BYTE_DATA 2 | ||
| 620 | #define I2C_SMBUS_WORD_DATA 3 | ||
| 621 | #define I2C_SMBUS_PROC_CALL 4 | ||
| 622 | #define I2C_SMBUS_BLOCK_DATA 5 | ||
| 623 | #define I2C_SMBUS_I2C_BLOCK_BROKEN 6 | ||
| 624 | #define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */ | ||
| 625 | #define I2C_SMBUS_I2C_BLOCK_DATA 8 | ||
| 626 | |||
| 627 | #endif /* _LINUX_I2C_H */ | 504 | #endif /* _LINUX_I2C_H */ |
