From patchwork Mon May 13 02:16:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13662984 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B1AFC25B4F for ; Mon, 13 May 2024 02:19:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A6EA10E100; Mon, 13 May 2024 02:19:12 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.b="TjcGT5yg"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 58F0510E100 for ; Mon, 13 May 2024 02:19:11 +0000 (UTC) Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id EA1F487D46; Mon, 13 May 2024 04:19:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1715566750; bh=yYjUoubo7oJSxL6WNhIWYEkFHtlrVGykg7J5NjBwY+o=; h=From:To:Cc:Subject:Date:From; b=TjcGT5yg+OjRLwUBppu3P0dhfikzsJ14dNgRjkBWfpnmb4iVBZ7qTbM16V63kRe3v LrbBYErNqNks+FyCZaT6k6Wp9oCbNxARAHv9Smeovz6m2mw/U2oZEQ/dLNaZZ4FLa+ Z6ttUdjGQmZvxDVFCx+aDki8XfoqaCsgsTJX1fLxMeQKCry2A4Ys53yyGlozri4j3M 6kdl/DucmcaEpwK0tfogPFtO7Ujod2cp2U94s0kmEALDnNdjOTBvsoLBLzSR7S9UtS +jAkoNiqJ8FaS8sadAc7iXXJjlW73n0EMjmyXgBqzFVnfGhp3YpWL2ovV2SxeyNguN cF0lzw/PVOvCw== From: Marek Vasut To: dri-devel@lists.freedesktop.org Cc: Marek Vasut , Adam Ford , Alexander Stein , Andrzej Hajda , Daniel Vetter , David Airlie , Frieder Schrempf , Inki Dae , Jagan Teki , Jernej Skrabec , Jonas Karlman , Laurent Pinchart , Lucas Stach , Maarten Lankhorst , Marek Szyprowski , Maxime Ripard , Michael Walle , Neil Armstrong , Robert Foss , Thomas Zimmermann , kernel@dh-electronics.com Subject: [PATCH 1/2] drm: bridge: samsung-dsim: Initialize bridge on attach Date: Mon, 13 May 2024 04:16:27 +0200 Message-ID: <20240513021849.129136-1-marex@denx.de> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Initialize the bridge on attach already, to force lanes into LP11 state, since attach does trigger attach of downstream bridges which may trigger (e)DP AUX channel mode read. This fixes a corner case where DSIM with TC9595 attached to it fails to operate the DP AUX channel, because the TC9595 enters some debug mode when it is released from reset without lanes in LP11 mode. By ensuring the DSIM lanes are in LP11, the TC9595 (tc358767.c driver) can be reset in its attach callback called from DSIM attach callback, and recovered out of the debug mode just before TC9595 performs first AUX channel access later in its attach callback. Signed-off-by: Marek Vasut Reviewed-by: Alexander Stein --- Cc: Adam Ford Cc: Alexander Stein Cc: Andrzej Hajda Cc: Daniel Vetter Cc: David Airlie Cc: Frieder Schrempf Cc: Inki Dae Cc: Jagan Teki Cc: Jernej Skrabec Cc: Jonas Karlman Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maarten Lankhorst Cc: Marek Szyprowski Cc: Maxime Ripard Cc: Michael Walle Cc: Neil Armstrong Cc: Robert Foss Cc: Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org Cc: kernel@dh-electronics.com --- drivers/gpu/drm/bridge/samsung-dsim.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index 95fedc68b0ae5..56093fc3d62cc 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1622,9 +1622,21 @@ static int samsung_dsim_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { struct samsung_dsim *dsi = bridge_to_dsi(bridge); + int ret; + + ret = pm_runtime_resume_and_get(dsi->dev); + if (ret < 0) + return ret; - return drm_bridge_attach(bridge->encoder, dsi->out_bridge, bridge, - flags); + ret = samsung_dsim_init(dsi); + if (ret < 0) + goto err; + + ret = drm_bridge_attach(bridge->encoder, dsi->out_bridge, bridge, + flags); +err: + pm_runtime_put_sync(dsi->dev); + return ret; } static const struct drm_bridge_funcs samsung_dsim_bridge_funcs = { From patchwork Mon May 13 02:16:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13662985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62D0FC25B5F for ; Mon, 13 May 2024 02:19:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 944D210E1F9; Mon, 13 May 2024 02:19:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.b="shM/gUAf"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C94510E100 for ; Mon, 13 May 2024 02:19:12 +0000 (UTC) Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 168FE88087; Mon, 13 May 2024 04:19:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1715566750; bh=5V67XcjIWoejjDIUwn6od3RXsXQX00knalwGdkENfk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=shM/gUAfPMZP8rkj/mt1WjWYeFVonS9i8iRzs1SFp0Bj1gek5MDp3Qh5gIAMKhENx OSGk34FvK+rGsUblSjfyDU7ZNUUwCsc8+Ca0uVA3HRfgPRpDmKey+cW0HGBQVFBGM9 jCfyMLGRb1yaSb5B0SRJhdC7n2RHiSkiLqdhTX3NYqZecfm9/JRrURA4EKiJiTeQ6p QnAwRLNYeSLCfnWNunenNbSeVEPUMU3oSb5DH5IxJth85z2l7F9369tSuaf4SaAgWH EwmqZoagekjXVUx6yzWzgPWLERH9W5odHSp4fy0Pi5yS+J2J7WZ45wSlpagOEqMiqE ZC7oxDFUbJ2eA== From: Marek Vasut To: dri-devel@lists.freedesktop.org Cc: Marek Vasut , Adam Ford , Alexander Stein , Andrzej Hajda , Daniel Vetter , David Airlie , Frieder Schrempf , Inki Dae , Jagan Teki , Jernej Skrabec , Jonas Karlman , Laurent Pinchart , Lucas Stach , Maarten Lankhorst , Marek Szyprowski , Maxime Ripard , Michael Walle , Neil Armstrong , Robert Foss , Thomas Zimmermann , kernel@dh-electronics.com Subject: [PATCH 2/2] drm/bridge: tc358767: Reset chip again on attach Date: Mon, 13 May 2024 04:16:28 +0200 Message-ID: <20240513021849.129136-2-marex@denx.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240513021849.129136-1-marex@denx.de> References: <20240513021849.129136-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In case the chip is released from reset using the RESX signal while the DSI lanes are in non-LP11 mode, the chip may enter some sort of debug mode, where its internal clock run at 1/6th of expected clock rate. In this mode, the AUX channel also operates at 1/6th of the 10 MHz mandated by DP specification, which breaks DPCD communication. There is no known software way of bringing the chip out of this state once the chip enters it, except for toggling the RESX signal and performing full reset. The chip may enter this mode when the chip was released from reset in probe(), because at that point the DSI lane mode is undefined. When the .attach callback is called, the DSI link is surely in LP11 mode. Toggle the RESX signal here and reconfigure the AUX channel. That way, the AUX channel communication from this point on does surely run at 10 MHz as it should. Signed-off-by: Marek Vasut Reviewed-by: Alexander Stein --- Cc: Adam Ford Cc: Alexander Stein Cc: Andrzej Hajda Cc: Daniel Vetter Cc: David Airlie Cc: Frieder Schrempf Cc: Inki Dae Cc: Jagan Teki Cc: Jernej Skrabec Cc: Jonas Karlman Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maarten Lankhorst Cc: Marek Szyprowski Cc: Maxime Ripard Cc: Michael Walle Cc: Neil Armstrong Cc: Robert Foss Cc: Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org Cc: kernel@dh-electronics.com --- drivers/gpu/drm/bridge/tc358767.c | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index fe2b93546eaef..9b01dc885973c 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -1749,10 +1749,30 @@ static const struct drm_connector_funcs tc_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; +static void tc_bridge_reset(struct tc_data *tc) +{ + if (!tc->reset_gpio) + return; + + gpiod_set_value_cansleep(tc->reset_gpio, 0); + usleep_range(10000, 11000); + gpiod_set_value_cansleep(tc->reset_gpio, 1); + usleep_range(5000, 10000); +} + static int tc_dpi_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { struct tc_data *tc = bridge_to_tc(bridge); + int ret; + + if (tc->reset_gpio) { + tc_bridge_reset(tc); + + ret = tc_set_syspllparam(tc); + if (ret) + return ret; + } if (!tc->panel_bridge) return 0; @@ -1769,6 +1789,36 @@ static int tc_edp_bridge_attach(struct drm_bridge *bridge, struct drm_device *drm = bridge->dev; int ret; + if (tc->reset_gpio) { + /* + * In case the chip is released from reset using the RESX + * signal while the DSI lanes are in non-LP11 mode, the chip + * may enter some sort of debug mode, where its internal + * clock run at 1/6th of expected clock rate. In this mode, + * the AUX channel also operates at 1/6th of the 10 MHz + * mandated by DP specification, which breaks DPCD + * communication. + * + * There is no known software way of bringing the chip out of + * this state once the chip enters it, except for toggling + * the RESX signal and performing full reset. + * + * The chip may enter this mode when the chip was released + * from reset in probe(), because at that point the DSI lane + * mode is undefined. + * + * At this point, the DSI link is surely in LP11 mode. Toggle + * the RESX signal here and reconfigure the AUX channel. That + * way, the AUX channel communication from this point on does + * surely run at 10 MHz as it should. + */ + tc_bridge_reset(tc); + + ret = tc_aux_link_setup(tc); + if (ret) + return ret; + } + if (tc->panel_bridge) { /* If a connector is required then this driver shall create it */ ret = drm_bridge_attach(tc->bridge.encoder, tc->panel_bridge,