Skip to contentSkip to conversation

drm/sun4i: hdmi: Fix usage of TMDS clock

PATCH In review Priit Laes 2 participants 2 messages Jan 22, 2019

Subsystems (4)
lore
Share & tools
lore

Priit Laes

author
#0 lore raw

PATCH 1/1 drm/sun4i: hdmi: Fix usage of TMDS clock

From: Priit Laes <[email protected]>

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")
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +4 -0
index 061d2e0d9011..25f4d676fd82 100644
@@ -92,6 +92,8 @@ static void sun4i_hdmi_disable(struct drm_encoder *encoder)
 	val = readl(hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
 	val &= ~SUN4I_HDMI_VID_CTRL_ENABLE;
 	writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
+
+	clk_disable_unprepare(hdmi->tmds_clk);
 }
 
 static void sun4i_hdmi_enable(struct drm_encoder *encoder)
@@ -112,6 +114,8 @@ static void sun4i_hdmi_enable(struct drm_encoder *encoder)
 		val |= SUN4I_HDMI_VID_CTRL_HDMI_MODE;
 
 	writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
+
+	clk_prepare_enable(hdmi->tmds_clk);
 }
 
 static void sun4i_hdmi_mode_set(struct drm_encoder *encoder,
Signature · 1 line
2.11.0
#1 lore raw
Quoted 31 lines · Priit Laes

From: Priit Laes <[email protected]>

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")
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +2 -0
index 061d2e0d9011..25f4d676fd82 100644
@@ -92,6 +92,8 @@ static void sun4i_hdmi_disable(struct drm_encoder *encoder)
 	val = readl(hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
 	val &= ~SUN4I_HDMI_VID_CTRL_ENABLE;
 	writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
+
+	clk_disable_unprepare(hdmi->tmds_clk);
 }
 
 static void sun4i_hdmi_enable(struct drm_encoder *encoder)

drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c static void sun4i_hdmi_enable(struct drm_encoder *encoder) · line 118

Quoted 5 lines
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +2 -0
@@ -112,6 +114,8 @@ static void sun4i_hdmi_enable(struct drm_encoder *encoder)
 		val |= SUN4I_HDMI_VID_CTRL_HDMI_MODE;
 
 	writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
+
+	clk_prepare_enable(hdmi->tmds_clk);

We'll probably need to enable that clock to send the infoframes as well. I moved it earlier (and that allows the enable and disable function to be symetric as well).

Thanks for figuring this out!
Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com