linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>,
	Stephen Boyd <sboyd@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
	linux-pm@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 8/8] OPP: Provide a simple implementation to configure multiple clocks
Date: Fri, 10 Jun 2022 13:50:52 +0530	[thread overview]
Message-ID: <76c4db9b37866c60306d39ed982cba56af15ff00.1654849214.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1654849214.git.viresh.kumar@linaro.org>

This provides a simple implementation to configure multiple clocks for a
device.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/opp/core.c     | 34 ++++++++++++++++++++++++++++++++++
 include/linux/pm_opp.h | 10 ++++++++++
 2 files changed, 44 insertions(+)

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 5635f4ad6d59..bb7be115a0c9 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -825,6 +825,40 @@ _opp_config_clk_single(struct device *dev, struct opp_table *opp_table,
 	return ret;
 }
 
+/*
+ * Simple implementation for configuring multiple clocks. Configure clocks in
+ * the order in which they are present in the array while scaling up.
+ */
+int dev_pm_opp_config_clks_simple(struct device *dev,
+		struct opp_table *opp_table, struct dev_pm_opp *opp, void *data,
+		bool scaling_down)
+{
+	int ret, i;
+
+	if (scaling_down) {
+		for (i = opp_table->clk_count - 1; i >= 0; i--) {
+			ret = clk_set_rate(opp_table->clks[i], opp->rates[i]);
+			if (ret) {
+				dev_err(dev, "%s: failed to set clock rate: %d\n", __func__,
+					ret);
+				return ret;
+			}
+		}
+	} else {
+		for (i = 0; i < opp_table->clk_count; i++) {
+			ret = clk_set_rate(opp_table->clks[i], opp->rates[i]);
+			if (ret) {
+				dev_err(dev, "%s: failed to set clock rate: %d\n", __func__,
+					ret);
+				return ret;
+			}
+		}
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_config_clks_simple);
+
 static int _opp_config_regulator_single(struct device *dev,
 			struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp,
 			struct regulator **regulators, unsigned int count)
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 74fbb7515128..8e69b4e971d0 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -162,6 +162,9 @@ int dev_pm_opp_unregister_notifier(struct device *dev, struct notifier_block *nb
 struct opp_table *dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config);
 int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config);
 void dev_pm_opp_clear_config(struct opp_table *opp_table);
+int dev_pm_opp_config_clks_simple(struct device *dev,
+		struct opp_table *opp_table, struct dev_pm_opp *opp, void *data,
+		bool scaling_down);
 
 struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, struct opp_table *dst_table, struct dev_pm_opp *src_opp);
 int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate);
@@ -345,6 +348,13 @@ static inline int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_c
 
 static inline void dev_pm_opp_clear_config(struct opp_table *opp_table) {}
 
+static inline int dev_pm_opp_config_clks_simple(struct device *dev,
+		struct opp_table *opp_table, struct dev_pm_opp *opp, void *data,
+		bool scaling_down)
+{
+	return -EOPNOTSUPP;
+}
+
 static inline struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table,
 				struct opp_table *dst_table, struct dev_pm_opp *src_opp)
 {
-- 
2.31.1.272.g89b43f80a514


      parent reply	other threads:[~2022-06-10  8:25 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10  8:20 [PATCH 0/8] OPP: Add support for multiple clocks Viresh Kumar
2022-06-10  8:20 ` [PATCH 1/8] OPP: Use consistent names for OPP table instances Viresh Kumar
2022-06-10  8:20 ` [PATCH 2/8] OPP: Remove rate_not_available parameter to _opp_add() Viresh Kumar
2022-06-10  8:20 ` [PATCH 3/8] OPP: Reuse _opp_compare_key() in _opp_add_static_v2() Viresh Kumar
2022-06-22 13:58   ` Jon Hunter
2022-06-22 14:07     ` Viresh Kumar
2022-06-10  8:20 ` [PATCH 4/8] OPP: Make dev_pm_opp_set_opp() independent of frequency Viresh Kumar
2022-06-10  8:20 ` [PATCH 5/8] OPP: Allow multiple clocks for a device Viresh Kumar
2022-06-13  8:07   ` Viresh Kumar
2022-06-22 13:47   ` Jon Hunter
2022-06-22 14:15     ` Viresh Kumar
2022-06-22 15:27       ` Jon Hunter
2022-06-29 18:33         ` Dmitry Osipenko
2022-06-30  0:50           ` Viresh Kumar
2022-06-30  9:13             ` Dmitry Osipenko
2022-06-30  9:52               ` Viresh Kumar
2022-06-30  9:57                 ` Dmitry Osipenko
2022-06-30 10:15                   ` Viresh Kumar
2022-07-04 12:09                     ` Viresh Kumar
2022-07-04 13:17                       ` Dmitry Osipenko
2022-07-04 15:52                         ` Viresh Kumar
2022-07-04 18:04                           ` Dmitry Osipenko
2022-07-05  4:08                             ` Viresh Kumar
2022-06-30  8:38   ` Krzysztof Kozlowski
2022-06-30  9:39     ` Viresh Kumar
2022-06-30 12:32   ` Krzysztof Kozlowski
2022-06-30 12:39     ` Krzysztof Kozlowski
2022-07-01  6:47       ` Viresh Kumar
2022-07-05  6:59       ` Viresh Kumar
2022-07-05  8:18         ` Krzysztof Kozlowski
2022-07-05  8:40           ` Viresh Kumar
2022-06-10  8:20 ` [PATCH 6/8] OPP: Add key specific assert() method to key finding helpers Viresh Kumar
2022-06-10  8:20 ` [PATCH 7/8] OPP: Assert clk_count == 1 for single clk helpers Viresh Kumar
2022-06-10  8:20 ` Viresh Kumar [this message]

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=76c4db9b37866c60306d39ed982cba56af15ff00.1654849214.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=rafael@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vireshk@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).