diff options
author | Lukasz Luba <lukasz.luba@arm.com> | 2022-03-02 11:29:14 +0000 |
---|---|---|
committer | Viresh Kumar <viresh.kumar@linaro.org> | 2022-03-03 09:35:04 +0530 |
commit | 4f9a7a1dc2a294c5c5c4b0246e2281e6ec88fb91 (patch) | |
tree | 3c2fe970b6d4b7e212283fea49857eeae816561c /drivers/opp/core.c | |
parent | 0409ab77728d705f376ae28fd7114161295e7ed2 (diff) | |
download | lwn-4f9a7a1dc2a294c5c5c4b0246e2281e6ec88fb91.tar.gz lwn-4f9a7a1dc2a294c5c5c4b0246e2281e6ec88fb91.zip |
OPP: Add "opp-microwatt" supporting code
Add new property to the OPP: power value. The OPP entry in the DT can have
"opp-microwatt". Add the needed code to handle this new property in the
existing infrastructure.
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/opp/core.c')
-rw-r--r-- | drivers/opp/core.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 3057beabd370..740407252298 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -114,6 +114,31 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) EXPORT_SYMBOL_GPL(dev_pm_opp_get_voltage); /** + * dev_pm_opp_get_power() - Gets the power corresponding to an opp + * @opp: opp for which power has to be returned for + * + * Return: power in micro watt corresponding to the opp, else + * return 0 + * + * This is useful only for devices with single power supply. + */ +unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp) +{ + unsigned long opp_power = 0; + int i; + + if (IS_ERR_OR_NULL(opp)) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + for (i = 0; i < opp->opp_table->regulator_count; i++) + opp_power += opp->supplies[i].u_watt; + + return opp_power; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_power); + +/** * dev_pm_opp_get_freq() - Gets the frequency corresponding to an available opp * @opp: opp for which frequency has to be returned for * |