linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Please suggest proper format for DT properties.
@ 2015-09-18 22:36 Constantine Shulyupin
  2015-09-21  1:51 ` Rob Herring
  2015-09-22  8:36 ` Arnd Bergmann
  0 siblings, 2 replies; 7+ messages in thread
From: Constantine Shulyupin @ 2015-09-18 22:36 UTC (permalink / raw)
  To: open list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	lm-sensors, Jean Delvare, Guenter Roeck, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala

Hi,

I am designing DT support for a hwmon chip. 
It has some sensors, each of them can be:
 - "disabled"
 - "thermal diode"
 - "thermistor"
 - "voltage"

Four possible options for DT properties format.

Option 1: Separated property for each sensor.

Example nct7802 node:

nct7802 {
	compatible = "nuvoton,nct7802";
	reg = <0x2a>;
	nuvoton,sensor1-type = "thermistor";
	nuvoton,sensor2-type = "disabled";
	nuvoton,sensor3-type = "voltage";
};

Option 2: Array of strings for all sensors.

nct7802 {
	compatible = "nuvoton,nct7802";
	reg = <0x2a>;
	nuvoton,sensors-types = "thermistor", "disabled", "voltage";
};

Option 3: Sets of 4 cells.

  Borrowed from marvell,reg-init and broadcom,c45-reg-init.

  The first cell is the page address, 
  the second a register address within the page,
  the third cell contains a mask to be ANDed with the existing register
  value, and the fourth cell is ORed with the result to yield the
  new register value. If the third cell has a value of zero,
  no read of the existing value is performed.

Example nct7802 node:

nct7802 {
	compatible = "nuvoton,nct7802";
	reg = <0x2a>;
	nct7802,reg-init =
		<0 0x21 0 0x01 > // START = 1
		<0 0x22 0x03 0x02>; // RTD1_MD = 2
};

Please suggest proper format for DT properties.

Thanks
Constantine

PS:
Datasheet: https://www.nuvoton.com/hq/products/cloud-computing/hardware-monitors/desktop-server-series/nct7802y/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Please suggest proper format for DT properties.
  2015-09-18 22:36 Please suggest proper format for DT properties Constantine Shulyupin
@ 2015-09-21  1:51 ` Rob Herring
  2015-09-21 19:24   ` Constantine Shulyupin
  2015-09-22  8:36 ` Arnd Bergmann
  1 sibling, 1 reply; 7+ messages in thread
From: Rob Herring @ 2015-09-21  1:51 UTC (permalink / raw)
  To: Constantine Shulyupin
  Cc: open list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	lm-sensors, Jean Delvare, Guenter Roeck, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala

On Fri, Sep 18, 2015 at 5:36 PM, Constantine Shulyupin
<const@makelinux.com> wrote:
> Hi,
>
> I am designing DT support for a hwmon chip.
> It has some sensors, each of them can be:
>  - "disabled"
>  - "thermal diode"
>  - "thermistor"
>  - "voltage"
>
> Four possible options for DT properties format.
>
> Option 1: Separated property for each sensor.
>
> Example nct7802 node:
>
> nct7802 {
>         compatible = "nuvoton,nct7802";
>         reg = <0x2a>;
>         nuvoton,sensor1-type = "thermistor";
>         nuvoton,sensor2-type = "disabled";
>         nuvoton,sensor3-type = "voltage";
> };
>
> Option 2: Array of strings for all sensors.
>
> nct7802 {
>         compatible = "nuvoton,nct7802";
>         reg = <0x2a>;
>         nuvoton,sensors-types = "thermistor", "disabled", "voltage";
> };

It seems you are just listing out all possible modes. Why do you need
this in the DT at all? This can be inferred by the compatible string.

>
> Option 3: Sets of 4 cells.
>
>   Borrowed from marvell,reg-init and broadcom,c45-reg-init.
>
>   The first cell is the page address,
>   the second a register address within the page,
>   the third cell contains a mask to be ANDed with the existing register
>   value, and the fourth cell is ORed with the result to yield the
>   new register value. If the third cell has a value of zero,
>   no read of the existing value is performed.

I don't see how this relates to the first 2 options. The register you
write selects the mode? In general, we don't want bindings of just
random register writes.

Rob

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Please suggest proper format for DT properties.
  2015-09-21  1:51 ` Rob Herring
