← Documents Documentation/userspace-api/gpio/chardev_v1.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API

GPIO 문자 장치 사용자 공간 API(v1)

폐기 예정인 GPIO character-device ABI v1의 chip, line handle, line event 객체와 연산 및 자료형을 설명합니다.

Source pathDocumentation/userspace-api/gpio/chardev_v1.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

chardev_v1.rst:1-131

폐기 예정인 GPIO character-device ABI v1의 chip, line handle, line event 객체와 연산 및 자료형을 설명합니다.

원문의 문단, symbol, source path, ioctl 이름, 자료형, 표와 줄 좌표를 보존해 전문 번역했습니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ========================================
4 GPIO Character Device Userspace API (v1)
5 ========================================
6
7 .. warning::
8 This API is obsoleted by chardev.rst (v2).
9
10 New developments should use the v2 API, and existing developments are
11 encouraged to migrate as soon as possible, as this API will be removed
12 in the future. The v2 API is a functional superset of the v1 API so any
13 v1 call can be directly translated to a v2 equivalent.
14
15 This interface will continue to be maintained for the migration period,
16 but new features will only be added to the new API.
17
18 First added in 4.8.
19
20 The API is based around three major objects, the :ref:`gpio-v1-chip`, the
21 :ref:`gpio-v1-line-handle`, and the :ref:`gpio-v1-line-event`.
22
23 Where "line event" is used in this document it refers to the request that can
24 monitor a line for edge events, not the edge events themselves.
25
26 .. _gpio-v1-chip:
27
28 Chip
29 ====
30
31 The Chip represents a single GPIO chip and is exposed to userspace using device
32 files of the form ``/dev/gpiochipX``.
33
34 Each chip supports a number of GPIO lines,
35 :c:type:`chip.lines<gpiochip_info>`. Lines on the chip are identified by an
36 ``offset`` in the range from 0 to ``chip.lines - 1``, i.e. `[0,chip.lines)`.
37
38 Lines are requested from the chip using either gpio-get-linehandle-ioctl.rst
39 and the resulting line handle is used to access the GPIO chip's lines, or
40 gpio-get-lineevent-ioctl.rst and the resulting line event is used to monitor
41 a GPIO line for edge events.
42
43 Within this documentation, the file descriptor returned by calling `open()`
44 on the GPIO device file is referred to as ``chip_fd``.
45
46 Operations
47 ----------
48
49 The following operations may be performed on the chip:
50
51 .. toctree::
52 :titlesonly:
53
54 Get Line Handle <gpio-get-linehandle-ioctl>
55 Get Line Event <gpio-get-lineevent-ioctl>
56 Get Chip Info <gpio-get-chipinfo-ioctl>
57 Get Line Info <gpio-get-lineinfo-ioctl>
58 Watch Line Info <gpio-get-lineinfo-watch-ioctl>
59 Unwatch Line Info <gpio-get-lineinfo-unwatch-ioctl>
60 Read Line Info Changed Events <gpio-lineinfo-changed-read>
61
62 .. _gpio-v1-line-handle:
63
64 Line Handle
65 ===========
66
67 Line handles are created by gpio-get-linehandle-ioctl.rst and provide
68 access to a set of requested lines. The line handle is exposed to userspace
69 via the anonymous file descriptor returned in
70 :c:type:`request.fd<gpiohandle_request>` by gpio-get-linehandle-ioctl.rst.
71
72 Within this documentation, the line handle file descriptor is referred to
73 as ``handle_fd``.
74
75 Operations
76 ----------
77
78 The following operations may be performed on the line handle:
79
80 .. toctree::
81 :titlesonly:
82
83 Get Line Values <gpio-handle-get-line-values-ioctl>
84 Set Line Values <gpio-handle-set-line-values-ioctl>
85 Reconfigure Lines <gpio-handle-set-config-ioctl>
86
87 .. _gpio-v1-line-event:
88
89 Line Event
90 ==========
91
92 Line events are created by gpio-get-lineevent-ioctl.rst and provide
93 access to a requested line. The line event is exposed to userspace
94 via the anonymous file descriptor returned in
95 :c:type:`request.fd<gpioevent_request>` by gpio-get-lineevent-ioctl.rst.
96
97 Within this documentation, the line event file descriptor is referred to
98 as ``event_fd``.
99
100 Operations
101 ----------
102
103 The following operations may be performed on the line event:
104
105 .. toctree::
106 :titlesonly:
107
108 Get Line Value <gpio-handle-get-line-values-ioctl>
109 Read Line Edge Events <gpio-lineevent-data-read>
110
111 Types
112 =====
113
114 This section contains the structs that are referenced by the ABI v1.
115
116 The :c:type:`struct gpiochip_info<gpiochip_info>` is common to ABI v1 and v2.
117
118 .. kernel-doc:: include/uapi/linux/gpio.h
119 :identifiers:
120 gpioevent_data
121 gpioevent_request
122 gpiohandle_config
123 gpiohandle_data
124 gpiohandle_request
125 gpioline_info
126 gpioline_info_changed
127
128 .. toctree::
129 :hidden:
130
131 error-codes
132

