blob: 64689d19dd518330b1b891074e68ea97b4b2918f [file] [log] [blame]
Luca Ceresolif6fcefa2020-01-29 16:19:51 +01001==================
2The SMBus Protocol
3==================
David Brownell1a31a882008-05-11 20:37:05 +02004
Linus Torvalds1da177e2005-04-16 15:20:36 -07005The following is a summary of the SMBus protocol. It applies to
6all revisions of the protocol (1.0, 1.1, and 2.0).
7Certain protocol features which are not supported by
8this package are briefly described at the end of this document.
9
10Some adapters understand only the SMBus (System Management Bus) protocol,
11which is a subset from the I2C protocol. Fortunately, many devices use
12only the same subset, which makes it possible to put them on an SMBus.
David Brownell1a31a882008-05-11 20:37:05 +020013
Linus Torvalds1da177e2005-04-16 15:20:36 -070014If you write a driver for some I2C device, please try to use the SMBus
15commands if at all possible (if the device uses only that subset of the
16I2C protocol). This makes it possible to use the device driver on both
17SMBus adapters and I2C adapters (the SMBus command set is automatically
18translated to I2C on I2C adapters, but plain I2C commands can not be
19handled at all on most pure SMBus adapters).
20
David Brownell1a31a882008-05-11 20:37:05 +020021Below is a list of SMBus protocol operations, and the functions executing
22them. Note that the names used in the SMBus protocol specifications usually
23don't match these function names. For some of the operations which pass a
24single data byte, the functions using SMBus protocol operation names execute
25a different protocol operation entirely.
26
Jean Delvarea1681782012-12-16 21:11:55 +010027Each transaction type corresponds to a functionality flag. Before calling a
28transaction function, a device driver should always check (just once) for
29the corresponding functionality flag to ensure that the underlying I2C
Luca Ceresoli924fbb42020-01-29 16:19:36 +010030adapter supports the transaction in question. See :doc:`functionality` for
31the details.
Jean Delvarea1681782012-12-16 21:11:55 +010032
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34Key to symbols
35==============
36
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -030037=============== =============================================================
Luca Ceresoli026c0fe2020-01-29 16:19:38 +010038S Start condition
39P Stop condition
40Rd/Wr (1 bit) Read/Write bit. Rd equals 1, Wr equals 0.
Luca Ceresoli9e89d612020-01-29 16:19:39 +010041A, NA (1 bit) Acknowledge (ACK) and Not Acknowledge (NACK) bit
Luca Ceresoli026c0fe2020-01-29 16:19:38 +010042Addr (7 bits) I2C 7 bit address. Note that this can be expanded as usual to
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 get a 10 bit I2C address.
Luca Ceresoli026c0fe2020-01-29 16:19:38 +010044Comm (8 bits) Command byte, a data byte which often selects a register on
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 the device.
Luca Ceresoli026c0fe2020-01-29 16:19:38 +010046Data (8 bits) A plain data byte. Sometimes, I write DataLow, DataHigh
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 for 16 bit data.
Luca Ceresoli026c0fe2020-01-29 16:19:38 +010048Count (8 bits) A data byte containing the length of a block operation.
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Luca Ceresoli026c0fe2020-01-29 16:19:38 +010050[..] Data sent by I2C device, as opposed to data sent by the host
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -030051 adapter.
52=============== =============================================================
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54
Jean Delvare67c2e662008-07-14 22:38:23 +020055SMBus Quick Command
56===================
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -030058This sends a single bit to the device, at the place of the Rd/Wr bit::
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Daniel Schaefera5765122020-06-14 20:23:55 +020060 S Addr Rd/Wr [A] P
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Jean Delvarea1681782012-12-16 21:11:55 +010062Functionality flag: I2C_FUNC_SMBUS_QUICK
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +010065SMBus Receive Byte
66==================
67
68Implemented by i2c_smbus_read_byte()
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70This reads a single byte from a device, without specifying a device
71register. Some devices are so simple that this interface is enough; for
72others, it is a shorthand if you want to read the same register as in
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -030073the previous SMBus command::
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -030075 S Addr Rd [A] [Data] NA P
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Jean Delvarea1681782012-12-16 21:11:55 +010077Functionality flag: I2C_FUNC_SMBUS_READ_BYTE
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +010080SMBus Send Byte
81===============
82
83Implemented by i2c_smbus_write_byte()
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
David Brownell1a31a882008-05-11 20:37:05 +020085This operation is the reverse of Receive Byte: it sends a single byte
86to a device. See Receive Byte for more information.
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -030088::
89
90 S Addr Wr [A] Data [A] P
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Jean Delvarea1681782012-12-16 21:11:55 +010092Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +010095SMBus Read Byte
96===============
97
98Implemented by i2c_smbus_read_byte_data()
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100This reads a single byte from a device, from a designated register.
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300101The register is specified through the Comm byte::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300103 S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Jean Delvarea1681782012-12-16 21:11:55 +0100105Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +0100108SMBus Read Word
109===============
110
111Implemented by i2c_smbus_read_word_data()
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
David Brownell1a31a882008-05-11 20:37:05 +0200113This operation is very like Read Byte; again, data is read from a
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114device, from a designated register that is specified through the Comm
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300115byte. But this time, the data is a complete word (16 bits)::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300117 S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Jean Delvarea1681782012-12-16 21:11:55 +0100119Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA
120
Luca Ceresolib36cbb72020-01-29 16:19:41 +0100121Note the convenience function i2c_smbus_read_word_swapped() is
Jonathan Cameron06a67842011-10-30 13:47:25 +0100122available for reads where the two data bytes are the other way
123around (not SMBus compliant, but very popular.)
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +0100126SMBus Write Byte
127================
128
129Implemented by i2c_smbus_write_byte_data()
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
131This writes a single byte to a device, to a designated register. The
132register is specified through the Comm byte. This is the opposite of
David Brownell1a31a882008-05-11 20:37:05 +0200133the Read Byte operation.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300135::
136
137 S Addr Wr [A] Comm [A] Data [A] P
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
Jean Delvarea1681782012-12-16 21:11:55 +0100139Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +0100142SMBus Write Word
143================
144
145Implemented by i2c_smbus_write_word_data()
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
David Brownell1a31a882008-05-11 20:37:05 +0200147This is the opposite of the Read Word operation. 16 bits
Luca Ceresoli414a5962020-01-29 16:19:42 +0100148of data are written to a device, to the designated register that is
Luca Ceresolic7148b052020-01-29 16:19:43 +0100149specified through the Comm byte::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300151 S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
Jean Delvarea1681782012-12-16 21:11:55 +0100153Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA
154
Luca Ceresolib36cbb72020-01-29 16:19:41 +0100155Note the convenience function i2c_smbus_write_word_swapped() is
Jonathan Cameron06a67842011-10-30 13:47:25 +0100156available for writes where the two data bytes are the other way
157around (not SMBus compliant, but very popular.)
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +0100160SMBus Process Call
161==================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163This command selects a device register (through the Comm byte), sends
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -030016416 bits of data to it, and reads 16 bits of data in return::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300166 S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
167 S Addr Rd [A] [DataLow] A [DataHigh] NA P
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
Jean Delvarea1681782012-12-16 21:11:55 +0100169Functionality flag: I2C_FUNC_SMBUS_PROC_CALL
170
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +0100172SMBus Block Read
173================
174
175Implemented by i2c_smbus_read_block_data()
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300177This command reads a block of up to 32 bytes from a device, from a
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178designated register that is specified through the Comm byte. The amount
179of data is specified by the device in the Count byte.
180
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300181::
182
183 S Addr Wr [A] Comm [A]
184 S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
Jean Delvarea1681782012-12-16 21:11:55 +0100186Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA
187
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +0100189SMBus Block Write
190=================
191
192Implemented by i2c_smbus_write_block_data()
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300194The opposite of the Block Read command, this writes up to 32 bytes to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195a device, to a designated register that is specified through the
196Comm byte. The amount of data is specified in the Count byte.
197
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300198::
199
200 S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Jean Delvarea1681782012-12-16 21:11:55 +0100202Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA
203
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
David Brownell1a31a882008-05-11 20:37:05 +0200205SMBus Block Write - Block Read Process Call
206===========================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
David Brownell1a31a882008-05-11 20:37:05 +0200208SMBus Block Write - Block Read Process Call was introduced in
209Revision 2.0 of the specification.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
211This command selects a device register (through the Comm byte), sends
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -03002121 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300214 S Addr Wr [A] Comm [A] Count [A] Data [A] ...
215 S Addr Rd [A] [Count] A [Data] ... A P
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Jean Delvarea1681782012-12-16 21:11:55 +0100217Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL
218
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
220SMBus Host Notify
221=================
222
223This command is sent from a SMBus device acting as a master to the
224SMBus host acting as a slave.
225It is the same form as Write Word, with the command code replaced by the
226alerting device's address.
227
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300228::
229
230 [S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
Benjamin Tissoirese456cd32016-06-09 16:53:48 +0200232This is implemented in the following way in the Linux kernel:
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300233
Benjamin Tissoires4d5538f2016-10-13 14:10:40 +0200234* I2C bus drivers which support SMBus Host Notify should report
235 I2C_FUNC_SMBUS_HOST_NOTIFY.
236* I2C bus drivers trigger SMBus Host Notify by a call to
237 i2c_handle_smbus_host_notify().
238* I2C drivers for devices which can trigger SMBus Host Notify will have
239 client->irq assigned to a Host Notify IRQ if noone else specified an other.
240
241There is currently no way to retrieve the data parameter from the client.
Benjamin Tissoirese456cd32016-06-09 16:53:48 +0200242
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
244Packet Error Checking (PEC)
245===========================
David Brownell1a31a882008-05-11 20:37:05 +0200246
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247Packet Error Checking was introduced in Revision 1.1 of the specification.
248
David Brownell1a31a882008-05-11 20:37:05 +0200249PEC adds a CRC-8 error-checking byte to transfers using it, immediately
250before the terminating STOP.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
252
253Address Resolution Protocol (ARP)
254=================================
David Brownell1a31a882008-05-11 20:37:05 +0200255
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256The Address Resolution Protocol was introduced in Revision 2.0 of
257the specification. It is a higher-layer protocol which uses the
258messages above.
259
260ARP adds device enumeration and dynamic address assignment to
261the protocol. All ARP communications use slave address 0x61 and
262require PEC checksums.
263
264
Jean Delvareb5527a72010-03-02 12:23:42 +0100265SMBus Alert
266===========
267
268SMBus Alert was introduced in Revision 1.0 of the specification.
269
270The SMBus alert protocol allows several SMBus slave devices to share a
271single interrupt pin on the SMBus master, while still allowing the master
272to know which slave triggered the interrupt.
273
274This is implemented the following way in the Linux kernel:
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300275
Jean Delvareb5527a72010-03-02 12:23:42 +0100276* I2C bus drivers which support SMBus alert should call
Wolfram Sanged680522020-02-28 18:12:20 +0100277 i2c_new_smbus_alert_device() to install SMBus alert support.
Jean Delvareb5527a72010-03-02 12:23:42 +0100278* I2C drivers for devices which can trigger SMBus alerts should implement
279 the optional alert() callback.
280
281
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282I2C Block Transactions
283======================
David Brownell1a31a882008-05-11 20:37:05 +0200284
Luca Ceresoli95b83772020-01-29 16:19:44 +0100285The following I2C block transactions are similar to the SMBus Block Read
286and Write operations, except these do not have a Count byte. They are
287supported by the SMBus layer and are described here for completeness, but
288they are *NOT* defined by the SMBus specification.
David Brownell1a31a882008-05-11 20:37:05 +0200289
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290I2C block transactions do not limit the number of bytes transferred
291but the SMBus layer places a limit of 32 bytes.
292
293
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +0100294I2C Block Read
295==============
296
297Implemented by i2c_smbus_read_i2c_block_data()
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300299This command reads a block of bytes from a device, from a
300designated register that is specified through the Comm byte::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300302 S Addr Wr [A] Comm [A]
303 S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
Jean Delvarea1681782012-12-16 21:11:55 +0100305Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307
Luca Ceresoli3c13f1f2020-01-29 16:19:40 +0100308I2C Block Write
309===============
310
311Implemented by i2c_smbus_write_i2c_block_data()
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300313The opposite of the Block Read command, this writes bytes to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314a device, to a designated register that is specified through the
315Comm byte. Note that command lengths of 0, 2, or more bytes are
316supported as they are indistinguishable from data.
317
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -0300318::
319
320 S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
Jean Delvarea1681782012-12-16 21:11:55 +0100321
322Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK