Skip to content

Commit 3ae1f39

Browse files
Sibi Sankarvireshk
authored andcommitted
OPP: Add and export helper to set bandwidth
Add and export 'dev_pm_opp_set_bw' to set the bandwidth levels associated with an OPP. Signed-off-by: Sibi Sankar <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent fb09180 commit 3ae1f39

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

drivers/opp/core.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,37 @@ static int _set_required_opps(struct device *dev,
831831
return ret;
832832
}
833833

834+
/**
835+
* dev_pm_opp_set_bw() - sets bandwidth levels corresponding to an opp
836+
* @dev: device for which we do this operation
837+
* @opp: opp based on which the bandwidth levels are to be configured
838+
*
839+
* This configures the bandwidth to the levels specified by the OPP. However
840+
* if the OPP specified is NULL the bandwidth levels are cleared out.
841+
*
842+
* Return: 0 on success or a negative error value.
843+
*/
844+
int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp)
845+
{
846+
struct opp_table *opp_table;
847+
int ret;
848+
849+
opp_table = _find_opp_table(dev);
850+
if (IS_ERR(opp_table)) {
851+
dev_err(dev, "%s: device opp table doesn't exist\n", __func__);
852+
return PTR_ERR(opp_table);
853+
}
854+
855+
if (opp)
856+
ret = _set_opp_bw(opp_table, opp, dev, false);
857+
else
858+
ret = _set_opp_bw(opp_table, NULL, dev, true);
859+
860+
dev_pm_opp_put_opp_table(opp_table);
861+
return ret;
862+
}
863+
EXPORT_SYMBOL_GPL(dev_pm_opp_set_bw);
864+
834865
/**
835866
* dev_pm_opp_set_rate() - Configure new OPP based on frequency
836867
* @dev: device for which we do this operation

include/linux/pm_opp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names
151151
void dev_pm_opp_detach_genpd(struct opp_table *opp_table);
152152
int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate);
153153
int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
154+
int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp);
154155
int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask);
155156
int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
156157
void dev_pm_opp_remove_table(struct device *dev);
@@ -342,6 +343,11 @@ static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_f
342343
return -ENOTSUPP;
343344
}
344345

346+
static inline int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp)
347+
{
348+
return -EOPNOTSUPP;
349+
}
350+
345351
static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask)
346352
{
347353
return -ENOTSUPP;

0 commit comments

Comments
 (0)