Question about regulator API
From: Harald Geyer
Date: Wed Dec 14 2016 - 09:59:48 EST
Hi all!
I have a quite complex situation with regulator consumers, which I'm not
sure how to handle best.
Suppose there is some quirky HW that after some random time crashes - i.e.
it doesn't respond to requests anymore at all. The driver can detect this
situation and the only way to fix it is to disable the supply for 2 seconds,
then enable it again. Also after enabling the power supply the driver needs
to wait 2 seconds before talking to the HW.
Now the complicated part: The HW is some kind of sensor which often is
used in an array of identical devices. To make the wiring simpler all
these devices are attatched to the same supply (and maybe the same bus),
however they are read independently and thus also are independent devices
from the kernel POV.
Thus the following constraints should be met:
* When user space asks the driver to read a device, it needs to "claim"
the supply and ensure that it has been up for at least 2 seconds
before proceeding to read the HW. The supply would be "locked" enabled.
(I think this is standard regulator API.)
* When HW failure is detected, the driver needs to tell the supply to
turn off for at least 2 seconds, wait for all other devices to release
the supply so it can actually be turned off, then wait for the off period,
then start over again.
(This is easy only with getting the supply exclusively.)
* It should be possible to read multiple devices quickly when everything
is okay and working. (Having 6 2-second delays accumulate would be quite
annoying.)
(This won't work with exclusive supply usage.)
* Optionally: If all devices are idle the supply would be enabled if short
response time is desired, but disabled if power saving is desired.
Can this somehow be solved with the existing API?
If not, do you think it would be reasonable/possible to extend the API
to cover situations like the one described above?
Any help or hints are appreciated.
TIA,
Harald