3. 한국어 전문 번역

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

상태, 이행 지침, 핵심 객체

1-24

이 문서는 Linux 4.8에서 처음 추가된 GPIO character device ABI v1을 설명합니다. 이 API는 `chardev.rst`의 v2 API로 대체되었으며 향후 제거될 예정입니다. 새 개발은 v2를 사용해야 하고, 기존 v1 프로그램도 가능한 한 빨리 이전하는 것이 권장됩니다.

v2는 v1의 기능적 상위 집합이므로 모든 v1 호출을 대응하는 v2 호출로 직접 옮길 수 있습니다. 이전 기간에는 v1 인터페이스를 계속 유지하지만 새 기능은 v2에만 추가됩니다.

v1 ABI의 중심 객체는 `gpio-v1-chip`, `gpio-v1-line-handle`, `gpio-v1-line-event` 세 가지입니다. 이 문서에서 line event라는 말은 edge event 자체가 아니라 한 GPIO line의 edge event를 감시하도록 만든 요청 객체를 뜻합니다.

GPIO ABI v1 객체 관계
/dev/gpiochipXchip_fdGet Line Handlehandle_fd값 읽기/쓰기 및 재구성
/dev/gpiochipXchip_fdGet Line Eventevent_fd값 읽기 및 edge event 감시

Chip에서 line handle 또는 line event를 요청하고 반환된 익명 파일 디스크립터로 후속 연산을 수행합니다.

.. SPDX-License-Identifier: GPL-2.0

========================================
GPIO Character Device Userspace API (v1)
========================================

.. warning::
   This API is obsoleted by chardev.rst (v2).

   New developments should use the v2 API, and existing developments are
   encouraged to migrate as soon as possible, as this API will be removed
   in the future. The v2 API is a functional superset of the v1 API so any
   v1 call can be directly translated to a v2 equivalent.

   This interface will continue to be maintained for the migration period,
   but new features will only be added to the new API.

First added in 4.8.

The API is based around three major objects, the :ref:`gpio-v1-chip`, the
:ref:`gpio-v1-line-handle`, and the :ref:`gpio-v1-line-event`.

Where "line event" is used in this document it refers to the request that can
monitor a line for edge events, not the edge events themselves.

Chip과 chip_fd

25-60

Chip은 하나의 GPIO chip을 나타내며 `/dev/gpiochipX` 형식의 장치 파일로 사용자 공간에 노출됩니다. 각 chip은 `gpiochip_info`의 `chip.lines`만큼 GPIO line을 제공하고, 각 line은 0부터 `chip.lines - 1`까지의 `offset`, 즉 반열린 구간 `[0, chip.lines)`로 식별됩니다.

`gpio-get-linehandle-ioctl.rst`로 line을 요청하면 GPIO line에 접근하는 line handle이 만들어집니다. `gpio-get-lineevent-ioctl.rst`로 요청하면 한 line의 edge event를 감시하는 line event가 만들어집니다. GPIO 장치 파일에 `open()`을 호출해 얻은 파일 디스크립터는 이 문서에서 `chip_fd`라고 부릅니다.

Chip에는 line handle 요청, line event 요청, chip 정보 조회, line 정보 조회, line 정보 변경 감시 시작과 해제, line 정보 변경 이벤트 읽기 연산을 수행할 수 있습니다.

v1 Chip 연산
항목설명
Get Line Handlegpio-get-linehandle-ioctl
Get Line Eventgpio-get-lineevent-ioctl
Get Chip Infogpio-get-chipinfo-ioctl
Get Line Infogpio-get-lineinfo-ioctl
Watch Line Infogpio-get-lineinfo-watch-ioctl
Unwatch Line Infogpio-get-lineinfo-unwatch-ioctl
Read Line Info Changed Eventsgpio-lineinfo-changed-read

각 항목은 원문의 toctree가 연결하는 세부 ABI 문서입니다.


.. _gpio-v1-chip:

Chip
====

The Chip represents a single GPIO chip and is exposed to userspace using device
files of the form ``/dev/gpiochipX``.

Each chip supports a number of GPIO lines,
:c:type:`chip.lines<gpiochip_info>`. Lines on the chip are identified by an
``offset`` in the range from 0 to ``chip.lines - 1``, i.e. `[0,chip.lines)`.

Lines are requested from the chip using either gpio-get-linehandle-ioctl.rst
and the resulting line handle is used to access the GPIO chip's lines, or
gpio-get-lineevent-ioctl.rst and the resulting line event is used to monitor
a GPIO line for edge events.

Within this documentation, the file descriptor returned by calling `open()`
on the GPIO device file is referred to as ``chip_fd``.

Operations
----------

The following operations may be performed on the chip:

