From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: Jonathan Santos <Jonathan.Santos@analog.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
lars@metafoo.de, Michael.Hennerich@analog.com,
nuno.sa@analog.com, andy@kernel.org, jonath4nns@gmail.com
Subject: Re: [PATCH v2 4/4] iio: adc: ad7768-1: add support for SPI offload
Date: Sun, 1 Mar 2026 12:10:11 +0000 [thread overview]
Message-ID: <20260301121011.4b5d2238@jic23-huawei> (raw)
In-Reply-To: <ca6f9ec7-ec58-4628-b41a-c2e4beb67777@baylibre.com>
On Sat, 28 Feb 2026 11:18:22 -0600
David Lechner <dlechner@baylibre.com> wrote:
> On 2/23/26 5:59 AM, Jonathan Santos wrote:
> > The AD7768-1 family supports sampling rates up to 1 MSPS, which exceeds
> > the capabilities of conventional triggered buffer operations due to SPI
> > transaction overhead and interrupt latency.
> >
>
> ...
>
> > +static int ad7768_offload_buffer_postenable(struct iio_dev *indio_dev)
> > +{
> > + struct ad7768_state *st = iio_priv(indio_dev);
> > + struct spi_offload_trigger_config config = {
> > + .type = SPI_OFFLOAD_TRIGGER_DATA_READY,
> > + };
> > + const struct iio_scan_type *scan_type;
> > + unsigned int unused;
> > + int ret;
> > +
> > + scan_type = iio_get_current_scan_type(indio_dev, &indio_dev->channels[0]);
> > + if (IS_ERR(scan_type))
> > + return PTR_ERR(scan_type);
> > +
> > + st->offload_xfer.len = spi_bpw_to_bytes(scan_type->realbits);
> > + st->offload_xfer.bits_per_word = scan_type->realbits;
> > + st->offload_xfer.offload_flags = SPI_OFFLOAD_XFER_RX_STREAM;
> > +
> > + spi_message_init_with_transfers(&st->offload_msg, &st->offload_xfer, 1);
> > + st->offload_msg.offload = st->offload;
> > +
> > + ret = spi_optimize_message(st->spi, &st->offload_msg);
> > + if (ret) {
> > + dev_err(&st->spi->dev, "failed to prepare offload, err: %d\n", ret);
> > + return ret;
> > + }
> > +
> > + /*
> > + * Write a 1 to the LSB of the INTERFACE_FORMAT register to enter
> > + * continuous read mode. Subsequent data reads do not require an
> > + * initial 8-bit write to query the ADC_DATA register.
> > + */
> > + ret = regmap_write(st->regmap, AD7768_REG_INTERFACE_FORMAT, 0x01);
> > + if (ret)
> > + goto err_unoptimize_message;
> > +
> > + ret = spi_offload_trigger_enable(st->offload, st->offload_trigger,
> > + &config);
> > + if (ret)
> > + goto err_exit_continuous_read_mode;
> > +
> > + return 0;
> > +
> > +err_exit_continuous_read_mode:
>
> I wouldn't mind a comment here explaining what this read does.
Given I'm not sure, Jonathan, can we have such a comment as a follow up patch please.
>
> > + regmap_read(st->regmap24, AD7768_REG24_ADC_DATA, &unused);
> > +
> > +err_unoptimize_message:
> > + spi_unoptimize_message(&st->offload_msg);
> > +
> > + return ret;
> > +}
>
> ...
>
> > +static bool ad7768_offload_trigger_match(struct spi_offload_trigger *trigger,
> > + enum spi_offload_trigger_type type,
> > + u64 *args, u32 nargs)
> > +{
> > + if (type != SPI_OFFLOAD_TRIGGER_DATA_READY)
> > + return false;
> > +
> > + /* Requires 1 or 2 args to indicate the trigger output signal */
>
> Would be more clear to say "up to 2 args are allowed, but only 1 is used".
I tweaked this.
>
> > + if (nargs == 0 || nargs > 2 || args[0] != AD7768_TRIGGER_SOURCE_DRDY)
> > + return false;
> > +
> > + return true;
> > +}
> > +
next prev parent reply other threads:[~2026-03-01 12:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 11:59 [PATCH v2 0/4] iio: adc: ad7768-1: add SPI offload support and fixes Jonathan Santos
2026-02-23 11:59 ` [PATCH v2 1/4] iio: adc: ad7768-1: fix one-shot mode data acquisition Jonathan Santos
2026-02-23 11:59 ` [PATCH v2 2/4] iio: adc: ad7768-1: remove switch to one-shot mode Jonathan Santos
2026-02-23 11:59 ` [PATCH v2 3/4] iio: adc: ad7768-1: disable IRQ autoenable Jonathan Santos
2026-02-23 11:59 ` [PATCH v2 4/4] iio: adc: ad7768-1: add support for SPI offload Jonathan Santos
2026-02-23 13:46 ` Andy Shevchenko
2026-02-28 19:20 ` Jonathan Cameron
2026-02-28 17:18 ` David Lechner
2026-03-01 12:10 ` Jonathan Cameron [this message]
2026-02-28 17:19 ` [PATCH v2 0/4] iio: adc: ad7768-1: add SPI offload support and fixes David Lechner
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=20260301121011.4b5d2238@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Santos@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jonath4nns@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®