From: Jonathan Cameron <jic23@kernel.org>
To: <alexandru.tachici@analog.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<devicetree@vger.kernel.org>, <robh+dt@kernel.org>
Subject: Re: [PATCH v2 0/2] iio: adc: ad7124: allow 16 channels
Date: Sat, 6 Feb 2021 15:30:37 +0000 [thread overview]
Message-ID: <20210206153037.1b497941@archlinux> (raw)
In-Reply-To: <20210204113551.68744-1-alexandru.tachici@analog.com>
On Thu, 4 Feb 2021 13:35:49 +0200
<alexandru.tachici@analog.com> wrote:
> From: Alexandru Tachici <alexandru.tachici@analog.com>
>
> AD7124-8 can have up to 16 pseudo-differential channels
> enabled simultaneously and only 8 configurations.
I'm curious. Datasheet says up to 15 pseudo differential
channels. I can't immediate see why though!
> In this
> scenario we cannot assign one configuration per channel,
> some channels will have to share configurations like, ODR,
> gain and filter parameters.
>
> Allow the user to specify channels and configurations
> separately in device-tree and assign, if needed, the same
> configuration to multiple channels.
>
> If two channels share the configuration changing the
> sampling rate of one will change the sampling rate of the
> other too.
I can see why you want to do this via device tree to keep
things simple, but it does sort of feel like it might be
something we 'should' be configuring from userspace.
This is unlike the whether the channels should be differential
or not in the first place (which is mostly down to what they
are wired up to). It's a little bit of a mess as some things
like the reference are in the 8 config registers and we
already have those in the per channel description.
I'm trying to get my head around how we might do this in
the ideal case.
So what we'd want would be:
1) Userspace to not have to care about this restriction if
whatever it requests is 'possible'.
2) If multiple channels have the same config, then we'd want
to 'pack' them into the same configuration register.
3) Be as flexible as possible.
The problem is we don't have any way in the ABI of making
atomic adjustments to multiple parameters, but perhaps it
'could' be made to work as follows.
1) All settings go through a level of indirection - i.e. we
cache them in the driver and only apply them as needed.
2) Sysfs raw reads work on a basis of LRU + packing where we
can. (or we just use one config and pay the cost of
switching every time)
3) Buffered reads. We check whether the requested
configuration of all channels is possible and set it up if
so. Otherwise we return -EBUSY or similar to indicate
that what is currently requested can't be done.
Hence we make it atomic at the point of enable.
Most of the time, I'm going to assume that users either have
a carefully crafted optimum setup for their system in which
case they can read the datasheet to figure out what is possible
or they want to have a small number of groups of channels
where it makes sense to replicate configuration because they
are reading the 'same sort of thing'.
Perhaps just pushing all this to dt is fine, but I'm not that
keep on it if there is a reasonable way to avoid it.
Things like filter selections and calibration offsets shouldn't
be influenced by DT (by putting them in shared groups like
this series does).
These are weirdly flexible devices (what fun!) :)
Jonathan
>
> Alexandru Tachici (2):
> iio: adc: ad7124: allow 16 channels
> dt-bindings: iio: adc: ad7124: add config nodes
>
> .../bindings/iio/adc/adi,ad7124.yaml | 72 +++++--
> drivers/iio/adc/ad7124.c | 183 +++++++++++-------
> 2 files changed, 166 insertions(+), 89 deletions(-)
>
prev parent reply other threads:[~2021-02-06 15:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-04 11:35 [PATCH v2 0/2] iio: adc: ad7124: allow 16 channels alexandru.tachici
2021-02-04 11:35 ` [PATCH v2 1/2] " alexandru.tachici
2021-02-06 15:36 ` Jonathan Cameron
2021-02-04 11:35 ` [PATCH v2 2/2] dt-bindings: iio: adc: ad7124: add config nodes alexandru.tachici
2021-02-04 15:20 ` Rob Herring
2021-02-06 15:26 ` Jonathan Cameron
2021-02-08 16:06 ` Rob Herring
2021-02-06 15:30 ` 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=20210206153037.1b497941@archlinux \
--to=jic23@kernel.org \
--cc=alexandru.tachici@analog.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).