Commit | Line | Data |
---|---|---|
e1f60b29 NM |
1 | /* |
2 | * Generic OPP Interface | |
3 | * | |
4 | * Copyright (C) 2009-2010 Texas Instruments Incorporated. | |
5 | * Nishanth Menon | |
6 | * Romit Dasgupta | |
7 | * Kevin Hilman | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | */ | |
13 | ||
14 | #ifndef __LINUX_OPP_H__ | |
15 | #define __LINUX_OPP_H__ | |
16 | ||
17 | #include <linux/err.h> | |
03ca370f | 18 | #include <linux/notifier.h> |
e1f60b29 | 19 | |
47d43ba7 | 20 | struct dev_pm_opp; |
313162d0 | 21 | struct device; |
e1f60b29 | 22 | |
47d43ba7 | 23 | enum dev_pm_opp_event { |
129eec55 | 24 | OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE, |
03ca370f MH |
25 | }; |
26 | ||
e1f60b29 NM |
27 | #if defined(CONFIG_PM_OPP) |
28 | ||
47d43ba7 | 29 | unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); |
e1f60b29 | 30 | |
47d43ba7 | 31 | unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); |
e1f60b29 | 32 | |
5d4879cd | 33 | int dev_pm_opp_get_opp_count(struct device *dev); |
3ca9bb33 | 34 | unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev); |
e1f60b29 | 35 | |
47d43ba7 NM |
36 | struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, |
37 | unsigned long freq, | |
38 | bool available); | |
e1f60b29 | 39 | |
47d43ba7 NM |
40 | struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, |
41 | unsigned long *freq); | |
e1f60b29 | 42 | |
47d43ba7 NM |
43 | struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, |
44 | unsigned long *freq); | |
e1f60b29 | 45 | |
5d4879cd NM |
46 | int dev_pm_opp_add(struct device *dev, unsigned long freq, |
47 | unsigned long u_volt); | |
129eec55 | 48 | void dev_pm_opp_remove(struct device *dev, unsigned long freq); |
e1f60b29 | 49 | |
5d4879cd | 50 | int dev_pm_opp_enable(struct device *dev, unsigned long freq); |
e1f60b29 | 51 | |
5d4879cd | 52 | int dev_pm_opp_disable(struct device *dev, unsigned long freq); |
e1f60b29 | 53 | |
5d4879cd | 54 | struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev); |
e1f60b29 | 55 | #else |
47d43ba7 | 56 | static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) |
e1f60b29 NM |
57 | { |
58 | return 0; | |
59 | } | |
60 | ||
47d43ba7 | 61 | static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) |
e1f60b29 NM |
62 | { |
63 | return 0; | |
64 | } | |
65 | ||
5d4879cd | 66 | static inline int dev_pm_opp_get_opp_count(struct device *dev) |
e1f60b29 NM |
67 | { |
68 | return 0; | |
69 | } | |
70 | ||
3ca9bb33 VK |
71 | static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev) |
72 | { | |
73 | return 0; | |
74 | } | |
75 | ||
47d43ba7 | 76 | static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, |
e1f60b29 NM |
77 | unsigned long freq, bool available) |
78 | { | |
79 | return ERR_PTR(-EINVAL); | |
80 | } | |
81 | ||
47d43ba7 | 82 | static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, |
e1f60b29 NM |
83 | unsigned long *freq) |
84 | { | |
85 | return ERR_PTR(-EINVAL); | |
86 | } | |
87 | ||
47d43ba7 | 88 | static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, |
e1f60b29 NM |
89 | unsigned long *freq) |
90 | { | |
91 | return ERR_PTR(-EINVAL); | |
92 | } | |
93 | ||
5d4879cd | 94 | static inline int dev_pm_opp_add(struct device *dev, unsigned long freq, |
e1f60b29 NM |
95 | unsigned long u_volt) |
96 | { | |
97 | return -EINVAL; | |
98 | } | |
99 | ||
129eec55 VK |
100 | static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq) |
101 | { | |
102 | } | |
103 | ||
5d4879cd | 104 | static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq) |
e1f60b29 NM |
105 | { |
106 | return 0; | |
107 | } | |
108 | ||
5d4879cd | 109 | static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq) |
e1f60b29 NM |
110 | { |
111 | return 0; | |
112 | } | |
03ca370f | 113 | |
5d4879cd NM |
114 | static inline struct srcu_notifier_head *dev_pm_opp_get_notifier( |
115 | struct device *dev) | |
03ca370f MH |
116 | { |
117 | return ERR_PTR(-EINVAL); | |
118 | } | |
a96d69d1 | 119 | #endif /* CONFIG_PM_OPP */ |
e1f60b29 | 120 | |
d6561bb2 SG |
121 | #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) |
122 | int of_init_opp_table(struct device *dev); | |
129eec55 | 123 | void of_free_opp_table(struct device *dev); |
8d4d4e98 VK |
124 | int of_cpumask_init_opp_table(cpumask_var_t cpumask); |
125 | void of_cpumask_free_opp_table(cpumask_var_t cpumask); | |
126 | int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask); | |
127 | int set_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask); | |
d6561bb2 SG |
128 | #else |
129 | static inline int of_init_opp_table(struct device *dev) | |
130 | { | |
131 | return -EINVAL; | |
132 | } | |
129eec55 VK |
133 | |
134 | static inline void of_free_opp_table(struct device *dev) | |
135 | { | |
136 | } | |
8d4d4e98 VK |
137 | |
138 | static inline int of_cpumask_init_opp_table(cpumask_var_t cpumask) | |
139 | { | |
140 | return -ENOSYS; | |
141 | } | |
142 | ||
143 | static inline void of_cpumask_free_opp_table(cpumask_var_t cpumask) | |
144 | { | |
145 | } | |
146 | ||
147 | static inline int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask) | |
148 | { | |
149 | return -ENOSYS; | |
150 | } | |
151 | ||
152 | static inline int set_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask) | |
153 | { | |
154 | return -ENOSYS; | |
155 | } | |
d6561bb2 SG |
156 | #endif |
157 | ||
e1f60b29 | 158 | #endif /* __LINUX_OPP_H__ */ |