2024-03-20 10:40:51

by Andrej Picej

[permalink] [raw]
Subject: [PATCH 0/2] i.MX93 ADC calibration settings

Hi all,

we had some problems with failing ADC calibration on the i.MX93 boards.
Changing default calibration settings fixed this. The board where this
patches are useful is not yet upstream but will be soon (hopefully).

Since we had these patches laying around we thought they might also be
useful for someone else.

Best regards,
Andrej

Andrej Picej (2):
iio: adc: imx93: Make calibration properties configurable
dt-bindings: iio: adc: nxp,imx93-adc.yaml: Add calibration properties

.../bindings/iio/adc/nxp,imx93-adc.yaml | 15 +++++
drivers/iio/adc/imx93_adc.c | 66 +++++++++++++++++--
2 files changed, 76 insertions(+), 5 deletions(-)

--
2.25.1



2024-03-20 10:41:07

by Andrej Picej

[permalink] [raw]
Subject: [PATCH 2/2] dt-bindings: iio: adc: nxp,imx93-adc.yaml: Add calibration properties

Document calibration properties and how to set them.

Signed-off-by: Andrej Picej <[email protected]>
---
.../bindings/iio/adc/nxp,imx93-adc.yaml | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/adc/nxp,imx93-adc.yaml b/Documentation/devicetree/bindings/iio/adc/nxp,imx93-adc.yaml
index dacc526dc695..64958be62a6a 100644
--- a/Documentation/devicetree/bindings/iio/adc/nxp,imx93-adc.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/nxp,imx93-adc.yaml
@@ -46,6 +46,21 @@ properties:
"#io-channel-cells":
const: 1

+ nxp,calib-avg-en:
+ description:
+ Enable or disable averaging of calibration time.
+ enum: [ 0, 1 ]
+
+ nxp,calib-nr-samples:
+ description:
+ Selects the number of averaging samples to be used during calibration.
+ enum: [ 16, 32, 128, 512 ]
+
+ nxp,calib-t-samples:
+ description:
+ Specifies the sample time of calibration conversions.
+ enum: [ 8, 16, 22, 32 ]
+
required:
- compatible
- reg
--
2.25.1


2024-03-20 21:42:00

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 2/2] dt-bindings: iio: adc: nxp,imx93-adc.yaml: Add calibration properties


On Wed, 20 Mar 2024 11:04:06 +0100, Andrej Picej wrote:
> Document calibration properties and how to set them.
>
> Signed-off-by: Andrej Picej <[email protected]>
> ---
> .../bindings/iio/adc/nxp,imx93-adc.yaml | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/iio/adc/nxp,imx93-adc.yaml: nxp,calib-avg-en: missing type definition
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/iio/adc/nxp,imx93-adc.yaml: nxp,calib-nr-samples: missing type definition
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/iio/adc/nxp,imx93-adc.yaml: nxp,calib-t-samples: missing type definition

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


2024-03-22 06:48:29

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/2] dt-bindings: iio: adc: nxp,imx93-adc.yaml: Add calibration properties

Hi Andrej,

kernel test robot noticed the following build warnings:

[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on linus/master v6.8 next-20240322]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Andrej-Picej/iio-adc-imx93-Make-calibration-properties-configurable/20240320-184314
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link: https://lore.kernel.org/r/20240320100407.1639082-3-andrej.picej%40norik.com
patch subject: [PATCH 2/2] dt-bindings: iio: adc: nxp,imx93-adc.yaml: Add calibration properties
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20240322/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

dtcheck warnings: (new ones prefixed by >>)
Documentation/devicetree/bindings/net/snps,dwmac.yaml: mac-mode: missing type definition
>> Documentation/devicetree/bindings/iio/adc/nxp,imx93-adc.yaml: nxp,calib-avg-en: missing type definition
>> Documentation/devicetree/bindings/iio/adc/nxp,imx93-adc.yaml: nxp,calib-nr-samples: missing type definition
>> Documentation/devicetree/bindings/iio/adc/nxp,imx93-adc.yaml: nxp,calib-t-samples: missing type definition

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-03-24 14:00:04

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 0/2] i.MX93 ADC calibration settings

On Wed, 20 Mar 2024 11:04:04 +0100
Andrej Picej <[email protected]> wrote:

> Hi all,
>
> we had some problems with failing ADC calibration on the i.MX93 boards.
> Changing default calibration settings fixed this. The board where this
> patches are useful is not yet upstream but will be soon (hopefully).

Tell us more. My initial instinct is that this shouldn't be board specific.
What's the trade off we are making here? Time vs precision of calibration or
something else? If these are set to a level by default that doesn't work
for our board, maybe we should just change them for all devices?

Jonathan

>
> Since we had these patches laying around we thought they might also be
> useful for someone else.
>
> Best regards,
> Andrej
>
> Andrej Picej (2):
> iio: adc: imx93: Make calibration properties configurable
> dt-bindings: iio: adc: nxp,imx93-adc.yaml: Add calibration properties
>
> .../bindings/iio/adc/nxp,imx93-adc.yaml | 15 +++++
> drivers/iio/adc/imx93_adc.c | 66 +++++++++++++++++--
> 2 files changed, 76 insertions(+), 5 deletions(-)
>


2024-03-25 15:25:31

by Andrej Picej

[permalink] [raw]
Subject: Re: [PATCH 0/2] i.MX93 ADC calibration settings

Hi Jonathan,

On 24. 03. 24 14:55, Jonathan Cameron wrote:
> On Wed, 20 Mar 2024 11:04:04 +0100
> Andrej Picej <[email protected]> wrote:
>
>> Hi all,
>>
>> we had some problems with failing ADC calibration on the i.MX93 boards.
>> Changing default calibration settings fixed this. The board where this
>> patches are useful is not yet upstream but will be soon (hopefully).
>
> Tell us more. My initial instinct is that this shouldn't be board specific.
> What's the trade off we are making here? Time vs precision of calibration or
> something else? If these are set to a level by default that doesn't work
> for our board, maybe we should just change them for all devices?
>

So we have two different boards with the same SoC. On one, the
calibration works with the default values, on the second one the
calibration fails, which makes the ADC unusable. What the ADC lines
measure differ between the boards though. But the implementation is
nothing out of the ordinary.

We tried different things but the only thing that helped is to use
different calibration properties. We tried deferring the probe and
calibration until later boot and after boot, but it did not help.

In the Reference Manual [1] (chapter 72.5.1) it is written:

> 4. Configure desired calibration settings (default values kept for highest accuracy maximum time).

So your assumption is correct, longer calibration time (more averaging
samples) -> higher precision. The default values go for a high accuracy.
And since we use a NRSMPL (Number of Averaging Samples) of 32 instead of
default 512, we reduce the accuracy so the calibration values pass the
internal defined limits.

I'm not sure that changing default values is the right solution here. We
saw default values work with one of the boards. And since the NXP kept
these values adjustable I think there is a reason behind it.

Note: When I say one of the boards I mean one board form. So same board
version, but different HW.

Best regards,
Andrej

[1] i.MX 93 Applications Processor Reference Manual, Rev. 4, 12/2023