@ 2015-09-21 19:24   ` Constantine Shulyupin
  2015-09-22  0:32     ` Rob Herring
  0 siblings, 1 reply; 7+ messages in thread
From: Constantine Shulyupin @ 2015-09-21 19:24 UTC (permalink / raw)
  To: Rob Herring
  Cc: open list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	lm-sensors, Jean Delvare, Guenter Roeck, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala

On Mon, Sep 21, 2015 at 4:51 AM, Rob Herring <robh@kernel.org> wrote:
> On Fri, Sep 18, 2015 at 5:36 PM, Constantine Shulyupin
> <const@makelinux.com> wrote:
>> Hi,
>>
>> I am designing DT support for a hwmon chip.
>> It has some sensors, each of them can be:
>>  - "disabled"
>>  - "thermal diode"
>>  - "thermistor"
>>  - "voltage"
>>
>> Four possible options for DT properties format.
>>
>> Option 1: Separated property for each sensor.
>>
>> Example nct7802 node:
>>
>> nct7802 {
>>         compatible = "nuvoton,nct7802";
>>         reg = <0x2a>;
>>         nuvoton,sensor1-type = "thermistor";
>>         nuvoton,sensor2-type = "disabled";
>>         nuvoton,sensor3-type = "voltage";
>> };
>>
>> Option 2: Array of strings for all sensors.
>>
>> nct7802 {
>>         compatible = "nuvoton,nct7802";
>>         reg = <0x2a>;
>>         nuvoton,sensors-types = "thermistor", "disabled", "voltage";
>> };
>
> It seems you are just listing out all possible modes. Why do you need
> this in the DT at all? This can be inferred by the compatible string.

