dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime@cerno.tech>
To: Daniel Vetter <daniel.vetter@intel.com>,
	David Airlie <airlied@linux.ie>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Maxime Ripard <maxime@cerno.tech>
Cc: dri-devel@lists.freedesktop.org,
	Dave Stevenson <dave.stevenson@raspberrypi.com>
Subject: [PATCH 23/33] drm/vc4: hdmi: Move HDMI reset to pm_resume
Date: Mon, 13 Jun 2022 16:47:50 +0200	[thread overview]
Message-ID: <20220613144800.326124-24-maxime@cerno.tech> (raw)
In-Reply-To: <20220613144800.326124-1-maxime@cerno.tech>

From: Dave Stevenson <dave.stevenson@raspberrypi.com>

The BCM2835-37 found in the RaspberryPi 0 to 3 have a power domain
attached to the HDMI block, handled in Linux through runtime_pm.

That power domain is shared with the VEC block, so even if we put our
runtime_pm reference in the HDMI driver it would keep being on. If the
VEC is disabled though, the power domain would be disabled and we would
lose any initialization done in our bind implementation.

That initialization involves calling the reset function and initializing
the CEC registers.

Let's move the initialization to our runtime_resume implementation so
that we initialize everything properly if we ever need to.

Fixes: c86b41214362 ("drm/vc4: hdmi: Move the HSM clock enable to runtime_pm")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 41 ++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 8142efa2d479..654c4116b669 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -2543,8 +2543,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
 	struct cec_connector_info conn_info;
 	struct platform_device *pdev = vc4_hdmi->pdev;
 	struct device *dev = &pdev->dev;
