summaryrefslogtreecommitdiff
path: root/drivers/opp
diff options
context:
space:
mode:
authorNeil Armstrong <neil.armstrong@linaro.org>2024-11-19 18:56:36 +0100
committerViresh Kumar <viresh.kumar@linaro.org>2024-12-23 16:27:22 +0530
commitb89c0ed09e1189217cd9d516b739627c523d53a4 (patch)
treecd0173bae19164550f358eb4f87e8b58554c8ef9 /drivers/opp
parent40384c840ea1944d7c5a392e8975ed088ecf0b37 (diff)
opp: core: implement dev_pm_opp_get_bw
Add and implement dev_pm_opp_get_bw() to retrieve the OPP's bandwidth in the same way as the dev_pm_opp_get_voltage() helper. Retrieving bandwidth is required in the case of the Adreno GPU where the GPU Management Unit can handle the Bandwidth scaling. The helper can get the peak or average bandwidth for any of the interconnect path. Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> [ Viresh: Fixed commit log and a comment in code ] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/opp')
-rw-r--r--drivers/opp/core.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 0311b18319a4..d4a0030a0228 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -107,6 +107,31 @@ static bool assert_single_clk(struct opp_table *opp_table)
}
/**
+ * dev_pm_opp_get_bw() - Gets the bandwidth corresponding to an opp
+ * @opp: opp for which bandwidth has to be returned for
+ * @peak: select peak or average bandwidth
+ * @index: bandwidth index
+ *
+ * Return: bandwidth in kBps, else return 0
+ */
+unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, bool peak, int index)
+{
+ if (IS_ERR_OR_NULL(opp)) {
+ pr_err("%s: Invalid parameters\n", __func__);
+ return 0;
+ }
+
+ if (index > opp->opp_table->path_count)
+ return 0;
+
+ if (!opp->bandwidth)
+ return 0;
+
+ return peak ? opp->bandwidth[index].peak : opp->bandwidth[index].avg;
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_get_bw);
+
+/**
* dev_pm_opp_get_voltage() - Gets the voltage corresponding to an opp
* @opp: opp for which voltage has to be returned for
*