Power Management (2.4)

The Power Management (PM) subsystem is
The power management is compiled in the kernel with the CONFIG_PM option.
Power Management aware drivers rely on this subsystem in order to perform safely with a power managed hardware.
pm_register returns a pointer to a pm_dev (used thereon by the driver to communicate with the PM), on NULL if it fails. It takes three parameters,
The structure pm_dev contains data, flags and states are set to 0 by pm_register.
The pm_callback() takes three parameters, This function is called by the PM subsystem in a process context and may sleep. The drivers returns 0 on success. After a successful PM_SUSPEND the driver should not process request or access hardware until a call to pm_access is made.
The driver calls pm_access and pm_dev_idle with the pm_dev pointer returned by the pm_register.
The kernel interface of the PM subsystem comprises Finally the internal functions are

Exercise

Write a simple driver that registers with the PM susbsystem. Verify that the callback is invoked. You can force a suspend/resume with apmsleep,
apmsleep +00:01
See the manpage apmsleep.1 for more informations.
Here is a solution: example.c and the Makefile.


Marco Corvi - 2003