Description
Is your feature request related to a problem? Please describe.
Until now, Zephyr allows enabling of the needed peripherals at compile time via Kconfig infrastructure. This is done to reduce code size. In this way the firmware expects that the needed peripheral devices are connected. If the devices are not connected, e.g. a disconnected shield, the firmware can handle this by omitting reading from this port.
The downside to this one is increased power consumption. The GPIO pins have already been initialized in a mode that expects active connection (UART, I2C). These pins are floating and their state is not power efficient. Also clocks for the peripherals have been enabled, so also these should be disabled.
Describe the solution you'd like
I would like to have a driver API like some_peripheral_deinit
. This will for sure disable the peripheral's clock. Either called by the user after a failed call to device_get_binding
, or automatically in the driver's init()
. The last case could be mapped to a Kconfig symbol.
The above is easy for the peripheral's clocks. For the GPIOs needed to be disabled some extra DTS fixups should be added for each peripheral to make them accessible.
Describe alternatives you've considered
Currently I'm doing the whole procedure either at application level, after checking a device_get_binding()
. I've also done some of the solution previously described in a private clone.
Additional context
The use case I want to achieve is to have a dynamic firmware that on board power checks ports for known to-be-connected devices (UART, I2C). If there isn't a connected device then disables the port to reduce power consumption. For this kind of application I don't care for code size. I enable a big number of supported peripherals and then sense which are connected.
Metadata
Metadata
Type
Projects
Status