Re: [PATCH v2 0/2] Add support for AD4000 series
From: Jonathan Cameron
Date: Sat Apr 13 2024 - 12:07:47 EST
> >
> > - Span compression and offset.
> > For non-differential ADCs, enabling the span compression requires an input offset.
> > Link: https://www.analog.com/media/en/technical-documentation/data-sheets/AD4000-4004-4008.pdf
> > page 18
> > and
> > Link: https://www.analog.com/media/en/technical-documentation/data-sheets/ad4002-4006-4010.pdf
> > page 19
> > I updated the _offset attribute for those ADCs according to span compression
> > being enabled or not. Is it okay to have an attribute update cause an update to
> > another one?
Yes. Happens all the time and it's not possible in general to define an ABI where
this doesn't happen on some combinations. scale in particular can be affected in lots
of fun non linear ways by other attributes.
How you handle it is a bit up to the driver writer and interpretation of what is
most natural for a given combination.
Sometimes:
a) Stash previously set value of the other attributes and try to find a new value
as near as possible give constraint of whatever else was just written
b) Just use whatever the register value now corresponds to given the other attribute
changed
Either way userspace needs to take another look at other attributes to see if they
changed after changing anything that might have an influence. It can then update
them however it likes.
> > Maybe also make the span compression a dt property and have it fixed after probe?
>
> This doesn't sound like something that belongs in DT since it doesn't
> depend on the physical properties of what is wired to the input.
>
> But the fact that offset should not be read until after scale is set
> sounds like a quirk that would be worth documenting in some
> chip-specific docs.
Agreed - it is useful to hint at this but in general software has to check
everything as there are lots of these sorts of interactions :(
Jonathan