xref: /linux/Documentation/iio/ad4062.rst (revision 505d195b0f96fd613a51b13dde37aa5ad301eb32)
11b1ddab0SJorge Marques.. SPDX-License-Identifier: GPL-2.0-only
21b1ddab0SJorge Marques
31b1ddab0SJorge Marques=============
41b1ddab0SJorge MarquesAD4062 driver
51b1ddab0SJorge Marques=============
61b1ddab0SJorge Marques
71b1ddab0SJorge MarquesADC driver for Analog Devices Inc. AD4060/AD4062 devices. The module name is
81b1ddab0SJorge Marques``ad4062``.
91b1ddab0SJorge Marques
101b1ddab0SJorge MarquesSupported devices
111b1ddab0SJorge Marques=================
121b1ddab0SJorge Marques
131b1ddab0SJorge MarquesThe following chips are supported by this driver:
141b1ddab0SJorge Marques
151b1ddab0SJorge Marques* `AD4060 <https://www.analog.com/AD4060>`_
161b1ddab0SJorge Marques* `AD4062 <https://www.analog.com/AD4062>`_
171b1ddab0SJorge Marques
181b1ddab0SJorge MarquesWiring modes
191b1ddab0SJorge Marques============
201b1ddab0SJorge Marques
211b1ddab0SJorge MarquesThe ADC is interfaced through an I3C bus, and contains two programmable GPIOs.
221b1ddab0SJorge Marques
231b1ddab0SJorge MarquesThe ADC convert-start happens on the SDA rising edge of the I3C stop (P) bit
241b1ddab0SJorge Marquesat the end of the read command.
251b1ddab0SJorge Marques
261b1ddab0SJorge MarquesThe two programmable GPIOS are optional and have a role assigned if present in
271b1ddab0SJorge Marquesthe devicetree ``interrupt-names`` property:
281b1ddab0SJorge Marques
29c894e058SJorge Marques- GP0: Is assigned the role of Threshold Either signal.
301b1ddab0SJorge Marques- GP1: Is assigned the role of Data Ready signal.
311b1ddab0SJorge Marques
32*d2ca7af2SJorge MarquesIf the property ``gpio-controller`` is present in the devicetree, then the GPO
33*d2ca7af2SJorge Marquesnot present in the ``interrupt-names`` is exposed as a GPO.
34*d2ca7af2SJorge Marques
351b1ddab0SJorge MarquesDevice attributes
361b1ddab0SJorge Marques=================
371b1ddab0SJorge Marques
381b1ddab0SJorge MarquesThe ADC contains only one channel with following attributes:
391b1ddab0SJorge Marques
401b1ddab0SJorge Marques.. list-table:: Channel attributes
411b1ddab0SJorge Marques   :header-rows: 1
421b1ddab0SJorge Marques
431b1ddab0SJorge Marques   * - Attribute
441b1ddab0SJorge Marques     - Description
451b1ddab0SJorge Marques   * - ``in_voltage_calibscale``
461b1ddab0SJorge Marques     - Sets the gain scaling factor that the hardware applies to the sample,
471b1ddab0SJorge Marques       to compensate for system gain error.
481b1ddab0SJorge Marques   * - ``in_voltage_oversampling_ratio``
491b1ddab0SJorge Marques     - Sets device's burst averaging mode to over sample using the
501b1ddab0SJorge Marques       internal sample rate. Value 1 disable the burst averaging mode.
511b1ddab0SJorge Marques   * - ``in_voltage_oversampling_ratio_available``
521b1ddab0SJorge Marques     - List of available oversampling values.
531b1ddab0SJorge Marques   * - ``in_voltage_raw``
541b1ddab0SJorge Marques     - Returns the raw ADC voltage value.
551b1ddab0SJorge Marques   * - ``in_voltage_scale``
561b1ddab0SJorge Marques     - Returns the channel scale in reference to the reference voltage
571b1ddab0SJorge Marques       ``ref-supply`` or ``vdd-supply`` if the former not present.
581b1ddab0SJorge Marques
591b1ddab0SJorge MarquesAlso contain the following device attributes:
601b1ddab0SJorge Marques
611b1ddab0SJorge Marques.. list-table:: Device attributes
621b1ddab0SJorge Marques   :header-rows: 1
631b1ddab0SJorge Marques
641b1ddab0SJorge Marques   * - Attribute
651b1ddab0SJorge Marques     - Description
661b1ddab0SJorge Marques   * - ``sampling_frequency``
671b1ddab0SJorge Marques     - Sets the duration of a single scan, used in the burst averaging mode.
681b1ddab0SJorge Marques       The duration is described by ``(n_avg - 1) / fosc + tconv``, where
691b1ddab0SJorge Marques       ``n_avg`` is the oversampling ratio, ``fosc`` is the internal sample
701b1ddab0SJorge Marques       rate and ``tconv`` is the ADC conversion time.
711b1ddab0SJorge Marques   * - ``sampling_frequency_available``
721b1ddab0SJorge Marques     - Lists the available sampling frequencies, computed on the current
731b1ddab0SJorge Marques       oversampling ratio. If the ratio is 1, the frequency is ``1/tconv``.
741b1ddab0SJorge Marques
751b1ddab0SJorge MarquesInterrupts
761b1ddab0SJorge Marques==========
771b1ddab0SJorge Marques
781b1ddab0SJorge MarquesThe interrupts are mapped through the ``interrupt-names`` and ``interrupts``
791b1ddab0SJorge Marquesproperties.
801b1ddab0SJorge Marques
81c894e058SJorge MarquesThe ``interrupt-names`` ``gp0`` entry sets the role of Threshold signal, and
82c894e058SJorge Marquesentry ``gp1`` the role of Data Ready signal.
83c894e058SJorge Marques
84c894e058SJorge MarquesIf each is not present, the driver fallback to enabling the same role as an
851b1ddab0SJorge MarquesI3C IBI.
861b1ddab0SJorge Marques
871b1ddab0SJorge MarquesLow-power mode
881b1ddab0SJorge Marques==============
891b1ddab0SJorge Marques
901b1ddab0SJorge MarquesThe device enters low-power mode on idle to save power. Enabling an event puts
911b1ddab0SJorge Marquesthe device out of the low-power since the ADC autonomously samples to assert
921b1ddab0SJorge Marquesthe event condition.
93c31721dcSJorge Marques
94c31721dcSJorge MarquesIIO trigger support
95c31721dcSJorge Marques===================
96c31721dcSJorge Marques
97c31721dcSJorge MarquesAn IIO trigger ``ad4062-devX`` is registered by the driver to be used by the
98c31721dcSJorge Marquessame device, to capture samples to a software buffer. It is required to attach
99c31721dcSJorge Marquesthe trigger to the device by setting the ``current_trigger`` before enabling
100c31721dcSJorge Marquesand reading the buffer.
101c31721dcSJorge Marques
102c31721dcSJorge MarquesThe acquisition is sequential and bounded by the protocol timings, software
103c31721dcSJorge Marqueslatency and internal timings, the sample rate is not configurable. The burst
104c31721dcSJorge Marquesaveraging mode does impact the effective sample rate, since it increases the
105c31721dcSJorge Marquesinternal timing to output a single sample.
106c894e058SJorge Marques
107c894e058SJorge MarquesThreshold events
108c894e058SJorge Marques================
109c894e058SJorge Marques
110c894e058SJorge MarquesThe ADC supports a monitoring mode to raise threshold events. The driver
111c894e058SJorge Marquessupports a single interrupt for both rising and falling readings.
112c894e058SJorge Marques
113c894e058SJorge MarquesThe feature is enabled/disabled by setting ``thresh_either_en``. During monitor
114c894e058SJorge Marquesmode, the device continuously operates in autonomous mode. Any register access
115c894e058SJorge Marquesputs the device back in configuration mode, due to this, any access disables
116c894e058SJorge Marquesmonitor mode.
117c894e058SJorge Marques
118c894e058SJorge MarquesThe following event attributes are available:
119c894e058SJorge Marques
120c894e058SJorge Marques.. list-table:: Event attributes
121c894e058SJorge Marques   :header-rows: 1
122c894e058SJorge Marques
123c894e058SJorge Marques   * - Attribute
124c894e058SJorge Marques     - Description
125c894e058SJorge Marques   * - ``sampling_frequency``
126c894e058SJorge Marques     - Frequency used in the monitoring mode, sets the device internal sample
127c894e058SJorge Marques       rate when the mode is activated.
128c894e058SJorge Marques   * - ``sampling_frequency_available``
129c894e058SJorge Marques     - List of available sample rates.
130c894e058SJorge Marques   * - ``thresh_either_en``
131c894e058SJorge Marques     - Enable monitoring mode.
132c894e058SJorge Marques   * - ``thresh_falling_hysteresis``
133c894e058SJorge Marques     - Set the hysteresis value for the minimum threshold.
134c894e058SJorge Marques   * - ``thresh_falling_value``
135c894e058SJorge Marques     - Set the minimum threshold value.
136c894e058SJorge Marques   * - ``thresh_rising_hysteresis``
137c894e058SJorge Marques     - Set the hysteresis value for the maximum threshold.
138c894e058SJorge Marques   * - ``thresh_rising_value``
139c894e058SJorge Marques     - Set the maximum threshold value.
140*d2ca7af2SJorge Marques
141*d2ca7af2SJorge MarquesGPO controller support
142*d2ca7af2SJorge Marques======================
143*d2ca7af2SJorge Marques
144*d2ca7af2SJorge MarquesThe device supports using GP0 and GP1 as GPOs. If the devicetree contains the
145*d2ca7af2SJorge Marquesnode ``gpio-controller```, the device is marked as a GPIO controller and the
146*d2ca7af2SJorge MarquesGPs not listed in ``interrupt-names`` are exposed as a GPO. The GPIO index
147*d2ca7af2SJorge Marquesmatches the pin name, so if GP0 is not exposed but GP1 is, index 0 is masked
148*d2ca7af2SJorge Marquesout and only index 1 can be set.
149