From: Jerome Brunet <jbrunet@baylibre.com>
To: David Lechner <dlechner@baylibre.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org,
linux-iio@vger.kernel.org, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Subject: Re: [PATCH 2/2] iio: frequency: add amlogic clock measure support
Date: Tue, 25 Jun 2024 10:31:51 +0200 [thread overview]
Message-ID: <1j4j9hift4.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <04254d15-2f6e-435d-ba4c-8e2e87766b9b@baylibre.com> (David Lechner's message of "Mon, 24 Jun 2024 17:51:05 -0500")
On Mon 24 Jun 2024 at 17:51, David Lechner <dlechner@baylibre.com> wrote:
> On 6/24/24 12:31 PM, Jerome Brunet wrote:
>> Add support for the HW found in most Amlogic SoC dedicated to measure
>> system clocks.
>>
>
>
>
>> +static int cmsr_read_raw(struct iio_dev *indio_dev,
>> + struct iio_chan_spec const *chan,
>> + int *val, int *val2, long mask)
>> +{
>> + struct amlogic_cmsr *cm = iio_priv(indio_dev);
>> +
>> + guard(mutex)(&cm->lock);
>> +
>> + switch (mask) {
>> + case IIO_CHAN_INFO_RAW:
>> + *val = cmsr_measure_unlocked(cm, chan->channel);
>
> Is this actually returning an alternating voltage magnitutde?
> Most frequency drivers don't have a raw value, only frequency.
No it is not the magnitude, it is the clock rate (frequency) indeed.
Maybe altvoltage was not the right pick for that but nothing obvious
stands out for Hz measurements
>
>> + if (*val < 0)
>> + return *val;
>> + return IIO_VAL_INT;
>> +
>> + case IIO_CHAN_INFO_PROCESSED: /* Result in Hz */
>
> Shouldn't this be IIO_CHAN_INFO_FREQUENCY?
How would I get raw / processed / scale with IIO_CHAN_INFO_FREQUENCY ?
>
> Processed is just (raw + offset) * scale which would be a voltage
> in this case since the channel type is IIO_ALTVOLTAGE.
This is was Processed does here, along with selecting the most
appropriate scale to perform the measurement.
>
>> + *val = cmsr_measure_processed_unlocked(cm, chan->channel, val2);
>> + if (*val < 0)
>> + return *val;
>> + return IIO_VAL_INT_64;
>> +
>> + case IIO_CHAN_INFO_SCALE:
>
> What is this attribute being used for?
Hz
>
> (clearly not used to convert the raw value to millivolts :-) )
>
> Maybe IIO_CHAN_INFO_INT_TIME is the right one for this? Although
> so far, that has only been used with light sensors.
I think you are mixing up channel info and type here.
I do want the info
* IIO_CHAN_INFO_RAW
* IIO_CHAN_INFO_PROCESSED
* IIO_CHAN_INFO_SCALE
I want those info to represent an alternate voltage frequency in Hz.
I thought type 'IIO_ALTVOLTAGE' was the right pick for that. Apparently
it is not. What is the appropriate type then ? Should I add a new one ?
>
>> + *val2 = cmsr_get_time_unlocked(cm);
>> + *val = 1000000;
>> + return IIO_VAL_FRACTIONAL;
>> +
>> + default:
>> + return -EINVAL;
>> + }
>> +}
>> +
--
Jerome
next prev parent reply other threads:[~2024-06-25 8:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 17:31 [PATCH 0/2] iio: frequency: add iio support for Amlogic clock measure Jerome Brunet
2024-06-24 17:31 ` [PATCH 1/2] dt-bindings: iio: frequency: add clock measure support Jerome Brunet
2024-06-25 5:38 ` Krzysztof Kozlowski
2024-06-24 17:31 ` [PATCH 2/2] iio: frequency: add amlogic " Jerome Brunet
2024-06-24 22:51 ` David Lechner
2024-06-24 23:03 ` David Lechner
2024-06-25 8:31 ` Jerome Brunet [this message]
2024-06-25 14:52 ` David Lechner
2024-06-25 16:59 ` Jerome Brunet
2024-06-29 19:26 ` Jonathan Cameron
2024-06-29 19:40 ` Jonathan Cameron
2024-06-30 7:21 ` Jerome Brunet
2024-06-30 10:17 ` Jonathan Cameron
2024-06-25 9:38 ` [PATCH 0/2] iio: frequency: add iio support for Amlogic clock measure Neil Armstrong
2024-06-25 9:53 ` Jerome Brunet
2024-06-25 13:18 ` Neil Armstrong
2024-06-25 13:51 ` Jerome Brunet
2024-07-01 7:41 ` Neil Armstrong
2024-07-01 9:01 ` Jerome Brunet
2024-07-01 9:10 ` Neil Armstrong
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=1j4j9hift4.fsf@starbuckisacylon.baylibre.com \
--to=jbrunet@baylibre.com \
--cc=conor+dt@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--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