[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240908164940.7c4ffb8a@jic23-huawei>
Date: Sun, 8 Sep 2024 16:49:40 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: David Lechner <dlechner@...libre.com>
Cc: Angelo Dureghello <adureghello@...libre.com>, Lars-Peter Clausen
<lars@...afoo.de>, Michael Hennerich <Michael.Hennerich@...log.com>, Nuno
Sá <nuno.sa@...log.com>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Olivier Moysan <olivier.moysan@...s.st.com>,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 8/9] iio: dac: ad3552r: add axi platform driver
On Thu, 5 Sep 2024 15:40:11 -0500
David Lechner <dlechner@...libre.com> wrote:
> On 9/5/24 10:17 AM, Angelo Dureghello wrote:
>
> ...
One reply to a comment David made.
Jonathan
>
> > + */
> > + if (st->single_channel)
> > + clk_rate = DIV_ROUND_CLOSEST(clk_rate, 4);
> > + else
> > + clk_rate = DIV_ROUND_CLOSEST(clk_rate, 8);
> > +
>
> Having the sample rate depend on how many channels are enabled in
> the buffer seems a bit odd. Sampling frequency is not strictly
> defined in IIO, so I think it would be fine to always return the
> same value no matter how many channels are enabled.
>
> We will just need to document that the sampling frequency is the
> rate per sample, not per channel. So if two channels are enabled,
> the effective sampling rate per channel is 1/2 of the sampling
> rate reported by the sysfs attribute.
There is an oddity around this that we've never cleared up fully.
In my head at least if there is a single sampling_frequency it
applies to 'scans', not individual channel reads (so would change
with the number of channels enabled). If there
is a per channel attribute we do have documentation:
What: /sys/bus/iio/devices/iio:deviceX/in_voltageX_sampling_frequency
What: /sys/bus/iio/devices/iio:deviceX/in_powerY_sampling_frequency
What: /sys/bus/iio/devices/iio:deviceX/in_currentZ_sampling_frequency
KernelVersion: 5.20
Contact: linux-iio@...r.kernel.org
Description:
Some devices have separate controls of sampling frequency for
individual channels. If multiple channels are enabled in a scan,
then the sampling_frequency of the scan may be computed from the
per channel sampling frequencies.
For many devices the sampling frequency isn't down to each sample taking
N microsecs and them running back to back, it is instead a function of
a periodic sampling start for samples that take the same time whatever
the sampling frequency. Also for simultaneous sampling ADCs it is never
channel dependent.
So I think if you want to avoid the confusion, make your device fall into
the description above and provide a per channel attribute rather
than shared_by_all.
Or keep it as things stand and have it halve when you double the channels.
>
> > + *val = clk_rate;
> > +
> > + return IIO_VAL_INT;
> > + }
...
Powered by blists - more mailing lists