← Documents Documentation/i2c/smbus-protocol.rst GitHub 원문 ↗

Linux 6.18.37 · I2C

The SMBus Protocol

SMBus 1.0~2.0의 바이트·워드·블록 전송과 PEC, ARP, Alert, Host Notify의 Linux API 및 기능 플래그를 설명합니다.

Source pathDocumentation/i2c/smbus-protocol.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

smbus-protocol.rst:1-324

SMBus는 I2C의 공통 부분집합이며 Linux는 각 전송 유형을 `i2c_smbus_*` API와 기능 플래그로 노출합니다. 드라이버는 호출 전에 어댑터 지원을 확인하고 ACK, repeated START, Count와 바이트 순서를 해당 프로토콜에 맞춰야 합니다.

문서 개요
항목
SourceDocumentation/i2c/smbus-protocol.rst
분량324 source lines
적용 규격SMBus 1.0, 1.1, 2.0
블록 상한32 bytes

원문 분량과 핵심 검토 대상을 요약합니다.

핵심 흐름
장치가 요구하는 SMBus 연산 선택기능 플래그 확인대응 API 호출프로토콜 전송 실행ACK·PEC·길이 조건 검증

문서의 주요 판단과 동작을 압축합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ==================
2 The SMBus Protocol
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 Documentation/i2c/functionality.rst for the details.
32
33
34 Key to symbols
35 ==============
36
37 =============== =============================================================
38 S Start condition
39 Sr Repeated start condition, used to switch from write to
40 read mode.
41 P Stop condition
42 Rd/Wr (1 bit) Read/Write bit. Rd equals 1, Wr equals 0.
43 A, NA (1 bit) Acknowledge (ACK) and Not Acknowledge (NACK) bit
44 Addr (7 bits) I2C 7 bit address. Note that this can be expanded to
45 get a 10 bit I2C address.
46 Comm (8 bits) Command byte, a data byte which often selects a register on
47 the device.
48 Data (8 bits) A plain data byte. DataLow and DataHigh represent the low and
49 high byte of a 16 bit word.
50 Count (8 bits) A data byte containing the length of a block operation.
51
52 [..] Data sent by I2C device, as opposed to data sent by the host
53 adapter.
54 =============== =============================================================
55
56
57 SMBus Quick Command
58 ===================
59
60 This sends a single bit to the device, at the place of the Rd/Wr bit::
61
62 S Addr Rd/Wr [A] P
63
64 Functionality flag: I2C_FUNC_SMBUS_QUICK
65
66
67 SMBus Receive Byte
68 ==================
69
70 Implemented by i2c_smbus_read_byte()
71
72 This reads a single byte from a device, without specifying a device
73 register. Some devices are so simple that this interface is enough; for
74 others, it is a shorthand if you want to read the same register as in
75 the previous SMBus command::
76
77 S Addr Rd [A] [Data] NA P
78
79 Functionality flag: I2C_FUNC_SMBUS_READ_BYTE
80
81
82 SMBus Send Byte
83 ===============
84
85 Implemented by i2c_smbus_write_byte()
86
87 This operation is the reverse of Receive Byte: it sends a single byte
88 to a device. See Receive Byte for more information.
89
90 ::
91
92 S Addr Wr [A] Data [A] P
93
94 Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE
95
96
97 SMBus Read Byte
98 ===============
99
100 Implemented by i2c_smbus_read_byte_data()
101
102 This reads a single byte from a device, from a designated register.
103 The register is specified through the Comm byte::
104
105 S Addr Wr [A] Comm [A] Sr Addr Rd [A] [Data] NA P
106
107 Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA
108
109
110 SMBus Read Word
111 ===============
112
113 Implemented by i2c_smbus_read_word_data()
114
115 This operation is very like Read Byte; again, data is read from a
116 device, from a designated register that is specified through the Comm
117 byte. But this time, the data is a complete word (16 bits)::
118
119 S Addr Wr [A] Comm [A] Sr Addr Rd [A] [DataLow] A [DataHigh] NA P
120
121 Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA
122
123 Note the convenience function i2c_smbus_read_word_swapped() is
124 available for reads where the two data bytes are the other way
125 around (not SMBus compliant, but very popular.)
126
127
128 SMBus Write Byte
129 ================
130
131 Implemented by i2c_smbus_write_byte_data()
132
133 This writes a single byte to a device, to a designated register. The
134 register is specified through the Comm byte. This is the opposite of
135 the Read Byte operation.
136
137 ::
138
139 S Addr Wr [A] Comm [A] Data [A] P
140
141 Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA
142
143
144 SMBus Write Word
145 ================
146
147 Implemented by i2c_smbus_write_word_data()
148
149 This is the opposite of the Read Word operation. 16 bits
150 of data are written to a device, to the designated register that is
151 specified through the Comm byte::
152
153 S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
154
155 Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA
156
157 Note the convenience function i2c_smbus_write_word_swapped() is
158 available for writes where the two data bytes are the other way
159 around (not SMBus compliant, but very popular.)
160
161
162 SMBus Process Call
163 ==================
164
165 This command selects a device register (through the Comm byte), sends
166 16 bits of data to it, and reads 16 bits of data in return::
167
168 S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
169 Sr Addr Rd [A] [DataLow] A [DataHigh] NA P
170
171 Functionality flag: I2C_FUNC_SMBUS_PROC_CALL
172
173
174 SMBus Block Read
175 ================
176
177 Implemented by i2c_smbus_read_block_data()
178
179 This command reads a block of up to 32 bytes from a device, from a
180 designated register that is specified through the Comm byte. The amount
181 of data is specified by the device in the Count byte.
182
183 ::
184
185 S Addr Wr [A] Comm [A]
186 Sr Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
187
188 Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA
189
190
191 SMBus Block Write
192 =================
193
194 Implemented by i2c_smbus_write_block_data()
195
196 The opposite of the Block Read command, this writes up to 32 bytes to
197 a device, to a designated register that is specified through the
198 Comm byte. The amount of data is specified in the Count byte.
199
200 ::
201
202 S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
203
204 Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA
205
206
207 SMBus Block Write - Block Read Process Call
208 ===========================================
209
210 SMBus Block Write - Block Read Process Call was introduced in
211 Revision 2.0 of the specification.
212
213 This command selects a device register (through the Comm byte), sends
214 1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return::
215
216 S Addr Wr [A] Comm [A] Count [A] Data [A] ...
217 Sr Addr Rd [A] [Count] A [Data] ... A P
218
219 Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL
220
221
222 SMBus Host Notify
223 =================
224
225 This command is sent from a SMBus device acting as a master to the
226 SMBus host acting as a slave.
227 It is the same form as Write Word, with the command code replaced by the
228 alerting device's address.
229
230 ::
231
232 [S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P]
233
234 This is implemented in the following way in the Linux kernel:
235
236 * I2C bus drivers which support SMBus Host Notify should report
237 I2C_FUNC_SMBUS_HOST_NOTIFY.
238 * I2C bus drivers trigger SMBus Host Notify by a call to
239 i2c_handle_smbus_host_notify().
240 * I2C drivers for devices which can trigger SMBus Host Notify will have
241 client->irq assigned to a Host Notify IRQ if no one else specified another.
242
243 There is currently no way to retrieve the data parameter from the client.
244
245
246 Packet Error Checking (PEC)
247 ===========================
248
249 Packet Error Checking was introduced in Revision 1.1 of the specification.
250
251 PEC adds a CRC-8 error-checking byte to transfers using it, immediately
252 before the terminating STOP.
253
254
255 Address Resolution Protocol (ARP)
256 =================================
257
258 The Address Resolution Protocol was introduced in Revision 2.0 of
259 the specification. It is a higher-layer protocol which uses the
260 messages above.
261
262 ARP adds device enumeration and dynamic address assignment to
263 the protocol. All ARP communications use slave address 0x61 and
264 require PEC checksums.
265
266
267 SMBus Alert
268 ===========
269
270 SMBus Alert was introduced in Revision 1.0 of the specification.
271
272 The SMBus alert protocol allows several SMBus slave devices to share a
273 single interrupt pin on the SMBus master, while still allowing the master
274 to know which slave triggered the interrupt.
275
276 This is implemented the following way in the Linux kernel:
277
278 * I2C bus drivers which support SMBus alert should call
279 i2c_new_smbus_alert_device() to install SMBus alert support.
280 * I2C drivers for devices which can trigger SMBus alerts should implement
281 the optional alert() callback.
282
283
284 I2C Block Transactions
285 ======================
286
287 The following I2C block transactions are similar to the SMBus Block Read
288 and Write operations, except these do not have a Count byte. They are
289 supported by the SMBus layer and are described here for completeness, but
290 they are *NOT* defined by the SMBus specification.
291
292 I2C block transactions do not limit the number of bytes transferred
293 but the SMBus layer places a limit of 32 bytes.
294
295
296 I2C Block Read
297 ==============
298
299 Implemented by i2c_smbus_read_i2c_block_data()
300
301 This command reads a block of bytes from a device, from a
302 designated register that is specified through the Comm byte::
303
304 S Addr Wr [A] Comm [A]
305 Sr Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
306
307 Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK
308
309
310 I2C Block Write
311 ===============
312
313 Implemented by i2c_smbus_write_i2c_block_data()
314
315 The opposite of the Block Read command, this writes bytes to
316 a device, to a designated register that is specified through the
317 Comm byte. Note that command lengths of 0, 2, or more bytes are
318 supported as they are indistinguishable from data.
319
320 ::
321
322 S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
323
324 Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
325

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

