Skip to content

Commit 7d34d56

Browse files
vireshkrafaeljw
authored andcommitted
PM / OPP: Disable OPPs that aren't supported by the regulator
Disable any OPPs where the connected regulator isn't able to provide the specified voltage. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 9f8ea96 commit 7d34d56

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/base/power/opp/core.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,22 @@ static struct dev_pm_opp *_allocate_opp(struct device *dev,
687687
return opp;
688688
}
689689

690+
static bool _opp_supported_by_regulators(struct dev_pm_opp *opp,
691+
struct device_opp *dev_opp)
692+
{
693+
struct regulator *reg = dev_opp->regulator;
694+
695+
if (!IS_ERR(reg) &&
696+
!regulator_is_supported_voltage(reg, opp->u_volt_min,
697+
opp->u_volt_max)) {
698+
pr_warn("%s: OPP minuV: %lu maxuV: %lu, not supported by regulator\n",
699+
__func__, opp->u_volt_min, opp->u_volt_max);
700+
return false;
701+
}
702+
703+
return true;
704+
}
705+
690706
static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp,
691707
struct device_opp *dev_opp)
692708
{
@@ -728,6 +744,12 @@ static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp,
728744
dev_err(dev, "%s: Failed to register opp to debugfs (%d)\n",
729745
__func__, ret);
730746

747+
if (!_opp_supported_by_regulators(new_opp, dev_opp)) {
748+
new_opp->available = false;
749+
dev_warn(dev, "%s: OPP not supported by regulators (%lu)\n",
750+
__func__, new_opp->rate);
751+
}
752+
731753
return 0;
732754
}
733755

0 commit comments

Comments
 (0)