All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Rafael Wysocki <rjw@rjwysocki.net>,
	ulf.hansson@linaro.org, Kevin Hilman <khilman@linaro.org>,
	Kevin Hilman <khilman@kernel.org>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>
Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Stephen Boyd <sboyd@codeaurora.org>,
	Nishanth Menon <nm@ti.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	robh+dt@kernel.org, lina.iyer@linaro.org, rnayak@codeaurora.org,
	Viresh Kumar <viresh.kumar@linaro.org>
Subject: [PATCH V3 6/7] PM / Domains: Allow domain performance states to be read from DT
Date: Fri, 24 Feb 2017 14:36:38 +0530	[thread overview]
Message-ID: <84786c05d90e5f3c9dc41a65fe3b8ce6052a7628.1487926924.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1487926924.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1487926924.git.viresh.kumar@linaro.org>

This patch allows SoC's to define domains performance states in the DT
using the "performance-states" node in the domain provider node.

Add API to read the performance states from DT by the domain specific
drivers. Note that this information is only used by the domain specific
drivers and the power domain core doesn't need to store it for now.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Rajendra Nayak <rnayak@codeaurora.org>
---
 drivers/base/power/domain.c | 101 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/pm_domain.h   |  15 +++++++
 2 files changed, 116 insertions(+)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 202effbebfd1..a7449c492990 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2251,6 +2251,107 @@ int of_genpd_parse_idle_states(struct device_node *dn,
 }
 EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states);
 
