Skip to contentSkip to conversation

drm/bridge: imx: Add i.MX93 MIPI DSI support

PATCH Superseded Liu Ying 8 participants 33 messages Jul 17, 2023 – Oct 17, 2023

Subsystems (6)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Liu Ying

author maintainer
#0 lore raw

cover drm/bridge: imx: Add i.MX93 MIPI DSI support

Hi,

This series aims to add MIPI DSI support for Freescale i.MX93 SoC.

There is a Synopsys DesignWare MIPI DSI host controller and a Synopsys Designware MIPI DPHY embedded in i.MX93. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

Note that since this series touches the dw-mipi-dsi driver, tests are needed to be done for meson, rockchip and stm.

Patch 1 ~ 7 do preparation work for adding i.MX93 MIPI DSI DRM bridge driver.

Patch 8 adds DT-binding documentation for i.MX93 MIPI DSI.

Patch 9 adds i.MX93 MIPI DSI DRM bridge.

Liu Ying (9):
drm/bridge: synopsys: dw-mipi-dsi: Add dw_mipi_dsi_get_bridge() helper drm/bridge: synopsys: dw-mipi-dsi: Add input bus format negotiation
support
drm/bridge: synopsys: dw-mipi-dsi: Force input bus flags drm/bridge: synopsys: dw-mipi-dsi: Add mode fixup support drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate
lbcc
drm/bridge: synopsys: dw-mipi-dsi: Set minimum lane byte clock cycles
for HSA and HBP
drm/bridge: synopsys: dw-mipi-dsi: Disable HSTX and LPRX timeout check
dt-bindings: display: bridge: Document Freescale i.MX93 MIPI DSI drm/bridge: imx: Add i.MX93 MIPI DSI support

 .../display/bridge/fsl,imx93-mipi-dsi.yaml    | 115 +++
 drivers/gpu/drm/bridge/imx/Kconfig            |  10 +
 drivers/gpu/drm/bridge/imx/Makefile           |   1 +
 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c   | 934 ++++++++++++++++++
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c |  91 +-
 include/drm/bridge/dw_mipi_dsi.h              |  16 +
 6 files changed, 1163 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/fsl,imx93-mipi-dsi.yaml
 create mode 100644 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c
Signature · 1 line
2.37.1
author maintainer
#1 lore raw

PATCH 1/9 drm/bridge: synopsys: dw-mipi-dsi: Add dw_mipi_dsi_get_bridge() helper

Add dw_mipi_dsi_get_bridge() helper so that it can be used by vendor drivers which implement vendor specific extensions to Synopsys DW MIPI DSI.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 6 ++++++
 include/drm/bridge/dw_mipi_dsi.h              | 2 ++
 2 files changed, 8 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +6 -0
index b2efecf7d160..57eae0fdd970 100644
@@ -1207,6 +1207,12 @@ void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave)
 }
 EXPORT_SYMBOL_GPL(dw_mipi_dsi_set_slave);
 
+struct drm_bridge *dw_mipi_dsi_get_bridge(struct dw_mipi_dsi *dsi)
+{
+	return &dsi->bridge;
+}
+EXPORT_SYMBOL_GPL(dw_mipi_dsi_get_bridge);
+
 /*
  * Probe/remove API, used from platforms based on the DRM bridge API.
  */
include/drm/bridge/dw_mipi_dsi.h +2 -0
index 5286a53a1875..f54621b17a69 100644
@@ -11,6 +11,7 @@
 
 #include <linux/types.h>
 
+#include <drm/drm_bridge.h>
 #include <drm/drm_modes.h>
 
 struct drm_display_mode;
@@ -68,5 +69,6 @@ void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi);
 int dw_mipi_dsi_bind(struct dw_mipi_dsi *dsi, struct drm_encoder *encoder);
 void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi);
 void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave);
+struct drm_bridge *dw_mipi_dsi_get_bridge(struct dw_mipi_dsi *dsi);
 
 #endif /* __DW_MIPI_DSI__ */
Signature · 1 line
2.37.1
author maintainer
#2 lore raw

PATCH 2/9 drm/bridge: synopsys: dw-mipi-dsi: Add input bus format negotiation support

In reply to Liu Ying

Introduce ->get_input_bus_fmts() callback to struct dw_mipi_dsi_plat_data so that vendor drivers can implement specific methods to get input bus formats for Synopsys DW MIPI DSI.

While at it, implement a generic callback for ->atomic_get_input_bus_fmts(), where we try to get the input bus formats through pdata->get_input_bus_fmts() first. If it's unavailable, fall back to the only format - MEDIA_BUS_FMT_FIXED, which matches the default behavior if ->atomic_get_input_bus_fmts() is not implemented as ->atomic_get_input_bus_fmts()'s kerneldoc indicates.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 30 +++++++++++++++++++
 include/drm/bridge/dw_mipi_dsi.h              | 11 +++++++
 2 files changed, 41 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +30 -0
index 57eae0fdd970..8580b8a97fb1 100644
@@ -12,6 +12,7 @@
 #include <linux/component.h>
 #include <linux/debugfs.h>
 #include <linux/iopoll.h>
+#include <linux/media-bus-format.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
 #include <linux/pm_runtime.h>
@@ -536,6 +537,34 @@ static const struct mipi_dsi_host_ops dw_mipi_dsi_host_ops = {
 	.transfer = dw_mipi_dsi_host_transfer,
 };
 
+static u32 *
+dw_mipi_dsi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
+					     struct drm_bridge_state *bridge_state,
+					     struct drm_crtc_state *crtc_state,
+					     struct drm_connector_state *conn_state,
+					     u32 output_fmt,
+					     unsigned int *num_input_fmts)
+{
+	struct dw_mipi_dsi *dsi = bridge_to_dsi(bridge);
+	const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data;
+	u32 *input_fmts;
+
+	if (pdata->get_input_bus_fmts)
+		return pdata->get_input_bus_fmts(pdata->priv_data,
+						 bridge, bridge_state,
+						 crtc_state, conn_state,
+						 output_fmt, num_input_fmts);
+
+	/* Fall back to MEDIA_BUS_FMT_FIXED as the only input format. */
+	input_fmts = kmalloc(sizeof(*input_fmts), GFP_KERNEL);
+	if (!input_fmts)
+		return NULL;
+	input_fmts[0] = MEDIA_BUS_FMT_FIXED;
+	*num_input_fmts = 1;
+
+	return input_fmts;
+}
+
 static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
 {
 	u32 val;
@@ -1003,6 +1032,7 @@ static int dw_mipi_dsi_bridge_attach(struct drm_bridge *bridge,
 static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
 	.atomic_duplicate_state	= drm_atomic_helper_bridge_duplicate_state,
 	.atomic_destroy_state	= drm_atomic_helper_bridge_destroy_state,
+	.atomic_get_input_bus_fmts = dw_mipi_dsi_bridge_atomic_get_input_bus_fmts,
 	.atomic_reset		= drm_atomic_helper_bridge_reset,
 	.atomic_enable		= dw_mipi_dsi_bridge_atomic_enable,
 	.atomic_post_disable	= dw_mipi_dsi_bridge_post_atomic_disable,
include/drm/bridge/dw_mipi_dsi.h +11 -0
index f54621b17a69..246650f2814f 100644
@@ -11,7 +11,10 @@
 
 #include <linux/types.h>
 
+#include <drm/drm_atomic.h>
 #include <drm/drm_bridge.h>
+#include <drm/drm_connector.h>
+#include <drm/drm_crtc.h>
 #include <drm/drm_modes.h>
 
 struct drm_display_mode;
@@ -56,6 +59,14 @@ struct dw_mipi_dsi_plat_data {
 					   unsigned long mode_flags,
 					   u32 lanes, u32 format);
 
+	u32 *(*get_input_bus_fmts)(void *priv_data,
+				   struct drm_bridge *bridge,
+				   struct drm_bridge_state *bridge_state,
+				   struct drm_crtc_state *crtc_state,
+				   struct drm_connector_state *conn_state,
+				   u32 output_fmt,
+				   unsigned int *num_input_fmts);
+
 	const struct dw_mipi_dsi_phy_ops *phy_ops;
 	const struct dw_mipi_dsi_host_ops *host_ops;
 
Signature · 1 line
2.37.1
author maintainer
#3 lore raw

PATCH 3/9 drm/bridge: synopsys: dw-mipi-dsi: Force input bus flags

In reply to Liu Ying

The DATAEN_ACTIVE_LOW bit in DSI_DPI_CFG_POL register is set to zero, so set the DRM_BUS_FLAG_DE_HIGH flag in input_bus_cfg.flags. It appears that the DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE flag also makes sense, so set it in input_bus_cfg.flags too. With this patch, the flags set by drm_atomic_bridge_propagate_bus_flags() are overridden (see comment in that function) in case any downstream bridges propagates invalid flags to this bridge. A real problematic case is to connect a RM67191 MIPI DSI panel whose driver sets DRM_BUS_FLAG_DE_LOW and DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE bus flags.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +13 -0
index 8580b8a97fb1..8cd89a63b5f2 100644
@@ -23,6 +23,7 @@
 #include <drm/bridge/dw_mipi_dsi.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
+#include <drm/drm_connector.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_modes.h>
@@ -565,6 +566,17 @@ dw_mipi_dsi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
 	return input_fmts;
 }
 
+static int dw_mipi_dsi_bridge_atomic_check(struct drm_bridge *bridge,
+					   struct drm_bridge_state *bridge_state,
+					   struct drm_crtc_state *crtc_state,
+					   struct drm_connector_state *conn_state)
+{
+	bridge_state->input_bus_cfg.flags =
+		DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE;
+
+	return 0;
+}
+
 static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
 {
 	u32 val;
@@ -1033,6 +1045,7 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
 	.atomic_duplicate_state	= drm_atomic_helper_bridge_duplicate_state,
 	.atomic_destroy_state	= drm_atomic_helper_bridge_destroy_state,
 	.atomic_get_input_bus_fmts = dw_mipi_dsi_bridge_atomic_get_input_bus_fmts,
+	.atomic_check		= dw_mipi_dsi_bridge_atomic_check,
 	.atomic_reset		= drm_atomic_helper_bridge_reset,
 	.atomic_enable		= dw_mipi_dsi_bridge_atomic_enable,
 	.atomic_post_disable	= dw_mipi_dsi_bridge_post_atomic_disable,
Signature · 1 line
2.37.1
author maintainer
#4 lore raw

PATCH 4/9 drm/bridge: synopsys: dw-mipi-dsi: Add mode fixup support

In reply to Liu Ying

Vendor drivers may need to fixup mode due to pixel clock tree limitation, so introduce the ->mode_fixup() callcack to struct dw_mipi_dsi_plat_data and call it at atomic check stage if available.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 14 ++++++++++++++
 include/drm/bridge/dw_mipi_dsi.h              |  3 +++
 2 files changed, 17 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +14 -0
index 8cd89a63b5f2..c754d55f71d1 100644
@@ -571,9 +571,23 @@ static int dw_mipi_dsi_bridge_atomic_check(struct drm_bridge *bridge,
 					   struct drm_crtc_state *crtc_state,
 					   struct drm_connector_state *conn_state)
 {
+	struct dw_mipi_dsi *dsi = bridge_to_dsi(bridge);
+	const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data;
+	bool ret;
+
 	bridge_state->input_bus_cfg.flags =
 		DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE;
 
+	if (pdata->mode_fixup) {
+		ret = pdata->mode_fixup(pdata->priv_data, &crtc_state->mode,
+					&crtc_state->adjusted_mode);
+		if (!ret) {
+			DRM_DEBUG_DRIVER("failed to fixup mode " DRM_MODE_FMT "\n",
+					 DRM_MODE_ARG(&crtc_state->mode));
+			return -EINVAL;
+		}
+	}
+
 	return 0;
 }
 
include/drm/bridge/dw_mipi_dsi.h +3 -0
index 246650f2814f..65d5e68065e3 100644
@@ -59,6 +59,9 @@ struct dw_mipi_dsi_plat_data {
 					   unsigned long mode_flags,
 					   u32 lanes, u32 format);
 
+	bool (*mode_fixup)(void *priv_data, const struct drm_display_mode *mode,
+			   struct drm_display_mode *adjusted_mode);
+
 	u32 *(*get_input_bus_fmts)(void *priv_data,
 				   struct drm_bridge *bridge,
 				   struct drm_bridge_state *bridge_state,
Signature · 1 line
2.37.1
author maintainer
#5 lore raw

PATCH 5/9 drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate lbcc

In reply to Liu Ying

To get better accuration, use pixel clock rate to calculate lbcc instead of lane_mbps since the pixel clock rate is in KHz while lane_mbps is in MHz. Without this, distorted image can be seen on a HDMI monitor connected with i.MX93 11x11 EVK through ADV7535 DSI to HDMI bridge in 1920x1080p@60 video mode.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +9 -1
index c754d55f71d1..332388fd86da 100644
@@ -12,6 +12,7 @@
 #include <linux/component.h>
 #include <linux/debugfs.h>
 #include <linux/iopoll.h>
+#include <linux/math64.h>
 #include <linux/media-bus-format.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
@@ -762,8 +763,15 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
 					   u32 hcomponent)
 {
 	u32 frac, lbcc;
+	int bpp;
 
-	lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8;
+	bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
+	if (bpp < 0) {
+		dev_err(dsi->dev, "failed to get bpp\n");
+		return 0;
+	}
+
+	lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes * 8);
 
 	frac = lbcc % mode->clock;
 	lbcc = lbcc / mode->clock;
Signature · 1 line
2.37.1
maintainer Reviewed-by on v1 5/9
#6 lore raw

Re: [PATCH 5/9] drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate lbcc

Quoted 30 lines · Liu Ying

To get better accuration, use pixel clock rate to calculate lbcc instead of lane_mbps since the pixel clock rate is in KHz while lane_mbps is in MHz. Without this, distorted image can be seen on a HDMI monitor connected with i.MX93 11x11 EVK through ADV7535 DSI to HDMI bridge in 1920x1080p@60 video mode.

---
  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2 -1
index c754d55f71d1..332388fd86da 100644
@@ -12,6 +12,7 @@
  #include <linux/component.h>
  #include <linux/debugfs.h>
  #include <linux/iopoll.h>
+#include <linux/math64.h>
  #include <linux/media-bus-format.h>
  #include <linux/module.h>
  #include <linux/of_device.h>
@@ -762,8 +763,15 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
  					   u32 hcomponent)
  {
  	u32 frac, lbcc;
+	int bpp;
 
-	lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8;

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi, · line 777

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +7 -0
+	bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
+	if (bpp < 0) {
+		dev_err(dsi->dev, "failed to get bpp\n");
+		return 0;
+	}
+
+	lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes * 8);
 
  	frac = lbcc % mode->clock;
  	lbcc = lbcc / mode->clock;
#7 lore raw

Re: [PATCH 5/9] drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate lbcc

In reply to Liu Ying

Hi,

Am Montag, 17. Juli 2023, 08:18:27 CEST schrieb Liu Ying:

Quoted 7 lines

To get better accuration, use pixel clock rate to calculate lbcc instead of lane_mbps since the pixel clock rate is in KHz while lane_mbps is in MHz. Without this, distorted image can be seen on a HDMI monitor connected with i.MX93 11x11 EVK through ADV7535 DSI to HDMI bridge in 1920x1080p@60 video mode.

looks like I'm late to the party, but this change breaks the display output my px30 minievb with the xinpeng xpp055c272 dsi display [0].

Found this commit via git bisection and added a bit of debug output to compare the value differences for the old and new calculation:

[   34.810722] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 810 * 480 * 1000 / 8
[   34.810749] dw_mipi_dsi_get_hcomponent_lbcc: new lbcc: 810 * 64000 * 24 / (4 * 8)
[   34.810756] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 48600000, new lbcc: 38880000
[   34.810762] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 10 * 480 * 1000 / 8
[   34.810767] dw_mipi_dsi_get_hcomponent_lbcc: new lbcc: 10 * 64000 * 24 / (4 * 8)
[   34.810773] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 600000, new lbcc: 480000
[   34.810778] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 40 * 480 * 1000 / 8
[   34.810783] dw_mipi_dsi_get_hcomponent_lbcc: new lbcc: 40 * 64000 * 24 / (4 * 8)
[   34.810789] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 2400000, new lbcc: 1920000

With the new lbcc I get a blank dsi panel and just going back to the old calculation of lbcc restores the image.

I don't have that much in-depth knowledge about dsi stuff and the original panel times also "just" came from the vendor tree, but I really would like to keep that display working ;-) .

Do you have any idea which way to go to fix this?

Thanks
Heiko

[0]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/rockchip/px30-evb.dts#n138
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c

Quoted 30 lines
---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +9 -1
index c754d55f71d1..332388fd86da 100644
@@ -12,6 +12,7 @@
 #include <linux/component.h>
 #include <linux/debugfs.h>
 #include <linux/iopoll.h>
+#include <linux/math64.h>
 #include <linux/media-bus-format.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
@@ -762,8 +763,15 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
 					   u32 hcomponent)
 {
 	u32 frac, lbcc;
+	int bpp;
 
-	lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8;
+	bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
+	if (bpp < 0) {
+		dev_err(dsi->dev, "failed to get bpp\n");
+		return 0;
+	}
+
+	lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes * 8);
author maintainer
#8 lore raw

