1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef __LINUX_OPP_H__
15#define __LINUX_OPP_H__
16
17#include <linux/err.h>
18#include <linux/notifier.h>
19
20struct dev_pm_opp;
21struct device;
22
23enum dev_pm_opp_event {
24 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
25};
26
27#if defined(CONFIG_PM_OPP)
28
29unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
30
31unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
32
33int dev_pm_opp_get_opp_count(struct device *dev);
34
35struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
36 unsigned long freq,
37 bool available);
38
39struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
40 unsigned long *freq);
41
42struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
43 unsigned long *freq);
44
45int dev_pm_opp_add(struct device *dev, unsigned long freq,
46 unsigned long u_volt);
47void dev_pm_opp_remove(struct device *dev, unsigned long freq);
48
49int dev_pm_opp_enable(struct device *dev, unsigned long freq);
50
51int dev_pm_opp_disable(struct device *dev, unsigned long freq);
52
53struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
54#else
55static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
56{
57 return 0;
58}
59
60static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
61{
62 return 0;
63}
64
65static inline int dev_pm_opp_get_opp_count(struct device *dev)
66{
67 return 0;
68}
69
70static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
71 unsigned long freq, bool available)
72{
73 return ERR_PTR(-EINVAL);
74}
75
76static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
77 unsigned long *freq)
78{
79 return ERR_PTR(-EINVAL);
80}
81
82static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
83 unsigned long *freq)
84{
85 return ERR_PTR(-EINVAL);
86}
87
88static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
89 unsigned long u_volt)
90{
91 return -EINVAL;
92}
93
94static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
95{
96}
97
98static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
99{
100 return 0;
101}
102
103static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
104{
105 return 0;
106}
107
108static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
109 struct device *dev)
110{
111 return ERR_PTR(-EINVAL);
112}
113#endif
114
115#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
116int of_init_opp_table(struct device *dev);
117void of_free_opp_table(struct device *dev);
118#else
119static inline int of_init_opp_table(struct device *dev)
120{
121 return -EINVAL;
122}
123
124static inline void of_free_opp_table(struct device *dev)
125{
126}
127#endif
128
129#endif
130