driver depency ordering in zephyr

I have a system I'm working on that requires a complicated device init ordering.

The system has 2 voltage regulators each with an enable.  One regulator has the enable tied to a native (on-chip) gpio.  This provides one voltage rail (3V3).  this voltage rail must be enabled to provide power for an I/O expander, which has an output for the second voltage regulator.

So the init sequence must be:

enable regulator_3V3 via gpio0

init io_expander

configure regulator output on io_expander

enable regulator_5V via io_expander

init peripherals downstream from regulator_5V (via level shifter)

The problem I see is that voltage regulators all get assigned the same init priority, so I don't see how I would be able to init one regulator before the io_expander and the other regulator after the io_expander.

Is there a way to do this?  

Best approach I have come up with is to duplicate the regulator_fixed driver into a second driver that I could then assign a different init priority.

Also I saw some discussion from 2020 about making the driver init order based on dependencies, does that work?   Even if it does, how would I indicate the dependency between the regulator and the devices it powers?

Related