iio: adc: stm32-adc: smart calibration support
authorOlivier Moysan <olivier.moysan@foss.st.com>
Tue, 15 Nov 2022 10:31:21 +0000 (11:31 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 23 Nov 2022 20:56:13 +0000 (20:56 +0000)
commit9d901e356c8d3640940cb72ff7969f03e85c2e95
tree099e7abca6dbeb36c793e40fcf997c4e5e73bb5a
parentf237cf1914e24ebba88670ecc36e8209c888c9a2
iio: adc: stm32-adc: smart calibration support

Add smart calibration support for STM32MP1.
- STM32MP15x: both linear & offset calibration are supported
- STM32MP13x: Only offset calibration is supported

Linear calibration:
Linear calibration is SoC dependent and does not change over time
so it can be done only once.
Linear calibration may have already been done in u-boot.
Skip calibration execution if calibration data are already available.
Save calibration factors in private data and restore them from private
data on next ADC start.

Offset calibration:
This calibration may vary over time, depending on temperature or voltage.
Run offset single-ended and differential calibration on each ADC start,
as it is not time consuming. This calibration do not need to be saved.
So, remove calfact_s and calfact_d value and bitfields that are no
longer used.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20221115103124.70074-2-olivier.moysan@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/stm32-adc-core.h
drivers/iio/adc/stm32-adc.c