Re: [PATCH v2 0/2] iio: add unit converter
From: Rob Herring
Date: Tue Apr 10 2018 - 09:07:04 EST
On Tue, Apr 03, 2018 at 08:09:08PM +0200, Peter Rosin wrote:
> On 2018-04-03 19:41, Andrew F. Davis wrote:
> > On 04/03/2018 10:36 AM, Peter Rosin wrote:
> >> Hi!
> >>
> >> This driver implements support for voltage dividers and current
> >> sense circuits. It's pretty generic and should be easily adaptable
> >> to other linear scaling purposes...
> >>
> >
> > I really like this idea, defining channel scaling / channel type
> > conversion in DT will be very useful. So much so that I would recommend
> > this not be a use specific driver but instead moved into the IIO core.
> >
> > This would allow defining these channel conversions in the device node
> > itself, so as to not need a separate node just for the converter (the
> > conversion is not a device and probably should not have it's own node
> > anyway). It would also help with enabling this support for buffered
> > readers/writers and not just devices only supporting _raw reads/writes.
>
> In my case, the voltage dividers and the current sense circuit are very
> much real, and I can point my finger at them on the board. Sure, they
> are not ICs, but to not call them devices is wrong IMHO, and the ADC
> which is involved have very little to do with the voltage dividers and
> the fact that it is involved in sensing current. This is not an argument
> for not moving the functionally to the core though, but that has some
> problems AFAICT. Because you need some kind of clever and generic
> binding to make the core do its thing, and it might not be easy to come
> up with something that fits all devices? And if we do put this in the
> core, that opens the door for more complex unit converters later on
> (non-linear etc), further complicating the generic bindings.
I agree. We've learned the hard way that even things like the LED diode
itself need to be described and not just the controller.
Rob