Skip to contentSkip to conversation

drm: bridge: samsung-dsim: Add i.MX8M Plus support

PATCH In review Marek Vasut 2 participants 2 messages Oct 15, 2022 – Nov 2, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: bridge: samsung-dsim: Add i.MX8M Plus support

Add extras to support i.MX8M Plus. The main change is the removal of HS/VS/DE signal inversion in the LCDIFv3-DSIM glue logic, otherwise the implementation of this IP in i.MX8M Plus is very much compatible with the i.MX8M Mini/Nano one.

---
Cc: Adam Ford <[email protected]>
Cc: Andrzej Hajda <[email protected]>
Cc: Frieder Schrempf <[email protected]>
Cc: Inki Dae <[email protected]>
Cc: Jagan Teki <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: Matteo Lisi <[email protected]>
Cc: Michael Nazzareno Trimarchi <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Seung-Woo Kim <[email protected]>
Cc: Tim Harvey <[email protected]>
Cc: Tommaso Merciai <[email protected]>
Cc: linux-amarula <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]

---
 drivers/gpu/drm/bridge/samsung-dsim.c | 55 +++++++++++++++++++++------
 include/drm/bridge/samsung-dsim.h     |  1 +
 2 files changed, 44 insertions(+), 12 deletions(-)
drivers/gpu/drm/bridge/samsung-dsim.c +43 -12
index 012d8b6463ad6..cf40fd8813ff2 100644
@@ -465,6 +465,7 @@ samsung_dsim_types[SAMSUNG_DSIM_TYPE_COUNT] = {
 	[SAMSUNG_DSIM_TYPE_EXYNOS5422] = &exynos5422_dsi_driver_data,
 	[SAMSUNG_DSIM_TYPE_EXYNOS5433] = &exynos5433_dsi_driver_data,
 	[SAMSUNG_DSIM_TYPE_IMX8MM] = &imx8mm_dsi_driver_data,
+	[SAMSUNG_DSIM_TYPE_IMX8MP] = &imx8mm_dsi_driver_data,
 };
 
 static inline struct samsung_dsim *host_to_dsi(struct mipi_dsi_host *h)
@@ -1404,18 +1405,26 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
 	struct samsung_dsim *dsi = bridge_to_dsi(bridge);
 	struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
 
+	/*
+	 * The i.MX8M Mini/Nano glue logic between LCDIF and DSIM
+	 * inverts HS/VS/DE sync signals polarity, therefore, while
+	 * i.MX 8M Mini Applications Processor Reference Manual Rev. 3, 11/2020
+	 * 13.6.3.5.2 RGB interface
+	 * i.MX 8M Nano Applications Processor Reference Manual Rev. 2, 07/2022
+	 * 13.6.2.7.2 RGB interface
+	 * both claim "Vsync, Hsync, and VDEN are active high signals.", the
+	 * LCDIF must generate inverted HS/VS/DE signals, i.e. active LOW.
+	 *
+	 * The i.MX8M Plus glue logic between LCDIFv3 and DSIM does not
+	 * implement the same behavior, therefore LCDIFv3 must generate
+	 * HS/VS/DE signals active HIGH.
+	 */
 	if (dsi->plat_data->hw_type == SAMSUNG_DSIM_TYPE_IMX8MM) {
-		/**
-		 * FIXME:
-		 * At least LCDIF + DSIM needs active low sync,
-		 * but i.MX 8M Mini Applications Processor Reference Manual,
-		 * Rev. 3, 11/2020 says
-		 *
-		 * 13.6.3.5.2 RGB interface
-		 * Vsync, Hsync, and VDEN are active high signals.
-		 */
 		adjusted_mode->flags |= (DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC);
 		adjusted_mode->flags &= ~(DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
+	} else if (dsi->plat_data->hw_type == SAMSUNG_DSIM_TYPE_IMX8MP) {
+		adjusted_mode->flags &= ~(DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC);
+		adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
 	}
 
 	return 0;
@@ -1448,7 +1457,8 @@ static int samsung_dsim_attach(struct drm_bridge *bridge,
 	 * Passing NULL to the previous bridge makes Exynos DSI drivers
 	 * work which is exactly done before.
 	 */
-	if (!(dsi->plat_data->hw_type == SAMSUNG_DSIM_TYPE_IMX8MM))
+	if (dsi->plat_data->hw_type != SAMSUNG_DSIM_TYPE_IMX8MM &&
+	    dsi->plat_data->hw_type != SAMSUNG_DSIM_TYPE_IMX8MP)
 		previous = NULL;
 
 	return drm_bridge_attach(bridge->encoder, dsi->out_bridge, previous,
@@ -1649,7 +1659,11 @@ static const struct samsung_dsim_host_ops samsung_dsim_generic_host_ops = {
 	.unregister_host = samsung_dsim_unregister_host,
 };
 
-static const struct drm_bridge_timings samsung_dsim_bridge_timings = {
+static const struct drm_bridge_timings samsung_dsim_bridge_timings_de_high = {
+	.input_bus_flags = DRM_BUS_FLAG_DE_HIGH,
+};
+
+static const struct drm_bridge_timings samsung_dsim_bridge_timings_de_low = {
 	.input_bus_flags = DRM_BUS_FLAG_DE_LOW,
 };
 
@@ -1733,9 +1747,17 @@ int samsung_dsim_probe(struct platform_device *pdev)
 
 	dsi->bridge.funcs = &samsung_dsim_bridge_funcs;
 	dsi->bridge.of_node = dev->of_node;
-	dsi->bridge.timings = &samsung_dsim_bridge_timings;
 	dsi->bridge.type = DRM_MODE_CONNECTOR_DSI;
 
+	/*
+	 * The i.MX8M Mini/Nano LCDIF-DSIM glue logic inverts DE signal
+	 * polarity, see comment in samsung_dsim_atomic_check().
+	 */
+	if (dsi->plat_data->hw_type == SAMSUNG_DSIM_TYPE_IMX8MM)
+		dsi->bridge.timings = &samsung_dsim_bridge_timings_de_low;
+	else
+		dsi->bridge.timings = &samsung_dsim_bridge_timings_de_high;
+
 	if (dsi->plat_data->host_ops && dsi->plat_data->host_ops->register_host)
 		ret = dsi->plat_data->host_ops->register_host(dsi);
 
@@ -1841,11 +1863,20 @@ static const struct samsung_dsim_plat_data samsung_dsim_imx8mm_pdata = {
 	.host_ops = &samsung_dsim_generic_host_ops,
 };
 
+static const struct samsung_dsim_plat_data samsung_dsim_imx8mp_pdata = {
+	.hw_type = SAMSUNG_DSIM_TYPE_IMX8MP,
+	.host_ops = &samsung_dsim_generic_host_ops,
+};
+
 static const struct of_device_id samsung_dsim_of_match[] = {
 	{
 		.compatible = "fsl,imx8mm-mipi-dsim",
 		.data = &samsung_dsim_imx8mm_pdata,
 	},
+	{
+		.compatible = "fsl,imx8mp-mipi-dsim",
+		.data = &samsung_dsim_imx8mp_pdata,
+	},
 	{ /* sentinel. */ }
 };
 MODULE_DEVICE_TABLE(of, samsung_dsim_of_match);
include/drm/bridge/samsung-dsim.h +1 -0
index df3d030daec6a..3789f9dbb238b 100644
@@ -28,6 +28,7 @@ enum samsung_dsim_type {
 	SAMSUNG_DSIM_TYPE_EXYNOS5422,
 	SAMSUNG_DSIM_TYPE_EXYNOS5433,
 	SAMSUNG_DSIM_TYPE_IMX8MM,
+	SAMSUNG_DSIM_TYPE_IMX8MP,
 	SAMSUNG_DSIM_TYPE_COUNT,
 };
 
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Marek

Quoted 6 lines · Marek Vasut

Add extras to support i.MX8M Plus. The main change is the removal of HS/VS/DE signal inversion in the LCDIFv3-DSIM glue logic, otherwise the implementation of this IP in i.MX8M Plus is very much compatible with the i.MX8M Mini/Nano one.

I also tried to test it on Verdin iMX8M Plus but so far I was unable to make it work. Either I am still missing some other pieces or I got the imx8mp.dtsi parts wrong. Do you have them available somewhere by any chance?

Thanks!

Cheers

Marcel

Quoted 147 lines

---
Cc: Adam Ford <[email protected]>
Cc: Andrzej Hajda <[email protected]>
Cc: Frieder Schrempf <[email protected]>
Cc: Inki Dae <[email protected]>
Cc: Jagan Teki <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: Matteo Lisi <[email protected]>
Cc: Michael Nazzareno Trimarchi <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Seung-Woo Kim <[email protected]>
Cc: Tim Harvey <[email protected]>
Cc: Tommaso Merciai <[email protected]>
Cc: linux-amarula <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]
---
 drivers/gpu/drm/bridge/samsung-dsim.c | 55 +++++++++++++++++++++------ include/drm/bridge/samsung-dsim.h     |  1 +

 2 files changed, 44 insertions(+), 12 deletions(-)
drivers/gpu/drm/bridge/samsung-dsim.c +1 -0
index 012d8b6463ad6..cf40fd8813ff2 100644
@@ -465,6 +465,7 @@ samsung_dsim_types[SAMSUNG_DSIM_TYPE_COUNT] = {
         [SAMSUNG_DSIM_TYPE_EXYNOS5422] = &exynos5422_dsi_driver_data,
         [SAMSUNG_DSIM_TYPE_EXYNOS5433] = &exynos5433_dsi_driver_data,
         [SAMSUNG_DSIM_TYPE_IMX8MM] = &imx8mm_dsi_driver_data,
+       [SAMSUNG_DSIM_TYPE_IMX8MP] = &imx8mm_dsi_driver_data,
  };


 static inline struct samsung_dsim *host_to_dsi(struct mipi_dsi_host *h)

drivers/gpu/drm/bridge/samsung-dsim.c +0 -0
@@ -1404,18 +1405,26 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
         struct samsung_dsim *dsi = bridge_to_dsi(bridge);
         struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;


+       /*
+        * The i.MX8M Mini/Nano glue logic between LCDIF and DSIM
+        * inverts HS/VS/DE sync signals polarity, therefore, while
+        * i.MX 8M Mini Applications Processor Reference Manual Rev. 3, 11/2020 +        * 13.6.3.5.2 RGB interface
+        * i.MX 8M Nano Applications Processor Reference Manual Rev. 2, 07/2022 +        * 13.6.2.7.2 RGB interface
+        * both claim "Vsync, Hsync, and VDEN are active high signals.", the +        * LCDIF must generate inverted HS/VS/DE signals, i.e. active LOW. +        *
+        * The i.MX8M Plus glue logic between LCDIFv3 and DSIM does not
+        * implement the same behavior, therefore LCDIFv3 must generate
+        * HS/VS/DE signals active HIGH.
+        */
        if (dsi->plat_data->hw_type == SAMSUNG_DSIM_TYPE_IMX8MM) {
-               /**
-                * FIXME:
-                * At least LCDIF + DSIM needs active low sync,
-                * but i.MX 8M Mini Applications Processor Reference Manual, -                * Rev. 3, 11/2020 says
-                *
-                * 13.6.3.5.2 RGB interface
-                * Vsync, Hsync, and VDEN are active high signals.
-                */
                adjusted_mode->flags |= (DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC); adjusted_mode->flags &= ~(DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC); +       } else if (dsi->plat_data->hw_type == SAMSUNG_DSIM_TYPE_IMX8MP) { +               adjusted_mode->flags &= ~(DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC); +               adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC); }

        return 0;

drivers/gpu/drm/bridge/samsung-dsim.c +2 -1
@@ -1448,7 +1457,8 @@ static int samsung_dsim_attach(struct drm_bridge *bridge,
          * Passing NULL to the previous bridge makes Exynos DSI drivers
          * work which is exactly done before.
          */
-       if (!(dsi->plat_data->hw_type == SAMSUNG_DSIM_TYPE_IMX8MM))
+       if (dsi->plat_data->hw_type != SAMSUNG_DSIM_TYPE_IMX8MM &&
+           dsi->plat_data->hw_type != SAMSUNG_DSIM_TYPE_IMX8MP)
                 previous = NULL;


        return drm_bridge_attach(bridge->encoder, dsi->out_bridge, previous,

drivers/gpu/drm/bridge/samsung-dsim.c +0 -0
@@ -1649,7 +1659,11 @@ static const struct samsung_dsim_host_ops samsung_dsim_generic_host_ops = {
         .unregister_host = samsung_dsim_unregister_host,
  };

drivers/gpu/drm/bridge/samsung-dsim.c +5 -1
-static const struct drm_bridge_timings samsung_dsim_bridge_timings = {
+static const struct drm_bridge_timings samsung_dsim_bridge_timings_de_high = {
+       .input_bus_flags = DRM_BUS_FLAG_DE_HIGH,
+};
+
+static const struct drm_bridge_timings samsung_dsim_bridge_timings_de_low = {

        .input_bus_flags = DRM_BUS_FLAG_DE_LOW,
 };

drivers/gpu/drm/bridge/samsung-dsim.c +0 -0
@@ -1733,9 +1747,17 @@ int samsung_dsim_probe(struct platform_device *pdev)


        dsi->bridge.funcs = &samsung_dsim_bridge_funcs; dsi->bridge.of_node = dev->of_node;
-       dsi->bridge.timings = &samsung_dsim_bridge_timings; dsi->bridge.type = DRM_MODE_CONNECTOR_DSI;

+       /*
+        * The i.MX8M Mini/Nano LCDIF-DSIM glue logic inverts DE signal +        * polarity, see comment in samsung_dsim_atomic_check().
+        */
+       if (dsi->plat_data->hw_type == SAMSUNG_DSIM_TYPE_IMX8MM)
+               dsi->bridge.timings = &samsung_dsim_bridge_timings_de_low; +       else
+               dsi->bridge.timings = &samsung_dsim_bridge_timings_de_high; +
        if (dsi->plat_data->host_ops && dsi->plat_data->host_ops->register_host) ret = dsi->plat_data->host_ops->register_host(dsi);

drivers/gpu/drm/bridge/samsung-dsim.c +0 -0
@@ -1841,11 +1863,20 @@ static const struct samsung_dsim_plat_data samsung_dsim_imx8mm_pdata = {
         .host_ops = &samsung_dsim_generic_host_ops,
  };

drivers/gpu/drm/bridge/samsung-dsim.c +5 -0
+static const struct samsung_dsim_plat_data samsung_dsim_imx8mp_pdata = {
+       .hw_type = SAMSUNG_DSIM_TYPE_IMX8MP,
+       .host_ops = &samsung_dsim_generic_host_ops,
+};
+

 static const struct of_device_id samsung_dsim_of_match[] = { {
                .compatible = "fsl,imx8mm-mipi-dsim", .data = &samsung_dsim_imx8mm_pdata, },
+       {
+               .compatible = "fsl,imx8mp-mipi-dsim", +               .data = &samsung_dsim_imx8mp_pdata, +       },
        { /* sentinel. */ }
 };
 MODULE_DEVICE_TABLE(of, samsung_dsim_of_match);

include/drm/bridge/samsung-dsim.h +1 -0
index df3d030daec6a..3789f9dbb238b 100644
@@ -28,6 +28,7 @@ enum samsung_dsim_type {
         SAMSUNG_DSIM_TYPE_EXYNOS5422,
         SAMSUNG_DSIM_TYPE_EXYNOS5433,
         SAMSUNG_DSIM_TYPE_IMX8MM,
+       SAMSUNG_DSIM_TYPE_IMX8MP,
         SAMSUNG_DSIM_TYPE_COUNT,
  };