요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
=====================
Kernel driver w1-gpio
=====================
Author: Ville Syrjala <[email protected]>
Description
-----------
GPIO 1-wire bus master driver. The driver uses the GPIO API to control the
wire and the GPIO pin can be specified using GPIO machine descriptor tables.
It is also possible to define the master using device tree, see
Documentation/devicetree/bindings/w1/w1-gpio.yaml
Example (mach-at91)
-------------------
::
#include <linux/gpio/machine.h>
#include <linux/w1-gpio.h>
static struct gpiod_lookup_table foo_w1_gpiod_table = {
.dev_id = "w1-gpio",
.table = {
GPIO_LOOKUP_IDX("at91-gpio", AT91_PIN_PB20, NULL, 0,
GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN),
},
};
static struct w1_gpio_platform_data foo_w1_gpio_pdata = {
.ext_pullup_enable_pin = -EINVAL,
};
static struct platform_device foo_w1_device = {
.name = "w1-gpio",
.id = -1,
.dev.platform_data = &foo_w1_gpio_pdata,
};
...
at91_set_GPIO_periph(foo_w1_gpio_pdata.pin, 1);
at91_set_multi_drive(foo_w1_gpio_pdata.pin, 1);
gpiod_add_lookup_table(&foo_w1_gpiod_table);
platform_device_register(&foo_w1_device);
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
GPIO 1-Wire master
1-15`w1-gpio`는 GPIO API로 single wire를 제어하는 1-Wire bus master driver이며 원 저자는 Ville Syrjala입니다.
GPIO pin은 machine descriptor table로 지정할 수 있고 device tree로도 master를 정의할 수 있습니다.
Device tree binding은 `Documentation/devicetree/bindings/w1/w1-gpio.yaml`을 참조합니다.
GPIO lookup과 DT 두 방식입니다.
=====================
Kernel driver w1-gpio
=====================
Author: Ville Syrjala <[email protected]>
Description
-----------
GPIO 1-wire bus master driver. The driver uses the GPIO API to control the
wire and the GPIO pin can be specified using GPIO machine descriptor tables.
It is also possible to define the master using device tree, see
Documentation/devicetree/bindings/w1/w1-gpio.yaml
mach-at91 descriptor 예제
16-47예제는 `foo_w1_gpiod_table`의 device ID를 `w1-gpio`로 두고 AT91 GPIO controller의 `AT91_PIN_PB20`을 index 0에 매핑합니다.
GPIO flag는 `GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN`으로 1-Wire에 필요한 open-drain 동작을 지정합니다.
`foo_w1_gpio_platform_data`는 external pull-up enable pin을 `-EINVAL`로 둡니다.
Platform device 이름은 `w1-gpio`, ID는 -1이며 platform data를 연결합니다.
초기화는 GPIO peripheral과 multi-drive를 활성화하고 lookup table을 등록한 뒤 platform device를 등록합니다. 원문 C code와 symbol은 해당 줄에 그대로 보존됩니다.
예제 구조체와 호출 책임입니다.
GPIO electrical mode부터 platform device까지의 순서입니다.
Example (mach-at91)
-------------------
::
#include <linux/gpio/machine.h>
#include <linux/w1-gpio.h>
static struct gpiod_lookup_table foo_w1_gpiod_table = {
.dev_id = "w1-gpio",
.table = {
GPIO_LOOKUP_IDX("at91-gpio", AT91_PIN_PB20, NULL, 0,
GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN),
},
};
static struct w1_gpio_platform_data foo_w1_gpio_pdata = {
.ext_pullup_enable_pin = -EINVAL,
};
static struct platform_device foo_w1_device = {
.name = "w1-gpio",
.id = -1,
.dev.platform_data = &foo_w1_gpio_pdata,
};
...
at91_set_GPIO_periph(foo_w1_gpio_pdata.pin, 1);
at91_set_multi_drive(foo_w1_gpio_pdata.pin, 1);
gpiod_add_lookup_table(&foo_w1_gpiod_table);
platform_device_register(&foo_w1_device);
요약·해설
w1-gpio.rst:1-47GPIO descriptor와 platform device를 사용한 1-Wire master 구성을 설명합니다.