Skip to content

Commit b89c0ed

Browse files
superna9999vireshk
authored andcommitted
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 <[email protected]> [ Viresh: Fixed commit log and a comment in code ] Signed-off-by: Viresh Kumar <[email protected]>
1 parent 40384c8 commit b89c0ed

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

drivers/opp/core.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,31 @@ static bool assert_single_clk(struct opp_table *opp_table)
106106
return !WARN_ON(opp_table->clk_count > 1);
107107
}
108108

109+
/**
110+
* dev_pm_opp_get_bw() - Gets the bandwidth corresponding to an opp
111+
* @opp: opp for which bandwidth has to be returned for
112+
* @peak: select peak or average bandwidth
113+
* @index: bandwidth index
114+
*
115+
* Return: bandwidth in kBps, else return 0
116+
*/
117+
unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, bool peak, int index)
118+
{
119+
if (IS_ERR_OR_NULL(opp)) {
120+
pr_err("%s: Invalid parameters\n", __func__);
121+
return 0;
122+
}
123+
124+
if (index > opp->opp_table->path_count)
125+
return 0;
126+
127+
if (!opp->bandwidth)
128+
return 0;
129+
130+
return peak ? opp->bandwidth[index].peak : opp->bandwidth[index].avg;
131+
}
132+
EXPORT_SYMBOL_GPL(dev_pm_opp_get_bw);
133+
109134
/**
110135
* dev_pm_opp_get_voltage() - Gets the voltage corresponding to an opp
111136
* @opp: opp for which voltage has to be returned for

include/linux/pm_opp.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ struct dev_pm_opp_data {
102102
struct opp_table *dev_pm_opp_get_opp_table(struct device *dev);
103103
void dev_pm_opp_put_opp_table(struct opp_table *opp_table);
104104

105+
unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, bool peak, int index);
106+
105107
unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
106108

107109
int dev_pm_opp_get_supplies(struct dev_pm_opp *opp, struct dev_pm_opp_supply *supplies);
@@ -205,6 +207,11 @@ static inline struct opp_table *dev_pm_opp_get_opp_table_indexed(struct device *
205207

206208
static inline void dev_pm_opp_put_opp_table(struct opp_table *opp_table) {}
207209

210+
static inline unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, bool peak, int index)
211+
{
212+
return 0;
213+
}
214+
208215
static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
209216
{
210217
return 0;

0 commit comments

Comments
 (0)