From 120ffd6bbd1a359bcbb9e092599d208782ed4dd4 Mon Sep 17 00:00:00 2001 From: Liu Ying <victor.liu@nxp.com> Date: Fri, 23 Apr 2021 17:26:43 +0800 Subject: [PATCH] MLK-25574-4 drm/bridge: nwl-dsi: Get MIPI DSI controller and PHY ready in ->mode_set() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some MIPI DSI panel drivers like 'raydium,rm68200' send MIPI_DCS_SET_DISPLAY_ON commands in panel_funcs->prepare(), which requires the MIPI DSI controller and PHY to be ready beforehand. Without this patch, the nwl-dsi driver gets the MIPI DSI controller and PHY ready in bridge_funcs->atomic_pre_enable(), which happens after the panel_funcs->prepare(). So, this patch shifts the bridge operation ealier from bridge_funcs->atomic_pre_enable() to bridge_funcs->mode_set(). This way, more MIPI DSI panels can connect to this nwl-dsi bridge. Cc: Andrzej Hajda <a.hajda@samsung.com> Cc: Neil Armstrong <narmstrong@baylibre.com> Cc: Robert Foss <robert.foss@linaro.org> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com> Cc: Jonas Karlman <jonas@kwiboo.se> Cc: Jernej Skrabec <jernej.skrabec@siol.net> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Guido Günther <agx@sigxcpu.org> Cc: Robert Chiras <robert.chiras@nxp.com> Cc: NXP Linux Team <linux-imx@nxp.com> Signed-off-by: Liu Ying <victor.liu@nxp.com> Reviewed-by: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Link: https://patchwork.freedesktop.org/patch/msgid/1619170003-4817-4-git-send-email-victor.liu@nxp.com Reviewed-by: Sandor Yu <Sandor.yu@nxp.com> --- drivers/gpu/drm/bridge/nwl-dsi.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c index 198f184d67b6a1..755a6f3d11e3c7 100644 --- a/drivers/gpu/drm/bridge/nwl-dsi.c +++ b/drivers/gpu/drm/bridge/nwl-dsi.c @@ -761,7 +761,7 @@ static irqreturn_t nwl_dsi_irq_handler(int irq, void *data) return IRQ_HANDLED; } -static int nwl_dsi_enable(struct nwl_dsi *dsi) +static int nwl_dsi_mode_set(struct nwl_dsi *dsi) { struct device *dev = dsi->dev; union phy_configure_opts *phy_cfg = &dsi->phy_cfg; @@ -1197,7 +1197,12 @@ static int nwl_dsi_bridge_atomic_check(struct drm_bridge *bridge, adjusted->flags |= (DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC); } - /* Do a full modeset if crtc_state->active is changed to be true. */ + /* + * Do a full modeset if crtc_state->active is changed to be true. + * This ensures our ->mode_set() is called to get the DSI controller + * and the PHY ready to send DCS commands, when only the connector's + * DPMS is brought out of "Off" status. + */ if (crtc_state->active_changed && crtc_state->active) crtc_state->mode_changed = true; @@ -1250,16 +1255,8 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge, /* Save the new desired phy config */ memcpy(&dsi->phy_cfg, &new_cfg, sizeof(new_cfg)); -} -static void -nwl_dsi_bridge_atomic_pre_enable(struct drm_bridge *bridge, - struct drm_bridge_state *old_bridge_state) -{ - struct nwl_dsi *dsi = bridge_to_dsi(bridge); - int ret; - - pm_runtime_get_sync(dsi->dev); + pm_runtime_get_sync(dev); dsi->pdata->dpi_reset(dsi, true); dsi->pdata->mipi_reset(dsi, true); @@ -1277,19 +1274,26 @@ nwl_dsi_bridge_atomic_pre_enable(struct drm_bridge *bridge, /* Step 1 from DSI reset-out instructions */ ret = dsi->pdata->pclk_reset(dsi, false); if (ret < 0) { - DRM_DEV_ERROR(dsi->dev, "Failed to deassert PCLK: %d\n", ret); + DRM_DEV_ERROR(dev, "Failed to deassert PCLK: %d\n", ret); return; } /* Step 2 from DSI reset-out instructions */ - nwl_dsi_enable(dsi); + nwl_dsi_mode_set(dsi); /* Step 3 from DSI reset-out instructions */ ret = dsi->pdata->mipi_reset(dsi, false); if (ret < 0) { - DRM_DEV_ERROR(dsi->dev, "Failed to deassert DSI: %d\n", ret); + DRM_DEV_ERROR(dev, "Failed to deassert DSI: %d\n", ret); return; } +} + +static void +nwl_dsi_bridge_atomic_pre_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) +{ + struct nwl_dsi *dsi = bridge_to_dsi(bridge); /* * We need to force call enable for the panel here, in order to -- GitLab