+/* Power domain performance state management helpers */
+static const struct of_device_id performance_state_match[] = {
+	{ .compatible = "domain-performance-state", },
+	{ }
+};
+
+static int genpd_parse_performance_state(struct genpd_performance_state *state,
+					 struct device_node *np)
+{
+	int ret;
+
+	ret = of_property_read_u32(np, "reg", &state->performance_state);
+	if (ret) {
+		pr_err(" * %s missing reg property\n", np->full_name);
+		return ret;
+	}
+
+	ret = of_property_read_variable_u32_array(np, "domain-microvolt",
+						  &state->u_volt, 1, 3);
+	if (ret >= 0)
+		return 0;
+
+	/* Property not found */
+	if (ret == -EINVAL)
+		return 0;
+
+	pr_err(" * %s Invalid domain-microvolt property\n", np->full_name);
+	return ret;
+}
+
+/**
+ * of_genpd_parse_performance_states: Return array of performance states for the
+ *				      genpd.
+ *
+ * @dn: The genpd device node
+ * @states: The pointer to which the state array will be saved.
+ * @n: The count of elements in the array returned from this function.
+ *
+ * Returns the device performance states parsed from the OF node. The memory for
+ * the states is allocated by this function and is the responsibility of the
+ * caller to free the memory after use.
+ */
+int of_genpd_parse_performance_states(struct device_node *dn,
+				struct genpd_performance_state **states, int *n)
+{
+	struct genpd_performance_state *st;
+	struct device_node *perf_np, *np;
+	int i = 0, ret, count;
+
+	perf_np = of_get_child_by_name(dn, "performance-states");
+	if (!perf_np) {
+		pr_err("performance-states node not found in %s node\n",
+		       dn->full_name);
+		return -ENODEV;
+	}
+
+	if (!of_match_node(performance_state_match, perf_np)) {
+		pr_err("performance-states node found in %s node isn't compatible\n",
+		       dn->full_name);
+		ret = -EINVAL;
+		goto put_node;
+	}
+
+	count = of_get_child_count(perf_np);
+	if (count <= 0) {
+		pr_err("performance-states node found in %s node doesn't have any child nodes\n",
+		       dn->full_name);
+		ret = -EINVAL;
+		goto put_node;
+	}
+
+	st = kcalloc(count, sizeof(*st), GFP_KERNEL);
+	if (!st) {
+		ret = -ENOMEM;
+		goto put_node;
+	}
+
+	for_each_available_child_of_node(perf_np, np) {
+		ret = genpd_parse_performance_state(&st[i++], np);
+		if (ret) {
+			pr_err("Parsing of performance state node %s failed with err %d\n",
+			       np->full_name, ret);
+			goto free_st;
+		}
+	}
+
+	of_node_put(perf_np);
+	*n = count;
+	*states = st;
+
+	return 0;
+
+free_st:
+	kfree(st);
+put_node:
+	of_node_put(perf_np);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(of_genpd_parse_performance_states);
+
 #endif /* CONFIG_PM_GENERIC_DOMAINS_OF */
 
 
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 83795935709e..7659ce3968c7 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -44,6 +44,13 @@ struct genpd_power_state {
 	struct fwnode_handle *fwnode;
 };
 
+struct genpd_performance_state {
+	unsigned int performance_state;
+	unsigned int u_volt;
+	unsigned int u_volt_min;
+	unsigned int u_volt_max;
+};
+
 struct genpd_lock_ops;
 
 struct generic_pm_domain {
@@ -226,6 +233,8 @@ extern int of_genpd_add_subdomain(struct of_phandle_args *parent,
 extern struct generic_pm_domain *of_genpd_remove_last(struct device_node *np);
 extern int of_genpd_parse_idle_states(struct device_node *dn,
 			struct genpd_power_state **states, int *n);
+extern int of_genpd_parse_performance_states(struct device_node *dn,
+			struct genpd_performance_state **states, int *n);
 
 int genpd_dev_pm_attach(struct device *dev);
 #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */
@@ -261,6 +270,12 @@ static inline int of_genpd_parse_idle_states(struct device_node *dn,
 	return -ENODEV;
 }
 
+static inline int of_genpd_parse_performance_states(struct device_node *dn,
+			struct genpd_performance_state **states, int *n)
+{
+	return -ENODEV;
+}
+
 static inline int genpd_dev_pm_attach(struct device *dev)
 {
 	return -ENODEV;
-- 
2.7.1.410.g6faf27b

  parent reply	other threads:[~2017-02-24  9:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-24  9:06 [PATCH V3 0/7] PM / Domains: Implement domain performance states Viresh Kumar
2017-02-24  9:06 ` [PATCH V3 1/7] PM / Domains: Introduce "performance-states" binding Viresh Kumar
2017-02-24  9:06   ` Viresh Kumar
2017-02-28  0:31   ` Rob Herring
2017-02-28  0:31     ` Rob Herring
2017-02-28  5:36     ` Viresh Kumar
2017-02-28  5:36       ` Viresh Kumar
2017-02-24  9:06 ` [PATCH V3 2/7] PM / OPP: Introduce "domain-performance-state" binding to OPP nodes Viresh Kumar
2017-02-24  9:06   ` Viresh Kumar
2017-02-28  0:39   ` Rob Herring
2017-02-28  0:39     ` Rob Herring
2017-02-28  6:57     ` Viresh Kumar
2017-02-28  6:57       ` Viresh Kumar
2017-02-28 14:10       ` Rob Herring
2017-02-28 14:10         ` Rob Herring
2017-02-28 15:14         ` Ulf Hansson
2017-02-28 15:14           ` Ulf Hansson
2017-02-28 15:52           ` Rob Herring
2017-02-28 15:52             ` Rob Herring
2017-02-28 19:13             ` Geert Uytterhoeven
2017-03-01  6:14             ` Viresh Kumar
2017-03-01  8:45               ` Geert Uytterhoeven
2017-03-01  8:54                 ` Viresh Kumar
2017-03-01  6:27             ` Rajendra Nayak
2017-03-01 23:13               ` Rob Herring
2017-03-02  3:30                 ` Rajendra Nayak
2017-03-01  6:12         ` Viresh Kumar
2017-02-24  9:06 ` [PATCH V3 3/7] PM / QOS: Keep common notifier list for genpd constraints Viresh Kumar
2017-02-24  9:06 ` [PATCH V3 4/7] PM / QOS: Add DEV_PM_QOS_PERFORMANCE request Viresh Kumar
2017-02-24  9:06 ` [PATCH V3 5/7] PM / domain: Register for PM QOS performance notifier Viresh Kumar
2017-02-24  9:06 ` Viresh Kumar [this message]
2017-02-24  9:06 ` [PATCH V3 7/7] PM / OPP: Add support to parse domain-performance-state Viresh Kumar
2017-03-10 20:38 ` [PATCH V3 0/7] PM / Domains: Implement domain performance states Kevin Hilman
2017-03-13 10:39   ` Viresh Kumar
2017-03-15 10:49     ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84786c05d90e5f3c9dc41a65fe3b8ce6052a7628.1487926924.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=khilman@kernel.org \
    --cc=khilman@linaro.org \
    --cc=len.brown@intel.com \
    --cc=lina.iyer@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=rnayak@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.