From: "Nuno Sá" <noname.nuno@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 6/6] iio: adc: ad7124: Implement system calibration
Date: Wed, 19 Feb 2025 10:45:17 +0000 [thread overview]
Message-ID: <dcf3c98a415743b0078dfb3de8acebcdc8b2b006.camel@gmail.com> (raw)
In-Reply-To: <5ee955a72e6f5226233053a883e8897ae325b568.1739902968.git.u.kleine-koenig@baylibre.com>
On Tue, 2025-02-18 at 19:31 +0100, Uwe Kleine-König wrote:
> Allow triggering both zero-scale and full-scale calibration via sysfs in
> the same way as it's done for ad7173.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---
> drivers/iio/adc/ad7124.c | 141 ++++++++++++++++++++++++++++++++++-----
> 1 file changed, 124 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> index 5c2e5a518af3..ad14503e9797 100644
> --- a/drivers/iio/adc/ad7124.c
> +++ b/drivers/iio/adc/ad7124.c
> @@ -4,6 +4,9 @@
> *
> * Copyright 2018 Analog Devices Inc.
> */
> +
> +#define DEBUG
Leftover :)
- Nuno Sá
> +
> #include <linux/bitfield.h>
> #include <linux/bitops.h>
> #include <linux/clk.h>
> @@ -181,6 +184,7 @@ struct ad7124_channel {
> struct ad7124_channel_config cfg;
> unsigned int ain;
> unsigned int slot;
> + u8 syscalib_mode;
> };
>
> struct ad7124_state {
> @@ -202,23 +206,6 @@ struct ad7124_state {
> DECLARE_KFIFO(live_cfgs_fifo, struct ad7124_channel_config *,
> AD7124_MAX_CONFIGS);
> };
>
> -static const struct iio_chan_spec ad7124_channel_template = {
> - .type = IIO_VOLTAGE,
> - .indexed = 1,
> - .differential = 1,
> - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> - BIT(IIO_CHAN_INFO_SCALE) |
> - BIT(IIO_CHAN_INFO_OFFSET) |
> - BIT(IIO_CHAN_INFO_SAMP_FREQ) |
> - BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
> - .scan_type = {
> - .sign = 'u',
> - .realbits = 24,
> - .storagebits = 32,
> - .endianness = IIO_BE,
> - },
> -};
> -
> static struct ad7124_chip_info ad7124_chip_info_tbl[] = {
> [ID_AD7124_4] = {
> .name = "ad7124-4",
> @@ -903,6 +890,126 @@ static int ad7124_check_chip_id(struct ad7124_state *st)
> return 0;
> }
>
> +enum {
> + AD7124_SYSCALIB_ZERO_SCALE,
> + AD7124_SYSCALIB_FULL_SCALE,
> +};
> +
> +static ssize_t ad7124_write_syscalib(struct iio_dev *indio_dev,
> + uintptr_t private,
> + const struct iio_chan_spec *chan,
> + const char *buf, size_t len)
> +{
> + struct ad7124_state *st = iio_priv(indio_dev);
> + struct ad7124_channel *ch = &st->channels[chan->channel];
> + struct device *dev = &st->sd.spi->dev;
> + bool sys_calib;
> + int ret, mode;
> +
> + ret = kstrtobool(buf, &sys_calib);
> + if (ret)
> + return ret;
> +
> + mode = ch->syscalib_mode;
> + if (sys_calib) {
FWIW, I agree with both David's comments. Moreover, if we do not claim the IIO
lock in other drivers/devices during calibration I think we should be doing
that.
- Nuno Sá
next prev parent reply other threads:[~2025-02-19 10:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 18:31 [PATCH v2 0/6] iio: adc: ad{4130,7124,7173}: A few fixes and ad7124 calibration Uwe Kleine-König
2025-02-18 18:31 ` [PATCH v2 1/6] iio: adc: ad_sigma_delta: Disable channel after calibration Uwe Kleine-König
2025-02-18 18:31 ` [PATCH v2 2/6] iio: adc: ad4130: Fix comparison of channel setups Uwe Kleine-König
2025-02-18 19:18 ` David Lechner
2025-02-19 8:53 ` Andy Shevchenko
2025-02-19 15:54 ` Uwe Kleine-König
2025-02-18 18:31 ` [PATCH v2 3/6] iio: adc: ad7124: Fix comparison of channel configs Uwe Kleine-König
2025-02-18 18:31 ` [PATCH v2 4/6] iio: adc: ad7173: " Uwe Kleine-König
2025-02-18 18:31 ` [PATCH v2 5/6] iio: adc: ad7124: Implement internal calibration at probe time Uwe Kleine-König
2025-02-22 14:44 ` Jonathan Cameron
2025-02-18 18:31 ` [PATCH v2 6/6] iio: adc: ad7124: Implement system calibration Uwe Kleine-König
2025-02-18 19:37 ` David Lechner
2025-02-21 18:23 ` Uwe Kleine-König
2025-02-19 10:45 ` Nuno Sá [this message]
2025-02-22 14:48 ` [PATCH v2 0/6] iio: adc: ad{4130,7124,7173}: A few fixes and ad7124 calibration 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=dcf3c98a415743b0078dfb3de8acebcdc8b2b006.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.com \
/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