From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: David Lechner <dlechner@baylibre.com>
Cc: Marcelo Schmitt <marcelo.schmitt@analog.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, devicetree@vger.kernel.org,
linux-spi@vger.kernel.org, jic23@kernel.org,
Michael.Hennerich@analog.com, nuno.sa@analog.com,
eblanc@baylibre.com, andy@kernel.org, corbet@lwn.net,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
broonie@kernel.org, Jonathan.Cameron@huawei.com,
andriy.shevchenko@linux.intel.com, ahaslam@baylibre.com,
sergiu.cuciurean@analog.com, tgamblin@baylibre.com
Subject: Re: [PATCH 07/15] iio: adc: ad4030: Add SPI offload support
Date: Tue, 2 Sep 2025 11:52:46 -0300 [thread overview]
Message-ID: <aLcEvmwbysTaEprV@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <b024bd46-f1bd-4d9f-9d91-15ba18b9864f@baylibre.com>
Hi David,
On 08/30, David Lechner wrote:
> On 8/29/25 7:42 PM, Marcelo Schmitt wrote:
> > AD4030 and similar ADCs can capture data at sample rates up to 2 mega
> > samples per second (MSPS). Not all SPI controllers are able to achieve
> > such high throughputs and even when the controller is fast enough to run
> > transfers at the required speed, it may be costly to the CPU to handle
> > transfer data at such high sample rates. Add SPI offload support for
> > AD4030 and similar ADCs so to enable ADC data capture at maximum sample
> > rates.
> >
...
> > +
> > +static int __ad4030_set_sampling_freq(struct ad4030_state *st, unsigned int freq)
> > +{
...
> > + do {
> > + conv_wf.duty_length_ns = target;
> > + ret = pwm_round_waveform_might_sleep(st->conv_trigger, &conv_wf);
> > + if (ret)
> > + return ret;
> > + target += 10;
> > + } while (conv_wf.duty_length_ns < 10);
> > +
> > + offload_period_ns = conv_wf.period_length_ns;
> > +
> > + ret = regmap_read(st->regmap, AD4030_REG_MODES, &mode);
> > + if (ret)
> > + return ret;
> > + if (FIELD_GET(AD4030_REG_MODES_MASK_OUT_DATA_MODE, mode) == AD4030_OUT_DATA_MD_30_AVERAGED_DIFF) {
>
> Since this depends on the oversampling ration, we need to defer this
> until we start a buffered read. Otherwise if someone sets sampling
> frequency first and the changes the oversampling ratio later, then
> the PWM period will not be correct.
>
Yes, that's one of the problems I noticed when testing yesterday and probably
the reason why I initially thought the scale was buggy for averaging/oversampling.
> Alternatly, we could update this both when sampling freqency and
> when oversampling ratio are updated. This would allow returning an
> error if the oversampling ratio is too big for the requested
> sampling frequency.
>
Sure, this sounds to be the best way of keeping track of the sampling frequency
and oversampling ratio combination. Otherwise, unadvised users (like me) could
set the oversampling ratio then run transfers without the driver being able to
update the CNV trigger waveform according to the number of samples to average.
The result of that is the device doesn't do oversampling (despite the
oversampling attribute value).
I also see your comments to this and other patches and I think I agree with them
all. Will re-spin to apply the requested changes and provide support for SPI
related stuff in a separate series.
Thanks,
Marcelo
next prev parent reply other threads:[~2025-09-02 14:52 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-30 0:39 [PATCH 00/15] Add SPI offload support to AD4030 Marcelo Schmitt
2025-08-30 0:40 ` [PATCH 01/15] iio: adc: ad4030: Fix _scale for when oversampling is enabled Marcelo Schmitt
2025-08-30 5:00 ` Andy Shevchenko
2025-08-30 18:43 ` Jonathan Cameron
2025-08-30 18:48 ` David Lechner
2025-09-02 13:18 ` Marcelo Schmitt
2025-08-30 0:40 ` [PATCH 02/15] dt-bindings: iio: adc: adi,ad4030: Reference spi-peripheral-props Marcelo Schmitt
2025-08-30 0:41 ` [PATCH 03/15] Documentation: iio: ad4030: Add double PWM SPI offload doc Marcelo Schmitt
2025-08-30 16:49 ` David Lechner
2025-08-30 0:41 ` [PATCH 04/15] dt-bindings: iio: adc: adi,ad4030: Add PWM Marcelo Schmitt
2025-08-30 0:42 ` [PATCH 05/15] spi: offload: types: add offset parameter Marcelo Schmitt
2025-08-30 5:01 ` Andy Shevchenko
2025-08-30 0:42 ` [PATCH 06/15] spi: spi-offload-trigger-pwm: Use duty offset Marcelo Schmitt
2025-08-30 5:02 ` Andy Shevchenko
2025-08-30 16:41 ` David Lechner
2025-08-30 0:42 ` [PATCH 07/15] iio: adc: ad4030: Add SPI offload support Marcelo Schmitt
2025-08-30 7:36 ` Andy Shevchenko
2025-08-30 12:08 ` kernel test robot
2025-08-30 19:11 ` Jonathan Cameron
2025-08-30 20:14 ` David Lechner
2025-09-02 14:52 ` Marcelo Schmitt [this message]
2025-08-30 0:43 ` [PATCH 08/15] dt-bindings: iio: adc: adi,ad4030: Add 4-lane per channel bus width option Marcelo Schmitt
2025-08-30 17:01 ` David Lechner
2025-08-30 0:43 ` [PATCH 09/15] iio: adc: ad4030: Support multiple data lanes per channel Marcelo Schmitt
2025-08-30 7:38 ` Andy Shevchenko
2025-08-30 17:19 ` David Lechner
2025-08-30 0:43 ` [PATCH 10/15] dt-bindings: iio: adc: adi,ad4030: Add adi,clock-mode Marcelo Schmitt
2025-08-30 18:02 ` David Lechner
2025-08-30 0:44 ` [PATCH 11/15] iio: adc: ad4030: Add clock mode option parse and setup Marcelo Schmitt
2025-08-30 7:42 ` Andy Shevchenko
2025-08-30 0:44 ` [PATCH 12/15] dt-bindings: iio: adc: adi,ad4030: Add adi,dual-data-rate Marcelo Schmitt
2025-08-30 17:27 ` David Lechner
2025-08-30 0:45 ` [PATCH 13/15] iio: adc: ad4030: Enable dual data rate Marcelo Schmitt
2025-08-30 7:46 ` Andy Shevchenko
2025-08-30 17:33 ` David Lechner
2025-08-30 0:45 ` [PATCH 14/15] dt-bindings: iio: adc: adi,ad4030: Add ADAQ4216 and ADAQ4224 Marcelo Schmitt
2025-08-30 18:45 ` David Lechner
2025-08-30 0:45 ` [PATCH 15/15] iio: adc: ad4030: Add support for " Marcelo Schmitt
2025-08-30 7:57 ` Andy Shevchenko
2025-09-02 15:22 ` Marcelo Schmitt
2025-08-30 19:17 ` David Lechner
2025-09-01 11:47 ` Dan Carpenter
2025-08-30 2:48 ` [PATCH 00/15] Add SPI offload support to AD4030 Marcelo Schmitt
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=aLcEvmwbysTaEprV@debian-BULLSEYE-live-builder-AMD64 \
--to=marcelo.schmitt1@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=ahaslam@baylibre.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=eblanc@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=marcelo.schmitt@analog.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=sergiu.cuciurean@analog.com \
--cc=tgamblin@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