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

Linux 6.18.37 · I2C

The I2C Protocol

I2C 기호, 단순 송수신, 반복 START 결합 전송, 메시지 변형 플래그의 신호 의미를 설명합니다.

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

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

1. 요약·해설

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

요약·해설

i2c-protocol.rst:1-96

I2C 전송은 START, 주소·방향, ACK·NACK, 데이터, STOP의 순서로 구성되며 결합 전송은 STOP 대신 반복 START를 사용합니다. 변형 플래그는 장치의 비표준 요구가 있을 때만 신중히 적용합니다.

문서 개요
항목
SourceDocumentation/i2c/i2c-protocol.rst
분량96 source lines
기본 커널 API3
변형 플래그5

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

핵심 흐름
기호와 방향 확인단순 또는 결합 전송 선택필요한 경우에만 변형 플래그 적용실제 버스 신호 검증

문서의 주요 판단이나 전송 순서를 압축해 보여 줍니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ================
2 The I2C Protocol
3 ================
4
5 This document is an overview of the basic I2C transactions and the kernel
6 APIs to perform them.
7
8 Key to symbols
9 ==============
10
11 =============== =============================================================
12 S Start condition
13 P Stop condition
14 Rd/Wr (1 bit) Read/Write bit. Rd equals 1, Wr equals 0.
15 A, NA (1 bit) Acknowledge (ACK) and Not Acknowledge (NACK) bit
16 Addr (7 bits) I2C 7 bit address. Note that this can be expanded to
17 get a 10 bit I2C address.
18 Data (8 bits) A plain data byte.
19
20 [..] Data sent by I2C device, as opposed to data sent by the
21 host adapter.
22 =============== =============================================================
23
24
25 Simple send transaction
26 =======================
27
28 Implemented by i2c_master_send()::
29
30 S Addr Wr [A] Data [A] Data [A] ... [A] Data [A] P
31
32
33 Simple receive transaction
34 ==========================
35
36 Implemented by i2c_master_recv()::
37
38 S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
39
40
41 Combined transactions
42 =====================
43
44 Implemented by i2c_transfer().
45
46 They are just like the above transactions, but instead of a stop
47 condition P a start condition S is sent and the transaction continues.
48 An example of a byte read, followed by a byte write::
49
50 S Addr Rd [A] [Data] NA S Addr Wr [A] Data [A] P
51
52
53 Modified transactions
54 =====================
55
56 The following modifications to the I2C protocol can also be generated by
57 setting these flags for I2C messages. With the exception of I2C_M_NOSTART, they
58 are usually only needed to work around device issues:
59
60 I2C_M_IGNORE_NAK:
61 Normally message is interrupted immediately if there is [NA] from the
62 client. Setting this flag treats any [NA] as [A], and all of
63 message is sent.
64 These messages may still fail to SCL lo->hi timeout.
65
66 I2C_M_NO_RD_ACK:
67 In a read message, master A/NA bit is skipped.
68
69 I2C_M_NOSTART:
70 In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some
71 point. For example, setting I2C_M_NOSTART on the second partial message
72 generates something like::
73
74 S Addr Rd [A] [Data] NA Data [A] P
75
76 If you set the I2C_M_NOSTART variable for the first partial message,
77 we do not generate Addr, but we do generate the start condition S.
78 This will probably confuse all other clients on your bus, so don't
79 try this.
80
81 This is often used to gather transmits from multiple data buffers in
82 system memory into something that appears as a single transfer to the
83 I2C device but may also be used between direction changes by some
84 rare devices.
85
86 I2C_M_REV_DIR_ADDR:
87 This toggles the Rd/Wr flag. That is, if you want to do a write, but
88 need to emit an Rd instead of a Wr, or vice versa, you set this
89 flag. For example::
90
91 S Addr Rd [A] Data [A] Data [A] ... [A] Data [A] P
92
93 I2C_M_STOP:
94 Force a stop condition (P) after the message. Some I2C related protocols
95 like SCCB require that. Normally, you really don't want to get interrupted
96 between the messages of one transfer.
97

3. 한국어 전문 번역

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

I2C 프로토콜 기호

1-23

이 문서는 기본 I2C 트랜잭션과 이를 수행하는 커널 API를 개괄합니다.

I2C 신호 표기
기호의미
`S`START 조건
`P`STOP 조건
`Rd/Wr` (1비트)읽기·쓰기 비트. `Rd`는 1, `Wr`은 0
`A`, `NA` (1비트)승인 ACK와 비승인 NACK 비트
`Addr` (7비트)I2C 7비트 주소. 10비트 주소로 확장 가능
`Data` (8비트)일반 데이터 바이트
`[..]`호스트 어댑터가 아니라 I2C 장치가 보낸 데이터

원문의 모든 프로토콜 기호와 비트 폭을 보존합니다.

기본 I2C 프레임
START `S`7비트 또는 10비트 `Addr`방향 비트 `Rd/Wr`수신 측의 `A` 또는 `NA`8비트 `Data`와 승인 반복STOP `P`

주소와 방향 뒤에 데이터와 승인 비트가 이어집니다.

================
The I2C Protocol
================

This document is an overview of the basic I2C transactions and the kernel
APIs to perform them.

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

=============== =============================================================
S               Start condition
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.
Data  (8 bits)  A plain data byte.

[..]            Data sent by I2C device, as opposed to data sent by the
                host adapter.
=============== =============================================================

단순 송신과 수신 트랜잭션

24-40

단순 송신은 `i2c_master_send()`로 구현합니다. 마스터가 START, 주소, 쓰기 비트를 보내고 장치 ACK를 받은 뒤 데이터 바이트와 각 ACK를 반복한 다음 STOP으로 끝냅니다.

단순 수신은 `i2c_master_recv()`로 구현합니다. 마스터가 START, 주소, 읽기 비트를 보내고 장치 ACK를 받은 뒤 장치가 보내는 데이터 바이트를 읽습니다. 마스터는 중간 바이트마다 ACK를 보내고 마지막 바이트에는 NACK를 보낸 뒤 STOP으로 끝냅니다.

단순 트랜잭션 비교
종류커널 API신호 순서
송신`i2c_master_send()``S Addr Wr [A] Data [A] ... Data [A] P`
수신`i2c_master_recv()``S Addr Rd [A] [Data] A ... [Data] NA P`

대괄호는 I2C 장치가 보낸 항목을 뜻합니다.

단순 송신
`S``Addr Wr`장치 `[A]`호스트 `Data`장치 `[A]`, 데이터만큼 반복`P`

호스트가 데이터와 함께 각 바이트 뒤의 장치 ACK를 확인합니다.

단순 수신
`S``Addr Rd`장치 `[A]`장치 `[Data]`, 마스터 `A` 반복마지막 장치 `[Data]`, 마스터 `NA``P`

마지막 데이터에는 마스터가 NA를 보내 수신 종료를 알립니다.


Simple send transaction
=======================

Implemented by i2c_master_send()::

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


Simple receive transaction
==========================

Implemented by i2c_master_recv()::

  S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P

결합 트랜잭션

41-51

결합 트랜잭션은 `i2c_transfer()`로 구현합니다. 단순 트랜잭션과 같지만 첫 메시지 뒤에 STOP 조건 `P`를 보내지 않고 반복 START 조건 `S`를 보내 트랜잭션을 계속합니다.

원문의 예는 한 바이트 읽기 뒤에 한 바이트 쓰기를 수행합니다. 읽기 주소와 ACK, 장치 데이터, 마스터 NACK 다음에 반복 START를 보내고, 쓰기 주소와 ACK, 호스트 데이터와 장치 ACK를 거쳐 STOP으로 끝냅니다.

읽기 후 쓰기 결합 전송
부분신호 순서
읽기`S Addr Rd [A] [Data] NA`
경계STOP 대신 반복 START `S`
쓰기`Addr Wr [A] Data [A] P`

중간 STOP 없이 반복 START로 방향을 바꿉니다.

결합 전송 신호
START와 읽기 주소한 바이트 수신 후 NACKSTOP 없이 반복 START쓰기 주소한 바이트 송신과 ACKSTOP

하나의 전송 안에서 버스를 놓지 않고 읽기에서 쓰기로 바뀝니다.

Combined transactions
=====================

Implemented by i2c_transfer().

They are just like the above transactions, but instead of a stop
condition P a start condition S is sent and the transaction continues.
An example of a byte read, followed by a byte write::

  S Addr Rd [A] [Data] NA S Addr Wr [A] Data [A] P

프로토콜 변형 플래그

52-96

I2C 메시지에 다음 플래그를 설정하면 프로토콜을 변형할 수 있습니다. `I2C_M_NOSTART`를 제외하면 보통 장치 문제를 우회할 때만 필요합니다.

`I2C_M_IGNORE_NAK`는 클라이언트가 보낸 모든 NACK `[NA]`를 ACK `[A]`로 취급하여 메시지 전체를 계속 전송합니다. 그래도 SCL Low에서 High로 전환하는 시간 초과 때문에 실패할 수 있습니다.

`I2C_M_NO_RD_ACK`는 읽기 메시지에서 마스터가 보내는 ACK·NACK 비트를 생략합니다.

