mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Liam Beguin <liambeguin@gmail.com>, Jonathan Cameron <jic23@kernel.org>
Cc: jdelvare@suse.com, lars@metafoo.de, pmeerw@pmeerw.net,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	robh+dt@kernel.org, Peter Rosin <peda@axentia.se>
Subject: Re: [RFC PATCH v1 0/2] hwmon: (iio_hwmon) optionally force iio channel type
Date: Sun, 16 May 2021 16:10:56 -0700	[thread overview]
Message-ID: <d99331c5-b3d6-5e87-3a3d-8cf2817dea11@roeck-us.net> (raw)
In-Reply-To: <CBEVHCPHGJJD.2IDUUG1RPDF64@shaak>

On 5/16/21 11:14 AM, Liam Beguin wrote:
> On Sun May 16, 2021 at 12:26 PM EDT, Jonathan Cameron wrote:
>> On Sun, 16 May 2021 08:54:06 -0700
>> Guenter Roeck <linux@roeck-us.net> wrote:
>>
>>> On 5/16/21 8:02 AM, Liam Beguin wrote:
>>>> Hi Jonathan,
>>>>
>>>> On Sun May 16, 2021 at 5:06 AM EDT, Jonathan Cameron wrote:
>>>>> On Sun, 16 May 2021 00:43:13 -0400
>>>>> Liam Beguin <liambeguin@gmail.com> wrote:
>>>>>   
>>>>>> Add a devicetree binding to optionally force a different IIO channel
>>>>>> type.
>>>>>>
>>>>>> This is useful in cases where ADC channels are connected to a circuit
>>>>>> that represent another unit such as a temperature or a current.
>>>>>>
>>>>>> `channel-types` was chosen instead of `io-channel-types` as this is not
>>>>>> part of the iio consumer bindings.
>>>>>>
>>>>>> In the current form, this patch does what it's intended to do:
>>>>>> change the unit displayed by `sensors`, but feels like the wrong way to
>>>>>> address the problem.
>>>>>>
>>>>>> Would it be possible to force the type of different IIO channels for
>>>>>> this kind of use case with a devicetree binding from the IIO subsystem?
>>>>>>
>>>>>> It would be convenient to do it within the IIO subsystem to have the
>>>>>> right unit there too.
>>>>>>
>>>>>> Thanks for your time,
>>>>>> Liam
>>>>>
>>>>> Hi Liam,
>>>>>
>>>>> +CC Peter for AFE part.
>>>>>
>>>>> It's an interesting approach, but I would suggest we think about this
>>>>> a different way.
>>>>>
>>>>> Whenever a channel is being used to measure something 'different' from
>>>>> what it actually measures (e.g. a voltage ADC measuring a current) that
>>>>> reflects their being some analog component involved.
>>>>> If you look at drivers/iio/afe/iio-rescale.c you can see the approach
>>>>> we currently use to handle this.
>>>>
>>>> Many thanks for pointing out the AFE code. That look like what I was
>>>> hoping to accomplish, but in a much better way.
>>>>    
>>>>>
>>>>> Effectively what you add to devicetree is a consumer of the ADC channel
>>>>> which in turn provides services to other devices. For this current case
>>>>> it would be either a current-sense-amplifier or a current-sense-shunt
>>>>> depending on what the analog front end looks like. We have to describe
>>>>> the characteristics of that front end which isn't something that can
>>>>> be done via a simple channel type.
>>>>>   
>>>>
>>>> Understood. My original intention was to use sensors.conf to do the
>>>> conversions and take into accounts those parameters.
>>>>    
>>>>> That afe consumer device can then provide services to another consumer
>>>>> (e.g. iio-hwmon) which work for your usecase.
>>>>>
>>>>> The main limitation of this approach currently is you end up with
>>>>> one device per channel. That could be improved upon if you have a
>>>>> usecase
>>>>> where it matters.
>>>>>
>>>>> I don't think we currently have an equivalent for temperature sensing
>>>>> but it would be easy enough to do something similar.
>>>>
>>>> Wonderful, thanks again for pointing out the AFE!
>>>>    
>>>
>>> Please don't reinvent the ntc_thermistor driver.
> 
>> Agreed, I'd forgotten it existed :( Had a feeling we'd solved that
>> problem before
>> but couldn't remember the name of the driver.
>>
>> The afe driver already deals with current / voltage scaling and
>> conversion
>> for common analog circuits. Potential dividers, current shunts etc, but
>> they
>> are all the linear cases IIRC.
>>
>> ntc_thermistor deals with the much more complex job of dealing with a
>> thermistor.
> 
> I agree, no need to reinvent this.
> 
> Like Jonathan said, the ntc_thermistor driver seems to handle much more
> complex cases. Where would be the best place to add support for PT100
> and PT1000? iio-rescale?
> 

Those sensors don't seem to be even useful for hardware monitoring, so
if they are linear (and it looks like that that the case) iio would be
a better place.

Guenter

      reply	other threads:[~2021-05-16 23:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16  4:43 Liam Beguin
2021-05-16  4:43 ` [RFC PATCH v1 1/2] " Liam Beguin
2021-05-16  4:43 ` [RFC PATCH v1 2/2] dt-bindings: hwmon: add iio-hwmon bindings Liam Beguin
2021-05-16  8:56 ` [RFC PATCH v1 0/2] hwmon: (iio_hwmon) optionally force iio channel type Guenter Roeck
2021-05-16 14:55   ` Liam Beguin
2021-05-16  9:06 ` Jonathan Cameron
2021-05-16 15:02   ` Liam Beguin
2021-05-16 15:54     ` Guenter Roeck
2021-05-16 16:26       ` Jonathan Cameron
2021-05-16 18:14         ` Liam Beguin
2021-05-16 23:10           ` Guenter Roeck [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=d99331c5-b3d6-5e87-3a3d-8cf2817dea11@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=liambeguin@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=pmeerw@pmeerw.net \
    --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

all inboxes | Powered by JetHome®