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

Linux 6.18.37 · IIO

AD4695 driver

AD4695 계열 ADC의 일반·offload SPI 배선, 입력 pairing, 전원·기준·보정과 sequencer 버퍼 샘플률을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

ad4695.rst:1-269

AD4695 드라이버는 실제 입력 배선에 따라 REFGND·COM·다음 INx와 채널을 pairing합니다. SPI offload에서는 PWM·BUSY 트리거와 advanced sequencer를 쓰며, 활성 채널 수와 채널별 OSR의 주기 합이 실제 buffered sample rate를 결정합니다.

문서 개요
항목
SourceDocumentation/iio/ad4695.rst
분량269 source lines
지원 장치4
OSR1, 4, 16, 64

원문 분량과 핵심 검토 대상을 요약합니다.

핵심 흐름
SPI 배선과 trigger source 설정채널별 input pairing 기술전원·기준 선택Sampling frequency 먼저 설정OSR 구성 후 sequencer buffer 수집

장치 설정과 수집 순서를 압축합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0-only
2
3 =============
4 AD4695 driver
5 =============
6
7 ADC driver for Analog Devices Inc. AD4695 and similar devices. The module name
8 is ``ad4695``.
9
10
11 Supported devices
12 =================
13
14 The following chips are supported by this driver:
15
16 * `AD4695 <https://www.analog.com/AD4695>`_
17 * `AD4696 <https://www.analog.com/AD4696>`_
18 * `AD4697 <https://www.analog.com/AD4697>`_
19 * `AD4698 <https://www.analog.com/AD4698>`_
20
21
22 Supported features
23 ==================
24
25 SPI wiring modes
26 ----------------
27
28 The driver currently supports the following SPI wiring configuration:
29
30 4-wire mode
31 ^^^^^^^^^^^
32
33 In this mode, CNV and CS are tied together and there is a single SDO line.
34
35 .. code-block::
36
37 +-------------+ +-------------+
38 | CS |<-+------| CS |
39 | CNV |<-+ | |
40 | ADC | | HOST |
41 | | | |
42 | SDI |<--------| SDO |
43 | SDO |-------->| SDI |
44 | SCLK |<--------| SCLK |
45 +-------------+ +-------------+
46
47 To use this mode, in the device tree, omit the ``cnv-gpios`` and
48 ``spi-rx-bus-width`` properties.
49
50 SPI offload wiring
51 ^^^^^^^^^^^^^^^^^^
52
53 When used with a SPI offload, the supported wiring configuration is:
54
55 .. code-block::
56
57 +-------------+ +-------------+
58 | GP0/BUSY |-------->| TRIGGER |
59 | CS |<--------| CS |
60 | | | |
61 | ADC | | SPI |
62 | | | |
63 | SDI |<--------| SDO |
64 | SDO |-------->| SDI |
65 | SCLK |<--------| SCLK |
66 | | | |
67 | | +-------------+
68 | CNV |<-----+--| PWM |
69 | | +--| GPIO |
70 +-------------+ +-------------+
71
72 In this case, both the ``cnv-gpios`` and ``pwms`` properties are required.
73 The ``#trigger-source-cells = <2>`` property is also required to connect back
74 to the SPI offload. The SPI offload will have ``trigger-sources`` property
75 with cells to indicate the busy signal and which GPx pin is used, e.g
76 ``<&ad4695 AD4695_TRIGGER_EVENT_BUSY AD4695_TRIGGER_PIN_GP0>``.
77
78 .. seealso:: `SPI offload support`_
79
80 Channel configuration
81 ---------------------
82
83 Since the chip supports multiple ways to configure each channel, this must be
84 described in the device tree based on what is actually wired up to the inputs.
85
86 There are three typical configurations:
87
88 An ``INx`` pin is used as the positive input with the ``REFGND``, ``COM`` or
89 the next ``INx`` pin as the negative input.
90
91 Pairing with REFGND
92 ^^^^^^^^^^^^^^^^^^^
93
94 Each ``INx`` pin can be used as a pseudo-differential input in conjunction with
95 the ``REFGND`` pin. The device tree will look like this:
96
97 .. code-block::
98
99 channel@0 {
100 reg = <0>; /* IN0 */
101 };
102
103 If no other channel properties are needed (e.g. ``adi,no-high-z``), the channel
104 node can be omitted entirely.
105
106 This will appear on the IIO bus as the ``voltage0`` channel. The processed value
107 (*raw × scale*) will be the voltage present on the ``IN0`` pin relative to
108 ``REFGND``. (Offset is always 0 when pairing with ``REFGND``.)
109
110 Pairing with COM
111 ^^^^^^^^^^^^^^^^
112
113 Each ``INx`` pin can be used as a pseudo-differential input in conjunction with
114 the ``COM`` pin. The device tree will look like this:
115
116 .. code-block::
117
118 com-supply = <&vref_div_2>;
119
120 channel@1 {
121 reg = <1>; /* IN1 */
122 common-mode-channel = <AD4695_COMMON_MODE_COM>;
123 bipolar;
124 };
125
126 This will appear on the IIO bus as the ``voltage1`` channel. The processed value
127 (*(raw + offset) × scale*) will be the voltage measured on the ``IN1`` pin
128 relative to ``REFGND``. (The offset is determined by the ``com-supply`` voltage.)
129
130 The macro comes from:
131
132 .. code-block::
133
134 #include <dt-bindings/iio/adc/adi,ad4695.h>
135
136 Pairing two INx pins
137 ^^^^^^^^^^^^^^^^^^^^
138
139 An even-numbered ``INx`` pin and the following odd-numbered ``INx`` pin can be
140 used as a pseudo-differential input. The device tree for using ``IN2`` as the
141 positive input and ``IN3`` as the negative input will look like this:
142
143 .. code-block::
144
145 in3-supply = <&vref_div_2>;
146
147 channel@2 {
148 reg = <2>; /* IN2 */
149 common-mode-channel = <3>; /* IN3 */
150 bipolar;
151 };
152
153 This will appear on the IIO bus as the ``voltage2`` channel. The processed value
154 (*(raw + offset) × scale*) will be the voltage measured on the ``IN1`` pin
155 relative to ``REFGND``. (Offset is determined by the ``in3-supply`` voltage.)
156
157 VCC supply
158 ----------
159
160 The chip supports being powered by an external LDO via the ``VCC`` input or an
161 internal LDO via the ``LDO_IN`` input. The driver looks at the device tree to
162 determine which is being used. If ``ldo-supply`` is present, then the internal
163 LDO is used. If ``vcc-supply`` is present, then the external LDO is used and
164 the internal LDO is disabled.
165
166 Reference voltage
167 -----------------
168
169 The chip supports an external reference voltage via the ``REF`` input or an
170 internal buffered reference voltage via the ``REFIN`` input. The driver looks
171 at the device tree to determine which is being used. If ``ref-supply`` is
172 present, then the external reference voltage is used and the internal buffer is
173 disabled. If ``refin-supply`` is present, then the internal buffered reference
174 voltage is used.
175
176 Gain/offset calibration
177 -----------------------
178
179 System calibration is supported using the channel gain and offset registers via
180 the ``calibscale`` and ``calibbias`` attributes respectively.
181
182 Oversampling
183 ------------
184
185 The chip supports per-channel oversampling when SPI offload is being used, with
186 available oversampling ratios (OSR) of 1 (default), 4, 16, and 64. Enabling
187 oversampling on a channel raises the effective number of bits of sampled data to
188 17 (OSR == 4), 18 (16), or 19 (64), respectively. This can be set via the
189 ``oversampling_ratio`` attribute.
190
191 Setting the oversampling ratio for a channel also changes the sample rate for
192 that channel, since it requires multiple conversions per 1 sample. Specifically,
193 the new sampling frequency is the PWM sampling frequency divided by the
194 particular OSR. This is set automatically by the driver when setting the
195 ``oversampling_ratio`` attribute. For example, if the device's current
196 ``sampling_frequency`` is 10000 and an OSR of 4 is set on channel ``voltage0``,
197 the new reported sampling rate for that channel will be 2500 (ignoring PWM API
198 rounding), while all others will remain at 10000. Subsequently setting the
199 sampling frequency to a higher value on that channel will adjust the CNV trigger
200 period for all channels, e.g. if ``voltage0``'s sampling frequency is adjusted
201 from 2500 (with an OSR of 4) to 10000, the value reported by
202 ``in_voltage0_sampling_frequency`` will be 10000, but all other channels will
203 now report 40000.
204
205 For simplicity, the sampling frequency of the device should be set (considering
206 the highest desired OSR value to be used) first, before configuring oversampling
207 for specific channels.
208
209 Unimplemented features
210 ----------------------
211
212 - Additional wiring modes
213 - Threshold events
214 - GPIO support
215 - CRC support
216
217 SPI offload support
218 ===================
219
220 To be able to achieve the maximum sample rate, the driver can be used with the
221 `AXI SPI Engine`_ to provide SPI offload support.
222
223 .. _AXI SPI Engine: http://analogdevicesinc.github.io/hdl/projects/ad469x_fmc/index.html
224
225 .. seealso:: `SPI offload wiring`_
226
227 When SPI offload is being used, some attributes will be different.
228
229 * ``trigger`` directory is removed.
230 * ``in_voltage0_sampling_frequency`` attributes are added for setting the sample
231 rate.
232 * ``in_voltage0_sampling_frequency_available`` attributes are added for querying
233 the max sample rate.
234 * ``timestamp`` channel is removed.
235 * Buffer data format may be different compared to when offload is not used,
236 e.g. the ``buffer0/in_voltage0_type`` attribute.
237
238 Device buffers
239 ==============
240
241 This driver supports hardware triggered buffers. This uses the "advanced
242 sequencer" feature of the chip to trigger a burst of conversions.
243
244 Also see :doc:`iio_devbuf` for more general information.
245
246 Effective sample rate for buffered reads
247 ----------------------------------------
248
249 When SPI offload is not used, the sample rate is determined by the trigger that
250 is manually configured in userspace. All enabled channels will be read in a
251 burst when the trigger is received.
252
253 When SPI offload is used, the sample rate is configured per channel. All
254 channels will have the same rate, so only one ``in_voltageY_sampling_frequency``
255 attribute needs to be set. Since this rate determines the delay between each
256 individual conversion, the effective sample rate for each sample is actually
257 the sum of the periods of each enabled channel in a buffered read. In other
258 words, it is the value of the ``in_voltageY_sampling_frequency`` attribute
259 divided by the number of enabled channels. So if 4 channels are enabled, with
260 the ``in_voltageY_sampling_frequency`` attributes set to 1 MHz, the effective
261 sample rate is 250 kHz.
262
263 With oversampling enabled, the effective sample rate also depends on the OSR
264 assigned to each channel. For example, if one of the 4 channels mentioned in the
265 previous case is configured with an OSR of 4, the effective sample rate for that
266 channel becomes (1 MHz / 4 ) = 250 kHz. The effective sample rate for all
267 four channels is then 1 / ( (3 / 1 MHz) + ( 1 / 250 kHz) ) ~= 142.9 kHz. Note
268 that in this case "sample" refers to one read of all enabled channels (i.e. one
269 full cycle through the auto-sequencer).
270

3. 한국어 전문 번역

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

지원 장치와 일반·offload SPI 배선

1-79

이 문서는 Analog Devices Inc. AD4695와 유사 ADC의 드라이버를 설명합니다. 모듈 이름은 `ad4695`이고 지원 칩은 AD4695, AD4696, AD4697, AD4698입니다.

일반 4-wire 모드에서는 CNV와 CS를 서로 묶고 SDO 선 하나를 사용합니다. ADC의 SDI는 호스트 SDO, ADC SDO는 호스트 SDI, SCLK는 서로 연결합니다.

AD4695 일반 4-wire 배선
ADC 핀방향HOST 핀역할
CS + CNVHOST → ADCCS장치 선택과 변환 시작을 함께 제어
SDIHOST → ADCSDO구성 데이터
SDOADC → HOSTSDI변환 결과
SCLKHOST → ADCSCLK직렬 클록

원문의 ADC·HOST ASCII 그림을 같은 신호 관계로 재구성합니다.

이 모드를 쓰려면 Device Tree에서 `cnv-gpios`와 `spi-rx-bus-width` 속성을 모두 생략합니다.

SPI offload에서는 `GP0/BUSY`가 offload TRIGGER 입력으로 가고, CS·SDI·SDO·SCLK는 일반 SPI처럼 연결합니다. CNV는 PWM과 GPIO가 함께 구동할 수 있게 연결됩니다.

