[PATCH v9 0/7] iio: adc: add ad7606 calibration support

Angelo Dureghello posted 7 patches 6 months, 1 week ago
Documentation/ABI/testing/sysfs-bus-iio            |  24 ++
.../devicetree/bindings/iio/adc/adi,ad7606.yaml    |  29 ++
drivers/iio/adc/ad7606.c                           | 351 ++++++++++++++++-----
drivers/iio/adc/ad7606.h                           |  22 +-
drivers/iio/industrialio-core.c                    |   1 +
include/linux/iio/types.h                          |   1 +
6 files changed, 347 insertions(+), 81 deletions(-)
[PATCH v9 0/7] iio: adc: add ad7606 calibration support
Posted by Angelo Dureghello 6 months, 1 week ago
Add gain, offset and phase (as a delay) calibration support, for
ad7606b, ad7606c16 and ad7606c18.

Calibration is available for devices with software mode capability. 

Offset and phase calibration is configurable by sysfs attributes, while
gain calibration value in ohms must match the external RFilter value,
when an external RFilter is available, so implemented through a specific
devicetree "adi,rfilter-ohms" property.

This patchset depends on:
https://lore.kernel.org/linux-iio/20250505131544.0a7477a2@jic23-huawei/

Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
Changes in v9:
- add patch 6/7 changing chan_scale to a more generic chan_info, 
- parse gain fdt property in existing function, to reduce code.
- Link to v8: https://lore.kernel.org/r/20250603-wip-bl-ad7606-calibration-v8-0-2371e7108f32@baylibre.com

Changes in v8:
- fix bug related to wrong calib gain setup,
- fix return value on wrong "reg" read from fdt on calib setup,
- fix commit messages/titles,
- add new function to write calib gain on ADC registers after reset.
- Link to v7: https://lore.kernel.org/r/20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com

Changes in v7:
- Fix each wrong commit desc. occurence related to convdelay.
- Fix ABI documentation with better words.
- Fix wrong comments in driver source code.
- Add r_gain default before reading the fdt value.
- Link to v6: https://lore.kernel.org/r/20250522-wip-bl-ad7606-calibration-v6-0-487b90433da0@baylibre.com

Changes in v6:
- exit for error in case of fdt that breaks the dt_schema,
- add (5/6) patch to fix the above on older code too, 
- Link to v5: https://lore.kernel.org/r/20250519-wip-bl-ad7606-calibration-v5-0-4054fc7c9f3d@baylibre.com

Changes in v5:
- fix tab/spaces wrong formatting on ABI doc (1/5),
- fix description in ABI doc (1/5),
- fix code multiline alignments (3/5),
- fix calibration offset calculation as oneliner expression (3/5), 
- Link to v4: https://lore.kernel.org/r/20250508-wip-bl-ad7606-calibration-v4-0-91a3f2837e6b@baylibre.com

Changes in v4:
- fix ad7606_chan_calib_gain_setup appropriately to be called once.
- Link to v3: https://lore.kernel.org/r/20250506-wip-bl-ad7606-calibration-v3-0-6eb7b6e72307@baylibre.com

Changes in v3:
- fix dt_bindings,
- change sysfs calib_delay to convdelay,
- fix sysfs documentation accordingly,
- used u32 for reg and r_gain,
- used DIV_ROUND_CLOSEST for setting r_gain,
- minor syntax fixes,
- Link to v2: https://lore.kernel.org/r/20250502-wip-bl-ad7606-calibration-v2-0-174bd0af081b@baylibre.com

Changes in v2:
- change phase_delay to calib_delay,
- fix dt_bindings,
- fix gain calibarion fdt parsing,
- fix ad7606c-18 calib offset range,
- fix calib offset calculation,
- fix calib gain range,
- Link to v1: https://lore.kernel.org/r/20250429-wip-bl-ad7606-calibration-v1-0-eb4d4821b172@baylibre.com

