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
72struct dev_pm_opp {
73 struct list_head node;
74 struct kref kref;
75
76 bool available;
77 bool dynamic;
78 bool turbo;
79 bool suspend;
80 unsigned int pstate;
81 unsigned long rate;
82
83 struct dev_pm_opp_supply *supplies;
84
85 unsigned long clock_latency_ns;
86
87 struct opp_table *opp_table;
88
89 struct device_node *np;
90
91#ifdef CONFIG_DEBUG_FS
92 struct dentry *dentry;
93#endif
94};
95
96
97
98
99
100
101
102
103
104
105struct opp_device {
106 struct list_head node;
107 const struct device *dev;
108
109#ifdef CONFIG_DEBUG_FS
110 struct dentry *dentry;
111#endif
112};
113
114enum opp_table_access {
115 OPP_TABLE_ACCESS_UNKNOWN = 0,
116 OPP_TABLE_ACCESS_EXCLUSIVE = 1,
117 OPP_TABLE_ACCESS_SHARED = 2,
118};
119
120
121
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
153struct opp_table {
154 struct list_head node;
155
156 struct blocking_notifier_head head;
157 struct list_head dev_list;
158 struct list_head opp_list;
159 struct kref kref;
160 struct mutex lock;
161
162 struct device_node *np;
163 unsigned long clock_latency_ns_max;
164
165
166 unsigned int voltage_tolerance_v1;
167
168 enum opp_table_access shared_opp;
169 struct dev_pm_opp *suspend_opp;
170
171 unsigned int *supported_hw;
172 unsigned int supported_hw_count;
173 const char *prop_name;
174 struct clk *clk;
175 struct regulator **regulators;
176 unsigned int regulator_count;
177 bool genpd_performance_state;
178
179 int (*set_opp)(struct dev_pm_set_opp_data *data);
180 struct dev_pm_set_opp_data *set_opp_data;
181 int (*get_pstate)(struct device *dev, unsigned long rate);
182
183#ifdef CONFIG_DEBUG_FS
184 struct dentry *dentry;
185 char dentry_name[NAME_MAX];
186#endif
187};
188
189
190void _get_opp_table_kref(struct opp_table *opp_table);
191struct opp_table *_find_opp_table(struct device *dev);
192struct opp_device *_add_opp_dev(const struct device *dev, struct opp_table *opp_table);
193void _dev_pm_opp_remove_table(struct opp_table *opp_table, struct device *dev, bool remove_all);
194void _dev_pm_opp_find_and_remove_table(struct device *dev, bool remove_all);
195struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table);
196void _opp_free(struct dev_pm_opp *opp);
197int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *opp_table);
198int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned long freq, long u_volt, bool dynamic);
199void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of);
200struct opp_table *_add_opp_table(struct device *dev);
201
202#ifdef CONFIG_OF
203void _of_init_opp_table(struct opp_table *opp_table, struct device *dev);
204#else
205static inline void _of_init_opp_table(struct opp_table *opp_table, struct device *dev) {}
206#endif
207
208#ifdef CONFIG_DEBUG_FS
209void opp_debug_remove_one(struct dev_pm_opp *opp);
210int opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table);
211int opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table);
212void opp_debug_unregister(struct opp_device *opp_dev, struct opp_table *opp_table);
213#else
214static inline void opp_debug_remove_one(struct dev_pm_opp *opp) {}
215
216static inline int opp_debug_create_one(struct dev_pm_opp *opp,
217 struct opp_table *opp_table)
218{ return 0; }
219static inline int opp_debug_register(struct opp_device *opp_dev,
220 struct opp_table *opp_table)
221{ return 0; }
222
223static inline void opp_debug_unregister(struct opp_device *opp_dev,
224 struct opp_table *opp_table)
225{ }
226#endif
227
228#endif
229