Writing Device Drivers

Power Management Flow of Control

The following sections describe the general flow of control for power management states from busy to powered off. The sequence of states differs depending on whether the component is component zero or another component. Figure 8-1 illustrates the flow of control in the Power Management framework.

Device Power Management Flow of Control for Component Zero

When a component's activity is complete, a driver can call pm_idle_component(9F) to mark the component as idle. When the component has been idle for its threshold time, the framework may power off the component. If the component is component zero, the framework calls the driver's detach(9E) entry point with the command DDI_PM_SUSPEND to enable the driver to save all hardware state to memory. The framework then calls the power(9E) entry point to set the power level of the component to power level zero.

When component zero is needed again, the driver calls ddi_dev_is_needed(9F) on the powered off component. The framework then calls power(9E) to power up the component and calls attach(9E) with the DDI_PM_RESUME command to restore the state of the device and unblock any pending operations. At this point, the ddi_dev_is_needed(9F) call returns to the device driver. The component is idle but powered on, and the driver can mark it as busy by calling pm_busy_component(9F).

Device Power Manangement Flow of Control for Components Other Than Component Zero

As with component zero, the driver uses pm_idle_component(9F) to mark components other than zero as idle. The framework may power off an idle component other than component zero by calling the power(9E) entry point to set the component to power level zero.

When a driver finds that a needed component is powered off, the driver calls ddi_dev_is_needed(9F) on the powered off component. When a driver calls ddi_dev_is_needed(9F) for a component other than component 0 that is powered off, the framework calls power(9E) to set the new power level before ddi_dev_is_needed(9F) returns. ddi_dev_is_needed(9F) keeps the framework informed of the state of the device and arranges for devices that this component depends on to be powered up. When ddi_dev_is_needed(9F) returns, the component is idle but powered on. The driver can mark it as busy by calling pm_busy_component(9F).

Figure 8-1 Power Management Conceptual State Diagram

Graphic