On Wed, 17 Feb 2021 10:34:38 +0200The way this DAC works is that it has a "latch" pin and some shadow registers. The way this is supposed to be used is that you update the shadow registers and then when the there is a rising edge on the latch pin all the shadow register values are transferred to DAC output registers.
Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx> wrote:
From: Mircea Caprioru <mircea.caprioru@xxxxxxxxxx>So this is taking a very generic setup, but then implementing it
A PWM signal will be used as a trigger source to have a deterministic
sampling frequency since this family of DAC has no hardware interrupt
source.
This feature is made optional however, as there are some board setups where
this isn't used.
as a bit of a hack within the driver.
It's effectively a PWM connected up to an instance
of iio/triggers/iio-trig-interrupt.c
Now, I've not looked at that trigger driver for a while, so you may well
need to figure out how to add a binding to instantiate it.
(looks like no one has used it since board file days, or via instantiation
from another driver).
It's a slightly odd corner case as what it reflects is that we have
an interrupt available that is intended to drive some sort of data
capture or output (it's a trigger signal) - but exactly what is done
is a runtime configurable. In this particular case that interrupt
is hooked up to a PWM and we also want to represent that.
The fact it's being driven via a PWM is interesting but we should be
able to extend that trigger driver to optionally accept a pwm provider
and if it has one provide frequency control.
Binding might look something like the following..
interrupt-trigger {
interrupts = <>;
pwms = <&pwm 0 4000 PWM_POLARITY_INVERTED>;
};
@Rob, what do you think of this odd beast?
So all in all, this generic facility needs a generic implementation, not
one buried in a driver.
Another open question here is whether you really can't just use an hrtimer
to get similar precision? Way back at the dawn of time in IIO we had
code to use the RTC periodic ticks as a trigger with the theory that they
would give very precise and even timing. In the end it turned out that
hrtimers worked just as well (and RTCs drivers emulated the periodic
ticks via hrtimers, dropping their use of the hardware periodic timers).