← Documents Documentation/ABI/obsolete/sysfs-gpio GitHub 원문 ↗

Linux 6.18.37 · ABI / obsolete

GPIO sysfs obsolete ABI

GPIO export, value·direction·edge·active_low와 gpiochip metadata를 제공하던 sysfs ABI와 gpio-cdev 대체를 설명합니다.

Source pathDocumentation/ABI/obsolete/sysfs-gpio
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

명시적 export model

sysfs-gpio:1-15

kernel code가 점유하지 않은 GPIO를 user space가 integer 번호로 export하고 나중에 unexport하는 legacy interface입니다.

GPIO와 gpiochip attribute 구조

sysfs-gpio:16-37

gpioN은 line 상태와 edge를, gpiochipN은 chip base·label·line 수를, chipX는 hardware offset 기반 export를 제공합니다.

gpio-cdev로 대체

sysfs-gpio:39-40

이 ABI는 Documentation/ABI/testing/gpio-cdev로 대체되었고 2020년 이후 제거 대상으로 지정되었습니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 What: /sys/class/gpio/
2 Date: July 2008
3 KernelVersion: 2.6.27
4 Contact: Linus Walleij <[email protected]>
5 Description:
6
7 As a Kconfig option, individual GPIO signals may be accessed from
8 userspace. GPIOs are only made available to userspace by an explicit
9 "export" operation. If a given GPIO is not claimed for use by
10 kernel code, it may be exported by userspace (and unexported later).
11 Kernel code may export it for complete or partial access.
12
13 GPIOs are identified as they are inside the kernel, using integers in
14 the range 0..INT_MAX. See Documentation/admin-guide/gpio for more information.
15
16 ::
17
18 /sys/class/gpio
19 /export ... asks the kernel to export a GPIO to userspace
20 /unexport ... to return a GPIO to the kernel
21 /gpioN ... for each exported GPIO #N OR
22 /value ... always readable, writes fail for input GPIOs
23 /direction ... r/w as: in, out (default low); write: high, low
24 /edge ... r/w as: none, falling, rising, both
25 /active_low ... r/w as: 0, 1
26 /gpiochipN ... for each gpiochip; #N is its first GPIO
27 /base ... (r/o) same as N
28 /label ... (r/o) descriptive chip name
29 /ngpio ... (r/o) number of GPIOs; numbered N to N + (ngpio - 1)
30 /gpio<OFFSET>
31 /value ... always readable, writes fail for input GPIOs
32 /direction ... r/w as: in, out (default low); write: high, low
33 /chipX ... for each gpiochip; #X is the gpio device ID
34 /export ... asks the kernel to export a GPIO at HW offset X to userspace
35 /unexport ... to return a GPIO at HW offset X to the kernel
36 /label ... (r/o) descriptive chip name
37 /ngpio ... (r/o) number of GPIOs exposed by the chip
38
39 This ABI is obsoleted by Documentation/ABI/testing/gpio-cdev and will be
40 removed after 2020.
41

3. 한국어 전문 번역

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

User-space GPIO export model

1-15
항목
What/sys/class/gpio/
Date2008년 7월
KernelVersion2.6.27
ContactLinus Walleij <[email protected]>

Kconfig option으로 개별 GPIO signal을 user space에서 접근할 수 있게 한다. GPIO는 명시적인 export operation을 수행해야 user space에 나타난다.

kernel code가 사용한다고 claim하지 않은 GPIO는 user space가 export하고 나중에 unexport할 수 있다. kernel code가 GPIO를 완전 접근 또는 제한된 접근 형태로 export할 수도 있다.

GPIO는 kernel 내부와 마찬가지로 0부터 INT_MAX까지의 integer로 식별한다. 자세한 내용은 Documentation/admin-guide/gpio를 참조한다.

Sysfs directory와 attribute

16-37
/sys/class/gpio 구조
nodechild attribute의미
01 /sys/class/gpioexport / unexportGPIO를 user space에 내보내거나 kernel로 반환
02 gpioNvalue / direction / edge / active_lowexport된 global GPIO N 제어
03 gpiochipNbase / label / ngpio / gpio<OFFSET>N부터 시작하는 chip과 line metadata
04 chipXexport / unexport / label / ngpiogpio device ID X의 hardware offset 기반 export

global export, line별 gpioN, chip metadata인 gpiochipN, hardware offset export용 chipX를 구조화한 그림이다.

경로·attributeaccess·허용값의미
/exportwritekernel에 GPIO export 요청
/unexportwriteGPIO를 kernel에 반환
/gpioN/valueread/write항상 읽을 수 있고 input GPIO에 대한 write는 실패
/gpioN/directionread/write: in, out, high, lowout 기본값은 low; high·low write로 output 상태 지정
/gpioN/edgeread/write: none, falling, rising, bothevent edge 선택
/gpioN/active_lowread/write: 0, 1logical polarity 반전
/gpiochipN/baseread-onlychip의 첫 GPIO 번호 N
/gpiochipN/labelread-onlychip 설명 이름
/gpiochipN/ngpioread-onlyN부터 N+(ngpio-1)까지의 GPIO 수
/gpiochipN/gpio<OFFSET>/valueread/writechip offset line 값
/gpiochipN/gpio<OFFSET>/directionread/writechip offset line 방향
/chipX/exportwritehardware offset X의 GPIO export
/chipX/unexportwritehardware offset X GPIO 반환
/chipX/labelread-onlychip 설명 이름
/chipX/ngpioread-onlychip이 노출한 GPIO 수

gpio-cdev 대체

39-40

이 sysfs ABI는 Documentation/ABI/testing/gpio-cdev에 정의된 GPIO character device ABI로 대체되었다. 2020년 이후 제거 대상으로 지정되었다.