Skip to content

Commit c0d9ca1

Browse files
gmarullnordic-krch
authored andcommitted
[nrf fromtree] pm: device: allow optional support of TURN_ON action
Some devices, e.g. SoC level devices like I2C peripheral, can never be powerd off as they are always energized. Such devices can only go from an active state or to a low power state (suspended). Allow them to simply return -ENOTSUP when called with TURN_ON (or TURN_OFF). Signed-off-by: Gerard Marull-Paretas <[email protected]> (cherry picked from commit 740eba1)
1 parent 8d6fc59 commit c0d9ca1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

include/zephyr/pm/device.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ bool pm_device_is_powered(const struct device *dev);
625625
* This helper function is intended to be called at the end of a driver
626626
* init function to automatically setup the device into the lowest power
627627
* mode. It assumes that the device has been configured as if it is in
628-
* @ref PM_DEVICE_STATE_OFF.
628+
* @ref PM_DEVICE_STATE_OFF, or @ref PM_DEVICE_STATE_SUSPENDED if device can
629+
* never be powered off.
629630
*
630631
* @param dev Device instance.
631632
* @param action_cb Device PM control callback function.
@@ -718,7 +719,7 @@ static inline int pm_device_driver_init(const struct device *dev, pm_device_acti
718719

719720
/* When power management is not enabled, all drivers should initialise to active state */
720721
rc = action_cb(dev, PM_DEVICE_ACTION_TURN_ON);
721-
if (rc < 0) {
722+
if ((rc < 0) && (rc != -ENOTSUP)) {
722723
return rc;
723724
}
724725

subsys/pm/device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ int pm_device_driver_init(const struct device *dev,
370370

371371
/* Run power-up logic */
372372
rc = action_cb(dev, PM_DEVICE_ACTION_TURN_ON);
373-
if (rc != 0) {
373+
if ((rc < 0) && (rc != -ENOTSUP)) {
374374
return rc;
375375
}
376376

0 commit comments

Comments
 (0)