Commit 80a9a059 authored by Chris Zhong's avatar Chris Zhong Committed by Sean Paul

drm/rockchip/dsi: add dw-mipi power domain support

Reference the power domain incase dw-mipi power down when
in use.
Signed-off-by: default avatarChris Zhong <zyw@rock-chips.com>
Reviewed-by: default avatarSean Paul <seanpaul@chromium.org>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1487577744-2855-8-git-send-email-zyw@rock-chips.com
parent ad1c974b
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/math64.h> #include <linux/math64.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
...@@ -294,6 +295,7 @@ struct dw_mipi_dsi { ...@@ -294,6 +295,7 @@ struct dw_mipi_dsi {
struct clk *pclk; struct clk *pclk;
struct clk *phy_cfg_clk; struct clk *phy_cfg_clk;
int dpms_mode;
unsigned int lane_mbps; /* per lane */ unsigned int lane_mbps; /* per lane */
u32 channel; u32 channel;
u32 lanes; u32 lanes;
...@@ -924,6 +926,9 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) ...@@ -924,6 +926,9 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder)
{ {
struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder); struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder);
if (dsi->dpms_mode != DRM_MODE_DPMS_ON)
return;
if (clk_prepare_enable(dsi->pclk)) { if (clk_prepare_enable(dsi->pclk)) {
dev_err(dsi->dev, "%s: Failed to enable pclk\n", __func__); dev_err(dsi->dev, "%s: Failed to enable pclk\n", __func__);
return; return;
...@@ -935,7 +940,9 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) ...@@ -935,7 +940,9 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder)
drm_panel_unprepare(dsi->panel); drm_panel_unprepare(dsi->panel);
dw_mipi_dsi_disable(dsi); dw_mipi_dsi_disable(dsi);
pm_runtime_put(dsi->dev);
clk_disable_unprepare(dsi->pclk); clk_disable_unprepare(dsi->pclk);
dsi->dpms_mode = DRM_MODE_DPMS_OFF;
} }
static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)
...@@ -951,11 +958,15 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) ...@@ -951,11 +958,15 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)
if (ret < 0) if (ret < 0)
return; return;
if (dsi->dpms_mode == DRM_MODE_DPMS_ON)
return;
if (clk_prepare_enable(dsi->pclk)) { if (clk_prepare_enable(dsi->pclk)) {
dev_err(dsi->dev, "%s: Failed to enable pclk\n", __func__); dev_err(dsi->dev, "%s: Failed to enable pclk\n", __func__);
return; return;
} }
pm_runtime_get_sync(dsi->dev);
dw_mipi_dsi_init(dsi); dw_mipi_dsi_init(dsi);
dw_mipi_dsi_dpi_config(dsi, mode); dw_mipi_dsi_dpi_config(dsi, mode);
dw_mipi_dsi_packet_handler_config(dsi); dw_mipi_dsi_packet_handler_config(dsi);
...@@ -991,6 +1002,7 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) ...@@ -991,6 +1002,7 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)
regmap_write(dsi->grf_regmap, pdata->grf_switch_reg, val); regmap_write(dsi->grf_regmap, pdata->grf_switch_reg, val);
dev_dbg(dsi->dev, "vop %s output to dsi0\n", (mux) ? "LIT" : "BIG"); dev_dbg(dsi->dev, "vop %s output to dsi0\n", (mux) ? "LIT" : "BIG");
dsi->dpms_mode = DRM_MODE_DPMS_ON;
} }
static int static int
...@@ -1158,6 +1170,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master, ...@@ -1158,6 +1170,7 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
dsi->dev = dev; dsi->dev = dev;
dsi->pdata = pdata; dsi->pdata = pdata;
dsi->dpms_mode = DRM_MODE_DPMS_OFF;
ret = rockchip_mipi_parse_dt(dsi); ret = rockchip_mipi_parse_dt(dsi);
if (ret) if (ret)
...@@ -1237,6 +1250,8 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master, ...@@ -1237,6 +1250,8 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
goto err_pllref; goto err_pllref;
} }
pm_runtime_enable(dev);
dsi->dsi_host.ops = &dw_mipi_dsi_host_ops; dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
dsi->dsi_host.dev = dev; dsi->dsi_host.dev = dev;
ret = mipi_dsi_host_register(&dsi->dsi_host); ret = mipi_dsi_host_register(&dsi->dsi_host);
...@@ -1269,6 +1284,7 @@ static void dw_mipi_dsi_unbind(struct device *dev, struct device *master, ...@@ -1269,6 +1284,7 @@ static void dw_mipi_dsi_unbind(struct device *dev, struct device *master,
struct dw_mipi_dsi *dsi = dev_get_drvdata(dev); struct dw_mipi_dsi *dsi = dev_get_drvdata(dev);
mipi_dsi_host_unregister(&dsi->dsi_host); mipi_dsi_host_unregister(&dsi->dsi_host);
pm_runtime_disable(dev);
clk_disable_unprepare(dsi->pllref_clk); clk_disable_unprepare(dsi->pllref_clk);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment