From the pm-components property exported by the device, the Device Power Management framework knows what power levels the device supports. Power level values must be positive integers. The interpretation of power levels is determined by the device driver writer, but they must be listed in monotonically increasing order in the pm-components property, and a power level of 0 is interpreted by the framework to mean off. When the framework must power up a device because of a dependency, it will bring each component to its highest power level.
Example 9-1 is an example pm-components entry from the .conf file of a driver which implements a single power-managed component consisting of a disk spindle motor. The disk spindle motor is component 0 and it supports 2 power levels, which represent stopped and spinning full speed.
pm-components="NAME=Spindle Motor", "0=Stopped", "1=Full Speed";
Example 9-2 shows an example of how Example 9-1 could be implemented in the attach() routine of the driver.
static char *pmcomps[] = { "NAME=Spindle Motor", "0=Stopped", "1=Full Speed" }; ... xxattach(dev_info_t *dip, ddi_attach_cmd_t cmd) { ... if (ddi_prop_update_string_array(DDI_DEV_T_NONE, dip, "pm-components", &pmcomp[0], sizeof (pmcomps) / sizeof (char *)) != DDI_PROP_SUCCESS) goto failed; ...
Example 9-3 shows a frame buffer that implements two components. Component 0 is the frame buffer electronics that support 4 different power levels. Component 1 represents the state of power management of the attached monitor.
pm-components="NAME=Frame Buffer", "0=Off", "1=Suspend", "2=Standby", "3=On", "NAME=Monitor", "0=Off", "1=Suspend", "2=Standby", "3=On";
When a device driver is first attached, the framework does not know the power level of the device. A power transition may occur when:
The driver calls pm_raise_power(9F) or pm_lower_power(9F).
The framework has lowered the power level of a component because it has exceeded its threshold time.
Once a power transition has occurred or the driver has informed the framework of the power level, the framework tracks the current power level of each component of the device. The driver can inform the framework of a power level change by calling pm_power_has_changed(9F).
The system calculates a default threshold for each possible transition from one power level to the next lower level, based on the system idleness threshold. These default thresholds can be overridden using dtpower(1M) or power.conf(4). Another default threshold, based on the system idleness threshold, is used when the component power level is unknown.