There are tree sensor, each of one can be one of three type ("thermal
diode", "thermistor", "voltage") or be disabled.
Also there are at least five platform depended registers, most of them
are enable/disable.
You can find full datasheet here
https://www.nuvoton.com/hq/products/cloud-computing/hardware-monitors/desktop-server-series/nct7802y/

The question is how to describe configuration of this registers in dts.
The second option is array of types for tree registers.

>> Option 3: Sets of 4 cells.
>>
>>   Borrowed from marvell,reg-init and broadcom,c45-reg-init.
>>
>>   The first cell is the page address,
>>   the second a register address within the page,
>>   the third cell contains a mask to be ANDed with the existing register
>>   value, and the fourth cell is ORed with the result to yield the
>>   new register value. If the third cell has a value of zero,
>>   no read of the existing value is performed.
>
> I don't see how this relates to the first 2 options. The register you
> write selects the mode? In general, we don't want bindings of just
> random register writes.
>
> Rob
Option 3 allows arbitrary registers configuration.

To see the full picture you can refer to datasheet mentioned above to
function nct7802_init_chip via
http://lxr.free-electrons.com/source/drivers/hwmon/nct7802.c#L789
and proposed patch for option #2: https://lkml.org/lkml/2015/9/13/204

-- 
Thanks
Constantine

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Please suggest proper format for DT properties.
  2015-09-21 19:24   ` Constantine Shulyupin
@ 2015-09-22  0:32     ` Rob Herring
  0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2015-09-22  0:32 UTC (permalink / raw)
  To: Constantine Shulyupin
  Cc: open list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	lm-sensors, Jean Delvare, Guenter Roeck, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala

On Mon, Sep 21, 2015 at 2:24 PM, Constantine Shulyupin
<const@makelinux.com> wrote:
> On Mon, Sep 21, 2015 at 4:51 AM, Rob Herring <robh@kernel.org> wrote:
>> On Fri, Sep 18, 2015 at 5:36 PM, Constantine Shulyupin
>> <const@makelinux.com> wrote:
>>> Hi,
>>>
>>> I am designing DT support for a hwmon chip.
>>> It has some sensors, each of them can be:
>>>  - "disabled"
>>>  - "thermal diode"
>>>  - "thermistor"
>>>  - "voltage"
>>>
>>> Four possible options for DT properties format.
>>>
>>> Option 1: Separated property for each sensor.
>>>
>>> Example nct7802 node:
>>>
>>> nct7802 {
>>>         compatible = "nuvoton,nct7802";
>>>         reg = <0x2a>;
>>>         nuvoton,sensor1-type = "thermistor";
>>>         nuvoton,sensor2-type = "disabled";
>>>         nuvoton,sensor3-type = "voltage";
>>> };
>>>
>>> Option 2: Array of strings for all sensors.
>>>
>>> nct7802 {
>>>         compatible = "nuvoton,nct7802";
>>>         reg = <0x2a>;
>>>         nuvoton,sensors-types = "thermistor", "disabled", "voltage";
>>> };
>>
>> It seems you are just listing out all possible modes. Why do you need
>> this in the DT at all? This can be inferred by the compatible string.
>
> There are tree sensor, each of one can be one of three type ("thermal
> diode", "thermistor", "voltage") or be disabled.
> Also there are at least five platform depended registers, most of them
> are enable/disable.
> You can find full datasheet here
> https://www.nuvoton.com/hq/products/cloud-computing/hardware-monitors/desktop-server-series/nct7802y/
>
> The question is how to describe configuration of this registers in dts.
> The second option is array of types for tree registers.

Okay, got it. I would go with option 2 in that case. Perhaps "mode"
instead of "type" though.

Rob

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Please suggest proper format for DT properties.
  2015-09-18 22:36 Please suggest proper format for DT properties Constantine Shulyupin
  2015-09-21  1:51 ` Rob Herring
@ 2015-09-22  8:36 ` Arnd Bergmann
  2015-09-22 15:08   ` Guenter Roeck
  1 sibling, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2015-09-22  8:36 UTC (permalink / raw)
  To: Constantine Shulyupin, Jean Delvare
  Cc: open list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Guenter Roeck, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala

On Saturday 19 September 2015 01:36:43 Constantine Shulyupin wrote:
> 
> I am designing DT support for a hwmon chip. 
> It has some sensors, each of them can be:
>  - "disabled"
>  - "thermal diode"
>  - "thermistor"
>  - "voltage"
> 
> Four possible options for DT properties format.
> 
> Option 1: Separated property for each sensor.
> 
> Example nct7802 node:
> 
> nct7802 {
>         compatible = "nuvoton,nct7802";
>         reg = <0x2a>;
>         nuvoton,sensor1-type = "thermistor";
>         nuvoton,sensor2-type = "disabled";
>         nuvoton,sensor3-type = "voltage";
> };
> 
> Option 2: Array of strings for all sensors.
> 
> nct7802 {
>         compatible = "nuvoton,nct7802";
>         reg = <0x2a>;
>         nuvoton,sensors-types = "thermistor", "disabled", "voltage";
> };
> 
> Option 3: Sets of 4 cells.
> 
>   Borrowed from marvell,reg-init and broadcom,c45-reg-init.
> 
>   The first cell is the page address, 
>   the second a register address within the page,
>   the third cell contains a mask to be ANDed with the existing register
>   value, and the fourth cell is ORed with the result to yield the
>   new register value. If the third cell has a value of zero,
>   no read of the existing value is performed.
> 
> Example nct7802 node:
> 
> nct7802 {
>         compatible = "nuvoton,nct7802";
>         reg = <0x2a>;
>         nct7802,reg-init =
>                 <0 0x21 0 0x01 > // START = 1
>                 <0 0x22 0x03 0x02>; // RTD1_MD = 2
> };
> 

I would strongly prefer Option 1 or 2 over option 3.
Between 1 and 2, I'd probably go for 1. Another option might
be to have a subnode per sensor:

nct7802@2a {
        compatible = "nuvoton,nct7802";
        reg = <0x2a>;
	#address-cells=<1>;
	#size-cells=<0>;

	sensor@1 {
		compatible = "nuvoton,nct7802-thermistor";
		further-properties;
	};
	sensor@3 {
		compatible = "nuvoton,nct7802-voltage";
		for-example-range-mv = <0 5000>;
	};
};

In either case, I'd say that disabled sensors should not need to
be listed.

	Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Please suggest proper format for DT properties.
  2015-09-22  8:36 ` Arnd Bergmann
@ 2015-09-22 15:08   ` Guenter Roeck
  2015-09-22 15:17     ` Arnd Bergmann
  0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2015-09-22 15:08 UTC (permalink / raw)
  To: Arnd Bergmann, Constantine Shulyupin, Jean Delvare
  Cc: open list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala

On 09/22/2015 01:36 AM, Arnd Bergmann wrote:
> On Saturday 19 September 2015 01:36:43 Constantine Shulyupin wrote:
>>
>> I am designing DT support for a hwmon chip.
>> It has some sensors, each of them can be:
>>   - "disabled"
>>   - "thermal diode"
>>   - "thermistor"
>>   - "voltage"
>>
>> Four possible options for DT properties format.
>>
>> Option 1: Separated property for each sensor.
>>
>> Example nct7802 node:
>>
>> nct7802 {
>>          compatible = "nuvoton,nct7802";
>>          reg = <0x2a>;
>>          nuvoton,sensor1-type = "thermistor";
>>          nuvoton,sensor2-type = "disabled";
>>          nuvoton,sensor3-type = "voltage";
>> };
>>
>> Option 2: Array of strings for all sensors.
>>
>> nct7802 {
>>          compatible = "nuvoton,nct7802";
>>          reg = <0x2a>;
>>          nuvoton,sensors-types = "thermistor", "disabled", "voltage";
>> };
>>
>> Option 3: Sets of 4 cells.
>>
>>    Borrowed from marvell,reg-init and broadcom,c45-reg-init.
>>
>>    The first cell is the page address,
>>    the second a register address within the page,
>>    the third cell contains a mask to be ANDed with the existing register
>>    value, and the fourth cell is ORed with the result to yield the
>>    new register value. If the third cell has a value of zero,
>>    no read of the existing value is performed.
>>
>> Example nct7802 node:
>>
>> nct7802 {
>>          compatible = "nuvoton,nct7802";
>>          reg = <0x2a>;
>>          nct7802,reg-init =
>>                  <0 0x21 0 0x01 > // START = 1
>>                  <0 0x22 0x03 0x02>; // RTD1_MD = 2
>> };
>>
>
> I would strongly prefer Option 1 or 2 over option 3.
> Between 1 and 2, I'd probably go for 1. Another option might
> be to have a subnode per sensor:
>
> nct7802@2a {
>          compatible = "nuvoton,nct7802";
>          reg = <0x2a>;
> 	#address-cells=<1>;
> 	#size-cells=<0>;
>
> 	sensor@1 {
> 		compatible = "nuvoton,nct7802-thermistor";
> 		further-properties;
> 	};
> 	sensor@3 {
> 		compatible = "nuvoton,nct7802-voltage";
> 		for-example-range-mv = <0 5000>;
> 	};
> };
>
I personally would prefer this approach. It would also make it easier to add more
properties. Wonder what is more appropriate, though - a compatible property or
something like the following ?
		sensor-type = "xxx";

I don't have a preference, just asking.

Also, would the index be derived from "@1", or should there be a reg property ?

> In either case, I'd say that disabled sensors should not need to
> be listed.
>
Agreed.

Thanks,
Guenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Please suggest proper format for DT properties.
  2015-09-22 15:08   ` Guenter Roeck
@ 2015-09-22 15:17     ` Arnd Bergmann
  0 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2015-09-22 15:17 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Constantine Shulyupin, Jean Delvare, open list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala

On Tuesday 22 September 2015 08:08:25 Guenter Roeck wrote:
> > I would strongly prefer Option 1 or 2 over option 3.
> > Between 1 and 2, I'd probably go for 1. Another option might
> > be to have a subnode per sensor:
> >
> > nct7802@2a {
> >          compatible = "nuvoton,nct7802";
> >          reg = <0x2a>;
> >       #address-cells=<1>;
> >       #size-cells=<0>;
> >
> >       sensor@1 {
> >               compatible = "nuvoton,nct7802-thermistor";
> >               further-properties;
> >       };
> >       sensor@3 {
> >               compatible = "nuvoton,nct7802-voltage";
> >               for-example-range-mv = <0 5000>;
> >       };
> > };
> >
> I personally would prefer this approach. It would also make it easier to add more
> properties. Wonder what is more appropriate, though - a compatible property or
> something like the following ?
>                 sensor-type = "xxx";
> 
> I don't have a preference, just asking.

I'm not sure here, either way would work, and we are not particularly
consistent in this regard. Maybe someone else has a stronger preference.

> Also, would the index be derived from "@1", or should there be a reg property ?

There needs to be a 'reg' property. Sorry for missing that above.

	Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-22 15:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-18 22:36 Please suggest proper format for DT properties Constantine Shulyupin
2015-09-21  1:51 ` Rob Herring
2015-09-21 19:24   ` Constantine Shulyupin
2015-09-22  0:32     ` Rob Herring
2015-09-22  8:36 ` Arnd Bergmann
2015-09-22 15:08   ` Guenter Roeck
2015-09-22 15:17     ` Arnd Bergmann

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).