SMBus 범위, 호환성과 기호

1-55

이 문서는 SMBus 프로토콜 1.0, 1.1, 2.0 전체에 적용되는 요약입니다. 이 Linux 패키지가 지원하지 않는 일부 프로토콜 기능도 문서 끝에서 간단히 설명합니다.

일부 어댑터는 I2C의 부분집합인 SMBus(System Management Bus) 프로토콜만 이해합니다. 많은 장치도 이 공통 부분집합만 사용하므로 SMBus에 연결할 수 있습니다.

I2C 장치가 SMBus 부분집합만 사용한다면 드라이버는 가능한 한 SMBus 명령을 사용해야 합니다. 그러면 같은 드라이버를 SMBus 어댑터와 I2C 어댑터 모두에서 쓸 수 있습니다. I2C 어댑터는 SMBus 명령 집합을 일반 I2C로 자동 변환하지만, 순수 SMBus 어댑터 대부분은 임의의 일반 I2C 명령을 처리하지 못합니다.

아래 연산 이름과 이를 실행하는 Linux 함수 이름은 SMBus 규격의 이름과 항상 일치하지 않습니다. 특히 데이터 바이트 하나를 전달하는 일부 함수는 이름과 다른 프로토콜 연산을 실제로 수행할 수 있으므로 전송 형식을 확인해야 합니다.

각 트랜잭션 유형에는 대응 기능 플래그가 있습니다. 장치 드라이버는 트랜잭션 함수를 호출하기 전에 기반 I2C 어댑터가 해당 연산을 지원하는지 대응 플래그로 한 번 확인해야 합니다. 자세한 내용은 `Documentation/i2c/functionality.rst`를 참조합니다.

SMBus 표기 기호
기호의미
`S`-START 조건
`Sr`-write에서 read로 바꿀 때 쓰는 repeated START
`P`-STOP 조건
`Rd/Wr`1 bitread는 1, write는 0
`A`, `NA`1 bitACK와 NACK
`Addr`7 bitsI2C 7비트 주소, 10비트 주소로 확장 가능
`Comm`8 bits흔히 장치 레지스터를 선택하는 command byte
`Data`8 bits일반 데이터, `DataLow`·`DataHigh`는 16비트 워드의 하위·상위 바이트
`Count`8 bits블록 연산의 길이
`[..]`-호스트 어댑터가 아니라 I2C 장치가 보낸 데이터

전송 순서 도식에서 사용하는 기호와 비트 폭입니다.

호환 가능한 SMBus 호출 선택
장치가 SMBus 부분집합만 사용하는지 확인필요 트랜잭션의 기능 플래그 선택probe 시 어댑터 지원 여부를 한 번 확인대응 `i2c_smbus_*` 함수 사용I2C 어댑터에서는 SMBus 명령을 I2C 전송으로 자동 변환

드라이버가 어댑터 기능을 확인하고 호출하는 순서입니다.

==================
The SMBus Protocol
==================

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.

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).

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.

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
Documentation/i2c/functionality.rst for the details.


Key to symbols
==============

=============== =============================================================
S               Start condition
Sr              Repeated start condition, used to switch from write to
                read mode.
