[PATCH 2/2] iio: adc: imx93: Make calibration parameters configurable
Andy Shevchenko
andriy.shevchenko at intel.com
Thu Jul 10 02:22:46 PDT 2025
On Thu, Jul 10, 2025 at 09:39:04AM +0200, Primoz Fiser wrote:
>
> Make i.MX93 ADC calibration parameters:
> - AVGEN: Enable calibration averaging function,
> - NRSMPL: Select number of calibration samples,
> - TSAMP: Select sample time of calibration conversions,
>
> in the MCR register configurable with the corresponding device-tree
> properties:
> - nxp,calib-avg-en,
> - nxp,calib-nr-samples and
> - nxp,calib-t-sample.
...
> #include <linux/platform_device.h>
> #include <linux/pm_runtime.h>
> #include <linux/regulator/consumer.h>
> +#include <linux/property.h>
Keep it in order.
...
> + ret = device_property_read_u32(adc->dev, "nxp,calib-avg-en", &val);
> + if (!ret) {
> + if (val != 0 && val != 1) {
> + dev_err(adc->dev, "invalid nxp,calib-avg-en: %d\n", val);
> + return -EINVAL;
> + }
> + reg = val;
> + mcr &= ~IMX93_ADC_MCR_AVGEN_MASK;
> + mcr |= FIELD_PREP(IMX93_ADC_MCR_AVGEN_MASK, reg);
> + }
Please, since it's optional, do other way around.
val = $DEFAUTL;
device_property_read_u32(adc->dev, "nxp,calib-avg-en", &val);
FIELD_MODIFY(...)
Similar approach may be used for the other properties.
...
> + /* write calibration settings to MCR */
> + writel(mcr, adc->regs + IMX93_ADC_MCR);
Please, factor out this to the function, so we won't see the direct IO in the
->probe().
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list