From: Jonathan Cameron <jic23@kernel.org>
To: Marcelo Schmitt <marcelo.schmitt@analog.com>
Cc: <linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<lars@metafoo.de>, <Michael.Hennerich@analog.com>,
<dlechner@baylibre.com>, <nuno.sa@analog.com>, <andy@kernel.org>,
<robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
<linus.walleij@linaro.org>, <brgl@bgdev.pl>,
<marcelo.schmitt1@gmail.com>
Subject: Re: [PATCH v4 06/11] iio: adc: ad4170: Add support for buffered data capture
Date: Sat, 7 Jun 2025 18:06:58 +0100 [thread overview]
Message-ID: <20250607180658.7db5271c@jic23-huawei> (raw)
In-Reply-To: <1e966af21b33b7dd969e1faa8126159c5dc501f7.1748829860.git.marcelo.schmitt@analog.com>
On Mon, 2 Jun 2025 08:38:46 -0300
Marcelo Schmitt <marcelo.schmitt@analog.com> wrote:
> Extend the AD4170 driver to allow buffered data capture in continuous read
> mode. In continuous read mode, the chip skips the instruction phase and
> outputs just ADC sample data, enabling faster sample rates to be reached.
> The internal channel sequencer always starts sampling from channel 0 and
> channel 0 must be enabled if more than one channel is selected for data
> capture. The scan mask validation callback checks if the aforementioned
> condition is met.
>
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
A comment inline about possibly relaxing the channel 0 constraint
as far as userspace is concerned anyway. Not necessary for now though.
> diff --git a/drivers/iio/adc/ad4170.c b/drivers/iio/adc/ad4170.c
> index 3d83c3ace569..86ef70acbf21 100644
> --- a/drivers/iio/adc/ad4170.c
> +++ b/drivers/iio/adc/ad4170.c
> @@ -13,7 +13,11 @@
> +static bool ad4170_validate_scan_mask(struct iio_dev *indio_dev,
> + const unsigned long *scan_mask)
> +{
> + unsigned int masklength = iio_get_masklength(indio_dev);
If this becomes a useability issue we could probably generative appropriate
available_scan_masks entries and let the demuxer in the IIO core deal with
dropping the unwanted first channel. That might be preferable to just
failing if the channel isn't enabled.
As a general rule, I think we've always used validate_scan_mask
to prevent too many channels being turned on, or incompatible sets of channels
rather than to prevent too few being enabled.
Anyhow that would be a relaxation of constraints so can be done if it
turns out to be needed later.
> +
> + /*
> + * The channel sequencer cycles through the enabled channels in
> + * sequential order, from channel 0 to channel 15, bypassing disabled
> + * channels. When more than one channel is enabled, channel 0 must
> + * always be enabled. See datasheet channel_en register description at
> + * page 95.
> + */
> + if (bitmap_weight(scan_mask, masklength) > 1)
> + return test_bit(0, scan_mask);
> +
> + return bitmap_weight(scan_mask, masklength) == 1;
> +}
next prev parent reply other threads:[~2025-06-07 17:07 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-02 11:34 [PATCH v4 00/11] iio: adc: Add support for AD4170 series of ADCs Marcelo Schmitt
2025-06-02 11:36 ` [PATCH v4 01/11] dt-bindings: iio: adc: Add AD4170 Marcelo Schmitt
2025-06-02 12:23 ` Rob Herring (Arm)
2025-06-02 20:52 ` Marcelo Schmitt
2025-06-07 16:33 ` Jonathan Cameron
2025-06-07 16:45 ` Jonathan Cameron
2025-06-09 15:28 ` Marcelo Schmitt
2025-06-09 15:44 ` Jonathan Cameron
2025-06-02 11:36 ` [PATCH v4 02/11] iio: adc: Add basic support for AD4170 Marcelo Schmitt
2025-06-02 14:55 ` Andy Shevchenko
2025-06-02 16:54 ` Marcelo Schmitt
2025-06-03 8:27 ` Andy Shevchenko
2025-06-03 12:02 ` Marcelo Schmitt
2025-06-03 13:43 ` Andy Shevchenko
2025-06-07 16:59 ` Jonathan Cameron
2025-06-03 14:00 ` kernel test robot
2025-06-02 11:37 ` [PATCH v4 03/11] iio: adc: ad4170: Add support for calibration gain Marcelo Schmitt
2025-06-02 12:54 ` Andy Shevchenko
2025-06-02 11:37 ` [PATCH v4 04/11] iio: adc: ad4170: Add support for calibration bias Marcelo Schmitt
2025-06-02 11:38 ` [PATCH v4 05/11] iio: adc: ad4170: Add digital filter and sample frequency config support Marcelo Schmitt
2025-06-02 11:38 ` [PATCH v4 06/11] iio: adc: ad4170: Add support for buffered data capture Marcelo Schmitt
2025-06-07 17:06 ` Jonathan Cameron [this message]
2025-06-09 20:39 ` Marcelo Schmitt
2025-06-02 11:39 ` [PATCH v4 07/11] iio: adc: ad4170: Add clock provider support Marcelo Schmitt
2025-06-02 11:39 ` [PATCH v4 08/11] iio: adc: ad4170: Add GPIO controller support Marcelo Schmitt
2025-06-02 11:39 ` [PATCH v4 09/11] iio: adc: ad4170: Add support for internal temperature sensor Marcelo Schmitt
2025-06-02 11:40 ` [PATCH v4 10/11] iio: adc: ad4170: Add support for weigh scale and RTD sensors Marcelo Schmitt
2025-06-07 17:15 ` Jonathan Cameron
2025-06-02 11:40 ` [PATCH v4 11/11] iio: adc: ad4170: Add timestamp channel 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=20250607180658.7db5271c@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
--cc=marcelo.schmitt@analog.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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