AD4695 SPI offload 배선
ADC 핀방향Offload/Host 핀역할
GP0/BUSYADC → SPITRIGGER변환 완료 이벤트
CSSPI → ADCCS직렬 인터페이스 선택
SDISPI → ADCSDO구성 데이터
SDOADC → SPISDI변환 결과
SCLKSPI → ADCSCLK직렬 클록
CNVHOST → ADCPWM + GPIO주기 변환 트리거와 직접 제어

두 번째 ASCII 그림의 ADC·SPI·트리거 연결을 구조화했습니다.

Offload 배선에서는 `cnv-gpios`와 `pwms`가 모두 필수입니다. SPI offload로 이벤트를 되돌려 연결하려면 `#trigger-source-cells = <2>`도 필요합니다.

SPI offload의 `trigger-sources` 셀은 busy 신호와 사용할 GPx 핀을 지정합니다. 예는 `<&ad4695 AD4695_TRIGGER_EVENT_BUSY AD4695_TRIGGER_PIN_GP0>`입니다.

배선별 Device Tree 요구
모드필수 속성생략 속성Trigger source
일반 4-wire-`cnv-gpios`, `spi-rx-bus-width`CS와 CNV 결합
SPI offload`cnv-gpios`, `pwms`, `#trigger-source-cells = <2>`-BUSY + GPx 핀 셀

