summaryrefslogtreecommitdiff
path: root/drivers/opp
diff options
context:
space:
mode:
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>2023-07-20 08:40:53 +0300
committerViresh Kumar <viresh.kumar@linaro.org>2023-07-24 10:52:39 +0300
commit5f756d03e2c7db63c1df7148d7b1739f29ff1532 (patch)
tree3505828ed917814c82989185a306006135f6680f /drivers/opp
parent142e17c1c2b48e3fb4f024e62ab6dee18f268694 (diff)
downloadlinux-5f756d03e2c7db63c1df7148d7b1739f29ff1532.tar.xz
OPP: Introduce dev_pm_opp_get_freq_indexed() API
In the case of devices with multiple clocks, drivers need to specify the frequency index for the OPP framework to get the specific frequency within the required OPP. So let's introduce the dev_pm_opp_get_freq_indexed() API accepting the frequency index as an argument. Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> [ Viresh: Fixed potential access to NULL opp pointer ] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/opp')
-rw-r--r--drivers/opp/core.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index cb4f47b341f9..07341050d57f 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -198,6 +198,26 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq);
/**
+ * dev_pm_opp_get_freq_indexed() - Gets the frequency corresponding to an
+ * available opp with specified index
+ * @opp: opp for which frequency has to be returned for
+ * @index: index of the frequency within the required opp
+ *
+ * Return: frequency in hertz corresponding to the opp with specified index,
+ * else return 0
+ */
+unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index)
+{
+ if (IS_ERR_OR_NULL(opp) || index >= opp->opp_table->clk_count) {
+ pr_err("%s: Invalid parameters\n", __func__);
+ return 0;
+ }
+
+ return opp->rates[index];
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq_indexed);
+
+/**
* dev_pm_opp_get_level() - Gets the level corresponding to an available opp
* @opp: opp for which level value has to be returned for
*