![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 0002 /* 0003 * i2c.h - definitions for the I2C bus interface 0004 * 0005 * Copyright (C) 1995-2000 Simon G. Vogl 0006 * With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and 0007 * Frodo Looijaard <frodol@dds.nl> 0008 */ 0009 0010 #ifndef _UAPI_LINUX_I2C_H 0011 #define _UAPI_LINUX_I2C_H 0012 0013 #include <linux/types.h> 0014 0015 /** 0016 * struct i2c_msg - an I2C transaction segment beginning with START 0017 * 0018 * @addr: Slave address, either 7 or 10 bits. When this is a 10 bit address, 0019 * %I2C_M_TEN must be set in @flags and the adapter must support 0020 * %I2C_FUNC_10BIT_ADDR. 0021 * 0022 * @flags: 0023 * Supported by all adapters: 0024 * %I2C_M_RD: read data (from slave to master). Guaranteed to be 0x0001! 0025 * 0026 * Optional: 0027 * %I2C_M_DMA_SAFE: the buffer of this message is DMA safe. Makes only sense 0028 * in kernelspace, because userspace buffers are copied anyway 0029 * 0030 * Only if I2C_FUNC_10BIT_ADDR is set: 0031 * %I2C_M_TEN: this is a 10 bit chip address 0032 * 0033 * Only if I2C_FUNC_SMBUS_READ_BLOCK_DATA is set: 0034 * %I2C_M_RECV_LEN: message length will be first received byte 0035 * 0036 * Only if I2C_FUNC_NOSTART is set: 0037 * %I2C_M_NOSTART: skip repeated start sequence 0038 0039 * Only if I2C_FUNC_PROTOCOL_MANGLING is set: 0040 * %I2C_M_NO_RD_ACK: in a read message, master ACK/NACK bit is skipped 0041 * %I2C_M_IGNORE_NAK: treat NACK from client as ACK 0042 * %I2C_M_REV_DIR_ADDR: toggles the Rd/Wr bit 0043 * %I2C_M_STOP: force a STOP condition after the message 0044 * 0045 * @len: Number of data bytes in @buf being read from or written to the I2C 0046 * slave address. For read transactions where %I2C_M_RECV_LEN is set, the 0047 * caller guarantees that this buffer can hold up to %I2C_SMBUS_BLOCK_MAX 0048 * bytes in addition to the initial length byte sent by the slave (plus, 0049 * if used, the SMBus PEC); and this value will be incremented by the number 0050 * of block data bytes received. 0051 * 0052 * @buf: The buffer into which data is read, or from which it's written. 0053 * 0054 * An i2c_msg is the low level representation of one segment of an I2C 0055 * transaction. It is visible to drivers in the @i2c_transfer() procedure, 0056 * to userspace from i2c-dev, and to I2C adapter drivers through the 0057 * @i2c_adapter.@master_xfer() method. 0058 * 0059 * Except when I2C "protocol mangling" is used, all I2C adapters implement 0060 * the standard rules for I2C transactions. Each transaction begins with a 0061 * START. That is followed by the slave address, and a bit encoding read 0062 * versus write. Then follow all the data bytes, possibly including a byte 0063 * with SMBus PEC. The transfer terminates with a NAK, or when all those 0064 * bytes have been transferred and ACKed. If this is the last message in a 0065 * group, it is followed by a STOP. Otherwise it is followed by the next 0066 * @i2c_msg transaction segment, beginning with a (repeated) START. 0067 * 0068 * Alternatively, when the adapter supports %I2C_FUNC_PROTOCOL_MANGLING then 0069 * passing certain @flags may have changed those standard protocol behaviors. 0070 * Those flags are only for use with broken/nonconforming slaves, and with 0071 * adapters which are known to support the specific mangling options they need. 0072 */ 0073 struct i2c_msg { 0074 __u16 addr; 0075 __u16 flags; 0076 #define I2C_M_RD 0x0001 /* guaranteed to be 0x0001! */ 0077 #define I2C_M_TEN 0x0010 /* use only if I2C_FUNC_10BIT_ADDR */ 0078 #define I2C_M_DMA_SAFE 0x0200 /* use only in kernel space */ 0079 #define I2C_M_RECV_LEN 0x0400 /* use only if I2C_FUNC_SMBUS_READ_BLOCK_DATA */ 0080 #define I2C_M_NO_RD_ACK 0x0800 /* use only if I2C_FUNC_PROTOCOL_MANGLING */ 0081 #define I2C_M_IGNORE_NAK 0x1000 /* use only if I2C_FUNC_PROTOCOL_MANGLING */ 0082 #define I2C_M_REV_DIR_ADDR 0x2000 /* use only if I2C_FUNC_PROTOCOL_MANGLING */ 0083 #define I2C_M_NOSTART 0x4000 /* use only if I2C_FUNC_NOSTART */ 0084 #define I2C_M_STOP 0x8000 /* use only if I2C_FUNC_PROTOCOL_MANGLING */ 0085 __u16 len; 0086 __u8 *buf; 0087 }; 0088 0089 /* To determine what functionality is present */ 0090 0091 #define I2C_FUNC_I2C 0x00000001 0092 #define I2C_FUNC_10BIT_ADDR 0x00000002 /* required for I2C_M_TEN */ 0093 #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* required for I2C_M_IGNORE_NAK etc. */ 0094 #define I2C_FUNC_SMBUS_PEC 0x00000008 0095 #define I2C_FUNC_NOSTART 0x00000010 /* required for I2C_M_NOSTART */ 0096 #define I2C_FUNC_SLAVE 0x00000020 0097 #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 or later */ 0098 #define I2C_FUNC_SMBUS_QUICK 0x00010000 0099 #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 0100 #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 0101 #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 0102 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 0103 #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 0104 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 0105 #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 0106 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 /* required for I2C_M_RECV_LEN */ 0107 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 0108 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ 0109 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ 0110 #define I2C_FUNC_SMBUS_HOST_NOTIFY 0x10000000 /* SMBus 2.0 or later */ 0111 0112 #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ 0113 I2C_FUNC_SMBUS_WRITE_BYTE) 0114 #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ 0115 I2C_FUNC_SMBUS_WRITE_BYTE_DATA) 0116 #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ 0117 I2C_FUNC_SMBUS_WRITE_WORD_DATA) 0118 #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ 0119 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) 0120 #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ 0121 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) 0122 0123 #define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \ 0124 I2C_FUNC_SMBUS_BYTE | \ 0125 I2C_FUNC_SMBUS_BYTE_DATA | \ 0126 I2C_FUNC_SMBUS_WORD_DATA | \ 0127 I2C_FUNC_SMBUS_PROC_CALL | \ 0128 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ 0129 I2C_FUNC_SMBUS_I2C_BLOCK | \ 0130 I2C_FUNC_SMBUS_PEC) 0131 0132 /* if I2C_M_RECV_LEN is also supported */ 0133 #define I2C_FUNC_SMBUS_EMUL_ALL (I2C_FUNC_SMBUS_EMUL | \ 0134 I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ 0135 I2C_FUNC_SMBUS_BLOCK_PROC_CALL) 0136 0137 /* 0138 * Data for SMBus Messages 0139 */ 0140 #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ 0141 union i2c_smbus_data { 0142 __u8 byte; 0143 __u16 word; 0144 __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ 0145 /* and one more for user-space compatibility */ 0146 }; 0147 0148 /* i2c_smbus_xfer read or write markers */ 0149 #define I2C_SMBUS_READ 1 0150 #define I2C_SMBUS_WRITE 0 0151 0152 /* SMBus transaction types (size parameter in the above functions) 0153 Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ 0154 #define I2C_SMBUS_QUICK 0 0155 #define I2C_SMBUS_BYTE 1 0156 #define I2C_SMBUS_BYTE_DATA 2 0157 #define I2C_SMBUS_WORD_DATA 3 0158 #define I2C_SMBUS_PROC_CALL 4 0159 #define I2C_SMBUS_BLOCK_DATA 5 0160 #define I2C_SMBUS_I2C_BLOCK_BROKEN 6 0161 #define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */ 0162 #define I2C_SMBUS_I2C_BLOCK_DATA 8 0163 0164 #endif /* _UAPI_LINUX_I2C_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |