linux内核i2c适配器功能
以kernel5.8.1为例,i2c适配器的功能定义在uapi/linux/i2c.h
// i2c.h
#define I2C_FUNC_I2C 0x00000001
#define I2C_FUNC_10BIT_ADDR 0x00000002
#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_IGNORE_NAK etc. */
#define I2C_FUNC_SMBUS_PEC 0x00000008
#define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */
#define I2C_FUNC_SLAVE 0x00000020
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
#define I2C_FUNC_SMBUS_QUICK 0x00010000
#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
#define I2C_FUNC_SMBUS_HOST_NOTIFY 0x10000000
各个宏的含义在Documentation\i2c\functionality.rst中由介绍。
宏名 | 含义 |
---|---|
I2C_FUNC_I2C | Plain i2c-level commands (Pure SMBus adapters typically can not do these) |
I2C_FUNC_10BIT_ADDR | Handles the 10-bit address extensions |
I2C_FUNC_PROTOCOL_MANGLING | Knows about the I2C_M_IGNORE_NAK, I2C_M_REV_DIR_ADDR and I2C_M_NO_RD_ACK flags (which modify the I2C protocol!) |
I2C_FUNC_NOSTART | Can skip repeated start sequence |
I2C_FUNC_SMBUS_QUICK | Handles the SMBus write_quick command |
I2C_FUNC_SMBUS_READ_BYTE | Handles the SMBus read_byte command |
I2C_FUNC_SMBUS_WRITE_BYTE | Handles the SMBus write_byte command |
I2C_FUNC_SMBUS_READ_BYTE_DATA | Handles the SMBus read_byte_data command |
I2C_FUNC_SMBUS_WRITE_BYTE_DATA | Handles the SMBus write_byte_data command |
I2C_FUNC_SMBUS_READ_WORD_DATA | Handles the SMBus read_word_data command |
I2C_FUNC_SMBUS_WRITE_WORD_DATA | Handles the SMBus write_byte_data command |
I2C_FUNC_SMBUS_PROC_CALL | Handles the SMBus process_call command |
I2C_FUNC_SMBUS_READ_BLOCK_DATA | Handles the SMBus read_block_data command |
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | Handles the SMBus write_block_data command |
I2C_FUNC_SMBUS_READ_I2C_BLOCK | Handles the SMBus read_i2c_block_data command |
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | Handles the SMBus write_i2c_block_data command |