aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/opp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/opp')
-rw-r--r--drivers/opp/of.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index 4e494720ac25..369d63a58ac4 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -970,6 +970,50 @@ put_cpu_node:
EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_sharing_cpus);
/**
+ * of_get_required_opp_performance_state() - Search for required OPP and return its performance state.
+ * @np: Node that contains the "required-opps" property.
+ * @index: Index of the phandle to parse.
+ *
+ * Returns the performance state of the OPP pointed out by the "required-opps"
+ * property at @index in @np.
+ *
+ * Return: Positive performance state on success, otherwise 0 on errors.
+ */
+unsigned int of_get_required_opp_performance_state(struct device_node *np,
+ int index)
+{
+ struct dev_pm_opp *opp;
+ struct device_node *required_np;
+ struct opp_table *opp_table;
+ unsigned int pstate = 0;
+
+ required_np = of_parse_required_opp(np, index);
+ if (!required_np)
+ return 0;
+
+ opp_table = _find_table_of_opp_np(required_np);
+ if (IS_ERR(opp_table)) {
+ pr_err("%s: Failed to find required OPP table %pOF: %ld\n",
+ __func__, np, PTR_ERR(opp_table));
+ goto put_required_np;
+ }
+
+ opp = _find_opp_of_np(opp_table, required_np);
+ if (opp) {
+ pstate = opp->pstate;
+ dev_pm_opp_put(opp);
+ }
+
+ dev_pm_opp_put_opp_table(opp_table);
+
+put_required_np:
+ of_node_put(required_np);
+
+ return pstate;
+}
+EXPORT_SYMBOL_GPL(of_get_required_opp_performance_state);
+
+/**
* of_dev_pm_opp_find_required_opp() - Search for required OPP.
* @dev: The device whose OPP node is referenced by the 'np' DT node.
* @np: Node that contains the "required-opps" property.