From 66032146459049fdf2a2f3280b1c5f5d4ca69d91 Mon Sep 17 00:00:00 2001 From: Chris Zhong Date: Fri, 1 Jul 2016 14:39:31 +0800 Subject: [PATCH] drm/rockchip: dw-mipi: add dw-mipi power domain support Reference the power domain incase dw-mipi power down when in use. Change-Id: I54a0f418f20299a744f87c1337f06ff3341dfac5 Signed-off-by: Chris Zhong --- drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index 7ae5d16bda15..aff222556345 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -293,6 +294,7 @@ struct dw_mipi_dsi { struct clk *pclk; struct clk *phy_cfg_clk; + int dpms_mode; unsigned int lane_mbps; /* per lane */ u32 channel; u32 lanes; @@ -849,6 +851,9 @@ static void dw_mipi_dsi_encoder_mode_set(struct drm_encoder *encoder, struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder); int ret; + if (dsi->dpms_mode == DRM_MODE_DPMS_ON) + return; + dsi->mode = adjusted_mode; ret = dw_mipi_dsi_get_lane_bps(dsi); @@ -860,6 +865,8 @@ static void dw_mipi_dsi_encoder_mode_set(struct drm_encoder *encoder, return; } + pm_runtime_get_sync(dsi->dev); + dw_mipi_dsi_init(dsi); dw_mipi_dsi_dpi_config(dsi, mode); dw_mipi_dsi_packet_handler_config(dsi); @@ -881,6 +888,9 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) { struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder); + if (dsi->dpms_mode != DRM_MODE_DPMS_ON) + return; + drm_panel_disable(dsi->panel); if (clk_prepare_enable(dsi->pclk)) { @@ -900,7 +910,9 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) dw_mipi_dsi_set_mode(dsi, DW_MIPI_DSI_CMD_MODE); dw_mipi_dsi_disable(dsi); + pm_runtime_put(dsi->dev); clk_disable_unprepare(dsi->pclk); + dsi->dpms_mode = DRM_MODE_DPMS_OFF; } static bool dw_mipi_dsi_encoder_mode_fixup(struct drm_encoder *encoder, @@ -941,6 +953,7 @@ static void dw_mipi_dsi_encoder_commit(struct drm_encoder *encoder) regmap_write(dsi->grf_regmap, pdata->grf_switch_reg, val); dev_dbg(dsi->dev, "vop %s output to dsi0\n", (mux) ? "LIT" : "BIG"); + dsi->dpms_mode = DRM_MODE_DPMS_ON; } static int @@ -1163,6 +1176,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master, dsi->dev = dev; dsi->pdata = pdata; + dsi->dpms_mode = DRM_MODE_DPMS_OFF; ret = rockchip_mipi_parse_dt(dsi); if (ret) @@ -1208,6 +1222,8 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master, dev_set_drvdata(dev, dsi); + pm_runtime_enable(dev); + dsi->dsi_host.ops = &dw_mipi_dsi_host_ops; dsi->dsi_host.dev = dev; return mipi_dsi_host_register(&dsi->dsi_host); @@ -1223,6 +1239,7 @@ static void dw_mipi_dsi_unbind(struct device *dev, struct device *master, struct dw_mipi_dsi *dsi = dev_get_drvdata(dev); mipi_dsi_host_unregister(&dsi->dsi_host); + pm_runtime_disable(dev); clk_disable_unprepare(dsi->pllref_clk); } -- 2.34.1