This source file includes following definitions.
- devfreq_add_device
- devfreq_remove_device
- devm_devfreq_add_device
- devm_devfreq_remove_device
- devfreq_suspend_device
- devfreq_resume_device
- devfreq_suspend
- devfreq_resume
- devfreq_recommended_opp
- devfreq_register_opp_notifier
- devfreq_unregister_opp_notifier
- devm_devfreq_register_opp_notifier
- devm_devfreq_unregister_opp_notifier
- devfreq_register_notifier
- devfreq_unregister_notifier
- devm_devfreq_register_notifier
- devm_devfreq_unregister_notifier
- devfreq_get_devfreq_by_phandle
- devfreq_update_stats
1
2
3
4
5
6
7
8
9
10 #ifndef __LINUX_DEVFREQ_H__
11 #define __LINUX_DEVFREQ_H__
12
13 #include <linux/device.h>
14 #include <linux/notifier.h>
15 #include <linux/pm_opp.h>
16
17 #define DEVFREQ_NAME_LEN 16
18
19
20 #define DEVFREQ_GOV_SIMPLE_ONDEMAND "simple_ondemand"
21 #define DEVFREQ_GOV_PERFORMANCE "performance"
22 #define DEVFREQ_GOV_POWERSAVE "powersave"
23 #define DEVFREQ_GOV_USERSPACE "userspace"
24 #define DEVFREQ_GOV_PASSIVE "passive"
25
26
27 #define DEVFREQ_TRANSITION_NOTIFIER (0)
28
29
30 #define DEVFREQ_PRECHANGE (0)
31 #define DEVFREQ_POSTCHANGE (1)
32
33 struct devfreq;
34 struct devfreq_governor;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 struct devfreq_dev_status {
52
53 unsigned long total_time;
54 unsigned long busy_time;
55 unsigned long current_frequency;
56 void *private_data;
57 };
58
59
60
61
62
63
64
65 #define DEVFREQ_FLAG_LEAST_UPPER_BOUND 0x1
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 struct devfreq_dev_profile {
96 unsigned long initial_freq;
97 unsigned int polling_ms;
98
99 int (*target)(struct device *dev, unsigned long *freq, u32 flags);
100 int (*get_dev_status)(struct device *dev,
101 struct devfreq_dev_status *stat);
102 int (*get_cur_freq)(struct device *dev, unsigned long *freq);
103 void (*exit)(struct device *dev);
104
105 unsigned long *freq_table;
106 unsigned int max_state;
107 };
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148 struct devfreq {
149 struct list_head node;
150
151 struct mutex lock;
152 struct device dev;
153 struct devfreq_dev_profile *profile;
154 const struct devfreq_governor *governor;
155 char governor_name[DEVFREQ_NAME_LEN];
156 struct notifier_block nb;
157 struct delayed_work work;
158
159 unsigned long previous_freq;
160 struct devfreq_dev_status last_status;
161
162 void *data;
163
164 unsigned long min_freq;
165 unsigned long max_freq;
166 unsigned long scaling_min_freq;
167 unsigned long scaling_max_freq;
168 bool stop_polling;
169
170 unsigned long suspend_freq;
171 unsigned long resume_freq;
172 atomic_t suspend_count;
173
174
175 unsigned int total_trans;
176 unsigned int *trans_table;
177 unsigned long *time_in_state;
178 unsigned long last_stat_updated;
179
180 struct srcu_notifier_head transition_notifier_list;
181 };
182
183 struct devfreq_freqs {
184 unsigned long old;
185 unsigned long new;
186 };
187
188 #if defined(CONFIG_PM_DEVFREQ)
189 extern struct devfreq *devfreq_add_device(struct device *dev,
190 struct devfreq_dev_profile *profile,
191 const char *governor_name,
192 void *data);
193 extern int devfreq_remove_device(struct devfreq *devfreq);
194 extern struct devfreq *devm_devfreq_add_device(struct device *dev,
195 struct devfreq_dev_profile *profile,
196 const char *governor_name,
197 void *data);
198 extern void devm_devfreq_remove_device(struct device *dev,
199 struct devfreq *devfreq);
200
201
202 extern int devfreq_suspend_device(struct devfreq *devfreq);
203 extern int devfreq_resume_device(struct devfreq *devfreq);
204
205 extern void devfreq_suspend(void);
206 extern void devfreq_resume(void);
207
208
209
210
211
212
213
214 extern int update_devfreq(struct devfreq *devfreq);
215
216
217 extern struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
218 unsigned long *freq, u32 flags);
219 extern int devfreq_register_opp_notifier(struct device *dev,
220 struct devfreq *devfreq);
221 extern int devfreq_unregister_opp_notifier(struct device *dev,
222 struct devfreq *devfreq);
223 extern int devm_devfreq_register_opp_notifier(struct device *dev,
224 struct devfreq *devfreq);
225 extern void devm_devfreq_unregister_opp_notifier(struct device *dev,
226 struct devfreq *devfreq);
227 extern int devfreq_register_notifier(struct devfreq *devfreq,
228 struct notifier_block *nb,
229 unsigned int list);
230 extern int devfreq_unregister_notifier(struct devfreq *devfreq,
231 struct notifier_block *nb,
232 unsigned int list);
233 extern int devm_devfreq_register_notifier(struct device *dev,
234 struct devfreq *devfreq,
235 struct notifier_block *nb,
236 unsigned int list);
237 extern void devm_devfreq_unregister_notifier(struct device *dev,
238 struct devfreq *devfreq,
239 struct notifier_block *nb,
240 unsigned int list);
241 extern struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
242 int index);
243
244 #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
245
246
247
248
249
250
251
252
253
254
255
256
257
258 struct devfreq_simple_ondemand_data {
259 unsigned int upthreshold;
260 unsigned int downdifferential;
261 };
262 #endif
263
264 #if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE)
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284 struct devfreq_passive_data {
285
286 struct devfreq *parent;
287
288
289 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
290
291
292 struct devfreq *this;
293 struct notifier_block nb;
294 };
295 #endif
296
297 #else
298 static inline struct devfreq *devfreq_add_device(struct device *dev,
299 struct devfreq_dev_profile *profile,
300 const char *governor_name,
301 void *data)
302 {
303 return ERR_PTR(-ENOSYS);
304 }
305
306 static inline int devfreq_remove_device(struct devfreq *devfreq)
307 {
308 return 0;
309 }
310
311 static inline struct devfreq *devm_devfreq_add_device(struct device *dev,
312 struct devfreq_dev_profile *profile,
313 const char *governor_name,
314 void *data)
315 {
316 return ERR_PTR(-ENOSYS);
317 }
318
319 static inline void devm_devfreq_remove_device(struct device *dev,
320 struct devfreq *devfreq)
321 {
322 }
323
324 static inline int devfreq_suspend_device(struct devfreq *devfreq)
325 {
326 return 0;
327 }
328
329 static inline int devfreq_resume_device(struct devfreq *devfreq)
330 {
331 return 0;
332 }
333
334 static inline void devfreq_suspend(void) {}
335 static inline void devfreq_resume(void) {}
336
337 static inline struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
338 unsigned long *freq, u32 flags)
339 {
340 return ERR_PTR(-EINVAL);
341 }
342
343 static inline int devfreq_register_opp_notifier(struct device *dev,
344 struct devfreq *devfreq)
345 {
346 return -EINVAL;
347 }
348
349 static inline int devfreq_unregister_opp_notifier(struct device *dev,
350 struct devfreq *devfreq)
351 {
352 return -EINVAL;
353 }
354
355 static inline int devm_devfreq_register_opp_notifier(struct device *dev,
356 struct devfreq *devfreq)
357 {
358 return -EINVAL;
359 }
360
361 static inline void devm_devfreq_unregister_opp_notifier(struct device *dev,
362 struct devfreq *devfreq)
363 {
364 }
365
366 static inline int devfreq_register_notifier(struct devfreq *devfreq,
367 struct notifier_block *nb,
368 unsigned int list)
369 {
370 return 0;
371 }
372
373 static inline int devfreq_unregister_notifier(struct devfreq *devfreq,
374 struct notifier_block *nb,
375 unsigned int list)
376 {
377 return 0;
378 }
379
380 static inline int devm_devfreq_register_notifier(struct device *dev,
381 struct devfreq *devfreq,
382 struct notifier_block *nb,
383 unsigned int list)
384 {
385 return 0;
386 }
387
388 static inline void devm_devfreq_unregister_notifier(struct device *dev,
389 struct devfreq *devfreq,
390 struct notifier_block *nb,
391 unsigned int list)
392 {
393 }
394
395 static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
396 int index)
397 {
398 return ERR_PTR(-ENODEV);
399 }
400
401 static inline int devfreq_update_stats(struct devfreq *df)
402 {
403 return -EINVAL;
404 }
405 #endif
406
407 #endif