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