* ina2xx: New DT properties
@ 2016-11-15 19:52 Clemens Gruber
2016-11-15 20:25 ` Rob Herring
0 siblings, 1 reply; 4+ messages in thread
From: Clemens Gruber @ 2016-11-15 19:52 UTC (permalink / raw)
To: linux-hwmon; +Cc: Guenter Roeck, Rob Herring, Jean Delvare
Hi,
I am preparing a patch for the ina2xx driver to allow configuring the
PGA bits (which define the shunt voltage range) and the BRNG bit (which
defines the bus voltage range) from the device tree.
We have multiple INA219 with different voltage ranges, so I can't just
change the hardcoded default in ina2xx.c
The ADC averaging setting should also be configurable.
Now I am asking myself if I should create several new DT properties or
rather add one config-reg property to set a different default value for
the 16-bit configuration register (instead of the driver defaults of
0x399F for the INA219 and 0x4527 for the INA226) ?
Solution A:
ina219_foo: ina219@44 {
compatible = "ti,ina219";
reg = <0x44>;
shunt-resistor = <25000>;
pga = <2>; /* PGA Gain /2 instead of the default /8 */
/* Note: Possible PGA Gain values are /1, /2, /4 and /8 */
has-16v-brng; /* Bus voltage range of 16V instead of 32V */
averaging = <128>; /* Average 128 samples */
};
Should each of those also have a sysfs attribute?
Solution B:
ina219_bar: ina219@45 {
compatible = "ti,ina219";
reg = <0x45>;
shunt-resistor = <25000>;
config-reg = <0x019F>; /* PGA /1, BRNG = 16V, No averaging */
};
Regards,
Clemens
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: ina2xx: New DT properties
2016-11-15 19:52 ina2xx: New DT properties Clemens Gruber
@ 2016-11-15 20:25 ` Rob Herring
2016-11-15 21:04 ` Guenter Roeck
2016-11-16 10:50 ` Clemens Gruber
0 siblings, 2 replies; 4+ messages in thread
From: Rob Herring @ 2016-11-15 20:25 UTC (permalink / raw)
To: Clemens Gruber; +Cc: linux-hwmon, Guenter Roeck, Jean Delvare
On Tue, Nov 15, 2016 at 1:52 PM, Clemens Gruber
<clemens.gruber@pqgruber.com> wrote:
> Hi,
>
> I am preparing a patch for the ina2xx driver to allow configuring the
> PGA bits (which define the shunt voltage range) and the BRNG bit (which
> defines the bus voltage range) from the device tree.
> We have multiple INA219 with different voltage ranges, so I can't just
> change the hardcoded default in ina2xx.c
> The ADC averaging setting should also be configurable.
>
> Now I am asking myself if I should create several new DT properties or
> rather add one config-reg property to set a different default value for
> the 16-bit configuration register (instead of the driver defaults of
> 0x399F for the INA219 and 0x4527 for the INA226) ?
>
> Solution A:
Generally, this is preferred.
> ina219_foo: ina219@44 {
> compatible = "ti,ina219";
> reg = <0x44>;
> shunt-resistor = <25000>;
>
> pga = <2>; /* PGA Gain /2 instead of the default /8 */
> /* Note: Possible PGA Gain values are /1, /2, /4 and /8 */
>
> has-16v-brng; /* Bus voltage range of 16V instead of 32V */
>
> averaging = <128>; /* Average 128 samples */
> };
>
> Should each of those also have a sysfs attribute?
These should probably be in DT or in sysfs, but not both. The decision
should be based on how are the settings picked: by the h/w design or
an end user will want to modify them.
> Solution B:
>
> ina219_bar: ina219@45 {
> compatible = "ti,ina219";
> reg = <0x45>;
> shunt-resistor = <25000>;
>
> config-reg = <0x019F>; /* PGA /1, BRNG = 16V, No averaging */
> };
>
> Regards,
> Clemens
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: ina2xx: New DT properties
2016-11-15 20:25 ` Rob Herring
@ 2016-11-15 21:04 ` Guenter Roeck
2016-11-16 10:50 ` Clemens Gruber
1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2016-11-15 21:04 UTC (permalink / raw)
To: Rob Herring; +Cc: Clemens Gruber, linux-hwmon, Jean Delvare
On Tue, Nov 15, 2016 at 02:25:11PM -0600, Rob Herring wrote:
> On Tue, Nov 15, 2016 at 1:52 PM, Clemens Gruber
> <clemens.gruber@pqgruber.com> wrote:
> > Hi,
> >
> > I am preparing a patch for the ina2xx driver to allow configuring the
> > PGA bits (which define the shunt voltage range) and the BRNG bit (which
> > defines the bus voltage range) from the device tree.
> > We have multiple INA219 with different voltage ranges, so I can't just
> > change the hardcoded default in ina2xx.c
> > The ADC averaging setting should also be configurable.
> >
> > Now I am asking myself if I should create several new DT properties or
> > rather add one config-reg property to set a different default value for
> > the 16-bit configuration register (instead of the driver defaults of
> > 0x399F for the INA219 and 0x4527 for the INA226) ?
> >
> > Solution A:
>
> Generally, this is preferred.
>
> > ina219_foo: ina219@44 {
> > compatible = "ti,ina219";
> > reg = <0x44>;
> > shunt-resistor = <25000>;
> >
> > pga = <2>; /* PGA Gain /2 instead of the default /8 */
> > /* Note: Possible PGA Gain values are /1, /2, /4 and /8 */
> >
> > has-16v-brng; /* Bus voltage range of 16V instead of 32V */
> >
> > averaging = <128>; /* Average 128 samples */
> > };
> >
> > Should each of those also have a sysfs attribute?
>
> These should probably be in DT or in sysfs, but not both. The decision
> should be based on how are the settings picked: by the h/w design or
> an end user will want to modify them.
>
Agreed.
Guenter
> > Solution B:
> >
> > ina219_bar: ina219@45 {
> > compatible = "ti,ina219";
> > reg = <0x45>;
> > shunt-resistor = <25000>;
> >
> > config-reg = <0x019F>; /* PGA /1, BRNG = 16V, No averaging */
> > };
> >
> > Regards,
> > Clemens
> --
> To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: ina2xx: New DT properties
2016-11-15 20:25 ` Rob Herring
2016-11-15 21:04 ` Guenter Roeck
@ 2016-11-16 10:50 ` Clemens Gruber
1 sibling, 0 replies; 4+ messages in thread
From: Clemens Gruber @ 2016-11-16 10:50 UTC (permalink / raw)
To: Rob Herring, Guenter Roeck; +Cc: linux-hwmon, Jean Delvare
On Tue, Nov 15, 2016 at 02:25:11PM -0600, Rob Herring wrote:
> On Tue, Nov 15, 2016 at 1:52 PM, Clemens Gruber
> <clemens.gruber@pqgruber.com> wrote:
> > Hi,
> >
> > I am preparing a patch for the ina2xx driver to allow configuring the
> > PGA bits (which define the shunt voltage range) and the BRNG bit (which
> > defines the bus voltage range) from the device tree.
> > We have multiple INA219 with different voltage ranges, so I can't just
> > change the hardcoded default in ina2xx.c
> > The ADC averaging setting should also be configurable.
> >
> > Now I am asking myself if I should create several new DT properties or
> > rather add one config-reg property to set a different default value for
> > the 16-bit configuration register (instead of the driver defaults of
> > 0x399F for the INA219 and 0x4527 for the INA226) ?
> >
> > Solution A:
>
> Generally, this is preferred.
>
> > ina219_foo: ina219@44 {
> > compatible = "ti,ina219";
> > reg = <0x44>;
> > shunt-resistor = <25000>;
> >
> > pga = <2>; /* PGA Gain /2 instead of the default /8 */
> > /* Note: Possible PGA Gain values are /1, /2, /4 and /8 */
> >
> > has-16v-brng; /* Bus voltage range of 16V instead of 32V */
> >
> > averaging = <128>; /* Average 128 samples */
> > };
> >
> > Should each of those also have a sysfs attribute?
>
> These should probably be in DT or in sysfs, but not both. The decision
> should be based on how are the settings picked: by the h/w design or
> an end user will want to modify them.
Thanks Rob and Guenter.
The settings depend on the hardware design and will probably be set
only once. I'll add them as device tree properties.
Maybe changing the averaging setting via sysfs could be useful. But we
can add that later if needed.
Regards,
Clemens
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-16 10:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-15 19:52 ina2xx: New DT properties Clemens Gruber
2016-11-15 20:25 ` Rob Herring
2016-11-15 21:04 ` Guenter Roeck
2016-11-16 10:50 ` Clemens Gruber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox