pm: device_runtime: Power device on/off in pre-kernel

Devices may be initialized but started powered down for this reason
is necessary to power a device on if requested even if in pre-kernel
state.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-05-07 10:22:12 -07:00 committed by Anas Nashif
commit e89d9d65cc

View file

@ -124,6 +124,22 @@ static int pm_device_request(const struct device *dev,
* satisfied and this call just incremented the reference count
* for this device.
*/
/* Unfortunately this is not what is happening yet. There are
* cases, for example, like the pinmux being initialized before
* the gpio. For that reason let's power on/off the device
* here until we don't have it properly fixed.
*/
if (dev->pm->usage == 1) {
(void)pm_device_state_set(dev,
PM_DEVICE_ACTIVE_STATE,
NULL, NULL);
} else if (dev->pm->usage == 0) {
(void)pm_device_state_set(dev,
PM_DEVICE_SUSPEND_STATE,
NULL, NULL);
}
return 0;
}