`I2C_M_NOSTART`는 결합 트랜잭션의 특정 지점에서 `S Addr Wr/Rd [A]`를 만들지 않습니다. 두 번째 부분 메시지에 설정하면 첫 읽기 뒤 별도 START와 주소 없이 바로 다음 데이터를 이어 보낼 수 있습니다.

첫 번째 부분 메시지에 `I2C_M_NOSTART`를 설정하면 주소는 만들지 않지만 START 조건 `S`는 만듭니다. 이는 버스의 다른 모든 클라이언트를 혼란스럽게 할 가능성이 크므로 사용해서는 안 됩니다.

이 플래그는 시스템 메모리의 여러 데이터 버퍼에서 나온 송신을 I2C 장치에 하나의 전송처럼 보이게 모을 때 자주 사용합니다. 드문 장치에서는 전송 방향이 바뀌는 사이에도 사용할 수 있습니다.

`I2C_M_REV_DIR_ADDR`는 주소 단계의 `Rd/Wr` 비트를 뒤집습니다. 쓰기를 수행하면서 `Wr` 대신 `Rd`를 내보내야 하거나 그 반대가 필요한 경우에 설정합니다.

`I2C_M_STOP`은 메시지 뒤에 STOP 조건 `P`를 강제로 만듭니다. SCCB 같은 일부 I2C 관련 프로토콜이 이를 요구하지만, 일반적인 하나의 전송에서는 메시지 사이가 끊기지 않는 편이 바람직합니다.

I2C 메시지 변형 플래그
플래그변형주의
`I2C_M_IGNORE_NAK`모든 `[NA]`를 `[A]`로 취급하고 계속 전송SCL Low→High 시간 초과는 여전히 실패
`I2C_M_NO_RD_ACK`읽기 메시지에서 마스터 A/NA 생략특수 장치에만 사용
`I2C_M_NOSTART`일부 `S Addr Wr/Rd [A]` 생략첫 메시지에 쓰면 다른 클라이언트를 혼란시킴
`I2C_M_REV_DIR_ADDR`주소의 Rd/Wr 비트 반전의도한 데이터 방향과 주소 비트가 달라짐
`I2C_M_STOP`해당 메시지 뒤 STOP 강제일반 결합 전송을 중단

각 플래그가 바꾸는 신호와 사용상 주의입니다.

변형 트랜잭션 신호
변형신호 순서
두 번째 메시지 `I2C_M_NOSTART``S Addr Rd [A] [Data] NA Data [A] P`
`I2C_M_REV_DIR_ADDR` 쓰기 예`S Addr Rd [A] Data [A] ... Data [A] P`

원문의 ASCII 신호열을 구조화하여 보존합니다.

변형 플래그 선택
표준 I2C 전송으로 장치 접근 시도장치 명세에서 비표준 요구 확인필요한 메시지 하나에만 변형 플래그 설정S·주소·방향·ACK·STOP 신호 재검토로직 분석기로 실제 버스 파형 검증

표준 전송으로 해결할 수 없는 장치 요구가 있을 때만 적용합니다.


Modified transactions
=====================

The following modifications to the I2C protocol can also be generated by
setting these flags for I2C messages. With the exception of I2C_M_NOSTART, they
are usually only needed to work around device issues:

I2C_M_IGNORE_NAK:
    Normally message is interrupted immediately if there is [NA] from the
    client. Setting this flag treats any [NA] as [A], and all of
    message is sent.
    These messages may still fail to SCL lo->hi timeout.

I2C_M_NO_RD_ACK:
    In a read message, master A/NA bit is skipped.

I2C_M_NOSTART:
    In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some
    point. For example, setting I2C_M_NOSTART on the second partial message
    generates something like::

      S Addr Rd [A] [Data] NA Data [A] P

    If you set the I2C_M_NOSTART variable for the first partial message,
    we do not generate Addr, but we do generate the start condition S.
    This will probably confuse all other clients on your bus, so don't
    try this.

    This is often used to gather transmits from multiple data buffers in
    system memory into something that appears as a single transfer to the
    I2C device but may also be used between direction changes by some
    rare devices.

I2C_M_REV_DIR_ADDR:
    This toggles the Rd/Wr flag. That is, if you want to do a write, but
    need to emit an Rd instead of a Wr, or vice versa, you set this
    flag. For example::

      S Addr Rd [A] Data [A] Data [A] ... [A] Data [A] P

I2C_M_STOP:
    Force a stop condition (P) after the message. Some I2C related protocols
    like SCCB require that. Normally, you really don't want to get interrupted
    between the messages of one transfer.