linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/3] add ISI support for iMX93
@ 2023-06-29  1:36 guoniu.zhou
  2023-06-29  1:36 ` [PATCH v5 1/3] media: dt-bindings: nxp,imx8-isi: add i.MX93 ISI compatible string guoniu.zhou
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: guoniu.zhou @ 2023-06-29  1:36 UTC (permalink / raw)
  To: linux-media, linux-imx, devicetree
  Cc: laurent.pinchart, mchehab, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, xavier.roumegue, kernel, jacopo.mondi, sakari.ailus

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

NXP i.MX93 family almost reuse ISI IP from i.MX8M family, so add
it support in current ISI driver

Changes in version 5:
- Add back some header files removed in version 4
- Refine some comments placement to make code more clearly

Changes in version 4:
- Update commit message to explain why need to move gasket ops to a structure
- Remove some redundant and unused header files
- Move gasket ops structure variable to imx8-isi-gasket.c and export them by extern
- Drop some check

Changes in version 3:
- Split [PATCH v2 2/2] into two patches, one create a separate file to
  store gasket operation and the other to add ISI support for i.MX93.
- Drop some debug message in gasket operation.
- Merge .gasket_enable and .gasket_config to .gasket_enable
- Drop some dead code
- Some other small updates

Changes in version 2:
- Remove two patches which used to rename imx8 to imx.
  [PATCH 1/4] media: dt-bindings: media: rename nxp,imx8-isi.yaml to nxp,imx-isi.yaml
  [PATCH 2/4] media: nxp: rename imx8-isi to imx-isi and remove reference to i.MX8
- Modify commit log to more accurately match its goal.
- Remove redundant "media" in patch subject.

Guoniu.zhou (3):
  media: dt-bindings: nxp,imx8-isi: add i.MX93 ISI compatible string
  media: nxp: imx8-isi: move i.MX8 gasket configuration to an ops
    structure
  media: nxp: imx8-isi: add ISI support for i.MX93

 .../bindings/media/nxp,imx8-isi.yaml          |  5 +-
 drivers/media/platform/nxp/imx8-isi/Makefile  |  4 +-
 .../platform/nxp/imx8-isi/imx8-isi-core.c     | 21 ++++-
 .../platform/nxp/imx8-isi/imx8-isi-core.h     | 14 ++-
 .../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 36 ++------
 .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 85 +++++++++++++++++++
 6 files changed, 128 insertions(+), 37 deletions(-)
 create mode 100644 drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c

-- 
2.37.1


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

* [PATCH v5 1/3] media: dt-bindings: nxp,imx8-isi: add i.MX93 ISI compatible string
  2023-06-29  1:36 [PATCH v5 0/3] add ISI support for iMX93 guoniu.zhou
@ 2023-06-29  1:36 ` guoniu.zhou
  2023-06-29  1:36 ` [PATCH v5 2/3] media: nxp: imx8-isi: move i.MX8 gasket configuration to an ops structure guoniu.zhou
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: guoniu.zhou @ 2023-06-29  1:36 UTC (permalink / raw)
  To: linux-media, linux-imx, devicetree
  Cc: laurent.pinchart, mchehab, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, xavier.roumegue, kernel, jacopo.mondi, sakari.ailus

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

Add the compatible string support for i.MX93 ISI.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
---
 Documentation/devicetree/bindings/media/nxp,imx8-isi.yaml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/nxp,imx8-isi.yaml b/Documentation/devicetree/bindings/media/nxp,imx8-isi.yaml
index 6038b9b5ab36..e4665469a86c 100644
--- a/Documentation/devicetree/bindings/media/nxp,imx8-isi.yaml
+++ b/Documentation/devicetree/bindings/media/nxp,imx8-isi.yaml
@@ -21,6 +21,7 @@ properties:
     enum:
       - fsl,imx8mn-isi
       - fsl,imx8mp-isi
+      - fsl,imx93-isi
 
   reg:
     maxItems: 1
@@ -72,7 +73,9 @@ allOf:
       properties:
         compatible:
           contains:
-            const: fsl,imx8mn-isi
+            enum:
+              - fsl,imx8mn-isi
+              - fsl,imx93-isi
     then:
       properties:
         interrupts:
-- 
2.37.1


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

* [PATCH v5 2/3] media: nxp: imx8-isi: move i.MX8 gasket configuration to an ops structure
  2023-06-29  1:36 [PATCH v5 0/3] add ISI support for iMX93 guoniu.zhou
  2023-06-29  1:36 ` [PATCH v5 1/3] media: dt-bindings: nxp,imx8-isi: add i.MX93 ISI compatible string guoniu.zhou
@ 2023-06-29  1:36 ` guoniu.zhou
  2023-07-27 21:41   ` Laurent Pinchart
  2023-06-29  1:36 ` [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93 guoniu.zhou
  2023-07-27  1:22 ` [PATCH v5 0/3] add ISI support for iMX93 G.N. Zhou
  3 siblings, 1 reply; 13+ messages in thread
From: guoniu.zhou @ 2023-06-29  1:36 UTC (permalink / raw)
  To: linux-media, linux-imx, devicetree
  Cc: laurent.pinchart, mchehab, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, xavier.roumegue, kernel, jacopo.mondi, sakari.ailus

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

The i.MX93 includes an ISI instance compatible with the imx8-isi
driver, but with a different gasket. To prepare for this, make the
gasket configuration modular by moving the code to an ops structure.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
---
 drivers/media/platform/nxp/imx8-isi/Makefile  |  4 +-
 .../platform/nxp/imx8-isi/imx8-isi-core.c     |  6 +-
 .../platform/nxp/imx8-isi/imx8-isi-core.h     | 12 +++-
 .../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 36 ++----------
 .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 55 +++++++++++++++++++
 5 files changed, 77 insertions(+), 36 deletions(-)

diff --git a/drivers/media/platform/nxp/imx8-isi/Makefile b/drivers/media/platform/nxp/imx8-isi/Makefile
index 9bff9297686d..4713c4e8b64b 100644
--- a/drivers/media/platform/nxp/imx8-isi/Makefile
+++ b/drivers/media/platform/nxp/imx8-isi/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
-imx8-isi-y := imx8-isi-core.o imx8-isi-crossbar.o imx8-isi-hw.o \
-	imx8-isi-pipe.o imx8-isi-video.o
+imx8-isi-y := imx8-isi-core.o imx8-isi-crossbar.o imx8-isi-gasket.o \
+	imx8-isi-hw.o imx8-isi-pipe.o imx8-isi-video.o
 imx8-isi-$(CONFIG_DEBUG_FS) += imx8-isi-debug.o
 imx8-isi-$(CONFIG_VIDEO_IMX8_ISI_M2M) += imx8-isi-m2m.o
 
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
index 253e77189b69..5165f8960c2c 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
@@ -289,7 +289,7 @@ static const struct mxc_isi_plat_data mxc_imx8mn_data = {
 	.clks			= mxc_imx8mn_clks,
 	.num_clks		= ARRAY_SIZE(mxc_imx8mn_clks),
 	.buf_active_reverse	= false,
-	.has_gasket		= true,
+	.gasket_ops		= &mxc_imx8_gasket_ops,
 	.has_36bit_dma		= false,
 };
 
@@ -303,7 +303,7 @@ static const struct mxc_isi_plat_data mxc_imx8mp_data = {
 	.clks			= mxc_imx8mn_clks,
 	.num_clks		= ARRAY_SIZE(mxc_imx8mn_clks),
 	.buf_active_reverse	= true,
-	.has_gasket		= true,
+	.gasket_ops		= &mxc_imx8_gasket_ops,
 	.has_36bit_dma		= true,
 };
 
@@ -443,7 +443,7 @@ static int mxc_isi_probe(struct platform_device *pdev)
 		return PTR_ERR(isi->regs);
 	}
 
-	if (isi->pdata->has_gasket) {
+	if (isi->pdata->gasket_ops) {
 		isi->gasket = syscon_regmap_lookup_by_phandle(dev->of_node,
 							      "fsl,blk-ctrl");
 		if (IS_ERR(isi->gasket)) {
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
index e469788a9e6c..78ca047d93d1 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
@@ -147,6 +147,14 @@ struct mxc_isi_set_thd {
 	struct mxc_isi_panic_thd panic_set_thd_v;
 };
 
+struct mxc_gasket_ops {
+	void (*enable)(struct mxc_isi_dev *isi,
+		       const struct v4l2_mbus_frame_desc *fd,
+		       const struct v4l2_mbus_framefmt *fmt,
+		       const unsigned int port);
+	void (*disable)(struct mxc_isi_dev *isi, const unsigned int port);
+};
+
 enum model {
 	MXC_ISI_IMX8MN,
 	MXC_ISI_IMX8MP,
@@ -159,10 +167,10 @@ struct mxc_isi_plat_data {
 	unsigned int reg_offset;
 	const struct mxc_isi_ier_reg  *ier_reg;
 	const struct mxc_isi_set_thd *set_thd;
+	const struct mxc_gasket_ops *gasket_ops;
 	const struct clk_bulk_data *clks;
 	unsigned int num_clks;
 	bool buf_active_reverse;
-	bool has_gasket;
 	bool has_36bit_dma;
 };
 
@@ -286,6 +294,8 @@ struct mxc_isi_dev {
 	struct dentry			*debugfs_root;
 };
 
+extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
+
 int mxc_isi_crossbar_init(struct mxc_isi_dev *isi);
 void mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar);
 int mxc_isi_crossbar_register(struct mxc_isi_crossbar *xbar);
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
index f7447b2f4d77..c6a658ef0c62 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
@@ -15,7 +15,6 @@
 #include <linux/types.h>
 
 #include <media/media-entity.h>
-#include <media/mipi-csi2.h>
 #include <media/v4l2-subdev.h>
 
 #include "imx8-isi-core.h"
@@ -25,32 +24,18 @@ static inline struct mxc_isi_crossbar *to_isi_crossbar(struct v4l2_subdev *sd)
 	return container_of(sd, struct mxc_isi_crossbar, sd);
 }
 
-/* -----------------------------------------------------------------------------
- * Media block control (i.MX8MN and i.MX8MP only)
- */
-#define GASKET_BASE(n)				(0x0060 + (n) * 0x30)
-
-#define GASKET_CTRL				0x0000
-#define GASKET_CTRL_DATA_TYPE(dt)		((dt) << 8)
-#define GASKET_CTRL_DATA_TYPE_MASK		(0x3f << 8)
-#define GASKET_CTRL_DUAL_COMP_ENABLE		BIT(1)
-#define GASKET_CTRL_ENABLE			BIT(0)
-
-#define GASKET_HSIZE				0x0004
-#define GASKET_VSIZE				0x0008
-
 static int mxc_isi_crossbar_gasket_enable(struct mxc_isi_crossbar *xbar,
 					  struct v4l2_subdev_state *state,
 					  struct v4l2_subdev *remote_sd,
 					  u32 remote_pad, unsigned int port)
 {
 	struct mxc_isi_dev *isi = xbar->isi;
+	const struct mxc_gasket_ops *gasket_ops = isi->pdata->gasket_ops;
 	const struct v4l2_mbus_framefmt *fmt;
 	struct v4l2_mbus_frame_desc fd;
-	u32 val;
 	int ret;
 
-	if (!isi->pdata->has_gasket)
+	if (!gasket_ops)
 		return 0;
 
 	/*
@@ -77,17 +62,7 @@ static int mxc_isi_crossbar_gasket_enable(struct mxc_isi_crossbar *xbar,
 	if (!fmt)
 		return -EINVAL;
 
-	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_HSIZE, fmt->width);
-	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_VSIZE, fmt->height);
-
-	val = GASKET_CTRL_DATA_TYPE(fd.entry[0].bus.csi2.dt)
-	    | GASKET_CTRL_ENABLE;
-
-	if (fd.entry[0].bus.csi2.dt == MIPI_CSI2_DT_YUV422_8B)
-		val |= GASKET_CTRL_DUAL_COMP_ENABLE;
-
-	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, val);
-
+	gasket_ops->enable(isi, &fd, fmt, port);
 	return 0;
 }
 
@@ -95,11 +70,12 @@ static void mxc_isi_crossbar_gasket_disable(struct mxc_isi_crossbar *xbar,
 					    unsigned int port)
 {
 	struct mxc_isi_dev *isi = xbar->isi;
+	const struct mxc_gasket_ops *gasket_ops = isi->pdata->gasket_ops;
 
-	if (!isi->pdata->has_gasket)
+	if (!gasket_ops)
 		return;
 
-	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, 0);
+	gasket_ops->disable(isi, port);
 }
 
 /* -----------------------------------------------------------------------------
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
new file mode 100644
index 000000000000..1d632dc60699
--- /dev/null
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2019-2023 NXP
+ */
+
+#include <linux/regmap.h>
+
+#include <media/mipi-csi2.h>
+
+#include "imx8-isi-core.h"
+
+/* -----------------------------------------------------------------------------
+ * i.MX8MN and i.MX8MP gasket
+ **/
+
+#define GASKET_BASE(n)				(0x0060 + (n) * 0x30)
+
+#define GASKET_CTRL				0x0000
+#define GASKET_CTRL_DATA_TYPE(dt)		((dt) << 8)
+#define GASKET_CTRL_DATA_TYPE_MASK		(0x3f << 8)
+#define GASKET_CTRL_DUAL_COMP_ENABLE		BIT(1)
+#define GASKET_CTRL_ENABLE			BIT(0)
+
+#define GASKET_HSIZE				0x0004
+#define GASKET_VSIZE				0x0008
+
+static void mxc_imx8_gasket_enable(struct mxc_isi_dev *isi,
+				   const struct v4l2_mbus_frame_desc *fd,
+				   const struct v4l2_mbus_framefmt *fmt,
+				   const unsigned int port)
+{
+	u32 val;
+
+	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_HSIZE, fmt->width);
+	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_VSIZE, fmt->height);
+
+	val = GASKET_CTRL_DATA_TYPE(fd->entry[0].bus.csi2.dt);
+	if (fd->entry[0].bus.csi2.dt == MIPI_CSI2_DT_YUV422_8B)
+		val |= GASKET_CTRL_DUAL_COMP_ENABLE;
+
+	val |= GASKET_CTRL_ENABLE;
+	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, val);
+}
+
+static void mxc_imx8_gasket_disable(struct mxc_isi_dev *isi,
+				    const unsigned int port)
+{
+	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, 0);
+}
+
+/* Gasket operations for i.MX8MN and i.MX8MP */
+const struct mxc_gasket_ops mxc_imx8_gasket_ops = {
+	.enable = mxc_imx8_gasket_enable,
+	.disable = mxc_imx8_gasket_disable,
+};
-- 
2.37.1


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

* [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93
  2023-06-29  1:36 [PATCH v5 0/3] add ISI support for iMX93 guoniu.zhou
  2023-06-29  1:36 ` [PATCH v5 1/3] media: dt-bindings: nxp,imx8-isi: add i.MX93 ISI compatible string guoniu.zhou
  2023-06-29  1:36 ` [PATCH v5 2/3] media: nxp: imx8-isi: move i.MX8 gasket configuration to an ops structure guoniu.zhou
@ 2023-06-29  1:36 ` guoniu.zhou
  2023-06-29  6:43   ` Alexander Stein
  2023-07-27 21:48   ` Laurent Pinchart
  2023-07-27  1:22 ` [PATCH v5 0/3] add ISI support for iMX93 G.N. Zhou
  3 siblings, 2 replies; 13+ messages in thread
From: guoniu.zhou @ 2023-06-29  1:36 UTC (permalink / raw)
  To: linux-media, linux-imx, devicetree
  Cc: laurent.pinchart, mchehab, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, xavier.roumegue, kernel, jacopo.mondi, sakari.ailus

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

i.MX93 use a different gasket which has different register definition
compared with i.MX8. Hence implement the gasket callbacks in order to
add ISI support for i.MX93.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../platform/nxp/imx8-isi/imx8-isi-core.c     | 15 ++++++++++
 .../platform/nxp/imx8-isi/imx8-isi-core.h     |  2 ++
 .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 30 +++++++++++++++++++
 3 files changed, 47 insertions(+)

diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
index 5165f8960c2c..27bd18b7ee65 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
@@ -307,6 +307,20 @@ static const struct mxc_isi_plat_data mxc_imx8mp_data = {
 	.has_36bit_dma		= true,
 };
 
+static const struct mxc_isi_plat_data mxc_imx93_data = {
+	.model			= MXC_ISI_IMX93,
+	.num_ports		= 1,
+	.num_channels		= 1,
+	.reg_offset		= 0,
+	.ier_reg		= &mxc_imx8_isi_ier_v2,
+	.set_thd		= &mxc_imx8_isi_thd_v1,
+	.clks			= mxc_imx8mn_clks,
+	.num_clks		= ARRAY_SIZE(mxc_imx8mn_clks),
+	.buf_active_reverse	= true,
+	.gasket_ops		= &mxc_imx93_gasket_ops,
+	.has_36bit_dma		= false,
+};
+
 /* -----------------------------------------------------------------------------
  * Power management
  */
@@ -518,6 +532,7 @@ static int mxc_isi_remove(struct platform_device *pdev)
 static const struct of_device_id mxc_isi_of_match[] = {
 	{ .compatible = "fsl,imx8mn-isi", .data = &mxc_imx8mn_data },
 	{ .compatible = "fsl,imx8mp-isi", .data = &mxc_imx8mp_data },
+	{ .compatible = "fsl,imx93-isi", .data = &mxc_imx93_data },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, mxc_isi_of_match);
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
index 78ca047d93d1..2810ebe9b5f7 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
@@ -158,6 +158,7 @@ struct mxc_gasket_ops {
 enum model {
 	MXC_ISI_IMX8MN,
 	MXC_ISI_IMX8MP,
+	MXC_ISI_IMX93,
 };
 
 struct mxc_isi_plat_data {
@@ -295,6 +296,7 @@ struct mxc_isi_dev {
 };
 
 extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
+extern const struct mxc_gasket_ops mxc_imx93_gasket_ops;
 
 int mxc_isi_crossbar_init(struct mxc_isi_dev *isi);
 void mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar);
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
index 1d632dc60699..50ac1d3a2b6f 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
@@ -53,3 +53,33 @@ const struct mxc_gasket_ops mxc_imx8_gasket_ops = {
 	.enable = mxc_imx8_gasket_enable,
 	.disable = mxc_imx8_gasket_disable,
 };
+
+/* -----------------------------------------------------------------------------
+ * i.MX93 gasket
+ **/
+
+#define DISP_MIX_CAMERA_MUX                     0x30
+#define DISP_MIX_CAMERA_MUX_DATA_TYPE(x)        (((x) & 0x3f) << 3)
+#define DISP_MIX_CAMERA_MUX_GASKET_ENABLE       BIT(16)
+static void mxc_imx93_gasket_enable(struct mxc_isi_dev *isi,
+				    const struct v4l2_mbus_frame_desc *fd,
+				    const struct v4l2_mbus_framefmt *fmt,
+				    const unsigned int port)
+{
+	u32 val;
+
+	val = DISP_MIX_CAMERA_MUX_DATA_TYPE(fd->entry[0].bus.csi2.dt);
+	val |= DISP_MIX_CAMERA_MUX_GASKET_ENABLE;
+	regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, val);
+}
+
+static void mxc_imx93_gasket_disable(struct mxc_isi_dev *isi,
+				     unsigned int port)
+{
+	regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, 0);
+}
+
+const struct mxc_gasket_ops mxc_imx93_gasket_ops = {
+	.enable = mxc_imx93_gasket_enable,
+	.disable = mxc_imx93_gasket_disable,
+};
-- 
2.37.1


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

* Re: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93
  2023-06-29  1:36 ` [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93 guoniu.zhou
@ 2023-06-29  6:43   ` Alexander Stein
  2023-06-29  7:07     ` G.N. Zhou (OSS)
  2023-07-27 21:48   ` Laurent Pinchart
  1 sibling, 1 reply; 13+ messages in thread
From: Alexander Stein @ 2023-06-29  6:43 UTC (permalink / raw)
  To: linux-media, linux-imx, devicetree, guoniu.zhou
  Cc: laurent.pinchart, mchehab, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, xavier.roumegue, kernel, jacopo.mondi, sakari.ailus

Hi Guoniu,

thanks for the patch series.

Am Donnerstag, 29. Juni 2023, 03:36:21 CEST schrieb guoniu.zhou@oss.nxp.com:
> ********************
> Achtung externe E-Mail: Öffnen Sie Anhänge und Links nur, wenn Sie wissen,
> dass diese aus einer sicheren Quelle stammen und sicher sind. Leiten Sie
> die E-Mail im Zweifelsfall zur Prüfung an den IT-Helpdesk weiter.
> Attention external email: Open attachments and links only if you know that
> they are from a secure source and are safe. In doubt forward the email to
> the IT-Helpdesk to check it. ********************
> 
> From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> 
> i.MX93 use a different gasket which has different register definition
> compared with i.MX8. Hence implement the gasket callbacks in order to
> add ISI support for i.MX93.
> 
> Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  .../platform/nxp/imx8-isi/imx8-isi-core.c     | 15 ++++++++++
>  .../platform/nxp/imx8-isi/imx8-isi-core.h     |  2 ++
>  .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 30 +++++++++++++++++++
>  3 files changed, 47 insertions(+)
> 
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c index
> 5165f8960c2c..27bd18b7ee65 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> @@ -307,6 +307,20 @@ static const struct mxc_isi_plat_data mxc_imx8mp_data =
> { .has_36bit_dma		= true,
>  };
> 
> +static const struct mxc_isi_plat_data mxc_imx93_data = {
> +	.model			= MXC_ISI_IMX93,
> +	.num_ports		= 1,
> +	.num_channels		= 1,
> +	.reg_offset		= 0,
> +	.ier_reg		= &mxc_imx8_isi_ier_v2,
> +	.set_thd		= &mxc_imx8_isi_thd_v1,
> +	.clks			= mxc_imx8mn_clks,
> +	.num_clks		= ARRAY_SIZE(mxc_imx8mn_clks),
> +	.buf_active_reverse	= true,
> +	.gasket_ops		= &mxc_imx93_gasket_ops,
> +	.has_36bit_dma		= false,
> +};
> +
>  /*
> ---------------------------------------------------------------------------
> -- * Power management
>   */
> @@ -518,6 +532,7 @@ static int mxc_isi_remove(struct platform_device *pdev)
>  static const struct of_device_id mxc_isi_of_match[] = {
>  	{ .compatible = "fsl,imx8mn-isi", .data = &mxc_imx8mn_data },
>  	{ .compatible = "fsl,imx8mp-isi", .data = &mxc_imx8mp_data },
> +	{ .compatible = "fsl,imx93-isi", .data = &mxc_imx93_data },
>  	{ /* sentinel */ },
>  };
>  MODULE_DEVICE_TABLE(of, mxc_isi_of_match);
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h index
> 78ca047d93d1..2810ebe9b5f7 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> @@ -158,6 +158,7 @@ struct mxc_gasket_ops {
>  enum model {
>  	MXC_ISI_IMX8MN,
>  	MXC_ISI_IMX8MP,
> +	MXC_ISI_IMX93,
>  };
> 
>  struct mxc_isi_plat_data {
> @@ -295,6 +296,7 @@ struct mxc_isi_dev {
>  };
> 
>  extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
> +extern const struct mxc_gasket_ops mxc_imx93_gasket_ops;
> 
>  int mxc_isi_crossbar_init(struct mxc_isi_dev *isi);
>  void mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar);
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c index
> 1d632dc60699..50ac1d3a2b6f 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> @@ -53,3 +53,33 @@ const struct mxc_gasket_ops mxc_imx8_gasket_ops = {
>  	.enable = mxc_imx8_gasket_enable,
>  	.disable = mxc_imx8_gasket_disable,
>  };
> +
> +/*
> ---------------------------------------------------------------------------
> -- + * i.MX93 gasket
> + **/
> +
> +#define DISP_MIX_CAMERA_MUX                     0x30

Which peripheral does this refer to? I would assume it is the Media Mix Domain 
Block Control, but there is no register at 0x30 mentioned in the reference 
manual. You have some additional information?

Also which type of input did you use? MIPI-CSI2 or parallel interface?

Thanks and best regards,
Alexander

> +#define DISP_MIX_CAMERA_MUX_DATA_TYPE(x)        (((x) & 0x3f) << 3)
> +#define DISP_MIX_CAMERA_MUX_GASKET_ENABLE       BIT(16)
> +static void mxc_imx93_gasket_enable(struct mxc_isi_dev *isi,
> +				    const struct v4l2_mbus_frame_desc 
*fd,
> +				    const struct v4l2_mbus_framefmt 
*fmt,
> +				    const unsigned int port)
> +{
> +	u32 val;
> +
> +	val = DISP_MIX_CAMERA_MUX_DATA_TYPE(fd->entry[0].bus.csi2.dt);
> +	val |= DISP_MIX_CAMERA_MUX_GASKET_ENABLE;
> +	regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, val);
> +}
> +
> +static void mxc_imx93_gasket_disable(struct mxc_isi_dev *isi,
> +				     unsigned int port)
> +{
> +	regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, 0);
> +}
> +
> +const struct mxc_gasket_ops mxc_imx93_gasket_ops = {
> +	.enable = mxc_imx93_gasket_enable,
> +	.disable = mxc_imx93_gasket_disable,
> +};


-- 
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/



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

* RE: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93
  2023-06-29  6:43   ` Alexander Stein
@ 2023-06-29  7:07     ` G.N. Zhou (OSS)
  2023-06-29  7:59       ` Alexander Stein
  0 siblings, 1 reply; 13+ messages in thread
From: G.N. Zhou (OSS) @ 2023-06-29  7:07 UTC (permalink / raw)
  To: Alexander Stein, linux-media, dl-linux-imx, devicetree, G.N. Zhou (OSS)
  Cc: laurent.pinchart, mchehab, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, Xavier Roumegue (OSS),
	kernel, jacopo.mondi, sakari.ailus

Hi Alexander,

> -----Original Message-----
> From: Alexander Stein <alexander.stein@ew.tq-group.com>
> Sent: 2023年6月29日 14:43
> To: linux-media@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> devicetree@vger.kernel.org; G.N. Zhou (OSS) <guoniu.zhou@oss.nxp.com>
> Cc: laurent.pinchart@ideasonboard.com; mchehab@kernel.org;
> robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; conor+dt@kernel.org;
> Xavier Roumegue (OSS) <xavier.roumegue@oss.nxp.com>;
> kernel@pengutronix.de; jacopo.mondi@ideasonboard.com;
> sakari.ailus@linux.intel.com
> Subject: Re: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93
> 
> Caution: This is an external email. Please take care when clicking links or opening
> attachments. When in doubt, report the message using the 'Report this email'
> button
> 
> 
> Hi Guoniu,
> 
> thanks for the patch series.
> 
> Am Donnerstag, 29. Juni 2023, 03:36:21 CEST schrieb
> guoniu.zhou@oss.nxp.com:
> > ********************
> > Achtung externe E-Mail: Öffnen Sie Anhänge und Links nur, wenn Sie
> > wissen, dass diese aus einer sicheren Quelle stammen und sicher sind.
> > Leiten Sie die E-Mail im Zweifelsfall zur Prüfung an den IT-Helpdesk weiter.
> > Attention external email: Open attachments and links only if you know
> > that they are from a secure source and are safe. In doubt forward the
> > email to the IT-Helpdesk to check it. ********************
> >
> > From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> >
> > i.MX93 use a different gasket which has different register definition
> > compared with i.MX8. Hence implement the gasket callbacks in order to
> > add ISI support for i.MX93.
> >
> > Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  .../platform/nxp/imx8-isi/imx8-isi-core.c     | 15 ++++++++++
> >  .../platform/nxp/imx8-isi/imx8-isi-core.h     |  2 ++
> >  .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 30 +++++++++++++++++++
> >  3 files changed, 47 insertions(+)
> >
> > diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c index
> > 5165f8960c2c..27bd18b7ee65 100644
> > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > @@ -307,6 +307,20 @@ static const struct mxc_isi_plat_data
> mxc_imx8mp_data =
> > { .has_36bit_dma              = true,
> >  };
> >
> > +static const struct mxc_isi_plat_data mxc_imx93_data = {
> > +     .model                  = MXC_ISI_IMX93,
> > +     .num_ports              = 1,
> > +     .num_channels           = 1,
> > +     .reg_offset             = 0,
> > +     .ier_reg                = &mxc_imx8_isi_ier_v2,
> > +     .set_thd                = &mxc_imx8_isi_thd_v1,
> > +     .clks                   = mxc_imx8mn_clks,
> > +     .num_clks               = ARRAY_SIZE(mxc_imx8mn_clks),
> > +     .buf_active_reverse     = true,
> > +     .gasket_ops             = &mxc_imx93_gasket_ops,
> > +     .has_36bit_dma          = false,
> > +};
> > +
> >  /*
> > ----------------------------------------------------------------------
> > -----
> > -- * Power management
> >   */
> > @@ -518,6 +532,7 @@ static int mxc_isi_remove(struct platform_device
> > *pdev)  static const struct of_device_id mxc_isi_of_match[] = {
> >       { .compatible = "fsl,imx8mn-isi", .data = &mxc_imx8mn_data },
> >       { .compatible = "fsl,imx8mp-isi", .data = &mxc_imx8mp_data },
> > +     { .compatible = "fsl,imx93-isi", .data = &mxc_imx93_data },
> >       { /* sentinel */ },
> >  };
> >  MODULE_DEVICE_TABLE(of, mxc_isi_of_match); diff --git
> > a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h index
> > 78ca047d93d1..2810ebe9b5f7 100644
> > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > @@ -158,6 +158,7 @@ struct mxc_gasket_ops {  enum model {
> >       MXC_ISI_IMX8MN,
> >       MXC_ISI_IMX8MP,
> > +     MXC_ISI_IMX93,
> >  };
> >
> >  struct mxc_isi_plat_data {
> > @@ -295,6 +296,7 @@ struct mxc_isi_dev {  };
> >
> >  extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
> > +extern const struct mxc_gasket_ops mxc_imx93_gasket_ops;
> >
> >  int mxc_isi_crossbar_init(struct mxc_isi_dev *isi);  void
> > mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar); diff --git
> > a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c index
> > 1d632dc60699..50ac1d3a2b6f 100644
> > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > @@ -53,3 +53,33 @@ const struct mxc_gasket_ops mxc_imx8_gasket_ops = {
> >       .enable = mxc_imx8_gasket_enable,
> >       .disable = mxc_imx8_gasket_disable,  };
> > +
> > +/*
> > ----------------------------------------------------------------------
> > -----
> > -- + * i.MX93 gasket
> > + **/
> > +
> > +#define DISP_MIX_CAMERA_MUX                     0x30
> 
> Which peripheral does this refer to? I would assume it is the Media Mix Domain
> Block Control, but there is no register at 0x30 mentioned in the reference manual.
> You have some additional information?
> 
> Also which type of input did you use? MIPI-CSI2 or parallel interface?

Yes, it's Media Mix Domain Block Control(I name it Disp_Mix due to history reason).

I check RM in NXP Website and don't found 0x30 as you said since it's REV2, not latest one which
still under review.

The input is MIPI CSI-2 by default.(We use default value in the serials)

> 
> Thanks and best regards,
> Alexander
> 
> > +#define DISP_MIX_CAMERA_MUX_DATA_TYPE(x)        (((x) & 0x3f) << 3)
> > +#define DISP_MIX_CAMERA_MUX_GASKET_ENABLE       BIT(16)
> > +static void mxc_imx93_gasket_enable(struct mxc_isi_dev *isi,
> > +                                 const struct v4l2_mbus_frame_desc
> *fd,
> > +                                 const struct v4l2_mbus_framefmt
> *fmt,
> > +                                 const unsigned int port) {
> > +     u32 val;
> > +
> > +     val = DISP_MIX_CAMERA_MUX_DATA_TYPE(fd->entry[0].bus.csi2.dt);
> > +     val |= DISP_MIX_CAMERA_MUX_GASKET_ENABLE;
> > +     regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, val); }
> > +
> > +static void mxc_imx93_gasket_disable(struct mxc_isi_dev *isi,
> > +                                  unsigned int port) {
> > +     regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, 0); }
> > +
> > +const struct mxc_gasket_ops mxc_imx93_gasket_ops = {
> > +     .enable = mxc_imx93_gasket_enable,
> > +     .disable = mxc_imx93_gasket_disable, };
> 
> 
> --
> 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/
> 


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

* Re: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93
  2023-06-29  7:07     ` G.N. Zhou (OSS)
@ 2023-06-29  7:59       ` Alexander Stein
  2023-06-29  8:23         ` G.N. Zhou (OSS)
  0 siblings, 1 reply; 13+ messages in thread
From: Alexander Stein @ 2023-06-29  7:59 UTC (permalink / raw)
  To: linux-media, dl-linux-imx, devicetree, G.N. Zhou (OSS), G.N. Zhou (OSS)
  Cc: laurent.pinchart, mchehab, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, Xavier Roumegue (OSS),
	kernel, jacopo.mondi, sakari.ailus

Hi Guoniu,

Am Donnerstag, 29. Juni 2023, 09:07:23 CEST schrieb G.N. Zhou (OSS):
> Hi Alexander,
> 
> 
> > -----Original Message-----
> > From: Alexander Stein <alexander.stein@ew.tq-group.com>
> > Sent: 2023年6月29日 14:43
> > To: linux-media@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> > devicetree@vger.kernel.org; G.N. Zhou (OSS) <guoniu.zhou@oss.nxp.com>
> > Cc: laurent.pinchart@ideasonboard.com; mchehab@kernel.org;
> > robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org;
> > conor+dt@kernel.org;
 Xavier Roumegue (OSS)
> > <xavier.roumegue@oss.nxp.com>;
> > kernel@pengutronix.de; jacopo.mondi@ideasonboard.com;
> > sakari.ailus@linux.intel.com
> > Subject: Re: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for
> > i.MX93
 
> > Caution: This is an external email. Please take care when clicking links
> > or opening
 attachments. When in doubt, report the message using the
> > 'Report this email' button
> > 
> > 
> > Hi Guoniu,
> > 
> > thanks for the patch series.
> > 
> > Am Donnerstag, 29. Juni 2023, 03:36:21 CEST schrieb
> > guoniu.zhou@oss.nxp.com:
> > 
> > > ********************
> > > Achtung externe E-Mail: Öffnen Sie Anhänge und Links nur, wenn Sie
> > > wissen, dass diese aus einer sicheren Quelle stammen und sicher sind.
> > > Leiten Sie die E-Mail im Zweifelsfall zur Prüfung an den IT-Helpdesk
> > > weiter.
 Attention external email: Open attachments and links only if
> > > you know that they are from a secure source and are safe. In doubt
> > > forward the email to the IT-Helpdesk to check it. ********************
> > >
> > >
> > >
> > > From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> > >
> > >
> > >
> > > i.MX93 use a different gasket which has different register definition
> > > compared with i.MX8. Hence implement the gasket callbacks in order to
> > > add ISI support for i.MX93.
> > >
> > >
> > >
> > > Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > ---
> > > 
> > >  .../platform/nxp/imx8-isi/imx8-isi-core.c     | 15 ++++++++++
> > >  .../platform/nxp/imx8-isi/imx8-isi-core.h     |  2 ++
> > >  .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 30 +++++++++++++++++++
> > >  3 files changed, 47 insertions(+)
> > >
> > >
> > >
> > > diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c index
> > > 5165f8960c2c..27bd18b7ee65 100644
> > > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > > @@ -307,6 +307,20 @@ static const struct mxc_isi_plat_data
> > 
> > mxc_imx8mp_data =
> > 
> > > { .has_36bit_dma              = true,
> > > 
> > >  };
> > >
> > >
> > >
> > > +static const struct mxc_isi_plat_data mxc_imx93_data = {
> > > +     .model                  = MXC_ISI_IMX93,
> > > +     .num_ports              = 1,
> > > +     .num_channels           = 1,
> > > +     .reg_offset             = 0,
> > > +     .ier_reg                = &mxc_imx8_isi_ier_v2,
> > > +     .set_thd                = &mxc_imx8_isi_thd_v1,
> > > +     .clks                   = mxc_imx8mn_clks,
> > > +     .num_clks               = ARRAY_SIZE(mxc_imx8mn_clks),
> > > +     .buf_active_reverse     = true,
> > > +     .gasket_ops             = &mxc_imx93_gasket_ops,
> > > +     .has_36bit_dma          = false,
> > > +};
> > > +
> > > 
> > >  /*
> > > 
> > > ----------------------------------------------------------------------
> > > -----
> > > -- * Power management
> > > 
> > >   */
> > > 
> > > @@ -518,6 +532,7 @@ static int mxc_isi_remove(struct platform_device
> > > *pdev)  static const struct of_device_id mxc_isi_of_match[] = {
> > > 
> > >       { .compatible = "fsl,imx8mn-isi", .data = &mxc_imx8mn_data },
> > >       { .compatible = "fsl,imx8mp-isi", .data = &mxc_imx8mp_data },
> > > 
> > > +     { .compatible = "fsl,imx93-isi", .data = &mxc_imx93_data },
> > > 
> > >       { /* sentinel */ },
> > >  
> > >  };
> > >  MODULE_DEVICE_TABLE(of, mxc_isi_of_match); diff --git
> > > 
> > > a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h index
> > > 78ca047d93d1..2810ebe9b5f7 100644
> > > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > > @@ -158,6 +158,7 @@ struct mxc_gasket_ops {  enum model {
> > > 
> > >       MXC_ISI_IMX8MN,
> > >       MXC_ISI_IMX8MP,
> > > 
> > > +     MXC_ISI_IMX93,
> > > 
> > >  };
> > >
> > >
> > >
> > >  struct mxc_isi_plat_data {
> > > 
> > > @@ -295,6 +296,7 @@ struct mxc_isi_dev {  };
> > >
> > >
> > >
> > >  extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
> > > 
> > > +extern const struct mxc_gasket_ops mxc_imx93_gasket_ops;
> > >
> > >
> > >
> > >  int mxc_isi_crossbar_init(struct mxc_isi_dev *isi);  void
> > > 
> > > mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar); diff --git
> > > a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c index
> > > 1d632dc60699..50ac1d3a2b6f 100644
> > > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > > @@ -53,3 +53,33 @@ const struct mxc_gasket_ops mxc_imx8_gasket_ops = {
> > > 
> > >       .enable = mxc_imx8_gasket_enable,
> > >       .disable = mxc_imx8_gasket_disable,  };
> > > 
> > > +
> > > +/*
> > > ----------------------------------------------------------------------
> > > -----
> > > -- + * i.MX93 gasket
> > > + **/
> > > +
> > > +#define DISP_MIX_CAMERA_MUX                     0x30
> > 
> > 
> > Which peripheral does this refer to? I would assume it is the Media Mix
> > Domain Block Control, but there is no register at 0x30 mentioned in the
> > reference manual. You have some additional information?
> > 
> > Also which type of input did you use? MIPI-CSI2 or parallel interface?
> 
> 
> Yes, it's Media Mix Domain Block Control(I name it Disp_Mix due to history
> reason).
>
> I check RM in NXP Website and don't found 0x30 as you said since it's REV2,
> not latest one which still under review.

Thanks for confirmation.

> The input is MIPI CSI-2 by default.(We use default value in the serials)

Thanks. Is there already a (preliminary) driver for the MIPI CSI-2 peripheral?

Thanks and best regards,
Alexander

> > 
> > Thanks and best regards,
> > Alexander
> > 
> > 
> > > +#define DISP_MIX_CAMERA_MUX_DATA_TYPE(x)        (((x) & 0x3f) << 3)
> > > +#define DISP_MIX_CAMERA_MUX_GASKET_ENABLE       BIT(16)
> > > +static void mxc_imx93_gasket_enable(struct mxc_isi_dev *isi,
> > > +                                 const struct v4l2_mbus_frame_desc
> > 
> > *fd,
> > 
> > > +                                 const struct v4l2_mbus_framefmt
> > 
> > *fmt,
> > 
> > > +                                 const unsigned int port) {
> > > +     u32 val;
> > > +
> > > +     val = DISP_MIX_CAMERA_MUX_DATA_TYPE(fd->entry[0].bus.csi2.dt);
> > > +     val |= DISP_MIX_CAMERA_MUX_GASKET_ENABLE;
> > > +     regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, val); }
> > > +
> > > +static void mxc_imx93_gasket_disable(struct mxc_isi_dev *isi,
> > > +                                  unsigned int port) {
> > > +     regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, 0); }
> > > +
> > > +const struct mxc_gasket_ops mxc_imx93_gasket_ops = {
> > > +     .enable = mxc_imx93_gasket_enable,
> > > +     .disable = mxc_imx93_gasket_disable, };
> > 
> > 
> > 
> > --
> > 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/
> > 
> 
> 


-- 
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/



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

* RE: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93
  2023-06-29  7:59       ` Alexander Stein
@ 2023-06-29  8:23         ` G.N. Zhou (OSS)
  0 siblings, 0 replies; 13+ messages in thread
From: G.N. Zhou (OSS) @ 2023-06-29  8:23 UTC (permalink / raw)
  To: Alexander Stein, linux-media, dl-linux-imx, devicetree,
	G.N. Zhou (OSS), G.N. Zhou (OSS)
  Cc: laurent.pinchart, mchehab, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, Xavier Roumegue (OSS),
	kernel, jacopo.mondi, sakari.ailus

Hi Alexander,

> -----Original Message-----
> From: Alexander Stein <alexander.stein@ew.tq-group.com>
> Sent: 2023年6月29日 16:00
> To: linux-media@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> devicetree@vger.kernel.org; G.N. Zhou (OSS) <guoniu.zhou@oss.nxp.com>;
> G.N. Zhou (OSS) <guoniu.zhou@oss.nxp.com>
> Cc: laurent.pinchart@ideasonboard.com; mchehab@kernel.org;
> robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; conor+dt@kernel.org;
> Xavier Roumegue (OSS) <xavier.roumegue@oss.nxp.com>;
> kernel@pengutronix.de; jacopo.mondi@ideasonboard.com;
> sakari.ailus@linux.intel.com
> Subject: Re: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93
> 
> Caution: This is an external email. Please take care when clicking links or opening
> attachments. When in doubt, report the message using the 'Report this email'
> button
> 
> 
> Hi Guoniu,
> 
> Am Donnerstag, 29. Juni 2023, 09:07:23 CEST schrieb G.N. Zhou (OSS):
> > Hi Alexander,
> >
> >
> > > -----Original Message-----
> > > From: Alexander Stein <alexander.stein@ew.tq-group.com>
> > > Sent: 2023年6月29日 14:43
> > > To: linux-media@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> > > devicetree@vger.kernel.org; G.N. Zhou (OSS)
> > > <guoniu.zhou@oss.nxp.com>
> > > Cc: laurent.pinchart@ideasonboard.com; mchehab@kernel.org;
> > > robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org;
> > > conor+dt@kernel.org;
>  Xavier Roumegue (OSS)
> > > <xavier.roumegue@oss.nxp.com>;
> > > kernel@pengutronix.de; jacopo.mondi@ideasonboard.com;
> > > sakari.ailus@linux.intel.com
> > > Subject: Re: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support
> > > for
> > > i.MX93
> 
> > > Caution: This is an external email. Please take care when clicking
> > > links or opening
>  attachments. When in doubt, report the message using the
> > > 'Report this email' button
> > >
> > >
> > > Hi Guoniu,
> > >
> > > thanks for the patch series.
> > >
> > > Am Donnerstag, 29. Juni 2023, 03:36:21 CEST schrieb
> > > guoniu.zhou@oss.nxp.com:
> > >
> > > > ********************
> > > > Achtung externe E-Mail: Öffnen Sie Anhänge und Links nur, wenn Sie
> > > > wissen, dass diese aus einer sicheren Quelle stammen und sicher sind.
> > > > Leiten Sie die E-Mail im Zweifelsfall zur Prüfung an den
> > > > IT-Helpdesk weiter.
>  Attention external email: Open attachments and links only if
> > > > you know that they are from a secure source and are safe. In doubt
> > > > forward the email to the IT-Helpdesk to check it.
> > > > ********************
> > > >
> > > >
> > > >
> > > > From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> > > >
> > > >
> > > >
> > > > i.MX93 use a different gasket which has different register
> > > > definition compared with i.MX8. Hence implement the gasket
> > > > callbacks in order to add ISI support for i.MX93.
> > > >
> > > >
> > > >
> > > > Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> > > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > > ---
> > > >
> > > >  .../platform/nxp/imx8-isi/imx8-isi-core.c     | 15 ++++++++++
> > > >  .../platform/nxp/imx8-isi/imx8-isi-core.h     |  2 ++
> > > >  .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 30
> +++++++++++++++++++
> > > >  3 files changed, 47 insertions(+)
> > > >
> > > >
> > > >
> > > > diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > > > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c index
> > > > 5165f8960c2c..27bd18b7ee65 100644
> > > > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > > > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > > > @@ -307,6 +307,20 @@ static const struct mxc_isi_plat_data
> > >
> > > mxc_imx8mp_data =
> > >
> > > > { .has_36bit_dma              = true,
> > > >
> > > >  };
> > > >
> > > >
> > > >
> > > > +static const struct mxc_isi_plat_data mxc_imx93_data = {
> > > > +     .model                  = MXC_ISI_IMX93,
> > > > +     .num_ports              = 1,
> > > > +     .num_channels           = 1,
> > > > +     .reg_offset             = 0,
> > > > +     .ier_reg                = &mxc_imx8_isi_ier_v2,
> > > > +     .set_thd                = &mxc_imx8_isi_thd_v1,
> > > > +     .clks                   = mxc_imx8mn_clks,
> > > > +     .num_clks               = ARRAY_SIZE(mxc_imx8mn_clks),
> > > > +     .buf_active_reverse     = true,
> > > > +     .gasket_ops             = &mxc_imx93_gasket_ops,
> > > > +     .has_36bit_dma          = false,
> > > > +};
> > > > +
> > > >
> > > >  /*
> > > >
> > > > ------------------------------------------------------------------
> > > > ----
> > > > -----
> > > > -- * Power management
> > > >
> > > >   */
> > > >
> > > > @@ -518,6 +532,7 @@ static int mxc_isi_remove(struct
> > > > platform_device
> > > > *pdev)  static const struct of_device_id mxc_isi_of_match[] = {
> > > >
> > > >       { .compatible = "fsl,imx8mn-isi", .data = &mxc_imx8mn_data },
> > > >       { .compatible = "fsl,imx8mp-isi", .data = &mxc_imx8mp_data
> > > > },
> > > >
> > > > +     { .compatible = "fsl,imx93-isi", .data = &mxc_imx93_data },
> > > >
> > > >       { /* sentinel */ },
> > > >
> > > >  };
> > > >  MODULE_DEVICE_TABLE(of, mxc_isi_of_match); diff --git
> > > >
> > > > a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > > > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h index
> > > > 78ca047d93d1..2810ebe9b5f7 100644
> > > > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > > > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > > > @@ -158,6 +158,7 @@ struct mxc_gasket_ops {  enum model {
> > > >
> > > >       MXC_ISI_IMX8MN,
> > > >       MXC_ISI_IMX8MP,
> > > >
> > > > +     MXC_ISI_IMX93,
> > > >
> > > >  };
> > > >
> > > >
> > > >
> > > >  struct mxc_isi_plat_data {
> > > >
> > > > @@ -295,6 +296,7 @@ struct mxc_isi_dev {  };
> > > >
> > > >
> > > >
> > > >  extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
> > > >
> > > > +extern const struct mxc_gasket_ops mxc_imx93_gasket_ops;
> > > >
> > > >
> > > >
> > > >  int mxc_isi_crossbar_init(struct mxc_isi_dev *isi);  void
> > > >
> > > > mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar); diff
> > > > --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > > > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c index
> > > > 1d632dc60699..50ac1d3a2b6f 100644
> > > > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > > > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > > > @@ -53,3 +53,33 @@ const struct mxc_gasket_ops
> mxc_imx8_gasket_ops
> > > > = {
> > > >
> > > >       .enable = mxc_imx8_gasket_enable,
> > > >       .disable = mxc_imx8_gasket_disable,  };
> > > >
> > > > +
> > > > +/*
> > > > ------------------------------------------------------------------
> > > > ----
> > > > -----
> > > > -- + * i.MX93 gasket
> > > > + **/
> > > > +
> > > > +#define DISP_MIX_CAMERA_MUX                     0x30
> > >
> > >
> > > Which peripheral does this refer to? I would assume it is the Media
> > > Mix Domain Block Control, but there is no register at 0x30 mentioned
> > > in the reference manual. You have some additional information?
> > >
> > > Also which type of input did you use? MIPI-CSI2 or parallel interface?
> >
> >
> > Yes, it's Media Mix Domain Block Control(I name it Disp_Mix due to
> > history reason).
> >
> > I check RM in NXP Website and don't found 0x30 as you said since it's
> > REV2, not latest one which still under review.
> 
> Thanks for confirmation.
> 
> > The input is MIPI CSI-2 by default.(We use default value in the
> > serials)
> 
> Thanks. Is there already a (preliminary) driver for the MIPI CSI-2 peripheral?

Yes, I'm preparing to send out it these days.

> 
> Thanks and best regards,
> Alexander
> 
> > >
> > > Thanks and best regards,
> > > Alexander
> > >
> > >
> > > > +#define DISP_MIX_CAMERA_MUX_DATA_TYPE(x)        (((x) & 0x3f)
> << 3)
> > > > +#define DISP_MIX_CAMERA_MUX_GASKET_ENABLE       BIT(16)
> > > > +static void mxc_imx93_gasket_enable(struct mxc_isi_dev *isi,
> > > > +                                 const struct
> > > > +v4l2_mbus_frame_desc
> > >
> > > *fd,
> > >
> > > > +                                 const struct v4l2_mbus_framefmt
> > >
> > > *fmt,
> > >
> > > > +                                 const unsigned int port) {
> > > > +     u32 val;
> > > > +
> > > > +     val =
> DISP_MIX_CAMERA_MUX_DATA_TYPE(fd->entry[0].bus.csi2.dt);
> > > > +     val |= DISP_MIX_CAMERA_MUX_GASKET_ENABLE;
> > > > +     regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, val); }
> > > > +
> > > > +static void mxc_imx93_gasket_disable(struct mxc_isi_dev *isi,
> > > > +                                  unsigned int port) {
> > > > +     regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, 0); }
> > > > +
> > > > +const struct mxc_gasket_ops mxc_imx93_gasket_ops = {
> > > > +     .enable = mxc_imx93_gasket_enable,
> > > > +     .disable = mxc_imx93_gasket_disable, };
> > >
> > >
> > >
> > > --
> > > 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/
> > >
> >
> >
> 
> 
> --
> 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/
> 


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

* RE: [PATCH v5 0/3] add ISI support for iMX93
  2023-06-29  1:36 [PATCH v5 0/3] add ISI support for iMX93 guoniu.zhou
                   ` (2 preceding siblings ...)
  2023-06-29  1:36 ` [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93 guoniu.zhou
@ 2023-07-27  1:22 ` G.N. Zhou
  3 siblings, 0 replies; 13+ messages in thread
From: G.N. Zhou @ 2023-07-27  1:22 UTC (permalink / raw)
  To: G.N. Zhou (OSS), linux-media, dl-linux-imx, devicetree
  Cc: laurent.pinchart, mchehab, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, Xavier Roumegue (OSS),
	kernel, jacopo.mondi, sakari.ailus

Hi all,

Do you have any other comments, suggestions or questions for the serial, I would be grateful from any valuable update from community. Thanks in advance.

Best Regards
G.N Zhou


> -----Original Message-----
> From: G.N. Zhou (OSS)
> Sent: 2023年6月29日 9:32
> To: linux-media@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> devicetree@vger.kernel.org
> Cc: laurent.pinchart@ideasonboard.com; mchehab@kernel.org;
> robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; conor+dt@kernel.org;
> Xavier Roumegue (OSS) <xavier.roumegue@oss.nxp.com>;
> kernel@pengutronix.de; jacopo.mondi@ideasonboard.com;
> sakari.ailus@linux.intel.com
> Subject: [PATCH v5 0/3] add ISI support for iMX93
> 
> From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> 
> NXP i.MX93 family almost reuse ISI IP from i.MX8M family, so add it support in
> current ISI driver
> 
> Changes in version 5:
> - Add back some header files removed in version 4
> - Refine some comments placement to make code more clearly
> 
> Changes in version 4:
> - Update commit message to explain why need to move gasket ops to a structure
> - Remove some redundant and unused header files
> - Move gasket ops structure variable to imx8-isi-gasket.c and export them by
> extern
> - Drop some check
> 
> Changes in version 3:
> - Split [PATCH v2 2/2] into two patches, one create a separate file to
>   store gasket operation and the other to add ISI support for i.MX93.
> - Drop some debug message in gasket operation.
> - Merge .gasket_enable and .gasket_config to .gasket_enable
> - Drop some dead code
> - Some other small updates
> 
> Changes in version 2:
> - Remove two patches which used to rename imx8 to imx.
>   [PATCH 1/4] media: dt-bindings: media: rename nxp,imx8-isi.yaml to
> nxp,imx-isi.yaml
>   [PATCH 2/4] media: nxp: rename imx8-isi to imx-isi and remove reference to
> i.MX8
> - Modify commit log to more accurately match its goal.
> - Remove redundant "media" in patch subject.
> 
> Guoniu.zhou (3):
>   media: dt-bindings: nxp,imx8-isi: add i.MX93 ISI compatible string
>   media: nxp: imx8-isi: move i.MX8 gasket configuration to an ops
>     structure
>   media: nxp: imx8-isi: add ISI support for i.MX93
> 
>  .../bindings/media/nxp,imx8-isi.yaml          |  5 +-
>  drivers/media/platform/nxp/imx8-isi/Makefile  |  4 +-
>  .../platform/nxp/imx8-isi/imx8-isi-core.c     | 21 ++++-
>  .../platform/nxp/imx8-isi/imx8-isi-core.h     | 14 ++-
>  .../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 36 ++------
>  .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 85 +++++++++++++++++++
>  6 files changed, 128 insertions(+), 37 deletions(-)  create mode 100644
> drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> 
> --
> 2.37.1


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

* Re: [PATCH v5 2/3] media: nxp: imx8-isi: move i.MX8 gasket configuration to an ops structure
  2023-06-29  1:36 ` [PATCH v5 2/3] media: nxp: imx8-isi: move i.MX8 gasket configuration to an ops structure guoniu.zhou
@ 2023-07-27 21:41   ` Laurent Pinchart
  2023-07-28  1:23     ` G.N. Zhou (OSS)
  0 siblings, 1 reply; 13+ messages in thread
From: Laurent Pinchart @ 2023-07-27 21:41 UTC (permalink / raw)
  To: guoniu.zhou
  Cc: linux-media, linux-imx, devicetree, mchehab, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, xavier.roumegue, kernel,
	jacopo.mondi, sakari.ailus

Hi Guoniu,

Thank you for the patch.

On Thu, Jun 29, 2023 at 09:36:20AM +0800, guoniu.zhou@oss.nxp.com wrote:
> From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> 
> The i.MX93 includes an ISI instance compatible with the imx8-isi
> driver, but with a different gasket. To prepare for this, make the
> gasket configuration modular by moving the code to an ops structure.
> 
> Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> ---
>  drivers/media/platform/nxp/imx8-isi/Makefile  |  4 +-
>  .../platform/nxp/imx8-isi/imx8-isi-core.c     |  6 +-
>  .../platform/nxp/imx8-isi/imx8-isi-core.h     | 12 +++-
>  .../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 36 ++----------
>  .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 55 +++++++++++++++++++
>  5 files changed, 77 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/media/platform/nxp/imx8-isi/Makefile b/drivers/media/platform/nxp/imx8-isi/Makefile
> index 9bff9297686d..4713c4e8b64b 100644
> --- a/drivers/media/platform/nxp/imx8-isi/Makefile
> +++ b/drivers/media/platform/nxp/imx8-isi/Makefile
> @@ -1,7 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> -imx8-isi-y := imx8-isi-core.o imx8-isi-crossbar.o imx8-isi-hw.o \
> -	imx8-isi-pipe.o imx8-isi-video.o
> +imx8-isi-y := imx8-isi-core.o imx8-isi-crossbar.o imx8-isi-gasket.o \
> +	imx8-isi-hw.o imx8-isi-pipe.o imx8-isi-video.o
>  imx8-isi-$(CONFIG_DEBUG_FS) += imx8-isi-debug.o
>  imx8-isi-$(CONFIG_VIDEO_IMX8_ISI_M2M) += imx8-isi-m2m.o
>  
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> index 253e77189b69..5165f8960c2c 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> @@ -289,7 +289,7 @@ static const struct mxc_isi_plat_data mxc_imx8mn_data = {
>  	.clks			= mxc_imx8mn_clks,
>  	.num_clks		= ARRAY_SIZE(mxc_imx8mn_clks),
>  	.buf_active_reverse	= false,
> -	.has_gasket		= true,
> +	.gasket_ops		= &mxc_imx8_gasket_ops,
>  	.has_36bit_dma		= false,
>  };
>  
> @@ -303,7 +303,7 @@ static const struct mxc_isi_plat_data mxc_imx8mp_data = {
>  	.clks			= mxc_imx8mn_clks,
>  	.num_clks		= ARRAY_SIZE(mxc_imx8mn_clks),
>  	.buf_active_reverse	= true,
> -	.has_gasket		= true,
> +	.gasket_ops		= &mxc_imx8_gasket_ops,
>  	.has_36bit_dma		= true,
>  };
>  
> @@ -443,7 +443,7 @@ static int mxc_isi_probe(struct platform_device *pdev)
>  		return PTR_ERR(isi->regs);
>  	}
>  
> -	if (isi->pdata->has_gasket) {
> +	if (isi->pdata->gasket_ops) {
>  		isi->gasket = syscon_regmap_lookup_by_phandle(dev->of_node,
>  							      "fsl,blk-ctrl");
>  		if (IS_ERR(isi->gasket)) {
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> index e469788a9e6c..78ca047d93d1 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> @@ -147,6 +147,14 @@ struct mxc_isi_set_thd {
>  	struct mxc_isi_panic_thd panic_set_thd_v;
>  };
>  
> +struct mxc_gasket_ops {
> +	void (*enable)(struct mxc_isi_dev *isi,
> +		       const struct v4l2_mbus_frame_desc *fd,
> +		       const struct v4l2_mbus_framefmt *fmt,
> +		       const unsigned int port);
> +	void (*disable)(struct mxc_isi_dev *isi, const unsigned int port);
> +};
> +
>  enum model {
>  	MXC_ISI_IMX8MN,
>  	MXC_ISI_IMX8MP,
> @@ -159,10 +167,10 @@ struct mxc_isi_plat_data {
>  	unsigned int reg_offset;
>  	const struct mxc_isi_ier_reg  *ier_reg;
>  	const struct mxc_isi_set_thd *set_thd;
> +	const struct mxc_gasket_ops *gasket_ops;
>  	const struct clk_bulk_data *clks;
>  	unsigned int num_clks;
>  	bool buf_active_reverse;
> -	bool has_gasket;
>  	bool has_36bit_dma;
>  };
>  
> @@ -286,6 +294,8 @@ struct mxc_isi_dev {
>  	struct dentry			*debugfs_root;
>  };
>  
> +extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
> +
>  int mxc_isi_crossbar_init(struct mxc_isi_dev *isi);
>  void mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar);
>  int mxc_isi_crossbar_register(struct mxc_isi_crossbar *xbar);
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> index f7447b2f4d77..c6a658ef0c62 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> @@ -15,7 +15,6 @@
>  #include <linux/types.h>
>  
>  #include <media/media-entity.h>
> -#include <media/mipi-csi2.h>
>  #include <media/v4l2-subdev.h>
>  
>  #include "imx8-isi-core.h"
> @@ -25,32 +24,18 @@ static inline struct mxc_isi_crossbar *to_isi_crossbar(struct v4l2_subdev *sd)
>  	return container_of(sd, struct mxc_isi_crossbar, sd);
>  }
>  
> -/* -----------------------------------------------------------------------------
> - * Media block control (i.MX8MN and i.MX8MP only)
> - */
> -#define GASKET_BASE(n)				(0x0060 + (n) * 0x30)
> -
> -#define GASKET_CTRL				0x0000
> -#define GASKET_CTRL_DATA_TYPE(dt)		((dt) << 8)
> -#define GASKET_CTRL_DATA_TYPE_MASK		(0x3f << 8)
> -#define GASKET_CTRL_DUAL_COMP_ENABLE		BIT(1)
> -#define GASKET_CTRL_ENABLE			BIT(0)
> -
> -#define GASKET_HSIZE				0x0004
> -#define GASKET_VSIZE				0x0008
> -
>  static int mxc_isi_crossbar_gasket_enable(struct mxc_isi_crossbar *xbar,
>  					  struct v4l2_subdev_state *state,
>  					  struct v4l2_subdev *remote_sd,
>  					  u32 remote_pad, unsigned int port)
>  {
>  	struct mxc_isi_dev *isi = xbar->isi;
> +	const struct mxc_gasket_ops *gasket_ops = isi->pdata->gasket_ops;
>  	const struct v4l2_mbus_framefmt *fmt;
>  	struct v4l2_mbus_frame_desc fd;
> -	u32 val;
>  	int ret;
>  
> -	if (!isi->pdata->has_gasket)
> +	if (!gasket_ops)
>  		return 0;
>  
>  	/*
> @@ -77,17 +62,7 @@ static int mxc_isi_crossbar_gasket_enable(struct mxc_isi_crossbar *xbar,
>  	if (!fmt)
>  		return -EINVAL;
>  
> -	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_HSIZE, fmt->width);
> -	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_VSIZE, fmt->height);
> -
> -	val = GASKET_CTRL_DATA_TYPE(fd.entry[0].bus.csi2.dt)
> -	    | GASKET_CTRL_ENABLE;
> -
> -	if (fd.entry[0].bus.csi2.dt == MIPI_CSI2_DT_YUV422_8B)
> -		val |= GASKET_CTRL_DUAL_COMP_ENABLE;
> -
> -	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, val);
> -
> +	gasket_ops->enable(isi, &fd, fmt, port);
>  	return 0;
>  }
>  
> @@ -95,11 +70,12 @@ static void mxc_isi_crossbar_gasket_disable(struct mxc_isi_crossbar *xbar,
>  					    unsigned int port)
>  {
>  	struct mxc_isi_dev *isi = xbar->isi;
> +	const struct mxc_gasket_ops *gasket_ops = isi->pdata->gasket_ops;
>  
> -	if (!isi->pdata->has_gasket)
> +	if (!gasket_ops)
>  		return;
>  
> -	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, 0);
> +	gasket_ops->disable(isi, port);
>  }
>  
>  /* -----------------------------------------------------------------------------
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> new file mode 100644
> index 000000000000..1d632dc60699
> --- /dev/null
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> @@ -0,0 +1,55 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright 2019-2023 NXP
> + */
> +
> +#include <linux/regmap.h>
> +
> +#include <media/mipi-csi2.h>
> +
> +#include "imx8-isi-core.h"
> +
> +/* -----------------------------------------------------------------------------
> + * i.MX8MN and i.MX8MP gasket
> + **/

There's an extra star here, it should be

  */

> +
> +#define GASKET_BASE(n)				(0x0060 + (n) * 0x30)
> +
> +#define GASKET_CTRL				0x0000
> +#define GASKET_CTRL_DATA_TYPE(dt)		((dt) << 8)
> +#define GASKET_CTRL_DATA_TYPE_MASK		(0x3f << 8)
> +#define GASKET_CTRL_DUAL_COMP_ENABLE		BIT(1)
> +#define GASKET_CTRL_ENABLE			BIT(0)
> +
> +#define GASKET_HSIZE				0x0004
> +#define GASKET_VSIZE				0x0008
> +
> +static void mxc_imx8_gasket_enable(struct mxc_isi_dev *isi,
> +				   const struct v4l2_mbus_frame_desc *fd,
> +				   const struct v4l2_mbus_framefmt *fmt,
> +				   const unsigned int port)
> +{
> +	u32 val;
> +
> +	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_HSIZE, fmt->width);
> +	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_VSIZE, fmt->height);
> +
> +	val = GASKET_CTRL_DATA_TYPE(fd->entry[0].bus.csi2.dt);
> +	if (fd->entry[0].bus.csi2.dt == MIPI_CSI2_DT_YUV422_8B)
> +		val |= GASKET_CTRL_DUAL_COMP_ENABLE;
> +
> +	val |= GASKET_CTRL_ENABLE;
> +	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, val);
> +}
> +
> +static void mxc_imx8_gasket_disable(struct mxc_isi_dev *isi,
> +				    const unsigned int port)
> +{
> +	regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, 0);
> +}
> +
> +/* Gasket operations for i.MX8MN and i.MX8MP */

This comment can be dropped too, the section header above is enough.
With these minor issues fixed,

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

There's no need to resubmit the series just for this, I can make those
modifications locally if no other changes are needed.

> +const struct mxc_gasket_ops mxc_imx8_gasket_ops = {
> +	.enable = mxc_imx8_gasket_enable,
> +	.disable = mxc_imx8_gasket_disable,
> +};

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93
  2023-06-29  1:36 ` [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93 guoniu.zhou
  2023-06-29  6:43   ` Alexander Stein
@ 2023-07-27 21:48   ` Laurent Pinchart
  2023-07-28  1:23     ` G.N. Zhou (OSS)
  1 sibling, 1 reply; 13+ messages in thread
From: Laurent Pinchart @ 2023-07-27 21:48 UTC (permalink / raw)
  To: guoniu.zhou
  Cc: linux-media, linux-imx, devicetree, mchehab, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, xavier.roumegue, kernel,
	jacopo.mondi, sakari.ailus

Hi Guoniu,

Thank you for the patch.

On Thu, Jun 29, 2023 at 09:36:21AM +0800, guoniu.zhou@oss.nxp.com wrote:
> From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> 
> i.MX93 use a different gasket which has different register definition

s/use/uses/
s/definition/definitions/

> compared with i.MX8. Hence implement the gasket callbacks in order to
> add ISI support for i.MX93.
> 
> Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  .../platform/nxp/imx8-isi/imx8-isi-core.c     | 15 ++++++++++
>  .../platform/nxp/imx8-isi/imx8-isi-core.h     |  2 ++
>  .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 30 +++++++++++++++++++
>  3 files changed, 47 insertions(+)
> 
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> index 5165f8960c2c..27bd18b7ee65 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> @@ -307,6 +307,20 @@ static const struct mxc_isi_plat_data mxc_imx8mp_data = {
>  	.has_36bit_dma		= true,
>  };
>  
> +static const struct mxc_isi_plat_data mxc_imx93_data = {
> +	.model			= MXC_ISI_IMX93,
> +	.num_ports		= 1,
> +	.num_channels		= 1,
> +	.reg_offset		= 0,
> +	.ier_reg		= &mxc_imx8_isi_ier_v2,
> +	.set_thd		= &mxc_imx8_isi_thd_v1,
> +	.clks			= mxc_imx8mn_clks,
> +	.num_clks		= ARRAY_SIZE(mxc_imx8mn_clks),
> +	.buf_active_reverse	= true,
> +	.gasket_ops		= &mxc_imx93_gasket_ops,
> +	.has_36bit_dma		= false,
> +};
> +
>  /* -----------------------------------------------------------------------------
>   * Power management
>   */
> @@ -518,6 +532,7 @@ static int mxc_isi_remove(struct platform_device *pdev)
>  static const struct of_device_id mxc_isi_of_match[] = {
>  	{ .compatible = "fsl,imx8mn-isi", .data = &mxc_imx8mn_data },
>  	{ .compatible = "fsl,imx8mp-isi", .data = &mxc_imx8mp_data },
> +	{ .compatible = "fsl,imx93-isi", .data = &mxc_imx93_data },
>  	{ /* sentinel */ },
>  };
>  MODULE_DEVICE_TABLE(of, mxc_isi_of_match);
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> index 78ca047d93d1..2810ebe9b5f7 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> @@ -158,6 +158,7 @@ struct mxc_gasket_ops {
>  enum model {
>  	MXC_ISI_IMX8MN,
>  	MXC_ISI_IMX8MP,
> +	MXC_ISI_IMX93,
>  };
>  
>  struct mxc_isi_plat_data {
> @@ -295,6 +296,7 @@ struct mxc_isi_dev {
>  };
>  
>  extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
> +extern const struct mxc_gasket_ops mxc_imx93_gasket_ops;
>  
>  int mxc_isi_crossbar_init(struct mxc_isi_dev *isi);
>  void mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar);
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> index 1d632dc60699..50ac1d3a2b6f 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> @@ -53,3 +53,33 @@ const struct mxc_gasket_ops mxc_imx8_gasket_ops = {
>  	.enable = mxc_imx8_gasket_enable,
>  	.disable = mxc_imx8_gasket_disable,
>  };
> +
> +/* -----------------------------------------------------------------------------
> + * i.MX93 gasket
> + **/

Extra star here too.

> +
> +#define DISP_MIX_CAMERA_MUX                     0x30
> +#define DISP_MIX_CAMERA_MUX_DATA_TYPE(x)        (((x) & 0x3f) << 3)
> +#define DISP_MIX_CAMERA_MUX_GASKET_ENABLE       BIT(16)

Let's add a blank line here.

With those small issues fixed,

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

I'll make the changes locally and include the series in my next pull
request.

> +static void mxc_imx93_gasket_enable(struct mxc_isi_dev *isi,
> +				    const struct v4l2_mbus_frame_desc *fd,
> +				    const struct v4l2_mbus_framefmt *fmt,
> +				    const unsigned int port)
> +{
> +	u32 val;
> +
> +	val = DISP_MIX_CAMERA_MUX_DATA_TYPE(fd->entry[0].bus.csi2.dt);
> +	val |= DISP_MIX_CAMERA_MUX_GASKET_ENABLE;
> +	regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, val);
> +}
> +
> +static void mxc_imx93_gasket_disable(struct mxc_isi_dev *isi,
> +				     unsigned int port)
> +{
> +	regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, 0);
> +}
> +
> +const struct mxc_gasket_ops mxc_imx93_gasket_ops = {
> +	.enable = mxc_imx93_gasket_enable,
> +	.disable = mxc_imx93_gasket_disable,
> +};

-- 
Regards,

Laurent Pinchart

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

* RE: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93
  2023-07-27 21:48   ` Laurent Pinchart
@ 2023-07-28  1:23     ` G.N. Zhou (OSS)
  0 siblings, 0 replies; 13+ messages in thread
From: G.N. Zhou (OSS) @ 2023-07-28  1:23 UTC (permalink / raw)
  To: Laurent Pinchart, G.N. Zhou (OSS)
  Cc: linux-media, dl-linux-imx, devicetree, mchehab, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, Xavier Roumegue (OSS),
	kernel, jacopo.mondi, sakari.ailus

Hi Laurent, 

> -----Original Message-----
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Sent: 2023年7月28日 5:49
> To: G.N. Zhou (OSS) <guoniu.zhou@oss.nxp.com>
> Cc: linux-media@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> devicetree@vger.kernel.org; mchehab@kernel.org; robh+dt@kernel.org;
> krzysztof.kozlowski+dt@linaro.org; conor+dt@kernel.org; Xavier Roumegue
> (OSS) <xavier.roumegue@oss.nxp.com>; kernel@pengutronix.de;
> jacopo.mondi@ideasonboard.com; sakari.ailus@linux.intel.com
> Subject: Re: [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93
> 
> Caution: This is an external email. Please take care when clicking links or opening
> attachments. When in doubt, report the message using the 'Report this email'
> button
> 
> 
> Hi Guoniu,
> 
> Thank you for the patch.
> 
> On Thu, Jun 29, 2023 at 09:36:21AM +0800, guoniu.zhou@oss.nxp.com wrote:
> > From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> >
> > i.MX93 use a different gasket which has different register definition
> 
> s/use/uses/
> s/definition/definitions/
> 
> > compared with i.MX8. Hence implement the gasket callbacks in order to
> > add ISI support for i.MX93.
> >
> > Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  .../platform/nxp/imx8-isi/imx8-isi-core.c     | 15 ++++++++++
> >  .../platform/nxp/imx8-isi/imx8-isi-core.h     |  2 ++
> >  .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 30 +++++++++++++++++++
> >  3 files changed, 47 insertions(+)
> >
> > diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > index 5165f8960c2c..27bd18b7ee65 100644
> > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > @@ -307,6 +307,20 @@ static const struct mxc_isi_plat_data
> mxc_imx8mp_data = {
> >       .has_36bit_dma          = true,
> >  };
> >
> > +static const struct mxc_isi_plat_data mxc_imx93_data = {
> > +     .model                  = MXC_ISI_IMX93,
> > +     .num_ports              = 1,
> > +     .num_channels           = 1,
> > +     .reg_offset             = 0,
> > +     .ier_reg                = &mxc_imx8_isi_ier_v2,
> > +     .set_thd                = &mxc_imx8_isi_thd_v1,
> > +     .clks                   = mxc_imx8mn_clks,
> > +     .num_clks               = ARRAY_SIZE(mxc_imx8mn_clks),
> > +     .buf_active_reverse     = true,
> > +     .gasket_ops             = &mxc_imx93_gasket_ops,
> > +     .has_36bit_dma          = false,
> > +};
> > +
> >  /* -----------------------------------------------------------------------------
> >   * Power management
> >   */
> > @@ -518,6 +532,7 @@ static int mxc_isi_remove(struct platform_device
> > *pdev)  static const struct of_device_id mxc_isi_of_match[] = {
> >       { .compatible = "fsl,imx8mn-isi", .data = &mxc_imx8mn_data },
> >       { .compatible = "fsl,imx8mp-isi", .data = &mxc_imx8mp_data },
> > +     { .compatible = "fsl,imx93-isi", .data = &mxc_imx93_data },
> >       { /* sentinel */ },
> >  };
> >  MODULE_DEVICE_TABLE(of, mxc_isi_of_match); diff --git
> > a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > index 78ca047d93d1..2810ebe9b5f7 100644
> > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > @@ -158,6 +158,7 @@ struct mxc_gasket_ops {  enum model {
> >       MXC_ISI_IMX8MN,
> >       MXC_ISI_IMX8MP,
> > +     MXC_ISI_IMX93,
> >  };
> >
> >  struct mxc_isi_plat_data {
> > @@ -295,6 +296,7 @@ struct mxc_isi_dev {  };
> >
> >  extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
> > +extern const struct mxc_gasket_ops mxc_imx93_gasket_ops;
> >
> >  int mxc_isi_crossbar_init(struct mxc_isi_dev *isi);  void
> > mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar); diff --git
> > a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > index 1d632dc60699..50ac1d3a2b6f 100644
> > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > @@ -53,3 +53,33 @@ const struct mxc_gasket_ops mxc_imx8_gasket_ops = {
> >       .enable = mxc_imx8_gasket_enable,
> >       .disable = mxc_imx8_gasket_disable,  };
> > +
> > +/*
> > +---------------------------------------------------------------------
> > +--------
> > + * i.MX93 gasket
> > + **/
> 
> Extra star here too.
> 
> > +
> > +#define DISP_MIX_CAMERA_MUX                     0x30
> > +#define DISP_MIX_CAMERA_MUX_DATA_TYPE(x)        (((x) & 0x3f) << 3)
> > +#define DISP_MIX_CAMERA_MUX_GASKET_ENABLE       BIT(16)
> 
> Let's add a blank line here.
> 
> With those small issues fixed,
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> I'll make the changes locally and include the series in my next pull request.

Okay, thanks.

> 
> > +static void mxc_imx93_gasket_enable(struct mxc_isi_dev *isi,
> > +                                 const struct v4l2_mbus_frame_desc
> *fd,
> > +                                 const struct v4l2_mbus_framefmt
> *fmt,
> > +                                 const unsigned int port) {
> > +     u32 val;
> > +
> > +     val = DISP_MIX_CAMERA_MUX_DATA_TYPE(fd->entry[0].bus.csi2.dt);
> > +     val |= DISP_MIX_CAMERA_MUX_GASKET_ENABLE;
> > +     regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, val); }
> > +
> > +static void mxc_imx93_gasket_disable(struct mxc_isi_dev *isi,
> > +                                  unsigned int port) {
> > +     regmap_write(isi->gasket, DISP_MIX_CAMERA_MUX, 0); }
> > +
> > +const struct mxc_gasket_ops mxc_imx93_gasket_ops = {
> > +     .enable = mxc_imx93_gasket_enable,
> > +     .disable = mxc_imx93_gasket_disable, };
> 
> --
> Regards,
> 
> Laurent Pinchart

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

* RE: [PATCH v5 2/3] media: nxp: imx8-isi: move i.MX8 gasket configuration to an ops structure
  2023-07-27 21:41   ` Laurent Pinchart
@ 2023-07-28  1:23     ` G.N. Zhou (OSS)
  0 siblings, 0 replies; 13+ messages in thread
From: G.N. Zhou (OSS) @ 2023-07-28  1:23 UTC (permalink / raw)
  To: Laurent Pinchart, G.N. Zhou (OSS)
  Cc: linux-media, dl-linux-imx, devicetree, mchehab, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, Xavier Roumegue (OSS),
	kernel, jacopo.mondi, sakari.ailus

Hi Laurent,

> -----Original Message-----
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Sent: 2023年7月28日 5:42
> To: G.N. Zhou (OSS) <guoniu.zhou@oss.nxp.com>
> Cc: linux-media@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> devicetree@vger.kernel.org; mchehab@kernel.org; robh+dt@kernel.org;
> krzysztof.kozlowski+dt@linaro.org; conor+dt@kernel.org; Xavier Roumegue
> (OSS) <xavier.roumegue@oss.nxp.com>; kernel@pengutronix.de;
> jacopo.mondi@ideasonboard.com; sakari.ailus@linux.intel.com
> Subject: Re: [PATCH v5 2/3] media: nxp: imx8-isi: move i.MX8 gasket
> configuration to an ops structure
> 
> Caution: This is an external email. Please take care when clicking links or opening
> attachments. When in doubt, report the message using the 'Report this email'
> button
> 
> 
> Hi Guoniu,
> 
> Thank you for the patch.
> 
> On Thu, Jun 29, 2023 at 09:36:20AM +0800, guoniu.zhou@oss.nxp.com wrote:
> > From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> >
> > The i.MX93 includes an ISI instance compatible with the imx8-isi
> > driver, but with a different gasket. To prepare for this, make the
> > gasket configuration modular by moving the code to an ops structure.
> >
> > Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> > ---
> >  drivers/media/platform/nxp/imx8-isi/Makefile  |  4 +-
> >  .../platform/nxp/imx8-isi/imx8-isi-core.c     |  6 +-
> >  .../platform/nxp/imx8-isi/imx8-isi-core.h     | 12 +++-
> >  .../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 36 ++----------
> >  .../platform/nxp/imx8-isi/imx8-isi-gasket.c   | 55 +++++++++++++++++++
> >  5 files changed, 77 insertions(+), 36 deletions(-)
> >
> > diff --git a/drivers/media/platform/nxp/imx8-isi/Makefile
> > b/drivers/media/platform/nxp/imx8-isi/Makefile
> > index 9bff9297686d..4713c4e8b64b 100644
> > --- a/drivers/media/platform/nxp/imx8-isi/Makefile
> > +++ b/drivers/media/platform/nxp/imx8-isi/Makefile
> > @@ -1,7 +1,7 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > -imx8-isi-y := imx8-isi-core.o imx8-isi-crossbar.o imx8-isi-hw.o \
> > -     imx8-isi-pipe.o imx8-isi-video.o
> > +imx8-isi-y := imx8-isi-core.o imx8-isi-crossbar.o imx8-isi-gasket.o \
> > +     imx8-isi-hw.o imx8-isi-pipe.o imx8-isi-video.o
> >  imx8-isi-$(CONFIG_DEBUG_FS) += imx8-isi-debug.o
> >  imx8-isi-$(CONFIG_VIDEO_IMX8_ISI_M2M) += imx8-isi-m2m.o
> >
> > diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > index 253e77189b69..5165f8960c2c 100644
> > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> > @@ -289,7 +289,7 @@ static const struct mxc_isi_plat_data
> mxc_imx8mn_data = {
> >       .clks                   = mxc_imx8mn_clks,
> >       .num_clks               = ARRAY_SIZE(mxc_imx8mn_clks),
> >       .buf_active_reverse     = false,
> > -     .has_gasket             = true,
> > +     .gasket_ops             = &mxc_imx8_gasket_ops,
> >       .has_36bit_dma          = false,
> >  };
> >
> > @@ -303,7 +303,7 @@ static const struct mxc_isi_plat_data
> mxc_imx8mp_data = {
> >       .clks                   = mxc_imx8mn_clks,
> >       .num_clks               = ARRAY_SIZE(mxc_imx8mn_clks),
> >       .buf_active_reverse     = true,
> > -     .has_gasket             = true,
> > +     .gasket_ops             = &mxc_imx8_gasket_ops,
> >       .has_36bit_dma          = true,
> >  };
> >
> > @@ -443,7 +443,7 @@ static int mxc_isi_probe(struct platform_device
> *pdev)
> >               return PTR_ERR(isi->regs);
> >       }
> >
> > -     if (isi->pdata->has_gasket) {
> > +     if (isi->pdata->gasket_ops) {
> >               isi->gasket =
> syscon_regmap_lookup_by_phandle(dev->of_node,
> >
> "fsl,blk-ctrl");
> >               if (IS_ERR(isi->gasket)) { diff --git
> > a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > index e469788a9e6c..78ca047d93d1 100644
> > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> > @@ -147,6 +147,14 @@ struct mxc_isi_set_thd {
> >       struct mxc_isi_panic_thd panic_set_thd_v;  };
> >
> > +struct mxc_gasket_ops {
> > +     void (*enable)(struct mxc_isi_dev *isi,
> > +                    const struct v4l2_mbus_frame_desc *fd,
> > +                    const struct v4l2_mbus_framefmt *fmt,
> > +                    const unsigned int port);
> > +     void (*disable)(struct mxc_isi_dev *isi, const unsigned int
> > +port); };
> > +
> >  enum model {
> >       MXC_ISI_IMX8MN,
> >       MXC_ISI_IMX8MP,
> > @@ -159,10 +167,10 @@ struct mxc_isi_plat_data {
> >       unsigned int reg_offset;
> >       const struct mxc_isi_ier_reg  *ier_reg;
> >       const struct mxc_isi_set_thd *set_thd;
> > +     const struct mxc_gasket_ops *gasket_ops;
> >       const struct clk_bulk_data *clks;
> >       unsigned int num_clks;
> >       bool buf_active_reverse;
> > -     bool has_gasket;
> >       bool has_36bit_dma;
> >  };
> >
> > @@ -286,6 +294,8 @@ struct mxc_isi_dev {
> >       struct dentry                   *debugfs_root;
> >  };
> >
> > +extern const struct mxc_gasket_ops mxc_imx8_gasket_ops;
> > +
> >  int mxc_isi_crossbar_init(struct mxc_isi_dev *isi);  void
> > mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar);  int
> > mxc_isi_crossbar_register(struct mxc_isi_crossbar *xbar); diff --git
> > a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> > b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> > index f7447b2f4d77..c6a658ef0c62 100644
> > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> > @@ -15,7 +15,6 @@
> >  #include <linux/types.h>
> >
> >  #include <media/media-entity.h>
> > -#include <media/mipi-csi2.h>
> >  #include <media/v4l2-subdev.h>
> >
> >  #include "imx8-isi-core.h"
> > @@ -25,32 +24,18 @@ static inline struct mxc_isi_crossbar
> *to_isi_crossbar(struct v4l2_subdev *sd)
> >       return container_of(sd, struct mxc_isi_crossbar, sd);  }
> >
> > -/*
> > ----------------------------------------------------------------------
> > -------
> > - * Media block control (i.MX8MN and i.MX8MP only)
> > - */
> > -#define GASKET_BASE(n)                               (0x0060 + (n) *
> 0x30)
> > -
> > -#define GASKET_CTRL                          0x0000
> > -#define GASKET_CTRL_DATA_TYPE(dt)            ((dt) << 8)
> > -#define GASKET_CTRL_DATA_TYPE_MASK           (0x3f << 8)
> > -#define GASKET_CTRL_DUAL_COMP_ENABLE         BIT(1)
> > -#define GASKET_CTRL_ENABLE                   BIT(0)
> > -
> > -#define GASKET_HSIZE                         0x0004
> > -#define GASKET_VSIZE                         0x0008
> > -
> >  static int mxc_isi_crossbar_gasket_enable(struct mxc_isi_crossbar *xbar,
> >                                         struct v4l2_subdev_state
> *state,
> >                                         struct v4l2_subdev
> *remote_sd,
> >                                         u32 remote_pad, unsigned int
> > port)  {
> >       struct mxc_isi_dev *isi = xbar->isi;
> > +     const struct mxc_gasket_ops *gasket_ops =
> > + isi->pdata->gasket_ops;
> >       const struct v4l2_mbus_framefmt *fmt;
> >       struct v4l2_mbus_frame_desc fd;
> > -     u32 val;
> >       int ret;
> >
> > -     if (!isi->pdata->has_gasket)
> > +     if (!gasket_ops)
> >               return 0;
> >
> >       /*
> > @@ -77,17 +62,7 @@ static int mxc_isi_crossbar_gasket_enable(struct
> mxc_isi_crossbar *xbar,
> >       if (!fmt)
> >               return -EINVAL;
> >
> > -     regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_HSIZE,
> fmt->width);
> > -     regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_VSIZE,
> fmt->height);
> > -
> > -     val = GASKET_CTRL_DATA_TYPE(fd.entry[0].bus.csi2.dt)
> > -         | GASKET_CTRL_ENABLE;
> > -
> > -     if (fd.entry[0].bus.csi2.dt == MIPI_CSI2_DT_YUV422_8B)
> > -             val |= GASKET_CTRL_DUAL_COMP_ENABLE;
> > -
> > -     regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, val);
> > -
> > +     gasket_ops->enable(isi, &fd, fmt, port);
> >       return 0;
> >  }
> >
> > @@ -95,11 +70,12 @@ static void mxc_isi_crossbar_gasket_disable(struct
> mxc_isi_crossbar *xbar,
> >                                           unsigned int port)  {
> >       struct mxc_isi_dev *isi = xbar->isi;
> > +     const struct mxc_gasket_ops *gasket_ops =
> > + isi->pdata->gasket_ops;
> >
> > -     if (!isi->pdata->has_gasket)
> > +     if (!gasket_ops)
> >               return;
> >
> > -     regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, 0);
> > +     gasket_ops->disable(isi, port);
> >  }
> >
> >  /* -----------------------------------------------------------------------------
> > diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > new file mode 100644
> > index 000000000000..1d632dc60699
> > --- /dev/null
> > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-gasket.c
> > @@ -0,0 +1,55 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright 2019-2023 NXP
> > + */
> > +
> > +#include <linux/regmap.h>
> > +
> > +#include <media/mipi-csi2.h>
> > +
> > +#include "imx8-isi-core.h"
> > +
> > +/* -----------------------------------------------------------------------------
> > + * i.MX8MN and i.MX8MP gasket
> > + **/
> 
> There's an extra star here, it should be
> 
>   */
> 
> > +
> > +#define GASKET_BASE(n)                               (0x0060 + (n) *
> 0x30)
> > +
> > +#define GASKET_CTRL                          0x0000
> > +#define GASKET_CTRL_DATA_TYPE(dt)            ((dt) << 8)
> > +#define GASKET_CTRL_DATA_TYPE_MASK           (0x3f << 8)
> > +#define GASKET_CTRL_DUAL_COMP_ENABLE         BIT(1)
> > +#define GASKET_CTRL_ENABLE                   BIT(0)
> > +
> > +#define GASKET_HSIZE                         0x0004
> > +#define GASKET_VSIZE                         0x0008
> > +
> > +static void mxc_imx8_gasket_enable(struct mxc_isi_dev *isi,
> > +                                const struct v4l2_mbus_frame_desc
> *fd,
> > +                                const struct v4l2_mbus_framefmt
> *fmt,
> > +                                const unsigned int port)
> > +{
> > +     u32 val;
> > +
> > +     regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_HSIZE,
> fmt->width);
> > +     regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_VSIZE,
> fmt->height);
> > +
> > +     val = GASKET_CTRL_DATA_TYPE(fd->entry[0].bus.csi2.dt);
> > +     if (fd->entry[0].bus.csi2.dt == MIPI_CSI2_DT_YUV422_8B)
> > +             val |= GASKET_CTRL_DUAL_COMP_ENABLE;
> > +
> > +     val |= GASKET_CTRL_ENABLE;
> > +     regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, val);
> > +}
> > +
> > +static void mxc_imx8_gasket_disable(struct mxc_isi_dev *isi,
> > +                                 const unsigned int port)
> > +{
> > +     regmap_write(isi->gasket, GASKET_BASE(port) + GASKET_CTRL, 0);
> > +}
> > +
> > +/* Gasket operations for i.MX8MN and i.MX8MP */
> 
> This comment can be dropped too, the section header above is enough.
> With these minor issues fixed,
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> There's no need to resubmit the series just for this, I can make those
> modifications locally if no other changes are needed.

Okay, thank you.

> 
> > +const struct mxc_gasket_ops mxc_imx8_gasket_ops = {
> > +     .enable = mxc_imx8_gasket_enable,
> > +     .disable = mxc_imx8_gasket_disable,
> > +};
> 
> --
> Regards,
> 
> Laurent Pinchart

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

end of thread, other threads:[~2023-07-28  1:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-29  1:36 [PATCH v5 0/3] add ISI support for iMX93 guoniu.zhou
2023-06-29  1:36 ` [PATCH v5 1/3] media: dt-bindings: nxp,imx8-isi: add i.MX93 ISI compatible string guoniu.zhou
2023-06-29  1:36 ` [PATCH v5 2/3] media: nxp: imx8-isi: move i.MX8 gasket configuration to an ops structure guoniu.zhou
2023-07-27 21:41   ` Laurent Pinchart
2023-07-28  1:23     ` G.N. Zhou (OSS)
2023-06-29  1:36 ` [PATCH v5 3/3] media: nxp: imx8-isi: add ISI support for i.MX93 guoniu.zhou
2023-06-29  6:43   ` Alexander Stein
2023-06-29  7:07     ` G.N. Zhou (OSS)
2023-06-29  7:59       ` Alexander Stein
2023-06-29  8:23         ` G.N. Zhou (OSS)
2023-07-27 21:48   ` Laurent Pinchart
2023-07-28  1:23     ` G.N. Zhou (OSS)
2023-07-27  1:22 ` [PATCH v5 0/3] add ISI support for iMX93 G.N. Zhou

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