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

Linux 6.18.37 · I2C

I2C Address Translators

I2C ATR의 업스트림 별칭, 다운스트림 실제 주소 변환, 포트 선택, 드라이버 수명 주기를 설명합니다.

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

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

1. 요약·해설

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

요약·해설

i2c-address-translators.rst:1-96

ATR은 업스트림 별칭을 다운스트림 포트와 실제 슬레이브 주소로 변환하며, 드라이버는 별칭 풀을 관리하고 attach·detach 시 칩 설정과 할당 상태를 맞춥니다.

문서 개요
항목
SourceDocumentation/i2c/i2c-address-translators.rst
분량96 source lines
예제 자식 버스B, C
예제 별칭0x20, 0x30

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

핵심 흐름
자식 장치에 별칭 할당업스트림 요청 주소 재작성ATR 하드웨어가 포트·실제 주소 변환응답 주소를 원래 형태로 복원

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

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 =======================
4 I2C Address Translators
5 =======================
6
7 Author: Luca Ceresoli <[email protected]>
8 Author: Tomi Valkeinen <[email protected]>
9
10 Description
11 -----------
12
13 An I2C Address Translator (ATR) is a device with an I2C slave parent
14 ("upstream") port and N I2C master child ("downstream") ports, and
15 forwards transactions from upstream to the appropriate downstream port
16 with a modified slave address. The address used on the parent bus is
17 called the "alias" and is (potentially) different from the physical
18 slave address of the child bus. Address translation is done by the
19 hardware.
20
21 An ATR looks similar to an i2c-mux except:
22 - the address on the parent and child busses can be different
23 - there is normally no need to select the child port; the alias used on the
24 parent bus implies it
25
26 The ATR functionality can be provided by a chip with many other features.
27 The kernel i2c-atr provides a helper to implement an ATR within a driver.
28
29 The ATR creates a new I2C "child" adapter on each child bus. Adding
30 devices on the child bus ends up in invoking the driver code to select
31 an available alias. Maintaining an appropriate pool of available aliases
32 and picking one for each new device is up to the driver implementer. The
33 ATR maintains a table of currently assigned alias and uses it to modify
34 all I2C transactions directed to devices on the child buses.
35
36 A typical example follows.
37
38 Topology::
39
40 Slave X @ 0x10
41 .-----. |
42 .-----. | |---+---- B
43 | CPU |--A--| ATR |
44 `-----' | |---+---- C
45 `-----' |
46 Slave Y @ 0x10
47
48 Alias table:
49
50 A, B and C are three physical I2C busses, electrically independent from
51 each other. The ATR receives the transactions initiated on bus A and
52 propagates them on bus B or bus C or none depending on the device address
53 in the transaction and based on the alias table.
54
55 Alias table:
56
57 .. table::
58
59 =============== =====
60 Client Alias
61 =============== =====
62 X (bus B, 0x10) 0x20
63 Y (bus C, 0x10) 0x30
64 =============== =====
65
66 Transaction:
67
68 - Slave X driver requests a transaction (on adapter B), slave address 0x10
69 - ATR driver finds slave X is on bus B and has alias 0x20, rewrites
70 messages with address 0x20, forwards to adapter A
71 - Physical I2C transaction on bus A, slave address 0x20
72 - ATR chip detects transaction on address 0x20, finds it in table,
73 propagates transaction on bus B with address translated to 0x10,
74 keeps clock stretched on bus A waiting for reply
75 - Slave X chip (on bus B) detects transaction at its own physical
76 address 0x10 and replies normally
77 - ATR chip stops clock stretching and forwards reply on bus A,
78 with address translated back to 0x20
79 - ATR driver receives the reply, rewrites messages with address 0x10
80 as they were initially
81 - Slave X driver gets back the msgs[], with reply and address 0x10
82
83 Usage:
84
85 1. In the driver (typically in the probe function) add an ATR by
86 calling i2c_atr_new() passing attach/detach callbacks
87 2. When the attach callback is called pick an appropriate alias,
88 configure it in the chip and return the chosen alias in the
89 alias_id parameter
90 3. When the detach callback is called, deconfigure the alias from
91 the chip and put the alias back in the pool for later usage
92
93 I2C ATR functions and data structures
94 -------------------------------------
95
96 .. kernel-doc:: include/linux/i2c-atr.h
97

3. 한국어 전문 번역

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

I2C 주소 변환기 개요

1-35

이 문서는 GPL-2.0 라이선스로 제공되며 Luca Ceresoli와 Tomi Valkeinen이 작성했습니다.

I2C Address Translator(ATR)는 I2C 슬레이브 역할을 하는 하나의 부모 포트, 즉 업스트림 포트와 I2C 마스터 역할을 하는 N개의 자식 포트, 즉 다운스트림 포트를 가진 장치입니다. 업스트림에서 받은 트랜잭션의 슬레이브 주소를 바꾸어 적절한 다운스트림 포트로 전달합니다.

부모 버스에서 사용하는 주소를 별칭(alias)이라고 하며, 자식 버스 장치의 실제 슬레이브 주소와 다를 수 있습니다. 주소 변환은 하드웨어가 수행합니다.

ATR은 `i2c-mux`와 비슷해 보이지만 부모 버스와 자식 버스의 주소가 서로 다를 수 있고, 부모 버스에서 사용한 별칭 자체가 자식 포트를 암시하므로 보통 포트를 별도로 선택할 필요가 없습니다.

ATR 기능은 여러 다른 기능을 함께 가진 칩이 제공할 수도 있습니다. 커널의 `i2c-atr`은 드라이버 안에 ATR을 구현하기 위한 도우미를 제공합니다.

ATR은 자식 버스마다 새로운 I2C 자식 어댑터를 만듭니다. 자식 버스에 장치를 추가하면 드라이버 코드가 호출되어 사용 가능한 별칭을 선택합니다. 사용 가능한 별칭 풀을 관리하고 새 장치마다 별칭을 고르는 책임은 드라이버 구현자에게 있습니다.

ATR은 현재 할당된 별칭 표를 유지하며, 자식 버스의 장치로 향하는 모든 I2C 트랜잭션의 주소를 이 표에 따라 수정합니다.

ATR과 i2c-mux의 차이
항목ATRi2c-mux
부모·자식 주소서로 다를 수 있음일반적으로 동일
자식 포트 선택별칭이 포트를 암시포트를 명시적으로 선택
주소 변환하드웨어가 수행보통 수행하지 않음
커널 도우미`i2c-atr``i2c-mux`

포트 선택과 주소 처리 기준을 비교합니다.

자식 장치 등록
ATR이 자식 버스별 I2C 어댑터 생성자식 버스에 장치 추가드라이버 attach 콜백 호출사용 가능한 별칭 선택칩과 ATR 별칭 표에 등록

새 자식 장치가 별칭을 얻는 과정입니다.

.. SPDX-License-Identifier: GPL-2.0

=======================
I2C Address Translators
=======================

Author: Luca Ceresoli <[email protected]>
Author: Tomi Valkeinen <[email protected]>

Description
-----------

An I2C Address Translator (ATR) is a device with an I2C slave parent
("upstream") port and N I2C master child ("downstream") ports, and
forwards transactions from upstream to the appropriate downstream port
with a modified slave address. The address used on the parent bus is
called the "alias" and is (potentially) different from the physical
slave address of the child bus. Address translation is done by the
hardware.

An ATR looks similar to an i2c-mux except:
 - the address on the parent and child busses can be different
 - there is normally no need to select the child port; the alias used on the
   parent bus implies it

The ATR functionality can be provided by a chip with many other features.
The kernel i2c-atr provides a helper to implement an ATR within a driver.

The ATR creates a new I2C "child" adapter on each child bus. Adding
devices on the child bus ends up in invoking the driver code to select
an available alias. Maintaining an appropriate pool of available aliases
and picking one for each new device is up to the driver implementer. The
ATR maintains a table of currently assigned alias and uses it to modify
all I2C transactions directed to devices on the child buses.

토폴로지와 별칭 표

36-65

전형적인 구성에는 CPU가 연결된 물리 버스 A와 ATR 뒤의 서로 독립적인 물리 버스 B, C가 있습니다. 버스 B의 Slave X와 버스 C의 Slave Y는 모두 실제 주소 `0x10`을 사용하지만 전기적으로 분리되어 있으므로 충돌하지 않습니다.

ATR은 버스 A에서 시작된 트랜잭션을 받고 주소와 별칭 표에 따라 버스 B, 버스 C 또는 어느 쪽에도 전달하지 않습니다. X에는 별칭 `0x20`, Y에는 별칭 `0x30`이 배정되어 있으므로 업스트림 주소만으로 목적 포트와 실제 주소를 결정할 수 있습니다.

구조화된 ATR 토폴로지
업스트림변환기다운스트림장치
CPU → bus AATRbus BSlave X @ `0x10`
CPU → bus AATRbus CSlave Y @ `0x10`

원문의 ASCII 토폴로지를 동일한 연결 정보로 재구성합니다.

ATR 별칭 표
클라이언트실제 위치별칭
Xbus B, `0x10``0x20`
Ybus C, `0x10``0x30`

업스트림에서 보이는 주소와 다운스트림 실제 주소의 대응입니다.

별칭 기반 포트 선택
CPU가 bus A에서 별칭 전송ATR이 별칭 표 조회`0x20`이면 bus B와 실제 주소 `0x10` 선택`0x30`이면 bus C와 실제 주소 `0x10` 선택일치하지 않으면 어느 자식 버스에도 전달하지 않음

업스트림 주소가 목적 버스와 실제 주소를 함께 결정합니다.

A typical example follows.

Topology::

                      Slave X @ 0x10
              .-----.   |
  .-----.     |     |---+---- B
  | CPU |--A--| ATR |
  `-----'     |     |---+---- C
              `-----'   |
                      Slave Y @ 0x10

Alias table:

A, B and C are three physical I2C busses, electrically independent from
each other. The ATR receives the transactions initiated on bus A and
propagates them on bus B or bus C or none depending on the device address
in the transaction and based on the alias table.

Alias table:

.. table::

   ===============   =====
   Client            Alias
   ===============   =====
   X (bus B, 0x10)   0x20
   Y (bus C, 0x10)   0x30
   ===============   =====

주소 변환 트랜잭션과 사용법

66-92

Slave X 드라이버가 어댑터 B에서 실제 슬레이브 주소 `0x10`으로 트랜잭션을 요청합니다. ATR 드라이버는 X가 버스 B에 있고 별칭이 `0x20`임을 찾아 메시지 주소를 `0x20`으로 다시 쓴 뒤 어댑터 A에 전달합니다.

버스 A에서는 슬레이브 주소 `0x20`으로 물리 I2C 트랜잭션이 수행됩니다. ATR 칩은 `0x20` 트랜잭션을 감지해 별칭 표에서 찾고, 주소를 `0x10`으로 바꾸어 버스 B에 전달합니다. 이때 응답을 기다리는 동안 버스 A의 클록을 스트레칭합니다.

버스 B의 Slave X 칩은 자신의 실제 주소 `0x10`에 대한 트랜잭션을 감지하고 정상 응답합니다. ATR 칩은 클록 스트레칭을 멈추고 응답 주소를 다시 `0x20`으로 바꾸어 버스 A로 전달합니다.

ATR 드라이버는 응답을 받은 뒤 메시지 주소를 처음과 같은 `0x10`으로 복원합니다. Slave X 드라이버는 응답과 실제 주소 `0x10`이 담긴 원래 형태의 `msgs[]`를 돌려받습니다.

Slave X 왕복 트랜잭션
Slave X 드라이버: adapter B, address `0x10` 요청ATR 드라이버: `0x10` → alias `0x20`, adapter A로 전달bus A: address `0x20` 물리 전송ATR 칩: alias `0x20` → bus B, address `0x10`Slave X: address `0x10`으로 응답ATR 칩: 응답을 alias `0x20`으로 bus A에 전달ATR 드라이버: 메시지 주소를 `0x10`으로 복원Slave X 드라이버: 원래 주소와 응답 수신

요청과 응답에서 주소가 두 번씩 변환됩니다.

드라이버에서는 보통 probe 함수에서 attach·detach 콜백을 넘겨 `i2c_atr_new()`를 호출해 ATR을 추가합니다. attach 콜백이 호출되면 적절한 별칭을 선택해 칩에 설정하고 선택한 값을 `alias_id` 매개변수로 반환합니다.

detach 콜백이 호출되면 칩에서 해당 별칭 설정을 제거하고, 나중에 다시 쓸 수 있도록 별칭 풀에 반환합니다.

ATR 드라이버 수명 주기
시점드라이버 동작
probe`i2c_atr_new()`에 attach·detach 콜백 전달
attach별칭 선택, 칩에 설정, `alias_id`로 반환
동작 중ATR이 현재 별칭 표로 모든 주소 변환
detach칩 설정 제거, 별칭을 사용 가능 풀에 반환

별칭 할당과 반환 책임을 정리합니다.

Transaction:

 - Slave X driver requests a transaction (on adapter B), slave address 0x10
 - ATR driver finds slave X is on bus B and has alias 0x20, rewrites
   messages with address 0x20, forwards to adapter A
 - Physical I2C transaction on bus A, slave address 0x20
 - ATR chip detects transaction on address 0x20, finds it in table,
   propagates transaction on bus B with address translated to 0x10,
   keeps clock stretched on bus A waiting for reply
 - Slave X chip (on bus B) detects transaction at its own physical
   address 0x10 and replies normally
 - ATR chip stops clock stretching and forwards reply on bus A,
   with address translated back to 0x20
 - ATR driver receives the reply, rewrites messages with address 0x10
   as they were initially
 - Slave X driver gets back the msgs[], with reply and address 0x10

Usage:

 1. In the driver (typically in the probe function) add an ATR by
    calling i2c_atr_new() passing attach/detach callbacks
 2. When the attach callback is called pick an appropriate alias,
    configure it in the chip and return the chosen alias in the
    alias_id parameter
 3. When the detach callback is called, deconfigure the alias from
    the chip and put the alias back in the pool for later usage

I2C ATR 함수와 자료 구조

93-96

I2C ATR의 함수와 자료 구조에 대한 API 설명은 `include/linux/i2c-atr.h`의 kernel-doc에서 생성됩니다. 구현자는 이 헤더의 선언과 콜백 계약을 기준으로 드라이버를 작성해야 합니다.

ATR API 원본
지시문대상
`kernel-doc``include/linux/i2c-atr.h`

문서가 참조하는 커널 헤더입니다.

I2C ATR functions and data structures
-------------------------------------

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