Skip to content

Commit 1e23e1d

Browse files
bivvyrkhuangtao
authored andcommitted
drm/rockchip: dsi: implement runtime pm to dynamically manage the clock
Change-Id: I7ac757a04b51dded41a9c3f6697bb9390e0e2e5e Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
1 parent 3624c3c commit 1e23e1d

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

drivers/gpu/drm/rockchip/dw-mipi-dsi.c

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,11 +1123,6 @@ static void dw_mipi_dsi_post_disable(struct dw_mipi_dsi *dsi)
11231123
mipi_dphy_power_off(dsi);
11241124

11251125
pm_runtime_put(dsi->dev);
1126-
clk_disable_unprepare(dsi->pclk);
1127-
clk_disable_unprepare(dsi->h2p_clk);
1128-
clk_disable_unprepare(dsi->dphy.hs_clk);
1129-
clk_disable_unprepare(dsi->dphy.ref_clk);
1130-
clk_disable_unprepare(dsi->dphy.cfg_clk);
11311126

11321127
if (dsi->slave)
11331128
dw_mipi_dsi_post_disable(dsi->slave);
@@ -1186,11 +1181,6 @@ static void dw_mipi_dsi_pre_enable(struct dw_mipi_dsi *dsi)
11861181
{
11871182
dw_mipi_dsi_pre_init(dsi);
11881183

1189-
clk_prepare_enable(dsi->dphy.cfg_clk);
1190-
clk_prepare_enable(dsi->dphy.ref_clk);
1191-
clk_prepare_enable(dsi->dphy.hs_clk);
1192-
clk_prepare_enable(dsi->h2p_clk);
1193-
clk_prepare_enable(dsi->pclk);
11941184
pm_runtime_get_sync(dsi->dev);
11951185

11961186
/* MIPI DSI APB software reset request. */
@@ -1671,6 +1661,37 @@ static int dw_mipi_dsi_remove(struct platform_device *pdev)
16711661
return 0;
16721662
}
16731663

1664+
static int __maybe_unused dw_mipi_dsi_runtime_suspend(struct device *dev)
1665+
{
1666+
struct dw_mipi_dsi *dsi = dev_get_drvdata(dev);
1667+
1668+
clk_disable_unprepare(dsi->pclk);
1669+
clk_disable_unprepare(dsi->h2p_clk);
1670+
clk_disable_unprepare(dsi->dphy.hs_clk);
1671+
clk_disable_unprepare(dsi->dphy.ref_clk);
1672+
clk_disable_unprepare(dsi->dphy.cfg_clk);
1673+
1674+
return 0;
1675+
}
1676+
1677+
static int __maybe_unused dw_mipi_dsi_runtime_resume(struct device *dev)
1678+
{
1679+
struct dw_mipi_dsi *dsi = dev_get_drvdata(dev);
1680+
1681+
clk_prepare_enable(dsi->dphy.cfg_clk);
1682+
clk_prepare_enable(dsi->dphy.ref_clk);
1683+
clk_prepare_enable(dsi->dphy.hs_clk);
1684+
clk_prepare_enable(dsi->h2p_clk);
1685+
clk_prepare_enable(dsi->pclk);
1686+
1687+
return 0;
1688+
}
1689+
1690+
static const struct dev_pm_ops dw_mipi_dsi_pm_ops = {
1691+
SET_RUNTIME_PM_OPS(dw_mipi_dsi_runtime_suspend,
1692+
dw_mipi_dsi_runtime_resume, NULL)
1693+
};
1694+
16741695
static const u32 px30_dsi_grf_reg_fields[MAX_FIELDS] = {
16751696
[DPIUPDATECFG] = GRF_REG_FIELD(0x0434, 7, 7),
16761697
[DPICOLORM] = GRF_REG_FIELD(0x0434, 3, 3),
@@ -1814,6 +1835,7 @@ static struct platform_driver dw_mipi_dsi_driver = {
18141835
.remove = dw_mipi_dsi_remove,
18151836
.driver = {
18161837
.of_match_table = dw_mipi_dsi_dt_ids,
1838+
.pm = &dw_mipi_dsi_pm_ops,
18171839
.name = DRIVER_NAME,
18181840
},
18191841
};

0 commit comments

Comments
 (0)