hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/opp/opp.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Generic OPP Interface
34 *
....@@ -5,16 +6,13 @@
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 __DRIVER_OPP_H__
1512 #define __DRIVER_OPP_H__
1613
1714 #include <linux/device.h>
15
+#include <linux/interconnect.h>
1816 #include <linux/kernel.h>
1917 #include <linux/kref.h>
2018 #include <linux/list.h>
....@@ -60,9 +58,12 @@
6058 * @suspend: true if suspend OPP
6159 * @pstate: Device's power domain's performance state.
6260 * @rate: Frequency in hertz
61
+ * @level: Performance level
6362 * @supplies: Power supplies voltage/current values
63
+ * @bandwidth: Interconnect bandwidth values
6464 * @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's
6565 * frequency from any other OPP's frequency.
66
+ * @required_opps: List of OPPs that are required by this OPP.
6667 * @opp_table: points back to the opp_table struct this opp belongs to
6768 * @np: OPP's device node.
6869 * @dentry: debugfs dentry pointer (per opp)
....@@ -79,11 +80,14 @@
7980 bool suspend;
8081 unsigned int pstate;
8182 unsigned long rate;
83
+ unsigned int level;
8284
8385 struct dev_pm_opp_supply *supplies;
86
+ struct dev_pm_opp_icc_bw *bandwidth;
8487
8588 unsigned long clock_latency_ns;
8689
90
+ struct dev_pm_opp **required_opps;
8791 struct opp_table *opp_table;
8892
8993 struct device_node *np;
....@@ -126,11 +130,17 @@
126130 * @dev_list: list of devices that share these OPPs
127131 * @opp_list: table of opps
128132 * @kref: for reference count of the table.
129
- * @lock: mutex protecting the opp_list.
133
+ * @lock: mutex protecting the opp_list and dev_list.
130134 * @np: struct device_node pointer for opp's DT node.
131135 * @clock_latency_ns_max: Max clock latency in nanoseconds.
136
+ * @parsed_static_opps: Count of devices for which OPPs are initialized from DT.
132137 * @shared_opp: OPP is shared between multiple devices.
133138 * @suspend_opp: Pointer to OPP to be used during device suspend.
139
+ * @genpd_virt_dev_lock: Mutex protecting the genpd virtual device pointers.
140
+ * @genpd_virt_devs: List of virtual devices for multiple genpd support.
141
+ * @required_opp_tables: List of device OPP tables that are required by OPPs in
142
+ * this table.
143
+ * @required_opp_count: Number of required devices.
134144 * @supported_hw: Array of version number to support.
135145 * @supported_hw_count: Number of elements in supported_hw array.
136146 * @prop_name: A name to postfix to many DT properties, while parsing them.
....@@ -139,7 +149,11 @@
139149 * @regulator_count: Number of power supply regulators. Its value can be -1
140150 * (uninitialized), 0 (no opp-microvolt property) or > 0 (has opp-microvolt
141151 * property).
152
+ * @paths: Interconnect path handles
153
+ * @path_count: Number of interconnect paths
154
+ * @enabled: Set to true if the device's resources are enabled/configured.
142155 * @genpd_performance_state: Device's power domain support performance state.
156
+ * @is_genpd: Marks if the OPP table belongs to a genpd.
143157 * @set_opp: Platform specific set_opp callback
144158 * @set_opp_data: Data to be passed to set_opp callback
145159 * @dentry: debugfs dentry pointer of the real device directory (not links).
....@@ -166,8 +180,14 @@
166180 /* For backward compatibility with v1 bindings */
167181 unsigned int voltage_tolerance_v1;
168182
183
+ unsigned int parsed_static_opps;
169184 enum opp_table_access shared_opp;
170185 struct dev_pm_opp *suspend_opp;
186
+
187
+ struct mutex genpd_virt_dev_lock;
188
+ struct device **genpd_virt_devs;
189
+ struct opp_table **required_opp_tables;
190
+ unsigned int required_opp_count;
171191
172192 unsigned int *supported_hw;
173193 unsigned int supported_hw_count;
....@@ -175,7 +195,11 @@
175195 struct clk *clk;
176196 struct regulator **regulators;
177197 int regulator_count;
198
+ struct icc_path **paths;
199
+ unsigned int path_count;
200
+ bool enabled;
178201 bool genpd_performance_state;
202
+ bool is_genpd;
179203
180204 int (*set_opp)(struct dev_pm_set_opp_data *data);
181205 struct dev_pm_set_opp_data *set_opp_data;
....@@ -188,39 +212,47 @@
188212
189213 /* Routines internal to opp core */
190214 void dev_pm_opp_get(struct dev_pm_opp *opp);
215
+bool _opp_remove_all_static(struct opp_table *opp_table);
191216 void _get_opp_table_kref(struct opp_table *opp_table);
192217 int _get_opp_count(struct opp_table *opp_table);
193218 struct opp_table *_find_opp_table(struct device *dev);
194219 struct opp_device *_add_opp_dev(const struct device *dev, struct opp_table *opp_table);
195
-void _dev_pm_opp_remove_table(struct opp_table *opp_table, struct device *dev, bool remove_all);
196
-void _dev_pm_opp_find_and_remove_table(struct device *dev, bool remove_all);
197220 struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table);
198221 void _opp_free(struct dev_pm_opp *opp);
222
+int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2);
199223 int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *opp_table, bool rate_not_available);
200224 int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned long freq, long u_volt, bool dynamic);
201
-void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of);
225
+void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, int last_cpu);
202226 struct opp_table *_add_opp_table(struct device *dev);
227
+void _put_opp_list_kref(struct opp_table *opp_table);
203228
204229 #ifdef CONFIG_OF
205
-void _of_init_opp_table(struct opp_table *opp_table, struct device *dev);
230
+void _of_init_opp_table(struct opp_table *opp_table, struct device *dev, int index);
231
+void _of_clear_opp_table(struct opp_table *opp_table);
232
+struct opp_table *_managed_opp(struct device *dev, int index);
233
+void _of_opp_free_required_opps(struct opp_table *opp_table,
234
+ struct dev_pm_opp *opp);
206235 #else
207
-static inline void _of_init_opp_table(struct opp_table *opp_table, struct device *dev) {}
236
+static inline void _of_init_opp_table(struct opp_table *opp_table, struct device *dev, int index) {}
237
+static inline void _of_clear_opp_table(struct opp_table *opp_table) {}
238
+static inline struct opp_table *_managed_opp(struct device *dev, int index) { return NULL; }
239
+static inline void _of_opp_free_required_opps(struct opp_table *opp_table,
240
+ struct dev_pm_opp *opp) {}
208241 #endif
209242
210243 #ifdef CONFIG_DEBUG_FS
211244 void opp_debug_remove_one(struct dev_pm_opp *opp);
212
-int opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table);
213
-int opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table);
245
+void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table);
246
+void opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table);
214247 void opp_debug_unregister(struct opp_device *opp_dev, struct opp_table *opp_table);
215248 #else
216249 static inline void opp_debug_remove_one(struct dev_pm_opp *opp) {}
217250
218
-static inline int opp_debug_create_one(struct dev_pm_opp *opp,
219
- struct opp_table *opp_table)
220
-{ return 0; }
221
-static inline int opp_debug_register(struct opp_device *opp_dev,
222
- struct opp_table *opp_table)
223
-{ return 0; }
251
+static inline void opp_debug_create_one(struct dev_pm_opp *opp,
252
+ struct opp_table *opp_table) { }
253
+
254
+static inline void opp_debug_register(struct opp_device *opp_dev,
255
+ struct opp_table *opp_table) { }
224256
225257 static inline void opp_debug_unregister(struct opp_device *opp_dev,
226258 struct opp_table *opp_table)