* [PATCH v2 0/2] Keep imx93 ADC works even calibration failed.
@ 2025-08-12 8:04 Haibo Chen
2025-08-12 8:04 ` [PATCH v2 1/2] iio: adc: imx93_adc: keep one style of the hex values Haibo Chen
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Haibo Chen @ 2025-08-12 8:04 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
primoz.fiser
Cc: linux-iio, imx, linux-arm-kernel, linux-kernel, Haibo Chen
imx93 ADC calibration has requirement for reference voltage:
ADC reference voltage Noise < 1.8V * 1/2^ENOB
Some boards can't meet such requirement, ADC calibration failed on these
boards, and adc can't be used. This is not appropriate, board can't meet
this requirement do not means ADC can't work, just means ADC can't work
that accurate. Here add an optimization, keep adc works even calibration
failed.
Changes in V2:
- add patch 1 to keep one style of the hex values according to
Andy Shevchenko's suggestion.
- keep {} when give the calibration failed warning log.
For the register 0x3A0, it is a new added register in latest imx93 RM,
please refer to this link:
https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-9-processors/i-mx-93-applications-processor-family-arm-cortex-a55-ml-acceleration-power-efficient-mpu:i.MX93
Patch v1 also pass test on one customer board, refer to this topic:
https://patchwork.kernel.org/project/linux-iio/patch/20250710073905.1105417-2-primoz.fiser@norik.com/
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
Haibo Chen (2):
iio: adc: imx93_adc: keep one style of the hex values
iio: adc: imx93_adc: load calibrated values even calibration failed
drivers/iio/adc/imx93_adc.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
---
base-commit: 2674d1eadaa2fd3a918dfcdb6d0bb49efe8a8bb9
change-id: 20250812-adc-839e49d55da9
Best regards,
--
Haibo Chen <haibo.chen@nxp.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/2] iio: adc: imx93_adc: keep one style of the hex values
2025-08-12 8:04 [PATCH v2 0/2] Keep imx93 ADC works even calibration failed Haibo Chen
@ 2025-08-12 8:04 ` 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-16 13:28 ` [PATCH v2 0/2] Keep imx93 ADC works " Jonathan Cameron
2 siblings, 2 replies; 9+ messages in thread
From: Haibo Chen @ 2025-08-12 8:04 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
primoz.fiser
Cc: linux-iio, imx, linux-arm-kernel, linux-kernel, Haibo Chen
Use capital letters consistently for hex values.
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
drivers/iio/adc/imx93_adc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/imx93_adc.c b/drivers/iio/adc/imx93_adc.c
index 7feaafd2316f246bd0c32fea99309900b5c65099..8471737ac04a2bac0417a6397f20865f6a2c01ca 100644
--- a/drivers/iio/adc/imx93_adc.c
+++ b/drivers/iio/adc/imx93_adc.c
@@ -32,11 +32,11 @@
#define IMX93_ADC_PCDR0 0x100
#define IMX93_ADC_PCDR1 0x104
#define IMX93_ADC_PCDR2 0x108
-#define IMX93_ADC_PCDR3 0x10c
+#define IMX93_ADC_PCDR3 0x10C
#define IMX93_ADC_PCDR4 0x110
#define IMX93_ADC_PCDR5 0x114
#define IMX93_ADC_PCDR6 0x118
-#define IMX93_ADC_PCDR7 0x11c
+#define IMX93_ADC_PCDR7 0x11C
#define IMX93_ADC_CALSTAT 0x39C
/* ADC bit shift */
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] iio: adc: imx93_adc: load calibrated values even calibration failed
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 8:04 ` Haibo Chen
2025-08-12 8:45 ` Primoz Fiser
2025-08-12 16:16 ` Frank Li
2025-08-16 13:28 ` [PATCH v2 0/2] Keep imx93 ADC works " Jonathan Cameron
2 siblings, 2 replies; 9+ messages in thread
From: Haibo Chen @ 2025-08-12 8:04 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
primoz.fiser
Cc: linux-iio, imx, linux-arm-kernel, linux-kernel, Haibo Chen
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>
---
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] iio: adc: imx93_adc: load calibrated values even calibration failed
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
1 sibling, 1 reply; 9+ messages in thread
From: Primoz Fiser @ 2025-08-12 8:45 UTC (permalink / raw)
To: Haibo Chen, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam
Cc: linux-iio, imx, linux-arm-kernel, linux-kernel,
upstream@lists.phytec.de
Hi Haibo,
On 12. 08. 25 10:04, 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.
Reviewed-by: Primoz Fiser <primoz.fiser@norik.com>
Thanks for fixing this.
BR,
Primoz
>
> Signed-off-by: Haibo Chen <haibo.chen@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;
>
--
Primoz Fiser
phone: +386-41-390-545
email: primoz.fiser@norik.com
--
Norik systems d.o.o.
Your embedded software partner
Slovenia, EU
phone: +386-41-540-545
email: info@norik.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] iio: adc: imx93_adc: keep one style of the hex values
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
1 sibling, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2025-08-12 9:06 UTC (permalink / raw)
To: Haibo Chen
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
primoz.fiser, linux-iio, imx, linux-arm-kernel, linux-kernel
On Tue, Aug 12, 2025 at 10:05 AM Haibo Chen <haibo.chen@nxp.com> wrote:
>
> Use capital letters consistently for hex values.
Suggested-by?
Reviewed-by: Andy Shevchenko <andy@kernel.org>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] iio: adc: imx93_adc: load calibrated values even calibration failed
2025-08-12 8:45 ` Primoz Fiser
@ 2025-08-12 15:53 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2025-08-12 15:53 UTC (permalink / raw)
To: Primoz Fiser
Cc: Haibo Chen, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, linux-iio, imx, linux-arm-kernel, linux-kernel,
upstream@lists.phytec.de
On Tue, 12 Aug 2025 10:45:48 +0200
Primoz Fiser <primoz.fiser@norik.com> wrote:
> Hi Haibo,
>
> On 12. 08. 25 10:04, 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.
>
> Reviewed-by: Primoz Fiser <primoz.fiser@norik.com>
>
> Thanks for fixing this.
>
> BR,
> Primoz
>
> >
> > Signed-off-by: Haibo Chen <haibo.chen@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.
result
If nothing else comes up I'll probably just fix that whilst applying.
Jonathan
> > + */
> > dev_warn(adc->dev, "ADC calibration failed!\n");
> > - imx93_adc_power_down(adc);
> > - return -EAGAIN;
> > }
> >
> > return 0;
> >
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] iio: adc: imx93_adc: keep one style of the hex values
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
1 sibling, 0 replies; 9+ messages in thread
From: Frank Li @ 2025-08-12 16:14 UTC (permalink / raw)
To: Haibo Chen
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
primoz.fiser, linux-iio, imx, linux-arm-kernel, linux-kernel
On Tue, Aug 12, 2025 at 04:04:22PM +0800, Haibo Chen wrote:
> Use capital letters consistently for hex values.
>
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/iio/adc/imx93_adc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/adc/imx93_adc.c b/drivers/iio/adc/imx93_adc.c
> index 7feaafd2316f246bd0c32fea99309900b5c65099..8471737ac04a2bac0417a6397f20865f6a2c01ca 100644
> --- a/drivers/iio/adc/imx93_adc.c
> +++ b/drivers/iio/adc/imx93_adc.c
> @@ -32,11 +32,11 @@
> #define IMX93_ADC_PCDR0 0x100
> #define IMX93_ADC_PCDR1 0x104
> #define IMX93_ADC_PCDR2 0x108
> -#define IMX93_ADC_PCDR3 0x10c
> +#define IMX93_ADC_PCDR3 0x10C
> #define IMX93_ADC_PCDR4 0x110
> #define IMX93_ADC_PCDR5 0x114
> #define IMX93_ADC_PCDR6 0x118
> -#define IMX93_ADC_PCDR7 0x11c
> +#define IMX93_ADC_PCDR7 0x11C
> #define IMX93_ADC_CALSTAT 0x39C
>
> /* ADC bit shift */
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] iio: adc: imx93_adc: load calibrated values even calibration failed
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 16:16 ` Frank Li
1 sibling, 0 replies; 9+ messages in thread
From: Frank Li @ 2025-08-12 16:16 UTC (permalink / raw)
To: Haibo Chen
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
primoz.fiser, linux-iio, imx, linux-arm-kernel, linux-kernel
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
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/2] Keep imx93 ADC works even calibration failed.
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 8:04 ` [PATCH v2 2/2] iio: adc: imx93_adc: load calibrated values even calibration failed Haibo Chen
@ 2025-08-16 13:28 ` Jonathan Cameron
2 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2025-08-16 13:28 UTC (permalink / raw)
To: Haibo Chen
Cc: David Lechner, Nuno Sá, Andy Shevchenko, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
primoz.fiser, linux-iio, imx, linux-arm-kernel, linux-kernel
On Tue, 12 Aug 2025 16:04:21 +0800
Haibo Chen <haibo.chen@nxp.com> wrote:
> imx93 ADC calibration has requirement for reference voltage:
> ADC reference voltage Noise < 1.8V * 1/2^ENOB
>
> Some boards can't meet such requirement, ADC calibration failed on these
> boards, and adc can't be used. This is not appropriate, board can't meet
> this requirement do not means ADC can't work, just means ADC can't work
> that accurate. Here add an optimization, keep adc works even calibration
> failed.
>
> Changes in V2:
> - add patch 1 to keep one style of the hex values according to
> Andy Shevchenko's suggestion.
> - keep {} when give the calibration failed warning log.
>
> For the register 0x3A0, it is a new added register in latest imx93 RM,
> please refer to this link:
> https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-9-processors/i-mx-93-applications-processor-family-arm-cortex-a55-ml-acceleration-power-efficient-mpu:i.MX93
>
> Patch v1 also pass test on one customer board, refer to this topic:
> https://patchwork.kernel.org/project/linux-iio/patch/20250710073905.1105417-2-primoz.fiser@norik.com/
>
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Series applied to the togreg branch of iio.git.
I'll push that out as testing to get a bit of build coverage before
risking letting next see it.
Thanks,
Jonathan
> ---
> Haibo Chen (2):
> iio: adc: imx93_adc: keep one style of the hex values
> iio: adc: imx93_adc: load calibrated values even calibration failed
>
> drivers/iio/adc/imx93_adc.c | 22 +++++++++++++++++-----
> 1 file changed, 17 insertions(+), 5 deletions(-)
> ---
> base-commit: 2674d1eadaa2fd3a918dfcdb6d0bb49efe8a8bb9
> change-id: 20250812-adc-839e49d55da9
>
> Best regards,
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-08-16 13:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-08-16 13:28 ` [PATCH v2 0/2] Keep imx93 ADC works " Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).