You can configure the MCA ADC lines to act as an analog window comparator and generate an IRQ depending on the voltage level in the input. This feature allows applications to be notified of this event instead of needing to periodically poll the input for its value.
Since this is an extension on the ADC driver, reading the input is also possible by using the same sysfs entry. The same formulas, channel mapping, and voltage reference also apply.
The comparator can be seen as a digital output that depends on two limits or thresholds: when the input is between the two limits the comparator’s output will be 1, and 0 when it is outside of the limits. If only one limit is needed, then the higher threshold should be set above the maximum (4096) and use the lower one.
The image below helps to illustrate when the edges are generated. Basically, entering the window generates a rising edge, and leaving it generates a falling edge, regardless of which threshold was exceeded (upper or lower).
Device tree bindings and customization
The MCA ADC device tree binding is documented at
Documentation/devicetree/bindings/iio/adc/digi,mca-adc.txt
.
You can specify the list of channels you want to use as comparators with property digi,comparator-ch-list
.
Both adc-ch-list and comparator-ch-list properties are exclusive.
If a channel is mistakenly included in both, adc-ch-list has priority and the kernel logs a warning.
|
MCA-enabled ADC channels and voltage reference
This example shows how to enable the analog comparator on one MCA ADC channel using the property digi,comparator-ch-list
.
Rest of ADC channels are used as normal ADC channels.
The voltage reference property is the same for both ADCs and Comparators, refer to the ADC configuration chapter for more details on how to configure this property.
&mca_adc {
digi,adc-ch-list = <1 2 4>;
digi,comparator-ch-list = <3>;
digi,adc-vref = <3000000>;
};