From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: "Michael Hennerich" <michael.hennerich@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Angelo Dureghello" <adureghello@baylibre.com>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: ad7380: fix SPI offload trigger rate
Date: Sat, 27 Sep 2025 16:54:55 +0100 [thread overview]
Message-ID: <20250927165455.19ebefd5@jic23-huawei> (raw)
In-Reply-To: <20250919-iio-adc-ad7380-fix-sampling-frequency-for-single-ended-chips-v1-1-7b2d761766cf@baylibre.com>
On Fri, 19 Sep 2025 15:50:34 -0500
David Lechner <dlechner@baylibre.com> wrote:
> Add a special case to double the SPI offload trigger rate when all
> channels of a single-ended chip are enabled in a buffered read.
>
> The single-ended chips in the AD738x family can only do simultaneous
> sampling of half their channels and have a multiplexer to allow reading
> the other half. To comply with the IIO definition of sampling_frequency,
> we need to trigger twice as often when the sequencer is enabled to so
> that both banks can be read in a single sample period.
>
> Fixes: bbeaec81a03e ("iio: ad7380: add support for SPI offload")
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Applied to my temporary fixes branch (always fun at this point in cycle).
It'll become the normal fixes branch after rc1.
J
> ---
> There was some unresolved discussion about this when we were adding
> SPI offload support to the ad7380 driver, but it turns out that handling
> the sampling frequency correctly for single-ended chips is actually
> quite simple.
> ---
> drivers/iio/adc/ad7380.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
> index fa251dc1aae6ab0a0d36792fa37b2cc22b99dfe6..bfd908deefc0f40b42bd8a44bfce7a2510b2fdf1 100644
> --- a/drivers/iio/adc/ad7380.c
> +++ b/drivers/iio/adc/ad7380.c
> @@ -1227,6 +1227,14 @@ static int ad7380_offload_buffer_postenable(struct iio_dev *indio_dev)
> if (ret)
> return ret;
>
> + /*
> + * When the sequencer is required to read all channels, we need to
> + * trigger twice per sample period in order to read one complete set
> + * of samples.
> + */
> + if (st->seq)
> + config.periodic.frequency_hz *= 2;
> +
> ret = spi_offload_trigger_enable(st->offload, st->offload_trigger, &config);
> if (ret)
> spi_unoptimize_message(&st->offload_msg);
>
> ---
> base-commit: 561285d048053fec8a3d6d1e3ddc60df11c393a0
> change-id: 20250919-iio-adc-ad7380-fix-sampling-frequency-for-single-ended-chips-05bbfea8891c
>
> Best regards,
prev parent reply other threads:[~2025-09-27 15:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 20:50 [PATCH] iio: adc: ad7380: fix SPI offload trigger rate David Lechner
2025-09-27 15:54 ` Jonathan Cameron [this message]
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=20250927165455.19ebefd5@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=adureghello@baylibre.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=nuno.sa@analog.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