Custom driver Power Management in Zephyr
In our SoC, Few drivers(uart, dma, trng, gpio etc) use Zephyr device model and there are few drivers (wakeup timer, radio etc) does not use the zephyr driver. In that case the how to control the non zephyr driver (custom drivers) for the power management? For example Radio driver is outside of zephyr device driver sub system. In that case how to switch on or off the radio when the low power mode is entered in zephyr power management sub system?
Hi,There are some ways to do this. Which one is better will depend on what
you are doing.
- You can register a notification with a callback to be called when the
system is about suspend/resume and handle your devices there. Be aware
of the imposed constraints (IRQ lockeds). See:
void pm_notifier_register(struct pm_notifier *notifier)
int pm_notifier_unregister(struct pm_notifier *notifier)
- If you are implementing the hook to set the SoC state in
our application (implementing the method pm_power_state_set(struct
pm_state_info info)) you can suspend your devices there are resume them
in pm_power_state_exit_post_ops(struct pm_state_info info)
Note that in both cases, your application will be called after Zephyr
has handled all "know" devices.
There are other hacks that you can do, but these two (mainly the first)
are the best options IMHO.