[PATCH 08/10] OPP: Add support for opp-suspend

Viresh Kumar viresh.kumar at linaro.org
Mon Jun 15 04:57:34 PDT 2015


With "operating-points-v2" bindings, its possible to specify the OPP to
which the device must be switched, before suspending.

This patch adds support for getting that information.

Signed-off-by: Viresh Kumar <viresh.kumar at linaro.org>
---
 drivers/base/power/opp.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 6b554e417b1f..0022453e4b60 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -137,6 +137,7 @@ struct device_opp {
 	struct device_node *np;
 	unsigned long clock_latency_ns_max;
 	bool shared_opp;
+	struct dev_pm_opp *suspend_opp;
 };
 
 /*
@@ -1218,6 +1219,8 @@ static int _of_init_opp_table_v2(struct device *dev,
 		goto put_opp_np;
 
 	if (!ret) {
+		const phandle *handle;
+
 		if (!dev_opp) {
 			dev_opp = _find_device_opp(dev);
 			if (WARN_ON(!dev_opp))
@@ -1227,6 +1230,25 @@ static int _of_init_opp_table_v2(struct device *dev,
 		dev_opp->np = opp_np;
 		if (of_get_property(opp_np, "opp-shared", NULL))
 			dev_opp->shared_opp = true;
+
+		/* OPP to select on device suspend */
+		handle = of_get_property(opp_np, "opp-suspend", NULL);
+		if (handle) {
+			struct device_node *suspend_opp_np;
+			struct dev_pm_opp *opp;
+
+			suspend_opp_np = of_find_node_by_phandle(be32_to_cpup(handle));
+
+			list_for_each_entry_rcu(opp, &dev_opp->opp_list, node)
+				if (opp->np == suspend_opp_np) {
+					dev_opp->suspend_opp = opp;
+					break;
+				}
+
+			if (!dev_opp->suspend_opp)
+				dev_err(dev, "%s: Invalid opp-suspend\n",
+					__func__);
+		}
 	} else {
 		of_free_opp_table(dev);
 	}
-- 
2.4.0




More information about the linux-arm-kernel mailing list