P               Stop condition
Rd/Wr (1 bit)   Read/Write bit. Rd equals 1, Wr equals 0.
A, NA (1 bit)   Acknowledge (ACK) and Not Acknowledge (NACK) bit
Addr  (7 bits)  I2C 7 bit address. Note that this can be expanded 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. DataLow and DataHigh represent the low and
                high byte of a 16 bit word.
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.
=============== =============================================================

Quick, Receive/Send Byte와 레지스터 Byte/Word 읽기

56-125

SMBus Quick Command는 `Rd/Wr` 비트 위치에서 장치로 단일 비트를 보냅니다. 전송은 `S Addr Rd/Wr [A] P`이고 기능 플래그는 `I2C_FUNC_SMBUS_QUICK`입니다.

SMBus Receive Byte는 `i2c_smbus_read_byte()`로 구현합니다. 장치 레지스터를 지정하지 않고 한 바이트를 읽습니다. 단순 장치에는 이것만으로 충분하고, 다른 장치에서는 직전 SMBus 명령과 같은 레지스터를 다시 읽는 축약형으로 사용할 수 있습니다.

Receive Byte 전송은 `S Addr Rd [A] [Data] NA P`이고 기능 플래그는 `I2C_FUNC_SMBUS_READ_BYTE`입니다. 호스트는 데이터 한 바이트를 받은 뒤 NACK하고 STOP합니다.

SMBus Send Byte는 Receive Byte의 반대이며 `i2c_smbus_write_byte()`가 한 바이트를 장치에 보냅니다. 전송은 `S Addr Wr [A] Data [A] P`, 기능 플래그는 `I2C_FUNC_SMBUS_WRITE_BYTE`입니다.

SMBus Read Byte는 `i2c_smbus_read_byte_data()`로 지정 레지스터의 한 바이트를 읽습니다. `Comm` 바이트로 레지스터를 고른 뒤 repeated START로 read 방향을 시작합니다. 전송은 `S Addr Wr [A] Comm [A] Sr Addr Rd [A] [Data] NA P`이고 기능 플래그는 `I2C_FUNC_SMBUS_READ_BYTE_DATA`입니다.

SMBus Read Word는 `i2c_smbus_read_word_data()`로 지정 레지스터의 16비트 워드를 읽습니다. Read Byte와 같은 방식이지만 장치가 `DataLow`를 먼저, `DataHigh`를 다음에 보냅니다. 호스트는 하위 바이트에 ACK하고 마지막 상위 바이트에는 NACK합니다.

Read Word 전송은 `S Addr Wr [A] Comm [A] Sr Addr Rd [A] [DataLow] A [DataHigh] NA P`, 기능 플래그는 `I2C_FUNC_SMBUS_READ_WORD_DATA`입니다. SMBus 규격과 반대로 두 바이트를 보내는 흔한 장치는 편의 함수 `i2c_smbus_read_word_swapped()`로 읽을 수 있습니다.

SMBus 기본 읽기·바이트 연산
연산Linux 함수전송 핵심기능 플래그
Quick Command-`S Addr Rd/Wr [A] P``I2C_FUNC_SMBUS_QUICK`
Receive Byte`i2c_smbus_read_byte()`레지스터 지정 없이 1 byte 읽기`I2C_FUNC_SMBUS_READ_BYTE`
Send Byte`i2c_smbus_write_byte()`레지스터 지정 없이 1 byte 쓰기`I2C_FUNC_SMBUS_WRITE_BYTE`
Read Byte`i2c_smbus_read_byte_data()``Comm`, `Sr`, 1 byte 읽기`I2C_FUNC_SMBUS_READ_BYTE_DATA`
Read Word`i2c_smbus_read_word_data()``Comm`, `Sr`, low/high 읽기`I2C_FUNC_SMBUS_READ_WORD_DATA`

연산별 Linux 함수, 전송 형식과 기능 플래그입니다.

레지스터 읽기
START와 주소 write`Comm`으로 레지스터 선택repeated START같은 주소 read장치 데이터 수신마지막 바이트 NACK 후 STOP

Read Byte와 Read Word가 공유하는 방향 전환입니다.


SMBus Quick Command
===================

This sends a single bit to the device, at the place of the Rd/Wr bit::

  S Addr Rd/Wr [A] P

Functionality flag: I2C_FUNC_SMBUS_QUICK


SMBus Receive Byte
==================

Implemented by i2c_smbus_read_byte()

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

Functionality flag: I2C_FUNC_SMBUS_READ_BYTE


SMBus Send Byte
===============

Implemented by i2c_smbus_write_byte()

This operation is the reverse of Receive Byte: it sends a single byte
to a device.  See Receive Byte for more information.

::

  S Addr Wr [A] Data [A] P

Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE


SMBus Read Byte
===============

Implemented by i2c_smbus_read_byte_data()

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] Sr Addr Rd [A] [Data] NA P

Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA


SMBus Read Word
===============

Implemented by i2c_smbus_read_word_data()

This operation is very like Read Byte; again, data is read from a
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] Sr Addr Rd [A] [DataLow] A [DataHigh] NA P

Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA

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.)

레지스터 Byte/Word 쓰기와 Process Call

126-173

SMBus Write Byte는 `i2c_smbus_write_byte_data()`로 지정 레지스터에 한 바이트를 씁니다. `Comm`으로 레지스터를 선택하며 Read Byte의 반대입니다. 전송은 `S Addr Wr [A] Comm [A] Data [A] P`, 기능 플래그는 `I2C_FUNC_SMBUS_WRITE_BYTE_DATA`입니다.

SMBus Write Word는 `i2c_smbus_write_word_data()`로 지정 레지스터에 16비트 데이터를 씁니다. `DataLow`를 먼저 보내고 `DataHigh`를 보냅니다. 전송은 `S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P`, 기능 플래그는 `I2C_FUNC_SMBUS_WRITE_WORD_DATA`입니다.

장치가 두 바이트를 SMBus 규격과 반대 순서로 기대하는 흔한 경우에는 `i2c_smbus_write_word_swapped()` 편의 함수를 사용할 수 있습니다.

SMBus Process Call은 `Comm`으로 장치 레지스터를 선택하고 16비트 데이터를 쓴 뒤, STOP 없이 repeated START로 방향을 바꿔 16비트 결과를 읽습니다.

전송은 write 구간의 `S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]` 뒤에 read 구간의 `Sr Addr Rd [A] [DataLow] A [DataHigh] NA P`가 이어집니다. 기능 플래그는 `I2C_FUNC_SMBUS_PROC_CALL`입니다.

SMBus 레지스터 쓰기와 호출
연산Linux 함수데이터기능 플래그
Write Byte`i2c_smbus_write_byte_data()``Comm` + 8 bits`I2C_FUNC_SMBUS_WRITE_BYTE_DATA`
Write Word`i2c_smbus_write_word_data()``Comm` + low/high 16 bits`I2C_FUNC_SMBUS_WRITE_WORD_DATA`
Process Call-`Comm` + 16-bit write + 16-bit read`I2C_FUNC_SMBUS_PROC_CALL`

단방향 쓰기와 쓰기-읽기 결합을 비교합니다.

Process Call
주소 write와 `Comm` 전송`DataLow`, `DataHigh` 요청 전송repeated START로 read 전환응답 `DataLow`에 ACK응답 `DataHigh`에 NACKSTOP

하나의 트랜잭션에서 요청 워드와 응답 워드를 교환합니다.



SMBus Write Byte
================

Implemented by i2c_smbus_write_byte_data()

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
the Read Byte operation.

::

  S Addr Wr [A] Comm [A] Data [A] P

Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA


SMBus Write Word
================

Implemented by i2c_smbus_write_word_data()

This is the opposite of the Read Word operation. 16 bits
of data are written to a device, to the designated register that is
specified through the Comm byte::

  S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P

Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA

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.)


SMBus Process Call
==================

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]
                              Sr Addr Rd [A] [DataLow] A [DataHigh] NA P

Functionality flag: I2C_FUNC_SMBUS_PROC_CALL

블록 전송, Block Process Call과 Host Notify

174-245

SMBus Block Read는 `i2c_smbus_read_block_data()`로 `Comm`이 지정하는 레지스터에서 최대 32바이트를 읽습니다. 장치가 `Count` 바이트로 데이터 양을 알려줍니다.

전송은 `S Addr Wr [A] Comm [A]` 뒤 repeated START와 `Addr Rd`가 이어지고, 장치가 `[Count]`와 그 수만큼의 `[Data]`를 보냅니다. 호스트는 중간 바이트마다 ACK하고 마지막 바이트에 NACK한 뒤 STOP합니다. 기능 플래그는 `I2C_FUNC_SMBUS_READ_BLOCK_DATA`입니다.

SMBus Block Write는 `i2c_smbus_write_block_data()`로 반대 방향의 전송을 수행합니다. `Comm`으로 레지스터를 지정하고 `Count`에 이어 최대 32바이트를 씁니다. 기능 플래그는 `I2C_FUNC_SMBUS_WRITE_BLOCK_DATA`입니다.

SMBus Block Write - Block Read Process Call은 규격 2.0에서 도입됐습니다. `Comm`으로 레지스터를 선택하고 1~31바이트를 쓴 뒤 repeated START로 1~31바이트를 읽습니다. 쓰기와 읽기 구간은 각각 자체 `Count`를 사용하며 기능 플래그는 `I2C_FUNC_SMBUS_BLOCK_PROC_CALL`입니다.

SMBus 블록 연산
연산Linux 함수쓰기 길이읽기 길이기능 플래그
Block Read`i2c_smbus_read_block_data()``Comm`장치 `Count`, 최대 32`I2C_FUNC_SMBUS_READ_BLOCK_DATA`
Block Write`i2c_smbus_write_block_data()`호스트 `Count`, 최대 32-`I2C_FUNC_SMBUS_WRITE_BLOCK_DATA`
Block Process Call-1~311~31`I2C_FUNC_SMBUS_BLOCK_PROC_CALL`

Count가 정하는 방향별 길이와 상한입니다.

SMBus Host Notify는 SMBus 장치가 마스터 역할로, 슬레이브 역할의 SMBus 호스트에 보내는 명령입니다. 형식은 Write Word와 같지만 command code 자리에 알림을 보낸 장치 주소가 들어갑니다.

전송은 장치가 주도하는 `[S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P]`입니다.

Linux에서 Host Notify를 지원하는 I2C 버스 드라이버는 `I2C_FUNC_SMBUS_HOST_NOTIFY`를 보고해야 하고, 알림을 수신하면 `i2c_handle_smbus_host_notify()`를 호출합니다. Host Notify를 발생시킬 수 있는 장치의 I2C 드라이버는 다른 IRQ가 지정되지 않았을 때 `client->irq`에 Host Notify IRQ를 할당받습니다.

현재는 클라이언트에서 Host Notify의 data 매개변수를 가져오는 방법이 없습니다.

Linux Host Notify 연결
구성 요소역할
버스 드라이버`I2C_FUNC_SMBUS_HOST_NOTIFY` 보고
알림 수신 경로`i2c_handle_smbus_host_notify()` 호출
장치 클라이언트별도 지정이 없으면 `client->irq`에 Host Notify IRQ
제약client에서 data 매개변수 조회 불가

버스 드라이버와 장치 드라이버의 책임입니다.

Host Notify 전달
알림 장치가 SMBus 마스터 역할 획득`HostAddr`에 `DevAddr`와 16-bit data 쓰기호스트 버스 드라이버가 메시지 수신`i2c_handle_smbus_host_notify()` 호출대응 `client->irq` 처리

장치가 마스터가 되어 호스트의 IRQ 처리로 이어집니다.

SMBus Block Read
================

Implemented by i2c_smbus_read_block_data()

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]
            Sr Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P

Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA


SMBus Block Write
=================

Implemented by i2c_smbus_write_block_data()

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

Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA


SMBus Block Write - Block Read Process Call
===========================================

SMBus Block Write - Block Read Process Call was introduced in
Revision 2.0 of the specification.

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] ...
                              Sr Addr Rd [A] [Count] A [Data] ... A P

Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL


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]

This is implemented in the following way in the Linux kernel:

* 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 no one else specified another.

There is currently no way to retrieve the data parameter from the client.

PEC, ARP와 SMBus Alert

246-283

Packet Error Checking(PEC)은 SMBus 규격 1.1에서 도입됐습니다. PEC를 사용하는 전송에서는 종료 STOP 바로 앞에 CRC-8 오류 검사 바이트 하나를 추가합니다.

Address Resolution Protocol(ARP)은 규격 2.0에서 도입된 상위 계층 프로토콜이며 앞에서 설명한 메시지를 사용합니다. 장치 열거와 동적 주소 할당 기능을 추가합니다.

모든 ARP 통신은 슬레이브 주소 `0x61`을 사용하며 PEC 체크섬이 필수입니다.

