.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Generic OPP Interface |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * Nishanth Menon |
---|
6 | 7 | * Romit Dasgupta |
---|
7 | 8 | * 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 | 9 | */ |
---|
13 | 10 | |
---|
14 | 11 | #ifndef __LINUX_OPP_H__ |
---|
15 | 12 | #define __LINUX_OPP_H__ |
---|
16 | 13 | |
---|
| 14 | +#include <linux/energy_model.h> |
---|
17 | 15 | #include <linux/err.h> |
---|
18 | 16 | #include <linux/notifier.h> |
---|
19 | 17 | |
---|
.. | .. |
---|
25 | 23 | |
---|
26 | 24 | enum dev_pm_opp_event { |
---|
27 | 25 | OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE, |
---|
| 26 | + OPP_EVENT_ADJUST_VOLTAGE, |
---|
28 | 27 | }; |
---|
29 | 28 | |
---|
30 | 29 | /** |
---|
.. | .. |
---|
41 | 40 | unsigned long u_volt_min; |
---|
42 | 41 | unsigned long u_volt_max; |
---|
43 | 42 | unsigned long u_amp; |
---|
| 43 | +}; |
---|
| 44 | + |
---|
| 45 | +/** |
---|
| 46 | + * struct dev_pm_opp_icc_bw - Interconnect bandwidth values |
---|
| 47 | + * @avg: Average bandwidth corresponding to this OPP (in icc units) |
---|
| 48 | + * @peak: Peak bandwidth corresponding to this OPP (in icc units) |
---|
| 49 | + * |
---|
| 50 | + * This structure stores the bandwidth values for a single interconnect path. |
---|
| 51 | + */ |
---|
| 52 | +struct dev_pm_opp_icc_bw { |
---|
| 53 | + u32 avg; |
---|
| 54 | + u32 peak; |
---|
44 | 55 | }; |
---|
45 | 56 | |
---|
46 | 57 | /** |
---|
.. | .. |
---|
79 | 90 | #if defined(CONFIG_PM_OPP) |
---|
80 | 91 | |
---|
81 | 92 | struct opp_table *dev_pm_opp_get_opp_table(struct device *dev); |
---|
| 93 | +struct opp_table *dev_pm_opp_get_opp_table_indexed(struct device *dev, int index); |
---|
82 | 94 | void dev_pm_opp_put_opp_table(struct opp_table *opp_table); |
---|
83 | 95 | |
---|
84 | 96 | unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); |
---|
85 | 97 | |
---|
86 | 98 | unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); |
---|
| 99 | + |
---|
| 100 | +unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); |
---|
87 | 101 | |
---|
88 | 102 | bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); |
---|
89 | 103 | |
---|
.. | .. |
---|
96 | 110 | struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, |
---|
97 | 111 | unsigned long freq, |
---|
98 | 112 | bool available); |
---|
| 113 | +struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, |
---|
| 114 | + unsigned int level); |
---|
99 | 115 | |
---|
100 | 116 | struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, |
---|
101 | 117 | unsigned long *freq); |
---|
| 118 | +struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev, |
---|
| 119 | + unsigned long u_volt); |
---|
102 | 120 | |
---|
103 | 121 | struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, |
---|
104 | 122 | unsigned long *freq); |
---|
.. | .. |
---|
107 | 125 | int dev_pm_opp_add(struct device *dev, unsigned long freq, |
---|
108 | 126 | unsigned long u_volt); |
---|
109 | 127 | void dev_pm_opp_remove(struct device *dev, unsigned long freq); |
---|
| 128 | +void dev_pm_opp_remove_all_dynamic(struct device *dev); |
---|
| 129 | + |
---|
| 130 | +int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, |
---|
| 131 | + unsigned long u_volt, unsigned long u_volt_min, |
---|
| 132 | + unsigned long u_volt_max); |
---|
110 | 133 | |
---|
111 | 134 | int dev_pm_opp_enable(struct device *dev, unsigned long freq); |
---|
112 | 135 | |
---|
.. | .. |
---|
125 | 148 | void dev_pm_opp_put_clkname(struct opp_table *opp_table); |
---|
126 | 149 | struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); |
---|
127 | 150 | void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table); |
---|
| 151 | +struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs); |
---|
| 152 | +void dev_pm_opp_detach_genpd(struct opp_table *opp_table); |
---|
| 153 | +int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); |
---|
128 | 154 | int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); |
---|
129 | | -int dev_pm_opp_check_rate_volt(struct device *dev, bool force); |
---|
| 155 | +int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp); |
---|
130 | 156 | int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); |
---|
131 | 157 | int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); |
---|
132 | 158 | void dev_pm_opp_remove_table(struct device *dev); |
---|
133 | 159 | void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask); |
---|
134 | 160 | #else |
---|
135 | 161 | static inline struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) |
---|
| 162 | +{ |
---|
| 163 | + return ERR_PTR(-ENOTSUPP); |
---|
| 164 | +} |
---|
| 165 | + |
---|
| 166 | +static inline struct opp_table *dev_pm_opp_get_opp_table_indexed(struct device *dev, int index) |
---|
136 | 167 | { |
---|
137 | 168 | return ERR_PTR(-ENOTSUPP); |
---|
138 | 169 | } |
---|
.. | .. |
---|
145 | 176 | } |
---|
146 | 177 | |
---|
147 | 178 | static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) |
---|
| 179 | +{ |
---|
| 180 | + return 0; |
---|
| 181 | +} |
---|
| 182 | + |
---|
| 183 | +static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) |
---|
148 | 184 | { |
---|
149 | 185 | return 0; |
---|
150 | 186 | } |
---|
.. | .. |
---|
185 | 221 | return ERR_PTR(-ENOTSUPP); |
---|
186 | 222 | } |
---|
187 | 223 | |
---|
| 224 | +static inline struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, |
---|
| 225 | + unsigned int level) |
---|
| 226 | +{ |
---|
| 227 | + return ERR_PTR(-ENOTSUPP); |
---|
| 228 | +} |
---|
| 229 | + |
---|
188 | 230 | static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, |
---|
189 | 231 | unsigned long *freq) |
---|
| 232 | +{ |
---|
| 233 | + return ERR_PTR(-ENOTSUPP); |
---|
| 234 | +} |
---|
| 235 | + |
---|
| 236 | +static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev, |
---|
| 237 | + unsigned long u_volt) |
---|
190 | 238 | { |
---|
191 | 239 | return ERR_PTR(-ENOTSUPP); |
---|
192 | 240 | } |
---|
.. | .. |
---|
207 | 255 | |
---|
208 | 256 | static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq) |
---|
209 | 257 | { |
---|
| 258 | +} |
---|
| 259 | + |
---|
| 260 | +static inline void dev_pm_opp_remove_all_dynamic(struct device *dev) |
---|
| 261 | +{ |
---|
| 262 | +} |
---|
| 263 | + |
---|
| 264 | +static inline int |
---|
| 265 | +dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, |
---|
| 266 | + unsigned long u_volt, unsigned long u_volt_min, |
---|
| 267 | + unsigned long u_volt_max) |
---|
| 268 | +{ |
---|
| 269 | + return 0; |
---|
210 | 270 | } |
---|
211 | 271 | |
---|
212 | 272 | static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq) |
---|
.. | .. |
---|
267 | 327 | |
---|
268 | 328 | static inline void dev_pm_opp_put_clkname(struct opp_table *opp_table) {} |
---|
269 | 329 | |
---|
| 330 | +static inline struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs) |
---|
| 331 | +{ |
---|
| 332 | + return ERR_PTR(-ENOTSUPP); |
---|
| 333 | +} |
---|
| 334 | + |
---|
| 335 | +static inline void dev_pm_opp_detach_genpd(struct opp_table *opp_table) {} |
---|
| 336 | + |
---|
| 337 | +static inline int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate) |
---|
| 338 | +{ |
---|
| 339 | + return -ENOTSUPP; |
---|
| 340 | +} |
---|
| 341 | + |
---|
270 | 342 | static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) |
---|
271 | 343 | { |
---|
272 | 344 | return -ENOTSUPP; |
---|
273 | 345 | } |
---|
274 | 346 | |
---|
275 | | -static inline int dev_pm_opp_check_rate_volt(struct device *dev, bool force) |
---|
| 347 | +static inline int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) |
---|
276 | 348 | { |
---|
277 | | - return -ENOTSUPP; |
---|
| 349 | + return -EOPNOTSUPP; |
---|
278 | 350 | } |
---|
279 | 351 | |
---|
280 | 352 | static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask) |
---|
.. | .. |
---|
305 | 377 | void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); |
---|
306 | 378 | int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); |
---|
307 | 379 | struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); |
---|
308 | | -struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, struct device_node *np); |
---|
309 | 380 | struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); |
---|
310 | | -int of_dev_pm_opp_get_cpu_power(unsigned long *mW, unsigned long *KHz, int cpu); |
---|
| 381 | +int of_get_required_opp_performance_state(struct device_node *np, int index); |
---|
| 382 | +int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table); |
---|
| 383 | +int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus); |
---|
| 384 | +static inline void dev_pm_opp_of_unregister_em(struct device *dev) |
---|
| 385 | +{ |
---|
| 386 | + em_dev_unregister_perf_domain(dev); |
---|
| 387 | +} |
---|
311 | 388 | #else |
---|
312 | 389 | static inline int dev_pm_opp_of_add_table(struct device *dev) |
---|
313 | 390 | { |
---|
.. | .. |
---|
342 | 419 | return NULL; |
---|
343 | 420 | } |
---|
344 | 421 | |
---|
345 | | -static inline struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, struct device_node *np) |
---|
346 | | -{ |
---|
347 | | - return NULL; |
---|
348 | | -} |
---|
349 | 422 | static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) |
---|
350 | 423 | { |
---|
351 | 424 | return NULL; |
---|
352 | 425 | } |
---|
353 | | -static inline int of_dev_pm_opp_get_cpu_power(unsigned long *mW, unsigned long *KHz, int cpu) |
---|
| 426 | + |
---|
| 427 | +static inline int dev_pm_opp_of_register_em(struct device *dev, |
---|
| 428 | + struct cpumask *cpus) |
---|
| 429 | +{ |
---|
| 430 | + return -ENOTSUPP; |
---|
| 431 | +} |
---|
| 432 | + |
---|
| 433 | +static inline void dev_pm_opp_of_unregister_em(struct device *dev) |
---|
| 434 | +{ |
---|
| 435 | +} |
---|
| 436 | + |
---|
| 437 | +static inline int of_get_required_opp_performance_state(struct device_node *np, int index) |
---|
| 438 | +{ |
---|
| 439 | + return -ENOTSUPP; |
---|
| 440 | +} |
---|
| 441 | + |
---|
| 442 | +static inline int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table) |
---|
354 | 443 | { |
---|
355 | 444 | return -ENOTSUPP; |
---|
356 | 445 | } |
---|