Blame view
Documentation/i2c/smbus-protocol
8.96 KB
1da177e4c
|
1 2 |
SMBus Protocol Summary ====================== |
1a31a88f4
|
3 |
|
1da177e4c
|
4 5 6 7 8 9 10 11 |
The following is a summary of the SMBus protocol. It applies to all revisions of the protocol (1.0, 1.1, and 2.0). Certain protocol features which are not supported by this package are briefly described at the end of this document. Some adapters understand only the SMBus (System Management Bus) protocol, which is a subset from the I2C protocol. Fortunately, many devices use only the same subset, which makes it possible to put them on an SMBus. |
1a31a88f4
|
12 |
|
1da177e4c
|
13 14 15 16 17 18 |
If you write a driver for some I2C device, please try to use the SMBus commands if at all possible (if the device uses only that subset of the I2C protocol). This makes it possible to use the device driver on both SMBus adapters and I2C adapters (the SMBus command set is automatically translated to I2C on I2C adapters, but plain I2C commands can not be handled at all on most pure SMBus adapters). |
1a31a88f4
|
19 20 21 22 23 |
Below is a list of SMBus protocol operations, and the functions executing them. Note that the names used in the SMBus protocol specifications usually don't match these function names. For some of the operations which pass a single data byte, the functions using SMBus protocol operation names execute a different protocol operation entirely. |
a1681781d
|
24 25 26 27 28 |
Each transaction type corresponds to a functionality flag. Before calling a transaction function, a device driver should always check (just once) for the corresponding functionality flag to ensure that the underlying I2C adapter supports the transaction in question. See <file:Documentation/i2c/functionality> for the details. |
1da177e4c
|
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
Key to symbols ============== S (1 bit) : Start bit P (1 bit) : Stop bit Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. A, NA (1 bit) : Accept and reverse accept bit. Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to get a 10 bit I2C address. Comm (8 bits): Command byte, a data byte which often selects a register on the device. Data (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh for 16 bit data. Count (8 bits): A data byte containing the length of a block operation. [..]: Data sent by I2C device, as opposed to data sent by the host adapter. |
67c2e6657
|
46 47 |
SMBus Quick Command =================== |
1da177e4c
|
48 49 |
This sends a single bit to the device, at the place of the Rd/Wr bit. |
1da177e4c
|
50 51 |
A Addr Rd/Wr [A] P |
a1681781d
|
52 |
Functionality flag: I2C_FUNC_SMBUS_QUICK |
1da177e4c
|
53 |
|
1a31a88f4
|
54 55 |
SMBus Receive Byte: i2c_smbus_read_byte() ========================================== |
1da177e4c
|
56 57 58 59 60 61 62 |
This reads a single byte from a device, without specifying a device register. Some devices are so simple that this interface is enough; for others, it is a shorthand if you want to read the same register as in the previous SMBus command. S Addr Rd [A] [Data] NA P |
a1681781d
|
63 |
Functionality flag: I2C_FUNC_SMBUS_READ_BYTE |
1da177e4c
|
64 |
|
1a31a88f4
|
65 66 |
SMBus Send Byte: i2c_smbus_write_byte() ======================================== |
1da177e4c
|
67 |
|
1a31a88f4
|
68 69 |
This operation is the reverse of Receive Byte: it sends a single byte to a device. See Receive Byte for more information. |
1da177e4c
|
70 71 |
S Addr Wr [A] Data [A] P |
a1681781d
|
72 |
Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE |
1da177e4c
|
73 |
|
1a31a88f4
|
74 75 |
SMBus Read Byte: i2c_smbus_read_byte_data() ============================================ |
1da177e4c
|
76 77 78 79 80 |
This reads a single byte from a device, from a designated register. The register is specified through the Comm byte. S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P |
a1681781d
|
81 |
Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA |
1da177e4c
|
82 |
|
1a31a88f4
|
83 84 |
SMBus Read Word: i2c_smbus_read_word_data() ============================================ |
1da177e4c
|
85 |
|
1a31a88f4
|
86 |
This operation is very like Read Byte; again, data is read from a |
1da177e4c
|
87 88 89 90 |
device, from a designated register that is specified through the Comm byte. But this time, the data is a complete word (16 bits). S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P |
a1681781d
|
91 |
Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA |
06a67848c
|
92 93 94 |
Note the convenience function i2c_smbus_read_word_swapped is available for reads where the two data bytes are the other way around (not SMBus compliant, but very popular.) |
1da177e4c
|
95 |
|
1a31a88f4
|
96 97 |
SMBus Write Byte: i2c_smbus_write_byte_data() ============================================== |
1da177e4c
|
98 99 100 |
This writes a single byte to a device, to a designated register. The register is specified through the Comm byte. This is the opposite of |
1a31a88f4
|
101 |
the Read Byte operation. |
1da177e4c
|
102 103 |
S Addr Wr [A] Comm [A] Data [A] P |
a1681781d
|
104 |
Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
1da177e4c
|
105 |
|
1a31a88f4
|
106 107 |
SMBus Write Word: i2c_smbus_write_word_data() ============================================== |
1da177e4c
|
108 |
|
1a31a88f4
|
109 |
This is the opposite of the Read Word operation. 16 bits |
3f9a4790a
|
110 |
of data is written to a device, to the designated register that is |
1da177e4c
|
111 112 113 |
specified through the Comm byte. S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P |
a1681781d
|
114 |
Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA |
06a67848c
|
115 116 117 |
Note the convenience function i2c_smbus_write_word_swapped is available for writes where the two data bytes are the other way around (not SMBus compliant, but very popular.) |
1da177e4c
|
118 |
|
c81109332
|
119 120 |
SMBus Process Call: =================== |
1da177e4c
|
121 122 123 124 125 126 |
This command selects a device register (through the Comm byte), sends 16 bits of data to it, and reads 16 bits of data in return. S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P |
a1681781d
|
127 |
Functionality flag: I2C_FUNC_SMBUS_PROC_CALL |
1da177e4c
|
128 |
|
1a31a88f4
|
129 130 |
SMBus Block Read: i2c_smbus_read_block_data() ============================================== |
1da177e4c
|
131 132 133 134 135 136 137 |
This command reads a block of up to 32 bytes from a device, from a designated register that is specified through the Comm byte. The amount of data is specified by the device in the Count byte. S Addr Wr [A] Comm [A] S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P |
a1681781d
|
138 |
Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA |
1da177e4c
|
139 |
|
1a31a88f4
|
140 141 |
SMBus Block Write: i2c_smbus_write_block_data() ================================================ |
1da177e4c
|
142 143 144 145 146 147 |
The opposite of the Block Read command, this writes up to 32 bytes to a device, to a designated register that is specified through the Comm byte. The amount of data is specified in the Count byte. S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P |
a1681781d
|
148 |
Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA |
1da177e4c
|
149 |
|
1a31a88f4
|
150 151 |
SMBus Block Write - Block Read Process Call =========================================== |
1da177e4c
|
152 |
|
1a31a88f4
|
153 154 |
SMBus Block Write - Block Read Process Call was introduced in Revision 2.0 of the specification. |
1da177e4c
|
155 156 157 158 159 160 |
This command selects a device register (through the Comm byte), sends 1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return. S Addr Wr [A] Comm [A] Count [A] Data [A] ... S Addr Rd [A] [Count] A [Data] ... A P |
a1681781d
|
161 |
Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
1da177e4c
|
162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
SMBus Host Notify ================= This command is sent from a SMBus device acting as a master to the SMBus host acting as a slave. It is the same form as Write Word, with the command code replaced by the alerting device's address. [S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P] Packet Error Checking (PEC) =========================== |
1a31a88f4
|
176 |
|
1da177e4c
|
177 |
Packet Error Checking was introduced in Revision 1.1 of the specification. |
1a31a88f4
|
178 179 |
PEC adds a CRC-8 error-checking byte to transfers using it, immediately before the terminating STOP. |
1da177e4c
|
180 181 182 183 |
Address Resolution Protocol (ARP) ================================= |
1a31a88f4
|
184 |
|
1da177e4c
|
185 186 187 188 189 190 191 |
The Address Resolution Protocol was introduced in Revision 2.0 of the specification. It is a higher-layer protocol which uses the messages above. ARP adds device enumeration and dynamic address assignment to the protocol. All ARP communications use slave address 0x61 and require PEC checksums. |
b5527a776
|
192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
SMBus Alert =========== SMBus Alert was introduced in Revision 1.0 of the specification. The SMBus alert protocol allows several SMBus slave devices to share a single interrupt pin on the SMBus master, while still allowing the master to know which slave triggered the interrupt. This is implemented the following way in the Linux kernel: * I2C bus drivers which support SMBus alert should call i2c_setup_smbus_alert() to setup SMBus alert support. * I2C drivers for devices which can trigger SMBus alerts should implement the optional alert() callback. |
1da177e4c
|
206 207 |
I2C Block Transactions ====================== |
1a31a88f4
|
208 |
|
1da177e4c
|
209 210 |
The following I2C block transactions are supported by the SMBus layer and are described here for completeness. |
1a31a88f4
|
211 |
They are *NOT* defined by the SMBus specification. |
1da177e4c
|
212 213 |
I2C block transactions do not limit the number of bytes transferred but the SMBus layer places a limit of 32 bytes. |
1a31a88f4
|
214 215 |
I2C Block Read: i2c_smbus_read_i2c_block_data() ================================================ |
1da177e4c
|
216 217 218 219 220 221 |
This command reads a block of bytes from a device, from a designated register that is specified through the Comm byte. S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P |
a1681781d
|
222 |
Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK |
1da177e4c
|
223 |
|
1a31a88f4
|
224 225 |
I2C Block Write: i2c_smbus_write_i2c_block_data() ================================================== |
1da177e4c
|
226 227 228 229 230 231 232 |
The opposite of the Block Read command, this writes bytes to a device, to a designated register that is specified through the Comm byte. Note that command lengths of 0, 2, or more bytes are supported as they are indistinguishable from data. S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P |
a1681781d
|
233 234 |
Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |