mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/8] drm/bridge: tc358762: Various small fixes
@ 2026-03-26 13:12 Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 1/8] drm/bridge: tc358762: Clean up register defines Tomi Valkeinen
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Tomi Valkeinen @ 2026-03-26 13:12 UTC (permalink / raw)
  To: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Tomi Valkeinen

While trying to get Raspberry Pi display v1.1 working on Beagleboard
platforms, I noticed various small issues with the tc358762 driver.
Unfortunately none of the fixes helped for my case, but neither did they
make the issues worse.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
Tomi Valkeinen (8):
      drm/bridge: tc358762: Clean up register defines
      drm/bridge: tc358762: Improce SYSCTRL register defines
      drm/bridge: tc358762: Improve LCDCTRL defines
      drm/bridge: tc358762: Configure SYSCTRL first
      drm/bridge: tc358762: Drop SPICMR write
      drm/bridge: tc358762: Improve DPI enable handling
      drm/bridge: tc358762: Update comment about the number of lanes
      drm/bridge: tc358762: Support VTG (but don't enable it)

 drivers/gpu/drm/bridge/tc358762.c | 125 +++++++++++++++++++++++++++++---------
 1 file changed, 96 insertions(+), 29 deletions(-)
---
base-commit: 11439c4635edd669ae435eec308f4ab8a0804808
change-id: 20260326-tc358762-fixes-6f666500da9e

Best regards,
-- 
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>


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

* [PATCH 1/8] drm/bridge: tc358762: Clean up register defines
  2026-03-26 13:12 [PATCH 0/8] drm/bridge: tc358762: Various small fixes Tomi Valkeinen
@ 2026-03-26 13:12 ` Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 2/8] drm/bridge: tc358762: Improce SYSCTRL " Tomi Valkeinen
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Tomi Valkeinen @ 2026-03-26 13:12 UTC (permalink / raw)
  To: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Tomi Valkeinen

Move the defines around and rename for clarity and consistency. No
functional change.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/bridge/tc358762.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
index 98df3e667d4a..833fd9913c75 100644
--- a/drivers/gpu/drm/bridge/tc358762.c
+++ b/drivers/gpu/drm/bridge/tc358762.c
@@ -29,17 +29,22 @@
 
 /* PPI layer registers */
 #define PPI_STARTPPI		0x0104 /* START control bit */
+#define PPI_STARTPPI_STARTPPI	BIT(0)
+
 #define PPI_LPTXTIMECNT		0x0114 /* LPTX timing signal */
 #define PPI_D0S_ATMR		0x0144
 #define PPI_D1S_ATMR		0x0148
 #define PPI_D0S_CLRSIPOCOUNT	0x0164 /* Assertion timer for Lane 0 */
 #define PPI_D1S_CLRSIPOCOUNT	0x0168 /* Assertion timer for Lane 1 */
-#define PPI_START_FUNCTION	1
 
 /* DSI layer registers */
 #define DSI_STARTDSI		0x0204 /* START control bit of DSI-TX */
+#define DSI_STARTDSI_STARTDSI	BIT(0)
+
 #define DSI_LANEENABLE		0x0210 /* Enables each lane */
-#define DSI_RX_START		1
+#define DSI_LANEENABLE_CLEN	BIT(0)
+#define DSI_LANEENABLE_L0EN	BIT(1)
+#define DSI_LANEENABLE_L1EN	BIT(2)
 
 /* LCDC/DPI Host Registers, based on guesswork that this matches TC358764 */
 #define LCDCTRL			0x0420 /* Video Path Control */
@@ -60,14 +65,8 @@
 /* System Controller Registers */
 #define SYSCTRL			0x0464
 
-/* System registers */
 #define LPX_PERIOD		3
 
-/* Lane enable PPI and DSI register bits */
-#define LANEENABLE_CLEN		BIT(0)
-#define LANEENABLE_L0EN		BIT(1)
-#define LANEENABLE_L1EN		BIT(2)
-
 struct tc358762 {
 	struct device *dev;
 	struct drm_bridge bridge;
@@ -118,7 +117,7 @@ static int tc358762_init(struct tc358762 *ctx)
 	u32 lcdctrl;
 
 	tc358762_write(ctx, DSI_LANEENABLE,
-		       LANEENABLE_L0EN | LANEENABLE_CLEN);
+		       DSI_LANEENABLE_L0EN | DSI_LANEENABLE_CLEN);
 	tc358762_write(ctx, PPI_D0S_CLRSIPOCOUNT, 5);
 	tc358762_write(ctx, PPI_D1S_CLRSIPOCOUNT, 5);
 	tc358762_write(ctx, PPI_D0S_ATMR, 0);
@@ -141,8 +140,8 @@ static int tc358762_init(struct tc358762 *ctx)
 	tc358762_write(ctx, SYSCTRL, 0x040f);
 	msleep(100);
 
-	tc358762_write(ctx, PPI_STARTPPI, PPI_START_FUNCTION);
-	tc358762_write(ctx, DSI_STARTDSI, DSI_RX_START);
+	tc358762_write(ctx, PPI_STARTPPI, PPI_STARTPPI_STARTPPI);
+	tc358762_write(ctx, DSI_STARTDSI, DSI_STARTDSI_STARTDSI);
 
 	msleep(100);
 

-- 
2.43.0


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

* [PATCH 2/8] drm/bridge: tc358762: Improce SYSCTRL register defines
  2026-03-26 13:12 [PATCH 0/8] drm/bridge: tc358762: Various small fixes Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 1/8] drm/bridge: tc358762: Clean up register defines Tomi Valkeinen
@ 2026-03-26 13:12 ` Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 3/8] drm/bridge: tc358762: Improve LCDCTRL defines Tomi Valkeinen
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Tomi Valkeinen @ 2026-03-26 13:12 UTC (permalink / raw)
  To: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Tomi Valkeinen

Define SYSCTRL fields. No functional changes.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/bridge/tc358762.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
index 833fd9913c75..9a0b1f0c18f0 100644
--- a/drivers/gpu/drm/bridge/tc358762.c
+++ b/drivers/gpu/drm/bridge/tc358762.c
@@ -64,6 +64,19 @@
 
 /* System Controller Registers */
 #define SYSCTRL			0x0464
+#define SYSCTRL_DPIDATA_IO_MASK GENMASK_U32(1, 0)
+#define SYSCTRL_DPIDATA_IO_1MA	0
+#define SYSCTRL_DPIDATA_IO_2MA	1
+#define SYSCTRL_DPIDATA_IO_3MA	2
+#define SYSCTRL_DPIDATA_IO_4MA	3
+#define SYSCTRL_DPISTB_IO_MASK	GENMASK_U32(3, 2)
+#define SYSCTRL_DPISTB_IO_1MA	0
+#define SYSCTRL_DPISTB_IO_2MA	1
+#define SYSCTRL_DPISTB_IO_3MA	2
+#define SYSCTRL_DPISTB_IO_4MA	3
+#define SYSCTRL_PCLKDIV_MASK	GENMASK_U32(11, 8)
+#define SYSCTRL_PCLKDIV_DIV_2	2
+#define SYSCTRL_PCLKDIV_DIV_3	4
 
 #define LPX_PERIOD		3
 
@@ -137,7 +150,11 @@ static int tc358762_init(struct tc358762 *ctx)
 
 	tc358762_write(ctx, LCDCTRL, lcdctrl);
 
-	tc358762_write(ctx, SYSCTRL, 0x040f);
+	tc358762_write(ctx, SYSCTRL,
+		       FIELD_PREP(SYSCTRL_DPIDATA_IO_MASK, SYSCTRL_DPIDATA_IO_4MA) |
+		       FIELD_PREP(SYSCTRL_DPISTB_IO_MASK, SYSCTRL_DPISTB_IO_4MA) |
+		       FIELD_PREP(SYSCTRL_PCLKDIV_MASK, SYSCTRL_PCLKDIV_DIV_3));
+
 	msleep(100);
 
 	tc358762_write(ctx, PPI_STARTPPI, PPI_STARTPPI_STARTPPI);

-- 
2.43.0


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

* [PATCH 3/8] drm/bridge: tc358762: Improve LCDCTRL defines
  2026-03-26 13:12 [PATCH 0/8] drm/bridge: tc358762: Various small fixes Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 1/8] drm/bridge: tc358762: Clean up register defines Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 2/8] drm/bridge: tc358762: Improce SYSCTRL " Tomi Valkeinen
@ 2026-03-26 13:12 ` Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 4/8] drm/bridge: tc358762: Configure SYSCTRL first Tomi Valkeinen
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Tomi Valkeinen @ 2026-03-26 13:12 UTC (permalink / raw)
  To: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Tomi Valkeinen

LCDCTRL fields are quite wrong in the driver. Fix the field defines.

A few notes about the wrong fields:

LCDCTRL_VSDELAY(1) actually sets LCDCTRL_DCLK_POL
LCDCTRL_UNK6 | LCDCTRL_VTGEN actually set LCDCTRL_PXLFORM_RGB888
LCDCTRL_RGB888 actually sets LCDCTRL_DPI_EN

The total still resulted in a working display even if the defines were
quite wrong.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/bridge/tc358762.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
index 9a0b1f0c18f0..cbedffb7a705 100644
--- a/drivers/gpu/drm/bridge/tc358762.c
+++ b/drivers/gpu/drm/bridge/tc358762.c
@@ -46,17 +46,22 @@
 #define DSI_LANEENABLE_L0EN	BIT(1)
 #define DSI_LANEENABLE_L1EN	BIT(2)
 
-/* LCDC/DPI Host Registers, based on guesswork that this matches TC358764 */
+/* LCDC/DPI Registers */
 #define LCDCTRL			0x0420 /* Video Path Control */
 #define LCDCTRL_MSF		BIT(0) /* Magic square in RGB666 */
-#define LCDCTRL_VTGEN		BIT(4)/* Use chip clock for timing */
-#define LCDCTRL_UNK6		BIT(6) /* Unknown */
-#define LCDCTRL_EVTMODE		BIT(5) /* Event mode */
-#define LCDCTRL_RGB888		BIT(8) /* RGB888 mode */
-#define LCDCTRL_HSPOL		BIT(17) /* Polarity of HSYNC signal */
-#define LCDCTRL_DEPOL		BIT(18) /* Polarity of DE signal */
-#define LCDCTRL_VSPOL		BIT(19) /* Polarity of VSYNC signal */
-#define LCDCTRL_VSDELAY(v)	(((v) & 0xfff) << 20) /* VSYNC delay */
+#define LCDCTRL_VTGEN		BIT(1) /* Use chip clock for timing */
+#define LCDCTRL_PXLFORM		GENMASK_U32(6, 4)
+#define LCDCTRL_PXLFORM_RGB666		0	/* x:R:G:B 6:8:8:8 */
+#define LCDCTRL_PXLFORM_RGB666_24	1	/* x:R:x:G:x:B 2:6:2:6:2:6 */
+#define LCDCTRL_PXLFORM_RGB565		2	/* x:R:G:B 8:5:6:5 */
+#define LCDCTRL_PXLFORM_RGB565_1	3	/* x:R:x:G:x:B 3:5:2:6:3:5 */
+#define LCDCTRL_PXLFORM_RGB565_2	4	/* x:R:x:G:x:B:x 2:5:3:6:2:5:1 */
+#define LCDCTRL_PXLFORM_RGB888		5	/* R:G:B 8:8:8 */
+#define LCDCTRL_DPI_EN		BIT(8)
+#define LCDCTRL_HSYNC_POL	BIT(17) /* Polarity of HSYNC signal */
+#define LCDCTRL_DE_POL		BIT(18) /* Polarity of DE signal */
+#define LCDCTRL_VSYNC_POL	BIT(19) /* Polarity of VSYNC signal */
+#define LCDCTRL_DCLK_POL	BIT(20) /* Polarity of pixel clock */
 
 /* SPI Master Registers */
 #define SPICMR			0x0450
@@ -139,14 +144,16 @@ static int tc358762_init(struct tc358762 *ctx)
 
 	tc358762_write(ctx, SPICMR, 0x00);
 
-	lcdctrl = LCDCTRL_VSDELAY(1) | LCDCTRL_RGB888 |
-		  LCDCTRL_UNK6 | LCDCTRL_VTGEN;
+	lcdctrl = FIELD_PREP(LCDCTRL_PXLFORM, LCDCTRL_PXLFORM_RGB888) |
+		  LCDCTRL_DPI_EN;
+
+	lcdctrl |= LCDCTRL_DCLK_POL;
 
 	if (ctx->mode.flags & DRM_MODE_FLAG_NHSYNC)
-		lcdctrl |= LCDCTRL_HSPOL;
+		lcdctrl |= LCDCTRL_HSYNC_POL;
 
 	if (ctx->mode.flags & DRM_MODE_FLAG_NVSYNC)
-		lcdctrl |= LCDCTRL_VSPOL;
+		lcdctrl |= LCDCTRL_VSYNC_POL;
 
 	tc358762_write(ctx, LCDCTRL, lcdctrl);
 

-- 
2.43.0


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

* [PATCH 4/8] drm/bridge: tc358762: Configure SYSCTRL first
  2026-03-26 13:12 [PATCH 0/8] drm/bridge: tc358762: Various small fixes Tomi Valkeinen
                   ` (2 preceding siblings ...)
  2026-03-26 13:12 ` [PATCH 3/8] drm/bridge: tc358762: Improve LCDCTRL defines Tomi Valkeinen
@ 2026-03-26 13:12 ` Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 5/8] drm/bridge: tc358762: Drop SPICMR write Tomi Valkeinen
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Tomi Valkeinen @ 2026-03-26 13:12 UTC (permalink / raw)
  To: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Tomi Valkeinen

SYSCTRL affects the DPI output and the clock tree, but we configure it
late, when the DPI output is already enabled and clocks are running.

Move the SYSCTRL configuration to the beginning, before anything is
enabled.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/bridge/tc358762.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
index cbedffb7a705..053579591dba 100644
--- a/drivers/gpu/drm/bridge/tc358762.c
+++ b/drivers/gpu/drm/bridge/tc358762.c
@@ -134,6 +134,13 @@ static int tc358762_init(struct tc358762 *ctx)
 {
 	u32 lcdctrl;
 
+	tc358762_write(ctx, SYSCTRL,
+		       FIELD_PREP(SYSCTRL_DPIDATA_IO_MASK, SYSCTRL_DPIDATA_IO_4MA) |
+		       FIELD_PREP(SYSCTRL_DPISTB_IO_MASK, SYSCTRL_DPISTB_IO_4MA) |
+		       FIELD_PREP(SYSCTRL_PCLKDIV_MASK, SYSCTRL_PCLKDIV_DIV_3));
+
+	msleep(100);
+
 	tc358762_write(ctx, DSI_LANEENABLE,
 		       DSI_LANEENABLE_L0EN | DSI_LANEENABLE_CLEN);
 	tc358762_write(ctx, PPI_D0S_CLRSIPOCOUNT, 5);
@@ -157,13 +164,6 @@ static int tc358762_init(struct tc358762 *ctx)
 
 	tc358762_write(ctx, LCDCTRL, lcdctrl);
 
-	tc358762_write(ctx, SYSCTRL,
-		       FIELD_PREP(SYSCTRL_DPIDATA_IO_MASK, SYSCTRL_DPIDATA_IO_4MA) |
-		       FIELD_PREP(SYSCTRL_DPISTB_IO_MASK, SYSCTRL_DPISTB_IO_4MA) |
-		       FIELD_PREP(SYSCTRL_PCLKDIV_MASK, SYSCTRL_PCLKDIV_DIV_3));
-
-	msleep(100);
-
 	tc358762_write(ctx, PPI_STARTPPI, PPI_STARTPPI_STARTPPI);
 	tc358762_write(ctx, DSI_STARTDSI, DSI_STARTDSI_STARTDSI);
 

-- 
2.43.0


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

* [PATCH 5/8] drm/bridge: tc358762: Drop SPICMR write
  2026-03-26 13:12 [PATCH 0/8] drm/bridge: tc358762: Various small fixes Tomi Valkeinen
                   ` (3 preceding siblings ...)
  2026-03-26 13:12 ` [PATCH 4/8] drm/bridge: tc358762: Configure SYSCTRL first Tomi Valkeinen
@ 2026-03-26 13:12 ` Tomi Valkeinen
  2026-03-26 15:13   ` Dave Stevenson
  2026-03-26 13:12 ` [PATCH 6/8] drm/bridge: tc358762: Improve DPI enable handling Tomi Valkeinen
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: Tomi Valkeinen @ 2026-03-26 13:12 UTC (permalink / raw)
  To: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Tomi Valkeinen

Drop write to SPICMR. It's unclear why the write is there, and it's
mostly just writing zeroes to already zero fields (reset defaults).

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/bridge/tc358762.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
index 053579591dba..52e2f3a73721 100644
--- a/drivers/gpu/drm/bridge/tc358762.c
+++ b/drivers/gpu/drm/bridge/tc358762.c
@@ -149,8 +149,6 @@ static int tc358762_init(struct tc358762 *ctx)
 	tc358762_write(ctx, PPI_D1S_ATMR, 0);
 	tc358762_write(ctx, PPI_LPTXTIMECNT, LPX_PERIOD);
 
-	tc358762_write(ctx, SPICMR, 0x00);
-
 	lcdctrl = FIELD_PREP(LCDCTRL_PXLFORM, LCDCTRL_PXLFORM_RGB888) |
 		  LCDCTRL_DPI_EN;
 

-- 
2.43.0


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

* [PATCH 6/8] drm/bridge: tc358762: Improve DPI enable handling
  2026-03-26 13:12 [PATCH 0/8] drm/bridge: tc358762: Various small fixes Tomi Valkeinen
                   ` (4 preceding siblings ...)
  2026-03-26 13:12 ` [PATCH 5/8] drm/bridge: tc358762: Drop SPICMR write Tomi Valkeinen
@ 2026-03-26 13:12 ` Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 7/8] drm/bridge: tc358762: Update comment about the number of lanes Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 8/8] drm/bridge: tc358762: Support VTG (but don't enable it) Tomi Valkeinen
  7 siblings, 0 replies; 11+ messages in thread
From: Tomi Valkeinen @ 2026-03-26 13:12 UTC (permalink / raw)
  To: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Tomi Valkeinen

The HW reset defaults has DPIENABLE bit as set. In the current driver we
configure and enable various things while DPIENABLE is set. This results
in a temporary DPI output with wrong timings, which may cause artifacts
on the panel.

Fix this by clearing DPIEANBLE as the first thing when we start to
enable the display. DPIENABLE is set later with the rest of the LCDCTRL
configuration, and at that time we have done all the other
configurations.

Also, for symmetry and possibly improving the DPI output at disable
time, explicitly disable DPIENABLE when disabling the bridge.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/bridge/tc358762.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
index 52e2f3a73721..cc1c5ff42cbd 100644
--- a/drivers/gpu/drm/bridge/tc358762.c
+++ b/drivers/gpu/drm/bridge/tc358762.c
@@ -134,6 +134,12 @@ static int tc358762_init(struct tc358762 *ctx)
 {
 	u32 lcdctrl;
 
+	/*
+	 * DPIENABLE has reset default of 1. Make sure we don't output on
+	 * DPI until we have finished the coniguration.
+	 */
+	tc358762_write(ctx, LCDCTRL, 0);
+
 	tc358762_write(ctx, SYSCTRL,
 		       FIELD_PREP(SYSCTRL_DPIDATA_IO_MASK, SYSCTRL_DPIDATA_IO_4MA) |
 		       FIELD_PREP(SYSCTRL_DPISTB_IO_MASK, SYSCTRL_DPISTB_IO_4MA) |
@@ -185,6 +191,9 @@ static void tc358762_post_disable(struct drm_bridge *bridge,
 
 	ctx->pre_enabled = false;
 
+	/* Turn off the DPI output */
+	tc358762_write(ctx, LCDCTRL, 0);
+
 	if (ctx->reset_gpio)
 		gpiod_set_value_cansleep(ctx->reset_gpio, 0);
 

-- 
2.43.0


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

* [PATCH 7/8] drm/bridge: tc358762: Update comment about the number of lanes
  2026-03-26 13:12 [PATCH 0/8] drm/bridge: tc358762: Various small fixes Tomi Valkeinen
                   ` (5 preceding siblings ...)
  2026-03-26 13:12 ` [PATCH 6/8] drm/bridge: tc358762: Improve DPI enable handling Tomi Valkeinen
@ 2026-03-26 13:12 ` Tomi Valkeinen
  2026-03-26 13:12 ` [PATCH 8/8] drm/bridge: tc358762: Support VTG (but don't enable it) Tomi Valkeinen
  7 siblings, 0 replies; 11+ messages in thread
From: Tomi Valkeinen @ 2026-03-26 13:12 UTC (permalink / raw)
  To: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Tomi Valkeinen

Update comment about the number of lanes.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/bridge/tc358762.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
index cc1c5ff42cbd..9fb921b3fa0d 100644
--- a/drivers/gpu/drm/bridge/tc358762.c
+++ b/drivers/gpu/drm/bridge/tc358762.c
@@ -305,7 +305,14 @@ static int tc358762_probe(struct mipi_dsi_device *dsi)
 	ctx->dev = dev;
 	ctx->pre_enabled = false;
 
-	/* TODO: Find out how to get dual-lane mode working */
+	/*
+	 * When using DSI clk for pixel clock (only mode supported in the driver),
+	 * the pclk is derived directly from the DSI byteclk via simple divider,
+	 * which is either 2 or 3.
+	 * The required divider can be calculated with bitspp / 8 / nlanes. Thus,
+	 * for RGB888, only nlanes = 1 works as nlanes = 2 would require divider
+	 * of 1.5.
+	 */
 	dsi->lanes = 1;
 	dsi->format = MIPI_DSI_FMT_RGB888;
 	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |

-- 
2.43.0


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

* [PATCH 8/8] drm/bridge: tc358762: Support VTG (but don't enable it)
  2026-03-26 13:12 [PATCH 0/8] drm/bridge: tc358762: Various small fixes Tomi Valkeinen
                   ` (6 preceding siblings ...)
  2026-03-26 13:12 ` [PATCH 7/8] drm/bridge: tc358762: Update comment about the number of lanes Tomi Valkeinen
@ 2026-03-26 13:12 ` Tomi Valkeinen
  7 siblings, 0 replies; 11+ messages in thread
From: Tomi Valkeinen @ 2026-03-26 13:12 UTC (permalink / raw)
  To: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: dri-devel, linux-kernel, Tomi Valkeinen

TC358762 can generate the DPI output's timings in two ways, either Video
Timings Generator (VTG) on or off:
- VTG off: Duplicate the timings coming from the DSI. This requires DSI
  pulse mode.
- VTG on: Sync frame on DSI VSync Start, but the exact output timings
  are defined in TC358762 registers. This can be used with DSI
  event/burst mode.

We are currently using VTG off in the driver. Add the scaffolding for
VTG mode, by adding "use_vtg" field, and configuring the timings if that
is set. For now "use_vtg" is always off, so this is mostly for
testing/debugging purposes, or basis for future work.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/bridge/tc358762.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
index 9fb921b3fa0d..ab1dd36468f4 100644
--- a/drivers/gpu/drm/bridge/tc358762.c
+++ b/drivers/gpu/drm/bridge/tc358762.c
@@ -18,6 +18,7 @@
 #include <linux/regulator/consumer.h>
 
 #include <video/mipi_display.h>
+#include <video/videomode.h>
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
@@ -63,6 +64,12 @@
 #define LCDCTRL_VSYNC_POL	BIT(19) /* Polarity of VSYNC signal */
 #define LCDCTRL_DCLK_POL	BIT(20) /* Polarity of pixel clock */
 
+#define LCDC_HSR_HBPR		0x0424
+#define LCDC_HDISPR_HFPR	0x0428
+#define LCDC_VSR_VBPR		0x042C
+#define LCDC_VDISPR_VFPR	0x0430
+#define LCDC_VFUEN		0x0434
+
 /* SPI Master Registers */
 #define SPICMR			0x0450
 #define SPITCR			0x0454
@@ -94,6 +101,7 @@ struct tc358762 {
 	struct drm_display_mode mode;
 	bool pre_enabled;
 	int error;
+	bool use_vtg;
 };
 
 static int tc358762_clear_error(struct tc358762 *ctx)
@@ -155,9 +163,31 @@ static int tc358762_init(struct tc358762 *ctx)
 	tc358762_write(ctx, PPI_D1S_ATMR, 0);
 	tc358762_write(ctx, PPI_LPTXTIMECNT, LPX_PERIOD);
 
+	if (ctx->use_vtg) {
+		struct videomode vm = { 0 };
+
+		drm_display_mode_to_videomode(&ctx->mode, &vm);
+
+		tc358762_write(ctx, LCDC_HSR_HBPR,
+			       vm.hsync_len | (vm.hback_porch << 16));
+		tc358762_write(ctx, LCDC_HDISPR_HFPR,
+			       vm.hactive | (vm.hfront_porch << 16));
+
+		tc358762_write(ctx, LCDC_VSR_VBPR,
+			       vm.vsync_len | (vm.vback_porch << 16));
+		tc358762_write(ctx, LCDC_VDISPR_VFPR,
+			       vm.vactive | (vm.vfront_porch << 16));
+
+		/* Upload VTG timings */
+		tc358762_write(ctx, LCDC_VFUEN, BIT(0));
+	}
+
 	lcdctrl = FIELD_PREP(LCDCTRL_PXLFORM, LCDCTRL_PXLFORM_RGB888) |
 		  LCDCTRL_DPI_EN;
 
+	if (ctx->use_vtg)
+		lcdctrl |= LCDCTRL_VTGEN;
+
 	lcdctrl |= LCDCTRL_DCLK_POL;
 
 	if (ctx->mode.flags & DRM_MODE_FLAG_NHSYNC)

-- 
2.43.0


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

* Re: [PATCH 5/8] drm/bridge: tc358762: Drop SPICMR write
  2026-03-26 13:12 ` [PATCH 5/8] drm/bridge: tc358762: Drop SPICMR write Tomi Valkeinen
@ 2026-03-26 15:13   ` Dave Stevenson
  2026-03-26 15:24     ` Tomi Valkeinen
  0 siblings, 1 reply; 11+ messages in thread
From: Dave Stevenson @ 2026-03-26 15:13 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-kernel

Hi Tomi

On Thu, 26 Mar 2026 at 13:13, Tomi Valkeinen
<tomi.valkeinen@ideasonboard.com> wrote:
>
> Drop write to SPICMR. It's unclear why the write is there, and it's
> mostly just writing zeroes to already zero fields (reset defaults).

What version of the datasheet are you working from? I have 1.41 from Nov 2013.

Offset 0x0450 bits 15:0 is register SPICTRL. All those bits do default to 0.
Offset 0x0450 bits 31:16 is register SPIRCMR, with clkmask in bits
25:16. The table says the default for that field is 0x3ff, but the
description says "0 (default) to 1023".

Changelog 1.17, July 2009 - "changed clkmask default to 'h3ff".

The SPI output of the chip isn't used on the Pi display, but it is in
DPI mode which defaults to sending commands out the port. I haven't
read the whole datasheet to work out the mechanism for sending SPI
commands to determine if it relevant at all.

  Dave

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  drivers/gpu/drm/bridge/tc358762.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
> index 053579591dba..52e2f3a73721 100644
> --- a/drivers/gpu/drm/bridge/tc358762.c
> +++ b/drivers/gpu/drm/bridge/tc358762.c
> @@ -149,8 +149,6 @@ static int tc358762_init(struct tc358762 *ctx)
>         tc358762_write(ctx, PPI_D1S_ATMR, 0);
>         tc358762_write(ctx, PPI_LPTXTIMECNT, LPX_PERIOD);
>
> -       tc358762_write(ctx, SPICMR, 0x00);
> -
>         lcdctrl = FIELD_PREP(LCDCTRL_PXLFORM, LCDCTRL_PXLFORM_RGB888) |
>                   LCDCTRL_DPI_EN;
>
>
> --
> 2.43.0
>

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

* Re: [PATCH 5/8] drm/bridge: tc358762: Drop SPICMR write
  2026-03-26 15:13   ` Dave Stevenson
@ 2026-03-26 15:24     ` Tomi Valkeinen
  0 siblings, 0 replies; 11+ messages in thread
From: Tomi Valkeinen @ 2026-03-26 15:24 UTC (permalink / raw)
  To: Dave Stevenson
  Cc: Marek Vasut, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-kernel

Hi,

On 26/03/2026 17:13, Dave Stevenson wrote:
> Hi Tomi
> 
> On Thu, 26 Mar 2026 at 13:13, Tomi Valkeinen
> <tomi.valkeinen@ideasonboard.com> wrote:
>>
>> Drop write to SPICMR. It's unclear why the write is there, and it's
>> mostly just writing zeroes to already zero fields (reset defaults).
> 
> What version of the datasheet are you working from? I have 1.41 from Nov 2013.

I have Rev 1.36.

> Offset 0x0450 bits 15:0 is register SPICTRL. All those bits do default to 0.
> Offset 0x0450 bits 31:16 is register SPIRCMR, with clkmask in bits
> 25:16. The table says the default for that field is 0x3ff, but the
> description says "0 (default) to 1023".

Yes, the mask (possibly) has a non-zero reset value (that's why I said
"mostly").

> Changelog 1.17, July 2009 - "changed clkmask default to 'h3ff".
> 
> The SPI output of the chip isn't used on the Pi display, but it is in
> DPI mode which defaults to sending commands out the port. I haven't
> read the whole datasheet to work out the mechanism for sending SPI
> commands to determine if it relevant at all.

I haven't studied the SPI support, but afaics it requires explicit
support in the driver. Which we don't have. So we only have this one odd
write to an SPI register, which, afaics, doesn't do anything like
"disable this unused feature" or such.

So I thought we can drop it as it's just confusing the reader there. If
there indeed is some use for it, or if removing the write has some side
effect, we can definitely keep it.

 Tomi

>   Dave
> 
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>> ---
>>  drivers/gpu/drm/bridge/tc358762.c | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
>> index 053579591dba..52e2f3a73721 100644
>> --- a/drivers/gpu/drm/bridge/tc358762.c
>> +++ b/drivers/gpu/drm/bridge/tc358762.c
>> @@ -149,8 +149,6 @@ static int tc358762_init(struct tc358762 *ctx)
>>         tc358762_write(ctx, PPI_D1S_ATMR, 0);
>>         tc358762_write(ctx, PPI_LPTXTIMECNT, LPX_PERIOD);
>>
>> -       tc358762_write(ctx, SPICMR, 0x00);
>> -
>>         lcdctrl = FIELD_PREP(LCDCTRL_PXLFORM, LCDCTRL_PXLFORM_RGB888) |
>>                   LCDCTRL_DPI_EN;
>>
>>
>> --
>> 2.43.0
>>


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

end of thread, other threads:[~2026-03-26 15:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-26 13:12 [PATCH 0/8] drm/bridge: tc358762: Various small fixes Tomi Valkeinen
2026-03-26 13:12 ` [PATCH 1/8] drm/bridge: tc358762: Clean up register defines Tomi Valkeinen
2026-03-26 13:12 ` [PATCH 2/8] drm/bridge: tc358762: Improce SYSCTRL " Tomi Valkeinen
2026-03-26 13:12 ` [PATCH 3/8] drm/bridge: tc358762: Improve LCDCTRL defines Tomi Valkeinen
2026-03-26 13:12 ` [PATCH 4/8] drm/bridge: tc358762: Configure SYSCTRL first Tomi Valkeinen
2026-03-26 13:12 ` [PATCH 5/8] drm/bridge: tc358762: Drop SPICMR write Tomi Valkeinen
2026-03-26 15:13   ` Dave Stevenson
2026-03-26 15:24     ` Tomi Valkeinen
2026-03-26 13:12 ` [PATCH 6/8] drm/bridge: tc358762: Improve DPI enable handling Tomi Valkeinen
2026-03-26 13:12 ` [PATCH 7/8] drm/bridge: tc358762: Update comment about the number of lanes Tomi Valkeinen
2026-03-26 13:12 ` [PATCH 8/8] drm/bridge: tc358762: Support VTG (but don't enable it) Tomi Valkeinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®