aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/power
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2013-09-19 17:03:50 -0400
committerRafael J. Wysocki <rjw@rjwysocki.net>2013-10-25 16:33:23 -0400
commit5d4879cda67b09f086807821cf594ee079d6dfbe (patch)
tree58532256e9bff42902510175e7cb7c727a89280b /Documentation/power
parent31d141e3a666269a3b6fcccddb0351caf7454240 (diff)
PM / OPP: rename functions to dev_pm_opp*
Since Operating Performance Points (OPP) functions are specific to device specific power management, be specific and rename opp_* accessors in OPP library with dev_pm_opp_* equivalent. Affected functions are: opp_get_voltage opp_get_freq opp_get_opp_count opp_find_freq_exact opp_find_freq_floor opp_find_freq_ceil opp_add opp_enable opp_disable opp_get_notifier opp_init_cpufreq_table opp_free_cpufreq_table Reported-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Nishanth Menon <nm@ti.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'Documentation/power')
-rw-r--r--Documentation/power/opp.txt102
1 files changed, 51 insertions, 51 deletions
diff --git a/Documentation/power/opp.txt b/Documentation/power/opp.txt
index 425c51d56aef..185367b1848f 100644
--- a/Documentation/power/opp.txt
+++ b/Documentation/power/opp.txt
@@ -71,14 +71,14 @@ operations until that OPP could be re-enabled if possible.
71 71
72OPP library facilitates this concept in it's implementation. The following 72OPP library facilitates this concept in it's implementation. The following
73operational functions operate only on available opps: 73operational functions operate only on available opps:
74opp_find_freq_{ceil, floor}, opp_get_voltage, opp_get_freq, opp_get_opp_count 74opp_find_freq_{ceil, floor}, dev_pm_opp_get_voltage, dev_pm_opp_get_freq, dev_pm_opp_get_opp_count
75and opp_init_cpufreq_table 75and dev_pm_opp_init_cpufreq_table
76 76
77opp_find_freq_exact is meant to be used to find the opp pointer which can then 77dev_pm_opp_find_freq_exact is meant to be used to find the opp pointer which can then
78be used for opp_enable/disable functions to make an opp available as required. 78be used for dev_pm_opp_enable/disable functions to make an opp available as required.
79 79
80WARNING: Users of OPP library should refresh their availability count using 80WARNING: Users of OPP library should refresh their availability count using
81get_opp_count if opp_enable/disable functions are invoked for a device, the 81get_opp_count if dev_pm_opp_enable/disable functions are invoked for a device, the
82exact mechanism to trigger these or the notification mechanism to other 82exact mechanism to trigger these or the notification mechanism to other
83dependent subsystems such as cpufreq are left to the discretion of the SoC 83dependent subsystems such as cpufreq are left to the discretion of the SoC
84specific framework which uses the OPP library. Similar care needs to be taken 84specific framework which uses the OPP library. Similar care needs to be taken
@@ -96,24 +96,24 @@ using RCU read locks. The opp_find_freq_{exact,ceil,floor},
96opp_get_{voltage, freq, opp_count} fall into this category. 96opp_get_{voltage, freq, opp_count} fall into this category.
97 97
98opp_{add,enable,disable} are updaters which use mutex and implement it's own 98opp_{add,enable,disable} are updaters which use mutex and implement it's own
99RCU locking mechanisms. opp_init_cpufreq_table acts as an updater and uses 99RCU locking mechanisms. dev_pm_opp_init_cpufreq_table acts as an updater and uses
100mutex to implment RCU updater strategy. These functions should *NOT* be called 100mutex to implment RCU updater strategy. These functions should *NOT* be called
101under RCU locks and other contexts that prevent blocking functions in RCU or 101under RCU locks and other contexts that prevent blocking functions in RCU or
102mutex operations from working. 102mutex operations from working.
103 103
1042. Initial OPP List Registration 1042. Initial OPP List Registration
105================================ 105================================
106The SoC implementation calls opp_add function iteratively to add OPPs per 106The SoC implementation calls dev_pm_opp_add function iteratively to add OPPs per
107device. It is expected that the SoC framework will register the OPP entries 107device. It is expected that the SoC framework will register the OPP entries
108optimally- typical numbers range to be less than 5. The list generated by 108optimally- typical numbers range to be less than 5. The list generated by
109registering the OPPs is maintained by OPP library throughout the device 109registering the OPPs is maintained by OPP library throughout the device
110operation. The SoC framework can subsequently control the availability of the 110operation. The SoC framework can subsequently control the availability of the
111OPPs dynamically using the opp_enable / disable functions. 111OPPs dynamically using the dev_pm_opp_enable / disable functions.
112 112
113opp_add - Add a new OPP for a specific domain represented by the device pointer. 113dev_pm_opp_add - Add a new OPP for a specific domain represented by the device pointer.
114 The OPP is defined using the frequency and voltage. Once added, the OPP 114 The OPP is defined using the frequency and voltage. Once added, the OPP
115 is assumed to be available and control of it's availability can be done 115 is assumed to be available and control of it's availability can be done
116 with the opp_enable/disable functions. OPP library internally stores 116 with the dev_pm_opp_enable/disable functions. OPP library internally stores
117 and manages this information in the opp struct. This function may be 117 and manages this information in the opp struct. This function may be
118 used by SoC framework to define a optimal list as per the demands of 118 used by SoC framework to define a optimal list as per the demands of
119 SoC usage environment. 119 SoC usage environment.
@@ -124,7 +124,7 @@ opp_add - Add a new OPP for a specific domain represented by the device pointer.
124 soc_pm_init() 124 soc_pm_init()
125 { 125 {
126 /* Do things */ 126 /* Do things */
127 r = opp_add(mpu_dev, 1000000, 900000); 127 r = dev_pm_opp_add(mpu_dev, 1000000, 900000);
128 if (!r) { 128 if (!r) {
129 pr_err("%s: unable to register mpu opp(%d)\n", r); 129 pr_err("%s: unable to register mpu opp(%d)\n", r);
130 goto no_cpufreq; 130 goto no_cpufreq;
@@ -143,44 +143,44 @@ functions return the matching pointer representing the opp if a match is
143found, else returns error. These errors are expected to be handled by standard 143found, else returns error. These errors are expected to be handled by standard
144error checks such as IS_ERR() and appropriate actions taken by the caller. 144error checks such as IS_ERR() and appropriate actions taken by the caller.
145 145
146opp_find_freq_exact - Search for an OPP based on an *exact* frequency and 146dev_pm_opp_find_freq_exact - Search for an OPP based on an *exact* frequency and
147 availability. This function is especially useful to enable an OPP which 147 availability. This function is especially useful to enable an OPP which
148 is not available by default. 148 is not available by default.
149 Example: In a case when SoC framework detects a situation where a 149 Example: In a case when SoC framework detects a situation where a
150 higher frequency could be made available, it can use this function to 150 higher frequency could be made available, it can use this function to
151 find the OPP prior to call the opp_enable to actually make it available. 151 find the OPP prior to call the dev_pm_opp_enable to actually make it available.
152 rcu_read_lock(); 152 rcu_read_lock();
153 opp = opp_find_freq_exact(dev, 1000000000, false); 153 opp = dev_pm_opp_find_freq_exact(dev, 1000000000, false);
154 rcu_read_unlock(); 154 rcu_read_unlock();
155 /* dont operate on the pointer.. just do a sanity check.. */ 155 /* dont operate on the pointer.. just do a sanity check.. */
156 if (IS_ERR(opp)) { 156 if (IS_ERR(opp)) {
157 pr_err("frequency not disabled!\n"); 157 pr_err("frequency not disabled!\n");
158 /* trigger appropriate actions.. */ 158 /* trigger appropriate actions.. */
159 } else { 159 } else {
160 opp_enable(dev,1000000000); 160 dev_pm_opp_enable(dev,1000000000);
161 } 161 }
162 162
163 NOTE: This is the only search function that operates on OPPs which are 163 NOTE: This is the only search function that operates on OPPs which are
164 not available. 164 not available.
165 165
166opp_find_freq_floor - Search for an available OPP which is *at most* the 166dev_pm_opp_find_freq_floor - Search for an available OPP which is *at most* the
167 provided frequency. This function is useful while searching for a lesser 167 provided frequency. This function is useful while searching for a lesser
168 match OR operating on OPP information in the order of decreasing 168 match OR operating on OPP information in the order of decreasing
169 frequency. 169 frequency.
170 Example: To find the highest opp for a device: 170 Example: To find the highest opp for a device:
171 freq = ULONG_MAX; 171 freq = ULONG_MAX;
172 rcu_read_lock(); 172 rcu_read_lock();
173 opp_find_freq_floor(dev, &freq); 173 dev_pm_opp_find_freq_floor(dev, &freq);
174 rcu_read_unlock(); 174 rcu_read_unlock();
175 175
176opp_find_freq_ceil - Search for an available OPP which is *at least* the 176dev_pm_opp_find_freq_ceil - Search for an available OPP which is *at least* the
177 provided frequency. This function is useful while searching for a 177 provided frequency. This function is useful while searching for a
178 higher match OR operating on OPP information in the order of increasing 178 higher match OR operating on OPP information in the order of increasing
179 frequency. 179 frequency.
180 Example 1: To find the lowest opp for a device: 180 Example 1: To find the lowest opp for a device:
181 freq = 0; 181 freq = 0;
182 rcu_read_lock(); 182 rcu_read_lock();
183 opp_find_freq_ceil(dev, &freq); 183 dev_pm_opp_find_freq_ceil(dev, &freq);
184 rcu_read_unlock(); 184 rcu_read_unlock();
185 Example 2: A simplified implementation of a SoC cpufreq_driver->target: 185 Example 2: A simplified implementation of a SoC cpufreq_driver->target:
186 soc_cpufreq_target(..) 186 soc_cpufreq_target(..)
@@ -188,7 +188,7 @@ opp_find_freq_ceil - Search for an available OPP which is *at least* the
188 /* Do stuff like policy checks etc. */ 188 /* Do stuff like policy checks etc. */
189 /* Find the best frequency match for the req */ 189 /* Find the best frequency match for the req */
190 rcu_read_lock(); 190 rcu_read_lock();
191 opp = opp_find_freq_ceil(dev, &freq); 191 opp = dev_pm_opp_find_freq_ceil(dev, &freq);
192 rcu_read_unlock(); 192 rcu_read_unlock();
193 if (!IS_ERR(opp)) 193 if (!IS_ERR(opp))
194 soc_switch_to_freq_voltage(freq); 194 soc_switch_to_freq_voltage(freq);
@@ -208,34 +208,34 @@ as thermal considerations (e.g. don't use OPPx until the temperature drops).
208 208
209WARNING: Do not use these functions in interrupt context. 209WARNING: Do not use these functions in interrupt context.
210 210
211opp_enable - Make a OPP available for operation. 211dev_pm_opp_enable - Make a OPP available for operation.
212 Example: Lets say that 1GHz OPP is to be made available only if the 212 Example: Lets say that 1GHz OPP is to be made available only if the
213 SoC temperature is lower than a certain threshold. The SoC framework 213 SoC temperature is lower than a certain threshold. The SoC framework
214 implementation might choose to do something as follows: 214 implementation might choose to do something as follows:
215 if (cur_temp < temp_low_thresh) { 215 if (cur_temp < temp_low_thresh) {
216 /* Enable 1GHz if it was disabled */ 216 /* Enable 1GHz if it was disabled */
217 rcu_read_lock(); 217 rcu_read_lock();
218 opp = opp_find_freq_exact(dev, 1000000000, false); 218 opp = dev_pm_opp_find_freq_exact(dev, 1000000000, false);
219 rcu_read_unlock(); 219 rcu_read_unlock();
220 /* just error check */ 220 /* just error check */
221 if (!IS_ERR(opp)) 221 if (!IS_ERR(opp))
222 ret = opp_enable(dev, 1000000000); 222 ret = dev_pm_opp_enable(dev, 1000000000);
223 else 223 else
224 goto try_something_else; 224 goto try_something_else;
225 } 225 }
226 226
227opp_disable - Make an OPP to be not available for operation 227dev_pm_opp_disable - Make an OPP to be not available for operation
228 Example: Lets say that 1GHz OPP is to be disabled if the temperature 228 Example: Lets say that 1GHz OPP is to be disabled if the temperature
229 exceeds a threshold value. The SoC framework implementation might 229 exceeds a threshold value. The SoC framework implementation might
230 choose to do something as follows: 230 choose to do something as follows:
231 if (cur_temp > temp_high_thresh) { 231 if (cur_temp > temp_high_thresh) {
232 /* Disable 1GHz if it was enabled */ 232 /* Disable 1GHz if it was enabled */
233 rcu_read_lock(); 233 rcu_read_lock();
234 opp = opp_find_freq_exact(dev, 1000000000, true); 234 opp = dev_pm_opp_find_freq_exact(dev, 1000000000, true);
235 rcu_read_unlock(); 235 rcu_read_unlock();
236 /* just error check */ 236 /* just error check */
237 if (!IS_ERR(opp)) 237 if (!IS_ERR(opp))
238 ret = opp_disable(dev, 1000000000); 238 ret = dev_pm_opp_disable(dev, 1000000000);
239 else 239 else
240 goto try_something_else; 240 goto try_something_else;
241 } 241 }
@@ -247,7 +247,7 @@ information from the OPP structure is necessary. Once an OPP pointer is
247retrieved using the search functions, the following functions can be used by SoC 247retrieved using the search functions, the following functions can be used by SoC
248framework to retrieve the information represented inside the OPP layer. 248framework to retrieve the information represented inside the OPP layer.
249 249
250opp_get_voltage - Retrieve the voltage represented by the opp pointer. 250dev_pm_opp_get_voltage - Retrieve the voltage represented by the opp pointer.
251 Example: At a cpufreq transition to a different frequency, SoC 251 Example: At a cpufreq transition to a different frequency, SoC
252 framework requires to set the voltage represented by the OPP using 252 framework requires to set the voltage represented by the OPP using
253 the regulator framework to the Power Management chip providing the 253 the regulator framework to the Power Management chip providing the
@@ -256,15 +256,15 @@ opp_get_voltage - Retrieve the voltage represented by the opp pointer.
256 { 256 {
257 /* do things */ 257 /* do things */
258 rcu_read_lock(); 258 rcu_read_lock();
259 opp = opp_find_freq_ceil(dev, &freq); 259 opp = dev_pm_opp_find_freq_ceil(dev, &freq);
260 v = opp_get_voltage(opp); 260 v = dev_pm_opp_get_voltage(opp);
261 rcu_read_unlock(); 261 rcu_read_unlock();
262 if (v) 262 if (v)
263 regulator_set_voltage(.., v); 263 regulator_set_voltage(.., v);
264 /* do other things */ 264 /* do other things */
265 } 265 }
266 266
267opp_get_freq - Retrieve the freq represented by the opp pointer. 267dev_pm_opp_get_freq - Retrieve the freq represented by the opp pointer.
268 Example: Lets say the SoC framework uses a couple of helper functions 268 Example: Lets say the SoC framework uses a couple of helper functions
269 we could pass opp pointers instead of doing additional parameters to 269 we could pass opp pointers instead of doing additional parameters to
270 handle quiet a bit of data parameters. 270 handle quiet a bit of data parameters.
@@ -273,8 +273,8 @@ opp_get_freq - Retrieve the freq represented by the opp pointer.
273 /* do things.. */ 273 /* do things.. */
274 max_freq = ULONG_MAX; 274 max_freq = ULONG_MAX;
275 rcu_read_lock(); 275 rcu_read_lock();
276 max_opp = opp_find_freq_floor(dev,&max_freq); 276 max_opp = dev_pm_opp_find_freq_floor(dev,&max_freq);
277 requested_opp = opp_find_freq_ceil(dev,&freq); 277 requested_opp = dev_pm_opp_find_freq_ceil(dev,&freq);
278 if (!IS_ERR(max_opp) && !IS_ERR(requested_opp)) 278 if (!IS_ERR(max_opp) && !IS_ERR(requested_opp))
279 r = soc_test_validity(max_opp, requested_opp); 279 r = soc_test_validity(max_opp, requested_opp);
280 rcu_read_unlock(); 280 rcu_read_unlock();
@@ -282,25 +282,25 @@ opp_get_freq - Retrieve the freq represented by the opp pointer.
282 } 282 }
283 soc_test_validity(..) 283 soc_test_validity(..)
284 { 284 {
285 if(opp_get_voltage(max_opp) < opp_get_voltage(requested_opp)) 285 if(dev_pm_opp_get_voltage(max_opp) < dev_pm_opp_get_voltage(requested_opp))
286 return -EINVAL; 286 return -EINVAL;
287 if(opp_get_freq(max_opp) < opp_get_freq(requested_opp)) 287 if(dev_pm_opp_get_freq(max_opp) < dev_pm_opp_get_freq(requested_opp))
288 return -EINVAL; 288 return -EINVAL;
289 /* do things.. */ 289 /* do things.. */
290 } 290 }
291 291
292opp_get_opp_count - Retrieve the number of available opps for a device 292dev_pm_opp_get_opp_count - Retrieve the number of available opps for a device
293 Example: Lets say a co-processor in the SoC needs to know the available 293 Example: Lets say a co-processor in the SoC needs to know the available
294 frequencies in a table, the main processor can notify as following: 294 frequencies in a table, the main processor can notify as following:
295 soc_notify_coproc_available_frequencies() 295 soc_notify_coproc_available_frequencies()
296 { 296 {
297 /* Do things */ 297 /* Do things */
298 rcu_read_lock(); 298 rcu_read_lock();
299 num_available = opp_get_opp_count(dev); 299 num_available = dev_pm_opp_get_opp_count(dev);
300 speeds = kzalloc(sizeof(u32) * num_available, GFP_KERNEL); 300 speeds = kzalloc(sizeof(u32) * num_available, GFP_KERNEL);
301 /* populate the table in increasing order */ 301 /* populate the table in increasing order */
302 freq = 0; 302 freq = 0;
303 while (!IS_ERR(opp = opp_find_freq_ceil(dev, &freq))) { 303 while (!IS_ERR(opp = dev_pm_opp_find_freq_ceil(dev, &freq))) {
304 speeds[i] = freq; 304 speeds[i] = freq;
305 freq++; 305 freq++;
306 i++; 306 i++;
@@ -313,7 +313,7 @@ opp_get_opp_count - Retrieve the number of available opps for a device
313 313
3146. Cpufreq Table Generation 3146. Cpufreq Table Generation
315=========================== 315===========================
316opp_init_cpufreq_table - cpufreq framework typically is initialized with 316dev_pm_opp_init_cpufreq_table - cpufreq framework typically is initialized with
317 cpufreq_frequency_table_cpuinfo which is provided with the list of 317 cpufreq_frequency_table_cpuinfo which is provided with the list of
318 frequencies that are available for operation. This function provides 318 frequencies that are available for operation. This function provides
319 a ready to use conversion routine to translate the OPP layer's internal 319 a ready to use conversion routine to translate the OPP layer's internal
@@ -326,7 +326,7 @@ opp_init_cpufreq_table - cpufreq framework typically is initialized with
326 soc_pm_init() 326 soc_pm_init()
327 { 327 {
328 /* Do things */ 328 /* Do things */
329 r = opp_init_cpufreq_table(dev, &freq_table); 329 r = dev_pm_opp_init_cpufreq_table(dev, &freq_table);
330 if (!r) 330 if (!r)
331 cpufreq_frequency_table_cpuinfo(policy, freq_table); 331 cpufreq_frequency_table_cpuinfo(policy, freq_table);
332 /* Do other things */ 332 /* Do other things */
@@ -336,7 +336,7 @@ opp_init_cpufreq_table - cpufreq framework typically is initialized with
336 addition to CONFIG_PM as power management feature is required to 336 addition to CONFIG_PM as power management feature is required to
337 dynamically scale voltage and frequency in a system. 337 dynamically scale voltage and frequency in a system.
338 338
339opp_free_cpufreq_table - Free up the table allocated by opp_init_cpufreq_table 339dev_pm_opp_free_cpufreq_table - Free up the table allocated by dev_pm_opp_init_cpufreq_table
340 340
3417. Data Structures 3417. Data Structures
342================== 342==================
@@ -366,8 +366,8 @@ struct opp - The internal data structure of OPP library which is used to
366 identifier for OPP in the interactions with OPP layer. 366 identifier for OPP in the interactions with OPP layer.
367 367
368 WARNING: The struct opp pointer should not be parsed or modified by the 368 WARNING: The struct opp pointer should not be parsed or modified by the
369 users. The defaults of for an instance is populated by opp_add, but the 369 users. The defaults of for an instance is populated by dev_pm_opp_add, but the
370 availability of the OPP can be modified by opp_enable/disable functions. 370 availability of the OPP can be modified by dev_pm_opp_enable/disable functions.
371 371
372struct device - This is used to identify a domain to the OPP layer. The 372struct device - This is used to identify a domain to the OPP layer. The
373 nature of the device and it's implementation is left to the user of 373 nature of the device and it's implementation is left to the user of
@@ -377,19 +377,19 @@ Overall, in a simplistic view, the data structure operations is represented as
377following: 377following:
378 378
379Initialization / modification: 379Initialization / modification:
380 +-----+ /- opp_enable 380 +-----+ /- dev_pm_opp_enable
381opp_add --> | opp | <------- 381dev_pm_opp_add --> | opp | <-------
382 | +-----+ \- opp_disable 382 | +-----+ \- dev_pm_opp_disable
383 \-------> domain_info(device) 383 \-------> domain_info(device)
384 384
385Search functions: 385Search functions:
386 /-- opp_find_freq_ceil ---\ +-----+ 386 /-- dev_pm_opp_find_freq_ceil ---\ +-----+
387domain_info<---- opp_find_freq_exact -----> | opp | 387domain_info<---- dev_pm_opp_find_freq_exact -----> | opp |
388 \-- opp_find_freq_floor ---/ +-----+ 388 \-- dev_pm_opp_find_freq_floor ---/ +-----+
389 389
390Retrieval functions: 390Retrieval functions:
391+-----+ /- opp_get_voltage 391+-----+ /- dev_pm_opp_get_voltage
392| opp | <--- 392| opp | <---
393+-----+ \- opp_get_freq 393+-----+ \- dev_pm_opp_get_freq
394 394
395domain_info <- opp_get_opp_count 395domain_info <- dev_pm_opp_get_opp_count