요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
GPIO와 gpiochip attribute 구조
sysfs-gpio:16-37gpioN은 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 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
What: /sys/class/gpio/
Date: July 2008
KernelVersion: 2.6.27
Contact: Linus Walleij <linusw@kernel.org>
Description:
As a Kconfig option, individual GPIO signals may be accessed from
userspace. GPIOs are only made available to userspace by an explicit
"export" operation. If a given GPIO is not claimed for use by
kernel code, it may be exported by userspace (and unexported later).
Kernel code may export it for complete or partial access.
GPIOs are identified as they are inside the kernel, using integers in
the range 0..INT_MAX. See Documentation/admin-guide/gpio for more information.
::
/sys/class/gpio
/export ... asks the kernel to export a GPIO to userspace
/unexport ... to return a GPIO to the kernel
/gpioN ... for each exported GPIO #N OR
/value ... always readable, writes fail for input GPIOs
/direction ... r/w as: in, out (default low); write: high, low
/edge ... r/w as: none, falling, rising, both
/active_low ... r/w as: 0, 1
/gpiochipN ... for each gpiochip; #N is its first GPIO
/base ... (r/o) same as N
/label ... (r/o) descriptive chip name
/ngpio ... (r/o) number of GPIOs; numbered N to N + (ngpio - 1)
/gpio<OFFSET>
/value ... always readable, writes fail for input GPIOs
/direction ... r/w as: in, out (default low); write: high, low
/chipX ... for each gpiochip; #X is the gpio device ID
/export ... asks the kernel to export a GPIO at HW offset X to userspace
/unexport ... to return a GPIO at HW offset X to the kernel
/label ... (r/o) descriptive chip name
/ngpio ... (r/o) number of GPIOs exposed by the chip
This ABI is obsoleted by Documentation/ABI/testing/gpio-cdev and will be
removed after 2020.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
User-space GPIO export model
1-15| 항목 | 값 |
|---|---|
| What | /sys/class/gpio/ |
| Date | 2008년 7월 |
| KernelVersion | 2.6.27 |
| Contact | Linus Walleij <linusw@kernel.org> |
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-37global export, line별 gpioN, chip metadata인 gpiochipN, hardware offset export용 chipX를 구조화한 그림이다.
| 경로·attribute | access·허용값 | 의미 |
|---|---|---|
| /export | write | kernel에 GPIO export 요청 |
| /unexport | write | GPIO를 kernel에 반환 |
| /gpioN/value | read/write | 항상 읽을 수 있고 input GPIO에 대한 write는 실패 |
| /gpioN/direction | read/write: in, out, high, low | out 기본값은 low; high·low write로 output 상태 지정 |
| /gpioN/edge | read/write: none, falling, rising, both | event edge 선택 |
| /gpioN/active_low | read/write: 0, 1 | logical polarity 반전 |
| /gpiochipN/base | read-only | chip의 첫 GPIO 번호 N |
| /gpiochipN/label | read-only | chip 설명 이름 |
| /gpiochipN/ngpio | read-only | N부터 N+(ngpio-1)까지의 GPIO 수 |
| /gpiochipN/gpio<OFFSET>/value | read/write | chip offset line 값 |
| /gpiochipN/gpio<OFFSET>/direction | read/write | chip offset line 방향 |
| /chipX/export | write | hardware offset X의 GPIO export |
| /chipX/unexport | write | hardware offset X GPIO 반환 |
| /chipX/label | read-only | chip 설명 이름 |
| /chipX/ngpio | read-only | chip이 노출한 GPIO 수 |
gpio-cdev 대체
39-40이 sysfs ABI는 Documentation/ABI/testing/gpio-cdev에 정의된 GPIO character device ABI로 대체되었다. 2020년 이후 제거 대상으로 지정되었다.
명시적 export model
sysfs-gpio:1-15kernel code가 점유하지 않은 GPIO를 user space가 integer 번호로 export하고 나중에 unexport하는 legacy interface입니다.