diff mbox series

[v4,06/12] drm/vc4: hdmi: Prevent clock unbalance

Message ID 20210507150515.257424-7-maxime@cerno.tech
State Accepted
Commit 5b006000423667ef0f55721fc93e477b31f22d28
Headers show
Series [v4,01/12] drm/vc4: txp: Properly set the possible_crtcs mask | expand

Commit Message

Maxime Ripard May 7, 2021, 3:05 p.m. UTC
Since we fixed the hooks to disable the encoder at boot, we now have an
unbalanced clk_disable call at boot since we never enabled them in the
first place.

Let's mimic the state of the hardware and enable the clocks at boot if
the controller is enabled to get the use-count right.

Cc: <stable@vger.kernel.org> # v5.10+
Fixes: 09c438139b8f ("drm/vc4: hdmi: Implement finer-grained hooks")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Dave Stevenson May 21, 2021, 6:05 p.m. UTC | #1
On Fri, 7 May 2021 at 16:05, Maxime Ripard <maxime@cerno.tech> wrote:
>

> Since we fixed the hooks to disable the encoder at boot, we now have an

> unbalanced clk_disable call at boot since we never enabled them in the

> first place.

>

> Let's mimic the state of the hardware and enable the clocks at boot if

> the controller is enabled to get the use-count right.

>

> Cc: <stable@vger.kernel.org> # v5.10+

> Fixes: 09c438139b8f ("drm/vc4: hdmi: Implement finer-grained hooks")

> Signed-off-by: Maxime Ripard <maxime@cerno.tech>


Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>


> ---

>  drivers/gpu/drm/vc4/vc4_hdmi.c | 8 ++++++++

>  1 file changed, 8 insertions(+)

>

> diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c

> index 1fda574579af..9c919472ae84 100644

> --- a/drivers/gpu/drm/vc4/vc4_hdmi.c

> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c

> @@ -1995,6 +1995,14 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)

>         if (vc4_hdmi->variant->reset)

>                 vc4_hdmi->variant->reset(vc4_hdmi);

>

> +       if ((of_device_is_compatible(dev->of_node, "brcm,bcm2711-hdmi0") ||

> +            of_device_is_compatible(dev->of_node, "brcm,bcm2711-hdmi1")) &&

> +           HDMI_READ(HDMI_VID_CTL) & VC4_HD_VID_CTL_ENABLE) {

> +               clk_prepare_enable(vc4_hdmi->pixel_clock);

> +               clk_prepare_enable(vc4_hdmi->hsm_clock);

> +               clk_prepare_enable(vc4_hdmi->pixel_bvb_clock);

> +       }

> +

>         pm_runtime_enable(dev);

>

>         drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);

> --

> 2.31.1

>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 1fda574579af..9c919472ae84 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -1995,6 +1995,14 @@  static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
 	if (vc4_hdmi->variant->reset)
 		vc4_hdmi->variant->reset(vc4_hdmi);
 
+	if ((of_device_is_compatible(dev->of_node, "brcm,bcm2711-hdmi0") ||
+	     of_device_is_compatible(dev->of_node, "brcm,bcm2711-hdmi1")) &&
+	    HDMI_READ(HDMI_VID_CTL) & VC4_HD_VID_CTL_ENABLE) {
+		clk_prepare_enable(vc4_hdmi->pixel_clock);
+		clk_prepare_enable(vc4_hdmi->hsm_clock);
+		clk_prepare_enable(vc4_hdmi->pixel_bvb_clock);
+	}
+
 	pm_runtime_enable(dev);
 
 	drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);