drm/panfrost: Convert to use resource-managed OPP API
Use resource-managed OPP API to simplify code. Signed-off-by: Yangtao Li <tiny.windzz@gmail.com> Reviewed-by: Steven Price <steven.price@arm.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
@@ -89,29 +89,25 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
|
|||||||
unsigned long cur_freq;
|
unsigned long cur_freq;
|
||||||
struct device *dev = &pfdev->pdev->dev;
|
struct device *dev = &pfdev->pdev->dev;
|
||||||
struct devfreq *devfreq;
|
struct devfreq *devfreq;
|
||||||
struct opp_table *opp_table;
|
|
||||||
struct thermal_cooling_device *cooling;
|
struct thermal_cooling_device *cooling;
|
||||||
struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq;
|
struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq;
|
||||||
|
|
||||||
opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
|
ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
|
||||||
pfdev->comp->num_supplies);
|
pfdev->comp->num_supplies);
|
||||||
if (IS_ERR(opp_table)) {
|
if (ret) {
|
||||||
ret = PTR_ERR(opp_table);
|
|
||||||
/* Continue if the optional regulator is missing */
|
/* Continue if the optional regulator is missing */
|
||||||
if (ret != -ENODEV) {
|
if (ret != -ENODEV) {
|
||||||
DRM_DEV_ERROR(dev, "Couldn't set OPP regulators\n");
|
DRM_DEV_ERROR(dev, "Couldn't set OPP regulators\n");
|
||||||
goto err_fini;
|
return ret;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
pfdevfreq->regulators_opp_table = opp_table;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = dev_pm_opp_of_add_table(dev);
|
ret = devm_pm_opp_of_add_table(dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/* Optional, continue without devfreq */
|
/* Optional, continue without devfreq */
|
||||||
if (ret == -ENODEV)
|
if (ret == -ENODEV)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto err_fini;
|
return ret;
|
||||||
}
|
}
|
||||||
pfdevfreq->opp_of_table_added = true;
|
pfdevfreq->opp_of_table_added = true;
|
||||||
|
|
||||||
@@ -122,10 +118,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
|
|||||||
cur_freq = clk_get_rate(pfdev->clock);
|
cur_freq = clk_get_rate(pfdev->clock);
|
||||||
|
|
||||||
opp = devfreq_recommended_opp(dev, &cur_freq, 0);
|
opp = devfreq_recommended_opp(dev, &cur_freq, 0);
|
||||||
if (IS_ERR(opp)) {
|
if (IS_ERR(opp))
|
||||||
ret = PTR_ERR(opp);
|
return PTR_ERR(opp);
|
||||||
goto err_fini;
|
|
||||||
}
|
|
||||||
|
|
||||||
panfrost_devfreq_profile.initial_freq = cur_freq;
|
panfrost_devfreq_profile.initial_freq = cur_freq;
|
||||||
dev_pm_opp_put(opp);
|
dev_pm_opp_put(opp);
|
||||||
@@ -134,8 +128,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
|
|||||||
DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
|
DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
|
||||||
if (IS_ERR(devfreq)) {
|
if (IS_ERR(devfreq)) {
|
||||||
DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n");
|
DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n");
|
||||||
ret = PTR_ERR(devfreq);
|
return PTR_ERR(devfreq);
|
||||||
goto err_fini;
|
|
||||||
}
|
}
|
||||||
pfdevfreq->devfreq = devfreq;
|
pfdevfreq->devfreq = devfreq;
|
||||||
|
|
||||||
@@ -146,10 +139,6 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
|
|||||||
pfdevfreq->cooling = cooling;
|
pfdevfreq->cooling = cooling;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_fini:
|
|
||||||
panfrost_devfreq_fini(pfdev);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void panfrost_devfreq_fini(struct panfrost_device *pfdev)
|
void panfrost_devfreq_fini(struct panfrost_device *pfdev)
|
||||||
@@ -160,14 +149,6 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev)
|
|||||||
devfreq_cooling_unregister(pfdevfreq->cooling);
|
devfreq_cooling_unregister(pfdevfreq->cooling);
|
||||||
pfdevfreq->cooling = NULL;
|
pfdevfreq->cooling = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pfdevfreq->opp_of_table_added) {
|
|
||||||
dev_pm_opp_of_remove_table(&pfdev->pdev->dev);
|
|
||||||
pfdevfreq->opp_of_table_added = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_pm_opp_put_regulators(pfdevfreq->regulators_opp_table);
|
|
||||||
pfdevfreq->regulators_opp_table = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void panfrost_devfreq_resume(struct panfrost_device *pfdev)
|
void panfrost_devfreq_resume(struct panfrost_device *pfdev)
|
||||||
|
|||||||
@@ -8,14 +8,12 @@
|
|||||||
#include <linux/ktime.h>
|
#include <linux/ktime.h>
|
||||||
|
|
||||||
struct devfreq;
|
struct devfreq;
|
||||||
struct opp_table;
|
|
||||||
struct thermal_cooling_device;
|
struct thermal_cooling_device;
|
||||||
|
|
||||||
struct panfrost_device;
|
struct panfrost_device;
|
||||||
|
|
||||||
struct panfrost_devfreq {
|
struct panfrost_devfreq {
|
||||||
struct devfreq *devfreq;
|
struct devfreq *devfreq;
|
||||||
struct opp_table *regulators_opp_table;
|
|
||||||
struct thermal_cooling_device *cooling;
|
struct thermal_cooling_device *cooling;
|
||||||
bool opp_of_table_added;
|
bool opp_of_table_added;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user