Skip to content

Commit b0530eb

Browse files
Rajendra Nayakrobclark
authored andcommitted
drm/msm/dpu: Use OPP API to set clk/perf state
On some qualcomm platforms DPU needs to express a performance state requirement on a power domain depending on the clock rates. Use OPP table from DT to register with OPP framework and use dev_pm_opp_set_rate() to set the clk/perf state. Signed-off-by: Rajendra Nayak <[email protected]> Reviewed-by: Rob Clark <[email protected]> Reviewed-by: Matthias Kaehlcke <[email protected]> Signed-off-by: Rob Clark <[email protected]>
1 parent 5e16372 commit b0530eb

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/debugfs.h>
88
#include <linux/errno.h>
99
#include <linux/mutex.h>
10+
#include <linux/pm_opp.h>
1011
#include <linux/sort.h>
1112
#include <linux/clk.h>
1213
#include <linux/bitmap.h>
@@ -218,7 +219,7 @@ static int _dpu_core_perf_set_core_clk_rate(struct dpu_kms *kms, u64 rate)
218219
rate = core_clk->max_rate;
219220

220221
core_clk->rate = rate;
221-
return msm_dss_clk_set_rate(core_clk, 1);
222+
return dev_pm_opp_set_rate(&kms->pdev->dev, core_clk->rate);
222223
}
223224

224225
static u64 _dpu_core_perf_get_core_clk_rate(struct dpu_kms *kms)

drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/debugfs.h>
1111
#include <linux/dma-buf.h>
1212
#include <linux/of_irq.h>
13+
#include <linux/pm_opp.h>
1314

1415
#include <drm/drm_crtc.h>
1516
#include <drm/drm_file.h>
@@ -1025,11 +1026,24 @@ static int dpu_bind(struct device *dev, struct device *master, void *data)
10251026
if (!dpu_kms)
10261027
return -ENOMEM;
10271028

1029+
dpu_kms->opp_table = dev_pm_opp_set_clkname(dev, "core");
1030+
if (IS_ERR(dpu_kms->opp_table))
1031+
return PTR_ERR(dpu_kms->opp_table);
1032+
/* OPP table is optional */
1033+
ret = dev_pm_opp_of_add_table(dev);
1034+
if (!ret) {
1035+
dpu_kms->has_opp_table = true;
1036+
} else if (ret != -ENODEV) {
1037+
dev_err(dev, "invalid OPP table in device tree\n");
1038+
dev_pm_opp_put_clkname(dpu_kms->opp_table);
1039+
return ret;
1040+
}
1041+
10281042
mp = &dpu_kms->mp;
10291043
ret = msm_dss_parse_clock(pdev, mp);
10301044
if (ret) {
10311045
DPU_ERROR("failed to parse clocks, ret=%d\n", ret);
1032-
return ret;
1046+
goto err;
10331047
}
10341048

10351049
platform_set_drvdata(pdev, dpu_kms);
@@ -1043,6 +1057,11 @@ static int dpu_bind(struct device *dev, struct device *master, void *data)
10431057

10441058
priv->kms = &dpu_kms->base;
10451059
return ret;
1060+
err:
1061+
if (dpu_kms->has_opp_table)
1062+
dev_pm_opp_of_remove_table(dev);
1063+
dev_pm_opp_put_clkname(dpu_kms->opp_table);
1064+
return ret;
10461065
}
10471066

10481067
static void dpu_unbind(struct device *dev, struct device *master, void *data)
@@ -1057,6 +1076,10 @@ static void dpu_unbind(struct device *dev, struct device *master, void *data)
10571076

10581077
if (dpu_kms->rpm_enabled)
10591078
pm_runtime_disable(&pdev->dev);
1079+
1080+
if (dpu_kms->has_opp_table)
1081+
dev_pm_opp_of_remove_table(dev);
1082+
dev_pm_opp_put_clkname(dpu_kms->opp_table);
10601083
}
10611084

10621085
static const struct component_ops dpu_ops = {
@@ -1082,6 +1105,8 @@ static int __maybe_unused dpu_runtime_suspend(struct device *dev)
10821105
struct dpu_kms *dpu_kms = platform_get_drvdata(pdev);
10831106
struct dss_module_power *mp = &dpu_kms->mp;
10841107

1108+
/* Drop the performance state vote */
1109+
dev_pm_opp_set_rate(dev, 0);
10851110
rc = msm_dss_enable_clk(mp->clk_config, mp->num_clk, false);
10861111
if (rc)
10871112
DPU_ERROR("clock disable failed rc:%d\n", rc);

drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ struct dpu_kms {
128128

129129
struct platform_device *pdev;
130130
bool rpm_enabled;
131+
132+
struct opp_table *opp_table;
133+
bool has_opp_table;
134+
131135
struct dss_module_power mp;
132136

133137
/* reference count bandwidth requests, so we know when we can

0 commit comments

Comments
 (0)