Documentation/driver-api/i2c.rst GitHub 원문 ↗

Linux 6.18.37 · Driver API

I²C and SMBus Subsystem

I2C bus protocol, Linux adapter·client driver model, SMBus 관계와 kernel API source를 설명합니다.

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

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

1. 요약·해설

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

요약과 해설

i2c.rst:1-48

I2C는 SCL·SDA 두 open-drain signal로 여러 master와 device를 연결합니다. Linux는 controller의 adapter driver와 device의 client driver를 분리하고, SMBus operation을 I2C primitive 또는 controller의 native command로 제공합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 I\ :sup:`2`\ C and SMBus Subsystem
2 ==================================
3
4 I\ :sup:`2`\ C (or without fancy typography, "I2C") is an acronym for
5 the "Inter-IC" bus, a simple bus protocol which is widely used where low
6 data rate communications suffice. Since it's also a licensed trademark,
7 some vendors use another name (such as "Two-Wire Interface", TWI) for
8 the same bus. I2C only needs two signals (SCL for clock, SDA for data),
9 conserving board real estate and minimizing signal quality issues. Most
10 I2C devices use seven bit addresses, and bus speeds of up to 400 kHz;
11 there's a high speed extension (3.4 MHz) that's not yet found wide use.
12 I2C is a multi-master bus; open drain signaling is used to arbitrate
13 between masters, as well as to handshake and to synchronize clocks from
14 slower clients.
15
16 The Linux I2C programming interfaces support the master side of bus
17 interactions and the slave side. The programming interface is
18 structured around two kinds of driver, and two kinds of device. An I2C
19 "Adapter Driver" abstracts the controller hardware; it binds to a
20 physical device (perhaps a PCI device or platform_device) and exposes a
21 :c:type:`struct i2c_adapter <i2c_adapter>` representing each
22 I2C bus segment it manages. On each I2C bus segment will be I2C devices
23 represented by a :c:type:`struct i2c_client <i2c_client>`.
24 Those devices will be bound to a :c:type:`struct i2c_driver
25 <i2c_driver>`, which should follow the standard Linux driver model. There
26 are functions to perform various I2C protocol operations; at this writing
27 all such functions are usable only from task context.
28
29 The System Management Bus (SMBus) is a sibling protocol. Most SMBus
30 systems are also I2C conformant. The electrical constraints are tighter
31 for SMBus, and it standardizes particular protocol messages and idioms.
32 Controllers that support I2C can also support most SMBus operations, but
33 SMBus controllers don't support all the protocol options that an I2C
34 controller will. There are functions to perform various SMBus protocol
35 operations, either using I2C primitives or by issuing SMBus commands to
36 i2c_adapter devices which don't support those I2C operations.
37
38 .. kernel-doc:: include/linux/i2c.h
39 :internal:
40
41 .. kernel-doc:: drivers/i2c/i2c-boardinfo.c
42 :functions: i2c_register_board_info
43
44 .. kernel-doc:: drivers/i2c/i2c-core-base.c
45 :export:
46
47 .. kernel-doc:: drivers/i2c/i2c-core-smbus.c
48 :export:
49

3. 한국어 전문 번역

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

I2C bus protocol

1-15

문서 제목은 `I²C and SMBus Subsystem`입니다. I2C는 Inter-IC bus의 약자로 낮은 data rate로 충분한 곳에서 널리 쓰이는 단순 bus protocol입니다. Licensed trademark이므로 일부 vendor는 같은 bus를 Two-Wire Interface(TWI) 같은 이름으로 부릅니다.

I2C에는 clock용 SCL과 data용 SDA 두 signal만 필요해 board area를 절약하고 signal-quality 문제를 줄입니다. 대부분 device는 7-bit address와 최대 400 kHz bus speed를 사용하며 3.4 MHz high-speed extension은 아직 널리 쓰이지 않습니다.

I2C는 multi-master bus입니다. Open-drain signaling으로 master 사이를 arbitration하고 handshake하며 느린 client의 clock과 동기화합니다.

I2C 핵심 특성
항목값·방식
SignalSCL clock + SDA data
일반 address7-bit
일반 speed최대 400 kHz
High-speed extension3.4 MHz
Bus ownershipMulti-master
ElectricalOpen drain arbitration·handshake·clock sync

Signal, address, speed, electrical arbitration을 정리했습니다.

Linux I2C driver model

16-28

Linux I2C programming interface는 bus interaction의 master side와 slave side를 모두 지원합니다. 구조는 driver 두 종류와 device 두 종류를 중심으로 합니다.

I2C Adapter Driver는 controller hardware를 추상화합니다. PCI device나 `platform_device` 같은 physical device에 bind하고, 관리하는 각 I2C bus segment를 나타내는 `struct i2c_adapter`를 노출합니다.

각 bus segment의 I2C device는 `struct i2c_client`로 표현되고 standard Linux driver model을 따르는 `struct i2c_driver`에 bind됩니다. 여러 I2C protocol operation function이 있으며 현재 모두 task context에서만 사용할 수 있습니다.

I2C driver model
PCI·platform controller deviceI2C Adapter Driverbus segment별 struct i2c_adapterdevice별 struct i2c_clientstruct i2c_driver bindTask context에서 protocol operation

Controller hardware에서 client driver까지의 object 관계입니다.

SMBus와 I2C의 관계

29-37

System Management Bus(SMBus)는 I2C의 sibling protocol이며 대부분 SMBus system은 I2C에도 부합합니다. SMBus는 electrical constraint가 더 엄격하고 특정 protocol message와 idiom을 표준화합니다.

I2C controller는 대부분 SMBus operation도 지원할 수 있지만 SMBus controller는 I2C controller의 모든 protocol option을 지원하지는 않습니다.

SMBus protocol operation function은 I2C primitive로 구현하거나, 필요한 I2C operation을 지원하지 않는 `i2c_adapter` device에 SMBus command를 직접 발행할 수 있습니다.

I2C와 SMBus
항목I2CSMBus
Electrical constraint일반더 엄격
Protocol다양한 option표준 message·idiom
Controller compatibility대부분 SMBus operation 지원모든 I2C option은 미지원
Operation 구현I2C primitiveI2C primitive 또는 SMBus command

Electrical·protocol capability와 fallback을 비교합니다.

I2C kernel API source

38-48

I2C internal API declaration은 `include/linux/i2c.h`에서 가져옵니다.

.. kernel-doc:: include/linux/i2c.h
   :internal:

Board-info registration API는 `drivers/i2c/i2c-boardinfo.c`의 `i2c_register_board_info`입니다.

.. kernel-doc:: drivers/i2c/i2c-boardinfo.c
   :functions: i2c_register_board_info

I2C core base의 exported API source는 `drivers/i2c/i2c-core-base.c`입니다.

.. kernel-doc:: drivers/i2c/i2c-core-base.c
   :export:

SMBus core의 exported API source는 `drivers/i2c/i2c-core-smbus.c`입니다.

.. kernel-doc:: drivers/i2c/i2c-core-smbus.c
   :export:
I2C kernel-doc source
영역Source path범위
Internal APIinclude/linux/i2c.hinternal
Board infodrivers/i2c/i2c-boardinfo.ci2c_register_board_info
Core basedrivers/i2c/i2c-core-base.cexport
SMBus coredrivers/i2c/i2c-core-smbus.cexport

Header·board-info·core·SMBus API source입니다.