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