drm/sun4i: hdmi: Fix usage of TMDS clock

This change “drm/sun4i: hdmi: Fix usage of TMDS clock” in Linux kernel is authored by Priit Laes <priit.laes [at] paf.com> on Tue Jan 22 09:32:32 2019 +0200.

drm/sun4i: hdmi: Fix usage of TMDS clock

Although TMDS clock is required for HDMI to properly function,
nobody called clk_prepare_enable(). This fixes reference counting
issues and makes sure clock is running when it needs to be running.

Due to TDMS clock being parent clock for DDC clock, TDMS clock
was turned on/off for each EDID probe, causing spurious failures
for certain HDMI/DVI screens.

Fixes: 9c5681011a0c ("drm/sun4i: Add HDMI support")
Signed-off-by: Priit Laes <priit.laes@paf.com>
[Maxime: Moved the TMDS clock enable earlier]
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190122073232.7240-1-plaes@plaes.org

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit 5e1bc25.

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
index 061d2e0..416da53 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
@@ -92,6 +92,8 @@ static void sun4i_hdmi_disable(struct drm_encoder *encoder)
 	val = readl(hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
 	writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
+	clk_disable_unprepare(hdmi->tmds_clk);
 static void sun4i_hdmi_enable(struct drm_encoder *encoder)
@@ -102,6 +104,8 @@ static void sun4i_hdmi_enable(struct drm_encoder *encoder)
 	DRM_DEBUG_DRIVER("Enabling the HDMI Outputn");
+	clk_prepare_enable(hdmi->tmds_clk);
 	sun4i_hdmi_setup_avi_infoframes(hdmi, mode);

The commit for this change in Linux stable tree is 5e1bc25 (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *