aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/devfreq
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/devfreq')
-rw-r--r--drivers/devfreq/Kconfig41
-rw-r--r--drivers/devfreq/devfreq.c10
2 files changed, 25 insertions, 26 deletions
diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
index 643b055ed3c..8f049103708 100644
--- a/drivers/devfreq/Kconfig
+++ b/drivers/devfreq/Kconfig
@@ -1,36 +1,29 @@
1config ARCH_HAS_DEVFREQ
2 bool
3 depends on ARCH_HAS_OPP
4 help
5 Denotes that the architecture supports DEVFREQ. If the architecture
6 supports multiple OPP entries per device and the frequency of the
7 devices with OPPs may be altered dynamically, the architecture
8 supports DEVFREQ.
9
10menuconfig PM_DEVFREQ 1menuconfig PM_DEVFREQ
11 bool "Generic Dynamic Voltage and Frequency Scaling (DVFS) support" 2 bool "Generic Dynamic Voltage and Frequency Scaling (DVFS) support"
12 depends on PM_OPP && ARCH_HAS_DEVFREQ
13 help 3 help
14 With OPP support, a device may have a list of frequencies and 4 A device may have a list of frequencies and voltages available.
15 voltages available. DEVFREQ, a generic DVFS framework can be 5 devfreq, a generic DVFS framework can be registered for a device
16 registered for a device with OPP support in order to let the 6 in order to let the governor provided to devfreq choose an
17 governor provided to DEVFREQ choose an operating frequency 7 operating frequency based on the device driver's policy.
18 based on the OPP's list and the policy given with DEVFREQ.
19 8
20 Each device may have its own governor and policy. DEVFREQ can 9 Each device may have its own governor and policy. Devfreq can
21 reevaluate the device state periodically and/or based on the 10 reevaluate the device state periodically and/or based on the
22 OPP list changes (each frequency/voltage pair in OPP may be 11 notification to "nb", a notifier block, of devfreq.
23 disabled or enabled).
24 12
25 Like some CPUs with CPUFREQ, a device may have multiple clocks. 13 Like some CPUs with CPUfreq, a device may have multiple clocks.
26 However, because the clock frequencies of a single device are 14 However, because the clock frequencies of a single device are
27 determined by the single device's state, an instance of DEVFREQ 15 determined by the single device's state, an instance of devfreq
28 is attached to a single device and returns a "representative" 16 is attached to a single device and returns a "representative"
29 clock frequency from the OPP of the device, which is also attached 17 clock frequency of the device, which is also attached
30 to a device by 1-to-1. The device registering DEVFREQ takes the 18 to a device by 1-to-1. The device registering devfreq takes the
31 responsiblity to "interpret" the frequency listed in OPP and 19 responsiblity to "interpret" the representative frequency and
32 to set its every clock accordingly with the "target" callback 20 to set its every clock accordingly with the "target" callback
33 given to DEVFREQ. 21 given to devfreq.
22
23 When OPP is used with the devfreq device, it is recommended to
24 register devfreq's nb to the OPP's notifier head. If OPP is
25 used with the devfreq device, you may use OPP helper
26 functions defined in devfreq.h.
34 27
35if PM_DEVFREQ 28if PM_DEVFREQ
36 29
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 5d15b812377..59d24e9cb8c 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -15,7 +15,9 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/module.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/stat.h>
19#include <linux/opp.h> 21#include <linux/opp.h>
20#include <linux/devfreq.h> 22#include <linux/devfreq.h>
21#include <linux/workqueue.h> 23#include <linux/workqueue.h>
@@ -416,10 +418,14 @@ out:
416 */ 418 */
417int devfreq_remove_device(struct devfreq *devfreq) 419int devfreq_remove_device(struct devfreq *devfreq)
418{ 420{
421 bool central_polling;
422
419 if (!devfreq) 423 if (!devfreq)
420 return -EINVAL; 424 return -EINVAL;
421 425
422 if (!devfreq->governor->no_central_polling) { 426 central_polling = !devfreq->governor->no_central_polling;
427
428 if (central_polling) {
423 mutex_lock(&devfreq_list_lock); 429 mutex_lock(&devfreq_list_lock);
424 while (wait_remove_device == devfreq) { 430 while (wait_remove_device == devfreq) {
425 mutex_unlock(&devfreq_list_lock); 431 mutex_unlock(&devfreq_list_lock);
@@ -431,7 +437,7 @@ int devfreq_remove_device(struct devfreq *devfreq)
431 mutex_lock(&devfreq->lock); 437 mutex_lock(&devfreq->lock);
432 _remove_devfreq(devfreq, false); /* it unlocks devfreq->lock */ 438 _remove_devfreq(devfreq, false); /* it unlocks devfreq->lock */
433 439
434 if (!devfreq->governor->no_central_polling) 440 if (central_polling)
435 mutex_unlock(&devfreq_list_lock); 441 mutex_unlock(&devfreq_list_lock);
436 442
437 return 0; 443 return 0;