요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
==========================
Kernel driver i2c-mux-gpio
==========================
Author: Peter Korsgaard <[email protected]>
Description
-----------
i2c-mux-gpio is an i2c mux driver providing access to I2C bus segments
from a master I2C bus and a hardware MUX controlled through GPIO pins.
E.G.::
---------- ---------- Bus segment 1 - - - - -
| | SCL/SDA | |-------------- | |
| |------------| |
| | | | Bus segment 2 | |
| Linux | GPIO 1..N | MUX |--------------- Devices
| |------------| | | |
| | | | Bus segment M
| | | |---------------| |
---------- ---------- - - - - -
SCL/SDA of the master I2C bus is multiplexed to bus segment 1..M
according to the settings of the GPIO pins 1..N.
Usage
-----
i2c-mux-gpio uses the platform bus, so you need to provide a struct
platform_device with the platform_data pointing to a struct
i2c_mux_gpio_platform_data with the I2C adapter number of the master
bus, the number of bus segments to create and the GPIO pins used
to control it. See include/linux/platform_data/i2c-mux-gpio.h for details.
E.G. something like this for a MUX providing 4 bus segments
controlled through 3 GPIO pins::
#include <linux/platform_data/i2c-mux-gpio.h>
#include <linux/platform_device.h>
static const unsigned myboard_gpiomux_gpios[] = {
AT91_PIN_PC26, AT91_PIN_PC25, AT91_PIN_PC24
};
static const unsigned myboard_gpiomux_values[] = {
0, 1, 2, 3
};
static struct i2c_mux_gpio_platform_data myboard_i2cmux_data = {
.parent = 1,
.base_nr = 2, /* optional */
.values = myboard_gpiomux_values,
.n_values = ARRAY_SIZE(myboard_gpiomux_values),
.gpios = myboard_gpiomux_gpios,
.n_gpios = ARRAY_SIZE(myboard_gpiomux_gpios),
.idle = 4, /* optional */
};
static struct platform_device myboard_i2cmux = {
.name = "i2c-mux-gpio",
.id = 0,
.dev = {
.platform_data = &myboard_i2cmux_data,
},
};
If you don't know the absolute GPIO pin numbers at registration time,
you can instead provide a chip name (.chip_name) and relative GPIO pin
numbers, and the i2c-mux-gpio driver will do the work for you,
including deferred probing if the GPIO chip isn't immediately
available.
Device Registration
-------------------
When registering your i2c-mux-gpio device, you should pass the number
of any GPIO pin it uses as the device ID. This guarantees that every
instance has a different ID.
Alternatively, if you don't need a stable device name, you can simply
pass PLATFORM_DEVID_AUTO as the device ID, and the platform core will
assign a dynamic ID to your device. If you do not know the absolute
GPIO pin numbers at registration time, this is even the only option.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
GPIO로 제어하는 I2C mux
1-27이 문서는 Peter Korsgaard가 작성했습니다. `i2c-mux-gpio`는 마스터 I2C 버스와 GPIO 핀으로 제어되는 하드웨어 mux를 통해 여러 I2C 버스 세그먼트에 접근하게 하는 I2C mux 드라이버입니다.
마스터 I2C 버스의 SCL/SDA 선은 GPIO 1부터 N의 설정에 따라 버스 세그먼트 1부터 M 가운데 하나로 연결됩니다.
원문의 ASCII 연결도를 동일한 신호 관계로 재구성합니다.
제어 GPIO 조합으로 마스터 신호가 한 세그먼트에 연결됩니다.
==========================
Kernel driver i2c-mux-gpio
==========================
Author: Peter Korsgaard <[email protected]>
Description
-----------
i2c-mux-gpio is an i2c mux driver providing access to I2C bus segments
from a master I2C bus and a hardware MUX controlled through GPIO pins.
E.G.::
---------- ---------- Bus segment 1 - - - - -
| | SCL/SDA | |-------------- | |
| |------------| |
| | | | Bus segment 2 | |
| Linux | GPIO 1..N | MUX |--------------- Devices
| |------------| | | |
| | | | Bus segment M
| | | |---------------| |
---------- ---------- - - - - -
SCL/SDA of the master I2C bus is multiplexed to bus segment 1..M
according to the settings of the GPIO pins 1..N.
platform_data 구성과 지연 probe
28-73`i2c-mux-gpio`는 platform bus를 사용합니다. 따라서 `platform_data`가 `struct i2c_mux_gpio_platform_data`를 가리키는 `struct platform_device`를 제공해야 합니다.
platform data에는 마스터 버스의 I2C 어댑터 번호, 생성할 버스 세그먼트 수, mux 제어에 사용할 GPIO 핀을 지정합니다. 자세한 내용은 `include/linux/platform_data/i2c-mux-gpio.h`를 참조합니다.
예제는 GPIO 3개로 버스 세그먼트 4개를 제공하는 mux를 구성합니다. `myboard_gpiomux_gpios`에는 `AT91_PIN_PC26`, `AT91_PIN_PC25`, `AT91_PIN_PC24`를 넣고, 채널 값 배열에는 `0`, `1`, `2`, `3`을 넣습니다.
`myboard_i2cmux_data`의 `.parent = 1`은 마스터 I2C 어댑터를 지정합니다. 선택 사항인 `.base_nr = 2`는 자식 버스 번호의 시작값, `.idle = 4`는 유휴 상태 값을 지정합니다. `values`와 `gpios` 배열 및 각 개수도 연결합니다.
platform device 이름은 `i2c-mux-gpio`, ID는 예제에서 0이며 `.dev.platform_data`가 위 설정 구조체를 가리킵니다.
예제 필드와 설정값을 정리합니다.
등록 시점에 절대 GPIO 핀 번호를 모른다면 `.chip_name`과 상대 GPIO 핀 번호를 대신 제공할 수 있습니다. `i2c-mux-gpio` 드라이버가 GPIO 칩을 찾아 연결하며, GPIO 칩을 즉시 사용할 수 없으면 지연 probe도 처리합니다.
마스터와 GPIO 선택표를 platform_data로 묶습니다.
Usage
-----
i2c-mux-gpio uses the platform bus, so you need to provide a struct
platform_device with the platform_data pointing to a struct
i2c_mux_gpio_platform_data with the I2C adapter number of the master
bus, the number of bus segments to create and the GPIO pins used
to control it. See include/linux/platform_data/i2c-mux-gpio.h for details.
E.G. something like this for a MUX providing 4 bus segments
controlled through 3 GPIO pins::
#include <linux/platform_data/i2c-mux-gpio.h>
#include <linux/platform_device.h>
static const unsigned myboard_gpiomux_gpios[] = {
AT91_PIN_PC26, AT91_PIN_PC25, AT91_PIN_PC24
};
static const unsigned myboard_gpiomux_values[] = {
0, 1, 2, 3
};
static struct i2c_mux_gpio_platform_data myboard_i2cmux_data = {
.parent = 1,
.base_nr = 2, /* optional */
.values = myboard_gpiomux_values,
.n_values = ARRAY_SIZE(myboard_gpiomux_values),
.gpios = myboard_gpiomux_gpios,
.n_gpios = ARRAY_SIZE(myboard_gpiomux_gpios),
.idle = 4, /* optional */
};
static struct platform_device myboard_i2cmux = {
.name = "i2c-mux-gpio",
.id = 0,
.dev = {
.platform_data = &myboard_i2cmux_data,
},
};
If you don't know the absolute GPIO pin numbers at registration time,
you can instead provide a chip name (.chip_name) and relative GPIO pin
numbers, and the i2c-mux-gpio driver will do the work for you,
including deferred probing if the GPIO chip isn't immediately
available.
platform device ID 선택
74-85`i2c-mux-gpio` 장치를 등록할 때는 사용하는 GPIO 핀 중 하나의 번호를 장치 ID로 전달하는 것이 좋습니다. 그러면 각 인스턴스가 서로 다른 ID를 갖게 됩니다.
안정적인 장치 이름이 필요 없다면 장치 ID로 `PLATFORM_DEVID_AUTO`를 전달할 수 있습니다. platform core가 동적 ID를 할당합니다.
등록 시점에 절대 GPIO 핀 번호를 모르는 경우에는 `PLATFORM_DEVID_AUTO`가 유일한 선택입니다.
GPIO 번호 기반 고정 ID와 자동 ID를 비교합니다.
Device Registration
-------------------
When registering your i2c-mux-gpio device, you should pass the number
of any GPIO pin it uses as the device ID. This guarantees that every
instance has a different ID.
Alternatively, if you don't need a stable device name, you can simply
pass PLATFORM_DEVID_AUTO as the device ID, and the platform core will
assign a dynamic ID to your device. If you do not know the absolute
GPIO pin numbers at registration time, this is even the only option.
요약·해설
i2c-mux-gpio.rst:1-85i2c-mux-gpio는 GPIO 조합으로 하드웨어 mux 채널을 선택해 하나의 마스터 SCL/SDA를 여러 논리 버스로 확장하며, platform_data가 부모 어댑터와 GPIO·채널 매핑을 정의합니다.
원문 분량과 핵심 검토 대상을 요약합니다.
문서의 주요 생성·구성 순서를 압축합니다.