RE: [PATCH 5/9] drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate lbcc

Quoted 1 line · Heiko Stübner

Hi,

Hi,

Quoted 6 lines

Am Montag, 17. Juli 2023, 08:18:27 CEST schrieb Liu Ying:

Quoted 3 lines

To get better accuration, use pixel clock rate to calculate lbcc instead of lane_mbps since the pixel clock rate is in KHz while lane_mbps is in MHz. Without this, distorted image can be seen on a HDMI monitor connected

with

Quoted 8 lines
Quoted 1 line

i.MX93 11x11 EVK through ADV7535 DSI to HDMI bridge in 1920x1080p@60

video

Quoted 3 lines

mode.

looks like I'm late to the party, but this change breaks the display output my px30 minievb with the xinpeng xpp055c272 dsi display [0].

Hmm, I asked for a test, but anyway sorry for the breakage.

The panel driver sets MIPI_DSI_MODE_VIDEO_BURST.
And, it seems that rockchip dsi driver [1] only supports the burst mode, because it takes 1/0.8 = 1.25 faster lane_mbps than "bandwidth of RGB".

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c#n568

Quoted 21 lines

Found this commit via git bisection and added a bit of debug output to compare the value differences for the old and new calculation:

[   34.810722] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 810 * 480 * 1000
/ 8
[   34.810749] dw_mipi_dsi_get_hcomponent_lbcc: new lbcc: 810 * 64000 *
24 / (4 * 8)
[   34.810756] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 48600000, new
lbcc: 38880000
[   34.810762] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 10 * 480 * 1000 /
8
[   34.810767] dw_mipi_dsi_get_hcomponent_lbcc: new lbcc: 10 * 64000 * 24
/ (4 * 8)
[   34.810773] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 600000, new lbcc:
480000
[   34.810778] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 40 * 480 * 1000 /
8
[   34.810783] dw_mipi_dsi_get_hcomponent_lbcc: new lbcc: 40 * 64000 * 24
/ (4 * 8)
[   34.810789] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 2400000, new
Quoted 1 line

lbcc: 1920000

Old lbcc / new lbcc is always 1.25.

The new lbcc is for non-burst modes(sync pulse/sync event), IIUC. At least, it works for i.MX93 with the RM67191 panel and ADV7535 in sync pulse mode.

Quoted 9 lines

With the new lbcc I get a blank dsi panel and just going back to the old calculation of lbcc restores the image.

I don't have that much in-depth knowledge about dsi stuff and the original panel times also "just" came from the vendor tree, but I really would like to keep that display working ;-) .

Do you have any idea which way to go to fix this?

Can you please test the below patch for your case?

--------------------------------------------------------8<---------------------------------------------------------------------

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +12 -6
@@ -774,13 +774,19 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
        u32 frac, lbcc, minimum_lbcc;
        int bpp;
 
-       bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
-       if (bpp < 0) {
-               dev_err(dsi->dev, "failed to get bpp\n");
-               return 0;
-       }
+       if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) {
+               /* lbcc based on lane_mbps */
+               lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8;
+       } else {
+               /* lbcc based on pixel clock */
+               bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
+               if (bpp < 0) {
+                       dev_err(dsi->dev, "failed to get bpp\n");
+                       return 0;
+               }
 
-       lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes * 8);
+               lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes * 8);
+       }
 
        frac = lbcc % mode->clock;
        lbcc = lbcc / mode->clock;

--------------------------------------------------------8<---------------------------------------------------------------------

It kind of keeps the old lbcc for burst mode, except for the minimum lbcc check I introduced.

It seems that meson supports non-burst modes only and stm supports both non-burst modes and burst mode. With the patch, I still worry about non-burst modes for stm, assuming the minimum lbcc check is ok and everything works for meson since I guess Neil has already tested the patch set on meson.

Should we go with the above patch? If yes, I may send it out.

Regards,
Liu Ying

Quoted 62 lines

Thanks
Heiko

[0]
https://git.ker/
nel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2F tree%2Farch%2Farm64%2Fboot%2Fdts%2Frockchip%2Fpx30- evb.dts%23n138&data=05%7C01%7Cvictor.liu%40nxp.com%7C8f712ad41720 4ba7411808dbce73ce63%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0 %7C638330769044424464%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C% 7C%7C&sdata=effPCbPOk3GGuO8mR%2FSlcjFJfDUEZmq082simvjkux0%3D&r eserved=0
https://git.ker/
nel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2F tree%2Fdrivers%2Fgpu%2Fdrm%2Fpanel%2Fpanel-xinpeng- xpp055c272.c&data=05%7C01%7Cvictor.liu%40nxp.com%7C8f712ad417204b a7411808dbce73ce63%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 C638330769044424464%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C %7C&sdata=bAgcLnJpIEQaYZZUI1CnUsgP7rMiNV6wKKg%2Bl8%2FlN40%3D&r eserved=0

Review

Quoted 5 lines
---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static u32

Quoted 12 lines

index c754d55f71d1..332388fd86da 100644

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -0
@@ -12,6 +12,7 @@
 #include <linux/component.h>
 #include <linux/debugfs.h>
 #include <linux/iopoll.h>
+#include <linux/math64.h>
 #include <linux/media-bus-format.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
@@ -762,8 +763,15 @@ static u32

dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static u32 · line 774

Quoted 13 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +8 -1
                                       u32 hcomponent)
 {
    u32 frac, lbcc;
+   int bpp;
 
-   lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8;
+   bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
+   if (bpp < 0) {
+           dev_err(dsi->dev, "failed to get bpp\n");
+           return 0;
+   }
+
+   lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes *

8);

#9 lore raw

Re: [PATCH 5/9] drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate lbcc

Hi,

Am Dienstag, 17. Oktober 2023, 12:15:11 CEST schrieb Ying Liu:

Quoted 8 lines · Heiko Stübner
Quoted 7 lines

Am Montag, 17. Juli 2023, 08:18:27 CEST schrieb Liu Ying:

Quoted 3 lines

To get better accuration, use pixel clock rate to calculate lbcc instead of lane_mbps since the pixel clock rate is in KHz while lane_mbps is in MHz. Without this, distorted image can be seen on a HDMI monitor connected

with

Quoted 1 line

i.MX93 11x11 EVK through ADV7535 DSI to HDMI bridge in 1920x1080p@60

video

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

mode.

looks like I'm late to the party, but this change breaks the display output my px30 minievb with the xinpeng xpp055c272 dsi display [0].

Hmm, I asked for a test, but anyway sorry for the breakage.

I'm often way behind with looking at drm-related changes, sorry about that.

So thanks a lot for taking the time to look into the problem.

Quoted 39 lines

The panel driver sets MIPI_DSI_MODE_VIDEO_BURST.
And, it seems that rockchip dsi driver [1] only supports the burst mode, because it takes 1/0.8 = 1.25 faster lane_mbps than "bandwidth of RGB".

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c#n568

Quoted 21 lines

Found this commit via git bisection and added a bit of debug output to compare the value differences for the old and new calculation:

[   34.810722] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 810 * 480 * 1000
/ 8
[   34.810749] dw_mipi_dsi_get_hcomponent_lbcc: new lbcc: 810 * 64000 *
24 / (4 * 8)
[   34.810756] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 48600000, new
lbcc: 38880000
[   34.810762] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 10 * 480 * 1000 /
8
[   34.810767] dw_mipi_dsi_get_hcomponent_lbcc: new lbcc: 10 * 64000 * 24
/ (4 * 8)
[   34.810773] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 600000, new lbcc:
480000
[   34.810778] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 40 * 480 * 1000 /
8
[   34.810783] dw_mipi_dsi_get_hcomponent_lbcc: new lbcc: 40 * 64000 * 24
/ (4 * 8)
[   34.810789] dw_mipi_dsi_get_hcomponent_lbcc: old lbcc: 2400000, new
Quoted 1 line

lbcc: 1920000

Old lbcc / new lbcc is always 1.25.

The new lbcc is for non-burst modes(sync pulse/sync event), IIUC. At least, it works for i.MX93 with the RM67191 panel and ADV7535 in sync pulse mode.

Quoted 4 lines

With the new lbcc I get a blank dsi panel and just going back to the old calculation of lbcc restores the image.

Quoted 7 lines
Quoted 5 lines

I don't have that much in-depth knowledge about dsi stuff and the original panel times also "just" came from the vendor tree, but I really would like to keep that display working ;-) .

Do you have any idea which way to go to fix this?

Can you please test the below patch for your case?

The patch below does fix the display on the device. After applying it I do get a working display again.

Quoted 34 lines

--------------------------------------------------------8<---------------------------------------------------------------------

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +12 -7
@@ -774,13 +774,19 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
        u32 frac, lbcc, minimum_lbcc;
        int bpp;
 
-       bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
-       if (bpp < 0) {
-               dev_err(dsi->dev, "failed to get bpp\n");
-               return 0;
-       }
+       if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) {
+               /* lbcc based on lane_mbps */
+               lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8;
+       } else {
+               /* lbcc based on pixel clock */
+               bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
+               if (bpp < 0) {
+                       dev_err(dsi->dev, "failed to get bpp\n");
+                       return 0;
+               }
 
-       lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes * 8);
+               lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes * 8);
+       }
 
        frac = lbcc % mode->clock;
        lbcc = lbcc / mode->clock;
--------------------------------------------------------8<---------------------------------------------------------------------

It kind of keeps the old lbcc for burst mode, except for the minimum lbcc check I introduced.

Quoted 6 lines

It seems that meson supports non-burst modes only and stm supports both non-burst modes and burst mode. With the patch, I still worry about non-burst modes for stm, assuming the minimum lbcc check is ok and everything works for meson since I guess Neil has already tested the patch set on meson.

Should we go with the above patch? If yes, I may send it out.

In my mind, definitly :-) .

But maybe Neil as the other reviewer also wants to chime in.

So again thanks for looking into the issue.
Heiko

Quoted 59 lines
Quoted 57 lines

[0]
https://git.ker/
nel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2F tree%2Farch%2Farm64%2Fboot%2Fdts%2Frockchip%2Fpx30- evb.dts%23n138&data=05%7C01%7Cvictor.liu%40nxp.com%7C8f712ad41720 4ba7411808dbce73ce63%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0 %7C638330769044424464%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C% 7C%7C&sdata=effPCbPOk3GGuO8mR%2FSlcjFJfDUEZmq082simvjkux0%3D&r eserved=0
https://git.ker/
nel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2F tree%2Fdrivers%2Fgpu%2Fdrm%2Fpanel%2Fpanel-xinpeng- xpp055c272.c&data=05%7C01%7Cvictor.liu%40nxp.com%7C8f712ad417204b a7411808dbce73ce63%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 C638330769044424464%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C %7C&sdata=bAgcLnJpIEQaYZZUI1CnUsgP7rMiNV6wKKg%2Bl8%2FlN40%3D&r eserved=0

Review

Quoted 5 lines
---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static u32

Quoted 12 lines

index c754d55f71d1..332388fd86da 100644

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -0
@@ -12,6 +12,7 @@
 #include <linux/component.h>
 #include <linux/debugfs.h>
 #include <linux/iopoll.h>
+#include <linux/math64.h>
 #include <linux/media-bus-format.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
@@ -762,8 +763,15 @@ static u32

dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static u32 · line 774

Quoted 13 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +8 -1
                                       u32 hcomponent)
 {
    u32 frac, lbcc;
+   int bpp;
 
-   lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8;
+   bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
+   if (bpp < 0) {
+           dev_err(dsi->dev, "failed to get bpp\n");
+           return 0;
+   }
+
+   lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes *

8);

author maintainer
#10 lore raw

PATCH 6/9 drm/bridge: synopsys: dw-mipi-dsi: Set minimum lane byte clock cycles for HSA and HBP

In reply to Liu Ying

According to Synopsys support channel, each region of HSA, HBP and HFP must have minimum number of 10 bytes where constant 4 bytes are for HSS or HSE and 6 bytes are for blanking packet(header + CRC). Hence, the below table comes in.

+------------+----------+-------+
| data lanes | min lbcc | bytes |
+------------+----------+-------+
|     1      |    10    |  1*10 |
+------------+----------+-------+
|     2      |    5     |  2*5  |
+------------+----------+-------+
|     3      |    4     |  3*4  |
+------------+----------+-------+
|     4      |    3     |  4*3  |
+------------+----------+-------+

Implement the minimum lbcc numbers to make sure that the values programmed into DSI_VID_HSA_TIME and DSI_VID_HBP_TIME registers meet the minimum number requirement. For DSI_VID_HLINE_TIME register, it seems that the value programmed should be based on mode->htotal as-is, instead of sum up HSA, HBP, HFP and HDISPLAY.

This helps the case where Raydium RM67191 DSI panel is connected, since it's video timing for hsync length is only 2 pixels and without this patch the programmed value for DSI_VID_HSA_TIME is only 2 with 4 data lanes.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +13 -1
index 332388fd86da..536306ccea5a 100644
@@ -757,12 +757,19 @@ static void dw_mipi_dsi_command_mode_config(struct dw_mipi_dsi *dsi)
 	dsi_write(dsi, DSI_MODE_CFG, ENABLE_CMD_MODE);
 }
 
+static const u32 minimum_lbccs[] = {10, 5, 4, 3};
+
+static inline u32 dw_mipi_dsi_get_minimum_lbcc(struct dw_mipi_dsi *dsi)
+{
+	return minimum_lbccs[dsi->lanes - 1];
+}
+
 /* Get lane byte clock cycles. */
 static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
 					   const struct drm_display_mode *mode,
 					   u32 hcomponent)
 {
-	u32 frac, lbcc;
+	u32 frac, lbcc, minimum_lbcc;
 	int bpp;
 
 	bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
@@ -778,6 +785,11 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
 	if (frac)
 		lbcc++;
 
+	minimum_lbcc = dw_mipi_dsi_get_minimum_lbcc(dsi);
+
+	if (lbcc < minimum_lbcc)
+		lbcc = minimum_lbcc;
+
 	return lbcc;
 }
 
Signature · 1 line
2.37.1
maintainer Reviewed-by on v1 6/9
#11 lore raw

Re: [PATCH 6/9] drm/bridge: synopsys: dw-mipi-dsi: Set minimum lane byte clock cycles for HSA and HBP

Quoted 59 lines · Liu Ying

According to Synopsys support channel, each region of HSA, HBP and HFP must have minimum number of 10 bytes where constant 4 bytes are for HSS or HSE and 6 bytes are for blanking packet(header + CRC). Hence, the below table comes in.

+------------+----------+-------+
| data lanes | min lbcc | bytes |
+------------+----------+-------+
|     1      |    10    |  1*10 |
+------------+----------+-------+
|     2      |    5     |  2*5  |
+------------+----------+-------+
|     3      |    4     |  3*4  |
+------------+----------+-------+
|     4      |    3     |  4*3  |
+------------+----------+-------+

Implement the minimum lbcc numbers to make sure that the values programmed into DSI_VID_HSA_TIME and DSI_VID_HBP_TIME registers meet the minimum number requirement. For DSI_VID_HLINE_TIME register, it seems that the value programmed should be based on mode->htotal as-is, instead of sum up HSA, HBP, HFP and HDISPLAY.

This helps the case where Raydium RM67191 DSI panel is connected, since it's video timing for hsync length is only 2 pixels and without this patch the programmed value for DSI_VID_HSA_TIME is only 2 with 4 data lanes.

---
  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +8 -1
index 332388fd86da..536306ccea5a 100644
@@ -757,12 +757,19 @@ static void dw_mipi_dsi_command_mode_config(struct dw_mipi_dsi *dsi)
  	dsi_write(dsi, DSI_MODE_CFG, ENABLE_CMD_MODE);
  }
 
+static const u32 minimum_lbccs[] = {10, 5, 4, 3};
+
+static inline u32 dw_mipi_dsi_get_minimum_lbcc(struct dw_mipi_dsi *dsi)
+{
+	return minimum_lbccs[dsi->lanes - 1];
+}
+
  /* Get lane byte clock cycles. */
  static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
  					   const struct drm_display_mode *mode,
  					   u32 hcomponent)
  {
-	u32 frac, lbcc;
+	u32 frac, lbcc, minimum_lbcc;
  	int bpp;
 
  	bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
@@ -778,6 +785,11 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
  	if (frac)

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi, · line 795

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +5 -0
  		lbcc++;
 
+	minimum_lbcc = dw_mipi_dsi_get_minimum_lbcc(dsi);
+
+	if (lbcc < minimum_lbcc)
+		lbcc = minimum_lbcc;
+
  	return lbcc;
  }
 
author maintainer
#12 lore raw

PATCH 7/9 drm/bridge: synopsys: dw-mipi-dsi: Disable HSTX and LPRX timeout check

In reply to Liu Ying

According to Synopsys DW MIPI DSI host databook, HSTX and LPRX timeout contention detections are measured in TO_CLK_DIVISION cycles. However, the current driver programs magic values to TO_CLK_DIVISION, HSTX_TO_CNT and LPRX_TO_CNT register fields, which makes timeout error event wrongly happen for some video modes, at least for the typical 1920x1080p@60 video mode read from a HDMI monitor driven by ADV7535 DSI to HDMI bridge. While at it, the current driver doesn't enable interrupt to handle or complain about the error status, so true error just happens silently except for display distortions by visual check.

Disable the timeout check by setting those timeout register fields to zero for now until someone comes along with better computations for the timeout values. Although the databook doesn't mention what happens when they are set to zero, it turns out the false error doesn't happen for the 1920x1080p@60 video mode at least.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2 -2
index 536306ccea5a..0fcadf99e783 100644
@@ -684,7 +684,7 @@ static void dw_mipi_dsi_init(struct dw_mipi_dsi *dsi)
 	 * timeout clock division should be computed with the
 	 * high speed transmission counter timeout and byte lane...
 	 */
-	dsi_write(dsi, DSI_CLKMGR_CFG, TO_CLK_DIVISION(10) |
+	dsi_write(dsi, DSI_CLKMGR_CFG, TO_CLK_DIVISION(0) |
 		  TX_ESC_CLK_DIVISION(esc_clk_division));
 }
 
@@ -747,7 +747,7 @@ static void dw_mipi_dsi_command_mode_config(struct dw_mipi_dsi *dsi)
 	 * compute high speed transmission counter timeout according
 	 * to the timeout clock division (TO_CLK_DIVISION) and byte lane...
 	 */
-	dsi_write(dsi, DSI_TO_CNT_CFG, HSTX_TO_CNT(1000) | LPRX_TO_CNT(1000));
+	dsi_write(dsi, DSI_TO_CNT_CFG, HSTX_TO_CNT(0) | LPRX_TO_CNT(0));
 	/*
 	 * TODO dw drv improvements
 	 * the Bus-Turn-Around Timeout Counter should be computed
Signature · 1 line
2.37.1
maintainer Reviewed-by on v1 7/9
#13 lore raw

Re: [PATCH 7/9] drm/bridge: synopsys: dw-mipi-dsi: Disable HSTX and LPRX timeout check

Quoted 35 lines · Liu Ying

According to Synopsys DW MIPI DSI host databook, HSTX and LPRX timeout contention detections are measured in TO_CLK_DIVISION cycles. However, the current driver programs magic values to TO_CLK_DIVISION, HSTX_TO_CNT and LPRX_TO_CNT register fields, which makes timeout error event wrongly happen for some video modes, at least for the typical 1920x1080p@60 video mode read from a HDMI monitor driven by ADV7535 DSI to HDMI bridge. While at it, the current driver doesn't enable interrupt to handle or complain about the error status, so true error just happens silently except for display distortions by visual check.

Disable the timeout check by setting those timeout register fields to zero for now until someone comes along with better computations for the timeout values. Although the databook doesn't mention what happens when they are set to zero, it turns out the false error doesn't happen for the 1920x1080p@60 video mode at least.

---
  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -1
index 536306ccea5a..0fcadf99e783 100644
@@ -684,7 +684,7 @@ static void dw_mipi_dsi_init(struct dw_mipi_dsi *dsi)
  	 * timeout clock division should be computed with the
  	 * high speed transmission counter timeout and byte lane...
  	 */
-	dsi_write(dsi, DSI_CLKMGR_CFG, TO_CLK_DIVISION(10) |
+	dsi_write(dsi, DSI_CLKMGR_CFG, TO_CLK_DIVISION(0) |
  		  TX_ESC_CLK_DIVISION(esc_clk_division));
  }
 

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static void dw_mipi_dsi_command_mode_config(struct dw_mipi_dsi *dsi) · line 753

Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -1
@@ -747,7 +747,7 @@ static void dw_mipi_dsi_command_mode_config(struct dw_mipi_dsi *dsi)
  	 * compute high speed transmission counter timeout according
  	 * to the timeout clock division (TO_CLK_DIVISION) and byte lane...
  	 */
-	dsi_write(dsi, DSI_TO_CNT_CFG, HSTX_TO_CNT(1000) | LPRX_TO_CNT(1000));
+	dsi_write(dsi, DSI_TO_CNT_CFG, HSTX_TO_CNT(0) | LPRX_TO_CNT(0));
  	/*
  	 * TODO dw drv improvements
  	 * the Bus-Turn-Around Timeout Counter should be computed
author maintainer
#14 lore raw

PATCH 8/9 dt-bindings: display: bridge: Document Freescale i.MX93 MIPI DSI

In reply to Liu Ying

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

---
 .../display/bridge/fsl,imx93-mipi-dsi.yaml    | 115 ++++++++++++++++++
 1 file changed, 115 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/fsl,imx93-mipi-dsi.yaml
Documentation/devicetree/bindings/display/bridge/fsl,imx93-mipi-dsi.yaml new file +115 -0
new file mode 100644
index 000000000000..d6e51d0cf546
@@ -0,0 +1,115 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/bridge/fsl,imx93-mipi-dsi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Freescale i.MX93 specific extensions to Synopsys Designware MIPI DSI
+
+maintainers:
+  - Liu Ying <[email protected]>
+
+description: |
+  There is a Synopsys Designware MIPI DSI Host Controller and a Synopsys
+  Designware MIPI DPHY embedded in Freescale i.MX93 SoC.  Some configurations
+  and extensions to them are controlled by i.MX93 media blk-ctrl.
+
+allOf:
+  - $ref: snps,dw-mipi-dsi.yaml#
+
+properties:
+  compatible:
+    const: fsl,imx93-mipi-dsi
+
+  clocks:
+    items:
+      - description: apb clock
+      - description: pixel clock
+      - description: PHY configuration clock
+      - description: PHY reference clock
+
+  clock-names:
+    items:
+      - const: pclk
+      - const: pix
+      - const: phy_cfg
+      - const: phy_ref
+
+  interrupts:
+    maxItems: 1
+
+  fsl,media-blk-ctrl:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      i.MX93 media blk-ctrl, as a syscon, controls pixel component bit map
+      configurations from LCDIF display controller to the MIPI DSI host
+      controller and MIPI DPHY PLL related configurations through PLL SoC
+      interface.
+
+  power-domains:
+    maxItems: 1
+
+required:
+  - compatible
+  - interrupts
+  - fsl,media-blk-ctrl
+  - power-domains
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/imx93-clock.h>
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/power/fsl,imx93-power.h>
+
+    dsi@4ae10000 {
+        compatible = "fsl,imx93-mipi-dsi";
+        reg = <0x4ae10000 0x10000>;
+        interrupts = <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&clk IMX93_CLK_MIPI_DSI_GATE>,
+                 <&clk IMX93_CLK_MEDIA_DISP_PIX>,
+                 <&clk IMX93_CLK_MIPI_PHY_CFG>,
+                 <&clk IMX93_CLK_24M>;
+        clock-names = "pclk", "pix", "phy_cfg", "phy_ref";
+        fsl,media-blk-ctrl = <&media_blk_ctrl>;
+        power-domains = <&media_blk_ctrl IMX93_MEDIABLK_PD_MIPI_DSI>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        panel@0 {
+            compatible = "raydium,rm67191";
+            reg = <0>;
+            reset-gpios = <&adp5585gpio 6 GPIO_ACTIVE_LOW>;
+            dsi-lanes = <4>;
+            video-mode = <2>;
+
+            port {
+                panel_in: endpoint {
+                    remote-endpoint = <&dsi_out>;
+                };
+            };
+        };
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            port@0 {
+                reg = <0>;
+
+                dsi_to_lcdif: endpoint {
+                    remote-endpoint = <&lcdif_to_dsi>;
+                };
+            };
+
+            port@1 {
+                reg = <1>;
+
+                dsi_out: endpoint {
+                    remote-endpoint = <&panel_in>;
+                };
+            };
+        };
+    };
Signature · 1 line
2.37.1
maintainer Reviewed-by on v1 8/9
#15 lore raw

Re: [PATCH 8/9] dt-bindings: display: bridge: Document Freescale i.MX93 MIPI DSI

Quoted 10 lines · Liu Ying

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

---
 .../display/bridge/fsl,imx93-mipi-dsi.yaml    | 115 ++++++++++++++++++
 1 file changed, 115 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/fsl,imx93-mipi-dsi.yaml
author maintainer
#16 lore raw

PATCH 9/9 drm/bridge: imx: Add i.MX93 MIPI DSI support

In reply to Liu Ying

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

---
 drivers/gpu/drm/bridge/imx/Kconfig          |  10 +
 drivers/gpu/drm/bridge/imx/Makefile         |   1 +
 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c | 934 ++++++++++++++++++++
 3 files changed, 945 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c
drivers/gpu/drm/bridge/imx/Kconfig +10 -0
index 9fae28db6aa7..5182298c7182 100644
@@ -49,4 +49,14 @@ config DRM_IMX8QXP_PIXEL_LINK_TO_DPI
 	  Choose this to enable pixel link to display pixel interface(PXL2DPI)
 	  found in Freescale i.MX8qxp processor.
 
+config DRM_IMX93_MIPI_DSI
+	tristate "Freescale i.MX93 specific extensions for Synopsys DW MIPI DSI"
+	depends on OF
+	depends on COMMON_CLK
+	select DRM_DW_MIPI_DSI
+	select GENERIC_PHY_MIPI_DPHY
+	help
+	  Choose this to enable MIPI DSI controller found in Freescale i.MX93
+	  processor.
+
 endif # ARCH_MXC || COMPILE_TEST
drivers/gpu/drm/bridge/imx/Makefile +1 -0
index 8e2ebf3399a1..2b0c2e44aa1b 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_IMX8QXP_LDB) += imx8qxp-ldb.o
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_COMBINER) += imx8qxp-pixel-combiner.o
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK) += imx8qxp-pixel-link.o
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK_TO_DPI) += imx8qxp-pxl2dpi.o
+obj-$(CONFIG_DRM_IMX93_MIPI_DSI) += imx93-mipi-dsi.o
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +934 -0

934 lines not on this page · raw message

Signature · 1 line
2.37.1
#17 lore raw
Quoted 7 lines · Liu Ying

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

I think the better way would add compatibility to be part of existing dw-mipi-dsi.c with specific driver data. This way it avoids all the platform-related helpers(extensions) and makes the driver generic to all SoCs which use DW DSI IP. It would be a straightforward change as the imx93 drm pipeline already supports bridge topology.

Thanks,
Jagan.

author maintainer
#18 lore raw

Hi Jagan,

Quoted 6 lines · Jagan Teki
Quoted 5 lines · Liu Ying

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Quoted 8 lines
Quoted 2 lines

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

I think the better way would add compatibility to be part of existing dw-mipi-dsi.c with specific driver data. This way it avoids all the platform-related helpers(extensions) and makes the driver generic to all SoCs which use DW DSI IP. It would be a straightforward change as the imx93 drm pipeline already supports bridge topology.

The platform-related stuff is handed over to dw-mipi-dsi.c via struct dw_mipi_dsi_plat_data as an argument of dw_mipi_dsi_probe(). It looks ok for vendor drivers to call dw_mipi_dsi_probe() to set the platform-related information(rockchip, meson and stm do that), like pdata.phy_ops and pdata.host_ops.

dw-mipi-dsi.c is generic w/wo this patch series.

Can you elaborate more about adding compatibility to be part of existing dw-mipi-dsi.c with specific driver data? I don't see clear approach to do that.

Regards,
Liu Ying

Quoted 3 lines

Thanks,
Jagan.

#19 lore raw
Quoted 19 lines · Ying Liu

Hi Jagan,

Quoted 6 lines · Jagan Teki
Quoted 5 lines · Liu Ying

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Quoted 8 lines
Quoted 2 lines

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

I think the better way would add compatibility to be part of existing dw-mipi-dsi.c with specific driver data. This way it avoids all the platform-related helpers(extensions) and makes the driver generic to all SoCs which use DW DSI IP. It would be a straightforward change as the imx93 drm pipeline already supports bridge topology.

Quoted 5 lines

The platform-related stuff is handed over to dw-mipi-dsi.c via struct dw_mipi_dsi_plat_data as an argument of dw_mipi_dsi_probe(). It looks ok for vendor drivers to call dw_mipi_dsi_probe() to set the platform-related information(rockchip, meson and stm do that), like pdata.phy_ops and pdata.host_ops.

I understand this topology of having soc-platform drivers with dw-mipi-dsi bridge. What I'm suggesting is to not add a soc-platform driver for imx93 instead add add support directly on dw-mipi-dsi bridge.

Quoted 6 lines

dw-mipi-dsi.c is generic w/wo this patch series.

Can you elaborate more about adding compatibility to be part of existing dw-mipi-dsi.c with specific driver data? I don't see clear approach to do that.

Please check the above comments, an example of samsung-dsim.c

Thanks,
Jagan.

author maintainer
#20 lore raw
Quoted 24 lines · Jagan Teki
Quoted 5 lines

Hi Jagan,

On Monday, July 17, 2023 2:44 PM Jagan Teki

Quoted 15 lines · <[email protected]> wrote:
Quoted 6 lines · Liu Ying
Quoted 5 lines

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Quoted 8 lines
Quoted 2 lines

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

I think the better way would add compatibility to be part of existing dw-mipi-dsi.c with specific driver data. This way it avoids all the platform-related helpers(extensions) and makes the driver generic to all SoCs which use DW DSI IP. It would be a straightforward change as the imx93 drm pipeline already supports bridge topology.

Quoted 3 lines

The platform-related stuff is handed over to dw-mipi-dsi.c via struct dw_mipi_dsi_plat_data as an argument of dw_mipi_dsi_probe(). It looks ok for vendor drivers to call dw_mipi_dsi_probe() to set the platform-

Quoted 8 lines

related

Quoted 2 lines

information(rockchip, meson and stm do that), like pdata.phy_ops and pdata.host_ops.

I understand this topology of having soc-platform drivers with dw-mipi-dsi bridge. What I'm suggesting is to not add a soc-platform driver for imx93 instead add add support directly on dw-mipi-dsi bridge.

It seems that directly supporting i.MX93 MIPI DSI in dw-mipi-dsi.c is not feasible. The main reason is that struct dw_mipi_dsi_plat_data contains phy_ops and each vendor driver provides very different methods for phy, while...

Quoted 9 lines
Quoted 7 lines

dw-mipi-dsi.c is generic w/wo this patch series.

Can you elaborate more about adding compatibility to be part of existing dw-mipi-dsi.c with specific driver data? I don't see clear approach to do that.

Please check the above comments, an example of samsung-dsim.c

... it seems that samsung-dsim.c uses struct samsung_dsim_driver_data to differential platform information and it doesn't contain any callback, which means comparing to DW MIPI DSI, Samsung DSIM shows more consistency across vendor SoCs from HW IP/SoC integration PoV.

Regards,
Liu Ying

Quoted 3 lines

Thanks,
Jagan.

#21 lore raw

Hi,

Quoted 35 lines · Ying Liu
Quoted 24 lines · Jagan Teki
Quoted 5 lines

Hi Jagan,

On Monday, July 17, 2023 2:44 PM Jagan Teki

Quoted 15 lines · <[email protected]> wrote:
Quoted 6 lines · Liu Ying
Quoted 5 lines

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Quoted 8 lines
Quoted 2 lines

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

I think the better way would add compatibility to be part of existing dw-mipi-dsi.c with specific driver data. This way it avoids all the platform-related helpers(extensions) and makes the driver generic to all SoCs which use DW DSI IP. It would be a straightforward change as the imx93 drm pipeline already supports bridge topology.

Quoted 3 lines

The platform-related stuff is handed over to dw-mipi-dsi.c via struct dw_mipi_dsi_plat_data as an argument of dw_mipi_dsi_probe(). It looks ok for vendor drivers to call dw_mipi_dsi_probe() to set the platform-

Quoted 8 lines

related

Quoted 2 lines

information(rockchip, meson and stm do that), like pdata.phy_ops and pdata.host_ops.

I understand this topology of having soc-platform drivers with dw-mipi-dsi bridge. What I'm suggesting is to not add a soc-platform driver for imx93 instead add add support directly on dw-mipi-dsi bridge.

Quoted 4 lines

It seems that directly supporting i.MX93 MIPI DSI in dw-mipi-dsi.c is not feasible. The main reason is that struct dw_mipi_dsi_plat_data contains phy_ops and each vendor driver provides very different methods for phy, while...

Cannot this phy_ops goes to PHY core somewhere around and even it is possible to add via driver data for imx93 by untouching existing handling? I know it is not as direct as I describe but it is worth maintaining the driver this way to keep control of the future soc-drivers to include in dw-mipi-dsi instead of handling platform code separately.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

dw-mipi-dsi.c is generic w/wo this patch series.

Can you elaborate more about adding compatibility to be part of existing dw-mipi-dsi.c with specific driver data? I don't see clear approach to do that.

Quoted 6 lines
Quoted 1 line

Please check the above comments, an example of samsung-dsim.c

... it seems that samsung-dsim.c uses struct samsung_dsim_driver_data to differential platform information and it doesn't contain any callback, which means comparing to DW MIPI DSI, Samsung DSIM shows more consistency across vendor SoCs from HW IP/SoC integration PoV.

Yes, but is it possible to adjust struct according to DW MIPI DSI.

Thanks
Jagan.

author maintainer
#22 lore raw
Quoted 2 lines · Jagan Teki

Hi,

Hi,

Quoted 47 lines · Ying Liu
Quoted 2 lines

On Tuesday, July 18, 2023 5:35 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 5 lines

Hi Jagan,

On Monday, July 17, 2023 2:44 PM Jagan Teki

Quoted 1 line · <[email protected]> wrote:
Quoted 1 line

On Mon, Jul 17, 2023 at 11:44 AM Liu Ying <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some

configurations

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

and extensions to them are controlled by i.MX93 media blk-ctrl.

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific

extensions.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

I think the better way would add compatibility to be part of existing dw-mipi-dsi.c with specific driver data. This way it avoids all the platform-related helpers(extensions) and makes the driver generic to all SoCs which use DW DSI IP. It would be a straightforward change as the imx93 drm pipeline already supports bridge topology.

The platform-related stuff is handed over to dw-mipi-dsi.c via struct dw_mipi_dsi_plat_data as an argument of dw_mipi_dsi_probe(). It

looks

Quoted 10 lines
Quoted 9 lines
Quoted 1 line

ok for vendor drivers to call dw_mipi_dsi_probe() to set the platform-

related

Quoted 2 lines

information(rockchip, meson and stm do that), like pdata.phy_ops and pdata.host_ops.

I understand this topology of having soc-platform drivers with dw-mipi-dsi bridge. What I'm suggesting is to not add a soc-platform driver for imx93 instead add add support directly on dw-mipi-dsi bridge.

Quoted 4 lines

It seems that directly supporting i.MX93 MIPI DSI in dw-mipi-dsi.c is not feasible. The main reason is that struct dw_mipi_dsi_plat_data contains phy_ops and each vendor driver provides very different methods for phy, while...

Quoted 6 lines

Cannot this phy_ops goes to PHY core somewhere around and even it is possible to add via driver data for imx93 by untouching existing handling? I know it is not as direct as I describe but it is worth maintaining the driver this way to keep control of the future soc-drivers to include in dw-mipi-dsi instead of handling platform code separately.

Like I said, each vendor driver provides very different methods for phy. The reason is that phy IPs are different and SoC integration things are handled via struct dw_mipi_dsi_phy_ops. Meson calls devm_phy_get() to get a phy. Rockchip calls devm_phy_create() to create a phy. Meson, rockchip and stm have their own struct dw_mipi_dsi_phy_ops implementations, same to i.MX93. Different pixel format control is implemented in meson's and i.MX93's ->init() callback. Meson additionally handles clocks in ->init() callback.

Generally speaking, it's a no-go to put phy_ops into PHY core for all the vendors, IMHO.

In particular, i.MX93 MIPI DPHY's PLL can be fully controlled by media blk-ctrl(as a syscon) thru the PLL's SoC control interface, while PHY registers can be controlled by DW MIPI DSI testdin/out control interface alternatively including a part of the PLL registers. So, adding a PHY driver for i.MX93 MIPI DPHY doesn't make sense since the PLL controlled by media blk-ctrl doesn't constitute a PHY. Instead, dw_mipi_dsi_phy_ops may cover all the PHY control well.

From my PoV, w/wo this series, dw-mipi-dsi.c looks fine to keep being generic and easy to maintain. All vendor drivers do is to handle platform specific stuff, which is good.

Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

dw-mipi-dsi.c is generic w/wo this patch series.

Can you elaborate more about adding compatibility to be part of

existing

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

dw-mipi-dsi.c with specific driver data? I don't see clear approach to do that.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Please check the above comments, an example of samsung-dsim.c

... it seems that samsung-dsim.c uses struct samsung_dsim_driver_data to differential platform information and it doesn't contain any callback, which means comparing to DW MIPI DSI, Samsung DSIM shows more consistency across vendor SoCs from HW IP/SoC integration PoV.

Yes, but is it possible to adjust struct according to DW MIPI DSI.

Looking at the vendor drivers, they show a lot diversity, which cannot be parameterized into a struct like the samsung dsim driver does.

struct dw_mipi_dsi_plat_data hides all platform specific information from dw-mipi-dsi.c well, IMHO.

Regards,
Liu Ying

Quoted 3 lines

Thanks
Jagan.

#23 lore raw
Quoted 81 lines · Ying Liu
Quoted 2 lines · Jagan Teki

Hi,

Hi,

Quoted 47 lines · Ying Liu
Quoted 2 lines

On Tuesday, July 18, 2023 5:35 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 5 lines

Hi Jagan,

On Monday, July 17, 2023 2:44 PM Jagan Teki

Quoted 1 line · <[email protected]> wrote:
Quoted 1 line

On Mon, Jul 17, 2023 at 11:44 AM Liu Ying <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some

configurations

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

and extensions to them are controlled by i.MX93 media blk-ctrl.

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific

extensions.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

I think the better way would add compatibility to be part of existing dw-mipi-dsi.c with specific driver data. This way it avoids all the platform-related helpers(extensions) and makes the driver generic to all SoCs which use DW DSI IP. It would be a straightforward change as the imx93 drm pipeline already supports bridge topology.

The platform-related stuff is handed over to dw-mipi-dsi.c via struct dw_mipi_dsi_plat_data as an argument of dw_mipi_dsi_probe(). It

looks

Quoted 10 lines
Quoted 9 lines
Quoted 1 line

ok for vendor drivers to call dw_mipi_dsi_probe() to set the platform-

related

Quoted 2 lines

information(rockchip, meson and stm do that), like pdata.phy_ops and pdata.host_ops.

I understand this topology of having soc-platform drivers with dw-mipi-dsi bridge. What I'm suggesting is to not add a soc-platform driver for imx93 instead add add support directly on dw-mipi-dsi bridge.

Quoted 4 lines

It seems that directly supporting i.MX93 MIPI DSI in dw-mipi-dsi.c is not feasible. The main reason is that struct dw_mipi_dsi_plat_data contains phy_ops and each vendor driver provides very different methods for phy, while...

Quoted 6 lines

Cannot this phy_ops goes to PHY core somewhere around and even it is possible to add via driver data for imx93 by untouching existing handling? I know it is not as direct as I describe but it is worth maintaining the driver this way to keep control of the future soc-drivers to include in dw-mipi-dsi instead of handling platform code separately.

Like I said, each vendor driver provides very different methods for phy. The reason is that phy IPs are different and SoC integration things are handled via struct dw_mipi_dsi_phy_ops. Meson calls devm_phy_get() to get a phy. Rockchip calls devm_phy_create() to create a phy. Meson, rockchip and stm have their own struct dw_mipi_dsi_phy_ops implementations, same to i.MX93. Different pixel format control is implemented in meson's and i.MX93's ->init() callback. Meson additionally handles clocks in ->init() callback.

Generally speaking, it's a no-go to put phy_ops into PHY core for all the vendors, IMHO.

In particular, i.MX93 MIPI DPHY's PLL can be fully controlled by media blk-ctrl(as a syscon) thru the PLL's SoC control interface, while PHY registers can be controlled by DW MIPI DSI testdin/out control interface alternatively including a part of the PLL registers. So, adding a PHY driver for i.MX93 MIPI DPHY doesn't make sense since the PLL controlled by media blk-ctrl doesn't constitute a PHY. Instead, dw_mipi_dsi_phy_ops may cover all the PHY control well.

Quoted 3 lines

From my PoV, w/wo this series, dw-mipi-dsi.c looks fine to keep being generic and easy to maintain. All vendor drivers do is to handle platform specific stuff, which is good.

Thanks for the explanation. I agreed with on you most of the points from the perspective of PoV which are difficult to FIT into a common bridge. However, I'm still believing that the having bridge does only the bridge job, and keeping the PHY or other PoV-specific stuff on respective driver subsystems would be great synergy for the bridge drivers or any common IP driver's point-of-view.

Anyway, I might not control i.MX93 PoV stuff, but I can try on it for the new DSI which uses this IP, and keep you in CC if it is a possible land in the near future.

Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

dw-mipi-dsi.c is generic w/wo this patch series.

Can you elaborate more about adding compatibility to be part of

existing

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

dw-mipi-dsi.c with specific driver data? I don't see clear approach to do that.

Please check the above comments, an example of samsung-dsim.c

... it seems that samsung-dsim.c uses struct samsung_dsim_driver_data to differential platform information and it doesn't contain any callback, which means comparing to DW MIPI DSI, Samsung DSIM shows more consistency across vendor SoCs from HW IP/SoC integration PoV.

Quoted 7 lines
Quoted 1 line

Yes, but is it possible to adjust struct according to DW MIPI DSI.

Looking at the vendor drivers, they show a lot diversity, which cannot be parameterized into a struct like the samsung dsim driver does.

struct dw_mipi_dsi_plat_data hides all platform specific information from dw-mipi-dsi.c well, IMHO.

Okay.

Thanks,
Jagan.

#24 lore raw
In reply to Liu Ying

Hi,

thanks for the patch.

Am Montag, 17. Juli 2023, 08:18:31 CEST schrieb Liu Ying:

Quoted 21 lines

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

---
 drivers/gpu/drm/bridge/imx/Kconfig          |  10 +
 drivers/gpu/drm/bridge/imx/Makefile         |   1 +
 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c | 934 ++++++++++++++++++++
 3 files changed, 945 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/Kconfig index 9fae28db6aa7..5182298c7182 100644

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI · line 49

Quoted 1 line
drivers/gpu/drm/bridge/imx/Kconfig +0 -0
@@ -49,4 +49,14 @@ config DRM_IMX8QXP_PIXEL_LINK_TO_DPI
 	  Choose this to enable pixel link to display pixel 

interface(PXL2DPI)

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI

Quoted 4 lines
drivers/gpu/drm/bridge/imx/Kconfig +2 -0
 	  found in Freescale i.MX8qxp processor.
 
+config DRM_IMX93_MIPI_DSI
+	tristate "Freescale i.MX93 specific extensions for Synopsys DW MIPI 

DSI"

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI

Quoted 6 lines
drivers/gpu/drm/bridge/imx/Kconfig +6 -0
+	depends on OF
+	depends on COMMON_CLK
+	select DRM_DW_MIPI_DSI
+	select GENERIC_PHY_MIPI_DPHY
+	help
+	  Choose this to enable MIPI DSI controller found in Freescale 

i.MX93

Quoted 23 lines
drivers/gpu/drm/bridge/imx/Kconfig +2 -0
+	  processor.
+
 endif # ARCH_MXC || COMPILE_TEST
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/Makefile index 8e2ebf3399a1..2b0c2e44aa1b 100644

drivers/gpu/drm/bridge/imx/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_IMX8QXP_LDB) += imx8qxp-ldb.o
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_COMBINER) += imx8qxp-pixel-combiner.o
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK) += imx8qxp-pixel-link.o
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK_TO_DPI) += imx8qxp-pxl2dpi.o
+obj-$(CONFIG_DRM_IMX93_MIPI_DSI) += imx93-mipi-dsi.o
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file mode 100644 index 000000000000..77f59e3407a0

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +2 -0
 
[snip]
 
+static int imx93_dsi_probe(struct platform_device *pdev)
+{

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 10 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +10 -0
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct imx93_dsi *dsi;
+	int ret;
+
+	dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
+	if (!dsi)
+		return -ENOMEM;
+
+	dsi->regmap = syscon_regmap_lookup_by_phandle(np, "fsl,media-blk-

ctrl");

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 3 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +3 -0
+	if (IS_ERR(dsi->regmap)) {
+		ret = PTR_ERR(dsi->regmap);
+		DRM_DEV_ERROR(dev, "failed to get block ctrl regmap: 

%d\n", ret);

Could you use dev_err_probe here instead?

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 8 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +8 -0
+		return ret;
+	}
+
+	dsi->clk_pixel = devm_clk_get(dev, "pix");
+	if (IS_ERR(dsi->clk_pixel)) {
+		ret = PTR_ERR(dsi->clk_pixel);
+		if (ret != -EPROBE_DEFER)
+			DRM_DEV_ERROR(dev, "failed to get pixel clock: 

%d\n", ret);

Could you use dev_err_probe here instead?

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 8 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +8 -0
+		return ret;
+	}
+
+	dsi->clk_cfg = devm_clk_get(dev, "phy_cfg");
+	if (IS_ERR(dsi->clk_cfg)) {
+		ret = PTR_ERR(dsi->clk_cfg);
+		if (ret != -EPROBE_DEFER)
+			DRM_DEV_ERROR(dev, "failed to get phy cfg clock: 

%d\n", ret);

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 8 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +8 -0
+		return ret;
+	}
+
+	dsi->clk_ref = devm_clk_get(dev, "phy_ref");
+	if (IS_ERR(dsi->clk_ref)) {
+		ret = PTR_ERR(dsi->clk_ref);
+		if (ret != -EPROBE_DEFER)
+			DRM_DEV_ERROR(dev, "failed to get phy ref clock: 

%d\n", ret);

Could you use dev_err_probe here instead?

Quoted 18 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +11 -0
+		return ret;
+	}
+
+	dsi->ref_clk_rate = clk_get_rate(dsi->clk_ref);
+	if (dsi->ref_clk_rate < REF_CLK_RATE_MIN ||
+	    dsi->ref_clk_rate > REF_CLK_RATE_MAX) {
+		DRM_DEV_ERROR(dev, "invalid phy ref clock rate %lu\n",
+			      dsi->ref_clk_rate);
+		return -EINVAL;
+	}
+	DRM_DEV_DEBUG_DRIVER(dev, "phy ref clock rate: %lu\n", dsi-

ref_clk_rate);

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +6 -0
+
+	dsi->dev = dev;
+	dsi->pdata.max_data_lanes = 4;
+	dsi->pdata.mode_valid = imx93_dsi_mode_valid;
+	dsi->pdata.mode_fixup = imx93_dsi_mode_fixup;
+	dsi->pdata.get_input_bus_fmts = imx93_dsi_get_input_bus_fmts;

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 10 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +10 -0
+	dsi->pdata.phy_ops = &imx93_dsi_phy_ops;
+	dsi->pdata.host_ops = &imx93_dsi_host_ops;
+	dsi->pdata.priv_data = dsi;
+	platform_set_drvdata(pdev, dsi);
+
+	dsi->dmd = dw_mipi_dsi_probe(pdev, &dsi->pdata);
+	if (IS_ERR(dsi->dmd)) {
+		ret = PTR_ERR(dsi->dmd);
+		if (ret != -EPROBE_DEFER)
+			DRM_DEV_ERROR(dev, "failed to probe dw_mipi_dsi: 

%d\n", ret);

Could you use dev_err_probe here instead?

Best regards,
Alexander

Quoted 32 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +32 -0
+		return ret;
+	}
+
+	return 0;
+}
+
+static void imx93_dsi_remove(struct platform_device *pdev)
+{
+	struct imx93_dsi *dsi = platform_get_drvdata(pdev);
+
+	dw_mipi_dsi_remove(dsi->dmd);
+}
+
+static const struct of_device_id imx93_dsi_dt_ids[] = {
+	{ .compatible = "fsl,imx93-mipi-dsi", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imx93_dsi_dt_ids);
+
+static struct platform_driver imx93_dsi_driver = {
+	.probe	= imx93_dsi_probe,
+	.remove_new = imx93_dsi_remove,
+	.driver	= {
+		.of_match_table = imx93_dsi_dt_ids,
+		.name = "imx93_mipi_dsi",
+	},
+};
+module_platform_driver(imx93_dsi_driver);
+
+MODULE_DESCRIPTION("Freescale i.MX93 MIPI DSI driver");
+MODULE_AUTHOR("Liu Ying <[email protected]>");
+MODULE_LICENSE("GPL");
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
author maintainer
#25 lore raw
Quoted 2 lines · Alexander Stein

Hi,

Hi,

Quoted 2 lines

thanks for the patch.

Thanks for your review.

Quoted 76 lines

Am Montag, 17. Juli 2023, 08:18:31 CEST schrieb Liu Ying:

Quoted 4 lines

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Quoted 8 lines

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

---
 drivers/gpu/drm/bridge/imx/Kconfig          |  10 +
 drivers/gpu/drm/bridge/imx/Makefile         |   1 +
 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c | 934

++++++++++++++++++++

Quoted 5 lines
 3 files changed, 945 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/Kconfig index

9fae28db6aa7..5182298c7182

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI · line 49

Quoted 5 lines

100644

drivers/gpu/drm/bridge/imx/Kconfig +0 -0
@@ -49,4 +49,14 @@ config DRM_IMX8QXP_PIXEL_LINK_TO_DPI
      Choose this to enable pixel link to display pixel

interface(PXL2DPI)

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI

Quoted 4 lines
drivers/gpu/drm/bridge/imx/Kconfig +2 -0
      found in Freescale i.MX8qxp processor.
 
+config DRM_IMX93_MIPI_DSI
+   tristate "Freescale i.MX93 specific extensions for Synopsys DW MIPI

DSI"

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI

Quoted 6 lines
drivers/gpu/drm/bridge/imx/Kconfig +6 -0
+   depends on OF
+   depends on COMMON_CLK
+   select DRM_DW_MIPI_DSI
+   select GENERIC_PHY_MIPI_DPHY
+   help
+     Choose this to enable MIPI DSI controller found in Freescale

i.MX93

Quoted 5 lines
drivers/gpu/drm/bridge/imx/Kconfig +2 -0
+     processor.
+
 endif # ARCH_MXC || COMPILE_TEST
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/Makefile index

8e2ebf3399a1..2b0c2e44aa1b

drivers/gpu/drm/bridge/imx/Makefile obj-$(CONFIG_DRM_IMX8QXP_LDB) += imx8qxp-ldb.o · line 4

Quoted 5 lines

100644

drivers/gpu/drm/bridge/imx/Makefile +0 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_IMX8QXP_LDB) += imx8qxp-ldb.o
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_COMBINER) += imx8qxp-pixel-

combiner.o

Quoted 13 lines
drivers/gpu/drm/bridge/imx/Makefile +1 -0
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK) += imx8qxp-pixel-link.o
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK_TO_DPI) += imx8qxp-pxl2dpi.o
+obj-$(CONFIG_DRM_IMX93_MIPI_DSI) += imx93-mipi-dsi.o
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file mode 100644 index 000000000000..77f59e3407a0

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +2 -0
 
[snip]
 
+static int imx93_dsi_probe(struct platform_device *pdev)
+{

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 10 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +10 -0
+   struct device *dev = &pdev->dev;
+   struct device_node *np = dev->of_node;
+   struct imx93_dsi *dsi;
+   int ret;
+
+   dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
+   if (!dsi)
+           return -ENOMEM;
+
+   dsi->regmap = syscon_regmap_lookup_by_phandle(np, "fsl,media-

blk-
ctrl");

Quoted 6 lines

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 3 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +3 -0
+   if (IS_ERR(dsi->regmap)) {
+           ret = PTR_ERR(dsi->regmap);
+           DRM_DEV_ERROR(dev, "failed to get block ctrl regmap:

%d\n", ret);

Could you use dev_err_probe here instead?

Maybe, it's better to keep using DRM_DEV_ERROR to achieve consistent error log format across the driver which is implemented in drm_dev_printk(). I see other DRM drivers do the same.

Quoted 9 lines

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 9 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +8 -0
+           return ret;
+   }
+
+   dsi->clk_pixel = devm_clk_get(dev, "pix");
+   if (IS_ERR(dsi->clk_pixel)) {
+           ret = PTR_ERR(dsi->clk_pixel);
+           if (ret != -EPROBE_DEFER)
+                   DRM_DEV_ERROR(dev, "failed to get pixel clock:
Quoted 3 lines

%d\n", ret);

Could you use dev_err_probe here instead?

Ditto.

Quoted 18 lines

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 9 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +8 -0
+           return ret;
+   }
+
+   dsi->clk_cfg = devm_clk_get(dev, "phy_cfg");
+   if (IS_ERR(dsi->clk_cfg)) {
+           ret = PTR_ERR(dsi->clk_cfg);
+           if (ret != -EPROBE_DEFER)
+                   DRM_DEV_ERROR(dev, "failed to get phy cfg clock:

%d\n", ret);

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 8 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +8 -0
+           return ret;
+   }
+
+   dsi->clk_ref = devm_clk_get(dev, "phy_ref");
+   if (IS_ERR(dsi->clk_ref)) {
+           ret = PTR_ERR(dsi->clk_ref);
+           if (ret != -EPROBE_DEFER)
+                   DRM_DEV_ERROR(dev, "failed to get phy ref clock:
Quoted 3 lines

%d\n", ret);

Could you use dev_err_probe here instead?

Ditto.

Quoted 31 lines
Quoted 19 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +11 -0
+           return ret;
+   }
+
+   dsi->ref_clk_rate = clk_get_rate(dsi->clk_ref);
+   if (dsi->ref_clk_rate < REF_CLK_RATE_MIN ||
+       dsi->ref_clk_rate > REF_CLK_RATE_MAX) {
+           DRM_DEV_ERROR(dev, "invalid phy ref clock rate %lu\n",
+                         dsi->ref_clk_rate);
+           return -EINVAL;
+   }
+   DRM_DEV_DEBUG_DRIVER(dev, "phy ref clock rate: %lu\n", dsi-

ref_clk_rate);

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +6 -0
+
+   dsi->dev = dev;
+   dsi->pdata.max_data_lanes = 4;
+   dsi->pdata.mode_valid = imx93_dsi_mode_valid;
+   dsi->pdata.mode_fixup = imx93_dsi_mode_fixup;
+   dsi->pdata.get_input_bus_fmts = imx93_dsi_get_input_bus_fmts;

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 10 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +10 -0
+   dsi->pdata.phy_ops = &imx93_dsi_phy_ops;
+   dsi->pdata.host_ops = &imx93_dsi_host_ops;
+   dsi->pdata.priv_data = dsi;
+   platform_set_drvdata(pdev, dsi);
+
+   dsi->dmd = dw_mipi_dsi_probe(pdev, &dsi->pdata);
+   if (IS_ERR(dsi->dmd)) {
+           ret = PTR_ERR(dsi->dmd);
+           if (ret != -EPROBE_DEFER)
+                   DRM_DEV_ERROR(dev, "failed to probe dw_mipi_dsi:

%d\n", ret);

Quoted 1 line

Could you use dev_err_probe here instead?

Ditto.

Regards,
Liu Ying

Quoted 51 lines

Best regards,
Alexander

Quoted 22 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +22 -0
+           return ret;
+   }
+
+   return 0;
+}
+
+static void imx93_dsi_remove(struct platform_device *pdev)
+{
+   struct imx93_dsi *dsi = platform_get_drvdata(pdev);
+
+   dw_mipi_dsi_remove(dsi->dmd);
+}
+
+static const struct of_device_id imx93_dsi_dt_ids[] = {
+   { .compatible = "fsl,imx93-mipi-dsi", },
+   { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imx93_dsi_dt_ids);
+
+static struct platform_driver imx93_dsi_driver = {
+   .probe  = imx93_dsi_probe,
+   .remove_new = imx93_dsi_remove,

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c line 934

Quoted 10 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +10 -0
+   .driver = {
+           .of_match_table = imx93_dsi_dt_ids,
+           .name = "imx93_mipi_dsi",
+   },
+};
+module_platform_driver(imx93_dsi_driver);
+
+MODULE_DESCRIPTION("Freescale i.MX93 MIPI DSI driver");
+MODULE_AUTHOR("Liu Ying <[email protected]>");
+MODULE_LICENSE("GPL");

--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.t/
q- group.com%2F&data=05%7C01%7Cvictor.liu%40nxp.com%7Cc42417f9a9484 3ead2b808db876380d3%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0 %7C638252633665634690%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C% 7C%7C&sdata=GUWOZgHFFp0nKImw2aIAsaqMv9KtgI6%2BD%2BaOdDhJ%2B tU%3D&reserved=0

#26 lore raw

Hi,

Am Dienstag, 18. Juli 2023, 11:00:25 CEST schrieb Ying Liu:

Quoted 1 line

On Tuesday, July 18, 2023 3:49 PM Alexander Stein <[email protected]

Quoted 108 lines · group.com> wrote:
Quoted 1 line

Hi,

Hi,

Quoted 1 line

thanks for the patch.

Thanks for your review.

Quoted 100 lines

Am Montag, 17. Juli 2023, 08:18:31 CEST schrieb Liu Ying:

Quoted 7 lines

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

Quoted 6 lines

---

 drivers/gpu/drm/bridge/imx/Kconfig          |  10 +
 drivers/gpu/drm/bridge/imx/Makefile         |   1 +
 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c | 934

++++++++++++++++++++

Quoted 5 lines
 3 files changed, 945 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/Kconfig index

9fae28db6aa7..5182298c7182

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI · line 50

Quoted 6 lines

100644

drivers/gpu/drm/bridge/imx/Kconfig +0 -0
@@ -49,4 +49,14 @@ config DRM_IMX8QXP_PIXEL_LINK_TO_DPI
 
      Choose this to enable pixel link to display pixel

interface(PXL2DPI)

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI

Quoted 4 lines
drivers/gpu/drm/bridge/imx/Kconfig +2 -0
      found in Freescale i.MX8qxp processor.
 
+config DRM_IMX93_MIPI_DSI
+   tristate "Freescale i.MX93 specific extensions for Synopsys DW MIPI

DSI"

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI

Quoted 6 lines
drivers/gpu/drm/bridge/imx/Kconfig +6 -0
+   depends on OF
+   depends on COMMON_CLK
+   select DRM_DW_MIPI_DSI
+   select GENERIC_PHY_MIPI_DPHY
+   help
+     Choose this to enable MIPI DSI controller found in Freescale

i.MX93

Quoted 7 lines
drivers/gpu/drm/bridge/imx/Kconfig +2 -0
+     processor.
+

endif # ARCH_MXC || COMPILE_TEST

(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/Makefile index

8e2ebf3399a1..2b0c2e44aa1b

drivers/gpu/drm/bridge/imx/Makefile obj-$(CONFIG_DRM_IMX8QXP_LDB) += imx8qxp-ldb.o · line 5

Quoted 6 lines

100644

drivers/gpu/drm/bridge/imx/Makefile +0 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_IMX8QXP_LDB) += imx8qxp-ldb.o
 
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_COMBINER) += imx8qxp-pixel-

combiner.o

Quoted 14 lines
drivers/gpu/drm/bridge/imx/Makefile +1 -0
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK) += imx8qxp-pixel-link.o
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK_TO_DPI) += imx8qxp-pxl2dpi.o
 
+obj-$(CONFIG_DRM_IMX93_MIPI_DSI) += imx93-mipi-dsi.o
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file mode 100644 index 000000000000..77f59e3407a0

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +2 -0
 
[snip]
 
+static int imx93_dsi_probe(struct platform_device *pdev)
+{

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 10 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +10 -0
+   struct device *dev = &pdev->dev;
+   struct device_node *np = dev->of_node;
+   struct imx93_dsi *dsi;
+   int ret;
+
+   dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
+   if (!dsi)
+           return -ENOMEM;
+
+   dsi->regmap = syscon_regmap_lookup_by_phandle(np, "fsl,media-

blk-
ctrl");

Quoted 2 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +2 -0
+   if (IS_ERR(dsi->regmap)) {
+           ret = PTR_ERR(dsi->regmap);
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

+ DRM_DEV_ERROR(dev, "failed to get block ctrl regmap:

%d\n", ret);

Could you use dev_err_probe here instead?

Maybe, it's better to keep using DRM_DEV_ERROR to achieve consistent error log format across the driver which is implemented in drm_dev_printk(). I see other DRM drivers do the same.

I see your point. On the other hand the benefit of dev_err_probe() is that the message of deferred probe can be seen in /sys/kernel/debug/devices_deferred. Your check against EPROBE_DEFER will hide the message if something is not correct.

Maybe a to be introduced DRM_DEV_ERROR_PROBE might be useful.

Best regards,
Alexander

Quoted 129 lines
Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +7 -0
+           return ret;
+   }
+
+   dsi->clk_pixel = devm_clk_get(dev, "pix");
+   if (IS_ERR(dsi->clk_pixel)) {
+           ret = PTR_ERR(dsi->clk_pixel);
+           if (ret != -EPROBE_DEFER)
Quoted 4 lines
Quoted 1 line

+ DRM_DEV_ERROR(dev, "failed to get pixel clock:

%d\n", ret);

Could you use dev_err_probe here instead?

Ditto.

Quoted 19 lines

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 9 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +8 -0
+           return ret;
+   }
+
+   dsi->clk_cfg = devm_clk_get(dev, "phy_cfg");
+   if (IS_ERR(dsi->clk_cfg)) {
+           ret = PTR_ERR(dsi->clk_cfg);
+           if (ret != -EPROBE_DEFER)
 
+                   DRM_DEV_ERROR(dev, "failed to get phy cfg clock:

%d\n", ret);

Quoted 7 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +7 -0
+           return ret;
+   }
+
+   dsi->clk_ref = devm_clk_get(dev, "phy_ref");
+   if (IS_ERR(dsi->clk_ref)) {
+           ret = PTR_ERR(dsi->clk_ref);
+           if (ret != -EPROBE_DEFER)
Quoted 4 lines
Quoted 1 line

+ DRM_DEV_ERROR(dev, "failed to get phy ref clock:

%d\n", ret);

Could you use dev_err_probe here instead?

Ditto.

Quoted 30 lines
Quoted 29 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +11 -0
+           return ret;
+   }
+
+   dsi->ref_clk_rate = clk_get_rate(dsi->clk_ref);
+   if (dsi->ref_clk_rate < REF_CLK_RATE_MIN ||
+       dsi->ref_clk_rate > REF_CLK_RATE_MAX) {
+           DRM_DEV_ERROR(dev, "invalid phy ref clock rate %lu\n",
+                         dsi->ref_clk_rate);
+           return -EINVAL;
+   }
+   DRM_DEV_DEBUG_DRIVER(dev, "phy ref clock rate: %lu\n", dsi-

ref_clk_rate);

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +15 -0
+
+   dsi->dev = dev;
+   dsi->pdata.max_data_lanes = 4;
+   dsi->pdata.mode_valid = imx93_dsi_mode_valid;
+   dsi->pdata.mode_fixup = imx93_dsi_mode_fixup;
+   dsi->pdata.get_input_bus_fmts = imx93_dsi_get_input_bus_fmts;
+   dsi->pdata.phy_ops = &imx93_dsi_phy_ops;
+   dsi->pdata.host_ops = &imx93_dsi_host_ops;
+   dsi->pdata.priv_data = dsi;
+   platform_set_drvdata(pdev, dsi);
+
+   dsi->dmd = dw_mipi_dsi_probe(pdev, &dsi->pdata);
+   if (IS_ERR(dsi->dmd)) {
+           ret = PTR_ERR(dsi->dmd);
+           if (ret != -EPROBE_DEFER)
Quoted 4 lines
Quoted 1 line

+ DRM_DEV_ERROR(dev, "failed to probe dw_mipi_dsi:

%d\n", ret);

Could you use dev_err_probe here instead?

Ditto.

Regards,
Liu Ying

Quoted 48 lines

Best regards,
Alexander

Quoted 22 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +22 -0
+           return ret;
+   }
+
+   return 0;
+}
+
+static void imx93_dsi_remove(struct platform_device *pdev)
+{
+   struct imx93_dsi *dsi = platform_get_drvdata(pdev);
+
+   dw_mipi_dsi_remove(dsi->dmd);
+}
+
+static const struct of_device_id imx93_dsi_dt_ids[] = {
+   { .compatible = "fsl,imx93-mipi-dsi", },
+   { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imx93_dsi_dt_ids);
+
+static struct platform_driver imx93_dsi_driver = {
+   .probe  = imx93_dsi_probe,
+   .remove_new = imx93_dsi_remove,

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c line 934

Quoted 10 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +10 -0
+   .driver = {
+           .of_match_table = imx93_dsi_dt_ids,
+           .name = "imx93_mipi_dsi",
+   },
+};
+module_platform_driver(imx93_dsi_driver);
+
+MODULE_DESCRIPTION("Freescale i.MX93 MIPI DSI driver");
+MODULE_AUTHOR("Liu Ying <[email protected]>");
+MODULE_LICENSE("GPL");

--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.t/
q- group.com%2F&data=05%7C01%7Cvictor.liu%40nxp.com%7Cc42417f9a9484 3ead2b808db876380d3%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0 %7C638252633665634690%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C% 7C%7C&sdata=GUWOZgHFFp0nKImw2aIAsaqMv9KtgI6%2BD%2BaOdDhJ%2B tU%3D&reserved=0

Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
author maintainer
#27 lore raw
Quoted 2 lines · Alexander Stein

Hi,

Hi,

Quoted 125 lines

Am Dienstag, 18. Juli 2023, 11:00:25 CEST schrieb Ying Liu:

Quoted 1 line

On Tuesday, July 18, 2023 3:49 PM Alexander Stein

<[email protected]

Quoted 68 lines · group.com> wrote:
Quoted 1 line

Hi,

Hi,

Quoted 1 line

thanks for the patch.

Thanks for your review.

Quoted 60 lines

Am Montag, 17. Juli 2023, 08:18:31 CEST schrieb Liu Ying:

Quoted 7 lines

Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

Quoted 6 lines

---

 drivers/gpu/drm/bridge/imx/Kconfig          |  10 +
 drivers/gpu/drm/bridge/imx/Makefile         |   1 +
 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c | 934

++++++++++++++++++++

Quoted 5 lines
 3 files changed, 945 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/Kconfig index

9fae28db6aa7..5182298c7182

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI · line 50

Quoted 6 lines

100644

drivers/gpu/drm/bridge/imx/Kconfig +0 -0
@@ -49,4 +49,14 @@ config DRM_IMX8QXP_PIXEL_LINK_TO_DPI
 
      Choose this to enable pixel link to display pixel

interface(PXL2DPI)

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI

Quoted 4 lines
drivers/gpu/drm/bridge/imx/Kconfig +2 -0
      found in Freescale i.MX8qxp processor.
 
+config DRM_IMX93_MIPI_DSI
+   tristate "Freescale i.MX93 specific extensions for Synopsys DW MIPI

DSI"

drivers/gpu/drm/bridge/imx/Kconfig config DRM_IMX8QXP_PIXEL_LINK_TO_DPI

Quoted 6 lines
drivers/gpu/drm/bridge/imx/Kconfig +6 -0
+   depends on OF
+   depends on COMMON_CLK
+   select DRM_DW_MIPI_DSI
+   select GENERIC_PHY_MIPI_DPHY
+   help
+     Choose this to enable MIPI DSI controller found in Freescale

i.MX93

Quoted 7 lines
drivers/gpu/drm/bridge/imx/Kconfig +2 -0
+     processor.
+

endif # ARCH_MXC || COMPILE_TEST

(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/Makefile index

8e2ebf3399a1..2b0c2e44aa1b

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/bridge/imx/Makefile obj-$(CONFIG_DRM_IMX8QXP_LDB) += imx8qxp-

Quoted 4 lines

100644

drivers/gpu/drm/bridge/imx/Makefile +0 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_IMX8QXP_LDB) += imx8qxp-

ldb.o

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/bridge/imx/Makefile obj-$(CONFIG_DRM_IMX8QXP_LDB) += imx8qxp- · line 4

Quoted 2 lines
drivers/gpu/drm/bridge/imx/Makefile +0 -0
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_COMBINER) += imx8qxp-pixel-

combiner.o

Quoted 2 lines
drivers/gpu/drm/bridge/imx/Makefile +0 -0
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK) += imx8qxp-pixel-link.o
 obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK_TO_DPI) += imx8qxp-

pxl2dpi.o

Quoted 29 lines
Quoted 29 lines
Quoted 12 lines
drivers/gpu/drm/bridge/imx/Makefile +1 -0
+obj-$(CONFIG_DRM_IMX93_MIPI_DSI) += imx93-mipi-dsi.o
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file mode 100644 index 000000000000..77f59e3407a0

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +2 -0
 
[snip]
 
+static int imx93_dsi_probe(struct platform_device *pdev)
+{

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 10 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +10 -0
+   struct device *dev = &pdev->dev;
+   struct device_node *np = dev->of_node;
+   struct imx93_dsi *dsi;
+   int ret;
+
+   dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
+   if (!dsi)
+           return -ENOMEM;
+
+   dsi->regmap = syscon_regmap_lookup_by_phandle(np, "fsl,media-

blk-
ctrl");

Quoted 2 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +2 -0
+   if (IS_ERR(dsi->regmap)) {
+           ret = PTR_ERR(dsi->regmap);
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

+ DRM_DEV_ERROR(dev, "failed to get block ctrl regmap:

%d\n", ret);

Could you use dev_err_probe here instead?

Maybe, it's better to keep using DRM_DEV_ERROR to achieve consistent error log format across the driver which is implemented in

drm_dev_printk().

Quoted 1 line

I see other DRM drivers do the same.

Quoted 7 lines

I see your point. On the other hand the benefit of dev_err_probe() is that the message of deferred probe can be seen in /sys/kernel/debug/devices_deferred.
Your check against EPROBE_DEFER will hide the message if something is not correct.

Maybe a to be introduced DRM_DEV_ERROR_PROBE might be useful.

Maybe. I assume this is not a must-have for this series - maybe someone may come along to introduce it in future.

Regards,
Liu Ying

Quoted 159 lines

Best regards,
Alexander

Quoted 72 lines
Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +7 -0
+           return ret;
+   }
+
+   dsi->clk_pixel = devm_clk_get(dev, "pix");
+   if (IS_ERR(dsi->clk_pixel)) {
+           ret = PTR_ERR(dsi->clk_pixel);
+           if (ret != -EPROBE_DEFER)
Quoted 4 lines
Quoted 1 line

+ DRM_DEV_ERROR(dev, "failed to get pixel clock:

%d\n", ret);

Could you use dev_err_probe here instead?

Ditto.

Quoted 19 lines

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 9 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +8 -0
+           return ret;
+   }
+
+   dsi->clk_cfg = devm_clk_get(dev, "phy_cfg");
+   if (IS_ERR(dsi->clk_cfg)) {
+           ret = PTR_ERR(dsi->clk_cfg);
+           if (ret != -EPROBE_DEFER)
 
+                   DRM_DEV_ERROR(dev, "failed to get phy cfg clock:

%d\n", ret);

Quoted 7 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +7 -0
+           return ret;
+   }
+
+   dsi->clk_ref = devm_clk_get(dev, "phy_ref");
+   if (IS_ERR(dsi->clk_ref)) {
+           ret = PTR_ERR(dsi->clk_ref);
+           if (ret != -EPROBE_DEFER)
Quoted 4 lines
Quoted 1 line

+ DRM_DEV_ERROR(dev, "failed to get phy ref clock:

%d\n", ret);

Could you use dev_err_probe here instead?

Ditto.

Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +11 -0
+           return ret;
+   }
+
+   dsi->ref_clk_rate = clk_get_rate(dsi->clk_ref);
+   if (dsi->ref_clk_rate < REF_CLK_RATE_MIN ||
+       dsi->ref_clk_rate > REF_CLK_RATE_MAX) {
+           DRM_DEV_ERROR(dev, "invalid phy ref clock rate %lu\n",
+                         dsi->ref_clk_rate);
+           return -EINVAL;
+   }
+   DRM_DEV_DEBUG_DRIVER(dev, "phy ref clock rate: %lu\n", dsi-

ref_clk_rate);

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +16 -0
+
+   dsi->dev = dev;
+   dsi->pdata.max_data_lanes = 4;
+   dsi->pdata.mode_valid = imx93_dsi_mode_valid;
+   dsi->pdata.mode_fixup = imx93_dsi_mode_fixup;
+   dsi->pdata.get_input_bus_fmts = imx93_dsi_get_input_bus_fmts;
+   dsi->pdata.phy_ops = &imx93_dsi_phy_ops;
+   dsi->pdata.host_ops = &imx93_dsi_host_ops;
+   dsi->pdata.priv_data = dsi;
+   platform_set_drvdata(pdev, dsi);
+
+   dsi->dmd = dw_mipi_dsi_probe(pdev, &dsi->pdata);
+   if (IS_ERR(dsi->dmd)) {
+           ret = PTR_ERR(dsi->dmd);
+           if (ret != -EPROBE_DEFER)
 
+                   DRM_DEV_ERROR(dev, "failed to probe dw_mipi_dsi:
Quoted 50 lines
Quoted 3 lines

%d\n", ret);

Could you use dev_err_probe here instead?

Ditto.

Regards,
Liu Ying

Quoted 41 lines

Best regards,
Alexander

Quoted 22 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +22 -0
+           return ret;
+   }
+
+   return 0;
+}
+
+static void imx93_dsi_remove(struct platform_device *pdev)
+{
+   struct imx93_dsi *dsi = platform_get_drvdata(pdev);
+
+   dw_mipi_dsi_remove(dsi->dmd);
+}
+
+static const struct of_device_id imx93_dsi_dt_ids[] = {
+   { .compatible = "fsl,imx93-mipi-dsi", },
+   { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imx93_dsi_dt_ids);
+
+static struct platform_driver imx93_dsi_driver = {
+   .probe  = imx93_dsi_probe,
+   .remove_new = imx93_dsi_remove,

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c line 934

Quoted 10 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +10 -0
+   .driver = {
+           .of_match_table = imx93_dsi_dt_ids,
+           .name = "imx93_mipi_dsi",
+   },
+};
+module_platform_driver(imx93_dsi_driver);
+
+MODULE_DESCRIPTION("Freescale i.MX93 MIPI DSI driver");
+MODULE_AUTHOR("Liu Ying <[email protected]>");
+MODULE_LICENSE("GPL");

--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider

http://www.t/
%2F&data=05%7C01%7Cvictor.liu%40nxp.com%7Cefbbc19ba3414f89448308 db8771b5df%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638252 694676247773%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJ QIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdat a=BCL6xs5i8jZZDFC2ONKMv5%2B1o0mpuD0ocxC3BnUa2To%3D&reserved=0

Quoted 2 lines
Quoted 2 lines

q-

group.com%2F&data=05%7C01%7Cvictor.liu%40nxp.com%7Cc42417f9a9484

Quoted 1 line
Quoted 1 line

3ead2b808db876380d3%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0

Quoted 1 line
Quoted 1 line

%7C638252633665634690%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4

wLj

Quoted 1 line
Quoted 1 line

AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%

Quoted 1 line
Quoted 1 line

7C%7C&sdata=GUWOZgHFFp0nKImw2aIAsaqMv9KtgI6%2BD%2BaOdDhJ%2B

Quoted 1 line
Quoted 1 line

tU%3D&reserved=0

--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.t/
q- group.com%2F&data=05%7C01%7Cvictor.liu%40nxp.com%7Cefbbc19ba3414 f89448308db8771b5df%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0% 7C638252694676247773%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjA wMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7 C%7C&sdata=%2FCtQd5%2BYCDCjOKmsbiO2LSeE1hqQsrmhepmSGalydhc%3 D&reserved=0

#28 lore raw
In reply to Ying Liu

Hi Ying Liu,

Quoted 10 lines · Ying Liu
Quoted 6 lines

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 3 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +3 -0
+   if (IS_ERR(dsi->regmap)) {
+           ret = PTR_ERR(dsi->regmap);
+           DRM_DEV_ERROR(dev, "failed to get block ctrl regmap:

%d\n", ret);

Could you use dev_err_probe here instead?

Maybe, it's better to keep using DRM_DEV_ERROR to achieve consistent error log format across the driver which is implemented in drm_dev_printk(). I see other DRM drivers do the same.

All the DRM_* macros are deprecated.
New code shall use drm_*, dev_* or pr_ as appropriate.

The appropriate variant here is dev_err_probe().

Sam

author maintainer
#29 lore raw
Quoted 2 lines · Sam Ravnborg

Hi Ying Liu,

Hi Sam,

Quoted 9 lines · Ying Liu
Quoted 7 lines
Quoted 6 lines

drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Quoted 3 lines
drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file +3 -0
+   if (IS_ERR(dsi->regmap)) {
+           ret = PTR_ERR(dsi->regmap);
+           DRM_DEV_ERROR(dev, "failed to get block ctrl regmap:

%d\n", ret);

Could you use dev_err_probe here instead?

Quoted 7 lines
Quoted 2 lines

Maybe, it's better to keep using DRM_DEV_ERROR to achieve consistent error log format across the driver which is implemented in

drm_dev_printk().

Quoted 1 line

I see other DRM drivers do the same.

All the DRM_* macros are deprecated.
New code shall use drm_*, dev_* or pr_ as appropriate.

Ok, will use dev_* in v2.

Quoted 2 lines

The appropriate variant here is dev_err_probe().

Ok, will use dev_err_probe() here in v2.

Regards,
Liu Ying

Quoted 2 lines

Sam

#30 lore raw
In reply to Liu Ying
kernel test robot noticed the following build errors:

Hi Liu,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-exynos/exynos-drm-next]
[also build test ERROR on drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.5-rc2 next-20230718] [cannot apply to drm-misc/drm-misc-next drm/drm-next]
[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/Liu-Ying/drm-bridge-synopsys-dw-mipi-dsi-Add-dw_mipi_dsi_get_bridge-helper/20230718-172247
base:   https://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git exynos-drm-next
patch link:    https://lore.kernel.org/r/20230717061831.1826878-10-victor.liu%40nxp.com
patch subject: [PATCH 9/9] drm/bridge: imx: Add i.MX93 MIPI DSI support
config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20230719/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230719/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

In file included from arch/arm/include/asm/div64.h:107,

                    from include/linux/math.h:6,
                    from include/linux/kernel.h:26,
                    from include/linux/clk.h:13,
                    from drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c:9:
   drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c: In function 'dphy_pll_get_configure_from_opts':
   include/asm-generic/div64.h:222:35: warning: comparison of distinct pointer types lacks a cast
     222 |         (void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
         |                                   ^~
   drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c:272:17: note: in expansion of macro 'do_div'
     272 |                 do_div(tmp, n * fvco_div);
         |                 ^~~~~~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bitfield.h:10,
                    from drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c:7:
>> include/asm-generic/div64.h:234:32: warning: right shift count >= width of type [-Wshift-count-overflow]
     234 |         } else if (likely(((n) >> 32) == 0)) {          \
         |                                ^~
   include/linux/compiler.h:76:45: note: in definition of macro 'likely'
      76 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c:272:17: note: in expansion of macro 'do_div'
     272 |                 do_div(tmp, n * fvco_div);
         |                 ^~~~~~
>> include/asm-generic/div64.h:238:36: error: passing argument 1 of '__div64_32' from incompatible pointer type [-Werror=incompatible-pointer-types]
     238 |                 __rem = __div64_32(&(n), __base);       \
         |                                    ^~~~
         |                                    |
         |                                    long unsigned int *
   drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c:272:17: note: in expansion of macro 'do_div'
     272 |                 do_div(tmp, n * fvco_div);
         |                 ^~~~~~
   arch/arm/include/asm/div64.h:24:45: note: expected 'uint64_t *' {aka 'long long unsigned int *'} but argument is of type 'long unsigned int *'
      24 | static inline uint32_t __div64_32(uint64_t *n, uint32_t base)
         |                                   ~~~~~~~~~~^

cc1: some warnings being treated as errors

vim +/__div64_32 +238 include/asm-generic/div64.h

^1da177e4c3f41 Linus Torvalds     2005-04-16  215  
^1da177e4c3f41 Linus Torvalds     2005-04-16  216  /* The unnecessary pointer compare is there
^1da177e4c3f41 Linus Torvalds     2005-04-16  217   * to check for type safety (n must be 64bit)
^1da177e4c3f41 Linus Torvalds     2005-04-16  218   */
^1da177e4c3f41 Linus Torvalds     2005-04-16  219  # define do_div(n,base) ({				\
^1da177e4c3f41 Linus Torvalds     2005-04-16  220  	uint32_t __base = (base);			\
^1da177e4c3f41 Linus Torvalds     2005-04-16  221  	uint32_t __rem;					\
^1da177e4c3f41 Linus Torvalds     2005-04-16  222  	(void)(((typeof((n)) *)0) == ((uint64_t *)0));	\
911918aa7ef6f8 Nicolas Pitre      2015-11-02  223  	if (__builtin_constant_p(__base) &&		\
911918aa7ef6f8 Nicolas Pitre      2015-11-02  224  	    is_power_of_2(__base)) {			\
911918aa7ef6f8 Nicolas Pitre      2015-11-02  225  		__rem = (n) & (__base - 1);		\
911918aa7ef6f8 Nicolas Pitre      2015-11-02  226  		(n) >>= ilog2(__base);			\
c747ce4706190e Geert Uytterhoeven 2021-08-11  227  	} else if (__builtin_constant_p(__base) &&	\
461a5e51060c93 Nicolas Pitre      2015-10-30  228  		   __base != 0) {			\
461a5e51060c93 Nicolas Pitre      2015-10-30  229  		uint32_t __res_lo, __n_lo = (n);	\
461a5e51060c93 Nicolas Pitre      2015-10-30  230  		(n) = __div64_const32(n, __base);	\
461a5e51060c93 Nicolas Pitre      2015-10-30  231  		/* the remainder can be computed with 32-bit regs */ \
461a5e51060c93 Nicolas Pitre      2015-10-30  232  		__res_lo = (n);				\
461a5e51060c93 Nicolas Pitre      2015-10-30  233  		__rem = __n_lo - __res_lo * __base;	\
911918aa7ef6f8 Nicolas Pitre      2015-11-02 @234  	} else if (likely(((n) >> 32) == 0)) {		\
^1da177e4c3f41 Linus Torvalds     2005-04-16  235  		__rem = (uint32_t)(n) % __base;		\
^1da177e4c3f41 Linus Torvalds     2005-04-16  236  		(n) = (uint32_t)(n) / __base;		\
c747ce4706190e Geert Uytterhoeven 2021-08-11  237  	} else {					\
^1da177e4c3f41 Linus Torvalds     2005-04-16 @238  		__rem = __div64_32(&(n), __base);	\
c747ce4706190e Geert Uytterhoeven 2021-08-11  239  	}						\
^1da177e4c3f41 Linus Torvalds     2005-04-16  240  	__rem;						\
^1da177e4c3f41 Linus Torvalds     2005-04-16  241   })
^1da177e4c3f41 Linus Torvalds     2005-04-16  242  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#31 lore raw
In reply to Liu Ying

Hi,

Am Montag, 17. Juli 2023, 08:18:22 CEST schrieb Liu Ying:

Quoted 43 lines

Hi,

This series aims to add MIPI DSI support for Freescale i.MX93 SoC.

There is a Synopsys DesignWare MIPI DSI host controller and a Synopsys Designware MIPI DPHY embedded in i.MX93. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

Note that since this series touches the dw-mipi-dsi driver, tests are needed to be done for meson, rockchip and stm.

Patch 1 ~ 7 do preparation work for adding i.MX93 MIPI DSI DRM bridge driver.

Patch 8 adds DT-binding documentation for i.MX93 MIPI DSI.

Patch 9 adds i.MX93 MIPI DSI DRM bridge.

Liu Ying (9):
drm/bridge: synopsys: dw-mipi-dsi: Add dw_mipi_dsi_get_bridge() helper drm/bridge: synopsys: dw-mipi-dsi: Add input bus format negotiation
support
drm/bridge: synopsys: dw-mipi-dsi: Force input bus flags drm/bridge: synopsys: dw-mipi-dsi: Add mode fixup support drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate
lbcc
drm/bridge: synopsys: dw-mipi-dsi: Set minimum lane byte clock cycles
for HSA and HBP
drm/bridge: synopsys: dw-mipi-dsi: Disable HSTX and LPRX timeout check
dt-bindings: display: bridge: Document Freescale i.MX93 MIPI DSI drm/bridge: imx: Add i.MX93 MIPI DSI support

 .../display/bridge/fsl,imx93-mipi-dsi.yaml    | 115 +++
 drivers/gpu/drm/bridge/imx/Kconfig            |  10 +
 drivers/gpu/drm/bridge/imx/Makefile           |   1 +
 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c   | 934 ++++++++++++++++++
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c |  91 +-
 include/drm/bridge/dw_mipi_dsi.h              |  16 +
 6 files changed, 1163 insertions(+), 4 deletions(-)
 create mode 100644
Quoted 2 lines

Documentation/devicetree/bindings/display/bridge/fsl,imx93-mipi-dsi.yaml create mode 100644 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Thanks for posting this patch series. I was trying to use this driver on our TQMa93xxLA platform where the DSI signals are connected to a TC9595 (driver tc358767) DSI-to-DP bridge.
Unfortunately this bridge requires the DSI signals to be in LP-11 upon reset and while in idle, otherwise not even DP AUX channel is functional. Apparently DSI is currently not in LP-11. But reading the RM I have no idea how to configure the DSI host to achieve that. Do you have additional information which might help me here?
Also could you provide your DT configuration?

Thanks and best regards,
Alexander

Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
author maintainer
#32 lore raw
Quoted 2 lines · Alexander Stein

Hi,

Hi,

Quoted 47 lines

Am Montag, 17. Juli 2023, 08:18:22 CEST schrieb Liu Ying:

Quoted 35 lines

Hi,

This series aims to add MIPI DSI support for Freescale i.MX93 SoC.

There is a Synopsys DesignWare MIPI DSI host controller and a Synopsys Designware MIPI DPHY embedded in i.MX93. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl.

Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions.

Note that since this series touches the dw-mipi-dsi driver, tests are needed to be done for meson, rockchip and stm.

Patch 1 ~ 7 do preparation work for adding i.MX93 MIPI DSI DRM bridge driver.

Patch 8 adds DT-binding documentation for i.MX93 MIPI DSI.

Patch 9 adds i.MX93 MIPI DSI DRM bridge.

Liu Ying (9):
drm/bridge: synopsys: dw-mipi-dsi: Add dw_mipi_dsi_get_bridge() helper drm/bridge: synopsys: dw-mipi-dsi: Add input bus format negotiation
support
drm/bridge: synopsys: dw-mipi-dsi: Force input bus flags drm/bridge: synopsys: dw-mipi-dsi: Add mode fixup support drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate
lbcc
drm/bridge: synopsys: dw-mipi-dsi: Set minimum lane byte clock cycles
for HSA and HBP
drm/bridge: synopsys: dw-mipi-dsi: Disable HSTX and LPRX timeout check
dt-bindings: display: bridge: Document Freescale i.MX93 MIPI DSI drm/bridge: imx: Add i.MX93 MIPI DSI support

Quoted 4 lines
 .../display/bridge/fsl,imx93-mipi-dsi.yaml    | 115 +++
 drivers/gpu/drm/bridge/imx/Kconfig            |  10 +
 drivers/gpu/drm/bridge/imx/Makefile           |   1 +
 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c   | 934

++++++++++++++++++

Quoted 5 lines
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c |  91 +-
 include/drm/bridge/dw_mipi_dsi.h              |  16 +
 6 files changed, 1163 insertions(+), 4 deletions(-)
 create mode 100644

Documentation/devicetree/bindings/display/bridge/fsl,imx93-mipi-

Quoted 7 lines

dsi.yaml

Quoted 1 line

create mode 100644 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c

Thanks for posting this patch series. I was trying to use this driver on our TQMa93xxLA platform where the DSI signals are connected to a TC9595 (driver
tc358767) DSI-to-DP bridge.

Thanks for trying to test/use this driver.

I don't have TC9595 bridge to test, unfortunately.

Quoted 5 lines

Unfortunately this bridge requires the DSI signals to be in LP-11 upon reset and while in idle, otherwise not even DP AUX channel is functional. Apparently DSI is currently not in LP-11. But reading the RM I have no idea how to configure the DSI host to achieve that. Do you have additional information which might help me here?

Hmm, probably no.
But, I tested ADV7535 DSI to HDMI bridge or RM67191 DSI panel on i.MX93 11x11 EVK with this series, which works.

Quoted 1 line

Also could you provide your DT configuration?

For media blk-ctrl, dsi and lcdif, see:
https://pastebin.mozilla.org/aP8tFrPM

For adv7535 display pipeline, see:
https://pastebin.mozilla.org/89zwvr9Y

Note assigned-clock-rates is needed in lcdif DT node to suggest video pll rate.

Regards,
Liu Ying

Quoted 16 lines

Thanks and best regards,
Alexander
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.t/
q- group.com%2F&data=05%7C01%7Cvictor.liu%40nxp.com%7Cbf329d1b4d704 801a94f08db876225f6%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0% 7C638252627845769696%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjA wMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7 C%7C&sdata=Q4wBL6Ji0wcMVIJpuR1gNAqBtFgUiJAwA5QvesFoGLc%3D&rese rved=0