-	unsigned long flags;
-	u32 value;
 	int ret;
 
 	if (!of_find_property(dev->of_node, "interrupts", NULL)) {
@@ -2563,15 +2561,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
 	cec_fill_conn_info_from_drm(&conn_info, &vc4_hdmi->connector);
 	cec_s_conn_info(vc4_hdmi->cec_adap, &conn_info);
 
-	spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
-	value = HDMI_READ(HDMI_CEC_CNTRL_1);
-	/* Set the logical address to Unregistered */
-	value |= VC4_HDMI_CEC_ADDR_MASK;
-	HDMI_WRITE(HDMI_CEC_CNTRL_1, value);
-	spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
-
-	vc4_hdmi_cec_update_clk_div(vc4_hdmi);
-
 	if (vc4_hdmi->variant->external_irq_controller) {
 		ret = request_threaded_irq(platform_get_irq_byname(pdev, "cec-rx"),
 					   vc4_cec_irq_handler_rx_bare,
@@ -2587,10 +2576,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
 		if (ret)
 			goto err_remove_cec_rx_handler;
 	} else {
-		spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
-		HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, 0xffffffff);
-		spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
-
 		ret = request_threaded_irq(platform_get_irq(pdev, 0),
 					   vc4_cec_irq_handler,
 					   vc4_cec_irq_handler_thread, 0,
@@ -2641,7 +2626,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
 }
 
 static void vc4_hdmi_cec_exit(struct vc4_hdmi *vc4_hdmi) {};
-
 #endif
 
 static int vc4_hdmi_build_regset(struct vc4_hdmi *vc4_hdmi,
@@ -2870,12 +2854,34 @@ static int __maybe_unused vc4_hdmi_runtime_suspend(struct device *dev)
 static int vc4_hdmi_runtime_resume(struct device *dev)
 {
 	struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev);
+	unsigned long __maybe_unused flags;
+	u32 __maybe_unused value;
 	int ret;
 
 	ret = clk_prepare_enable(vc4_hdmi->hsm_clock);
 	if (ret)
 		return ret;
 
+	if (vc4_hdmi->variant->reset)
+		vc4_hdmi->variant->reset(vc4_hdmi);
+
+#ifdef CONFIG_DRM_VC4_HDMI_CEC
+	spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
+	value = HDMI_READ(HDMI_CEC_CNTRL_1);
+	/* Set the logical address to Unregistered */
+	value |= VC4_HDMI_CEC_ADDR_MASK;
+	HDMI_WRITE(HDMI_CEC_CNTRL_1, value);
+	spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
+
+	vc4_hdmi_cec_update_clk_div(vc4_hdmi);
+
+	if (!vc4_hdmi->variant->external_irq_controller) {
+		spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
+		HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, 0xffffffff);
+		spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
+	}
+#endif
+
 	return 0;
 }
 
@@ -2965,9 +2971,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
 	pm_runtime_set_active(dev);
 	pm_runtime_enable(dev);
 
-	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) {
-- 
2.36.1


  parent reply	other threads:[~2022-06-13 14:49 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13 14:47 [PATCH 00/33] drm/vc4: Misc fixes Maxime Ripard
2022-06-13 14:47 ` [PATCH 01/33] drm/vc4: drv: Adopt the dma configuration from the HVS or V3D component Maxime Ripard
2022-06-13 14:47 ` [PATCH 02/33] drm/vc4: kms: Warn if clk_set_min_rate fails Maxime Ripard
2022-06-28 11:28   ` Dave Stevenson
2022-06-13 14:47 ` [PATCH 03/33] drm/vc4: kms: Use maximum FIFO load for the HVS clock rate Maxime Ripard
2022-06-28 11:30   ` Dave Stevenson
2022-06-13 14:47 ` [PATCH 04/33] drm/vc4: plane: Remove subpixel positioning check Maxime Ripard
2022-06-13 14:47 ` [PATCH 05/33] drm/vc4: plane: Fix margin calculations for the right/bottom edges Maxime Ripard
2022-06-13 14:47 ` [PATCH 06/33] drm/vc4: plane: Add alpha_blend_mode property to each plane Maxime Ripard
2022-06-13 14:47 ` [PATCH 07/33] drm/vc4: hvs: Add debugfs node that dumps the current display lists Maxime Ripard
2022-06-13 14:47 ` [PATCH 08/33] drm/vc4: dpi: Add support for composite syncs to vc4_dpi Maxime Ripard
2022-06-13 14:47 ` [PATCH 09/33] drm/vc4: dpi: Add option for inverting pixel clock and output enable Maxime Ripard
2022-06-13 14:47 ` [PATCH 10/33] drm/vc4: dpi: Ensure a default format is selected Maxime Ripard
2022-06-13 14:47 ` [PATCH 11/33] drm/vc4: dsi: Release workaround buffer and DMA Maxime Ripard
2022-06-13 14:47 ` [PATCH 12/33] drm/vc4: dsi: Correct DSI divider calculations Maxime Ripard
2022-06-13 14:47 ` [PATCH 13/33] drm/vc4: dsi: Correct pixel order for DSI0 Maxime Ripard
2022-06-13 14:47 ` [PATCH 14/33] drm/vc4: dsi: Register dsi0 as the correct vc4 encoder type Maxime Ripard
2022-06-13 14:47 ` [PATCH 15/33] drm/vc4: dsi: Fix dsi0 interrupt support Maxime Ripard
2022-06-13 14:47 ` [PATCH 16/33] drm/vc4: dsi: Add correct stop condition to vc4_dsi_encoder_disable iteration Maxime Ripard
2022-06-13 14:47 ` [PATCH 17/33] drm/vc4: hdmi: Disable audio if dmas property is present but empty Maxime Ripard
2022-06-13 14:47 ` [PATCH 18/33] drm/vc4: hdmi: Add all the vc5 HDMI registers into the debugfs dumps Maxime Ripard
2022-06-13 14:47 ` [PATCH 19/33] drm/vc4: hdmi: Clear unused infoframe packet RAM registers Maxime Ripard
2022-06-13 14:47 ` [PATCH 20/33] drm/vc4: hdmi: Avoid full hdmi audio fifo writes Maxime Ripard
2022-06-13 14:47 ` [PATCH 21/33] drm/vc4: hdmi: Reset HDMI MISC_CONTROL register Maxime Ripard
2022-06-13 14:47 ` [PATCH 22/33] drm/vc4: hdmi: Switch to pm_runtime_status_suspended Maxime Ripard
2022-06-13 14:47 ` Maxime Ripard [this message]
2022-08-04 23:11   ` [PATCH 23/33] drm/vc4: hdmi: Move HDMI reset to pm_resume Florian Fainelli
2022-08-09 19:02     ` Florian Fainelli
2022-08-10 11:06       ` Dave Stevenson
2022-08-10 20:33       ` Stefan Wahren
2022-08-15 14:12         ` Maxime Ripard
2022-08-15 16:52           ` Florian Fainelli
2022-08-18 15:38             ` Maxime Ripard
2022-08-09 20:16     ` Stefan Wahren
2022-08-09 20:28       ` Florian Fainelli
2022-06-13 14:47 ` [PATCH 24/33] drm/vc4: hdmi: Stop checking for enabled output in audio Maxime Ripard
2022-06-13 14:47 ` [PATCH 25/33] drm/vc4: hdmi: Skip writes to disabled packet RAM Maxime Ripard
2022-06-13 14:47 ` [PATCH 26/33] drm/vc4: hdmi: Remove VC4_HDMI_SCHEDULER_CONTROL_VERT_ALWAYS_KEEPOUT Maxime Ripard
2022-06-13 14:47 ` [PATCH 27/33] drm/vc4: hdmi: Add HDMI format detection registers to register list Maxime Ripard
2022-06-13 14:47 ` [PATCH 28/33] drm/vc4: hdmi: Add MISC_CONTROL register for vc4 Maxime Ripard
2022-06-13 14:47 ` [PATCH 29/33] drm/vc4: hdmi: Report that 3d/stereo is allowed Maxime Ripard
2022-06-13 14:47 ` [PATCH 30/33] drm/vc4: hdmi: Fix timings for interlaced modes Maxime Ripard
2022-06-13 14:47 ` [PATCH 31/33] drm/vc4: hdmi: Force modeset when bpc or format changes Maxime Ripard
2022-06-13 14:47 ` [PATCH 32/33] drm/vc4: hdmi: Correct HDMI timing registers for interlaced modes Maxime Ripard
2022-06-13 14:48 ` [PATCH 33/33] drm/vc4: hdmi: Move pixel doubling from Pixelvalve to HDMI block Maxime Ripard
2022-06-28 13:34 ` [PATCH 00/33] drm/vc4: Misc fixes Maxime Ripard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220613144800.326124-24-maxime@cerno.tech \
    --to=maxime@cerno.tech \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@intel.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).