← Documents Documentation/iio/iio_configfs.rst GitHub 원문 ↗

Linux 6.18.37 · IIO

Industrial IIO configfs support

IIO configfs 마운트, software trigger 유형 구현과 hrtimer 인스턴스 생성·삭제를 설명합니다.

Source pathDocumentation/iio/iio_configfs.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

iio_configfs.rst:1-102

IIO configfs는 `/config/iio` 아래에서 trigger 같은 커널 객체를 구성합니다. Software trigger 모듈은 probe·remove 연산과 유형 객체를 등록하며, hrtimer 인스턴스는 디렉터리 생성·삭제로 수명 주기를 제어합니다.

문서 개요
항목내용
SourceDocumentation/iio/iio_configfs.rst
분량102 source lines
Kernel optionCONFIG_IIO_CONFIGFS
Trigger path/config/iio/triggers

원문 분량과 핵심 인터페이스를 요약합니다.

핵심 흐름
Configfs 마운트Software trigger type 등록유형 디렉터리 생성Hrtimer instance 생성Sampling frequency 설정 후 삭제

구성과 데이터 처리 순서를 압축합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ===============================
2 Industrial IIO configfs support
3 ===============================
4
5 1. Overview
6 ===========
7
8 Configfs is a filesystem-based manager of kernel objects. IIO uses some
9 objects that could be easily configured using configfs (e.g.: devices,
10 triggers).
11
12 See Documentation/filesystems/configfs.rst for more information
13 about how configfs works.
14
15 2. Usage
16 ========
17
18 In order to use configfs support in IIO we need to select it at compile
19 time via CONFIG_IIO_CONFIGFS config option.
20
21 Then, mount the configfs filesystem (usually under /config directory)::
22
23 $ mkdir /config
24 $ mount -t configfs none /config
25
26 At this point, all default IIO groups will be created and can be accessed
27 under /config/iio. Next chapters will describe available IIO configuration
28 objects.
29
30 3. Software triggers
31 ====================
32
33 One of the IIO default configfs groups is the "triggers" group. It is
34 automagically accessible when the configfs is mounted and can be found
35 under /config/iio/triggers.
36
37 IIO software triggers implementation offers support for creating multiple
38 trigger types. A new trigger type is usually implemented as a separate
39 kernel module following the interface in include/linux/iio/sw_trigger.h::
40
41 /*
42 * drivers/iio/trigger/iio-trig-sample.c
43 * sample kernel module implementing a new trigger type
44 */
45 #include <linux/iio/sw_trigger.h>
46
47
48 static struct iio_sw_trigger *iio_trig_sample_probe(const char *name)
49 {
50 /*
51 * This allocates and registers an IIO trigger plus other
52 * trigger type specific initialization.
53 */
54 }
55
56 static int iio_trig_sample_remove(struct iio_sw_trigger *swt)
57 {
58 /*
59 * This undoes the actions in iio_trig_sample_probe
60 */
61 }
62
63 static const struct iio_sw_trigger_ops iio_trig_sample_ops = {
64 .probe = iio_trig_sample_probe,
65 .remove = iio_trig_sample_remove,
66 };
67
68 static struct iio_sw_trigger_type iio_trig_sample = {
69 .name = "trig-sample",
70 .owner = THIS_MODULE,
71 .ops = &iio_trig_sample_ops,
72 };
73
74 module_iio_sw_trigger_driver(iio_trig_sample);
75
76 Each trigger type has its own directory under /config/iio/triggers. Loading
77 iio-trig-sample module will create 'trig-sample' trigger type directory
78 /config/iio/triggers/trig-sample.
79
80 We support the following interrupt sources (trigger types):
81
82 * hrtimer, uses high resolution timers as interrupt source
83
84 3.1 Hrtimer triggers creation and destruction
85 ---------------------------------------------
86
87 Loading iio-trig-hrtimer module will register hrtimer trigger types allowing
88 users to create hrtimer triggers under /config/iio/triggers/hrtimer.
89
90 e.g::
91
92 $ mkdir /config/iio/triggers/hrtimer/instance1
93 $ rmdir /config/iio/triggers/hrtimer/instance1
94
95 Each trigger can have one or more attributes specific to the trigger type.
96
97 3.2 "hrtimer" trigger types attributes
98 --------------------------------------
99
100 "hrtimer" trigger type doesn't have any configurable attribute from /config dir.
101 It does introduce the sampling_frequency attribute to trigger directory.
102 That attribute sets the polling frequency in Hz, with mHz precision.
103

3. 한국어 전문 번역

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

IIO configfs 개요와 마운트

1-29

Configfs는 파일시스템 기반의 커널 객체 관리자입니다. IIO가 사용하는 장치나 trigger 같은 객체는 configfs를 이용해 쉽게 구성할 수 있습니다.

Configfs의 동작 방식에 대한 자세한 내용은 `Documentation/filesystems/configfs.rst`를 참고합니다.

IIO에서 configfs 지원을 사용하려면 컴파일 시 `CONFIG_IIO_CONFIGFS` 구성 옵션을 선택해야 합니다.

그다음 보통 `/config` 디렉터리에 configfs 파일시스템을 마운트합니다.

$ mkdir /config
$ mount -t configfs none /config

마운트가 끝나면 모든 기본 IIO 그룹이 생성되어 `/config/iio` 아래에서 접근할 수 있습니다. 이어지는 절에서 사용 가능한 IIO 구성 객체를 설명합니다.

IIO configfs 활성화
`CONFIG_IIO_CONFIGFS` 선택커널 빌드와 부팅`/config` 디렉터리 생성Configfs를 `/config`에 마운트`/config/iio`의 기본 그룹 접근

커널 설정부터 기본 IIO 그룹 접근까지의 순서입니다.

IIO configfs 기본 경로
항목
Kernel option`CONFIG_IIO_CONFIGFS`
일반 mount point`/config`
IIO root group`/config/iio`
Configfs 설명`Documentation/filesystems/configfs.rst`

설정 단계와 생성되는 경로를 정리했습니다.

===============================
Industrial IIO configfs support
===============================

1. Overview
===========

Configfs is a filesystem-based manager of kernel objects. IIO uses some
objects that could be easily configured using configfs (e.g.: devices,
triggers).

See Documentation/filesystems/configfs.rst for more information
about how configfs works.

2. Usage
========

In order to use configfs support in IIO we need to select it at compile
time via CONFIG_IIO_CONFIGFS config option.

Then, mount the configfs filesystem (usually under /config directory)::

  $ mkdir /config
  $ mount -t configfs none /config

At this point, all default IIO groups will be created and can be accessed
under /config/iio. Next chapters will describe available IIO configuration
objects.

Software trigger 유형 구현

30-79

IIO의 기본 configfs 그룹 가운데 하나는 `triggers` 그룹입니다. Configfs를 마운트하면 자동으로 접근할 수 있으며 경로는 `/config/iio/triggers`입니다.

IIO software trigger 구현은 여러 trigger 유형을 만들 수 있도록 지원합니다. 새 trigger 유형은 보통 `include/linux/iio/sw_trigger.h`의 인터페이스를 따르는 별도 커널 모듈로 구현합니다.

원문 예제의 `drivers/iio/trigger/iio-trig-sample.c` 모듈은 `probe`에서 IIO trigger를 할당·등록하고 유형별 초기화를 수행하며, `remove`에서 해당 동작을 되돌립니다.

static struct iio_sw_trigger *iio_trig_sample_probe(const char *name)
{
        /* Allocate and register an IIO trigger, then initialize it. */
}

static int iio_trig_sample_remove(struct iio_sw_trigger *swt)
{
        /* Undo iio_trig_sample_probe(). */
}

두 함수는 `struct iio_sw_trigger_ops`의 `.probe`와 `.remove`에 연결됩니다. Trigger 유형 객체에는 이름 `trig-sample`, 소유자 `THIS_MODULE`, 연산 집합을 넣고 `module_iio_sw_trigger_driver(iio_trig_sample)`로 등록합니다.

static const struct iio_sw_trigger_ops iio_trig_sample_ops = {
        .probe  = iio_trig_sample_probe,
        .remove = iio_trig_sample_remove,
};

static struct iio_sw_trigger_type iio_trig_sample = {
        .name = "trig-sample",
        .owner = THIS_MODULE,
        .ops = &iio_trig_sample_ops,
};

module_iio_sw_trigger_driver(iio_trig_sample);

각 trigger 유형은 `/config/iio/triggers` 아래에 자체 디렉터리를 가집니다. `iio-trig-sample` 모듈을 로드하면 `trig-sample` 유형 디렉터리 `/config/iio/triggers/trig-sample`이 생성됩니다.

Software trigger 구현 요소
요소역할
`iio_trig_sample_probe()`Trigger 할당·등록과 유형별 초기화
`iio_trig_sample_remove()`Probe 동작 취소
`iio_sw_trigger_ops`Probe와 remove callback 연결
`iio_sw_trigger_type`이름·owner·ops 정의
`module_iio_sw_trigger_driver()`Trigger type module 등록

샘플 모듈의 객체와 역할을 구조화했습니다.

Trigger type 등록
`sw_trigger.h` 인터페이스 구현Probe·remove callback 연결`iio_sw_trigger_type` 정의Module macro로 유형 등록`/config/iio/triggers/<type>` 생성

커널 모듈에서 configfs 디렉터리가 생기는 과정입니다.

3. Software triggers
====================

One of the IIO default configfs groups is the "triggers" group. It is
automagically accessible when the configfs is mounted and can be found
under /config/iio/triggers.

IIO software triggers implementation offers support for creating multiple
trigger types. A new trigger type is usually implemented as a separate
kernel module following the interface in include/linux/iio/sw_trigger.h::

  /*
   * drivers/iio/trigger/iio-trig-sample.c
   * sample kernel module implementing a new trigger type
   */
  #include <linux/iio/sw_trigger.h>


  static struct iio_sw_trigger *iio_trig_sample_probe(const char *name)
  {
        /*
         * This allocates and registers an IIO trigger plus other
         * trigger type specific initialization.
         */
  }

  static int iio_trig_sample_remove(struct iio_sw_trigger *swt)
  {
        /*
         * This undoes the actions in iio_trig_sample_probe
         */
  }

  static const struct iio_sw_trigger_ops iio_trig_sample_ops = {
        .probe                = iio_trig_sample_probe,
        .remove                = iio_trig_sample_remove,
  };

  static struct iio_sw_trigger_type iio_trig_sample = {
        .name = "trig-sample",
        .owner = THIS_MODULE,
        .ops = &iio_trig_sample_ops,
  };

  module_iio_sw_trigger_driver(iio_trig_sample);

Each trigger type has its own directory under /config/iio/triggers. Loading
iio-trig-sample module will create 'trig-sample' trigger type directory
/config/iio/triggers/trig-sample.

Hrtimer trigger 생성·삭제와 속성

80-102

지원하는 interrupt source, 즉 trigger 유형에는 고해상도 timer를 interrupt source로 사용하는 `hrtimer`가 있습니다.

`iio-trig-hrtimer` 모듈을 로드하면 hrtimer trigger 유형이 등록되어 사용자가 `/config/iio/triggers/hrtimer` 아래에서 hrtimer trigger를 만들 수 있습니다.

예제는 `instance1` 디렉터리를 만들어 trigger 인스턴스를 생성하고 디렉터리를 제거해 인스턴스를 삭제합니다.

$ mkdir /config/iio/triggers/hrtimer/instance1
$ rmdir /config/iio/triggers/hrtimer/instance1

각 trigger에는 유형에 따라 하나 이상의 전용 속성이 있을 수 있습니다.

`hrtimer` trigger 유형은 `/config` 디렉터리에서 설정할 수 있는 속성을 제공하지 않습니다. 대신 trigger 디렉터리에 `sampling_frequency` 속성을 추가합니다. 이 속성은 mHz 정밀도로 polling frequency를 Hz 단위로 설정합니다.

Hrtimer trigger 인터페이스
동작경로·속성효과
생성`mkdir .../hrtimer/instance1`Hrtimer trigger 인스턴스 생성
삭제`rmdir .../hrtimer/instance1`Trigger 인스턴스 제거
주파수`sampling_frequency`Hz 단위, mHz 정밀도 polling 설정

인스턴스 수명 주기와 주파수 속성을 정리했습니다.

Hrtimer trigger 수명 주기
`iio-trig-hrtimer` 모듈 로드Hrtimer trigger type 등록Configfs 디렉터리 생성으로 인스턴스 추가`sampling_frequency` 설정디렉터리 제거로 인스턴스 삭제

모듈 로드부터 인스턴스 제거까지의 흐름입니다.

We support the following interrupt sources (trigger types):

        * hrtimer, uses high resolution timers as interrupt source

3.1 Hrtimer triggers creation and destruction
---------------------------------------------

Loading iio-trig-hrtimer module will register hrtimer trigger types allowing
users to create hrtimer triggers under /config/iio/triggers/hrtimer.

e.g::

  $ mkdir /config/iio/triggers/hrtimer/instance1
  $ rmdir /config/iio/triggers/hrtimer/instance1

Each trigger can have one or more attributes specific to the trigger type.

3.2 "hrtimer" trigger types attributes
--------------------------------------

"hrtimer" trigger type doesn't have any configurable attribute from /config dir.
It does introduce the sampling_frequency attribute to trigger directory.
That attribute sets the polling frequency in Hz, with mHz precision.