以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_I2CPlain i2c-level commands (Pure SMBus adapters typically can not do these)I2C_FUNC_10BIT_ADDRHandles the 10-bit address extensionsI2C_FUNC_PROTOCOL_MANGLINGKnows 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_NOSTARTCan skip repeated start sequenceI2C_FUNC_SMBUS_QUICKHandles the SMBus write_quick commandI2C_FUNC_SMBUS_READ_BYTEHandles the SMBus read_byte commandI2C_FUNC_SMBUS_WRITE_BYTEHandles the SMBus write_byte commandI2C_FUNC_SMBUS_READ_BYTE_DATAHandles the SMBus read_byte_data commandI2C_FUNC_SMBUS_WRITE_BYTE_DATAHandles the SMBus write_byte_data commandI2C_FUNC_SMBUS_READ_WORD_DATAHandles the SMBus read_word_data commandI2C_FUNC_SMBUS_WRITE_WORD_DATAHandles the SMBus write_byte_data commandI2C_FUNC_SMBUS_PROC_CALLHandles the SMBus process_call commandI2C_FUNC_SMBUS_READ_BLOCK_DATAHandles the SMBus read_block_data commandI2C_FUNC_SMBUS_WRITE_BLOCK_DATAHandles the SMBus write_block_data commandI2C_FUNC_SMBUS_READ_I2C_BLOCKHandles the SMBus read_i2c_block_data commandI2C_FUNC_SMBUS_WRITE_I2C_BLOCKHandles the SMBus write_i2c_block_data command