aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/devfreq.h
diff options
context:
space:
mode:
authorRajagopal Venkat <rajagopal.venkat@linaro.org>2012-10-25 19:50:09 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-14 18:35:04 -0500
commit7e6fdd4bad033fa2d73716377b184fa975b0d985 (patch)
tree171f13c8aadd833965a9cb0b83a84fe3eb74c1da /include/linux/devfreq.h
parent77b67063bb6bce6d475e910d3b886a606d0d91f7 (diff)
PM / devfreq: Core updates to support devices which can idle
Prepare devfreq core framework to support devices which can idle. When device idleness is detected perhaps through runtime-pm, need some mechanism to suspend devfreq load monitoring and resume back when device is online. Present code continues monitoring unless device is removed from devfreq core. This patch introduces following design changes, - use per device work instead of global work to monitor device load. This enables suspend/resume of device devfreq and reduces monitoring code complexity. - decouple delayed work based load monitoring logic from core by introducing helpers functions to be used by governors. This provides flexibility for governors either to use delayed work based monitoring functions or to implement their own mechanism. - devfreq core interacts with governors via events to perform specific actions. These events include start/stop devfreq. This sets ground for adding suspend/resume events. The devfreq apis are not modified and are kept intact. Signed-off-by: Rajagopal Venkat <rajagopal.venkat@linaro.org> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/linux/devfreq.h')
-rw-r--r--include/linux/devfreq.h34
1 files changed, 10 insertions, 24 deletions
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
index 281c72a3b9d5..9cdffde74bb5 100644
--- a/include/linux/devfreq.h
+++ b/include/linux/devfreq.h
@@ -91,25 +91,18 @@ struct devfreq_dev_profile {
91 * status of the device (load = busy_time / total_time). 91 * status of the device (load = busy_time / total_time).
92 * If no_central_polling is set, this callback is called 92 * If no_central_polling is set, this callback is called
93 * only with update_devfreq() notified by OPP. 93 * only with update_devfreq() notified by OPP.
94 * @init Called when the devfreq is being attached to a device 94 * @event_handler Callback for devfreq core framework to notify events
95 * @exit Called when the devfreq is being removed from a 95 * to governors. Events include per device governor
96 * device. Governor should stop any internal routines 96 * init and exit, opp changes out of devfreq, suspend
97 * before return because related data may be 97 * and resume of per device devfreq during device idle.
98 * freed after exit().
99 * @no_central_polling Do not use devfreq's central polling mechanism.
100 * When this is set, devfreq will not call
101 * get_target_freq with devfreq_monitor(). However,
102 * devfreq will call get_target_freq with
103 * devfreq_update() notified by OPP framework.
104 * 98 *
105 * Note that the callbacks are called with devfreq->lock locked by devfreq. 99 * Note that the callbacks are called with devfreq->lock locked by devfreq.
106 */ 100 */
107struct devfreq_governor { 101struct devfreq_governor {
108 const char name[DEVFREQ_NAME_LEN]; 102 const char name[DEVFREQ_NAME_LEN];
109 int (*get_target_freq)(struct devfreq *this, unsigned long *freq); 103 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
110 int (*init)(struct devfreq *this); 104 int (*event_handler)(struct devfreq *devfreq,
111 void (*exit)(struct devfreq *this); 105 unsigned int event, void *data);
112 const bool no_central_polling;
113}; 106};
114 107
115/** 108/**
@@ -124,18 +117,13 @@ struct devfreq_governor {
124 * @nb notifier block used to notify devfreq object that it should 117 * @nb notifier block used to notify devfreq object that it should
125 * reevaluate operable frequencies. Devfreq users may use 118 * reevaluate operable frequencies. Devfreq users may use
126 * devfreq.nb to the corresponding register notifier call chain. 119 * devfreq.nb to the corresponding register notifier call chain.
127 * @polling_jiffies interval in jiffies. 120 * @work delayed work for load monitoring.
128 * @previous_freq previously configured frequency value. 121 * @previous_freq previously configured frequency value.
129 * @next_polling the number of remaining jiffies to poll with
130 * "devfreq_monitor" executions to reevaluate
131 * frequency/voltage of the device. Set by
132 * profile's polling_ms interval.
133 * @data Private data of the governor. The devfreq framework does not 122 * @data Private data of the governor. The devfreq framework does not
134 * touch this. 123 * touch this.
135 * @being_removed a flag to mark that this object is being removed in
136 * order to prevent trying to remove the object multiple times.
137 * @min_freq Limit minimum frequency requested by user (0: none) 124 * @min_freq Limit minimum frequency requested by user (0: none)
138 * @max_freq Limit maximum frequency requested by user (0: none) 125 * @max_freq Limit maximum frequency requested by user (0: none)
126 * @stop_polling devfreq polling status of a device.
139 * 127 *
140 * This structure stores the devfreq information for a give device. 128 * This structure stores the devfreq information for a give device.
141 * 129 *
@@ -153,17 +141,15 @@ struct devfreq {
153 struct devfreq_dev_profile *profile; 141 struct devfreq_dev_profile *profile;
154 const struct devfreq_governor *governor; 142 const struct devfreq_governor *governor;
155 struct notifier_block nb; 143 struct notifier_block nb;
144 struct delayed_work work;
156 145
157 unsigned long polling_jiffies;
158 unsigned long previous_freq; 146 unsigned long previous_freq;
159 unsigned int next_polling;
160 147
161 void *data; /* private data for governors */ 148 void *data; /* private data for governors */
162 149
163 bool being_removed;
164
165 unsigned long min_freq; 150 unsigned long min_freq;
166 unsigned long max_freq; 151 unsigned long max_freq;
152 bool stop_polling;
167}; 153};
168 154
169#if defined(CONFIG_PM_DEVFREQ) 155#if defined(CONFIG_PM_DEVFREQ)