Closed
Description
There seems to be a cross-over of uses-cases/requirements between 2 issues around device initialization, so gathering both here for tracking and discussion.
- Allow for selective deferment of device initialization (aka manual init) Allow for selective deferment of device initialization (aka manual init) #39896
- Support peripheral deallocation at runtime Support peripheral deallocation at runtime #20012
Let's summarize the requirements:
Add the ability to manually initialize a device:
This means adding 2 things:
- marking a device as manually initialized
- exposing a device_init() function
Add the ability to de-initialize a device:
- exposing a device_deinit() function (or some other relevant name)
Cross-over requirements:
- Forcing initialization: device_deinit() needs to be called prior to device_init()
- In case PM is enabled: device_deninit() should call PM to put the device OFF (so all dependencies will also be properly affected)
- In case PM is not enabled: we will need a better error-management so if a device is put down, things will not just explode (dependencies still trying to access the device etc...). Device APIs do not check for device status, so currently calling a device that has been de-initialized, would lead to unknown state.