Device Idle Power Management

Browse source code on GitHub

Overview

This sample demonstrates Zephyr’s device power management subsystem using a parent-child device hierarchy. Two dummy devices (a parent bus device and a child peripheral device) are defined with PM action callbacks that handle PM_DEVICE_ACTION_SUSPEND and PM_DEVICE_ACTION_RESUME transitions.

The application performs the following sequence:

  1. The child device is opened, which resumes the parent first via pm_device_runtime_get(), then resumes itself.

  2. A write and read operation is performed through the parent bus.

  3. The child device is closed, which suspends both the child and parent via pm_device_runtime_put().

This sample shows how to:

Requirements

This sample does not require any special hardware and can be run on QEMU or any board that supports the device power management subsystem (CONFIG_PM_DEVICE).

Building and Running

Build and run the sample as follows, changing qemu_x86 for your board:

west build -b qemu_x86 samples/subsys/pm/device_pm
west build -t run

Sample Output

When the sample runs successfully, the following output is displayed on the console:

*** Booting Zephyr OS build zephyr-vX.Y.Z ***
Device PM sample app start
parent resuming..
child resuming..
Dummy device resumed
child suspending..
parent suspending..
Device PM sample app complete

Devices are initialized in a suspended state using pm_device_driver_init(). When the application opens the child device, both the parent and child are resumed. After performing I/O, the application closes the device, which suspends both the child and parent.

Exit QEMU by pressing CTRL+A x.

References

See also

Device
Device Runtime