일반 전송과 offload의 속성을 비교합니다.

SPI offload 변환
PWM이 CNV 변환 트리거 생성ADC가 변환 수행GP0/BUSY가 SPI offload TRIGGER 알림Offload 엔진이 SCLK로 결과 읽기IIO 버퍼에 채널 데이터 저장

PWM 변환 시작부터 BUSY 트리거와 데이터 읽기까지입니다.

.. SPDX-License-Identifier: GPL-2.0-only

=============
AD4695 driver
=============

ADC driver for Analog Devices Inc. AD4695 and similar devices. The module name
is ``ad4695``.


Supported devices
=================

The following chips are supported by this driver:

* `AD4695 <https://www.analog.com/AD4695>`_
* `AD4696 <https://www.analog.com/AD4696>`_
* `AD4697 <https://www.analog.com/AD4697>`_
* `AD4698 <https://www.analog.com/AD4698>`_


Supported features
==================

SPI wiring modes
----------------

The driver currently supports the following SPI wiring configuration:

4-wire mode
^^^^^^^^^^^

In this mode, CNV and CS are tied together and there is a single SDO line.

.. code-block::

    +-------------+         +-------------+
    |          CS |<-+------| CS          |
    |         CNV |<-+      |             |
    |     ADC     |         |     HOST    |
    |             |         |             |
    |         SDI |<--------| SDO         |
    |         SDO |-------->| SDI         |
    |        SCLK |<--------| SCLK        |
    +-------------+         +-------------+

To use this mode, in the device tree, omit the ``cnv-gpios`` and
``spi-rx-bus-width`` properties.

SPI offload wiring
^^^^^^^^^^^^^^^^^^

When used with a SPI offload, the supported wiring configuration is:

.. code-block::

    +-------------+         +-------------+
    |    GP0/BUSY |-------->| TRIGGER     |
    |          CS |<--------| CS          |
    |             |         |             |
    |     ADC     |         |     SPI     |
    |             |         |             |
    |         SDI |<--------| SDO         |
    |         SDO |-------->| SDI         |
    |        SCLK |<--------| SCLK        |
    |             |         |             |
    |             |         +-------------+
    |         CNV |<-----+--| PWM         |
    |             |      +--| GPIO        |
    +-------------+         +-------------+

In this case, both the ``cnv-gpios`` and  ``pwms`` properties are required.
The ``#trigger-source-cells = <2>`` property is also required to connect back
to the SPI offload. The SPI offload will have ``trigger-sources`` property
with cells to indicate the busy signal and which GPx pin is used, e.g
``<&ad4695 AD4695_TRIGGER_EVENT_BUSY AD4695_TRIGGER_PIN_GP0>``.

.. seealso:: `SPI offload support`_

