From: Frank Li <Frank.li@nxp.com>
To: Haibo Chen <haibo.chen@nxp.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Shawn Guo" <shawnguo@kernel.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
primoz.fiser@norik.com, linux-iio@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] iio: adc: imx93_adc: load calibrated values even calibration failed
Date: Tue, 12 Aug 2025 12:16:44 -0400 [thread overview]
Message-ID: <aJto7EJhmkURzJaF@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250812-adc-v2-2-0260833f13b8@nxp.com>
On Tue, Aug 12, 2025 at 04:04:23PM +0800, Haibo Chen wrote:
> ADC calibration might fail because of the noise on reference voltage.
> To avoid calibration fail, need to meet the following requirement:
> ADC reference voltage Noise < 1.8V * 1/2^ENOB
>
> For the case which the ADC reference voltage on board do not meet
> the requirement, still load the calibrated values, so ADC can also
> work but maybe not that accurate.
>
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/iio/adc/imx93_adc.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/imx93_adc.c b/drivers/iio/adc/imx93_adc.c
> index 8471737ac04a2bac0417a6397f20865f6a2c01ca..17b0a2548b0a3614ac537b01e28bc3144d17d6fc 100644
> --- a/drivers/iio/adc/imx93_adc.c
> +++ b/drivers/iio/adc/imx93_adc.c
> @@ -38,6 +38,7 @@
> #define IMX93_ADC_PCDR6 0x118
> #define IMX93_ADC_PCDR7 0x11C
> #define IMX93_ADC_CALSTAT 0x39C
> +#define IMX93_ADC_CALCFG0 0x3A0
>
> /* ADC bit shift */
> #define IMX93_ADC_MCR_MODE_MASK BIT(29)
> @@ -58,6 +59,8 @@
> #define IMX93_ADC_IMR_ECH_MASK BIT(0)
> #define IMX93_ADC_PCDR_CDATA_MASK GENMASK(11, 0)
>
> +#define IMX93_ADC_CALCFG0_LDFAIL_MASK BIT(4)
> +
> /* ADC status */
> #define IMX93_ADC_MSR_ADCSTATUS_IDLE 0
> #define IMX93_ADC_MSR_ADCSTATUS_POWER_DOWN 1
> @@ -145,7 +148,7 @@ static void imx93_adc_config_ad_clk(struct imx93_adc *adc)
>
> static int imx93_adc_calibration(struct imx93_adc *adc)
> {
> - u32 mcr, msr;
> + u32 mcr, msr, calcfg;
> int ret;
>
> /* make sure ADC in power down mode */
> @@ -158,6 +161,11 @@ static int imx93_adc_calibration(struct imx93_adc *adc)
>
> imx93_adc_power_up(adc);
>
> + /* Enable loading of calibrated values even in fail condition */
> + calcfg = readl(adc->regs + IMX93_ADC_CALCFG0);
> + calcfg |= IMX93_ADC_CALCFG0_LDFAIL_MASK;
> + writel(calcfg, adc->regs + IMX93_ADC_CALCFG0);
> +
> /*
> * TODO: we use the default TSAMP/NRSMPL/AVGEN in MCR,
> * can add the setting of these bit if need in future.
> @@ -180,9 +188,13 @@ static int imx93_adc_calibration(struct imx93_adc *adc)
> /* check whether calbration is success or not */
> msr = readl(adc->regs + IMX93_ADC_MSR);
> if (msr & IMX93_ADC_MSR_CALFAIL_MASK) {
> + /*
> + * Only give warning here, this means the noise of the
> + * reference voltage do not meet the requirement:
> + * ADC reference voltage Noise < 1.8V * 1/2^ENOB
> + * And the resault of ADC is not that accurate.
> + */
> dev_warn(adc->dev, "ADC calibration failed!\n");
> - imx93_adc_power_down(adc);
> - return -EAGAIN;
> }
>
> return 0;
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-08-12 19:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 8:04 [PATCH v2 0/2] Keep imx93 ADC works even calibration failed Haibo Chen
2025-08-12 8:04 ` [PATCH v2 1/2] iio: adc: imx93_adc: keep one style of the hex values Haibo Chen
2025-08-12 9:06 ` Andy Shevchenko
2025-08-12 16:14 ` Frank Li
2025-08-12 8:04 ` [PATCH v2 2/2] iio: adc: imx93_adc: load calibrated values even calibration failed Haibo Chen
2025-08-12 8:45 ` Primoz Fiser
2025-08-12 15:53 ` Jonathan Cameron
2025-08-12 16:16 ` Frank Li [this message]
2025-08-16 13:28 ` [PATCH v2 0/2] Keep imx93 ADC works " Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aJto7EJhmkURzJaF@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=festevam@gmail.com \
--cc=haibo.chen@nxp.com \
--cc=imx@lists.linux.dev \
--cc=jic23@kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=primoz.fiser@norik.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox