1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef __DRIVER_OPP_H__
15#define __DRIVER_OPP_H__
16
17#include <linux/device.h>
18#include <linux/kernel.h>
19#include <linux/kref.h>
20#include <linux/list.h>
21#include <linux/limits.h>
22#include <linux/pm_opp.h>
23#include <linux/notifier.h>
24
25struct clk;
26struct regulator;
27
28
29extern struct mutex opp_table_lock;
30
31extern struct list_head opp_tables;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74struct dev_pm_opp {
75 struct list_head node;
76 struct kref kref;
77
78 bool available;
79 bool dynamic;
80 bool turbo;
81 bool suspend;
82 unsigned int pstate;
83 unsigned long rate;
84 unsigned int level;
85
86 struct dev_pm_opp_supply *supplies;
87
88 unsigned long clock_latency_ns;
89
90 struct dev_pm_opp **required_opps;
91 struct opp_table *opp_table;
92
93 struct device_node *np;
94
95#ifdef CONFIG_DEBUG_FS
96 struct dentry *dentry;
97#endif
98};
99
100
101
102
103
104
105
106
107
108
109struct opp_device {
110 struct list_head node;
111 const struct device *dev;
112
113#ifdef CONFIG_DEBUG_FS
114 struct dentry *dentry;
115#endif
116};
117
118enum opp_table_access {
119 OPP_TABLE_ACCESS_UNKNOWN = 0,
120 OPP_TABLE_ACCESS_EXCLUSIVE = 1,
121 OPP_TABLE_ACCESS_SHARED = 2,
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166struct opp_table {
167 struct list_head node;
168
169 struct blocking_notifier_head head;
170 struct list_head dev_list;
171 struct list_head opp_list;
172 struct kref kref;
173 struct kref list_kref;
174 struct mutex lock;
175
176 struct device_node *np;
177 unsigned long clock_latency_ns_max;
178
179
180 unsigned int voltage_tolerance_v1;
181
182 bool parsed_static_opps;
183 enum opp_table_access shared_opp;
184 struct dev_pm_opp *suspend_opp;
185
186 struct mutex genpd_virt_dev_lock;
187 struct device **genpd_virt_devs;
188 struct opp_table **required_opp_tables;
189 unsigned int required_opp_count;
190
191 unsigned int *supported_hw;
192 unsigned int supported_hw_count;
193 const char *prop_name;
194 struct clk *clk;
195 struct regulator **regulators;
196 int regulator_count;
197 bool genpd_performance_state;
198 bool is_genpd;
199
200 int (*set_opp)(struct dev_pm_set_opp_data *data);
201 struct dev_pm_set_opp_data *set_opp_data;
202
203#ifdef CONFIG_DEBUG_FS
204 struct dentry *dentry;
205 char dentry_name[NAME_MAX];
206#endif
207};
208
209
210void dev_pm_opp_get(struct dev_pm_opp *opp);
211void _opp_remove_all_static(struct opp_table *opp_table);
212void _get_opp_table_kref(struct opp_table *opp_table);
213int _get_opp_count(struct opp_table *opp_table);
214struct opp_table *_find_opp_table(struct device *dev);
215struct opp_device *_add_opp_dev(const struct device *dev, struct opp_table *opp_table);
216void _dev_pm_opp_find_and_remove_table(struct device *dev);
217struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table);
218void _opp_free(struct dev_pm_opp *opp);
219int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *opp_table, bool rate_not_available);
220int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned long freq, long u_volt, bool dynamic);
221void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, int last_cpu);
222struct opp_table *_add_opp_table(struct device *dev);
223void _put_opp_list_kref(struct opp_table *opp_table);
224
225#ifdef CONFIG_OF
226void _of_init_opp_table(struct opp_table *opp_table, struct device *dev, int index);
227void _of_clear_opp_table(struct opp_table *opp_table);
228struct opp_table *_managed_opp(struct device *dev, int index);
229void _of_opp_free_required_opps(struct opp_table *opp_table,
230 struct dev_pm_opp *opp);
231#else
232static inline void _of_init_opp_table(struct opp_table *opp_table, struct device *dev, int index) {}
233static inline void _of_clear_opp_table(struct opp_table *opp_table) {}
234static inline struct opp_table *_managed_opp(struct device *dev, int index) { return NULL; }
235static inline void _of_opp_free_required_opps(struct opp_table *opp_table,
236 struct dev_pm_opp *opp) {}
237#endif
238
239#ifdef CONFIG_DEBUG_FS
240void opp_debug_remove_one(struct dev_pm_opp *opp);
241void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table);
242void opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table);
243void opp_debug_unregister(struct opp_device *opp_dev, struct opp_table *opp_table);
244#else
245static inline void opp_debug_remove_one(struct dev_pm_opp *opp) {}
246
247static inline void opp_debug_create_one(struct dev_pm_opp *opp,
248 struct opp_table *opp_table) { }
249
250static inline void opp_debug_register(struct opp_device *opp_dev,
251 struct opp_table *opp_table) { }
252
253static inline void opp_debug_unregister(struct opp_device *opp_dev,
254 struct opp_table *opp_table)
255{ }
256#endif
257
258#endif
259