Blame view
Documentation/i2c/smbus-protocol.rst
9.64 KB
f6fcefa10
|
1 2 3 |
================== The SMBus Protocol ================== |
1a31a88f4
|
4 |
|
1da177e4c
|
5 6 7 8 9 10 11 12 |
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
|
13 |
|
1da177e4c
|
14 15 16 17 18 19 |
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
|
20 21 22 23 24 |
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
|
25 26 27 |
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 |
924fbb4d2
|
28 29 |
adapter supports the transaction in question. See :doc:`functionality` for the details. |
a1681781d
|
30 |
|
1da177e4c
|
31 32 33 |
Key to symbols ============== |
ccf988b66
|
34 |
=============== ============================================================= |
026c0fe66
|
35 36 37 |
S Start condition P Stop condition Rd/Wr (1 bit) Read/Write bit. Rd equals 1, Wr equals 0. |
9e89d6187
|
38 |
A, NA (1 bit) Acknowledge (ACK) and Not Acknowledge (NACK) bit |
026c0fe66
|
39 |
Addr (7 bits) I2C 7 bit address. Note that this can be expanded as usual to |
1da177e4c
|
40 |
get a 10 bit I2C address. |
026c0fe66
|
41 |
Comm (8 bits) Command byte, a data byte which often selects a register on |
1da177e4c
|
42 |
the device. |
026c0fe66
|
43 |
Data (8 bits) A plain data byte. Sometimes, I write DataLow, DataHigh |
1da177e4c
|
44 |
for 16 bit data. |
026c0fe66
|
45 |
Count (8 bits) A data byte containing the length of a block operation. |
1da177e4c
|
46 |
|
026c0fe66
|
47 |
[..] Data sent by I2C device, as opposed to data sent by the host |
ccf988b66
|
48 49 |
adapter. =============== ============================================================= |
1da177e4c
|
50 |
|
67c2e6657
|
51 52 |
SMBus Quick Command =================== |
1da177e4c
|
53 |
|
ccf988b66
|
54 |
This sends a single bit to the device, at the place of the Rd/Wr bit:: |
1da177e4c
|
55 |
|
a5765124e
|
56 |
S Addr Rd/Wr [A] P |
1da177e4c
|
57 |
|
a1681781d
|
58 |
Functionality flag: I2C_FUNC_SMBUS_QUICK |
1da177e4c
|
59 |
|
3c13f1fbe
|
60 61 62 63 |
SMBus Receive Byte ================== Implemented by i2c_smbus_read_byte() |
1da177e4c
|
64 65 66 67 |
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 |
ccf988b66
|
68 |
the previous SMBus command:: |
1da177e4c
|
69 |
|
ccf988b66
|
70 |
S Addr Rd [A] [Data] NA P |
1da177e4c
|
71 |
|
a1681781d
|
72 |
Functionality flag: I2C_FUNC_SMBUS_READ_BYTE |
1da177e4c
|
73 |
|
3c13f1fbe
|
74 75 76 77 |
SMBus Send Byte =============== Implemented by i2c_smbus_write_byte() |
1da177e4c
|
78 |
|
1a31a88f4
|
79 80 |
This operation is the reverse of Receive Byte: it sends a single byte to a device. See Receive Byte for more information. |
1da177e4c
|
81 |
|
ccf988b66
|
82 83 84 |
:: S Addr Wr [A] Data [A] P |
1da177e4c
|
85 |
|
a1681781d
|
86 |
Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE |
1da177e4c
|
87 |
|
3c13f1fbe
|
88 89 90 91 |
SMBus Read Byte =============== Implemented by i2c_smbus_read_byte_data() |
1da177e4c
|
92 93 |
This reads a single byte from a device, from a designated register. |
ccf988b66
|
94 |
The register is specified through the Comm byte:: |
1da177e4c
|
95 |
|
ccf988b66
|
96 |
S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P |
1da177e4c
|
97 |
|
a1681781d
|
98 |
Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA |
1da177e4c
|
99 |
|
3c13f1fbe
|
100 101 102 103 |
SMBus Read Word =============== Implemented by i2c_smbus_read_word_data() |
1da177e4c
|
104 |
|
1a31a88f4
|
105 |
This operation is very like Read Byte; again, data is read from a |
1da177e4c
|
106 |
device, from a designated register that is specified through the Comm |
ccf988b66
|
107 |
byte. But this time, the data is a complete word (16 bits):: |
1da177e4c
|
108 |
|
ccf988b66
|
109 |
S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P |
1da177e4c
|
110 |
|
a1681781d
|
111 |
Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA |
b36cbb70e
|
112 |
Note the convenience function i2c_smbus_read_word_swapped() is |
06a67848c
|
113 114 |
available for reads where the two data bytes are the other way around (not SMBus compliant, but very popular.) |
1da177e4c
|
115 |
|
3c13f1fbe
|
116 117 118 119 |
SMBus Write Byte ================ Implemented by i2c_smbus_write_byte_data() |
1da177e4c
|
120 121 122 |
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
|
123 |
the Read Byte operation. |
1da177e4c
|
124 |
|
ccf988b66
|
125 126 127 |
:: S Addr Wr [A] Comm [A] Data [A] P |
1da177e4c
|
128 |
|
a1681781d
|
129 |
Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
1da177e4c
|
130 |
|
3c13f1fbe
|
131 132 133 134 |
SMBus Write Word ================ Implemented by i2c_smbus_write_word_data() |
1da177e4c
|
135 |
|
1a31a88f4
|
136 |
This is the opposite of the Read Word operation. 16 bits |
414a59645
|
137 |
of data are written to a device, to the designated register that is |
c7148b059
|
138 |
specified through the Comm byte:: |
1da177e4c
|
139 |
|
ccf988b66
|
140 |
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P |
1da177e4c
|
141 |
|
a1681781d
|
142 |
Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA |
b36cbb70e
|
143 |
Note the convenience function i2c_smbus_write_word_swapped() is |
06a67848c
|
144 145 |
available for writes where the two data bytes are the other way around (not SMBus compliant, but very popular.) |
1da177e4c
|
146 |
|
3c13f1fbe
|
147 148 |
SMBus Process Call ================== |
1da177e4c
|
149 150 |
This command selects a device register (through the Comm byte), sends |
ccf988b66
|
151 |
16 bits of data to it, and reads 16 bits of data in return:: |
1da177e4c
|
152 |
|
ccf988b66
|
153 154 |
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P |
1da177e4c
|
155 |
|
a1681781d
|
156 |
Functionality flag: I2C_FUNC_SMBUS_PROC_CALL |
1da177e4c
|
157 |
|
3c13f1fbe
|
158 159 160 161 |
SMBus Block Read ================ Implemented by i2c_smbus_read_block_data() |
1da177e4c
|
162 |
|
ccf988b66
|
163 |
This command reads a block of up to 32 bytes from a device, from a |
1da177e4c
|
164 165 |
designated register that is specified through the Comm byte. The amount of data is specified by the device in the Count byte. |
ccf988b66
|
166 167 168 169 |
:: S Addr Wr [A] Comm [A] S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P |
1da177e4c
|
170 |
|
a1681781d
|
171 |
Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA |
1da177e4c
|
172 |
|
3c13f1fbe
|
173 174 175 176 |
SMBus Block Write ================= Implemented by i2c_smbus_write_block_data() |
1da177e4c
|
177 |
|
ccf988b66
|
178 |
The opposite of the Block Read command, this writes up to 32 bytes to |
1da177e4c
|
179 180 |
a device, to a designated register that is specified through the Comm byte. The amount of data is specified in the Count byte. |
ccf988b66
|
181 182 183 |
:: S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P |
1da177e4c
|
184 |
|
a1681781d
|
185 |
Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA |
1da177e4c
|
186 |
|
1a31a88f4
|
187 188 |
SMBus Block Write - Block Read Process Call =========================================== |
1da177e4c
|
189 |
|
1a31a88f4
|
190 191 |
SMBus Block Write - Block Read Process Call was introduced in Revision 2.0 of the specification. |
1da177e4c
|
192 193 |
This command selects a device register (through the Comm byte), sends |
ccf988b66
|
194 |
1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return:: |
1da177e4c
|
195 |
|
ccf988b66
|
196 197 |
S Addr Wr [A] Comm [A] Count [A] Data [A] ... S Addr Rd [A] [Count] A [Data] ... A P |
1da177e4c
|
198 |
|
a1681781d
|
199 |
Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
1da177e4c
|
200 201 202 203 204 205 206 207 |
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. |
ccf988b66
|
208 209 210 |
:: [S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P] |
1da177e4c
|
211 |
|
e456cd37b
|
212 |
This is implemented in the following way in the Linux kernel: |
ccf988b66
|
213 |
|
4d5538f58
|
214 215 216 217 218 219 220 221 |
* I2C bus drivers which support SMBus Host Notify should report I2C_FUNC_SMBUS_HOST_NOTIFY. * I2C bus drivers trigger SMBus Host Notify by a call to i2c_handle_smbus_host_notify(). * I2C drivers for devices which can trigger SMBus Host Notify will have client->irq assigned to a Host Notify IRQ if noone else specified an other. There is currently no way to retrieve the data parameter from the client. |
e456cd37b
|
222 |
|
1da177e4c
|
223 224 225 |
Packet Error Checking (PEC) =========================== |
1a31a88f4
|
226 |
|
1da177e4c
|
227 |
Packet Error Checking was introduced in Revision 1.1 of the specification. |
1a31a88f4
|
228 229 |
PEC adds a CRC-8 error-checking byte to transfers using it, immediately before the terminating STOP. |
1da177e4c
|
230 231 232 233 |
Address Resolution Protocol (ARP) ================================= |
1a31a88f4
|
234 |
|
1da177e4c
|
235 236 237 238 239 240 241 |
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
|
242 243 244 245 246 247 248 249 250 251 |
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: |
ccf988b66
|
252 |
|
b5527a776
|
253 |
* I2C bus drivers which support SMBus alert should call |
ed6805222
|
254 |
i2c_new_smbus_alert_device() to install SMBus alert support. |
b5527a776
|
255 256 |
* I2C drivers for devices which can trigger SMBus alerts should implement the optional alert() callback. |
1da177e4c
|
257 258 |
I2C Block Transactions ====================== |
1a31a88f4
|
259 |
|
95b83774e
|
260 261 262 263 |
The following I2C block transactions are similar to the SMBus Block Read and Write operations, except these do not have a Count byte. They are supported by the SMBus layer and are described here for completeness, but they are *NOT* defined by the SMBus specification. |
1a31a88f4
|
264 |
|
1da177e4c
|
265 266 |
I2C block transactions do not limit the number of bytes transferred but the SMBus layer places a limit of 32 bytes. |
3c13f1fbe
|
267 268 269 270 |
I2C Block Read ============== Implemented by i2c_smbus_read_i2c_block_data() |
1da177e4c
|
271 |
|
ccf988b66
|
272 273 |
This command reads a block of bytes from a device, from a designated register that is specified through the Comm byte:: |
1da177e4c
|
274 |
|
ccf988b66
|
275 276 |
S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P |
1da177e4c
|
277 |
|
a1681781d
|
278 |
Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK |
1da177e4c
|
279 |
|
3c13f1fbe
|
280 281 282 283 |
I2C Block Write =============== Implemented by i2c_smbus_write_i2c_block_data() |
1da177e4c
|
284 |
|
ccf988b66
|
285 |
The opposite of the Block Read command, this writes bytes to |
1da177e4c
|
286 287 288 |
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. |
ccf988b66
|
289 290 291 |
:: S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P |
a1681781d
|
292 293 |
Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |