hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/include/linux/pm_opp.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Generic OPP Interface
34 *
....@@ -5,15 +6,12 @@
56 * Nishanth Menon
67 * Romit Dasgupta
78 * 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.
129 */
1310
1411 #ifndef __LINUX_OPP_H__
1512 #define __LINUX_OPP_H__
1613
14
+#include <linux/energy_model.h>
1715 #include <linux/err.h>
1816 #include <linux/notifier.h>
1917
....@@ -25,6 +23,7 @@
2523
2624 enum dev_pm_opp_event {
2725 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
26
+ OPP_EVENT_ADJUST_VOLTAGE,
2827 };
2928
3029 /**
....@@ -41,6 +40,18 @@
4140 unsigned long u_volt_min;
4241 unsigned long u_volt_max;
4342 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;
4455 };
4556
4657 /**
....@@ -79,11 +90,14 @@
7990 #if defined(CONFIG_PM_OPP)
8091
8192 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);
8294 void dev_pm_opp_put_opp_table(struct opp_table *opp_table);
8395
8496 unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
8597
8698 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);
87101
88102 bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
89103
....@@ -96,9 +110,13 @@
96110 struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
97111 unsigned long freq,
98112 bool available);
113
+struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
114
+ unsigned int level);
99115
100116 struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
101117 unsigned long *freq);
118
+struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev,
119
+ unsigned long u_volt);
102120
103121 struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
104122 unsigned long *freq);
....@@ -107,6 +125,11 @@
107125 int dev_pm_opp_add(struct device *dev, unsigned long freq,
108126 unsigned long u_volt);
109127 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);
110133
111134 int dev_pm_opp_enable(struct device *dev, unsigned long freq);
112135
....@@ -125,14 +148,22 @@
125148 void dev_pm_opp_put_clkname(struct opp_table *opp_table);
126149 struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data));
127150 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);
128154 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);
130156 int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask);
131157 int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
132158 void dev_pm_opp_remove_table(struct device *dev);
133159 void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask);
134160 #else
135161 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)
136167 {
137168 return ERR_PTR(-ENOTSUPP);
138169 }
....@@ -145,6 +176,11 @@
145176 }
146177
147178 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)
148184 {
149185 return 0;
150186 }
....@@ -185,8 +221,20 @@
185221 return ERR_PTR(-ENOTSUPP);
186222 }
187223
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
+
188230 static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
189231 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)
190238 {
191239 return ERR_PTR(-ENOTSUPP);
192240 }
....@@ -207,6 +255,18 @@
207255
208256 static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
209257 {
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;
210270 }
211271
212272 static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
....@@ -267,14 +327,26 @@
267327
268328 static inline void dev_pm_opp_put_clkname(struct opp_table *opp_table) {}
269329
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
+
270342 static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
271343 {
272344 return -ENOTSUPP;
273345 }
274346
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)
276348 {
277
- return -ENOTSUPP;
349
+ return -EOPNOTSUPP;
278350 }
279351
280352 static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask)
....@@ -305,9 +377,14 @@
305377 void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask);
306378 int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
307379 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);
309380 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
+}
311388 #else
312389 static inline int dev_pm_opp_of_add_table(struct device *dev)
313390 {
....@@ -342,15 +419,27 @@
342419 return NULL;
343420 }
344421
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
-}
349422 static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp)
350423 {
351424 return NULL;
352425 }
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)
354443 {
355444 return -ENOTSUPP;
356445 }