.. toctree::
   :titlesonly:

   Get Line Handle <gpio-get-linehandle-ioctl>
   Get Line Event <gpio-get-lineevent-ioctl>
   Get Chip Info <gpio-get-chipinfo-ioctl>
   Get Line Info <gpio-get-lineinfo-ioctl>
   Watch Line Info <gpio-get-lineinfo-watch-ioctl>
   Unwatch Line Info <gpio-get-lineinfo-unwatch-ioctl>
   Read Line Info Changed Events <gpio-lineinfo-changed-read>

Line Handle과 handle_fd

61-85

Line handle은 `gpio-get-linehandle-ioctl.rst`로 만들며 요청한 line 집합에 접근할 수 있게 합니다. ioctl이 `gpiohandle_request`의 `request.fd`에 반환하는 익명 파일 디스크립터로 사용자 공간에 노출되고, 이 문서에서는 이를 `handle_fd`라고 부릅니다.

Line handle에서는 요청한 line 값 읽기, line 값 쓰기, line 재구성 연산을 수행할 수 있습니다.

v1 Line Handle 연산
항목설명
Get Line Valuesgpio-handle-get-line-values-ioctl
Set Line Valuesgpio-handle-set-line-values-ioctl
Reconfigure Linesgpio-handle-set-config-ioctl

handle_fd에 적용되는 세부 요청입니다.


.. _gpio-v1-line-handle:

Line Handle
===========

Line handles are created by gpio-get-linehandle-ioctl.rst and provide
access to a set of requested lines.  The line handle is exposed to userspace
via the anonymous file descriptor returned  in
:c:type:`request.fd<gpiohandle_request>` by gpio-get-linehandle-ioctl.rst.

Within this documentation, the line handle file descriptor is referred to
as ``handle_fd``.

Operations
----------

The following operations may be performed on the line handle:

.. toctree::
   :titlesonly:

   Get Line Values <gpio-handle-get-line-values-ioctl>
   Set Line Values <gpio-handle-set-line-values-ioctl>
   Reconfigure Lines <gpio-handle-set-config-ioctl>

Line Event와 event_fd

86-110

Line event는 `gpio-get-lineevent-ioctl.rst`로 만들며 요청한 단일 line에 접근합니다. ioctl이 `gpioevent_request`의 `request.fd`에 반환하는 익명 파일 디스크립터로 사용자 공간에 노출되고, 이 문서에서는 이를 `event_fd`라고 부릅니다.

Line event에서는 현재 line 값을 가져오거나 line의 edge event를 읽을 수 있습니다.

v1 Line Event 연산
항목설명
Get Line Valuegpio-handle-get-line-values-ioctl
Read Line Edge Eventsgpio-lineevent-data-read

event_fd에 적용되는 세부 요청입니다.


.. _gpio-v1-line-event:

Line Event
==========

Line events are created by gpio-get-lineevent-ioctl.rst and provide
access to a requested line.  The line event is exposed to userspace
via the anonymous file descriptor returned  in
:c:type:`request.fd<gpioevent_request>` by gpio-get-lineevent-ioctl.rst.

Within this documentation, the line event file descriptor is referred to
as ``event_fd``.

Operations
----------

The following operations may be performed on the line event:

.. toctree::
   :titlesonly:

   Get Line Value <gpio-handle-get-line-values-ioctl>
   Read Line Edge Events <gpio-lineevent-data-read>

ABI v1 자료형

111-131

이 절은 ABI v1이 참조하는 구조체를 `include/uapi/linux/gpio.h`의 kernel-doc에서 가져옵니다. `gpiochip_info` 구조체는 ABI v1과 v2가 함께 사용합니다.

v1 전용 식별자는 `gpioevent_data`, `gpioevent_request`, `gpiohandle_config`, `gpiohandle_data`, `gpiohandle_request`, `gpioline_info`, `gpioline_info_changed`입니다. 숨은 toctree 항목으로 공통 `error-codes` 문서를 연결합니다.

ABI v1 kernel-doc 식별자
항목설명
gpioevent_data수신한 edge event 데이터
gpioevent_request단일 line event 요청
gpiohandle_configline handle 재구성
gpiohandle_dataline 값 배열
gpiohandle_requestline handle 생성 요청
gpioline_infoline 정보
gpioline_info_changedline 정보 변경 이벤트
gpiochip_infov1과 v2가 공유하는 chip 정보

구조체 이름과 주 용도를 정리했습니다.

Types
=====

This section contains the structs that are referenced by the ABI v1.

The :c:type:`struct gpiochip_info<gpiochip_info>` is common to ABI v1 and v2.

.. kernel-doc:: include/uapi/linux/gpio.h
   :identifiers:
    gpioevent_data
    gpioevent_request
    gpiohandle_config
    gpiohandle_data
    gpiohandle_request
    gpioline_info
    gpioline_info_changed

.. toctree::
   :hidden:

   error-codes