채널 pairing과 전원·기준 전압

80-175

칩은 채널마다 여러 입력 구성을 지원하므로 실제 입력 배선에 맞춰 Device Tree에 기술해야 합니다. 일반적인 구성은 INx를 positive 입력으로 쓰고 REFGND, COM 또는 다음 INx를 negative 입력으로 짝짓는 세 가지입니다.

REFGND pairing에서는 각 INx가 REFGND와 함께 pseudo-differential 입력으로 동작합니다. `channel@0 { reg = <0>; };`은 IN0을 선택합니다. `adi,no-high-z` 같은 추가 속성이 없다면 채널 노드를 통째로 생략할 수 있습니다.

이 구성은 IIO에서 `voltage0`으로 보입니다. 처리 값 `raw × scale`은 REFGND에 대한 IN0 전압이고, REFGND pairing의 offset은 항상 0입니다.

COM pairing에서는 `com-supply`를 제공하고 채널 노드에 `common-mode-channel = <AD4695_COMMON_MODE_COM>`과 `bipolar`를 지정합니다. 예제의 IN1은 IIO `voltage1`로 보입니다.

처리 값 `(raw + offset) × scale`은 REFGND에 대한 IN1 전압이며 offset은 `com-supply` 전압으로 결정됩니다. 매크로는 `#include <dt-bindings/iio/adc/adi,ad4695.h>`에서 가져옵니다.

두 INx pairing에서는 짝수 INx와 바로 다음 홀수 INx를 pseudo-differential 쌍으로 사용합니다. 예제는 `in3-supply`를 제공하고 `channel@2`의 positive 입력 IN2에 `common-mode-channel = <3>`과 `bipolar`를 지정해 IN3을 negative 입력으로 연결합니다.

이 구성은 IIO `voltage2`로 보입니다. 원문은 처리 값 설명에서 IN1이라고 적고 있으며, offset은 `in3-supply` 전압으로 결정된다고 설명합니다. 원문의 핀 표기와 줄 좌표는 영어 원문 블록에 그대로 보존했습니다.

AD4695 입력 pairing
구성PositiveNegative·기준IIO 채널처리식·offset
REFGND pairingINxREFGND`voltageX``raw × scale`, offset 0
COM pairingINxCOM`voltageX``(raw + offset) × scale`, `com-supply` 결정
IN pair짝수 INx다음 홀수 INx`voltageX``(raw + offset) × scale`, `inY-supply` 결정

Negative 기준 선택과 IIO 처리식을 비교합니다.

Channel node 핵심 속성
속성용도
`reg`Positive INx 번호
`common-mode-channel`COM 매크로 또는 negative INx 번호
`bipolar`Bipolar pseudo-differential 처리
`com-supply`COM 전압으로 offset 결정
`inY-supply`짝지은 INy 전압으로 offset 결정
`adi,no-high-z`추가 채널 설정의 예

각 pairing을 표현하는 Device Tree 항목입니다.

전원은 `VCC` 입력의 외부 LDO 또는 `LDO_IN` 입력의 내부 LDO를 사용할 수 있습니다. `ldo-supply`가 있으면 내부 LDO, `vcc-supply`가 있으면 외부 LDO를 쓰고 내부 LDO를 비활성화합니다.

기준 전압은 `REF`의 외부 기준 또는 `REFIN`의 내부 buffered 기준을 지원합니다. `ref-supply`가 있으면 외부 기준을 쓰고 내부 버퍼를 끄며, `refin-supply`가 있으면 내부 buffered 기준을 사용합니다.

AD4695 전원·기준 선택
속성선택 경로내부 회로
`ldo-supply``LDO_IN` 내부 LDO내부 LDO 사용
`vcc-supply``VCC` 외부 LDO내부 LDO 비활성화
`ref-supply``REF` 외부 기준내부 reference buffer 비활성화
`refin-supply``REFIN` 내부 buffered 기준내부 buffer 사용

Device Tree supply 속성이 선택하는 입력 경로입니다.

Channel configuration
---------------------

Since the chip supports multiple ways to configure each channel, this must be
described in the device tree based on what is actually wired up to the inputs.

There are three typical configurations:

An ``INx`` pin is used as the positive input with the ``REFGND``, ``COM`` or
the next ``INx`` pin as the negative input.

Pairing with REFGND
^^^^^^^^^^^^^^^^^^^

Each ``INx`` pin can be used as a pseudo-differential input in conjunction with
the ``REFGND`` pin. The device tree will look like this:

.. code-block::

    channel@0 {
        reg = <0>; /* IN0 */
    };

If no other channel properties are needed (e.g. ``adi,no-high-z``), the channel
node can be omitted entirely.

This will appear on the IIO bus as the ``voltage0`` channel. The processed value
(*raw × scale*) will be the voltage present on the ``IN0`` pin relative to
``REFGND``. (Offset is always 0 when pairing with ``REFGND``.)

Pairing with COM
^^^^^^^^^^^^^^^^

Each ``INx`` pin can be used as a pseudo-differential input in conjunction with
the ``COM`` pin. The device tree will look like this:

.. code-block::

    com-supply = <&vref_div_2>;

    channel@1 {
        reg = <1>; /* IN1 */
        common-mode-channel = <AD4695_COMMON_MODE_COM>;
        bipolar;
    };

This will appear on the IIO bus as the ``voltage1`` channel. The processed value
(*(raw + offset) × scale*) will be the voltage measured on the ``IN1`` pin
relative to ``REFGND``. (The offset is determined by the ``com-supply`` voltage.)

The macro comes from:

.. code-block::

    #include <dt-bindings/iio/adc/adi,ad4695.h>

Pairing two INx pins
^^^^^^^^^^^^^^^^^^^^

An even-numbered ``INx`` pin and the following odd-numbered ``INx`` pin can be
used as a pseudo-differential input. The device tree for using ``IN2`` as the
positive input and ``IN3`` as the negative input will look like this:

.. code-block::

    in3-supply = <&vref_div_2>;

    channel@2 {
        reg = <2>; /* IN2 */
        common-mode-channel = <3>; /* IN3 */
        bipolar;
    };

This will appear on the IIO bus as the ``voltage2`` channel. The processed value
(*(raw + offset) × scale*) will be the voltage measured on the ``IN1`` pin
relative to ``REFGND``. (Offset is determined by the ``in3-supply`` voltage.)

VCC supply
----------

The chip supports being powered by an external LDO via the ``VCC`` input or an
internal LDO via the ``LDO_IN`` input. The driver looks at the device tree to
determine which is being used. If ``ldo-supply`` is present, then the internal
LDO is used. If ``vcc-supply`` is present, then the external LDO is used and
the internal LDO is disabled.

Reference voltage
-----------------

The chip supports an external reference voltage via the ``REF`` input or an
internal buffered reference voltage via the ``REFIN`` input. The driver looks
at the device tree to determine which is being used. If ``ref-supply`` is
present, then the external reference voltage is used and the internal buffer is
disabled. If ``refin-supply`` is present, then the internal buffered reference
voltage is used.

보정, 채널별 oversampling과 미구현 기능

176-216

채널 gain과 offset 레지스터를 통한 시스템 보정을 지원합니다. Gain은 `calibscale`, offset은 `calibbias` 속성으로 제어합니다.

SPI offload를 사용할 때 채널별 oversampling을 지원합니다. OSR은 기본값 1과 4, 16, 64이며 `oversampling_ratio` 속성으로 설정합니다.

Oversampling을 켜면 유효 샘플 비트 수가 OSR 4에서 17비트, 16에서 18비트, 64에서 19비트로 증가합니다.

AD4695 oversampling
OSR유효 비트채널 sampling frequency
1기본 해상도PWM frequency
417 bitsPWM frequency / 4
1618 bitsPWM frequency / 16
6419 bitsPWM frequency / 64

OSR과 유효 데이터 비트 및 채널 샘플률 관계입니다.

채널 OSR을 바꾸면 샘플 하나에 여러 변환이 필요하므로 해당 채널 샘플률도 변합니다. 드라이버는 `oversampling_ratio` 설정 때 PWM sampling frequency를 OSR로 나눈 값으로 자동 조정합니다.

예를 들어 장치 `sampling_frequency`가 10000이고 `voltage0`에 OSR 4를 설정하면 PWM API 반올림을 무시할 때 그 채널은 2500, 나머지는 10000을 보고합니다.