---
Angelo Dureghello (7):
      Documentation: ABI: IIO: add new convdelay documentation
      iio: core: add ADC delay calibration definition
      iio: adc: ad7606: add offset and phase calibration support
      dt-bindings: iio: adc: adi,ad7606: add gain calibration support
      iio: adc: ad7606: exit for invalid fdt dt_schema properties
      iio: adc: ad7606: rename chan_scale to a more generic chan_info
      iio: adc: ad7606: add gain calibration support

 Documentation/ABI/testing/sysfs-bus-iio            |  24 ++
 .../devicetree/bindings/iio/adc/adi,ad7606.yaml    |  29 ++
 drivers/iio/adc/ad7606.c                           | 351 ++++++++++++++++-----
 drivers/iio/adc/ad7606.h                           |  22 +-
 drivers/iio/industrialio-core.c                    |   1 +
 include/linux/iio/types.h                          |   1 +
 6 files changed, 347 insertions(+), 81 deletions(-)
---
base-commit: 351e9e8549a49300e674fc562b4b2a7e4bd74a66
change-id: 20250429-wip-bl-ad7606-calibration-20a396a60352

Best regards,
-- 
Angelo Dureghello <adureghello@baylibre.com>
Re: [PATCH v9 0/7] iio: adc: add ad7606 calibration support
Posted by Andy Shevchenko 6 months, 1 week ago
On Fri, Jun 06, 2025 at 04:19:15PM +0200, Angelo Dureghello wrote:
> Add gain, offset and phase (as a delay) calibration support, for
> ad7606b, ad7606c16 and ad7606c18.
> 
> Calibration is available for devices with software mode capability. 
> 
> Offset and phase calibration is configurable by sysfs attributes, while
> gain calibration value in ohms must match the external RFilter value,
> when an external RFilter is available, so implemented through a specific
> devicetree "adi,rfilter-ohms" property.

FWIW,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v9 0/7] iio: adc: add ad7606 calibration support
Posted by Jonathan Cameron 6 months, 1 week ago
On Fri, 6 Jun 2025 22:14:19 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Fri, Jun 06, 2025 at 04:19:15PM +0200, Angelo Dureghello wrote:
> > Add gain, offset and phase (as a delay) calibration support, for
> > ad7606b, ad7606c16 and ad7606c18.
> > 
> > Calibration is available for devices with software mode capability. 
> > 
> > Offset and phase calibration is configurable by sysfs attributes, while
> > gain calibration value in ohms must match the external RFilter value,
> > when an external RFilter is available, so implemented through a specific
> > devicetree "adi,rfilter-ohms" property.  
> 
> FWIW,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 

Applied to the testing branch of iio.git.  I'll rebase that on rc1
shortly and push out as togreg.

Thanks,

Jonathan
Re: [PATCH v9 0/7] iio: adc: add ad7606 calibration support
Posted by Jonathan Cameron 6 months, 1 week ago
On Sat, 7 Jun 2025 14:08:11 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Fri, 6 Jun 2025 22:14:19 +0300
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> 
> > On Fri, Jun 06, 2025 at 04:19:15PM +0200, Angelo Dureghello wrote:  
> > > Add gain, offset and phase (as a delay) calibration support, for
> > > ad7606b, ad7606c16 and ad7606c18.
> > > 
> > > Calibration is available for devices with software mode capability. 
> > > 
> > > Offset and phase calibration is configurable by sysfs attributes, while
> > > gain calibration value in ohms must match the external RFilter value,
> > > when an external RFilter is available, so implemented through a specific
> > > devicetree "adi,rfilter-ohms" property.    
> > 
> > FWIW,
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >   
> 
> Applied to the testing branch of iio.git.  I'll rebase that on rc1
> shortly and push out as togreg.
> 

I just saw that David gave non trivial feedback on v8.
I'll keep this queued up but I'm happy to rebase if we do need to make
any additional tweaks (or to add tags if appropriate!)

Jonathan

> Thanks,
> 
> Jonathan