[PATCH v3 1/2] dt-bindings: thermal: generic-adc: Add optional io-channel-cells property

Svyatoslav Ryhel posted 2 patches 11 months, 1 week ago
There is a newer version of this series
[PATCH v3 1/2] dt-bindings: thermal: generic-adc: Add optional io-channel-cells property
Posted by Svyatoslav Ryhel 11 months, 1 week ago
This implements a mechanism to derive temperature values from an existing ADC IIO
channel, effectively creating a temperature IIO channel. This approach avoids adding
a new sensor and its associated conversion table, while providing IIO-based temperature
data for devices that may not utilize hwmon.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 .../devicetree/bindings/thermal/generic-adc-thermal.yaml      | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml b/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
index 12e6418dc24d..4bc2cff0593c 100644
--- a/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
+++ b/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
@@ -30,6 +30,9 @@ properties:
   io-channel-names:
     const: sensor-channel
 
+  '#io-channel-cells':
+    const: 1
+
   temperature-lookup-table:
     description: |
       Lookup table to map the relation between ADC value and temperature.
@@ -60,6 +63,7 @@ examples:
         #thermal-sensor-cells = <0>;
         io-channels = <&ads1015 1>;
         io-channel-names = "sensor-channel";
+        #io-channel-cells = <1>;
         temperature-lookup-table = <
               (-40000) 2578
               (-39000) 2577
-- 
2.43.0
Re: [PATCH v3 1/2] dt-bindings: thermal: generic-adc: Add optional io-channel-cells property
Posted by Lukasz Luba 11 months, 1 week ago

On 3/3/25 12:21, Svyatoslav Ryhel wrote:
> This implements a mechanism to derive temperature values from an existing ADC IIO
> channel, effectively creating a temperature IIO channel. This approach avoids adding
> a new sensor and its associated conversion table, while providing IIO-based temperature
> data for devices that may not utilize hwmon.
> 
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
>   .../devicetree/bindings/thermal/generic-adc-thermal.yaml      | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml b/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
> index 12e6418dc24d..4bc2cff0593c 100644
> --- a/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
> +++ b/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
> @@ -30,6 +30,9 @@ properties:
>     io-channel-names:
>       const: sensor-channel
>   
> +  '#io-channel-cells':
> +    const: 1
> +
>     temperature-lookup-table:
>       description: |
>         Lookup table to map the relation between ADC value and temperature.
> @@ -60,6 +63,7 @@ examples:
>           #thermal-sensor-cells = <0>;
>           io-channels = <&ads1015 1>;
>           io-channel-names = "sensor-channel";
> +        #io-channel-cells = <1>;
>           temperature-lookup-table = <
>                 (-40000) 2578
>                 (-39000) 2577

Do we really need this change in the DT?
Won't the code in the thermal driver that registers a new iio device
would just be enough?

I agree with Rob that it looks odd.
Re: [PATCH v3 1/2] dt-bindings: thermal: generic-adc: Add optional io-channel-cells property
Posted by Svyatoslav Ryhel 11 months, 1 week ago
ср, 5 бер. 2025 р. о 12:00 Lukasz Luba <lukasz.luba@arm.com> пише:
>
>
>
> On 3/3/25 12:21, Svyatoslav Ryhel wrote:
> > This implements a mechanism to derive temperature values from an existing ADC IIO
> > channel, effectively creating a temperature IIO channel. This approach avoids adding
> > a new sensor and its associated conversion table, while providing IIO-based temperature
> > data for devices that may not utilize hwmon.
> >
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > ---
> >   .../devicetree/bindings/thermal/generic-adc-thermal.yaml      | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml b/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
> > index 12e6418dc24d..4bc2cff0593c 100644
> > --- a/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
> > +++ b/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
> > @@ -30,6 +30,9 @@ properties:
> >     io-channel-names:
> >       const: sensor-channel
> >
> > +  '#io-channel-cells':
> > +    const: 1
> > +
> >     temperature-lookup-table:
> >       description: |
> >         Lookup table to map the relation between ADC value and temperature.
> > @@ -60,6 +63,7 @@ examples:
> >           #thermal-sensor-cells = <0>;
> >           io-channels = <&ads1015 1>;
> >           io-channel-names = "sensor-channel";
> > +        #io-channel-cells = <1>;
> >           temperature-lookup-table = <
> >                 (-40000) 2578
> >                 (-39000) 2577
>
> Do we really need this change in the DT?
> Won't the code in the thermal driver that registers a new iio device
> would just be enough?
>
> I agree with Rob that it looks odd.

Building tree will complain on missing cells property if you try to
bind it. It is not in required category anyway.
Re: [PATCH v3 1/2] dt-bindings: thermal: generic-adc: Add optional io-channel-cells property
Posted by Rob Herring 11 months, 1 week ago
On Wed, Mar 05, 2025 at 12:03:20PM +0200, Svyatoslav Ryhel wrote:
> ср, 5 бер. 2025 р. о 12:00 Lukasz Luba <lukasz.luba@arm.com> пише:
> >
> >
> >
> > On 3/3/25 12:21, Svyatoslav Ryhel wrote:
> > > This implements a mechanism to derive temperature values from an existing ADC IIO
> > > channel, effectively creating a temperature IIO channel. This approach avoids adding
> > > a new sensor and its associated conversion table, while providing IIO-based temperature
> > > data for devices that may not utilize hwmon.
> > >
> > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > ---
> > >   .../devicetree/bindings/thermal/generic-adc-thermal.yaml      | 4 ++++
> > >   1 file changed, 4 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml b/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
> > > index 12e6418dc24d..4bc2cff0593c 100644
> > > --- a/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
> > > +++ b/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
> > > @@ -30,6 +30,9 @@ properties:
> > >     io-channel-names:
> > >       const: sensor-channel
> > >
> > > +  '#io-channel-cells':
> > > +    const: 1
> > > +
> > >     temperature-lookup-table:
> > >       description: |
> > >         Lookup table to map the relation between ADC value and temperature.
> > > @@ -60,6 +63,7 @@ examples:
> > >           #thermal-sensor-cells = <0>;
> > >           io-channels = <&ads1015 1>;
> > >           io-channel-names = "sensor-channel";
> > > +        #io-channel-cells = <1>;
> > >           temperature-lookup-table = <
> > >                 (-40000) 2578
> > >                 (-39000) 2577
> >
> > Do we really need this change in the DT?
> > Won't the code in the thermal driver that registers a new iio device
> > would just be enough?
> >
> > I agree with Rob that it looks odd.
> 
> Building tree will complain on missing cells property if you try to
> bind it. It is not in required category anyway.

Sorry, I don't follow nor see why you need the property if there are no 
DT consumers.

Rob
Re: [PATCH v3 1/2] dt-bindings: thermal: generic-adc: Add optional io-channel-cells property
Posted by Lukasz Luba 11 months, 1 week ago

On 3/5/25 10:03, Svyatoslav Ryhel wrote:
> ср, 5 бер. 2025 р. о 12:00 Lukasz Luba <lukasz.luba@arm.com> пише:
>>
>>
>>
>> On 3/3/25 12:21, Svyatoslav Ryhel wrote:
>>> This implements a mechanism to derive temperature values from an existing ADC IIO
>>> channel, effectively creating a temperature IIO channel. This approach avoids adding
>>> a new sensor and its associated conversion table, while providing IIO-based temperature
>>> data for devices that may not utilize hwmon.
>>>
>>> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
>>> ---
>>>    .../devicetree/bindings/thermal/generic-adc-thermal.yaml      | 4 ++++
>>>    1 file changed, 4 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml b/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
>>> index 12e6418dc24d..4bc2cff0593c 100644
>>> --- a/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
>>> +++ b/Documentation/devicetree/bindings/thermal/generic-adc-thermal.yaml
>>> @@ -30,6 +30,9 @@ properties:
>>>      io-channel-names:
>>>        const: sensor-channel
>>>
>>> +  '#io-channel-cells':
>>> +    const: 1
>>> +
>>>      temperature-lookup-table:
>>>        description: |
>>>          Lookup table to map the relation between ADC value and temperature.
>>> @@ -60,6 +63,7 @@ examples:
>>>            #thermal-sensor-cells = <0>;
>>>            io-channels = <&ads1015 1>;
>>>            io-channel-names = "sensor-channel";
>>> +        #io-channel-cells = <1>;
>>>            temperature-lookup-table = <
>>>                  (-40000) 2578
>>>                  (-39000) 2577
>>
>> Do we really need this change in the DT?
>> Won't the code in the thermal driver that registers a new iio device
>> would just be enough?
>>
>> I agree with Rob that it looks odd.
> 
> Building tree will complain on missing cells property if you try to
> bind it. It is not in required category anyway.

Fair enough, then I will leave it to DT folks.

For me it's looks OK-ish, assuming you add this property with the
comment describing it like Rob asked.

UUIC it will always be only 1 channel - with that temperature,
so shouldn't harm much the design in DT.