Skip to content

Commit 5f756d0

Browse files
Mani-Sadhasivamvireshk
authored andcommitted
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 <[email protected]> [ Viresh: Fixed potential access to NULL opp pointer ] Signed-off-by: Viresh Kumar <[email protected]>
1 parent 142e17c commit 5f756d0

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

drivers/opp/core.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,26 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
197197
}
198198
EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq);
199199

200+
/**
201+
* dev_pm_opp_get_freq_indexed() - Gets the frequency corresponding to an
202+
* available opp with specified index
203+
* @opp: opp for which frequency has to be returned for
204+
* @index: index of the frequency within the required opp
205+
*
206+
* Return: frequency in hertz corresponding to the opp with specified index,
207+
* else return 0
208+
*/
209+
unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index)
210+
{
211+
if (IS_ERR_OR_NULL(opp) || index >= opp->opp_table->clk_count) {
212+
pr_err("%s: Invalid parameters\n", __func__);
213+
return 0;
214+
}
215+
216+
return opp->rates[index];
217+
}
218+
EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq_indexed);
219+
200220
/**
201221
* dev_pm_opp_get_level() - Gets the level corresponding to an available opp
202222
* @opp: opp for which level value has to be returned for

include/linux/pm_opp.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp);
105105

106106
unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
107107

108+
unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index);
109+
108110
unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp);
109111

110112
unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp,
@@ -213,6 +215,11 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
213215
return 0;
214216
}
215217

218+
static inline unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index)
219+
{
220+
return 0;
221+
}
222+
216223
static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp)
217224
{
218225
return 0;

0 commit comments

Comments
 (0)