SMBus Alert는 규격 1.0에서 도입됐습니다. 여러 SMBus 슬레이브 장치가 SMBus 마스터의 인터럽트 핀 하나를 공유하면서도, 마스터가 어느 슬레이브가 인터럽트를 발생시켰는지 식별하게 합니다.

Linux에서 SMBus Alert를 지원하는 I2C 버스 드라이버는 `i2c_new_smbus_alert_device()`를 호출해 alert 지원을 설치해야 합니다. Alert를 발생시킬 수 있는 장치의 I2C 드라이버는 선택적 `alert()` 콜백을 구현해야 합니다.

SMBus 확장 기능의 규격 이력
기능도입 규격핵심
SMBus Alert1.0공유 인터럽트 핀에서 발생 장치 식별
PEC1.1STOP 직전 CRC-8 바이트
ARP2.0장치 열거와 동적 주소 할당, 주소 `0x61`, PEC 필수

도입 버전과 핵심 의미입니다.

Linux SMBus Alert
버스 드라이버가 `i2c_new_smbus_alert_device()` 호출여러 장치가 공유 SMBAlert 핀 사용마스터가 Alert Response 절차로 발생 장치 식별해당 I2C 장치 드라이버의 `alert()` 콜백 실행

공유 핀 인터럽트를 장치별 콜백으로 연결합니다.

Packet Error Checking (PEC)
===========================

Packet Error Checking was introduced in Revision 1.1 of the specification.

PEC adds a CRC-8 error-checking byte to transfers using it, immediately
before the terminating STOP.


Address Resolution Protocol (ARP)
=================================

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.


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_new_smbus_alert_device() to install SMBus alert support.
* I2C drivers for devices which can trigger SMBus alerts should implement
  the optional alert() callback.

SMBus 계층이 제공하는 I2C Block 전송

284-324

I2C block 트랜잭션은 SMBus Block Read/Write와 비슷하지만 `Count` 바이트가 없습니다. SMBus 계층이 완전성을 위해 지원하고 이 문서에서 설명하지만 SMBus 규격 자체에는 정의되지 않은 연산입니다.

I2C block 트랜잭션의 프로토콜 자체는 전송 바이트 수를 제한하지 않지만 Linux SMBus 계층은 32바이트로 제한합니다.

I2C Block Read는 `i2c_smbus_read_i2c_block_data()`로 `Comm`이 지정하는 레지스터에서 바이트 블록을 읽습니다. `S Addr Wr [A] Comm [A]` 뒤 repeated START로 read 방향을 열고, 장치 데이터들을 읽은 뒤 마지막 데이터에 NACK하고 STOP합니다. 기능 플래그는 `I2C_FUNC_SMBUS_READ_I2C_BLOCK`입니다.

I2C Block Write는 `i2c_smbus_write_i2c_block_data()`로 지정 레지스터에 바이트를 씁니다. 길이 0, 2 또는 그 이상의 command도 데이터와 구분할 수 없으므로 지원됩니다. 전송은 `S Addr Wr [A] Comm [A] Data [A] ... Data [A] P`, 기능 플래그는 `I2C_FUNC_SMBUS_WRITE_I2C_BLOCK`입니다.

I2C Block과 SMBus Block 비교
연산 계열`Count` 바이트프로토콜 길이Linux SMBus 계층
SMBus Block있음최대 32 bytes최대 32 bytes
I2C Block없음제한 없음최대 32 bytes

Count 존재와 Linux 계층의 길이 제한을 구분합니다.

I2C Block 함수와 기능 플래그
방향Linux 함수기능 플래그
Read`i2c_smbus_read_i2c_block_data()``I2C_FUNC_SMBUS_READ_I2C_BLOCK`
Write`i2c_smbus_write_i2c_block_data()``I2C_FUNC_SMBUS_WRITE_I2C_BLOCK`

규격 외 I2C block 연산의 Linux API입니다.

I2C Block Transactions
======================

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.

I2C block transactions do not limit the number of bytes transferred
but the SMBus layer places a limit of 32 bytes.


I2C Block Read
==============

Implemented by i2c_smbus_read_i2c_block_data()

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]
            Sr Addr Rd [A] [Data] A [Data] A ... A [Data] NA P

Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK


I2C Block Write
===============

Implemented by i2c_smbus_write_i2c_block_data()

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

Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK