The following device drivers offer relative frequency control and have an additive effect:
KERNEL INTERFACE
Kernel components can query and set CPU frequencies through the cpufreq kernel interface. This involves obtaining a cpufreq device, calling cpufreq_levels to get the currently available frequency levels, checking the current level with cpufreq_get, and setting a new one from the list with cpufreq_set. Each level may actually reference more than one cpufreq driver but kernel components do not need to be aware of this. The total_set element of
.Vt "struct cf_level" provides a summary of the frequency and power for this level. Unknown or irrelevant values are set to CPUFREQ_VAL_UNKNOWN. The cpufreq_levels method takes a cpufreq device and an empty array of levels. The count value should be set to the number of levels available and after the function completes, will be set to the actual number of levels returned. If there are more levels than count will allow, it should return E2BIG.
The cpufreq_get method takes a pointer to space to store a level. After successful completion, the output will be the current active level and is equal to one of the levels returned by cpufreq_levels.
Kernel drivers offering hardware-specific CPU frequency control export their individual settings through the cpufreq driver interface. This involves implementing these methods: cpufreq_drv_settings, cpufreq_drv_type, cpufreq_drv_set, and cpufreq_drv_get. Additionally, the driver must attach a device as a child of a CPU device so that these methods can be called by the cpufreq framework. The cpufreq_drv_settings method returns an array of currently available settings, each of type
.Vt "struct cf_setting" . The driver should set unknown or irrelevant values to CPUFREQ_VAL_UNKNOWN. All the following elements for each setting should be returned:
struct cf_setting {
intfreq; /* CPU clock in Mhz or 100ths of a percent. */
intvolts; /* Voltage in mV. */
intpower; /* Power consumed in mW. */
intlat; /* Transition latency in us. */
device_t dev; /* Driver providing this setting. */
};
On entry to this method, count contains the number of settings that can be returned. On successful completion, the driver sets it to the actual number of settings returned. If the driver offers more settings than count will allow, it should return E2BIG.
The cpufreq_drv_type method indicates the type of settings it offers, either CPUFREQ_TYPE_ABSOLUTE or CPUFREQ_TYPE_RELATIVE. Additionally, the driver may set the CPUFREQ_FLAG_INFO_ONLY flag if the settings it provides are information for other drivers only and cannot be passed to cpufreq_drv_set to activate them.
The cpufreq_drv_set method takes a driver setting and makes it active. If the setting is invalid or not currently available, it should return EINVAL.