blob: 6012b12b35109f686da47253b947fba050a34f44 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001SMBus Protocol Summary
2======================
David Brownell1a31a882008-05-11 20:37:05 +02003
Linus Torvalds1da177e2005-04-16 15:20:36 -07004The following is a summary of the SMBus protocol. It applies to
5all revisions of the protocol (1.0, 1.1, and 2.0).
6Certain protocol features which are not supported by
7this package are briefly described at the end of this document.
8
9Some adapters understand only the SMBus (System Management Bus) protocol,
10which is a subset from the I2C protocol. Fortunately, many devices use
11only the same subset, which makes it possible to put them on an SMBus.
David Brownell1a31a882008-05-11 20:37:05 +020012
Linus Torvalds1da177e2005-04-16 15:20:36 -070013If you write a driver for some I2C device, please try to use the SMBus
14commands if at all possible (if the device uses only that subset of the
15I2C protocol). This makes it possible to use the device driver on both
16SMBus adapters and I2C adapters (the SMBus command set is automatically
17translated to I2C on I2C adapters, but plain I2C commands can not be
18handled at all on most pure SMBus adapters).
19
David Brownell1a31a882008-05-11 20:37:05 +020020Below is a list of SMBus protocol operations, and the functions executing
21them. Note that the names used in the SMBus protocol specifications usually
22don't match these function names. For some of the operations which pass a
23single data byte, the functions using SMBus protocol operation names execute
24a different protocol operation entirely.
25
Jean Delvarea1681782012-12-16 21:11:55 +010026Each transaction type corresponds to a functionality flag. Before calling a
27transaction function, a device driver should always check (just once) for
28the corresponding functionality flag to ensure that the underlying I2C
29adapter supports the transaction in question. See
30<file:Documentation/i2c/functionality> for the details.
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33Key to symbols
34==============
35
36S (1 bit) : Start bit
37P (1 bit) : Stop bit
38Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
39A, NA (1 bit) : Accept and reverse accept bit.
40Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to
41 get a 10 bit I2C address.
42Comm (8 bits): Command byte, a data byte which often selects a register on
43 the device.
44Data (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh
45 for 16 bit data.
46Count (8 bits): A data byte containing the length of a block operation.
47
48[..]: Data sent by I2C device, as opposed to data sent by the host adapter.
49
50
Jean Delvare67c2e662008-07-14 22:38:23 +020051SMBus Quick Command
52===================
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54This sends a single bit to the device, at the place of the Rd/Wr bit.
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56A Addr Rd/Wr [A] P
57
Jean Delvarea1681782012-12-16 21:11:55 +010058Functionality flag: I2C_FUNC_SMBUS_QUICK
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
David Brownell1a31a882008-05-11 20:37:05 +020061SMBus Receive Byte: i2c_smbus_read_byte()
62==========================================
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64This reads a single byte from a device, without specifying a device
65register. Some devices are so simple that this interface is enough; for
66others, it is a shorthand if you want to read the same register as in
67the previous SMBus command.
68
69S Addr Rd [A] [Data] NA P
70
Jean Delvarea1681782012-12-16 21:11:55 +010071Functionality flag: I2C_FUNC_SMBUS_READ_BYTE
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
David Brownell1a31a882008-05-11 20:37:05 +020074SMBus Send Byte: i2c_smbus_write_byte()
75========================================
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
David Brownell1a31a882008-05-11 20:37:05 +020077This operation is the reverse of Receive Byte: it sends a single byte
78to a device. See Receive Byte for more information.
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80S Addr Wr [A] Data [A] P
81
Jean Delvarea1681782012-12-16 21:11:55 +010082Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
David Brownell1a31a882008-05-11 20:37:05 +020085SMBus Read Byte: i2c_smbus_read_byte_data()
86============================================
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88This reads a single byte from a device, from a designated register.
89The register is specified through the Comm byte.
90
91S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
92
Jean Delvarea1681782012-12-16 21:11:55 +010093Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
David Brownell1a31a882008-05-11 20:37:05 +020096SMBus Read Word: i2c_smbus_read_word_data()
97============================================
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
David Brownell1a31a882008-05-11 20:37:05 +020099This operation is very like Read Byte; again, data is read from a
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100device, from a designated register that is specified through the Comm
101byte. But this time, the data is a complete word (16 bits).
102
103S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
104
Jean Delvarea1681782012-12-16 21:11:55 +0100105Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA
106
Jonathan Cameron06a67842011-10-30 13:47:25 +0100107Note the convenience function i2c_smbus_read_word_swapped is
108available for reads where the two data bytes are the other way
109around (not SMBus compliant, but very popular.)
110
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
David Brownell1a31a882008-05-11 20:37:05 +0200112SMBus Write Byte: i2c_smbus_write_byte_data()
113==============================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115This writes a single byte to a device, to a designated register. The
116register is specified through the Comm byte. This is the opposite of
David Brownell1a31a882008-05-11 20:37:05 +0200117the Read Byte operation.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119S Addr Wr [A] Comm [A] Data [A] P
120
Jean Delvarea1681782012-12-16 21:11:55 +0100121Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
David Brownell1a31a882008-05-11 20:37:05 +0200124SMBus Write Word: i2c_smbus_write_word_data()
125==============================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
David Brownell1a31a882008-05-11 20:37:05 +0200127This is the opposite of the Read Word operation. 16 bits
Mike Frysinger3f9a4792007-02-13 22:08:59 +0100128of data is written to a device, to the designated register that is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129specified through the Comm byte.
130
131S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
132
Jean Delvarea1681782012-12-16 21:11:55 +0100133Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA
134
Jonathan Cameron06a67842011-10-30 13:47:25 +0100135Note the convenience function i2c_smbus_write_word_swapped is
136available for writes where the two data bytes are the other way
137around (not SMBus compliant, but very popular.)
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
Tushar Beherac8110932012-11-19 16:31:42 +0530140SMBus Process Call:
141===================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
143This command selects a device register (through the Comm byte), sends
14416 bits of data to it, and reads 16 bits of data in return.
145
146S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
147 S Addr Rd [A] [DataLow] A [DataHigh] NA P
148
Jean Delvarea1681782012-12-16 21:11:55 +0100149Functionality flag: I2C_FUNC_SMBUS_PROC_CALL
150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
David Brownell1a31a882008-05-11 20:37:05 +0200152SMBus Block Read: i2c_smbus_read_block_data()
153==============================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
155This command reads a block of up to 32 bytes from a device, from a
156designated register that is specified through the Comm byte. The amount
157of data is specified by the device in the Count byte.
158
159S Addr Wr [A] Comm [A]
160 S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
161
Jean Delvarea1681782012-12-16 21:11:55 +0100162Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164
David Brownell1a31a882008-05-11 20:37:05 +0200165SMBus Block Write: i2c_smbus_write_block_data()
166================================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
168The opposite of the Block Read command, this writes up to 32 bytes to
169a device, to a designated register that is specified through the
170Comm byte. The amount of data is specified in the Count byte.
171
172S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
173
Jean Delvarea1681782012-12-16 21:11:55 +0100174Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA
175
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
David Brownell1a31a882008-05-11 20:37:05 +0200177SMBus Block Write - Block Read Process Call
178===========================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
David Brownell1a31a882008-05-11 20:37:05 +0200180SMBus Block Write - Block Read Process Call was introduced in
181Revision 2.0 of the specification.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
183This command selects a device register (through the Comm byte), sends
1841 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return.
185
186S Addr Wr [A] Comm [A] Count [A] Data [A] ...
187 S Addr Rd [A] [Count] A [Data] ... A P
188
Jean Delvarea1681782012-12-16 21:11:55 +0100189Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL
190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
192SMBus Host Notify
193=================
194
195This command is sent from a SMBus device acting as a master to the
196SMBus host acting as a slave.
197It is the same form as Write Word, with the command code replaced by the
198alerting device's address.
199
200[S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P]
201
202
203Packet Error Checking (PEC)
204===========================
David Brownell1a31a882008-05-11 20:37:05 +0200205
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206Packet Error Checking was introduced in Revision 1.1 of the specification.
207
David Brownell1a31a882008-05-11 20:37:05 +0200208PEC adds a CRC-8 error-checking byte to transfers using it, immediately
209before the terminating STOP.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
211
212Address Resolution Protocol (ARP)
213=================================
David Brownell1a31a882008-05-11 20:37:05 +0200214
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215The Address Resolution Protocol was introduced in Revision 2.0 of
216the specification. It is a higher-layer protocol which uses the
217messages above.
218
219ARP adds device enumeration and dynamic address assignment to
220the protocol. All ARP communications use slave address 0x61 and
221require PEC checksums.
222
223
Jean Delvareb5527a72010-03-02 12:23:42 +0100224SMBus Alert
225===========
226
227SMBus Alert was introduced in Revision 1.0 of the specification.
228
229The SMBus alert protocol allows several SMBus slave devices to share a
230single interrupt pin on the SMBus master, while still allowing the master
231to know which slave triggered the interrupt.
232
233This is implemented the following way in the Linux kernel:
234* I2C bus drivers which support SMBus alert should call
235 i2c_setup_smbus_alert() to setup SMBus alert support.
236* I2C drivers for devices which can trigger SMBus alerts should implement
237 the optional alert() callback.
238
239
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240I2C Block Transactions
241======================
David Brownell1a31a882008-05-11 20:37:05 +0200242
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243The following I2C block transactions are supported by the
244SMBus layer and are described here for completeness.
David Brownell1a31a882008-05-11 20:37:05 +0200245They are *NOT* defined by the SMBus specification.
246
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247I2C block transactions do not limit the number of bytes transferred
248but the SMBus layer places a limit of 32 bytes.
249
250
David Brownell1a31a882008-05-11 20:37:05 +0200251I2C Block Read: i2c_smbus_read_i2c_block_data()
252================================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
254This command reads a block of bytes from a device, from a
255designated register that is specified through the Comm byte.
256
257S Addr Wr [A] Comm [A]
258 S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
259
Jean Delvarea1681782012-12-16 21:11:55 +0100260Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
262
David Brownell1a31a882008-05-11 20:37:05 +0200263I2C Block Write: i2c_smbus_write_i2c_block_data()
264==================================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
266The opposite of the Block Read command, this writes bytes to
267a device, to a designated register that is specified through the
268Comm byte. Note that command lengths of 0, 2, or more bytes are
269supported as they are indistinguishable from data.
270
271S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
Jean Delvarea1681782012-12-16 21:11:55 +0100272
273Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK