linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Add MIPI CSI-2 support for i.MX8ULP
@ 2025-08-12  8:19 guoniu.zhou
  2025-08-12  8:19 ` [PATCH 1/5] media: dt-bindings: nxp,imx8mq-mipi-csi2: Add i.MX8ULP compatible string guoniu.zhou
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: guoniu.zhou @ 2025-08-12  8:19 UTC (permalink / raw)
  To: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel
  Cc: rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam, frank.li

From: Guoniu Zhou <guoniu.zhou@nxp.com>

Add MIPI CSI-2 support for i.MX8ULP.

Guoniu Zhou (5):
  media: dt-bindings: nxp,imx8mq-mipi-csi2: Add i.MX8ULP compatible
    string
  arm64: dts: imx8ulp: Add CSI and ISI Nodes
  media: imx8mq-mipi-csi2: Use devm_clk_bulk_get_all() to fetch clocks
  media: imx8mq-mipi-csi2: Explicitly release reset
  media: imx8mq-mipi-csi2: Add support for i.MX8ULP

 .../bindings/media/nxp,imx8mq-mipi-csi2.yaml  | 23 +++++++
 arch/arm64/boot/dts/freescale/imx8ulp.dtsi    | 67 +++++++++++++++++++
 drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 59 +++++-----------
 3 files changed, 108 insertions(+), 41 deletions(-)

-- 
base-commit: d968e50b5c26642754492dea23cbd3592bde62d8
--
2.34.1


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

* [PATCH 1/5] media: dt-bindings: nxp,imx8mq-mipi-csi2: Add i.MX8ULP compatible string
  2025-08-12  8:19 [PATCH 0/5] Add MIPI CSI-2 support for i.MX8ULP guoniu.zhou
@ 2025-08-12  8:19 ` guoniu.zhou
  2025-08-12  8:34   ` Krzysztof Kozlowski
  2025-08-12 16:25   ` Frank Li
  2025-08-12  8:19 ` [PATCH 2/5] arm64: dts: imx8ulp: Add CSI and ISI Nodes guoniu.zhou
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 12+ messages in thread
From: guoniu.zhou @ 2025-08-12  8:19 UTC (permalink / raw)
  To: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel
  Cc: rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam, frank.li

From: Guoniu Zhou <guoniu.zhou@nxp.com>

The CSI-2 receiver in the i.MX8ULP is almost identical to the
version present in the i.MX8QXP/QM. But have different reset
and clock design, so add a device-specific compatible string
for i.MX8ULP to handle the difference.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
 .../bindings/media/nxp,imx8mq-mipi-csi2.yaml  | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml b/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml
index 3389bab266a9..83fdda2252e5 100644
--- a/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml
+++ b/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml
@@ -20,6 +20,7 @@ properties:
       - enum:
           - fsl,imx8mq-mipi-csi2
           - fsl,imx8qxp-mipi-csi2
+          - fsl,imx8ulp-mipi-csi2
       - items:
           - const: fsl,imx8qm-mipi-csi2
           - const: fsl,imx8qxp-mipi-csi2
@@ -39,12 +40,17 @@ properties:
                      clock that the RX DPHY receives.
       - description: ui is the pixel clock (phy_ref up to 333Mhz).
                      See the reference manual for details.
+      - description: pclk is the lpav bus clock of i.MX8ULP.
+                     See the reference manual for details.
+    minItems: 3
 
   clock-names:
     items:
       - const: core
       - const: esc
       - const: ui
+      - const: pclk
+    minItems: 3
 
   power-domains:
     maxItems: 1
@@ -137,6 +143,23 @@ allOf:
           minItems: 2
         resets:
           maxItems: 1
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - fsl,imx8ulp-mipi-csi2
+    then:
+      properties:
+        reg:
+          minItems: 2
+        resets:
+          maxItems: 2
+        clocks:
+          minItems: 4
+        clock-names:
+          minItems: 4
     else:
       properties:
         reg:
-- 
2.34.1


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

* [PATCH 2/5] arm64: dts: imx8ulp: Add CSI and ISI Nodes
  2025-08-12  8:19 [PATCH 0/5] Add MIPI CSI-2 support for i.MX8ULP guoniu.zhou
  2025-08-12  8:19 ` [PATCH 1/5] media: dt-bindings: nxp,imx8mq-mipi-csi2: Add i.MX8ULP compatible string guoniu.zhou
@ 2025-08-12  8:19 ` guoniu.zhou
  2025-08-12 16:28   ` Frank Li
  2025-08-12  8:19 ` [PATCH 3/5] media: imx8mq-mipi-csi2: Use devm_clk_bulk_get_all() to fetch clocks guoniu.zhou
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: guoniu.zhou @ 2025-08-12  8:19 UTC (permalink / raw)
  To: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel
  Cc: rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam, frank.li

From: Guoniu Zhou <guoniu.zhou@nxp.com>

The CSI-2 in the i.MX8ULP is almost identical to the version present
in the i.MX8QXP/QM and is routed to the ISI. Add both the ISI and CSI
nodes and mark them as disabled by default since capture is dependent
on an attached camera.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
 arch/arm64/boot/dts/freescale/imx8ulp.dtsi | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi b/arch/arm64/boot/dts/freescale/imx8ulp.dtsi
index 2562a35286c2..71abc2a3d505 100644
--- a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8ulp.dtsi
@@ -7,6 +7,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/power/imx8ulp-power.h>
+#include <dt-bindings/reset/imx8ulp-pcc-reset.h>
 #include <dt-bindings/thermal/thermal.h>
 
 #include "imx8ulp-pinfunc.h"
@@ -840,6 +841,72 @@ spdif: spdif@2dab0000 {
 				dma-names = "rx", "tx";
 				status = "disabled";
 			};
+
+			isi: isi@2dac0000 {
+				compatible = "fsl,imx8ulp-isi";
+				reg = <0x2dac0000 0x10000>;
+				interrupts = <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&pcc5 IMX8ULP_CLK_ISI>,
+					 <&cgc2 IMX8ULP_CLK_LPAV_AXI_DIV>;
+				clock-names = "axi", "apb";
+				power-domains = <&scmi_devpd IMX8ULP_PD_ISI>;
+				status = "disabled";
+
+				ports {
+					#address-cells = <1>;
+					#size-cells = <0>;
+
+					port@0 {
+						reg = <0>;
+						isi_in: endpoint {
+							remote-endpoint = <&mipi_csi_out>;
+						};
+					};
+				};
+			};
+
+			mipi_csi: csi@2daf0000 {
+				compatible = "fsl,imx8ulp-mipi-csi2";
+				reg = <0x2daf0000 0x10000>,
+				      <0x2dad0000 0x10000>;
+				clocks = <&pcc5 IMX8ULP_CLK_CSI>,
+					 <&pcc5 IMX8ULP_CLK_CSI_CLK_ESC>,
+					 <&pcc5 IMX8ULP_CLK_CSI_CLK_UI>,
+					 <&pcc5 IMX8ULP_CLK_CSI_REGS>;
+				clock-names = "core", "esc", "ui", "pclk";
+				assigned-clocks = <&pcc5 IMX8ULP_CLK_CSI>,
+						  <&pcc5 IMX8ULP_CLK_CSI_CLK_ESC>,
+						  <&pcc5 IMX8ULP_CLK_CSI_CLK_UI>,
+						  <&pcc5 IMX8ULP_CLK_CSI_REGS>;
+				assigned-clock-parents = <&cgc2 IMX8ULP_CLK_PLL4_PFD1_DIV1>,
+							 <&cgc2 IMX8ULP_CLK_PLL4_PFD1_DIV2>,
+							 <&cgc2 IMX8ULP_CLK_PLL4_PFD0_DIV1>;
+				assigned-clock-rates = <200000000>,
+						       <80000000>,
+						       <100000000>,
+						       <79200000>;
+				power-domains = <&scmi_devpd IMX8ULP_PD_MIPI_CSI>;
+				resets = <&pcc5 PCC5_CSI_SWRST>,
+					 <&pcc5 PCC5_CSI_REGS_SWRST>;
+				status = "disabled";
+
+				ports {
+					#address-cells = <1>;
+					#size-cells = <0>;
+
+					port@0 {
+						reg = <0>;
+					};
+
+					port@1 {
+						reg = <1>;
+
+						mipi_csi_out: endpoint {
+							remote-endpoint = <&isi_in>;
+						};
+					};
+				};
+			};
 		};
 
 		gpiod: gpio@2e200000 {
-- 
2.34.1


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

* [PATCH 3/5] media: imx8mq-mipi-csi2: Use devm_clk_bulk_get_all() to fetch clocks
  2025-08-12  8:19 [PATCH 0/5] Add MIPI CSI-2 support for i.MX8ULP guoniu.zhou
  2025-08-12  8:19 ` [PATCH 1/5] media: dt-bindings: nxp,imx8mq-mipi-csi2: Add i.MX8ULP compatible string guoniu.zhou
  2025-08-12  8:19 ` [PATCH 2/5] arm64: dts: imx8ulp: Add CSI and ISI Nodes guoniu.zhou
@ 2025-08-12  8:19 ` guoniu.zhou
  2025-08-12 16:31   ` Frank Li
  2025-08-12  8:19 ` [PATCH 4/5] media: imx8mq-mipi-csi2: Explicitly release reset guoniu.zhou
  2025-08-12  8:19 ` [PATCH 5/5] media: imx8mq-mipi-csi2: Add support for i.MX8ULP guoniu.zhou
  4 siblings, 1 reply; 12+ messages in thread
From: guoniu.zhou @ 2025-08-12  8:19 UTC (permalink / raw)
  To: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel
  Cc: rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam, frank.li

From: Guoniu Zhou <guoniu.zhou@nxp.com>

Use devm_clk_bulk_get_all() helper to simplify clock handle code.

No functional changes intended.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
 drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 52 ++++++-------------
 1 file changed, 15 insertions(+), 37 deletions(-)

diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
index ed6578f7f0f9..be07ff27071f 100644
--- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
+++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
@@ -72,21 +72,6 @@ enum {
 	ST_SUSPENDED	= 4,
 };
 
-enum imx8mq_mipi_csi_clk {
-	CSI2_CLK_CORE,
-	CSI2_CLK_ESC,
-	CSI2_CLK_UI,
-	CSI2_NUM_CLKS,
-};
-
-static const char * const imx8mq_mipi_csi_clk_id[CSI2_NUM_CLKS] = {
-	[CSI2_CLK_CORE] = "core",
-	[CSI2_CLK_ESC] = "esc",
-	[CSI2_CLK_UI] = "ui",
-};
-
-#define CSI2_NUM_CLKS	ARRAY_SIZE(imx8mq_mipi_csi_clk_id)
-
 struct imx8mq_plat_data {
 	int (*enable)(struct csi_state *state, u32 hs_settle);
 	void (*disable)(struct csi_state *state);
@@ -112,7 +97,8 @@ struct csi_state {
 	struct device *dev;
 	const struct imx8mq_plat_data *pdata;
 	void __iomem *regs;
-	struct clk_bulk_data clks[CSI2_NUM_CLKS];
+	struct clk_bulk_data *clks;
+	int num_clks;
 	struct reset_control *rst;
 	struct regulator *mipi_phy_regulator;
 
@@ -417,24 +403,16 @@ static void imx8mq_mipi_csi_set_params(struct csi_state *state)
 			      CSI2RX_SEND_LEVEL);
 }
 
-static int imx8mq_mipi_csi_clk_enable(struct csi_state *state)
-{
-	return clk_bulk_prepare_enable(CSI2_NUM_CLKS, state->clks);
-}
-
-static void imx8mq_mipi_csi_clk_disable(struct csi_state *state)
+static struct clk *find_esc_clk(struct csi_state *state)
 {
-	clk_bulk_disable_unprepare(CSI2_NUM_CLKS, state->clks);
-}
-
-static int imx8mq_mipi_csi_clk_get(struct csi_state *state)
-{
-	unsigned int i;
+	int i;
 
-	for (i = 0; i < CSI2_NUM_CLKS; i++)
-		state->clks[i].id = imx8mq_mipi_csi_clk_id[i];
+	for (i = 0; i < state->num_clks; i++) {
+		if (!strcmp(state->clks[i].id, "esc"))
+			return state->clks[i].clk;
+	}
 
-	return devm_clk_bulk_get(state->dev, CSI2_NUM_CLKS, state->clks);
+	return NULL;
 }
 
 static int imx8mq_mipi_csi_calc_hs_settle(struct csi_state *state,
@@ -489,7 +467,7 @@ static int imx8mq_mipi_csi_calc_hs_settle(struct csi_state *state,
 	 * documentation recommends picking a value away from the boundaries.
 	 * Let's pick the average.
 	 */
-	esc_clk_rate = clk_get_rate(state->clks[CSI2_CLK_ESC].clk);
+	esc_clk_rate = clk_get_rate(find_esc_clk(state));
 	if (!esc_clk_rate) {
 		dev_err(state->dev, "Could not get esc clock rate.\n");
 		return -EINVAL;
@@ -848,7 +826,7 @@ static void imx8mq_mipi_csi_pm_suspend(struct device *dev)
 
 	if (state->state & ST_POWERED) {
 		imx8mq_mipi_csi_stop_stream(state);
-		imx8mq_mipi_csi_clk_disable(state);
+		clk_bulk_disable_unprepare(state->num_clks, state->clks);
 		state->state &= ~ST_POWERED;
 	}
 
@@ -866,7 +844,7 @@ static int imx8mq_mipi_csi_pm_resume(struct device *dev)
 
 	if (!(state->state & ST_POWERED)) {
 		state->state |= ST_POWERED;
-		ret = imx8mq_mipi_csi_clk_enable(state);
+		ret = clk_bulk_prepare_enable(state->num_clks, state->clks);
 	}
 	if (state->state & ST_STREAMING) {
 		sd_state = v4l2_subdev_lock_and_get_active_state(sd);
@@ -1092,9 +1070,9 @@ static int imx8mq_mipi_csi_probe(struct platform_device *pdev)
 	if (IS_ERR(state->regs))
 		return PTR_ERR(state->regs);
 
-	ret = imx8mq_mipi_csi_clk_get(state);
-	if (ret < 0)
-		return ret;
+	state->num_clks = devm_clk_bulk_get_all(dev, &state->clks);
+	if (state->num_clks < 0)
+		return dev_err_probe(dev, state->num_clks, "Failed to get clocks\n");
 
 	platform_set_drvdata(pdev, &state->sd);
 
-- 
2.34.1


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

* [PATCH 4/5] media: imx8mq-mipi-csi2: Explicitly release reset
  2025-08-12  8:19 [PATCH 0/5] Add MIPI CSI-2 support for i.MX8ULP guoniu.zhou
                   ` (2 preceding siblings ...)
  2025-08-12  8:19 ` [PATCH 3/5] media: imx8mq-mipi-csi2: Use devm_clk_bulk_get_all() to fetch clocks guoniu.zhou
@ 2025-08-12  8:19 ` guoniu.zhou
  2025-08-12 16:38   ` Frank Li
  2025-08-12  8:19 ` [PATCH 5/5] media: imx8mq-mipi-csi2: Add support for i.MX8ULP guoniu.zhou
  4 siblings, 1 reply; 12+ messages in thread
From: guoniu.zhou @ 2025-08-12  8:19 UTC (permalink / raw)
  To: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel
  Cc: rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam, frank.li

From: Guoniu Zhou <guoniu.zhou@nxp.com>

Call reset_control_deassert() to explicitly release reset to
make sure reset bits are cleared since platform like i.MX8ULP
can't clear its reset bits automatically.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
 drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
index be07ff27071f..071d939d9048 100644
--- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
+++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
@@ -371,9 +371,7 @@ static int imx8mq_mipi_csi_sw_reset(struct csi_state *state)
 	int ret;
 
 	/*
-	 * these are most likely self-clearing reset bits. to make it
-	 * more clear, the reset-imx7 driver should implement the
-	 * .reset() operation.
+	 * Explicitly release reset to make sure reset bits are cleared.
 	 */
 	ret = reset_control_assert(state->rst);
 	if (ret < 0) {
@@ -381,7 +379,7 @@ static int imx8mq_mipi_csi_sw_reset(struct csi_state *state)
 		return ret;
 	}
 
-	return 0;
+	return reset_control_deassert(state->rst);
 }
 
 static void imx8mq_mipi_csi_set_params(struct csi_state *state)
-- 
2.34.1


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

* [PATCH 5/5] media: imx8mq-mipi-csi2: Add support for i.MX8ULP
  2025-08-12  8:19 [PATCH 0/5] Add MIPI CSI-2 support for i.MX8ULP guoniu.zhou
                   ` (3 preceding siblings ...)
  2025-08-12  8:19 ` [PATCH 4/5] media: imx8mq-mipi-csi2: Explicitly release reset guoniu.zhou
@ 2025-08-12  8:19 ` guoniu.zhou
  2025-08-12 16:41   ` Frank Li
  4 siblings, 1 reply; 12+ messages in thread
From: guoniu.zhou @ 2025-08-12  8:19 UTC (permalink / raw)
  To: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel
  Cc: rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam, frank.li

From: Guoniu Zhou <guoniu.zhou@nxp.com>

The CSI-2 receiver in i.MX8ULP is almost same as i.MX8QXP/QM except
clocks and resets, so add compatible string for i.MX8ULP to handle
the difference and reuse platform data of i.MX8QXP/QM.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
 drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
index 071d939d9048..14cd08f9a4f6 100644
--- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
+++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
@@ -1136,6 +1136,7 @@ static void imx8mq_mipi_csi_remove(struct platform_device *pdev)
 static const struct of_device_id imx8mq_mipi_csi_of_match[] = {
 	{ .compatible = "fsl,imx8mq-mipi-csi2", .data = &imx8mq_data },
 	{ .compatible = "fsl,imx8qxp-mipi-csi2", .data = &imx8qxp_data },
+	{ .compatible = "fsl,imx8ulp-mipi-csi2", .data = &imx8qxp_data },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, imx8mq_mipi_csi_of_match);
-- 
2.34.1


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

* Re: [PATCH 1/5] media: dt-bindings: nxp,imx8mq-mipi-csi2: Add i.MX8ULP compatible string
  2025-08-12  8:19 ` [PATCH 1/5] media: dt-bindings: nxp,imx8mq-mipi-csi2: Add i.MX8ULP compatible string guoniu.zhou
@ 2025-08-12  8:34   ` Krzysztof Kozlowski
  2025-08-12 16:25   ` Frank Li
  1 sibling, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2025-08-12  8:34 UTC (permalink / raw)
  To: guoniu.zhou, linux-media, devicetree, imx, linux-arm-kernel,
	linux-kernel
  Cc: rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam, frank.li

On 12/08/2025 10:19, guoniu.zhou@oss.nxp.com wrote:
> From: Guoniu Zhou <guoniu.zhou@nxp.com>
> 
> The CSI-2 receiver in the i.MX8ULP is almost identical to the
> version present in the i.MX8QXP/QM. But have different reset
> and clock design, so add a device-specific compatible string
> for i.MX8ULP to handle the difference.
> 
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
> ---
>  .../bindings/media/nxp,imx8mq-mipi-csi2.yaml  | 23 +++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml b/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml
> index 3389bab266a9..83fdda2252e5 100644
> --- a/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml
> +++ b/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml
> @@ -20,6 +20,7 @@ properties:
>        - enum:
>            - fsl,imx8mq-mipi-csi2
>            - fsl,imx8qxp-mipi-csi2
> +          - fsl,imx8ulp-mipi-csi2
>        - items:
>            - const: fsl,imx8qm-mipi-csi2
>            - const: fsl,imx8qxp-mipi-csi2
> @@ -39,12 +40,17 @@ properties:
>                       clock that the RX DPHY receives.
>        - description: ui is the pixel clock (phy_ref up to 333Mhz).
>                       See the reference manual for details.
> +      - description: pclk is the lpav bus clock of i.MX8ULP.
> +                     See the reference manual for details.
> +    minItems: 3

You need to restrict all variants. Or explain why old hardware has now 4
clocks. That explanation is missing.

Best regards,
Krzysztof

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

* Re: [PATCH 1/5] media: dt-bindings: nxp,imx8mq-mipi-csi2: Add i.MX8ULP compatible string
  2025-08-12  8:19 ` [PATCH 1/5] media: dt-bindings: nxp,imx8mq-mipi-csi2: Add i.MX8ULP compatible string guoniu.zhou
  2025-08-12  8:34   ` Krzysztof Kozlowski
@ 2025-08-12 16:25   ` Frank Li
  1 sibling, 0 replies; 12+ messages in thread
From: Frank Li @ 2025-08-12 16:25 UTC (permalink / raw)
  To: guoniu.zhou
  Cc: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel,
	rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam

On Tue, Aug 12, 2025 at 04:19:21PM +0800, guoniu.zhou@oss.nxp.com wrote:
> From: Guoniu Zhou <guoniu.zhou@nxp.com>
>
> The CSI-2 receiver in the i.MX8ULP is almost identical to the
> version present in the i.MX8QXP/QM. But have different reset
> and clock design, so add a device-specific compatible string
> for i.MX8ULP to handle the difference.

Nit: wrap at 75 chars.

Keep the same restriction for other compatible string.

>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
> ---
>  .../bindings/media/nxp,imx8mq-mipi-csi2.yaml  | 23 +++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml b/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml
> index 3389bab266a9..83fdda2252e5 100644
> --- a/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml
> +++ b/Documentation/devicetree/bindings/media/nxp,imx8mq-mipi-csi2.yaml
> @@ -20,6 +20,7 @@ properties:
>        - enum:
>            - fsl,imx8mq-mipi-csi2
>            - fsl,imx8qxp-mipi-csi2
> +          - fsl,imx8ulp-mipi-csi2
>        - items:
>            - const: fsl,imx8qm-mipi-csi2
>            - const: fsl,imx8qxp-mipi-csi2
> @@ -39,12 +40,17 @@ properties:
>                       clock that the RX DPHY receives.
>        - description: ui is the pixel clock (phy_ref up to 333Mhz).
>                       See the reference manual for details.
> +      - description: pclk is the lpav bus clock of i.MX8ULP.
> +                     See the reference manual for details.
> +    minItems: 3
>
>    clock-names:
>      items:
>        - const: core
>        - const: esc
>        - const: ui
> +      - const: pclk
> +    minItems: 3
>
>    power-domains:
>      maxItems: 1
> @@ -137,6 +143,23 @@ allOf:
>            minItems: 2
>          resets:
>            maxItems: 1
> +
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            enum:
> +              - fsl,imx8ulp-mipi-csi2
> +    then:
> +      properties:
> +        reg:
> +          minItems: 2
> +        resets:
> +          maxItems: 2

need restrict minItems:  also, because top reset: minItems is 1.

Frank
> +        clocks:
> +          minItems: 4
> +        clock-names:
> +          minItems: 4
>      else:
>        properties:
>          reg:
> --
> 2.34.1
>

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

* Re: [PATCH 2/5] arm64: dts: imx8ulp: Add CSI and ISI Nodes
  2025-08-12  8:19 ` [PATCH 2/5] arm64: dts: imx8ulp: Add CSI and ISI Nodes guoniu.zhou
@ 2025-08-12 16:28   ` Frank Li
  0 siblings, 0 replies; 12+ messages in thread
From: Frank Li @ 2025-08-12 16:28 UTC (permalink / raw)
  To: guoniu.zhou
  Cc: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel,
	rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam

On Tue, Aug 12, 2025 at 04:19:23PM +0800, guoniu.zhou@oss.nxp.com wrote:
> From: Guoniu Zhou <guoniu.zhou@nxp.com>
>
> The CSI-2 in the i.MX8ULP is almost identical to the version present
> in the i.MX8QXP/QM and is routed to the ISI. Add both the ISI and CSI
> nodes and mark them as disabled by default since capture is dependent
> on an attached camera.
>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
> ---

suppose dts is last patch because binding and driver will be pickup by
media maintainer first, then shawn pick up dts part.

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  arch/arm64/boot/dts/freescale/imx8ulp.dtsi | 67 ++++++++++++++++++++++
>  1 file changed, 67 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi b/arch/arm64/boot/dts/freescale/imx8ulp.dtsi
> index 2562a35286c2..71abc2a3d505 100644
> --- a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi
> +++ b/arch/arm64/boot/dts/freescale/imx8ulp.dtsi
> @@ -7,6 +7,7 @@
>  #include <dt-bindings/gpio/gpio.h>
>  #include <dt-bindings/interrupt-controller/arm-gic.h>
>  #include <dt-bindings/power/imx8ulp-power.h>
> +#include <dt-bindings/reset/imx8ulp-pcc-reset.h>
>  #include <dt-bindings/thermal/thermal.h>
>
>  #include "imx8ulp-pinfunc.h"
> @@ -840,6 +841,72 @@ spdif: spdif@2dab0000 {
>  				dma-names = "rx", "tx";
>  				status = "disabled";
>  			};
> +
> +			isi: isi@2dac0000 {
> +				compatible = "fsl,imx8ulp-isi";
> +				reg = <0x2dac0000 0x10000>;
> +				interrupts = <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>;
> +				clocks = <&pcc5 IMX8ULP_CLK_ISI>,
> +					 <&cgc2 IMX8ULP_CLK_LPAV_AXI_DIV>;
> +				clock-names = "axi", "apb";
> +				power-domains = <&scmi_devpd IMX8ULP_PD_ISI>;
> +				status = "disabled";
> +
> +				ports {
> +					#address-cells = <1>;
> +					#size-cells = <0>;
> +
> +					port@0 {
> +						reg = <0>;
> +						isi_in: endpoint {
> +							remote-endpoint = <&mipi_csi_out>;
> +						};
> +					};
> +				};
> +			};
> +
> +			mipi_csi: csi@2daf0000 {
> +				compatible = "fsl,imx8ulp-mipi-csi2";
> +				reg = <0x2daf0000 0x10000>,
> +				      <0x2dad0000 0x10000>;
> +				clocks = <&pcc5 IMX8ULP_CLK_CSI>,
> +					 <&pcc5 IMX8ULP_CLK_CSI_CLK_ESC>,
> +					 <&pcc5 IMX8ULP_CLK_CSI_CLK_UI>,
> +					 <&pcc5 IMX8ULP_CLK_CSI_REGS>;
> +				clock-names = "core", "esc", "ui", "pclk";
> +				assigned-clocks = <&pcc5 IMX8ULP_CLK_CSI>,
> +						  <&pcc5 IMX8ULP_CLK_CSI_CLK_ESC>,
> +						  <&pcc5 IMX8ULP_CLK_CSI_CLK_UI>,
> +						  <&pcc5 IMX8ULP_CLK_CSI_REGS>;
> +				assigned-clock-parents = <&cgc2 IMX8ULP_CLK_PLL4_PFD1_DIV1>,
> +							 <&cgc2 IMX8ULP_CLK_PLL4_PFD1_DIV2>,
> +							 <&cgc2 IMX8ULP_CLK_PLL4_PFD0_DIV1>;
> +				assigned-clock-rates = <200000000>,
> +						       <80000000>,
> +						       <100000000>,
> +						       <79200000>;
> +				power-domains = <&scmi_devpd IMX8ULP_PD_MIPI_CSI>;
> +				resets = <&pcc5 PCC5_CSI_SWRST>,
> +					 <&pcc5 PCC5_CSI_REGS_SWRST>;
> +				status = "disabled";
> +
> +				ports {
> +					#address-cells = <1>;
> +					#size-cells = <0>;
> +
> +					port@0 {
> +						reg = <0>;
> +					};
> +
> +					port@1 {
> +						reg = <1>;
> +
> +						mipi_csi_out: endpoint {
> +							remote-endpoint = <&isi_in>;
> +						};
> +					};
> +				};
> +			};
>  		};
>
>  		gpiod: gpio@2e200000 {
> --
> 2.34.1
>

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

* Re: [PATCH 3/5] media: imx8mq-mipi-csi2: Use devm_clk_bulk_get_all() to fetch clocks
  2025-08-12  8:19 ` [PATCH 3/5] media: imx8mq-mipi-csi2: Use devm_clk_bulk_get_all() to fetch clocks guoniu.zhou
@ 2025-08-12 16:31   ` Frank Li
  0 siblings, 0 replies; 12+ messages in thread
From: Frank Li @ 2025-08-12 16:31 UTC (permalink / raw)
  To: guoniu.zhou
  Cc: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel,
	rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam

On Tue, Aug 12, 2025 at 04:19:24PM +0800, guoniu.zhou@oss.nxp.com wrote:
> From: Guoniu Zhou <guoniu.zhou@nxp.com>
>
> Use devm_clk_bulk_get_all() helper to simplify clock handle code.
>
> No functional changes intended.
>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> ---
>  drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 52 ++++++-------------
>  1 file changed, 15 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> index ed6578f7f0f9..be07ff27071f 100644
> --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> @@ -72,21 +72,6 @@ enum {
>  	ST_SUSPENDED	= 4,
>  };
>
> -enum imx8mq_mipi_csi_clk {
> -	CSI2_CLK_CORE,
> -	CSI2_CLK_ESC,
> -	CSI2_CLK_UI,
> -	CSI2_NUM_CLKS,
> -};
> -
> -static const char * const imx8mq_mipi_csi_clk_id[CSI2_NUM_CLKS] = {
> -	[CSI2_CLK_CORE] = "core",
> -	[CSI2_CLK_ESC] = "esc",
> -	[CSI2_CLK_UI] = "ui",
> -};
> -
> -#define CSI2_NUM_CLKS	ARRAY_SIZE(imx8mq_mipi_csi_clk_id)
> -
>  struct imx8mq_plat_data {
>  	int (*enable)(struct csi_state *state, u32 hs_settle);
>  	void (*disable)(struct csi_state *state);
> @@ -112,7 +97,8 @@ struct csi_state {
>  	struct device *dev;
>  	const struct imx8mq_plat_data *pdata;
>  	void __iomem *regs;
> -	struct clk_bulk_data clks[CSI2_NUM_CLKS];
> +	struct clk_bulk_data *clks;
> +	int num_clks;
>  	struct reset_control *rst;
>  	struct regulator *mipi_phy_regulator;
>
> @@ -417,24 +403,16 @@ static void imx8mq_mipi_csi_set_params(struct csi_state *state)
>  			      CSI2RX_SEND_LEVEL);
>  }
>
> -static int imx8mq_mipi_csi_clk_enable(struct csi_state *state)
> -{
> -	return clk_bulk_prepare_enable(CSI2_NUM_CLKS, state->clks);
> -}
> -
> -static void imx8mq_mipi_csi_clk_disable(struct csi_state *state)
> +static struct clk *find_esc_clk(struct csi_state *state)
>  {
> -	clk_bulk_disable_unprepare(CSI2_NUM_CLKS, state->clks);
> -}
> -
> -static int imx8mq_mipi_csi_clk_get(struct csi_state *state)
> -{
> -	unsigned int i;
> +	int i;
>
> -	for (i = 0; i < CSI2_NUM_CLKS; i++)
> -		state->clks[i].id = imx8mq_mipi_csi_clk_id[i];
> +	for (i = 0; i < state->num_clks; i++) {
> +		if (!strcmp(state->clks[i].id, "esc"))
> +			return state->clks[i].clk;
> +	}
>
> -	return devm_clk_bulk_get(state->dev, CSI2_NUM_CLKS, state->clks);
> +	return NULL;
>  }
>
>  static int imx8mq_mipi_csi_calc_hs_settle(struct csi_state *state,
> @@ -489,7 +467,7 @@ static int imx8mq_mipi_csi_calc_hs_settle(struct csi_state *state,
>  	 * documentation recommends picking a value away from the boundaries.
>  	 * Let's pick the average.
>  	 */
> -	esc_clk_rate = clk_get_rate(state->clks[CSI2_CLK_ESC].clk);
> +	esc_clk_rate = clk_get_rate(find_esc_clk(state));
>  	if (!esc_clk_rate) {
>  		dev_err(state->dev, "Could not get esc clock rate.\n");
>  		return -EINVAL;
> @@ -848,7 +826,7 @@ static void imx8mq_mipi_csi_pm_suspend(struct device *dev)
>
>  	if (state->state & ST_POWERED) {
>  		imx8mq_mipi_csi_stop_stream(state);
> -		imx8mq_mipi_csi_clk_disable(state);
> +		clk_bulk_disable_unprepare(state->num_clks, state->clks);
>  		state->state &= ~ST_POWERED;
>  	}
>
> @@ -866,7 +844,7 @@ static int imx8mq_mipi_csi_pm_resume(struct device *dev)
>
>  	if (!(state->state & ST_POWERED)) {
>  		state->state |= ST_POWERED;
> -		ret = imx8mq_mipi_csi_clk_enable(state);
> +		ret = clk_bulk_prepare_enable(state->num_clks, state->clks);
>  	}
>  	if (state->state & ST_STREAMING) {
>  		sd_state = v4l2_subdev_lock_and_get_active_state(sd);
> @@ -1092,9 +1070,9 @@ static int imx8mq_mipi_csi_probe(struct platform_device *pdev)
>  	if (IS_ERR(state->regs))
>  		return PTR_ERR(state->regs);
>
> -	ret = imx8mq_mipi_csi_clk_get(state);
> -	if (ret < 0)
> -		return ret;
> +	state->num_clks = devm_clk_bulk_get_all(dev, &state->clks);
> +	if (state->num_clks < 0)
> +		return dev_err_probe(dev, state->num_clks, "Failed to get clocks\n");
>
>  	platform_set_drvdata(pdev, &state->sd);
>
> --
> 2.34.1
>

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

* Re: [PATCH 4/5] media: imx8mq-mipi-csi2: Explicitly release reset
  2025-08-12  8:19 ` [PATCH 4/5] media: imx8mq-mipi-csi2: Explicitly release reset guoniu.zhou
@ 2025-08-12 16:38   ` Frank Li
  0 siblings, 0 replies; 12+ messages in thread
From: Frank Li @ 2025-08-12 16:38 UTC (permalink / raw)
  To: guoniu.zhou
  Cc: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel,
	rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam

On Tue, Aug 12, 2025 at 04:19:25PM +0800, guoniu.zhou@oss.nxp.com wrote:
> From: Guoniu Zhou <guoniu.zhou@nxp.com>
>
> Call reset_control_deassert() to explicitly release reset to
> make sure reset bits are cleared since platform like i.MX8ULP
> can't clear its reset bits automatically.

nit: wrap at 75 char

>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>

> ---
>  drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> index be07ff27071f..071d939d9048 100644
> --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> @@ -371,9 +371,7 @@ static int imx8mq_mipi_csi_sw_reset(struct csi_state *state)
>  	int ret;
>
>  	/*
> -	 * these are most likely self-clearing reset bits. to make it
> -	 * more clear, the reset-imx7 driver should implement the
> -	 * .reset() operation.
> +	 * Explicitly release reset to make sure reset bits are cleared.

this comments should be above reset_control_deassert()

Frank
>  	 */
>  	ret = reset_control_assert(state->rst);
>  	if (ret < 0) {
> @@ -381,7 +379,7 @@ static int imx8mq_mipi_csi_sw_reset(struct csi_state *state)
>  		return ret;
>  	}
>
> -	return 0;
> +	return reset_control_deassert(state->rst);
>  }
>
>  static void imx8mq_mipi_csi_set_params(struct csi_state *state)
> --
> 2.34.1
>

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

* Re: [PATCH 5/5] media: imx8mq-mipi-csi2: Add support for i.MX8ULP
  2025-08-12  8:19 ` [PATCH 5/5] media: imx8mq-mipi-csi2: Add support for i.MX8ULP guoniu.zhou
@ 2025-08-12 16:41   ` Frank Li
  0 siblings, 0 replies; 12+ messages in thread
From: Frank Li @ 2025-08-12 16:41 UTC (permalink / raw)
  To: guoniu.zhou
  Cc: linux-media, devicetree, imx, linux-arm-kernel, linux-kernel,
	rmfrfs, laurent.pinchart, martink, kernel, mchehab, robh, krzk+dt,
	conor+dt, shawnguo, s.hauer, kernel, festevam

On Tue, Aug 12, 2025 at 04:19:26PM +0800, guoniu.zhou@oss.nxp.com wrote:
> From: Guoniu Zhou <guoniu.zhou@nxp.com>
>
> The CSI-2 receiver in i.MX8ULP is almost same as i.MX8QXP/QM except
> clocks and resets, so add compatible string for i.MX8ULP to handle
> the difference and reuse platform data of i.MX8QXP/QM.
>
> Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
> ---
>  drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> index 071d939d9048..14cd08f9a4f6 100644
> --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> @@ -1136,6 +1136,7 @@ static void imx8mq_mipi_csi_remove(struct platform_device *pdev)
>  static const struct of_device_id imx8mq_mipi_csi_of_match[] = {
>  	{ .compatible = "fsl,imx8mq-mipi-csi2", .data = &imx8mq_data },
>  	{ .compatible = "fsl,imx8qxp-mipi-csi2", .data = &imx8qxp_data },
> +	{ .compatible = "fsl,imx8ulp-mipi-csi2", .data = &imx8qxp_data },

if platform data is the same, you can update dt binding file, allow
fsl,imx8ulp-mipi-csi2 fallback to fsl,imx8qxp-mipi-csi2.

So, needn't this patch at all.

comaptible = "fsl,imx8ulp-mipi-csi2", "fsl,imx8qxp-mipi-csi2".

Frank

>  	{ /* sentinel */ },
>  };
>  MODULE_DEVICE_TABLE(of, imx8mq_mipi_csi_of_match);
> --
> 2.34.1
>

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

end of thread, other threads:[~2025-08-12 16:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12  8:19 [PATCH 0/5] Add MIPI CSI-2 support for i.MX8ULP guoniu.zhou
2025-08-12  8:19 ` [PATCH 1/5] media: dt-bindings: nxp,imx8mq-mipi-csi2: Add i.MX8ULP compatible string guoniu.zhou
2025-08-12  8:34   ` Krzysztof Kozlowski
2025-08-12 16:25   ` Frank Li
2025-08-12  8:19 ` [PATCH 2/5] arm64: dts: imx8ulp: Add CSI and ISI Nodes guoniu.zhou
2025-08-12 16:28   ` Frank Li
2025-08-12  8:19 ` [PATCH 3/5] media: imx8mq-mipi-csi2: Use devm_clk_bulk_get_all() to fetch clocks guoniu.zhou
2025-08-12 16:31   ` Frank Li
2025-08-12  8:19 ` [PATCH 4/5] media: imx8mq-mipi-csi2: Explicitly release reset guoniu.zhou
2025-08-12 16:38   ` Frank Li
2025-08-12  8:19 ` [PATCH 5/5] media: imx8mq-mipi-csi2: Add support for i.MX8ULP guoniu.zhou
2025-08-12 16:41   ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).