그 뒤 OSR 4인 `voltage0`의 샘플률을 2500에서 10000으로 올리면 드라이버가 모든 채널의 CNV trigger 주기를 바꿉니다. `in_voltage0_sampling_frequency`는 10000이지만 다른 채널은 40000을 보고하게 됩니다.

혼동을 줄이려면 사용할 가장 높은 OSR을 고려해 장치 sampling frequency를 먼저 설정한 다음 특정 채널에 oversampling을 구성해야 합니다.

Sampling frequency와 OSR 설정 순서
사용할 최대 OSR 결정장치 sampling frequency 먼저 설정채널별 `oversampling_ratio` 설정드라이버가 채널 sampling frequency 자동 계산보고된 각 채널 속성 확인

공유 CNV 주기와 채널별 분주 관계를 안정적으로 정합니다.

아직 구현되지 않은 기능은 추가 배선 모드, threshold 이벤트, GPIO 지원과 CRC 지원입니다.

AD4695 미구현 기능
분류항목
배선Additional wiring modes
이벤트Threshold events
범용 I/OGPIO support
무결성CRC support

현재 드라이버 범위 밖의 기능입니다.

Gain/offset calibration
-----------------------

System calibration is supported using the channel gain and offset registers via
the ``calibscale`` and ``calibbias`` attributes respectively.

Oversampling
------------

The chip supports per-channel oversampling when SPI offload is being used, with
available oversampling ratios (OSR) of 1 (default), 4, 16, and 64.  Enabling
oversampling on a channel raises the effective number of bits of sampled data to
17 (OSR == 4), 18 (16), or 19 (64), respectively. This can be set via the
``oversampling_ratio`` attribute.

Setting the oversampling ratio for a channel also changes the sample rate for
that channel, since it requires multiple conversions per 1 sample. Specifically,
the new sampling frequency is the PWM sampling frequency divided by the
particular OSR. This is set automatically by the driver when setting the
``oversampling_ratio`` attribute. For example, if the device's current
``sampling_frequency`` is 10000 and an OSR of 4 is set on channel ``voltage0``,
the new reported sampling rate for that channel will be 2500 (ignoring PWM API
rounding), while all others will remain at 10000.  Subsequently setting the
sampling frequency to a higher value on that channel will adjust the CNV trigger
period for all channels, e.g. if ``voltage0``'s sampling frequency is adjusted
from 2500 (with an OSR of 4) to 10000, the value reported by
``in_voltage0_sampling_frequency`` will be 10000, but all other channels will
now report 40000.

For simplicity, the sampling frequency of the device should be set (considering
the highest desired OSR value to be used) first, before configuring oversampling
for specific channels.

Unimplemented features
----------------------

- Additional wiring modes
- Threshold events
- GPIO support
- CRC support

SPI offload 인터페이스와 buffered 유효 샘플률

217-269

최대 샘플 속도를 위해 드라이버는 `AXI SPI Engine`과 함께 SPI offload를 사용할 수 있습니다.

Offload를 사용하면 일부 IIO 속성이 달라집니다. `trigger` 디렉터리와 `timestamp` 채널을 제거하고, 샘플률 설정용 `in_voltage0_sampling_frequency`와 최대 샘플률 조회용 `in_voltage0_sampling_frequency_available`을 추가합니다.

버퍼 데이터 형식도 offload를 쓰지 않을 때와 다를 수 있으며 `buffer0/in_voltage0_type` 같은 속성에서 확인할 수 있습니다.

AD4695 offload 인터페이스 변화
항목SPI offload 사용 시
`trigger` 디렉터리제거
`in_voltage0_sampling_frequency`추가, 샘플률 설정
`in_voltage0_sampling_frequency_available`추가, 최대 샘플률 조회
`timestamp` 채널제거
`buffer0/in_voltage0_type`데이터 형식이 달라질 수 있음

일반 trigger 방식과 비교한 사용자 공간 차이입니다.

드라이버는 하드웨어 triggered buffer를 지원하며 칩의 advanced sequencer로 변환 burst를 시작합니다. 일반 IIO 버퍼 정보는 `iio_devbuf` 문서를 참조합니다.

SPI offload를 사용하지 않을 때는 사용자 공간에서 수동 구성한 trigger가 샘플률을 결정합니다. Trigger를 받으면 활성화한 모든 채널을 burst로 읽습니다.

SPI offload에서는 채널별로 샘플률을 구성합니다. 모든 채널이 같은 rate를 가지므로 `in_voltageY_sampling_frequency` 하나만 설정하면 됩니다. 하지만 이 값은 개별 변환 사이의 지연을 정하므로, 활성 채널 전체를 한 번 읽는 유효 샘플률은 각 채널 주기의 합으로 결정됩니다.

OSR이 모두 1이면 유효 샘플률은 `in_voltageY_sampling_frequency / 활성 채널 수`입니다. 예를 들어 4채널을 활성화하고 속성을 1MHz로 설정하면 전체 cycle의 유효 샘플률은 250kHz입니다.

Oversampling을 사용하면 채널별 OSR도 반영합니다. 4채널 중 하나가 OSR 4이면 해당 채널의 유효 변환률은 `1MHz / 4 = 250kHz`이고 전체 4채널 cycle은 `1 / ((3 / 1MHz) + (1 / 250kHz)) ≈ 142.9kHz`입니다.

여기서 sample은 활성화한 모든 채널을 한 번씩 읽는 것, 즉 auto-sequencer의 한 전체 cycle을 뜻합니다.

Buffered 유효 샘플률 예
구성계산유효 sample rate
4 channels, 모두 OSR 1, 1MHz`1MHz / 4`250kHz
3 channels OSR 1 + 1 channel OSR 4`1 / ((3/1MHz) + (1/250kHz))`약 142.9kHz

채널 수와 OSR이 전체 cycle에 미치는 영향입니다.

Advanced sequencer buffer cycle
CNV 주기 설정Advanced sequencer가 활성 채널 순회각 채널에서 OSR만큼 변환모든 채널 결과를 buffer에 기록전체 순회 완료를 sample 하나로 계산

한 sample을 활성 채널 전체 cycle로 정의합니다.

SPI offload support
===================

To be able to achieve the maximum sample rate, the driver can be used with the
`AXI SPI Engine`_ to provide SPI offload support.

.. _AXI SPI Engine: http://analogdevicesinc.github.io/hdl/projects/ad469x_fmc/index.html

.. seealso:: `SPI offload wiring`_

When SPI offload is being used, some attributes will be different.

* ``trigger`` directory is removed.
* ``in_voltage0_sampling_frequency`` attributes are added for setting the sample
  rate.
* ``in_voltage0_sampling_frequency_available`` attributes are added for querying
  the max sample rate.
* ``timestamp`` channel is removed.
* Buffer data format may be different compared to when offload is not used,
  e.g. the ``buffer0/in_voltage0_type`` attribute.

Device buffers
==============

This driver supports hardware triggered buffers. This uses the "advanced
sequencer" feature of the chip to trigger a burst of conversions.

Also see :doc:`iio_devbuf` for more general information.

Effective sample rate for buffered reads
----------------------------------------

When SPI offload is not used, the sample rate is determined by the trigger that
is manually configured in userspace. All enabled channels will be read in a
burst when the trigger is received.

When SPI offload is used, the sample rate is configured per channel. All
channels will have the same rate, so only one ``in_voltageY_sampling_frequency``
attribute needs to be set. Since this rate determines the delay between each
individual conversion, the effective sample rate for each sample is actually
the sum of the periods of each enabled channel in a buffered read. In other
words, it is the value of the ``in_voltageY_sampling_frequency`` attribute
divided by the number of enabled channels. So if 4 channels are enabled, with
the ``in_voltageY_sampling_frequency`` attributes set to 1 MHz, the effective
sample rate is 250 kHz.

With oversampling enabled, the effective sample rate also depends on the OSR
assigned to each channel. For example, if one of the 4 channels mentioned in the
previous case is configured with an OSR of 4, the effective sample rate for that
channel becomes (1 MHz / 4 ) = 250 kHz. The effective sample rate for all
four channels is then 1 / ( (3 / 1 MHz) + ( 1 / 250 kHz) ) ~= 142.9 kHz. Note
that in this case "sample" refers to one read of all enabled channels (i.e. one
full cycle through the auto-sequencer).