pm: device: add action to turn device on

Adds `PM_DEVICE_ACTION_TURN_ON` to transition from `PM_DEVICE_STATE_OFF`
to `PM_DEVICE_STATE_SUSPENDED`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2022-01-05 17:18:37 +10:00 committed by Anas Nashif
parent 2e732dff6d
commit 79f382e96e
2 changed files with 9 additions and 0 deletions

View file

@ -75,6 +75,8 @@ enum pm_device_action {
PM_DEVICE_ACTION_RESUME,
/** Turn off. */
PM_DEVICE_ACTION_TURN_OFF,
/** Turn on. */
PM_DEVICE_ACTION_TURN_ON,
/** Force suspend. */
PM_DEVICE_ACTION_FORCE_SUSPEND,
};

View file

@ -119,6 +119,13 @@ int pm_device_action_run(const struct device *dev,
state = PM_DEVICE_STATE_OFF;
break;
case PM_DEVICE_ACTION_TURN_ON:
if (pm->state != PM_DEVICE_STATE_OFF) {
return -ENOTSUP;
}
state = PM_DEVICE_STATE_SUSPENDED;
break;
default:
return -ENOTSUP;
}