Commit | Line | Data |
---|---|---|
d2912cb1 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
e1f60b29 NM |
2 | /* |
3 | * Generic OPP Interface | |
4 | * | |
5 | * Copyright (C) 2009-2010 Texas Instruments Incorporated. | |
6 | * Nishanth Menon | |
7 | * Romit Dasgupta | |
8 | * Kevin Hilman | |
e1f60b29 NM |
9 | */ |
10 | ||
11 | #ifndef __LINUX_OPP_H__ | |
12 | #define __LINUX_OPP_H__ | |
13 | ||
0e0ffa85 | 14 | #include <linux/energy_model.h> |
e1f60b29 | 15 | #include <linux/err.h> |
03ca370f | 16 | #include <linux/notifier.h> |
e1f60b29 | 17 | |
94735585 | 18 | struct clk; |
838a4772 | 19 | struct cpufreq_frequency_table; |
94735585 | 20 | struct regulator; |
47d43ba7 | 21 | struct dev_pm_opp; |
313162d0 | 22 | struct device; |
91291d9a | 23 | struct opp_table; |
e1f60b29 | 24 | |
47d43ba7 | 25 | enum dev_pm_opp_event { |
129eec55 | 26 | OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE, |
25cb20a2 | 27 | OPP_EVENT_ADJUST_VOLTAGE, |
03ca370f MH |
28 | }; |
29 | ||
0f0fe7e0 VK |
30 | /** |
31 | * struct dev_pm_opp_supply - Power supply voltage/current values | |
32 | * @u_volt: Target voltage in microvolts corresponding to this OPP | |
33 | * @u_volt_min: Minimum voltage in microvolts corresponding to this OPP | |
34 | * @u_volt_max: Maximum voltage in microvolts corresponding to this OPP | |
35 | * @u_amp: Maximum current drawn by the device in microamperes | |
4f9a7a1d | 36 | * @u_watt: Power used by the device in microwatts |
0f0fe7e0 | 37 | * |
4f9a7a1d LL |
38 | * This structure stores the voltage/current/power values for a single power |
39 | * supply. | |
0f0fe7e0 VK |
40 | */ |
41 | struct dev_pm_opp_supply { | |
42 | unsigned long u_volt; | |
43 | unsigned long u_volt_min; | |
44 | unsigned long u_volt_max; | |
45 | unsigned long u_amp; | |
4f9a7a1d | 46 | unsigned long u_watt; |
0f0fe7e0 VK |
47 | }; |
48 | ||
aee3352f VK |
49 | typedef int (*config_regulators_t)(struct device *dev, |
50 | struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp, | |
51 | struct regulator **regulators, unsigned int count); | |
52 | ||
2083da24 VK |
53 | typedef int (*config_clks_t)(struct device *dev, struct opp_table *opp_table, |
54 | struct dev_pm_opp *opp, void *data, bool scaling_down); | |
55 | ||
11b9b663 VK |
56 | /** |
57 | * struct dev_pm_opp_config - Device OPP configuration values | |
2083da24 VK |
58 | * @clk_names: Clk names, NULL terminated array. |
59 | * @config_clks: Custom set clk helper. | |
11b9b663 | 60 | * @prop_name: Name to postfix to properties. |
aee3352f | 61 | * @config_regulators: Custom set regulator helper. |
11b9b663 VK |
62 | * @supported_hw: Array of hierarchy of versions to match. |
63 | * @supported_hw_count: Number of elements in the array. | |
64 | * @regulator_names: Array of pointers to the names of the regulator, NULL terminated. | |
65 | * @genpd_names: Null terminated array of pointers containing names of genpd to | |
e37440e7 VK |
66 | * attach. Mutually exclusive with required_devs. |
67 | * @virt_devs: Pointer to return the array of genpd virtual devices. Mutually | |
68 | * exclusive with required_devs. | |
69 | * @required_devs: Required OPP devices. Mutually exclusive with genpd_names/virt_devs. | |
11b9b663 VK |
70 | * |
71 | * This structure contains platform specific OPP configurations for the device. | |
72 | */ | |
73 | struct dev_pm_opp_config { | |
74 | /* NULL terminated */ | |
75 | const char * const *clk_names; | |
2083da24 | 76 | config_clks_t config_clks; |
11b9b663 | 77 | const char *prop_name; |
aee3352f | 78 | config_regulators_t config_regulators; |
11b9b663 VK |
79 | const unsigned int *supported_hw; |
80 | unsigned int supported_hw_count; | |
81 | const char * const *regulator_names; | |
82 | const char * const *genpd_names; | |
83 | struct device ***virt_devs; | |
e37440e7 | 84 | struct device **required_devs; |
11b9b663 VK |
85 | }; |
86 | ||
073d3d2c VK |
87 | #define OPP_LEVEL_UNSET U32_MAX |
88 | ||
248a38d5 UH |
89 | /** |
90 | * struct dev_pm_opp_data - The data to use to initialize an OPP. | |
abb3f971 | 91 | * @turbo: Flag to indicate whether the OPP is to be marked turbo or not. |
073d3d2c VK |
92 | * @level: The performance level for the OPP. Set level to OPP_LEVEL_UNSET if |
93 | * level field isn't used. | |
248a38d5 UH |
94 | * @freq: The clock rate in Hz for the OPP. |
95 | * @u_volt: The voltage in uV for the OPP. | |
96 | */ | |
97 | struct dev_pm_opp_data { | |
abb3f971 | 98 | bool turbo; |
3166383d | 99 | unsigned int level; |
248a38d5 UH |
100 | unsigned long freq; |
101 | unsigned long u_volt; | |
102 | }; | |
103 | ||
e1f60b29 NM |
104 | #if defined(CONFIG_PM_OPP) |
105 | ||
f067a982 VK |
106 | struct opp_table *dev_pm_opp_get_opp_table(struct device *dev); |
107 | void dev_pm_opp_put_opp_table(struct opp_table *opp_table); | |
108 | ||
47d43ba7 | 109 | unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); |
e1f60b29 | 110 | |
69b1af17 VK |
111 | int dev_pm_opp_get_supplies(struct dev_pm_opp *opp, struct dev_pm_opp_supply *supplies); |
112 | ||
4f9a7a1d LL |
113 | unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp); |
114 | ||
5f756d03 MS |
115 | unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index); |
116 | ||
5b93ac54 RN |
117 | unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); |
118 | ||
597ff543 DO |
119 | unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, |
120 | unsigned int index); | |
121 | ||
19445b25 BZ |
122 | bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); |
123 | ||
5d4879cd | 124 | int dev_pm_opp_get_opp_count(struct device *dev); |
3ca9bb33 | 125 | unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev); |
655c9df9 | 126 | unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev); |
21743447 | 127 | unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev); |
3aa26a3b | 128 | unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev); |
e1f60b29 | 129 | |
47d43ba7 NM |
130 | struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, |
131 | unsigned long freq, | |
132 | bool available); | |
754833b3 | 133 | |
a5893928 VK |
134 | struct dev_pm_opp * |
135 | dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, | |
136 | u32 index, bool available); | |
137 | ||
47d43ba7 NM |
138 | struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, |
139 | unsigned long *freq); | |
e1f60b29 | 140 | |
142e17c1 MS |
141 | struct dev_pm_opp *dev_pm_opp_find_freq_floor_indexed(struct device *dev, |
142 | unsigned long *freq, u32 index); | |
143 | ||
754833b3 VK |
144 | struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, |
145 | unsigned long *freq); | |
146 | ||
142e17c1 MS |
147 | struct dev_pm_opp *dev_pm_opp_find_freq_ceil_indexed(struct device *dev, |
148 | unsigned long *freq, u32 index); | |
149 | ||
22079af7 VK |
150 | struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, |
151 | unsigned int level); | |
754833b3 | 152 | |
22079af7 VK |
153 | struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, |
154 | unsigned int *level); | |
155 | ||
a0242c81 | 156 | struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev, |
ba367479 | 157 | unsigned int *level); |
a0242c81 | 158 | |
00ce3873 KK |
159 | struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev, |
160 | unsigned int *bw, int index); | |
161 | ||
162 | struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev, | |
163 | unsigned int *bw, int index); | |
164 | ||
7034764a | 165 | void dev_pm_opp_put(struct dev_pm_opp *opp); |
e1f60b29 | 166 | |
248a38d5 UH |
167 | int dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *opp); |
168 | ||
129eec55 | 169 | void dev_pm_opp_remove(struct device *dev, unsigned long freq); |
1690d8bb | 170 | void dev_pm_opp_remove_all_dynamic(struct device *dev); |
e1f60b29 | 171 | |
25cb20a2 SB |
172 | int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, |
173 | unsigned long u_volt, unsigned long u_volt_min, | |
174 | unsigned long u_volt_max); | |
175 | ||
5d4879cd | 176 | int dev_pm_opp_enable(struct device *dev, unsigned long freq); |
e1f60b29 | 177 | |
5d4879cd | 178 | int dev_pm_opp_disable(struct device *dev, unsigned long freq); |
e1f60b29 | 179 | |
dc2c9ad5 VK |
180 | int dev_pm_opp_register_notifier(struct device *dev, struct notifier_block *nb); |
181 | int dev_pm_opp_unregister_notifier(struct device *dev, struct notifier_block *nb); | |
182 | ||
11b9b663 VK |
183 | int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config); |
184 | int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config); | |
185 | void dev_pm_opp_clear_config(int token); | |
8174a3a6 VK |
186 | int dev_pm_opp_config_clks_simple(struct device *dev, |
187 | struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, | |
188 | bool scaling_down); | |
11b9b663 | 189 | |
7d8658ef | 190 | struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, struct opp_table *dst_table, struct dev_pm_opp *src_opp); |
c8a59103 | 191 | int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); |
6a0712f6 | 192 | int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); |
abbe3483 | 193 | int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp); |
ddbb74bc AB |
194 | int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); |
195 | int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); | |
411466c5 SH |
196 | void dev_pm_opp_remove_table(struct device *dev); |
197 | void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask); | |
ce8073d8 | 198 | int dev_pm_opp_sync_regulators(struct device *dev); |
e1f60b29 | 199 | #else |
f067a982 VK |
200 | static inline struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) |
201 | { | |
1d614920 | 202 | return ERR_PTR(-EOPNOTSUPP); |
f067a982 VK |
203 | } |
204 | ||
eb7c8743 VK |
205 | static inline struct opp_table *dev_pm_opp_get_opp_table_indexed(struct device *dev, int index) |
206 | { | |
1d614920 | 207 | return ERR_PTR(-EOPNOTSUPP); |
eb7c8743 VK |
208 | } |
209 | ||
f067a982 VK |
210 | static inline void dev_pm_opp_put_opp_table(struct opp_table *opp_table) {} |
211 | ||
47d43ba7 | 212 | static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) |
e1f60b29 NM |
213 | { |
214 | return 0; | |
215 | } | |
216 | ||
69b1af17 VK |
217 | static inline int dev_pm_opp_get_supplies(struct dev_pm_opp *opp, struct dev_pm_opp_supply *supplies) |
218 | { | |
219 | return -EOPNOTSUPP; | |
220 | } | |
221 | ||
4f9a7a1d LL |
222 | static inline unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp) |
223 | { | |
224 | return 0; | |
225 | } | |
226 | ||
5f756d03 MS |
227 | static inline unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index) |
228 | { | |
229 | return 0; | |
230 | } | |
231 | ||
5b93ac54 RN |
232 | static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) |
233 | { | |
234 | return 0; | |
235 | } | |
236 | ||
597ff543 DO |
237 | static inline |
238 | unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, | |
239 | unsigned int index) | |
240 | { | |
241 | return 0; | |
242 | } | |
243 | ||
19445b25 BZ |
244 | static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) |
245 | { | |
246 | return false; | |
247 | } | |
248 | ||
5d4879cd | 249 | static inline int dev_pm_opp_get_opp_count(struct device *dev) |
e1f60b29 NM |
250 | { |
251 | return 0; | |
252 | } | |
253 | ||
3ca9bb33 VK |
254 | static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev) |
255 | { | |
256 | return 0; | |
257 | } | |
258 | ||
655c9df9 VK |
259 | static inline unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) |
260 | { | |
261 | return 0; | |
262 | } | |
263 | ||
21743447 VK |
264 | static inline unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev) |
265 | { | |
266 | return 0; | |
267 | } | |
268 | ||
3aa26a3b | 269 | static inline unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev) |
4eafbd15 | 270 | { |
3aa26a3b | 271 | return 0; |
4eafbd15 BZ |
272 | } |
273 | ||
754833b3 VK |
274 | static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, |
275 | unsigned long freq, bool available) | |
71419d84 | 276 | { |
1d614920 | 277 | return ERR_PTR(-EOPNOTSUPP); |
71419d84 NC |
278 | } |
279 | ||
a5893928 VK |
280 | static inline struct dev_pm_opp * |
281 | dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, | |
282 | u32 index, bool available) | |
283 | { | |
284 | return ERR_PTR(-EOPNOTSUPP); | |
285 | } | |
286 | ||
754833b3 VK |
287 | static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, |
288 | unsigned long *freq) | |
8dd5cada | 289 | { |
1d614920 | 290 | return ERR_PTR(-EOPNOTSUPP); |
8dd5cada DO |
291 | } |
292 | ||
142e17c1 MS |
293 | static inline struct dev_pm_opp * |
294 | dev_pm_opp_find_freq_floor_indexed(struct device *dev, unsigned long *freq, u32 index) | |
295 | { | |
296 | return ERR_PTR(-EOPNOTSUPP); | |
297 | } | |
298 | ||
754833b3 VK |
299 | static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, |
300 | unsigned long *freq) | |
22079af7 VK |
301 | { |
302 | return ERR_PTR(-EOPNOTSUPP); | |
303 | } | |
304 | ||
142e17c1 MS |
305 | static inline struct dev_pm_opp * |
306 | dev_pm_opp_find_freq_ceil_indexed(struct device *dev, unsigned long *freq, u32 index) | |
307 | { | |
308 | return ERR_PTR(-EOPNOTSUPP); | |
309 | } | |
310 | ||
754833b3 VK |
311 | static inline struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, |
312 | unsigned int level) | |
e1f60b29 | 313 | { |
1d614920 | 314 | return ERR_PTR(-EOPNOTSUPP); |
e1f60b29 NM |
315 | } |
316 | ||
754833b3 VK |
317 | static inline struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, |
318 | unsigned int *level) | |
e1f60b29 | 319 | { |
1d614920 | 320 | return ERR_PTR(-EOPNOTSUPP); |
e1f60b29 NM |
321 | } |
322 | ||
a0242c81 | 323 | static inline struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev, |
ba367479 | 324 | unsigned int *level) |
a0242c81 K |
325 | { |
326 | return ERR_PTR(-EOPNOTSUPP); | |
327 | } | |
328 | ||
00ce3873 KK |
329 | static inline struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev, |
330 | unsigned int *bw, int index) | |
331 | { | |
332 | return ERR_PTR(-EOPNOTSUPP); | |
333 | } | |
334 | ||
335 | static inline struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev, | |
336 | unsigned int *bw, int index) | |
337 | { | |
338 | return ERR_PTR(-EOPNOTSUPP); | |
339 | } | |
340 | ||
7034764a VK |
341 | static inline void dev_pm_opp_put(struct dev_pm_opp *opp) {} |
342 | ||
248a38d5 UH |
343 | static inline int |
344 | dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *opp) | |
e1f60b29 | 345 | { |
1d614920 | 346 | return -EOPNOTSUPP; |
e1f60b29 NM |
347 | } |
348 | ||
129eec55 VK |
349 | static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq) |
350 | { | |
351 | } | |
352 | ||
1690d8bb VK |
353 | static inline void dev_pm_opp_remove_all_dynamic(struct device *dev) |
354 | { | |
355 | } | |
356 | ||
25cb20a2 SB |
357 | static inline int |
358 | dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, | |
359 | unsigned long u_volt, unsigned long u_volt_min, | |
360 | unsigned long u_volt_max) | |
361 | { | |
362 | return 0; | |
363 | } | |
364 | ||
5d4879cd | 365 | static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq) |
e1f60b29 NM |
366 | { |
367 | return 0; | |
368 | } | |
369 | ||
5d4879cd | 370 | static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq) |
e1f60b29 NM |
371 | { |
372 | return 0; | |
373 | } | |
03ca370f | 374 | |
dc2c9ad5 | 375 | static inline int dev_pm_opp_register_notifier(struct device *dev, struct notifier_block *nb) |
03ca370f | 376 | { |
1d614920 | 377 | return -EOPNOTSUPP; |
dc2c9ad5 VK |
378 | } |
379 | ||
380 | static inline int dev_pm_opp_unregister_notifier(struct device *dev, struct notifier_block *nb) | |
381 | { | |
1d614920 | 382 | return -EOPNOTSUPP; |
03ca370f | 383 | } |
7de36b0a | 384 | |
11b9b663 VK |
385 | static inline int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) |
386 | { | |
387 | return -EOPNOTSUPP; | |
388 | } | |
389 | ||
390 | static inline int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) | |
391 | { | |
392 | return -EOPNOTSUPP; | |
393 | } | |
394 | ||
395 | static inline void dev_pm_opp_clear_config(int token) {} | |
396 | ||
8174a3a6 VK |
397 | static inline int dev_pm_opp_config_clks_simple(struct device *dev, |
398 | struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, | |
399 | bool scaling_down) | |
400 | { | |
401 | return -EOPNOTSUPP; | |
402 | } | |
403 | ||
7d8658ef SK |
404 | static inline struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, |
405 | struct opp_table *dst_table, struct dev_pm_opp *src_opp) | |
406 | { | |
407 | return ERR_PTR(-EOPNOTSUPP); | |
408 | } | |
409 | ||
c8a59103 VK |
410 | static inline int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate) |
411 | { | |
1d614920 | 412 | return -EOPNOTSUPP; |
c8a59103 VK |
413 | } |
414 | ||
6a0712f6 VK |
415 | static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) |
416 | { | |
1d614920 | 417 | return -EOPNOTSUPP; |
6a0712f6 VK |
418 | } |
419 | ||
abbe3483 VK |
420 | static inline int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp) |
421 | { | |
1d614920 | 422 | return -EOPNOTSUPP; |
abbe3483 VK |
423 | } |
424 | ||
ddbb74bc | 425 | static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask) |
642aa8ce | 426 | { |
1d614920 | 427 | return -EOPNOTSUPP; |
642aa8ce VK |
428 | } |
429 | ||
ddbb74bc | 430 | static inline int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) |
6f707daa VK |
431 | { |
432 | return -EINVAL; | |
433 | } | |
434 | ||
411466c5 SH |
435 | static inline void dev_pm_opp_remove_table(struct device *dev) |
436 | { | |
437 | } | |
438 | ||
439 | static inline void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask) | |
440 | { | |
441 | } | |
442 | ||
ce8073d8 DO |
443 | static inline int dev_pm_opp_sync_regulators(struct device *dev) |
444 | { | |
1d614920 | 445 | return -EOPNOTSUPP; |
ce8073d8 DO |
446 | } |
447 | ||
a96d69d1 | 448 | #endif /* CONFIG_PM_OPP */ |
e1f60b29 | 449 | |
838a4772 VK |
450 | #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP) |
451 | int dev_pm_opp_init_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table); | |
452 | void dev_pm_opp_free_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table); | |
453 | #else | |
454 | static inline int dev_pm_opp_init_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table) | |
455 | { | |
456 | return -EINVAL; | |
457 | } | |
458 | ||
459 | static inline void dev_pm_opp_free_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table) | |
460 | { | |
461 | } | |
462 | #endif | |
463 | ||
464 | ||
d6561bb2 | 465 | #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) |
8f8d37b2 | 466 | int dev_pm_opp_of_add_table(struct device *dev); |
fa9b274f | 467 | int dev_pm_opp_of_add_table_indexed(struct device *dev, int index); |
e69709f6 | 468 | int devm_pm_opp_of_add_table_indexed(struct device *dev, int index); |
8f8d37b2 | 469 | void dev_pm_opp_of_remove_table(struct device *dev); |
3d5cfbb6 | 470 | int devm_pm_opp_of_add_table(struct device *dev); |
ddbb74bc AB |
471 | int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask); |
472 | void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); | |
473 | int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); | |
0764c604 | 474 | struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); |
e2f4b5f8 | 475 | struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); |
2feb5a89 | 476 | int of_get_required_opp_performance_state(struct device_node *np, int index); |
e3943f00 | 477 | bool dev_pm_opp_of_has_required_opp(struct device *dev); |
6d3f922c | 478 | int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table); |
0e0ffa85 | 479 | int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus); |
e3ac0f36 LL |
480 | int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW, |
481 | unsigned long *kHz); | |
0e0ffa85 LL |
482 | static inline void dev_pm_opp_of_unregister_em(struct device *dev) |
483 | { | |
484 | em_dev_unregister_perf_domain(dev); | |
485 | } | |
d6561bb2 | 486 | #else |
8f8d37b2 | 487 | static inline int dev_pm_opp_of_add_table(struct device *dev) |
d6561bb2 | 488 | { |
1d614920 | 489 | return -EOPNOTSUPP; |
d6561bb2 | 490 | } |
129eec55 | 491 | |
fa9b274f VK |
492 | static inline int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) |
493 | { | |
1d614920 | 494 | return -EOPNOTSUPP; |
fa9b274f VK |
495 | } |
496 | ||
e69709f6 DO |
497 | static inline int devm_pm_opp_of_add_table_indexed(struct device *dev, int index) |
498 | { | |
499 | return -EOPNOTSUPP; | |
500 | } | |
501 | ||
8f8d37b2 | 502 | static inline void dev_pm_opp_of_remove_table(struct device *dev) |
129eec55 VK |
503 | { |
504 | } | |
8d4d4e98 | 505 | |
3d5cfbb6 YL |
506 | static inline int devm_pm_opp_of_add_table(struct device *dev) |
507 | { | |
508 | return -EOPNOTSUPP; | |
509 | } | |
510 | ||
ddbb74bc | 511 | static inline int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask) |
8d4d4e98 | 512 | { |
1d614920 | 513 | return -EOPNOTSUPP; |
8d4d4e98 VK |
514 | } |
515 | ||
ddbb74bc | 516 | static inline void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask) |
8d4d4e98 VK |
517 | { |
518 | } | |
519 | ||
ddbb74bc | 520 | static inline int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) |
8d4d4e98 | 521 | { |
1d614920 | 522 | return -EOPNOTSUPP; |
8d4d4e98 | 523 | } |
0764c604 DG |
524 | |
525 | static inline struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev) | |
526 | { | |
527 | return NULL; | |
528 | } | |
a88bd2a5 | 529 | |
e2f4b5f8 VK |
530 | static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) |
531 | { | |
532 | return NULL; | |
533 | } | |
a4f342b9 | 534 | |
0e0ffa85 LL |
535 | static inline int dev_pm_opp_of_register_em(struct device *dev, |
536 | struct cpumask *cpus) | |
537 | { | |
1d614920 | 538 | return -EOPNOTSUPP; |
0e0ffa85 LL |
539 | } |
540 | ||
541 | static inline void dev_pm_opp_of_unregister_em(struct device *dev) | |
a4f342b9 QP |
542 | { |
543 | } | |
544 | ||
e3ac0f36 LL |
545 | static inline int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW, |
546 | unsigned long *kHz) | |
547 | { | |
548 | return -EOPNOTSUPP; | |
549 | } | |
550 | ||
2feb5a89 | 551 | static inline int of_get_required_opp_performance_state(struct device_node *np, int index) |
4c6a343e | 552 | { |
1d614920 | 553 | return -EOPNOTSUPP; |
4c6a343e | 554 | } |
6d3f922c | 555 | |
e3943f00 UH |
556 | static inline bool dev_pm_opp_of_has_required_opp(struct device *dev) |
557 | { | |
558 | return false; | |
559 | } | |
560 | ||
6d3f922c GD |
561 | static inline int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table) |
562 | { | |
1d614920 | 563 | return -EOPNOTSUPP; |
6d3f922c | 564 | } |
d6561bb2 SG |
565 | #endif |
566 | ||
b0ec0942 VK |
567 | /* OPP Configuration helpers */ |
568 | ||
248a38d5 UH |
569 | static inline int dev_pm_opp_add(struct device *dev, unsigned long freq, |
570 | unsigned long u_volt) | |
571 | { | |
572 | struct dev_pm_opp_data data = { | |
573 | .freq = freq, | |
574 | .u_volt = u_volt, | |
575 | }; | |
576 | ||
577 | return dev_pm_opp_add_dynamic(dev, &data); | |
578 | } | |
579 | ||
b0ec0942 VK |
580 | /* Regulators helpers */ |
581 | static inline int dev_pm_opp_set_regulators(struct device *dev, | |
582 | const char * const names[]) | |
583 | { | |
584 | struct dev_pm_opp_config config = { | |
585 | .regulator_names = names, | |
586 | }; | |
587 | ||
588 | return dev_pm_opp_set_config(dev, &config); | |
589 | } | |
590 | ||
591 | static inline void dev_pm_opp_put_regulators(int token) | |
592 | { | |
593 | dev_pm_opp_clear_config(token); | |
594 | } | |
595 | ||
596 | static inline int devm_pm_opp_set_regulators(struct device *dev, | |
597 | const char * const names[]) | |
598 | { | |
599 | struct dev_pm_opp_config config = { | |
600 | .regulator_names = names, | |
601 | }; | |
602 | ||
603 | return devm_pm_opp_set_config(dev, &config); | |
604 | } | |
605 | ||
89f03984 VK |
606 | /* Supported-hw helpers */ |
607 | static inline int dev_pm_opp_set_supported_hw(struct device *dev, | |
608 | const u32 *versions, | |
609 | unsigned int count) | |
610 | { | |
611 | struct dev_pm_opp_config config = { | |
612 | .supported_hw = versions, | |
613 | .supported_hw_count = count, | |
614 | }; | |
615 | ||
616 | return dev_pm_opp_set_config(dev, &config); | |
617 | } | |
618 | ||
619 | static inline void dev_pm_opp_put_supported_hw(int token) | |
620 | { | |
621 | dev_pm_opp_clear_config(token); | |
622 | } | |
623 | ||
624 | static inline int devm_pm_opp_set_supported_hw(struct device *dev, | |
625 | const u32 *versions, | |
626 | unsigned int count) | |
627 | { | |
628 | struct dev_pm_opp_config config = { | |
629 | .supported_hw = versions, | |
630 | .supported_hw_count = count, | |
631 | }; | |
632 | ||
633 | return devm_pm_opp_set_config(dev, &config); | |
634 | } | |
635 | ||
2368f576 VK |
636 | /* clkname helpers */ |
637 | static inline int dev_pm_opp_set_clkname(struct device *dev, const char *name) | |
638 | { | |
639 | const char *names[] = { name, NULL }; | |
640 | struct dev_pm_opp_config config = { | |
641 | .clk_names = names, | |
642 | }; | |
643 | ||
644 | return dev_pm_opp_set_config(dev, &config); | |
645 | } | |
646 | ||
647 | static inline void dev_pm_opp_put_clkname(int token) | |
648 | { | |
649 | dev_pm_opp_clear_config(token); | |
650 | } | |
651 | ||
652 | static inline int devm_pm_opp_set_clkname(struct device *dev, const char *name) | |
653 | { | |
654 | const char *names[] = { name, NULL }; | |
655 | struct dev_pm_opp_config config = { | |
656 | .clk_names = names, | |
657 | }; | |
658 | ||
659 | return devm_pm_opp_set_config(dev, &config); | |
660 | } | |
661 | ||
aee3352f VK |
662 | /* config-regulators helpers */ |
663 | static inline int dev_pm_opp_set_config_regulators(struct device *dev, | |
664 | config_regulators_t helper) | |
665 | { | |
666 | struct dev_pm_opp_config config = { | |
667 | .config_regulators = helper, | |
668 | }; | |
669 | ||
670 | return dev_pm_opp_set_config(dev, &config); | |
671 | } | |
672 | ||
673 | static inline void dev_pm_opp_put_config_regulators(int token) | |
674 | { | |
675 | dev_pm_opp_clear_config(token); | |
3c543b42 VK |
676 | } |
677 | ||
442e7a17 VK |
678 | /* genpd helpers */ |
679 | static inline int dev_pm_opp_attach_genpd(struct device *dev, | |
680 | const char * const *names, | |
681 | struct device ***virt_devs) | |
682 | { | |
683 | struct dev_pm_opp_config config = { | |
684 | .genpd_names = names, | |
685 | .virt_devs = virt_devs, | |
686 | }; | |
687 | ||
688 | return dev_pm_opp_set_config(dev, &config); | |
689 | } | |
690 | ||
691 | static inline void dev_pm_opp_detach_genpd(int token) | |
692 | { | |
693 | dev_pm_opp_clear_config(token); | |
694 | } | |
695 | ||
696 | static inline int devm_pm_opp_attach_genpd(struct device *dev, | |
697 | const char * const *names, | |
698 | struct device ***virt_devs) | |
699 | { | |
700 | struct dev_pm_opp_config config = { | |
701 | .genpd_names = names, | |
702 | .virt_devs = virt_devs, | |
703 | }; | |
704 | ||
705 | return devm_pm_opp_set_config(dev, &config); | |
706 | } | |
707 | ||
298098e5 VK |
708 | /* prop-name helpers */ |
709 | static inline int dev_pm_opp_set_prop_name(struct device *dev, const char *name) | |
710 | { | |
711 | struct dev_pm_opp_config config = { | |
712 | .prop_name = name, | |
713 | }; | |
714 | ||
715 | return dev_pm_opp_set_config(dev, &config); | |
716 | } | |
717 | ||
718 | static inline void dev_pm_opp_put_prop_name(int token) | |
719 | { | |
720 | dev_pm_opp_clear_config(token); | |
721 | } | |
442e7a17 | 722 | |
746de825 VK |
723 | static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) |
724 | { | |
725 | return dev_pm_opp_get_freq_indexed(opp, 0); | |
726 | } | |
727 | ||
e1f60b29 | 728 | #endif /* __LINUX_OPP_H__ */ |