1.. SPDX-License-Identifier: GPL-2.0-only 2 3============= 4AD4062 driver 5============= 6 7ADC driver for Analog Devices Inc. AD4060/AD4062 devices. The module name is 8``ad4062``. 9 10Supported devices 11================= 12 13The following chips are supported by this driver: 14 15* `AD4060 <https://www.analog.com/AD4060>`_ 16* `AD4062 <https://www.analog.com/AD4062>`_ 17 18Wiring modes 19============ 20 21The ADC is interfaced through an I3C bus, and contains two programmable GPIOs. 22 23The ADC convert-start happens on the SDA rising edge of the I3C stop (P) bit 24at the end of the read command. 25 26The two programmable GPIOS are optional and have a role assigned if present in 27the devicetree ``interrupt-names`` property: 28 29- GP0: Is assigned the role of Threshold Either signal. 30- GP1: Is assigned the role of Data Ready signal. 31 32If the property ``gpio-controller`` is present in the devicetree, then the GPO 33not present in the ``interrupt-names`` is exposed as a GPO. 34 35Device attributes 36================= 37 38The ADC contains only one channel with following attributes: 39 40.. list-table:: Channel attributes 41 :header-rows: 1 42 43 * - Attribute 44 - Description 45 * - ``in_voltage_calibscale`` 46 - Sets the gain scaling factor that the hardware applies to the sample, 47 to compensate for system gain error. 48 * - ``in_voltage_oversampling_ratio`` 49 - Sets device's burst averaging mode to over sample using the 50 internal sample rate. Value 1 disable the burst averaging mode. 51 * - ``in_voltage_oversampling_ratio_available`` 52 - List of available oversampling values. 53 * - ``in_voltage_raw`` 54 - Returns the raw ADC voltage value. 55 * - ``in_voltage_scale`` 56 - Returns the channel scale in reference to the reference voltage 57 ``ref-supply`` or ``vdd-supply`` if the former not present. 58 59Also contain the following device attributes: 60 61.. list-table:: Device attributes 62 :header-rows: 1 63 64 * - Attribute 65 - Description 66 * - ``sampling_frequency`` 67 - Sets the duration of a single scan, used in the burst averaging mode. 68 The duration is described by ``(n_avg - 1) / fosc + tconv``, where 69 ``n_avg`` is the oversampling ratio, ``fosc`` is the internal sample 70 rate and ``tconv`` is the ADC conversion time. 71 * - ``sampling_frequency_available`` 72 - Lists the available sampling frequencies, computed on the current 73 oversampling ratio. If the ratio is 1, the frequency is ``1/tconv``. 74 75Interrupts 76========== 77 78The interrupts are mapped through the ``interrupt-names`` and ``interrupts`` 79properties. 80 81The ``interrupt-names`` ``gp0`` entry sets the role of Threshold signal, and 82entry ``gp1`` the role of Data Ready signal. 83 84If each is not present, the driver fallback to enabling the same role as an 85I3C IBI. 86 87Low-power mode 88============== 89 90The device enters low-power mode on idle to save power. Enabling an event puts 91the device out of the low-power since the ADC autonomously samples to assert 92the event condition. 93 94IIO trigger support 95=================== 96 97An IIO trigger ``ad4062-devX`` is registered by the driver to be used by the 98same device, to capture samples to a software buffer. It is required to attach 99the trigger to the device by setting the ``current_trigger`` before enabling 100and reading the buffer. 101 102The acquisition is sequential and bounded by the protocol timings, software 103latency and internal timings, the sample rate is not configurable. The burst 104averaging mode does impact the effective sample rate, since it increases the 105internal timing to output a single sample. 106 107Threshold events 108================ 109 110The ADC supports a monitoring mode to raise threshold events. The driver 111supports a single interrupt for both rising and falling readings. 112 113The feature is enabled/disabled by setting ``thresh_either_en``. During monitor 114mode, the device continuously operates in autonomous mode. Any register access 115puts the device back in configuration mode, due to this, any access disables 116monitor mode. 117 118The following event attributes are available: 119 120.. list-table:: Event attributes 121 :header-rows: 1 122 123 * - Attribute 124 - Description 125 * - ``sampling_frequency`` 126 - Frequency used in the monitoring mode, sets the device internal sample 127 rate when the mode is activated. 128 * - ``sampling_frequency_available`` 129 - List of available sample rates. 130 * - ``thresh_either_en`` 131 - Enable monitoring mode. 132 * - ``thresh_falling_hysteresis`` 133 - Set the hysteresis value for the minimum threshold. 134 * - ``thresh_falling_value`` 135 - Set the minimum threshold value. 136 * - ``thresh_rising_hysteresis`` 137 - Set the hysteresis value for the maximum threshold. 138 * - ``thresh_rising_value`` 139 - Set the maximum threshold value. 140 141GPO controller support 142====================== 143 144The device supports using GP0 and GP1 as GPOs. If the devicetree contains the 145node ``gpio-controller```, the device is marked as a GPIO controller and the 146GPs not listed in ``interrupt-names`` are exposed as a GPO. The GPIO index 147matches the pin name, so if GP0 is not exposed but GP1 is, index 0 is masked 148out and only index 1 can be set. 149