[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1503504610-12880-6-git-send-email-aisheng.dong@nxp.com>
Date: Thu, 24 Aug 2017 00:10:08 +0800
From: Dong Aisheng <aisheng.dong@....com>
To: <linux-pm@...r.kernel.org>
CC: <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>, <sboyd@...eaurora.org>,
<vireshk@...nel.org>, <nm@...com>, <rjw@...ysocki.net>,
<shawnguo@...nel.org>, <Anson.Huang@....com>, <ping.bai@....com>,
Dong Aisheng <aisheng.dong@....com>
Subject: [PATCH 5/7] PM / OPP: Add dev_pm_opp_get_cur_clk()
User may need to know the current OPP clock for updating policy clk
accordingly. e.g. cpufreq policy clock.
This function does the work.
Cc: Viresh Kumar <vireshk@...nel.org>
Cc: Nishanth Menon <nm@...com>
Cc: Stephen Boyd <sboyd@...eaurora.org>
Cc: "Rafael J. Wysocki" <rjw@...ysocki.net>
Signed-off-by: Dong Aisheng <aisheng.dong@....com>
---
drivers/base/power/opp/core.c | 29 +++++++++++++++++++++++++++++
include/linux/pm_opp.h | 3 +++
2 files changed, 32 insertions(+)
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index d4656cc..a425f98 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -1441,6 +1441,35 @@ void dev_pm_opp_put_clkname(struct opp_table *opp_table)
EXPORT_SYMBOL_GPL(dev_pm_opp_put_clkname);
/**
+ * dev_pm_opp_get_cur_clk() - Get the current OPP clock the device is running
+ * @dev: device for which we do this operation
+ *
+ * This must be called before any OPPs are initialized for the device.
+ */
+struct clk *dev_pm_opp_get_cur_clk(struct device *dev)
+{
+ struct opp_table *opp_table;
+ int ret;
+
+ opp_table = dev_pm_opp_get_opp_table(dev);
+ if (!opp_table)
+ return ERR_PTR(-ENOMEM);
+
+ if (IS_ERR(opp_table->cur_clk)) {
+ ret = -ENODEV;
+ goto err;
+ }
+
+ return opp_table->cur_clk;
+
+err:
+ dev_pm_opp_put_opp_table(opp_table);
+
+ return ERR_PTR(ret);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_get_cur_clk);
+
+/**
* dev_pm_opp_register_set_opp_helper() - Register custom set OPP helper
* @dev: Device for which the helper is getting registered.
* @set_opp: Custom set OPP helper.
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index a8b1e4d..e20d090 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -123,6 +123,7 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev, const char * con
void dev_pm_opp_put_regulators(struct opp_table *opp_table);
struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char * name);
void dev_pm_opp_put_clkname(struct opp_table *opp_table);
+struct clk *dev_pm_opp_get_cur_clk(struct device *dev);
struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data));
void dev_pm_opp_register_put_opp_helper(struct opp_table *opp_table);
struct opp_table *dev_pm_opp_register_set_clk_helper(struct device *dev, int (*set_clk)(struct device *dev, struct clk *clk,
@@ -279,6 +280,8 @@ static inline struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const
static inline void dev_pm_opp_put_clkname(struct opp_table *opp_table) {}
+static inline struct clk *dev_pm_opp_get_cur_clk(struct device *dev) {}
+
static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
{
return -ENOTSUPP;
--
2.7.4
Powered by blists - more mailing lists