This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

initialize device to DEVICE_PM_OFF_STATE?

I have a nRF5340 with a UART that connects to a circuit that is not powered on until it is needed by the application.  So the UART must be powered off until the application requires it.  I see that there is a function device_set_power_state that I can use with DEVICE_PM_ACTIVE_STATE to turn it on.  However, I don't see a way to initialize the device to DEVICE_PM_OFF_STATE.  Is there something I need to do in the dts to indicate that?

Parents
  • Hey Denis!

    It is a bit tricky to make make the peripheral not to start off being initialized. The Zephyr drivers don't allow you to do that, though you can use the nrfx ones.

    Take a look at this post.

    Best regards,

    Elfving

  • There doesn't seem to be anything to preclude a driver initializing into DEVICE_PM_OFF_STATE.  Would be great to have a configuration option, something like CONFIG_UART_3_NRF_PM_OFF_STATE=y, for this in the uart_nrfx_uarte.c driver.  I may look at adding that, unless you know of something in Zephyr that would cause that not to work?

  • Hello Denis!

    denis said:
    There doesn't seem to be anything to preclude a driver initializing into DEVICE_PM_OFF_STATE.
    denis said:
    I may look at adding that, unless you know of something in Zephyr that would cause that not to work?

    It isn't possible to defer the Zephyr driver model init functions; they are always run before main(). But what you can do is something along the lines of what we've done here & here: return -EBUSY when driver is still initializing.

    denis said:
    Would be great to have a configuration option, something like CONFIG_UART_3_NRF_PM_OFF_STATE=y

    Yes, absolutely. I had a talk with one of our SW engineers about it, and he think he's seen some issue upstream about this, but isn't sure.

    Modifying drivers can be a hassle though. Any reason why you can't simply turn it off at the start of the application?

    Best regards,

    Elfving

Reply
  • Hello Denis!

    denis said:
    There doesn't seem to be anything to preclude a driver initializing into DEVICE_PM_OFF_STATE.
    denis said:
    I may look at adding that, unless you know of something in Zephyr that would cause that not to work?

    It isn't possible to defer the Zephyr driver model init functions; they are always run before main(). But what you can do is something along the lines of what we've done here & here: return -EBUSY when driver is still initializing.

    denis said:
    Would be great to have a configuration option, something like CONFIG_UART_3_NRF_PM_OFF_STATE=y

    Yes, absolutely. I had a talk with one of our SW engineers about it, and he think he's seen some issue upstream about this, but isn't sure.

    Modifying drivers can be a hassle though. Any reason why you can't simply turn it off at the start of the application?

    Best regards,

    Elfving

Children
No Data
Related