linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] drm: rcar-du: DSI fixes
@ 2022-08-22 13:05 Tomi Valkeinen
  2022-08-22 13:05 ` [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX Tomi Valkeinen
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Tomi Valkeinen @ 2022-08-22 13:05 UTC (permalink / raw)
  To: Laurent Pinchart, Kieran Bingham, dri-devel, linux-renesas-soc
  Cc: Tomi Valkeinen

Hi,

This is v2 of the third patch in an earlier series ("drm: rcar-du: fix
DSI enable & disable sequence"). The first two patches have already been
accepted.

Changes in v2:
- Split the patch into smaller pieces
- Modify the pclk enable function names so that they match between LVDS
  and DSI.
- Cosmetic changes (comments).

 Tomi

Tomi Valkeinen (4):
  drm: rcar-du: dsi: Properly stop video mode TX
  drm: rcar-du: dsi: Improve DSI shutdown
  drm: rcar-du: fix DSI enable & disable sequence
  drm: rcar-du: lvds: Rename pclk enable/disable functions

 drivers/gpu/drm/rcar-du/rcar_du_crtc.c    | 30 ++++++++++-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h     |  2 +
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c |  4 ++
 drivers/gpu/drm/rcar-du/rcar_lvds.c       |  4 +-
 drivers/gpu/drm/rcar-du/rcar_lvds.h       | 10 ++--
 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c   | 64 +++++++++++++++++++++--
 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h   | 31 +++++++++++
 7 files changed, 131 insertions(+), 14 deletions(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h

-- 
2.34.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX
  2022-08-22 13:05 [PATCH v2 0/4] drm: rcar-du: DSI fixes Tomi Valkeinen
@ 2022-08-22 13:05 ` Tomi Valkeinen
  2022-08-22 13:12   ` Laurent Pinchart
  2022-08-22 13:25   ` Biju Das
  2022-08-22 13:05 ` [PATCH v2 2/4] drm: rcar-du: dsi: Improve DSI shutdown Tomi Valkeinen
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 20+ messages in thread
From: Tomi Valkeinen @ 2022-08-22 13:05 UTC (permalink / raw)
  To: Laurent Pinchart, Kieran Bingham, dri-devel, linux-renesas-soc
  Cc: Tomi Valkeinen

From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>

The driver does not explicitly stop the video mode transmission when
disabling the output. While this doesn't seem to be causing any issues,
lets follow the steps described in the documentation and add a
rcar_mipi_dsi_stop_video() which stop the video mode transmission. This
function will also be used in later patches to stop the video
transmission even if the DSI IP is not shut down.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 29 +++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
index 62f7eb84ab01..7f2be490fcf8 100644
--- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
+++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
@@ -542,6 +542,34 @@ static int rcar_mipi_dsi_start_video(struct rcar_mipi_dsi *dsi)
 	return 0;
 }
 
+static void rcar_mipi_dsi_stop_video(struct rcar_mipi_dsi *dsi)
+{
+	u32 status;
+	int ret;
+
+	/* Disable transmission in video mode. */
+	rcar_mipi_dsi_clr(dsi, TXVMCR, TXVMCR_EN_VIDEO);
+
+	ret = read_poll_timeout(rcar_mipi_dsi_read, status,
+				!(status & TXVMSR_ACT),
+				2000, 100000, false, dsi, TXVMSR);
+	if (ret < 0) {
+		dev_err(dsi->dev, "Failed to disable video transmission\n");
+		return;
+	}
+
+	/* Assert video FIFO clear. */
+	rcar_mipi_dsi_set(dsi, TXVMCR, TXVMCR_VFCLR);
+
+	ret = read_poll_timeout(rcar_mipi_dsi_read, status,
+				!(status & TXVMSR_VFRDY),
+				2000, 100000, false, dsi, TXVMSR);
+	if (ret < 0) {
+		dev_err(dsi->dev, "Failed to assert video FIFO clear\n");
+		return;
+	}
+}
+
 /* -----------------------------------------------------------------------------
  * Bridge
  */
@@ -601,6 +629,7 @@ static void rcar_mipi_dsi_atomic_disable(struct drm_bridge *bridge,
 {
 	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
 
+	rcar_mipi_dsi_stop_video(dsi);
 	rcar_mipi_dsi_shutdown(dsi);
 	rcar_mipi_dsi_clk_disable(dsi);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 2/4] drm: rcar-du: dsi: Improve DSI shutdown
  2022-08-22 13:05 [PATCH v2 0/4] drm: rcar-du: DSI fixes Tomi Valkeinen
  2022-08-22 13:05 ` [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX Tomi Valkeinen
@ 2022-08-22 13:05 ` Tomi Valkeinen
  2022-08-22 13:20   ` Laurent Pinchart
  2022-08-22 13:05 ` [PATCH v2 3/4] drm: rcar-du: fix DSI enable & disable sequence Tomi Valkeinen
  2022-08-22 13:05 ` [PATCH v2 4/4] drm: rcar-du: lvds: Rename pclk enable/disable functions Tomi Valkeinen
  3 siblings, 1 reply; 20+ messages in thread
From: Tomi Valkeinen @ 2022-08-22 13:05 UTC (permalink / raw)
  To: Laurent Pinchart, Kieran Bingham, dri-devel, linux-renesas-soc
  Cc: Tomi Valkeinen

From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>

Improve the DSI shutdown procedure by clearing various bits that were
set while enabling the DSI output. There has been no clear issues caused
by these, but it's safer to ensure that the features are disabled at the
start of the next DSI enable.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
index 7f2be490fcf8..6a10a35f1122 100644
--- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
+++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
@@ -441,9 +441,21 @@ static int rcar_mipi_dsi_startup(struct rcar_mipi_dsi *dsi,
 
 static void rcar_mipi_dsi_shutdown(struct rcar_mipi_dsi *dsi)
 {
+	/* Disable VCLKEN */
+	rcar_mipi_dsi_clr(dsi, VCLKEN, VCLKEN_CKEN);
+
+	/* Disable DOT clock */
+	rcar_mipi_dsi_clr(dsi, VCLKSET, VCLKSET_CKEN);
+
 	rcar_mipi_dsi_clr(dsi, PHYSETUP, PHYSETUP_RSTZ);
 	rcar_mipi_dsi_clr(dsi, PHYSETUP, PHYSETUP_SHUTDOWNZ);
 
+	/* CFGCLK disable */
+	rcar_mipi_dsi_clr(dsi, CFGCLKSET, CFGCLKSET_CKEN);
+
+	/* LPCLK disable */
+	rcar_mipi_dsi_clr(dsi, LPCLKSET, LPCLKSET_CKEN);
+
 	dev_dbg(dsi->dev, "DSI device is shutdown\n");
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 3/4] drm: rcar-du: fix DSI enable & disable sequence
  2022-08-22 13:05 [PATCH v2 0/4] drm: rcar-du: DSI fixes Tomi Valkeinen
  2022-08-22 13:05 ` [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX Tomi Valkeinen
  2022-08-22 13:05 ` [PATCH v2 2/4] drm: rcar-du: dsi: Improve DSI shutdown Tomi Valkeinen
@ 2022-08-22 13:05 ` Tomi Valkeinen
  2022-08-22 13:40   ` Laurent Pinchart
                     ` (2 more replies)
  2022-08-22 13:05 ` [PATCH v2 4/4] drm: rcar-du: lvds: Rename pclk enable/disable functions Tomi Valkeinen
  3 siblings, 3 replies; 20+ messages in thread
From: Tomi Valkeinen @ 2022-08-22 13:05 UTC (permalink / raw)
  To: Laurent Pinchart, Kieran Bingham, dri-devel, linux-renesas-soc
  Cc: Tomi Valkeinen

From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>

The rcar crtc depends on the clock provided from the rcar DSI bridge.
When the DSI bridge is disabled, the clock is stopped, which causes the
crtc disable to timeout.

Also, while I have no issue with the enable, the documentation suggests
to enable the DSI before the crtc so that the crtc has its clock enabled
at enable time. This is also not done by the current driver.

To fix this, we need to keep the DSI bridge enabled until the crtc has
disabled itself, and enable the DSI bridge before crtc enables itself.

Add functions (rcar_mipi_dsi_atomic_early_enable and
rcar_mipi_dsi_atomic_late_disable) to the rcar DSI bridge driver which
the rcar driver can use to enable/disable the DSI clock when needed.
This is similar to what is already done with the rcar LVDS bridge.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c    | 26 +++++++++++++++++++
 drivers/gpu/drm/rcar-du/rcar_du_drv.h     |  2 ++
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c |  4 +++
 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c   | 25 +++++++++++++-----
 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h   | 31 +++++++++++++++++++++++
 5 files changed, 82 insertions(+), 6 deletions(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index fd3b94649a01..31e33270e6db 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -29,6 +29,7 @@
 #include "rcar_du_regs.h"
 #include "rcar_du_vsp.h"
 #include "rcar_lvds.h"
+#include "rcar_mipi_dsi.h"
 
 static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg)
 {
@@ -747,6 +748,18 @@ static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc,
 		rcar_lvds_clk_enable(bridge, mode->clock * 1000);
 	}
 
+	/*
+	 * Similarly to LVDS, on V3U the dot clock is provided by the DSI
+	 * encoder, and we need to enable the DSI clocks before enabling the CRTC.
+	 */
+	if ((rcdu->info->dsi_clk_mask & BIT(rcrtc->index)) &&
+	    (rstate->outputs &
+	     (BIT(RCAR_DU_OUTPUT_DSI0) | BIT(RCAR_DU_OUTPUT_DSI1)))) {
+		struct drm_bridge *bridge = rcdu->dsi[rcrtc->index];
+
+		rcar_mipi_dsi_pclk_enable(bridge, state);
+	}
+
 	rcar_du_crtc_start(rcrtc);
 
 	/*
@@ -780,6 +793,19 @@ static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc,
 		rcar_lvds_clk_disable(bridge);
 	}
 
+	if ((rcdu->info->dsi_clk_mask & BIT(rcrtc->index)) &&
+	    (rstate->outputs &
+	     (BIT(RCAR_DU_OUTPUT_DSI0) | BIT(RCAR_DU_OUTPUT_DSI1)))) {
+		struct drm_bridge *bridge = rcdu->dsi[rcrtc->index];
+
+		/*
+		 * Disable the DSI clock output, see
+		 * rcar_du_crtc_atomic_enable().
+		 */
+
+		rcar_mipi_dsi_pclk_disable(bridge);
+	}
+
 	spin_lock_irq(&crtc->dev->event_lock);
 	if (crtc->state->event) {
 		drm_crtc_send_vblank_event(crtc, crtc->state->event);
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index bfad7775d9a1..9367c2f59431 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -91,6 +91,7 @@ struct rcar_du_device_info {
 #define RCAR_DU_MAX_GROUPS		DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
 #define RCAR_DU_MAX_VSPS		4
 #define RCAR_DU_MAX_LVDS		2
+#define RCAR_DU_MAX_DSI			2
 
 struct rcar_du_device {
 	struct device *dev;
@@ -107,6 +108,7 @@ struct rcar_du_device {
 	struct platform_device *cmms[RCAR_DU_MAX_CRTCS];
 	struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
 	struct drm_bridge *lvds[RCAR_DU_MAX_LVDS];
+	struct drm_bridge *dsi[RCAR_DU_MAX_DSI];
 
 	struct {
 		struct drm_property *colorkey;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
index 60d6be78323b..ac93e08e8af4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
@@ -84,6 +84,10 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
 		if (output == RCAR_DU_OUTPUT_LVDS0 ||
 		    output == RCAR_DU_OUTPUT_LVDS1)
 			rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] = bridge;
+
+		if (output == RCAR_DU_OUTPUT_DSI0 ||
+		    output == RCAR_DU_OUTPUT_DSI1)
+			rcdu->dsi[output - RCAR_DU_OUTPUT_DSI0] = bridge;
 	}
 
 	/*
diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
index 6a10a35f1122..b8fabf821a12 100644
--- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
+++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
@@ -598,7 +598,22 @@ static int rcar_mipi_dsi_attach(struct drm_bridge *bridge,
 static void rcar_mipi_dsi_atomic_enable(struct drm_bridge *bridge,
 					struct drm_bridge_state *old_bridge_state)
 {
-	struct drm_atomic_state *state = old_bridge_state->base.state;
+	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
+
+	rcar_mipi_dsi_start_video(dsi);
+}
+
+static void rcar_mipi_dsi_atomic_disable(struct drm_bridge *bridge,
+					 struct drm_bridge_state *old_bridge_state)
+{
+	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
+
+	rcar_mipi_dsi_stop_video(dsi);
+}
+
+void rcar_mipi_dsi_pclk_enable(struct drm_bridge *bridge,
+			       struct drm_atomic_state *state)
+{
 	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
 	const struct drm_display_mode *mode;
 	struct drm_connector *connector;
@@ -626,8 +641,6 @@ static void rcar_mipi_dsi_atomic_enable(struct drm_bridge *bridge,
 	if (ret < 0)
 		goto err_dsi_start_hs;
 
-	rcar_mipi_dsi_start_video(dsi);
-
 	return;
 
 err_dsi_start_hs:
@@ -635,16 +648,16 @@ static void rcar_mipi_dsi_atomic_enable(struct drm_bridge *bridge,
 err_dsi_startup:
 	rcar_mipi_dsi_clk_disable(dsi);
 }
+EXPORT_SYMBOL_GPL(rcar_mipi_dsi_pclk_enable);
 
-static void rcar_mipi_dsi_atomic_disable(struct drm_bridge *bridge,
-					 struct drm_bridge_state *old_bridge_state)
+void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge)
 {
 	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
 
-	rcar_mipi_dsi_stop_video(dsi);
 	rcar_mipi_dsi_shutdown(dsi);
 	rcar_mipi_dsi_clk_disable(dsi);
 }
+EXPORT_SYMBOL_GPL(rcar_mipi_dsi_pclk_disable);
 
 static enum drm_mode_status
 rcar_mipi_dsi_bridge_mode_valid(struct drm_bridge *bridge,
diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h
new file mode 100644
index 000000000000..ff759fc5edc7
--- /dev/null
+++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * R-Car DSI Encoder
+ *
+ * Copyright (C) 2022 Renesas Electronics Corporation
+ *
+ * Contact: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
+ */
+
+#ifndef __RCAR_MIPI_DSI_H__
+#define __RCAR_MIPI_DSI_H__
+
+struct drm_atomic_state;
+struct drm_bridge;
+
+#if IS_ENABLED(CONFIG_DRM_RCAR_MIPI_DSI)
+void rcar_mipi_dsi_pclk_enable(struct drm_bridge *bridge,
+			       struct drm_atomic_state *state);
+void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge);
+#else
+static inline void rcar_mipi_dsi_pclk_enable(struct drm_bridge *bridge,
+					     struct drm_atomic_state *state)
+{
+}
+
+void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge)
+{
+}
+#endif /* CONFIG_DRM_RCAR_MIPI_DSI */
+
+#endif /* __RCAR_MIPI_DSI_H__ */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 4/4] drm: rcar-du: lvds: Rename pclk enable/disable functions
  2022-08-22 13:05 [PATCH v2 0/4] drm: rcar-du: DSI fixes Tomi Valkeinen
                   ` (2 preceding siblings ...)
  2022-08-22 13:05 ` [PATCH v2 3/4] drm: rcar-du: fix DSI enable & disable sequence Tomi Valkeinen
@ 2022-08-22 13:05 ` Tomi Valkeinen
  2022-08-22 13:52   ` Laurent Pinchart
  2022-08-23 20:09   ` kernel test robot
  3 siblings, 2 replies; 20+ messages in thread
From: Tomi Valkeinen @ 2022-08-22 13:05 UTC (permalink / raw)
  To: Laurent Pinchart, Kieran Bingham, dri-devel, linux-renesas-soc
  Cc: Tomi Valkeinen

From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>

Rename LVDS pclk enable/disable functions to match what we use for DSI.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c |  4 ++--
 drivers/gpu/drm/rcar-du/rcar_lvds.c    |  4 ++--
 drivers/gpu/drm/rcar-du/rcar_lvds.h    | 10 +++++-----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 31e33270e6db..3619e1ddeb62 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -745,7 +745,7 @@ static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc,
 		const struct drm_display_mode *mode =
 			&crtc->state->adjusted_mode;
 
-		rcar_lvds_clk_enable(bridge, mode->clock * 1000);
+		rcar_lvds_pclk_enable(bridge, mode->clock * 1000);
 	}
 
 	/*
@@ -790,7 +790,7 @@ static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc,
 		 * Disable the LVDS clock output, see
 		 * rcar_du_crtc_atomic_enable().
 		 */
-		rcar_lvds_clk_disable(bridge);
+		rcar_lvds_pclk_disable(bridge);
 	}
 
 	if ((rcdu->info->dsi_clk_mask & BIT(rcrtc->index)) &&
diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
index d85aa4bc7f84..f438d7d858c7 100644
--- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
+++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
@@ -306,7 +306,7 @@ static void rcar_lvds_pll_setup_d3_e3(struct rcar_lvds *lvds, unsigned int freq)
  * Clock - D3/E3 only
  */
 
-int rcar_lvds_clk_enable(struct drm_bridge *bridge, unsigned long freq)
+int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq)
 {
 	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
 	int ret;
@@ -326,7 +326,7 @@ int rcar_lvds_clk_enable(struct drm_bridge *bridge, unsigned long freq)
 }
 EXPORT_SYMBOL_GPL(rcar_lvds_clk_enable);
 
-void rcar_lvds_clk_disable(struct drm_bridge *bridge)
+void rcar_lvds_pclk_disable(struct drm_bridge *bridge)
 {
 	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.h b/drivers/gpu/drm/rcar-du/rcar_lvds.h
index 3097bf749bec..bee7033b60d6 100644
--- a/drivers/gpu/drm/rcar-du/rcar_lvds.h
+++ b/drivers/gpu/drm/rcar-du/rcar_lvds.h
@@ -13,17 +13,17 @@
 struct drm_bridge;
 
 #if IS_ENABLED(CONFIG_DRM_RCAR_LVDS)
-int rcar_lvds_clk_enable(struct drm_bridge *bridge, unsigned long freq);
-void rcar_lvds_clk_disable(struct drm_bridge *bridge);
+int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq);
+void rcar_lvds_pclk_disable(struct drm_bridge *bridge);
 bool rcar_lvds_dual_link(struct drm_bridge *bridge);
 bool rcar_lvds_is_connected(struct drm_bridge *bridge);
 #else
-static inline int rcar_lvds_clk_enable(struct drm_bridge *bridge,
-				       unsigned long freq)
+static inline int rcar_lvds_pclk_enable(struct drm_bridge *bridge,
+					unsigned long freq)
 {
 	return -ENOSYS;
 }
-static inline void rcar_lvds_clk_disable(struct drm_bridge *bridge) { }
+static inline void rcar_lvds_pclk_disable(struct drm_bridge *bridge) { }
 static inline bool rcar_lvds_dual_link(struct drm_bridge *bridge)
 {
 	return false;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX
  2022-08-22 13:05 ` [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX Tomi Valkeinen
@ 2022-08-22 13:12   ` Laurent Pinchart
  2022-08-22 13:25   ` Biju Das
  1 sibling, 0 replies; 20+ messages in thread
From: Laurent Pinchart @ 2022-08-22 13:12 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Kieran Bingham, dri-devel, linux-renesas-soc, Tomi Valkeinen

Hi Tomi,

Thank you for the patch.

On Mon, Aug 22, 2022 at 04:05:09PM +0300, Tomi Valkeinen wrote:
> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> 
> The driver does not explicitly stop the video mode transmission when
> disabling the output. While this doesn't seem to be causing any issues,
> lets follow the steps described in the documentation and add a
> rcar_mipi_dsi_stop_video() which stop the video mode transmission. This
> function will also be used in later patches to stop the video
> transmission even if the DSI IP is not shut down.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 29 +++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> index 62f7eb84ab01..7f2be490fcf8 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> @@ -542,6 +542,34 @@ static int rcar_mipi_dsi_start_video(struct rcar_mipi_dsi *dsi)
>  	return 0;
>  }
>  
> +static void rcar_mipi_dsi_stop_video(struct rcar_mipi_dsi *dsi)
> +{
> +	u32 status;
> +	int ret;
> +
> +	/* Disable transmission in video mode. */
> +	rcar_mipi_dsi_clr(dsi, TXVMCR, TXVMCR_EN_VIDEO);
> +
> +	ret = read_poll_timeout(rcar_mipi_dsi_read, status,
> +				!(status & TXVMSR_ACT),
> +				2000, 100000, false, dsi, TXVMSR);
> +	if (ret < 0) {
> +		dev_err(dsi->dev, "Failed to disable video transmission\n");
> +		return;
> +	}
> +
> +	/* Assert video FIFO clear. */
> +	rcar_mipi_dsi_set(dsi, TXVMCR, TXVMCR_VFCLR);
> +
> +	ret = read_poll_timeout(rcar_mipi_dsi_read, status,
> +				!(status & TXVMSR_VFRDY),
> +				2000, 100000, false, dsi, TXVMSR);
> +	if (ret < 0) {
> +		dev_err(dsi->dev, "Failed to assert video FIFO clear\n");
> +		return;
> +	}
> +}
> +
>  /* -----------------------------------------------------------------------------
>   * Bridge
>   */
> @@ -601,6 +629,7 @@ static void rcar_mipi_dsi_atomic_disable(struct drm_bridge *bridge,
>  {
>  	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
>  
> +	rcar_mipi_dsi_stop_video(dsi);
>  	rcar_mipi_dsi_shutdown(dsi);
>  	rcar_mipi_dsi_clk_disable(dsi);
>  }

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] drm: rcar-du: dsi: Improve DSI shutdown
  2022-08-22 13:05 ` [PATCH v2 2/4] drm: rcar-du: dsi: Improve DSI shutdown Tomi Valkeinen
@ 2022-08-22 13:20   ` Laurent Pinchart
  2022-08-22 13:49     ` Tomi Valkeinen
  0 siblings, 1 reply; 20+ messages in thread
From: Laurent Pinchart @ 2022-08-22 13:20 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Kieran Bingham, dri-devel, linux-renesas-soc, Tomi Valkeinen

Hi Tomi,

Thank you for the patch.

On Mon, Aug 22, 2022 at 04:05:10PM +0300, Tomi Valkeinen wrote:
> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> 
> Improve the DSI shutdown procedure by clearing various bits that were
> set while enabling the DSI output. There has been no clear issues caused
> by these, but it's safer to ensure that the features are disabled at the
> start of the next DSI enable.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> index 7f2be490fcf8..6a10a35f1122 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> @@ -441,9 +441,21 @@ static int rcar_mipi_dsi_startup(struct rcar_mipi_dsi *dsi,
>  
>  static void rcar_mipi_dsi_shutdown(struct rcar_mipi_dsi *dsi)
>  {
> +	/* Disable VCLKEN */
> +	rcar_mipi_dsi_clr(dsi, VCLKEN, VCLKEN_CKEN);
> +
> +	/* Disable DOT clock */
> +	rcar_mipi_dsi_clr(dsi, VCLKSET, VCLKSET_CKEN);

I think you can write 0 to those two registers, this will also be safer.
With this,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

I think there's a bug in rcar_mipi_dsi_startup() related to this by the
way, the function only uses rcar_mipi_dsi_set() to set bits, so if the
DSI format is modified between two starts, bad things will happen.

> +
>  	rcar_mipi_dsi_clr(dsi, PHYSETUP, PHYSETUP_RSTZ);
>  	rcar_mipi_dsi_clr(dsi, PHYSETUP, PHYSETUP_SHUTDOWNZ);
>  
> +	/* CFGCLK disable */
> +	rcar_mipi_dsi_clr(dsi, CFGCLKSET, CFGCLKSET_CKEN);
> +
> +	/* LPCLK disable */
> +	rcar_mipi_dsi_clr(dsi, LPCLKSET, LPCLKSET_CKEN);
> +
>  	dev_dbg(dsi->dev, "DSI device is shutdown\n");
>  }
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 20+ messages in thread

* RE: [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX
  2022-08-22 13:05 ` [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX Tomi Valkeinen
  2022-08-22 13:12   ` Laurent Pinchart
@ 2022-08-22 13:25   ` Biju Das
  2022-08-22 14:00     ` Tomi Valkeinen
  1 sibling, 1 reply; 20+ messages in thread
From: Biju Das @ 2022-08-22 13:25 UTC (permalink / raw)
  To: Tomi Valkeinen, Laurent Pinchart, Kieran Bingham, dri-devel,
	linux-renesas-soc
  Cc: Tomi Valkeinen

Hi Tomi,

Thanks for the patch.

> Subject: [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX
> 
> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> 
> The driver does not explicitly stop the video mode transmission when
> disabling the output. While this doesn't seem to be causing any issues,
> lets follow the steps described in the documentation and add a
> rcar_mipi_dsi_stop_video() which stop the video mode transmission. This
> function will also be used in later patches to stop the video
> transmission even if the DSI IP is not shut down.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 29 +++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> index 62f7eb84ab01..7f2be490fcf8 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> @@ -542,6 +542,34 @@ static int rcar_mipi_dsi_start_video(struct
> rcar_mipi_dsi *dsi)
>  	return 0;
>  }
> 
> +static void rcar_mipi_dsi_stop_video(struct rcar_mipi_dsi *dsi) {
> +	u32 status;
> +	int ret;
> +
> +	/* Disable transmission in video mode. */
> +	rcar_mipi_dsi_clr(dsi, TXVMCR, TXVMCR_EN_VIDEO);
> +
> +	ret = read_poll_timeout(rcar_mipi_dsi_read, status,
> +				!(status & TXVMSR_ACT),
> +				2000, 100000, false, dsi, TXVMSR);
> +	if (ret < 0) {
> +		dev_err(dsi->dev, "Failed to disable video transmission\n");
> +		return;
> +	}
> +
> +	/* Assert video FIFO clear. */
> +	rcar_mipi_dsi_set(dsi, TXVMCR, TXVMCR_VFCLR);
> +
> +	ret = read_poll_timeout(rcar_mipi_dsi_read, status,
> +				!(status & TXVMSR_VFRDY),
> +				2000, 100000, false, dsi, TXVMSR);
> +	if (ret < 0) {
> +		dev_err(dsi->dev, "Failed to assert video FIFO clear\n");
> +		return;

This return is not required.

Cheers,
Biju

> +	}
> +}
> +
>  /* --------------------------------------------------------------------
> ---------
>   * Bridge
>   */
> @@ -601,6 +629,7 @@ static void rcar_mipi_dsi_atomic_disable(struct
> drm_bridge *bridge,  {
>  	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
> 
> +	rcar_mipi_dsi_stop_video(dsi);
>  	rcar_mipi_dsi_shutdown(dsi);
>  	rcar_mipi_dsi_clk_disable(dsi);
>  }
> --
> 2.34.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 3/4] drm: rcar-du: fix DSI enable & disable sequence
  2022-08-22 13:05 ` [PATCH v2 3/4] drm: rcar-du: fix DSI enable & disable sequence Tomi Valkeinen
@ 2022-08-22 13:40   ` Laurent Pinchart
  2022-08-23  3:08   ` kernel test robot
  2022-08-23 19:08   ` kernel test robot
  2 siblings, 0 replies; 20+ messages in thread
From: Laurent Pinchart @ 2022-08-22 13:40 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Kieran Bingham, dri-devel, linux-renesas-soc, Tomi Valkeinen

Hi Tomi,

Thank you for the patch.

On Mon, Aug 22, 2022 at 04:05:11PM +0300, Tomi Valkeinen wrote:
> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> 
> The rcar crtc depends on the clock provided from the rcar DSI bridge.
> When the DSI bridge is disabled, the clock is stopped, which causes the
> crtc disable to timeout.
> 
> Also, while I have no issue with the enable, the documentation suggests
> to enable the DSI before the crtc so that the crtc has its clock enabled
> at enable time. This is also not done by the current driver.
> 
> To fix this, we need to keep the DSI bridge enabled until the crtc has
> disabled itself, and enable the DSI bridge before crtc enables itself.
> 
> Add functions (rcar_mipi_dsi_atomic_early_enable and
> rcar_mipi_dsi_atomic_late_disable) to the rcar DSI bridge driver which

The function names don't match the code. With this fixed,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> the rcar driver can use to enable/disable the DSI clock when needed.
> This is similar to what is already done with the rcar LVDS bridge.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.c    | 26 +++++++++++++++++++
>  drivers/gpu/drm/rcar-du/rcar_du_drv.h     |  2 ++
>  drivers/gpu/drm/rcar-du/rcar_du_encoder.c |  4 +++
>  drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c   | 25 +++++++++++++-----
>  drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h   | 31 +++++++++++++++++++++++
>  5 files changed, 82 insertions(+), 6 deletions(-)
>  create mode 100644 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> index fd3b94649a01..31e33270e6db 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> @@ -29,6 +29,7 @@
>  #include "rcar_du_regs.h"
>  #include "rcar_du_vsp.h"
>  #include "rcar_lvds.h"
> +#include "rcar_mipi_dsi.h"
>  
>  static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg)
>  {
> @@ -747,6 +748,18 @@ static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc,
>  		rcar_lvds_clk_enable(bridge, mode->clock * 1000);
>  	}
>  
> +	/*
> +	 * Similarly to LVDS, on V3U the dot clock is provided by the DSI
> +	 * encoder, and we need to enable the DSI clocks before enabling the CRTC.
> +	 */
> +	if ((rcdu->info->dsi_clk_mask & BIT(rcrtc->index)) &&
> +	    (rstate->outputs &
> +	     (BIT(RCAR_DU_OUTPUT_DSI0) | BIT(RCAR_DU_OUTPUT_DSI1)))) {
> +		struct drm_bridge *bridge = rcdu->dsi[rcrtc->index];
> +
> +		rcar_mipi_dsi_pclk_enable(bridge, state);
> +	}
> +
>  	rcar_du_crtc_start(rcrtc);
>  
>  	/*
> @@ -780,6 +793,19 @@ static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc,
>  		rcar_lvds_clk_disable(bridge);
>  	}
>  
> +	if ((rcdu->info->dsi_clk_mask & BIT(rcrtc->index)) &&
> +	    (rstate->outputs &
> +	     (BIT(RCAR_DU_OUTPUT_DSI0) | BIT(RCAR_DU_OUTPUT_DSI1)))) {
> +		struct drm_bridge *bridge = rcdu->dsi[rcrtc->index];
> +
> +		/*
> +		 * Disable the DSI clock output, see
> +		 * rcar_du_crtc_atomic_enable().
> +		 */
> +
> +		rcar_mipi_dsi_pclk_disable(bridge);
> +	}
> +
>  	spin_lock_irq(&crtc->dev->event_lock);
>  	if (crtc->state->event) {
>  		drm_crtc_send_vblank_event(crtc, crtc->state->event);
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
> index bfad7775d9a1..9367c2f59431 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
> @@ -91,6 +91,7 @@ struct rcar_du_device_info {
>  #define RCAR_DU_MAX_GROUPS		DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
>  #define RCAR_DU_MAX_VSPS		4
>  #define RCAR_DU_MAX_LVDS		2
> +#define RCAR_DU_MAX_DSI			2
>  
>  struct rcar_du_device {
>  	struct device *dev;
> @@ -107,6 +108,7 @@ struct rcar_du_device {
>  	struct platform_device *cmms[RCAR_DU_MAX_CRTCS];
>  	struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
>  	struct drm_bridge *lvds[RCAR_DU_MAX_LVDS];
> +	struct drm_bridge *dsi[RCAR_DU_MAX_DSI];
>  
>  	struct {
>  		struct drm_property *colorkey;
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> index 60d6be78323b..ac93e08e8af4 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> @@ -84,6 +84,10 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
>  		if (output == RCAR_DU_OUTPUT_LVDS0 ||
>  		    output == RCAR_DU_OUTPUT_LVDS1)
>  			rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] = bridge;
> +
> +		if (output == RCAR_DU_OUTPUT_DSI0 ||
> +		    output == RCAR_DU_OUTPUT_DSI1)
> +			rcdu->dsi[output - RCAR_DU_OUTPUT_DSI0] = bridge;
>  	}
>  
>  	/*
> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> index 6a10a35f1122..b8fabf821a12 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> @@ -598,7 +598,22 @@ static int rcar_mipi_dsi_attach(struct drm_bridge *bridge,
>  static void rcar_mipi_dsi_atomic_enable(struct drm_bridge *bridge,
>  					struct drm_bridge_state *old_bridge_state)
>  {
> -	struct drm_atomic_state *state = old_bridge_state->base.state;
> +	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
> +
> +	rcar_mipi_dsi_start_video(dsi);
> +}
> +
> +static void rcar_mipi_dsi_atomic_disable(struct drm_bridge *bridge,
> +					 struct drm_bridge_state *old_bridge_state)
> +{
> +	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
> +
> +	rcar_mipi_dsi_stop_video(dsi);
> +}
> +
> +void rcar_mipi_dsi_pclk_enable(struct drm_bridge *bridge,
> +			       struct drm_atomic_state *state)
> +{
>  	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
>  	const struct drm_display_mode *mode;
>  	struct drm_connector *connector;
> @@ -626,8 +641,6 @@ static void rcar_mipi_dsi_atomic_enable(struct drm_bridge *bridge,
>  	if (ret < 0)
>  		goto err_dsi_start_hs;
>  
> -	rcar_mipi_dsi_start_video(dsi);
> -
>  	return;
>  
>  err_dsi_start_hs:
> @@ -635,16 +648,16 @@ static void rcar_mipi_dsi_atomic_enable(struct drm_bridge *bridge,
>  err_dsi_startup:
>  	rcar_mipi_dsi_clk_disable(dsi);
>  }
> +EXPORT_SYMBOL_GPL(rcar_mipi_dsi_pclk_enable);
>  
> -static void rcar_mipi_dsi_atomic_disable(struct drm_bridge *bridge,
> -					 struct drm_bridge_state *old_bridge_state)
> +void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge)
>  {
>  	struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
>  
> -	rcar_mipi_dsi_stop_video(dsi);
>  	rcar_mipi_dsi_shutdown(dsi);
>  	rcar_mipi_dsi_clk_disable(dsi);
>  }
> +EXPORT_SYMBOL_GPL(rcar_mipi_dsi_pclk_disable);
>  
>  static enum drm_mode_status
>  rcar_mipi_dsi_bridge_mode_valid(struct drm_bridge *bridge,
> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h
> new file mode 100644
> index 000000000000..ff759fc5edc7
> --- /dev/null
> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h
> @@ -0,0 +1,31 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * R-Car DSI Encoder
> + *
> + * Copyright (C) 2022 Renesas Electronics Corporation
> + *
> + * Contact: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> + */
> +
> +#ifndef __RCAR_MIPI_DSI_H__
> +#define __RCAR_MIPI_DSI_H__
> +
> +struct drm_atomic_state;
> +struct drm_bridge;
> +
> +#if IS_ENABLED(CONFIG_DRM_RCAR_MIPI_DSI)
> +void rcar_mipi_dsi_pclk_enable(struct drm_bridge *bridge,
> +			       struct drm_atomic_state *state);
> +void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge);
> +#else
> +static inline void rcar_mipi_dsi_pclk_enable(struct drm_bridge *bridge,
> +					     struct drm_atomic_state *state)
> +{
> +}
> +
> +void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge)
> +{
> +}
> +#endif /* CONFIG_DRM_RCAR_MIPI_DSI */
> +
> +#endif /* __RCAR_MIPI_DSI_H__ */

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] drm: rcar-du: dsi: Improve DSI shutdown
  2022-08-22 13:20   ` Laurent Pinchart
@ 2022-08-22 13:49     ` Tomi Valkeinen
  2022-08-22 14:05       ` Laurent Pinchart
  0 siblings, 1 reply; 20+ messages in thread
From: Tomi Valkeinen @ 2022-08-22 13:49 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Kieran Bingham, dri-devel, linux-renesas-soc, Tomi Valkeinen

On 22/08/2022 16:20, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Mon, Aug 22, 2022 at 04:05:10PM +0300, Tomi Valkeinen wrote:
>> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>>
>> Improve the DSI shutdown procedure by clearing various bits that were
>> set while enabling the DSI output. There has been no clear issues caused
>> by these, but it's safer to ensure that the features are disabled at the
>> start of the next DSI enable.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>> ---
>>   drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 12 ++++++++++++
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
>> index 7f2be490fcf8..6a10a35f1122 100644
>> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
>> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
>> @@ -441,9 +441,21 @@ static int rcar_mipi_dsi_startup(struct rcar_mipi_dsi *dsi,
>>   
>>   static void rcar_mipi_dsi_shutdown(struct rcar_mipi_dsi *dsi)
>>   {
>> +	/* Disable VCLKEN */
>> +	rcar_mipi_dsi_clr(dsi, VCLKEN, VCLKEN_CKEN);
>> +
>> +	/* Disable DOT clock */
>> +	rcar_mipi_dsi_clr(dsi, VCLKSET, VCLKSET_CKEN);
> 
> I think you can write 0 to those two registers, this will also be safer.
> With this,

VCLKEN has only the single VCLKEN_CKEN bit and the rest of the bits are 
reserved with default value of 0, however VCLKSET has other fields and 
the default value of those fields is not 0.

Why do you think it's safer to set the whole register to 0? Isn't it 
better to just do what we want to do, which makes the purpose clear and, 
I think, is safer as we don't touch bits we don't know about?

> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> I think there's a bug in rcar_mipi_dsi_startup() related to this by the
> way, the function only uses rcar_mipi_dsi_set() to set bits, so if the
> DSI format is modified between two starts, bad things will happen.

Oh, that's bad. rcar_mipi_dsi_set() is not a very good function as it's 
easy to misuse it like that. I'll make a fix for that.

  Tomi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/4] drm: rcar-du: lvds: Rename pclk enable/disable functions
  2022-08-22 13:05 ` [PATCH v2 4/4] drm: rcar-du: lvds: Rename pclk enable/disable functions Tomi Valkeinen
@ 2022-08-22 13:52   ` Laurent Pinchart
  2022-08-22 13:56     ` Tomi Valkeinen
  2022-08-23 20:09   ` kernel test robot
  1 sibling, 1 reply; 20+ messages in thread
From: Laurent Pinchart @ 2022-08-22 13:52 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Kieran Bingham, dri-devel, linux-renesas-soc, Tomi Valkeinen

Hi Tomi,

Thank you for the patch.

On Mon, Aug 22, 2022 at 04:05:12PM +0300, Tomi Valkeinen wrote:
> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> 
> Rename LVDS pclk enable/disable functions to match what we use for DSI.

I'd explain here the rationale for the new names:

The DU driver uses the rcar_lvds_clk_enable() and
rcar_lvds_clk_disable() functions enable or disable the pixel clock
generated by the LVDS encoder, as it requires that clock for proper DU
operation. Rename the functions by replacing "clk" with "pclk" to make
it clearer that they related to the pixel clock.

Then the patch could move to the beginning of the series.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.c |  4 ++--
>  drivers/gpu/drm/rcar-du/rcar_lvds.c    |  4 ++--
>  drivers/gpu/drm/rcar-du/rcar_lvds.h    | 10 +++++-----
>  3 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> index 31e33270e6db..3619e1ddeb62 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
> @@ -745,7 +745,7 @@ static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc,
>  		const struct drm_display_mode *mode =
>  			&crtc->state->adjusted_mode;
>  
> -		rcar_lvds_clk_enable(bridge, mode->clock * 1000);
> +		rcar_lvds_pclk_enable(bridge, mode->clock * 1000);
>  	}
>  
>  	/*
> @@ -790,7 +790,7 @@ static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc,
>  		 * Disable the LVDS clock output, see
>  		 * rcar_du_crtc_atomic_enable().
>  		 */
> -		rcar_lvds_clk_disable(bridge);
> +		rcar_lvds_pclk_disable(bridge);
>  	}
>  
>  	if ((rcdu->info->dsi_clk_mask & BIT(rcrtc->index)) &&
> diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> index d85aa4bc7f84..f438d7d858c7 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> @@ -306,7 +306,7 @@ static void rcar_lvds_pll_setup_d3_e3(struct rcar_lvds *lvds, unsigned int freq)
>   * Clock - D3/E3 only
>   */
>  
> -int rcar_lvds_clk_enable(struct drm_bridge *bridge, unsigned long freq)
> +int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq)
>  {
>  	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
>  	int ret;
> @@ -326,7 +326,7 @@ int rcar_lvds_clk_enable(struct drm_bridge *bridge, unsigned long freq)
>  }
>  EXPORT_SYMBOL_GPL(rcar_lvds_clk_enable);
>  
> -void rcar_lvds_clk_disable(struct drm_bridge *bridge)
> +void rcar_lvds_pclk_disable(struct drm_bridge *bridge)
>  {
>  	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
>  
> diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.h b/drivers/gpu/drm/rcar-du/rcar_lvds.h
> index 3097bf749bec..bee7033b60d6 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_lvds.h
> +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.h
> @@ -13,17 +13,17 @@
>  struct drm_bridge;
>  
>  #if IS_ENABLED(CONFIG_DRM_RCAR_LVDS)
> -int rcar_lvds_clk_enable(struct drm_bridge *bridge, unsigned long freq);
> -void rcar_lvds_clk_disable(struct drm_bridge *bridge);
> +int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq);
> +void rcar_lvds_pclk_disable(struct drm_bridge *bridge);
>  bool rcar_lvds_dual_link(struct drm_bridge *bridge);
>  bool rcar_lvds_is_connected(struct drm_bridge *bridge);
>  #else
> -static inline int rcar_lvds_clk_enable(struct drm_bridge *bridge,
> -				       unsigned long freq)
> +static inline int rcar_lvds_pclk_enable(struct drm_bridge *bridge,
> +					unsigned long freq)
>  {
>  	return -ENOSYS;
>  }
> -static inline void rcar_lvds_clk_disable(struct drm_bridge *bridge) { }
> +static inline void rcar_lvds_pclk_disable(struct drm_bridge *bridge) { }
>  static inline bool rcar_lvds_dual_link(struct drm_bridge *bridge)
>  {
>  	return false;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/4] drm: rcar-du: lvds: Rename pclk enable/disable functions
  2022-08-22 13:52   ` Laurent Pinchart
@ 2022-08-22 13:56     ` Tomi Valkeinen
  0 siblings, 0 replies; 20+ messages in thread
From: Tomi Valkeinen @ 2022-08-22 13:56 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Kieran Bingham, dri-devel, linux-renesas-soc, Tomi Valkeinen

On 22/08/2022 16:52, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Mon, Aug 22, 2022 at 04:05:12PM +0300, Tomi Valkeinen wrote:
>> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>>
>> Rename LVDS pclk enable/disable functions to match what we use for DSI.
> 
> I'd explain here the rationale for the new names:
> 
> The DU driver uses the rcar_lvds_clk_enable() and
> rcar_lvds_clk_disable() functions enable or disable the pixel clock
> generated by the LVDS encoder, as it requires that clock for proper DU
> operation. Rename the functions by replacing "clk" with "pclk" to make
> it clearer that they related to the pixel clock.
> 
> Then the patch could move to the beginning of the series.

Sounds good to me.

  Tomi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX
  2022-08-22 13:25   ` Biju Das
@ 2022-08-22 14:00     ` Tomi Valkeinen
  2022-08-22 14:16       ` Biju Das
  0 siblings, 1 reply; 20+ messages in thread
From: Tomi Valkeinen @ 2022-08-22 14:00 UTC (permalink / raw)
  To: Biju Das, Laurent Pinchart, Kieran Bingham, dri-devel, linux-renesas-soc
  Cc: Tomi Valkeinen

Hi,

On 22/08/2022 16:25, Biju Das wrote:
> Hi Tomi,
> 
> Thanks for the patch.
> 
>> Subject: [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX
>>
>> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>>
>> The driver does not explicitly stop the video mode transmission when
>> disabling the output. While this doesn't seem to be causing any issues,
>> lets follow the steps described in the documentation and add a
>> rcar_mipi_dsi_stop_video() which stop the video mode transmission. This
>> function will also be used in later patches to stop the video
>> transmission even if the DSI IP is not shut down.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>> ---
>>   drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 29 +++++++++++++++++++++++++
>>   1 file changed, 29 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
>> b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
>> index 62f7eb84ab01..7f2be490fcf8 100644
>> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
>> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
>> @@ -542,6 +542,34 @@ static int rcar_mipi_dsi_start_video(struct
>> rcar_mipi_dsi *dsi)
>>   	return 0;
>>   }
>>
>> +static void rcar_mipi_dsi_stop_video(struct rcar_mipi_dsi *dsi) {
>> +	u32 status;
>> +	int ret;
>> +
>> +	/* Disable transmission in video mode. */
>> +	rcar_mipi_dsi_clr(dsi, TXVMCR, TXVMCR_EN_VIDEO);
>> +
>> +	ret = read_poll_timeout(rcar_mipi_dsi_read, status,
>> +				!(status & TXVMSR_ACT),
>> +				2000, 100000, false, dsi, TXVMSR);
>> +	if (ret < 0) {
>> +		dev_err(dsi->dev, "Failed to disable video transmission\n");
>> +		return;
>> +	}
>> +
>> +	/* Assert video FIFO clear. */
>> +	rcar_mipi_dsi_set(dsi, TXVMCR, TXVMCR_VFCLR);
>> +
>> +	ret = read_poll_timeout(rcar_mipi_dsi_read, status,
>> +				!(status & TXVMSR_VFRDY),
>> +				2000, 100000, false, dsi, TXVMSR);
>> +	if (ret < 0) {
>> +		dev_err(dsi->dev, "Failed to assert video FIFO clear\n");
>> +		return;
> 
> This return is not required.

That is true, but I'd personally rather keep it there. If the return is 
removed, I can imagine how easily one could add a new piece of code in 
the end of the function, not realizing that one also needs to add a 
return (the one above) so that the code works correctly.

It just feels a bit safer this way.

  Tomi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] drm: rcar-du: dsi: Improve DSI shutdown
  2022-08-22 13:49     ` Tomi Valkeinen
@ 2022-08-22 14:05       ` Laurent Pinchart
  2022-08-22 14:19         ` Tomi Valkeinen
  0 siblings, 1 reply; 20+ messages in thread
From: Laurent Pinchart @ 2022-08-22 14:05 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Kieran Bingham, dri-devel, linux-renesas-soc, Tomi Valkeinen

On Mon, Aug 22, 2022 at 04:49:02PM +0300, Tomi Valkeinen wrote:
> On 22/08/2022 16:20, Laurent Pinchart wrote:
> > Hi Tomi,
> > 
> > Thank you for the patch.
> > 
> > On Mon, Aug 22, 2022 at 04:05:10PM +0300, Tomi Valkeinen wrote:
> >> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> >>
> >> Improve the DSI shutdown procedure by clearing various bits that were
> >> set while enabling the DSI output. There has been no clear issues caused
> >> by these, but it's safer to ensure that the features are disabled at the
> >> start of the next DSI enable.
> >>
> >> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> >> ---
> >>   drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 12 ++++++++++++
> >>   1 file changed, 12 insertions(+)
> >>
> >> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> >> index 7f2be490fcf8..6a10a35f1122 100644
> >> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> >> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> >> @@ -441,9 +441,21 @@ static int rcar_mipi_dsi_startup(struct rcar_mipi_dsi *dsi,
> >>   
> >>   static void rcar_mipi_dsi_shutdown(struct rcar_mipi_dsi *dsi)
> >>   {
> >> +	/* Disable VCLKEN */
> >> +	rcar_mipi_dsi_clr(dsi, VCLKEN, VCLKEN_CKEN);
> >> +
> >> +	/* Disable DOT clock */
> >> +	rcar_mipi_dsi_clr(dsi, VCLKSET, VCLKSET_CKEN);
> > 
> > I think you can write 0 to those two registers, this will also be safer.
> > With this,
> 
> VCLKEN has only the single VCLKEN_CKEN bit and the rest of the bits are 
> reserved with default value of 0, however VCLKSET has other fields and 
> the default value of those fields is not 0.

But the two fields whose default value isn't 0 are set in the startup()
function (albeit incorrectly as discussed below), so it should be fine.

> Why do you think it's safer to set the whole register to 0? Isn't it 
> better to just do what we want to do, which makes the purpose clear and, 
> I think, is safer as we don't touch bits we don't know about?

Because it will ensure that we don't get surprises when we later restart
the device, such as mentioned below :-)

> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > 
> > I think there's a bug in rcar_mipi_dsi_startup() related to this by the
> > way, the function only uses rcar_mipi_dsi_set() to set bits, so if the
> > DSI format is modified between two starts, bad things will happen.
> 
> Oh, that's bad. rcar_mipi_dsi_set() is not a very good function as it's 
> easy to misuse it like that. I'll make a fix for that.
-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 20+ messages in thread

* RE: [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX
  2022-08-22 14:00     ` Tomi Valkeinen
@ 2022-08-22 14:16       ` Biju Das
  0 siblings, 0 replies; 20+ messages in thread
From: Biju Das @ 2022-08-22 14:16 UTC (permalink / raw)
  To: Tomi Valkeinen, Laurent Pinchart, Kieran Bingham, dri-devel,
	linux-renesas-soc
  Cc: Tomi Valkeinen

Hi,

> Subject: Re: [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode
> TX
> 
> Hi,
> 
> On 22/08/2022 16:25, Biju Das wrote:
> > Hi Tomi,
> >
> > Thanks for the patch.
> >
> >> Subject: [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode
> >> TX
> >>
> >> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> >>
> >> The driver does not explicitly stop the video mode transmission when
> >> disabling the output. While this doesn't seem to be causing any
> >> issues, lets follow the steps described in the documentation and add
> >> a
> >> rcar_mipi_dsi_stop_video() which stop the video mode transmission.
> >> This function will also be used in later patches to stop the video
> >> transmission even if the DSI IP is not shut down.
> >>
> >> Signed-off-by: Tomi Valkeinen
> >> <tomi.valkeinen+renesas@ideasonboard.com>
> >> ---
> >>   drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 29
> +++++++++++++++++++++++++
> >>   1 file changed, 29 insertions(+)
> >>
> >> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> >> b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> >> index 62f7eb84ab01..7f2be490fcf8 100644
> >> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> >> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> >> @@ -542,6 +542,34 @@ static int rcar_mipi_dsi_start_video(struct
> >> rcar_mipi_dsi *dsi)
> >>   	return 0;
> >>   }
> >>
> >> +static void rcar_mipi_dsi_stop_video(struct rcar_mipi_dsi *dsi) {
> >> +	u32 status;
> >> +	int ret;
> >> +
> >> +	/* Disable transmission in video mode. */
> >> +	rcar_mipi_dsi_clr(dsi, TXVMCR, TXVMCR_EN_VIDEO);
> >> +
> >> +	ret = read_poll_timeout(rcar_mipi_dsi_read, status,
> >> +				!(status & TXVMSR_ACT),
> >> +				2000, 100000, false, dsi, TXVMSR);
> >> +	if (ret < 0) {
> >> +		dev_err(dsi->dev, "Failed to disable video transmission\n");
> >> +		return;
> >> +	}
> >> +
> >> +	/* Assert video FIFO clear. */
> >> +	rcar_mipi_dsi_set(dsi, TXVMCR, TXVMCR_VFCLR);
> >> +
> >> +	ret = read_poll_timeout(rcar_mipi_dsi_read, status,
> >> +				!(status & TXVMSR_VFRDY),
> >> +				2000, 100000, false, dsi, TXVMSR);
> >> +	if (ret < 0) {
> >> +		dev_err(dsi->dev, "Failed to assert video FIFO clear\n");
> >> +		return;
> >
> > This return is not required.
> 
> That is true, but I'd personally rather keep it there. If the return is
> removed, I can imagine how easily one could add a new piece of code in
> the end of the function, not realizing that one also needs to add a
> return (the one above) so that the code works correctly.
> 
> It just feels a bit safer this way.

OK, I just thought of reducing number of lines and remove unwanted code
As return type is void.

if (ret < 0)
  dev_err(dsi->dev, "Failed to assert video FIFO clear\n");

Any way there is a review process which will capture the issue you mentioned.

I am ok with your statement.

Cheers,
Biju

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] drm: rcar-du: dsi: Improve DSI shutdown
  2022-08-22 14:05       ` Laurent Pinchart
@ 2022-08-22 14:19         ` Tomi Valkeinen
  2022-08-22 14:28           ` Laurent Pinchart
  0 siblings, 1 reply; 20+ messages in thread
From: Tomi Valkeinen @ 2022-08-22 14:19 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Kieran Bingham, dri-devel, linux-renesas-soc, Tomi Valkeinen

On 22/08/2022 17:05, Laurent Pinchart wrote:
> On Mon, Aug 22, 2022 at 04:49:02PM +0300, Tomi Valkeinen wrote:
>> On 22/08/2022 16:20, Laurent Pinchart wrote:
>>> Hi Tomi,
>>>
>>> Thank you for the patch.
>>>
>>> On Mon, Aug 22, 2022 at 04:05:10PM +0300, Tomi Valkeinen wrote:
>>>> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>>>>
>>>> Improve the DSI shutdown procedure by clearing various bits that were
>>>> set while enabling the DSI output. There has been no clear issues caused
>>>> by these, but it's safer to ensure that the features are disabled at the
>>>> start of the next DSI enable.
>>>>
>>>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>>>> ---
>>>>    drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 12 ++++++++++++
>>>>    1 file changed, 12 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
>>>> index 7f2be490fcf8..6a10a35f1122 100644
>>>> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
>>>> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
>>>> @@ -441,9 +441,21 @@ static int rcar_mipi_dsi_startup(struct rcar_mipi_dsi *dsi,
>>>>    
>>>>    static void rcar_mipi_dsi_shutdown(struct rcar_mipi_dsi *dsi)
>>>>    {
>>>> +	/* Disable VCLKEN */
>>>> +	rcar_mipi_dsi_clr(dsi, VCLKEN, VCLKEN_CKEN);
>>>> +
>>>> +	/* Disable DOT clock */
>>>> +	rcar_mipi_dsi_clr(dsi, VCLKSET, VCLKSET_CKEN);
>>>
>>> I think you can write 0 to those two registers, this will also be safer.
>>> With this,
>>
>> VCLKEN has only the single VCLKEN_CKEN bit and the rest of the bits are
>> reserved with default value of 0, however VCLKSET has other fields and
>> the default value of those fields is not 0.
> 
> But the two fields whose default value isn't 0 are set in the startup()
> function (albeit incorrectly as discussed below), so it should be fine.

That is true. But I'd rather write 0 to VCLKEN in the startup, before 
writing the configuration.

>> Why do you think it's safer to set the whole register to 0? Isn't it
>> better to just do what we want to do, which makes the purpose clear and,
>> I think, is safer as we don't touch bits we don't know about?
> 
> Because it will ensure that we don't get surprises when we later restart
> the device, such as mentioned below :-)

Well, but that's a bug in the startup code. I don't think the shutdown 
code should do things to make startup work better if the startup does 
something wrong. Nevertheless, while I slightly disagree, I'm fine with 
writing zero there in shutdown.

  Tomi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] drm: rcar-du: dsi: Improve DSI shutdown
  2022-08-22 14:19         ` Tomi Valkeinen
@ 2022-08-22 14:28           ` Laurent Pinchart
  0 siblings, 0 replies; 20+ messages in thread
From: Laurent Pinchart @ 2022-08-22 14:28 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Kieran Bingham, dri-devel, linux-renesas-soc, Tomi Valkeinen

On Mon, Aug 22, 2022 at 05:19:56PM +0300, Tomi Valkeinen wrote:
> On 22/08/2022 17:05, Laurent Pinchart wrote:
> > On Mon, Aug 22, 2022 at 04:49:02PM +0300, Tomi Valkeinen wrote:
> >> On 22/08/2022 16:20, Laurent Pinchart wrote:
> >>> Hi Tomi,
> >>>
> >>> Thank you for the patch.
> >>>
> >>> On Mon, Aug 22, 2022 at 04:05:10PM +0300, Tomi Valkeinen wrote:
> >>>> From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> >>>>
> >>>> Improve the DSI shutdown procedure by clearing various bits that were
> >>>> set while enabling the DSI output. There has been no clear issues caused
> >>>> by these, but it's safer to ensure that the features are disabled at the
> >>>> start of the next DSI enable.
> >>>>
> >>>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> >>>> ---
> >>>>    drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 12 ++++++++++++
> >>>>    1 file changed, 12 insertions(+)
> >>>>
> >>>> diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> >>>> index 7f2be490fcf8..6a10a35f1122 100644
> >>>> --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> >>>> +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
> >>>> @@ -441,9 +441,21 @@ static int rcar_mipi_dsi_startup(struct rcar_mipi_dsi *dsi,
> >>>>    
> >>>>    static void rcar_mipi_dsi_shutdown(struct rcar_mipi_dsi *dsi)
> >>>>    {
> >>>> +	/* Disable VCLKEN */
> >>>> +	rcar_mipi_dsi_clr(dsi, VCLKEN, VCLKEN_CKEN);
> >>>> +
> >>>> +	/* Disable DOT clock */
> >>>> +	rcar_mipi_dsi_clr(dsi, VCLKSET, VCLKSET_CKEN);
> >>>
> >>> I think you can write 0 to those two registers, this will also be safer.
> >>> With this,
> >>
> >> VCLKEN has only the single VCLKEN_CKEN bit and the rest of the bits are
> >> reserved with default value of 0, however VCLKSET has other fields and
> >> the default value of those fields is not 0.
> > 
> > But the two fields whose default value isn't 0 are set in the startup()
> > function (albeit incorrectly as discussed below), so it should be fine.
> 
> That is true. But I'd rather write 0 to VCLKEN in the startup, before 
> writing the configuration.

You can do both :-)

> >> Why do you think it's safer to set the whole register to 0? Isn't it
> >> better to just do what we want to do, which makes the purpose clear and,
> >> I think, is safer as we don't touch bits we don't know about?
> > 
> > Because it will ensure that we don't get surprises when we later restart
> > the device, such as mentioned below :-)
> 
> Well, but that's a bug in the startup code. I don't think the shutdown 
> code should do things to make startup work better if the startup does 
> something wrong. Nevertheless, while I slightly disagree, I'm fine with 
> writing zero there in shutdown.

I agree it needs to be fixed at start() time, but I think it's also good
practice to put the device in a fully known state after shutdown, at
least when it's easy to do so. It would also save an unnecessary read
access to the register.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 3/4] drm: rcar-du: fix DSI enable & disable sequence
  2022-08-22 13:05 ` [PATCH v2 3/4] drm: rcar-du: fix DSI enable & disable sequence Tomi Valkeinen
  2022-08-22 13:40   ` Laurent Pinchart
@ 2022-08-23  3:08   ` kernel test robot
  2022-08-23 19:08   ` kernel test robot
  2 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2022-08-23  3:08 UTC (permalink / raw)
  To: Tomi Valkeinen, Laurent Pinchart, Kieran Bingham, dri-devel,
	linux-renesas-soc
  Cc: llvm, kbuild-all, Tomi Valkeinen

Hi Tomi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pinchartl-media/drm/du/next]
[also build test WARNING on linus/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tomi-Valkeinen/drm-rcar-du-DSI-fixes/20220822-210756
base:   git://linuxtv.org/pinchartl/media.git drm/du/next
config: riscv-randconfig-r042-20220821 (https://download.01.org/0day-ci/archive/20220823/202208231031.hFwNDAuL-lkp@intel.com/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project abce7acebd4c06c977bc4bd79170697f1122bc5e)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/d037472981c443d699c022aa91c5335f686d82ad
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Tomi-Valkeinen/drm-rcar-du-DSI-fixes/20220822-210756
        git checkout d037472981c443d699c022aa91c5335f686d82ad
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/gpu/drm/rcar-du/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c:10:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c:10:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c:10:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:1024:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
                                                     ~~~~~~~~~~ ^
>> drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c:615:6: warning: no previous prototype for function 'rcar_mipi_dsi_pclk_enable' [-Wmissing-prototypes]
   void rcar_mipi_dsi_pclk_enable(struct drm_bridge *bridge,
        ^
   drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c:615:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void rcar_mipi_dsi_pclk_enable(struct drm_bridge *bridge,
   ^
   static 
>> drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c:654:6: warning: no previous prototype for function 'rcar_mipi_dsi_pclk_disable' [-Wmissing-prototypes]
   void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge)
        ^
   drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c:654:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge)
   ^
   static 
   9 warnings generated.


vim +/rcar_mipi_dsi_pclk_enable +615 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c

   614	
 > 615	void rcar_mipi_dsi_pclk_enable(struct drm_bridge *bridge,
   616				       struct drm_atomic_state *state)
   617	{
   618		struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
   619		const struct drm_display_mode *mode;
   620		struct drm_connector *connector;
   621		struct drm_crtc *crtc;
   622		int ret;
   623	
   624		connector = drm_atomic_get_new_connector_for_encoder(state,
   625								     bridge->encoder);
   626		crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
   627		mode = &drm_atomic_get_new_crtc_state(state, crtc)->adjusted_mode;
   628	
   629		ret = rcar_mipi_dsi_clk_enable(dsi);
   630		if (ret < 0) {
   631			dev_err(dsi->dev, "failed to enable DSI clocks\n");
   632			return;
   633		}
   634	
   635		ret = rcar_mipi_dsi_startup(dsi, mode);
   636		if (ret < 0)
   637			goto err_dsi_startup;
   638	
   639		rcar_mipi_dsi_set_display_timing(dsi, mode);
   640	
   641		ret = rcar_mipi_dsi_start_hs_clock(dsi);
   642		if (ret < 0)
   643			goto err_dsi_start_hs;
   644	
   645		return;
   646	
   647	err_dsi_start_hs:
   648		rcar_mipi_dsi_shutdown(dsi);
   649	err_dsi_startup:
   650		rcar_mipi_dsi_clk_disable(dsi);
   651	}
   652	EXPORT_SYMBOL_GPL(rcar_mipi_dsi_pclk_enable);
   653	
 > 654	void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge)
   655	{
   656		struct rcar_mipi_dsi *dsi = bridge_to_rcar_mipi_dsi(bridge);
   657	
   658		rcar_mipi_dsi_shutdown(dsi);
   659		rcar_mipi_dsi_clk_disable(dsi);
   660	}
   661	EXPORT_SYMBOL_GPL(rcar_mipi_dsi_pclk_disable);
   662	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 3/4] drm: rcar-du: fix DSI enable & disable sequence
  2022-08-22 13:05 ` [PATCH v2 3/4] drm: rcar-du: fix DSI enable & disable sequence Tomi Valkeinen
  2022-08-22 13:40   ` Laurent Pinchart
  2022-08-23  3:08   ` kernel test robot
@ 2022-08-23 19:08   ` kernel test robot
  2 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2022-08-23 19:08 UTC (permalink / raw)
  To: Tomi Valkeinen, Laurent Pinchart, Kieran Bingham, dri-devel,
	linux-renesas-soc
  Cc: kbuild-all, Tomi Valkeinen

Hi Tomi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pinchartl-media/drm/du/next]
[also build test WARNING on linus/master v6.0-rc2 next-20220823]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tomi-Valkeinen/drm-rcar-du-DSI-fixes/20220822-210756
base:   git://linuxtv.org/pinchartl/media.git drm/du/next
config: arm-defconfig (https://download.01.org/0day-ci/archive/20220824/202208240201.ss8E6NY0-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d037472981c443d699c022aa91c5335f686d82ad
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Tomi-Valkeinen/drm-rcar-du-DSI-fixes/20220822-210756
        git checkout d037472981c443d699c022aa91c5335f686d82ad
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/gpu/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from drivers/gpu/drm/rcar-du/rcar_du_crtc.c:34:
>> drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h:26:6: warning: no previous prototype for 'rcar_mipi_dsi_pclk_disable' [-Wmissing-prototypes]
      26 | void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/rcar_mipi_dsi_pclk_disable +26 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.h

    25	
  > 26	void rcar_mipi_dsi_pclk_disable(struct drm_bridge *bridge)
    27	{
    28	}
    29	#endif /* CONFIG_DRM_RCAR_MIPI_DSI */
    30	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/4] drm: rcar-du: lvds: Rename pclk enable/disable functions
  2022-08-22 13:05 ` [PATCH v2 4/4] drm: rcar-du: lvds: Rename pclk enable/disable functions Tomi Valkeinen
  2022-08-22 13:52   ` Laurent Pinchart
@ 2022-08-23 20:09   ` kernel test robot
  1 sibling, 0 replies; 20+ messages in thread
From: kernel test robot @ 2022-08-23 20:09 UTC (permalink / raw)
  To: Tomi Valkeinen, Laurent Pinchart, Kieran Bingham, dri-devel,
	linux-renesas-soc
  Cc: kbuild-all, Tomi Valkeinen

Hi Tomi,

I love your patch! Yet something to improve:

[auto build test ERROR on pinchartl-media/drm/du/next]
[also build test ERROR on linus/master v6.0-rc2 next-20220823]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tomi-Valkeinen/drm-rcar-du-DSI-fixes/20220822-210756
base:   git://linuxtv.org/pinchartl/media.git drm/du/next
config: arm-defconfig (https://download.01.org/0day-ci/archive/20220824/202208240422.wr7amM6Y-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/2c77c282d07b279cf94254b358b048d48a8a745b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Tomi-Valkeinen/drm-rcar-du-DSI-fixes/20220822-210756
        git checkout 2c77c282d07b279cf94254b358b048d48a8a745b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/gpu/drm/rcar-du/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/linkage.h:7,
                    from include/linux/kernel.h:8,
                    from include/linux/clk.h:13,
                    from drivers/gpu/drm/rcar-du/rcar_lvds.c:10:
>> drivers/gpu/drm/rcar-du/rcar_lvds.c:326:19: error: 'rcar_lvds_clk_enable' undeclared here (not in a function); did you mean 'rcar_lvds_pclk_enable'?
     326 | EXPORT_SYMBOL_GPL(rcar_lvds_clk_enable);
         |                   ^~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:98:23: note: in definition of macro '___EXPORT_SYMBOL'
      98 |         extern typeof(sym) sym;                                                 \
         |                       ^~~
   include/linux/export.h:160:41: note: in expansion of macro '__EXPORT_SYMBOL'
     160 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:164:41: note: in expansion of macro '_EXPORT_SYMBOL'
     164 | #define EXPORT_SYMBOL_GPL(sym)          _EXPORT_SYMBOL(sym, "_gpl")
         |                                         ^~~~~~~~~~~~~~
   drivers/gpu/drm/rcar-du/rcar_lvds.c:326:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
     326 | EXPORT_SYMBOL_GPL(rcar_lvds_clk_enable);
         | ^~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/rcar-du/rcar_lvds.c:341:19: error: 'rcar_lvds_clk_disable' undeclared here (not in a function); did you mean 'rcar_lvds_pclk_disable'?
     341 | EXPORT_SYMBOL_GPL(rcar_lvds_clk_disable);
         |                   ^~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:98:23: note: in definition of macro '___EXPORT_SYMBOL'
      98 |         extern typeof(sym) sym;                                                 \
         |                       ^~~
   include/linux/export.h:160:41: note: in expansion of macro '__EXPORT_SYMBOL'
     160 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:164:41: note: in expansion of macro '_EXPORT_SYMBOL'
     164 | #define EXPORT_SYMBOL_GPL(sym)          _EXPORT_SYMBOL(sym, "_gpl")
         |                                         ^~~~~~~~~~~~~~
   drivers/gpu/drm/rcar-du/rcar_lvds.c:341:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
     341 | EXPORT_SYMBOL_GPL(rcar_lvds_clk_disable);
         | ^~~~~~~~~~~~~~~~~


vim +326 drivers/gpu/drm/rcar-du/rcar_lvds.c

02f2b30032c12b Laurent Pinchart 2019-01-17  303  
02f2b30032c12b Laurent Pinchart 2019-01-17  304  /* -----------------------------------------------------------------------------
02f2b30032c12b Laurent Pinchart 2019-01-17  305   * Clock - D3/E3 only
02f2b30032c12b Laurent Pinchart 2019-01-17  306   */
02f2b30032c12b Laurent Pinchart 2019-01-17  307  
2c77c282d07b27 Tomi Valkeinen   2022-08-22  308  int rcar_lvds_pclk_enable(struct drm_bridge *bridge, unsigned long freq)
02f2b30032c12b Laurent Pinchart 2019-01-17  309  {
02f2b30032c12b Laurent Pinchart 2019-01-17  310  	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
02f2b30032c12b Laurent Pinchart 2019-01-17  311  	int ret;
02f2b30032c12b Laurent Pinchart 2019-01-17  312  
02f2b30032c12b Laurent Pinchart 2019-01-17  313  	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
02f2b30032c12b Laurent Pinchart 2019-01-17  314  		return -ENODEV;
02f2b30032c12b Laurent Pinchart 2019-01-17  315  
02f2b30032c12b Laurent Pinchart 2019-01-17  316  	dev_dbg(lvds->dev, "enabling LVDS PLL, freq=%luHz\n", freq);
02f2b30032c12b Laurent Pinchart 2019-01-17  317  
02f2b30032c12b Laurent Pinchart 2019-01-17  318  	ret = clk_prepare_enable(lvds->clocks.mod);
02f2b30032c12b Laurent Pinchart 2019-01-17  319  	if (ret < 0)
02f2b30032c12b Laurent Pinchart 2019-01-17  320  		return ret;
02f2b30032c12b Laurent Pinchart 2019-01-17  321  
02f2b30032c12b Laurent Pinchart 2019-01-17  322  	__rcar_lvds_pll_setup_d3_e3(lvds, freq, true);
02f2b30032c12b Laurent Pinchart 2019-01-17  323  
02f2b30032c12b Laurent Pinchart 2019-01-17  324  	return 0;
02f2b30032c12b Laurent Pinchart 2019-01-17  325  }
02f2b30032c12b Laurent Pinchart 2019-01-17 @326  EXPORT_SYMBOL_GPL(rcar_lvds_clk_enable);
02f2b30032c12b Laurent Pinchart 2019-01-17  327  
2c77c282d07b27 Tomi Valkeinen   2022-08-22  328  void rcar_lvds_pclk_disable(struct drm_bridge *bridge)
02f2b30032c12b Laurent Pinchart 2019-01-17  329  {
02f2b30032c12b Laurent Pinchart 2019-01-17  330  	struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
02f2b30032c12b Laurent Pinchart 2019-01-17  331  
02f2b30032c12b Laurent Pinchart 2019-01-17  332  	if (WARN_ON(!(lvds->info->quirks & RCAR_LVDS_QUIRK_EXT_PLL)))
02f2b30032c12b Laurent Pinchart 2019-01-17  333  		return;
02f2b30032c12b Laurent Pinchart 2019-01-17  334  
02f2b30032c12b Laurent Pinchart 2019-01-17  335  	dev_dbg(lvds->dev, "disabling LVDS PLL\n");
02f2b30032c12b Laurent Pinchart 2019-01-17  336  
02f2b30032c12b Laurent Pinchart 2019-01-17  337  	rcar_lvds_write(lvds, LVDPLLCR, 0);
02f2b30032c12b Laurent Pinchart 2019-01-17  338  
02f2b30032c12b Laurent Pinchart 2019-01-17  339  	clk_disable_unprepare(lvds->clocks.mod);
02f2b30032c12b Laurent Pinchart 2019-01-17  340  }
02f2b30032c12b Laurent Pinchart 2019-01-17 @341  EXPORT_SYMBOL_GPL(rcar_lvds_clk_disable);
02f2b30032c12b Laurent Pinchart 2019-01-17  342  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2022-08-23 20:33 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-22 13:05 [PATCH v2 0/4] drm: rcar-du: DSI fixes Tomi Valkeinen
2022-08-22 13:05 ` [PATCH v2 1/4] drm: rcar-du: dsi: Properly stop video mode TX Tomi Valkeinen
2022-08-22 13:12   ` Laurent Pinchart
2022-08-22 13:25   ` Biju Das
2022-08-22 14:00     ` Tomi Valkeinen
2022-08-22 14:16       ` Biju Das
2022-08-22 13:05 ` [PATCH v2 2/4] drm: rcar-du: dsi: Improve DSI shutdown Tomi Valkeinen
2022-08-22 13:20   ` Laurent Pinchart
2022-08-22 13:49     ` Tomi Valkeinen
2022-08-22 14:05       ` Laurent Pinchart
2022-08-22 14:19         ` Tomi Valkeinen
2022-08-22 14:28           ` Laurent Pinchart
2022-08-22 13:05 ` [PATCH v2 3/4] drm: rcar-du: fix DSI enable & disable sequence Tomi Valkeinen
2022-08-22 13:40   ` Laurent Pinchart
2022-08-23  3:08   ` kernel test robot
2022-08-23 19:08   ` kernel test robot
2022-08-22 13:05 ` [PATCH v2 4/4] drm: rcar-du: lvds: Rename pclk enable/disable functions Tomi Valkeinen
2022-08-22 13:52   ` Laurent Pinchart
2022-08-22 13:56     ` Tomi Valkeinen
2022-08-23 20:09   ` kernel test robot

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).