From: "Nuno Sá" <noname.nuno@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Esteban Blanc <eblanc@baylibre.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Nuno Sa <nuno.sa@analog.com>,
Jonathan Corbet <corbet@lwn.net>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
David Lechner <dlechner@baylibre.com>,
linux-doc@vger.kernel.org
Subject: Re: [PATCH 4/6] iio: adc: ad4030: add support for ad4630-24 and ad4630-16
Date: Mon, 16 Sep 2024 08:12:24 +0200 [thread overview]
Message-ID: <2b319d9453f4fe8842e4c306d9e2071ad031c0e7.camel@gmail.com> (raw)
In-Reply-To: <20240914122529.14759e63@jic23-huawei>
On Sat, 2024-09-14 at 12:25 +0100, Jonathan Cameron wrote:
> On Fri, 13 Sep 2024 15:46:17 +0200
> Nuno Sá <noname.nuno@gmail.com> wrote:
>
> > On Fri, 2024-09-13 at 12:55 +0000, Esteban Blanc wrote:
> > > On Fri Sep 13, 2024 at 10:18 AM UTC, Nuno Sá wrote:
> > > > On Fri, 2024-09-13 at 09:55 +0000, Esteban Blanc wrote:
> > > > > On Mon Aug 26, 2024 at 9:27 AM UTC, Jonathan Cameron wrote:
> > > > > > On Thu, 22 Aug 2024 14:45:20 +0200
> > > > > > Esteban Blanc <eblanc@baylibre.com> wrote:
> > > > > > > +static const unsigned long ad4630_channel_masks[] = {
> > > > > > > + /* Differential only */
> > > > > > > + BIT(0) | BIT(2),
> > > > > > > + /* Differential with common byte */
> > > > > > > + GENMASK(3, 0),
> > > > > > The packing of data isn't going to be good. How bad to shuffle
> > > > > > to put the two small channels next to each other?
> > > > > > Seems like it means you will want to combine your deinterleave
> > > > > > and channel specific handling above, which is a bit fiddly but
> > > > > > not much worse than current code.
> > > > >
> > > > > I can do it since that was what I had done in the RFC in the first place.
> > > > > Nuno asked for in this email
> > > > > https://lore.kernel.org/r/0036d44542f8cf45c91c867f0ddd7b45d1904d6b.camel@gmail.com/
> > > > > :
> > > > >
> > > > > > > > * You're pushing the CM channels into the end. So when we a 2 channel
> > > > > > > > device
> > > > > > > > we'll have:
> > > > >
> > > > > > > > in_voltage0 - diff
> > > > > > > > in_voltage1 - diff
> > > > > > > > in_voltage2 - CM associated with chan0
> > > > > > > > in_voltage0 - CM associated with chan1
> > > > > > > >
> > > > > > > > I think we could make it so the CM channel comes right after the
> > > > > > > > channel
> > > > > > > > where
> > > > > > > > it's data belongs too. So for example, odd channels would be CM
> > > > > > > > channels
> > > > > > > > (and
> > > > > > > > labels could also make sense).
> > > > >
> > > > > So that's what I did here :D
> > > > >
> > > > > For the software side off things here it doesn't change a lot of things
> > > > > since we have to manipulate the data anyway, putting the extra byte at the
> > > > > end or in between is no extra work.
> > > > > For the offload engine however, it should be easier to ask for 24 bits
> > > > > then 8 bits for each channel as it would return two u32 per "hardware
> > > > > channel".
> > > > >
> > > > > In order to avoid having two different layouts, I was kind of sold by
> > > > > Nuno's idea of having the CM in between each diff channel.
> > > > >
> > > >
> > > > Tbh, I was not even thinking about the layout when I proposed the
> > > > arrangement.
> > > > Just
> > > > made sense to me (from a logical point of view) to have them together as they
> > > > relate
> > > > to the same physical channel. FWIW, we're also speaking bytes in here so not
> > > > sure
> > > > if
> > > > it's that important (or bad).
> > >
> > > The best we can do (if we managed to do it HDL wise) is to reorder the
> > > data to get both CM byte in a single u32 after the 2 u32 of both diff
> > > channel. That would be 3 u32 instead of 4.
>
> Entirely up to you. :)
> > >
> >
> > We are starting to see more and more devices that do stuff like this. Have one
> > physical channel that reflects in more than one IIO channel. For SW buffering
> > it's
> > not really a big deal but for HW buffering it's not ideal.
> >
> > I feel that at some point we should think about having a way to map a channel
> > scan
> > element (being kind of a virtual scan element) into the storage_bits of another
> > one.
> > So in this case, one sample (for one channel) would be the 32bits and things
> > should
> > work the same either in SW or HW buffering.
> >
> > That said, it's probably easier said than done in practice :)
>
> Yeah. That could get ugly fast + All existing userspace will fail to handle it
> so I'm not keen. Maybe it's doable if we assume the 'virtual channels' are all
> meta data we don't mind loosing with existing software stacks and define
> a non overlapping ABI to identify the metadata. Still smells bad to me so
> I'll take quite a bit of convincing!
Naturally it would have to be done in a way that drivers not defining the "special"
scan elements would not be affected.
>
> Adding something to clearly 'associate' multiple related channels would be fine
> as that wouldn't change the data interpretation, just provide more info on top.
> Kind of a structured _label
>
> Maybe a _channelgroup attribute? Would be const and all the channels with
> the same index would reflect that they were measured on same 'thing'.
> Typically thing might be a pin or differential pair, but we might be measuring
> different types of signals - e.g. current and power.
>
Sounds reasonable but I think the tricky part is always to have a sane way of saying
that multiple scan elements relate to just one storage_bits so we could say something
like (taking this as example):
scan0: //diff channel which describing the physical HW in terms of real size
.storage_bits = 32
.real_bits = 24
.shift = 8
scan1: //CM data
//.storage - relates to scan0 so should add nothing to the sample size if both
enabled
.real_bits = 8
Likely not what you meant but one thing I took from your '_channelgroup' idea was to
have something similar to extended_info maybe with a small top level description and
then an array of channels (that would form the group/aggregated channel). Only on the
top level description we would be allowed to define the size of the scan element (in
case of buffering). Still seems tricky to me :).
Anyways, Right now, I have no time for something like this but eventually would like
to try something. But if someone wants to propose something sooner, please :)
- Nuno Sá
next prev parent reply other threads:[~2024-09-16 6:12 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 12:45 [PATCH 0/6] iio: adc: ad4030: new driver for AD4030 and similar ADCs Esteban Blanc
2024-08-22 12:45 ` [PATCH 1/6] dt-bindings: iio: adc: add ADI ad4030, ad4630 and ad4632 Esteban Blanc
2024-08-22 15:56 ` Conor Dooley
2024-08-26 8:36 ` Krzysztof Kozlowski
2024-08-22 12:45 ` [PATCH 2/6] iio: adc: ad4030: add driver for ad4030-24 Esteban Blanc
2024-08-22 19:39 ` David Lechner
2024-08-24 10:40 ` Jonathan Cameron
2024-09-13 10:22 ` Nuno Sá
2024-09-13 12:04 ` Esteban Blanc
2024-08-24 11:21 ` Jonathan Cameron
2024-08-27 16:45 ` Esteban Blanc
2024-08-28 13:34 ` Jonathan Cameron
2024-08-22 12:45 ` [PATCH 3/6] iio: adc: ad4030: add averaging support Esteban Blanc
2024-08-22 19:41 ` David Lechner
2024-08-22 12:45 ` [PATCH 4/6] iio: adc: ad4030: add support for ad4630-24 and ad4630-16 Esteban Blanc
2024-08-22 19:43 ` David Lechner
2024-08-26 9:27 ` Jonathan Cameron
2024-09-13 9:55 ` Esteban Blanc
2024-09-13 10:18 ` Nuno Sá
2024-09-13 12:55 ` Esteban Blanc
2024-09-13 13:46 ` Nuno Sá
2024-09-14 11:25 ` Jonathan Cameron
2024-09-16 6:12 ` Nuno Sá [this message]
2024-09-17 11:21 ` Jonathan Cameron
2024-09-17 11:19 ` Jonathan Cameron
2024-09-16 9:19 ` Esteban Blanc
2024-09-17 11:21 ` Jonathan Cameron
2024-09-16 13:03 ` Esteban Blanc
2024-08-22 12:45 ` [PATCH 5/6] iio: adc: ad4030: add support for ad4632-16 and ad4632-24 Esteban Blanc
2024-08-26 9:29 ` Jonathan Cameron
2024-08-22 12:45 ` [PATCH 6/6] docs: iio: ad4030: add documentation Esteban Blanc
2024-08-22 19:43 ` David Lechner
2024-08-22 15:54 ` [PATCH 0/6] iio: adc: ad4030: new driver for AD4030 and similar ADCs Conor Dooley
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=2b319d9453f4fe8842e4c306d9e2071ad031c0e7.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=Michael.Hennerich@analog.com \
--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=lars@metafoo.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).