devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Nuno Sá" <noname.nuno@gmail.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Antoniu Miclaus" <antoniu.miclaus@analog.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>,
	"Olivier Moysan" <olivier.moysan@foss.st.com>,
	"Uwe Kleine-König" <ukleinek@kernel.org>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
	"João Paulo Gonçalves" <joao.goncalves@toradex.com>,
	"Mike Looijmans" <mike.looijmans@topic.nl>,
	"Dumitru Ceclan" <mitrutzceclan@gmail.com>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"Alisa-Dariana Roman" <alisadariana@gmail.com>,
	"Sergiu Cuciurean" <sergiu.cuciurean@analog.com>,
	"Dragos Bogdan" <dragos.bogdan@analog.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-pwm@vger.kernel.org
Subject: Re: [PATCH 6/7] iio: adc: ad485x: add ad485x driver
Date: Sat, 5 Oct 2024 18:26:08 +0100	[thread overview]
Message-ID: <20241005182608.2be20d3a@jic23-huawei> (raw)
In-Reply-To: <35944d57af0ed62124e1e7cea544ef357fad1659.camel@gmail.com>

On Mon, 30 Sep 2024 09:05:04 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Sat, 2024-09-28 at 18:30 +0100, Jonathan Cameron wrote:
> >   
> > >   
> > > > +static struct iio_chan_spec_ext_info ad4858_ext_info[] = {
> > > > +       IIO_ENUM("packet_format", IIO_SHARED_BY_ALL, &ad4858_packet_fmt),
> > > > +       IIO_ENUM_AVAILABLE("packet_format",
> > > > +                          IIO_SHARED_BY_ALL, &ad4858_packet_fmt),
> > > > +       {},
> > > > +};
> > > > +
> > > > +static struct iio_chan_spec_ext_info ad4857_ext_info[] = {
> > > > +       IIO_ENUM("packet_format", IIO_SHARED_BY_ALL, &ad4857_packet_fmt),
> > > > +       IIO_ENUM_AVAILABLE("packet_format",
> > > > +                          IIO_SHARED_BY_ALL, &ad4857_packet_fmt),
> > > > +       {},
> > > > +};    
> > > 
> > > Usually, something like this packet format would be automatically
> > > selected when buffered reads are enabled based on what other features
> > > it provides are needed, i.e only enable the status bits when events
> > > are enabled.
> > > 
> > > (For those that didn't read the datasheet, the different packet
> > > formats basically enable extra status bits per sample. And in the case
> > > of oversampling, one of the formats also selects a reduced number of
> > > sample bits.)
> > > 
> > > We have quite a few parts in the pipline right like this one that have
> > > per-sample status bits. In the past, these were generally handled with
> > > IIO events, but this doesn't really work for these high-speed backends
> > > since the data is being piped directly to DMA and we don't look at
> > > each sample in the ADC driver. So it would be worthwhile to try to
> > > find some general solution here for handling this sort of thing.  
> 
> I did not read the datasheet that extensively but here it goes my 2 cents
> (basically my internal feedback on this one):
> 
> So this packet format thingy may be a very "funny" discussion if we really need
> to support it. I'm not sure how useful it is the 32 bits format rather than
> being used in test pattern. I'm not seeing too much benefit on the channel id or
> span id information (we can already get that info with other attributes). The
> OR/UR is the one that could be more useful but is there someone using it? Do we
> really need to have it close to the sample? If not, there's the status register
> and... Also, I think this can be implemented using IIO events (likely what we
> will be asked). So what comes to mind could be:

Definite preference for using events, but for a device doing DMA I'm not sure
how we can do that without requiring parsing all the data.

So we would need some metadata description to know it is there.

> 
> For test_pattern (could be implemented as ext_info or an additional channel I
> think - not for now I guess) we can easily look at our word side and dynamically
> set the proper packet size. So, to me, this is effectively the only place where
> 32bits would make sense (assuming we don't implement OR/UR for now).
> For oversampling we can have both 20/24 bit averaged data. But from the
> datasheet:
> 
> "Oversampling is useful in applications requiring lower noise and higher dynamic
> range per output data-word, which the AD4858 supports with 24-bit output
> resolution and reduced average output data rates"
> 
> So from the above it looks like it could make sense to default to 24bit packets
> if oversampling is enabled.

That sounds like what we do for the DMA oversampling cases that change
the resolutions.

> 
> Now the question is OR/UR. If that is something we can support with events, we
> could see when one of OR/UR is being requested to either enable 24 packets (no
> oversampling) or 32 bit packets (oversampling on).
> 
> 
> 
> > 
> > We have previously talked about schemes to describe metadata
> > alongside channels. I guess maybe it's time to actually look at how
> > that works.  I'm not sure dynamic control of that metadata
> > is going to be easy to do though or if we even want to
> > (as opposed to always on or off for a particular device).
> >   
> 
> Indeed this is something we have been discussing and the ability to have status
> alongside a buffered samples is starting to be requested more and more. Some
> parts do have the status bit alongside the sample (meaning in the same register
> read) which means it basically goes with the sample as part of it's
> storage_bits. While not ideal, an application caring about those bits still has
> access to the complete raw sample and can access them. 

This has the advantage that if we come along later and define a metadata
in storage bits description it is backwards compatible.  We've been doing
this for years with some devices.

> It gets more complicated
> where the status (sometimes a per device status register) is located in another
> register. I guess we can have two case:
> 
> 1) A device status which applies for all channels being sampled;
> 2) A per channel status (where the .metada approach could make sense).

If it's a separate register per channel and optional, we'd have to treat it as a metadata
channel as no guarantee it would be packed next to the main channel.

If we have a description of metadata additions in main channel storage, I'm not
against having a IIO_METADATA channel type. 

If it's a single channel I'm not sure how we'd make as channel description
general enough easily as we end up with every field possibly needed an association
with a different channel.

> 
> But I'm not sure how we could define something like this other than assuming
> that raw status data is being sent to userspace (given that every device has
> it's own custom status bits and quirks).
That is always fine.

Jonathan
> 
> - Nuno Sá  


  reply	other threads:[~2024-10-05 17:26 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-23 10:10 [PATCH 0/7] *** Add support for AD485x DAS Family *** Antoniu Miclaus
2024-09-23 10:10 ` [PATCH 1/7] iio: backend: add API for interface get Antoniu Miclaus
2024-09-26  8:40   ` David Lechner
2024-09-26 10:52     ` Nuno Sá
2024-09-28 17:23       ` Jonathan Cameron
2024-09-30  6:46         ` Nuno Sá
2024-09-23 10:10 ` [PATCH 2/7] iio: backend: add support for data size set Antoniu Miclaus
2024-09-23 11:17   ` Andy Shevchenko
2024-09-26  9:10   ` David Lechner
2024-09-28 17:24   ` Jonathan Cameron
2024-09-23 10:10 ` [PATCH 3/7] iio: adc: adi-axi-adc: add interface type Antoniu Miclaus
2024-09-23 10:10 ` [PATCH 4/7] iio: adc: adi-axi-adc: set data format Antoniu Miclaus
2024-09-26  9:08   ` David Lechner
2024-09-23 10:10 ` [PATCH 5/7] dt-bindings: iio: adc: add ad458x Antoniu Miclaus
2024-09-23 21:20   ` Conor Dooley
2024-09-24 13:42   ` David Lechner
2024-09-24 22:32   ` Rob Herring
2024-09-23 10:10 ` [PATCH 6/7] iio: adc: ad485x: add ad485x driver Antoniu Miclaus
2024-09-23 11:43   ` Andy Shevchenko
2024-09-24 16:08   ` kernel test robot
2024-09-26 14:39   ` David Lechner
2024-09-26 15:00     ` Andy Shevchenko
2024-09-28 17:30     ` Jonathan Cameron
2024-09-29 19:21       ` Andy Shevchenko
2024-09-30  7:05       ` Nuno Sá
2024-10-05 17:26         ` Jonathan Cameron [this message]
2024-10-11 10:23           ` Nuno Sá
2024-10-12 10:31             ` Jonathan Cameron
2024-09-28 17:47   ` Jonathan Cameron
2024-10-01 11:53     ` Miclaus, Antoniu
2024-10-01 12:54       ` Andy Shevchenko
2024-10-01 13:51         ` Miclaus, Antoniu
2024-10-01 14:08           ` David Lechner
2024-10-03 10:14             ` Miclaus, Antoniu
2024-10-03 10:35               ` Andy Shevchenko
2024-10-03 13:08               ` David Lechner
2024-10-04 14:07                 ` Miclaus, Antoniu
2024-10-05 17:27                   ` Jonathan Cameron
2024-09-23 10:10 ` [PATCH 7/7] Documentation: ABI: testing: ad485x: add ABI docs Antoniu Miclaus
2024-09-23 11:45   ` Andy Shevchenko
2024-09-28 17:32   ` Jonathan Cameron
2024-09-23 11:14 ` [PATCH 0/7] *** Add support for AD485x DAS Family *** Andy Shevchenko

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=20241005182608.2be20d3a@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=alisadariana@gmail.com \
    --cc=andy@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=antoniu.miclaus@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=dragos.bogdan@analog.com \
    --cc=joao.goncalves@toradex.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=mike.looijmans@topic.nl \
    --cc=mitrutzceclan@gmail.com \
    --cc=noname.nuno@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=olivier.moysan@foss.st.com \
    --cc=robh@kernel.org \
    --cc=sergiu.cuciurean@analog.com \
    --cc=ukleinek@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).