linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] dmaengine: fsl-edma: add 8ulp support
@ 2024-02-29 20:58 Frank Li
  2024-02-29 20:58 ` [PATCH v2 1/5] dmaengine: fsl-edma: remove 'slave_id' from fsl_edma_chan Frank Li
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Frank Li @ 2024-02-29 20:58 UTC (permalink / raw)
  To: Vinod Koul, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peng Fan
  Cc: imx, dmaengine, linux-kernel, devicetree, Frank Li, Joy Zou

Do some small clean up.                                                    

0c562876972ee dmaengine: fsl-edma: remove 'slave_id' from fsl_edma_chan    
d9b66cb5fdf62 dmaengine: fsl-edma: add safety check for 'srcid'            
aae21b7528311 dmaengine: fsl-edma: clean up chclk and FSL_EDMA_DRV_HAS_CHCLK

Update binding doc.                                                        
23a1d1a6609fa dt-bindings: fsl-dma: fsl-edma: add fsl,imx8ulp-edma compatible string

Add 8ulp support.                                                          
dmaengine: fsl-edma: add i.MX8ULP edma support

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Changes in v2:
  Fixed dt-bind about clocks number restriction for vf610. Keep the same
restriction for other compatible string.

  Send out v2 to avoid consiste test rebot report build error.
  Fixed build error

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

  Rework dt-binding commit message. Add reason why change clk number to 33.

- Link to v1: https://lore.kernel.org/r/20240227-8ulp_edma-v1-0-7fcfe1e265c2@nxp.com

---
Frank Li (3):
      dmaengine: fsl-edma: remove 'slave_id' from fsl_edma_chan
      dmaengine: fsl-edma: add safety check for 'srcid'
      dmaengine: fsl-edma: clean up chclk and FSL_EDMA_DRV_HAS_CHCLK

Joy Zou (2):
      dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string
      dmaengine: fsl-edma: add i.MX8ULP edma support

 .../devicetree/bindings/dma/fsl,edma.yaml          | 26 +++++++++++-
 drivers/dma/fsl-edma-common.c                      |  6 +++
 drivers/dma/fsl-edma-common.h                      |  2 -
 drivers/dma/fsl-edma-main.c                        | 47 ++++++++++++++++------
 drivers/dma/mcf-edma-main.c                        |  4 +-
 5 files changed, 66 insertions(+), 19 deletions(-)
---
base-commit: 2d5c7b7eb345249cb34d42cbc2b97b4c57ea944e
change-id: 20240227-8ulp_edma-12ee2648d74b

Best regards,
-- 
Frank Li <Frank.Li@nxp.com>


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

* [PATCH v2 1/5] dmaengine: fsl-edma: remove 'slave_id' from fsl_edma_chan
  2024-02-29 20:58 [PATCH v2 0/5] dmaengine: fsl-edma: add 8ulp support Frank Li
@ 2024-02-29 20:58 ` Frank Li
  2024-02-29 20:58 ` [PATCH v2 2/5] dmaengine: fsl-edma: add safety check for 'srcid' Frank Li
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Frank Li @ 2024-02-29 20:58 UTC (permalink / raw)
  To: Vinod Koul, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peng Fan
  Cc: imx, dmaengine, linux-kernel, devicetree, Frank Li

The 'slave_id' field is redundant as it duplicates the functionality of
'srcid'. Remove 'slave_id' from fsl_edma_chan to eliminate redundancy.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/dma/fsl-edma-common.h |  1 -
 drivers/dma/fsl-edma-main.c   | 10 +++++-----
 drivers/dma/mcf-edma-main.c   |  4 ++--
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h
index 7bf0aba471a8c..4cf1de9f0e512 100644
--- a/drivers/dma/fsl-edma-common.h
+++ b/drivers/dma/fsl-edma-common.h
@@ -151,7 +151,6 @@ struct fsl_edma_chan {
 	enum dma_status			status;
 	enum fsl_edma_pm_state		pm_state;
 	bool				idle;
-	u32				slave_id;
 	struct fsl_edma_engine		*edma;
 	struct fsl_edma_desc		*edesc;
 	struct dma_slave_config		cfg;
diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c
index 402f0058a180c..0a6e0c4040274 100644
--- a/drivers/dma/fsl-edma-main.c
+++ b/drivers/dma/fsl-edma-main.c
@@ -114,8 +114,8 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
 			if (chan) {
 				chan->device->privatecnt++;
 				fsl_chan = to_fsl_edma_chan(chan);
-				fsl_chan->slave_id = dma_spec->args[1];
-				fsl_edma_chan_mux(fsl_chan, fsl_chan->slave_id,
+				fsl_chan->srcid = dma_spec->args[1];
+				fsl_edma_chan_mux(fsl_chan, fsl_chan->srcid,
 						true);
 				mutex_unlock(&fsl_edma->fsl_edma_mutex);
 				return chan;
@@ -540,7 +540,7 @@ static int fsl_edma_probe(struct platform_device *pdev)
 
 		fsl_chan->edma = fsl_edma;
 		fsl_chan->pm_state = RUNNING;
-		fsl_chan->slave_id = 0;
+		fsl_chan->srcid = 0;
 		fsl_chan->idle = true;
 		fsl_chan->dma_dir = DMA_NONE;
 		fsl_chan->vchan.desc_free = fsl_edma_free_desc;
@@ -682,8 +682,8 @@ static int fsl_edma_resume_early(struct device *dev)
 			continue;
 		fsl_chan->pm_state = RUNNING;
 		edma_write_tcdreg(fsl_chan, 0, csr);
-		if (fsl_chan->slave_id != 0)
-			fsl_edma_chan_mux(fsl_chan, fsl_chan->slave_id, true);
+		if (fsl_chan->srcid != 0)
+			fsl_edma_chan_mux(fsl_chan, fsl_chan->srcid, true);
 	}
 
 	if (!(fsl_edma->drvdata->flags & FSL_EDMA_DRV_SPLIT_REG))
diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
index dba6317838767..78c606f6d0026 100644
--- a/drivers/dma/mcf-edma-main.c
+++ b/drivers/dma/mcf-edma-main.c
@@ -195,7 +195,7 @@ static int mcf_edma_probe(struct platform_device *pdev)
 		struct fsl_edma_chan *mcf_chan = &mcf_edma->chans[i];
 
 		mcf_chan->edma = mcf_edma;
-		mcf_chan->slave_id = i;
+		mcf_chan->srcid = i;
 		mcf_chan->idle = true;
 		mcf_chan->dma_dir = DMA_NONE;
 		mcf_chan->vchan.desc_free = fsl_edma_free_desc;
@@ -277,7 +277,7 @@ bool mcf_edma_filter_fn(struct dma_chan *chan, void *param)
 	if (chan->device->dev->driver == &mcf_edma_driver.driver) {
 		struct fsl_edma_chan *mcf_chan = to_fsl_edma_chan(chan);
 
-		return (mcf_chan->slave_id == (uintptr_t)param);
+		return (mcf_chan->srcid == (uintptr_t)param);
 	}
 
 	return false;

-- 
2.34.1


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

* [PATCH v2 2/5] dmaengine: fsl-edma: add safety check for 'srcid'
  2024-02-29 20:58 [PATCH v2 0/5] dmaengine: fsl-edma: add 8ulp support Frank Li
  2024-02-29 20:58 ` [PATCH v2 1/5] dmaengine: fsl-edma: remove 'slave_id' from fsl_edma_chan Frank Li
@ 2024-02-29 20:58 ` Frank Li
  2024-02-29 20:58 ` [PATCH v2 3/5] dmaengine: fsl-edma: clean up chclk and FSL_EDMA_DRV_HAS_CHCLK Frank Li
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Frank Li @ 2024-02-29 20:58 UTC (permalink / raw)
  To: Vinod Koul, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peng Fan
  Cc: imx, dmaengine, linux-kernel, devicetree, Frank Li

Ensure that 'srcid' is a non-zero value to avoid dtb passing invalid
'srcid' to the driver.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/dma/fsl-edma-main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c
index 0a6e0c4040274..2148a7f1ae843 100644
--- a/drivers/dma/fsl-edma-main.c
+++ b/drivers/dma/fsl-edma-main.c
@@ -115,6 +115,13 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
 				chan->device->privatecnt++;
 				fsl_chan = to_fsl_edma_chan(chan);
 				fsl_chan->srcid = dma_spec->args[1];
+
+				if (!fsl_chan->srcid) {
+					dev_err(&fsl_chan->pdev->dev, "Invalidate srcid %d\n",
+						fsl_chan->srcid);
+					return NULL;
+				}
+
 				fsl_edma_chan_mux(fsl_chan, fsl_chan->srcid,
 						true);
 				mutex_unlock(&fsl_edma->fsl_edma_mutex);

-- 
2.34.1


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

* [PATCH v2 3/5] dmaengine: fsl-edma: clean up chclk and FSL_EDMA_DRV_HAS_CHCLK
  2024-02-29 20:58 [PATCH v2 0/5] dmaengine: fsl-edma: add 8ulp support Frank Li
  2024-02-29 20:58 ` [PATCH v2 1/5] dmaengine: fsl-edma: remove 'slave_id' from fsl_edma_chan Frank Li
  2024-02-29 20:58 ` [PATCH v2 2/5] dmaengine: fsl-edma: add safety check for 'srcid' Frank Li
@ 2024-02-29 20:58 ` Frank Li
  2024-02-29 20:58 ` [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string Frank Li
  2024-02-29 20:58 ` [PATCH v2 5/5] dmaengine: fsl-edma: add i.MX8ULP edma support Frank Li
  4 siblings, 0 replies; 12+ messages in thread
From: Frank Li @ 2024-02-29 20:58 UTC (permalink / raw)
  To: Vinod Koul, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peng Fan
  Cc: imx, dmaengine, linux-kernel, devicetree, Frank Li

No device currently utilizes chclk and FSL_EDMA_DRV_HAS_CHCLK features.
Removes these unused features.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/dma/fsl-edma-common.h | 2 --
 drivers/dma/fsl-edma-main.c   | 8 --------
 2 files changed, 10 deletions(-)

diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h
index 4cf1de9f0e512..532f647e540e7 100644
--- a/drivers/dma/fsl-edma-common.h
+++ b/drivers/dma/fsl-edma-common.h
@@ -192,7 +192,6 @@ struct fsl_edma_desc {
 #define FSL_EDMA_DRV_WRAP_IO		BIT(3)
 #define FSL_EDMA_DRV_EDMA64		BIT(4)
 #define FSL_EDMA_DRV_HAS_PD		BIT(5)
-#define FSL_EDMA_DRV_HAS_CHCLK		BIT(6)
 #define FSL_EDMA_DRV_HAS_CHMUX		BIT(7)
 /* imx8 QM audio edma remote local swapped */
 #define FSL_EDMA_DRV_QUIRK_SWAPPED	BIT(8)
@@ -237,7 +236,6 @@ struct fsl_edma_engine {
 	void __iomem		*muxbase[DMAMUX_NR];
 	struct clk		*muxclk[DMAMUX_NR];
 	struct clk		*dmaclk;
-	struct clk		*chclk;
 	struct mutex		fsl_edma_mutex;
 	const struct fsl_edma_drvdata *drvdata;
 	u32			n_chans;
diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c
index 2148a7f1ae843..41c71c360ff1f 100644
--- a/drivers/dma/fsl-edma-main.c
+++ b/drivers/dma/fsl-edma-main.c
@@ -483,14 +483,6 @@ static int fsl_edma_probe(struct platform_device *pdev)
 		}
 	}
 
-	if (drvdata->flags & FSL_EDMA_DRV_HAS_CHCLK) {
-		fsl_edma->chclk = devm_clk_get_enabled(&pdev->dev, "mp");
-		if (IS_ERR(fsl_edma->chclk)) {
-			dev_err(&pdev->dev, "Missing MP block clock.\n");
-			return PTR_ERR(fsl_edma->chclk);
-		}
-	}
-
 	ret = of_property_read_variable_u32_array(np, "dma-channel-mask", chan_mask, 1, 2);
 
 	if (ret > 0) {

-- 
2.34.1


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

* [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string
  2024-02-29 20:58 [PATCH v2 0/5] dmaengine: fsl-edma: add 8ulp support Frank Li
                   ` (2 preceding siblings ...)
  2024-02-29 20:58 ` [PATCH v2 3/5] dmaengine: fsl-edma: clean up chclk and FSL_EDMA_DRV_HAS_CHCLK Frank Li
@ 2024-02-29 20:58 ` Frank Li
  2024-03-04 16:44   ` Rob Herring
  2024-02-29 20:58 ` [PATCH v2 5/5] dmaengine: fsl-edma: add i.MX8ULP edma support Frank Li
  4 siblings, 1 reply; 12+ messages in thread
From: Frank Li @ 2024-02-29 20:58 UTC (permalink / raw)
  To: Vinod Koul, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peng Fan
  Cc: imx, dmaengine, linux-kernel, devicetree, Frank Li, Joy Zou

From: Joy Zou <joy.zou@nxp.com>

Introduce the compatible string 'fsl,imx8ulp-edma' to enable support for
the i.MX8ULP's eDMA, alongside adjusting the clock numbering. The i.MX8ULP
eDMA architecture features one clock for each DMA channel and an additional
clock for the core controller. Given a maximum of 32 DMA channels, the
maximum clock number consequently increases to 33.

Signed-off-by: Joy Zou <joy.zou@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 .../devicetree/bindings/dma/fsl,edma.yaml          | 26 ++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/fsl,edma.yaml b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
index aa51d278cb67b..55cce79c759f8 100644
--- a/Documentation/devicetree/bindings/dma/fsl,edma.yaml
+++ b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
@@ -23,6 +23,7 @@ properties:
           - fsl,imx7ulp-edma
           - fsl,imx8qm-adma
           - fsl,imx8qm-edma
+          - fsl,imx8ulp-edma
           - fsl,imx93-edma3
           - fsl,imx93-edma4
           - fsl,imx95-edma5
@@ -53,11 +54,11 @@ properties:
 
   clocks:
     minItems: 1
-    maxItems: 2
+    maxItems: 33
 
   clock-names:
     minItems: 1
-    maxItems: 2
+    maxItems: 33
 
   big-endian:
     description: |
@@ -108,6 +109,7 @@ allOf:
       properties:
         clocks:
           minItems: 2
+          maxItems: 2
         clock-names:
           items:
             - const: dmamux0
@@ -136,6 +138,7 @@ allOf:
       properties:
         clock:
           minItems: 2
+          maxItems: 2
         clock-names:
           items:
             - const: dma
@@ -151,6 +154,25 @@ allOf:
         dma-channels:
           const: 32
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: fsl,imx8ulp-edma
+    then:
+      properties:
+        clock:
+          maxItems: 33
+        clock-names:
+          items:
+            - const: dma
+            - pattern: "^CH[0-31]-clk$"
+        interrupt-names: false
+        interrupts:
+          maxItems: 32
+        "#dma-cells":
+          const: 3
+
 unevaluatedProperties: false
 
 examples:

-- 
2.34.1


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

* [PATCH v2 5/5] dmaengine: fsl-edma: add i.MX8ULP edma support
  2024-02-29 20:58 [PATCH v2 0/5] dmaengine: fsl-edma: add 8ulp support Frank Li
                   ` (3 preceding siblings ...)
  2024-02-29 20:58 ` [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string Frank Li
@ 2024-02-29 20:58 ` Frank Li
  4 siblings, 0 replies; 12+ messages in thread
From: Frank Li @ 2024-02-29 20:58 UTC (permalink / raw)
  To: Vinod Koul, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peng Fan
  Cc: imx, dmaengine, linux-kernel, devicetree, Frank Li, Joy Zou

From: Joy Zou <joy.zou@nxp.com>

Add support for the i.MX8ULP platform to the eDMA driver. Introduce the use
of the correct FSL_EDMA_DRV_HAS_CHCLK flag to handle per-channel clock
configurations.

Signed-off-by: Joy Zou <joy.zou@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/dma/fsl-edma-common.c |  6 ++++++
 drivers/dma/fsl-edma-common.h |  1 +
 drivers/dma/fsl-edma-main.c   | 22 ++++++++++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c
index b18faa7cfedb9..f9144b0154396 100644
--- a/drivers/dma/fsl-edma-common.c
+++ b/drivers/dma/fsl-edma-common.c
@@ -3,6 +3,7 @@
 // Copyright (c) 2013-2014 Freescale Semiconductor, Inc
 // Copyright (c) 2017 Sysam, Angelo Dureghello  <angelo@sysam.it>
 
+#include <linux/clk.h>
 #include <linux/dmapool.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -810,6 +811,9 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
 {
 	struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
 
+	if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_HAS_CHCLK)
+		clk_prepare_enable(fsl_chan->clk);
+
 	fsl_chan->tcd_pool = dma_pool_create("tcd_pool", chan->device->dev,
 				fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_TCD64 ?
 				sizeof(struct fsl_edma_hw_tcd64) : sizeof(struct fsl_edma_hw_tcd),
@@ -838,6 +842,8 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan)
 	fsl_chan->tcd_pool = NULL;
 	fsl_chan->is_sw = false;
 	fsl_chan->srcid = 0;
+	if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_HAS_CHCLK)
+		clk_disable_unprepare(fsl_chan->clk);
 }
 
 void fsl_edma_cleanup_vchan(struct dma_device *dmadev)
diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h
index 532f647e540e7..01157912bfd5f 100644
--- a/drivers/dma/fsl-edma-common.h
+++ b/drivers/dma/fsl-edma-common.h
@@ -192,6 +192,7 @@ struct fsl_edma_desc {
 #define FSL_EDMA_DRV_WRAP_IO		BIT(3)
 #define FSL_EDMA_DRV_EDMA64		BIT(4)
 #define FSL_EDMA_DRV_HAS_PD		BIT(5)
+#define FSL_EDMA_DRV_HAS_CHCLK		BIT(6)
 #define FSL_EDMA_DRV_HAS_CHMUX		BIT(7)
 /* imx8 QM audio edma remote local swapped */
 #define FSL_EDMA_DRV_QUIRK_SWAPPED	BIT(8)
diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c
index 41c71c360ff1f..0837535aa7548 100644
--- a/drivers/dma/fsl-edma-main.c
+++ b/drivers/dma/fsl-edma-main.c
@@ -356,6 +356,16 @@ static struct fsl_edma_drvdata imx8qm_audio_data = {
 	.setup_irq = fsl_edma3_irq_init,
 };
 
+static struct fsl_edma_drvdata imx8ulp_data = {
+	.flags = FSL_EDMA_DRV_HAS_CHMUX | FSL_EDMA_DRV_HAS_CHCLK | FSL_EDMA_DRV_HAS_DMACLK |
+		 FSL_EDMA_DRV_EDMA3,
+	.chreg_space_sz = 0x10000,
+	.chreg_off = 0x10000,
+	.mux_off = 0x10000 + offsetof(struct fsl_edma3_ch_reg, ch_mux),
+	.mux_skip = 0x10000,
+	.setup_irq = fsl_edma3_irq_init,
+};
+
 static struct fsl_edma_drvdata imx93_data3 = {
 	.flags = FSL_EDMA_DRV_HAS_DMACLK | FSL_EDMA_DRV_EDMA3,
 	.chreg_space_sz = 0x10000,
@@ -388,6 +398,7 @@ static const struct of_device_id fsl_edma_dt_ids[] = {
 	{ .compatible = "fsl,imx7ulp-edma", .data = &imx7ulp_data},
 	{ .compatible = "fsl,imx8qm-edma", .data = &imx8qm_data},
 	{ .compatible = "fsl,imx8qm-adma", .data = &imx8qm_audio_data},
+	{ .compatible = "fsl,imx8ulp-edma", .data = &imx8ulp_data},
 	{ .compatible = "fsl,imx93-edma3", .data = &imx93_data3},
 	{ .compatible = "fsl,imx93-edma4", .data = &imx93_data4},
 	{ .compatible = "fsl,imx95-edma5", .data = &imx95_data5},
@@ -441,6 +452,7 @@ static int fsl_edma_probe(struct platform_device *pdev)
 	struct fsl_edma_engine *fsl_edma;
 	const struct fsl_edma_drvdata *drvdata = NULL;
 	u32 chan_mask[2] = {0, 0};
+	char clk_name[36];
 	struct edma_regs *regs;
 	int chans;
 	int ret, i;
@@ -550,11 +562,21 @@ static int fsl_edma_probe(struct platform_device *pdev)
 				+ i * drvdata->chreg_space_sz + drvdata->chreg_off + len;
 		fsl_chan->mux_addr = fsl_edma->membase + drvdata->mux_off + i * drvdata->mux_skip;
 
+		if (drvdata->flags & FSL_EDMA_DRV_HAS_CHCLK) {
+			snprintf(clk_name, sizeof(clk_name), "CH%02d-clk", i);
+			fsl_chan->clk = devm_clk_get_enabled(&pdev->dev,
+							     (const char *)clk_name);
+
+			if (IS_ERR(fsl_chan->clk))
+				return PTR_ERR(fsl_chan->clk);
+		}
 		fsl_chan->pdev = pdev;
 		vchan_init(&fsl_chan->vchan, &fsl_edma->dma_dev);
 
 		edma_write_tcdreg(fsl_chan, cpu_to_le32(0), csr);
 		fsl_edma_chan_mux(fsl_chan, 0, false);
+		if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_HAS_CHCLK)
+			clk_disable_unprepare(fsl_chan->clk);
 	}
 
 	ret = fsl_edma->drvdata->setup_irq(pdev, fsl_edma);

-- 
2.34.1


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

* Re: [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string
  2024-02-29 20:58 ` [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string Frank Li
@ 2024-03-04 16:44   ` Rob Herring
  2024-03-04 23:31     ` Frank Li
  0 siblings, 1 reply; 12+ messages in thread
From: Rob Herring @ 2024-03-04 16:44 UTC (permalink / raw)
  To: Frank Li
  Cc: Vinod Koul, Krzysztof Kozlowski, Conor Dooley, Peng Fan, imx,
	dmaengine, linux-kernel, devicetree, Joy Zou

On Thu, Feb 29, 2024 at 03:58:10PM -0500, Frank Li wrote:
> From: Joy Zou <joy.zou@nxp.com>
> 
> Introduce the compatible string 'fsl,imx8ulp-edma' to enable support for
> the i.MX8ULP's eDMA, alongside adjusting the clock numbering. The i.MX8ULP
> eDMA architecture features one clock for each DMA channel and an additional
> clock for the core controller. Given a maximum of 32 DMA channels, the
> maximum clock number consequently increases to 33.
> 
> Signed-off-by: Joy Zou <joy.zou@nxp.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>  .../devicetree/bindings/dma/fsl,edma.yaml          | 26 ++++++++++++++++++++--
>  1 file changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/dma/fsl,edma.yaml b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> index aa51d278cb67b..55cce79c759f8 100644
> --- a/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> +++ b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> @@ -23,6 +23,7 @@ properties:
>            - fsl,imx7ulp-edma
>            - fsl,imx8qm-adma
>            - fsl,imx8qm-edma
> +          - fsl,imx8ulp-edma
>            - fsl,imx93-edma3
>            - fsl,imx93-edma4
>            - fsl,imx95-edma5
> @@ -53,11 +54,11 @@ properties:
>  
>    clocks:
>      minItems: 1
> -    maxItems: 2
> +    maxItems: 33
>  
>    clock-names:
>      minItems: 1
> -    maxItems: 2
> +    maxItems: 33
>  
>    big-endian:
>      description: |
> @@ -108,6 +109,7 @@ allOf:
>        properties:
>          clocks:
>            minItems: 2
> +          maxItems: 2
>          clock-names:
>            items:
>              - const: dmamux0
> @@ -136,6 +138,7 @@ allOf:
>        properties:
>          clock:
>            minItems: 2
> +          maxItems: 2
>          clock-names:
>            items:
>              - const: dma
> @@ -151,6 +154,25 @@ allOf:
>          dma-channels:
>            const: 32
>  
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: fsl,imx8ulp-edma
> +    then:
> +      properties:
> +        clock:

clocks

> +          maxItems: 33

That is already the max. I think you want 'minItems: 33' here.

> +        clock-names:
> +          items:
> +            - const: dma
> +            - pattern: "^CH[0-31]-clk$"

'-clk' is redundant. [0-31] is not how you do a range of numbers with 
regex. 

This doesn't cover clocks 3-33. Not a great way to express in 
json-schema, but this should do it:

allOf:
  - items:
      - const: dma
  - items:
      oneOf:
        - const: dma
        - pattern: "^ch([0-9]|[1-2][0-9]|[3[01])$"

That doesn't enforce the order of 'chN' entries though. Probably good 
enough.


> +        interrupt-names: false
> +        interrupts:
> +          maxItems: 32

minItems

> +        "#dma-cells":
> +          const: 3

Is what is in each cell defined somewhere? If not, you need a 
description with those details.

Rob

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

* Re: [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string
  2024-03-04 16:44   ` Rob Herring
@ 2024-03-04 23:31     ` Frank Li
  2024-03-06 20:40       ` Rob Herring
  0 siblings, 1 reply; 12+ messages in thread
From: Frank Li @ 2024-03-04 23:31 UTC (permalink / raw)
  To: Rob Herring
  Cc: Vinod Koul, Krzysztof Kozlowski, Conor Dooley, Peng Fan, imx,
	dmaengine, linux-kernel, devicetree, Joy Zou

On Mon, Mar 04, 2024 at 10:44:23AM -0600, Rob Herring wrote:
> On Thu, Feb 29, 2024 at 03:58:10PM -0500, Frank Li wrote:
> > From: Joy Zou <joy.zou@nxp.com>
> > 
> > Introduce the compatible string 'fsl,imx8ulp-edma' to enable support for
> > the i.MX8ULP's eDMA, alongside adjusting the clock numbering. The i.MX8ULP
> > eDMA architecture features one clock for each DMA channel and an additional
> > clock for the core controller. Given a maximum of 32 DMA channels, the
> > maximum clock number consequently increases to 33.
> > 
> > Signed-off-by: Joy Zou <joy.zou@nxp.com>
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> >  .../devicetree/bindings/dma/fsl,edma.yaml          | 26 ++++++++++++++++++++--
> >  1 file changed, 24 insertions(+), 2 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/dma/fsl,edma.yaml b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > index aa51d278cb67b..55cce79c759f8 100644
> > --- a/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > +++ b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > @@ -23,6 +23,7 @@ properties:
> >            - fsl,imx7ulp-edma
> >            - fsl,imx8qm-adma
> >            - fsl,imx8qm-edma
> > +          - fsl,imx8ulp-edma
> >            - fsl,imx93-edma3
> >            - fsl,imx93-edma4
> >            - fsl,imx95-edma5
> > @@ -53,11 +54,11 @@ properties:
> >  
> >    clocks:
> >      minItems: 1
> > -    maxItems: 2
> > +    maxItems: 33
> >  
> >    clock-names:
> >      minItems: 1
> > -    maxItems: 2
> > +    maxItems: 33
> >  
> >    big-endian:
> >      description: |
> > @@ -108,6 +109,7 @@ allOf:
> >        properties:
> >          clocks:
> >            minItems: 2
> > +          maxItems: 2
> >          clock-names:
> >            items:
> >              - const: dmamux0
> > @@ -136,6 +138,7 @@ allOf:
> >        properties:
> >          clock:
> >            minItems: 2
> > +          maxItems: 2
> >          clock-names:
> >            items:
> >              - const: dma
> > @@ -151,6 +154,25 @@ allOf:
> >          dma-channels:
> >            const: 32
> >  
> > +  - if:
> > +      properties:
> > +        compatible:
> > +          contains:
> > +            const: fsl,imx8ulp-edma
> > +    then:
> > +      properties:
> > +        clock:
> 
> clocks
> 
> > +          maxItems: 33
> 
> That is already the max. I think you want 'minItems: 33' here.
> 
> > +        clock-names:
> > +          items:
> > +            - const: dma
> > +            - pattern: "^CH[0-31]-clk$"
> 
> '-clk' is redundant. [0-31] is not how you do a range of numbers with 
> regex. 
> 
> This doesn't cover clocks 3-33. Not a great way to express in 
> json-schema, but this should do it:
> 
> allOf:
>   - items:
>       - const: dma
>   - items:
>       oneOf:
>         - const: dma
>         - pattern: "^ch([0-9]|[1-2][0-9]|[3[01])$"

I understand pattern is wrong. But I don't understand why need 'allOf'.
8ulp need clock 'dma" and "ch*". I think 

items:
    - const: dma 
    - pattern: "^CH[0-31]-clk$"

should be enough.

If you means put on top allOf, other platform use clock name such as
'dmamux0'.

Frank

> 
> That doesn't enforce the order of 'chN' entries though. Probably good 
> enough.
> 
> 
> > +        interrupt-names: false
> > +        interrupts:
> > +          maxItems: 32
> 
> minItems
> 
> > +        "#dma-cells":
> > +          const: 3
> 
> Is what is in each cell defined somewhere? If not, you need a 
> description with those details.
> 
> Rob

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

* Re: [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string
  2024-03-04 23:31     ` Frank Li
@ 2024-03-06 20:40       ` Rob Herring
  2024-03-07 21:41         ` Frank Li
  2024-03-11  2:38         ` Frank Li
  0 siblings, 2 replies; 12+ messages in thread
From: Rob Herring @ 2024-03-06 20:40 UTC (permalink / raw)
  To: Frank Li
  Cc: Vinod Koul, Krzysztof Kozlowski, Conor Dooley, Peng Fan, imx,
	dmaengine, linux-kernel, devicetree, Joy Zou

On Mon, Mar 4, 2024 at 5:31 PM Frank Li <Frank.li@nxp.com> wrote:
>
> On Mon, Mar 04, 2024 at 10:44:23AM -0600, Rob Herring wrote:
> > On Thu, Feb 29, 2024 at 03:58:10PM -0500, Frank Li wrote:
> > > From: Joy Zou <joy.zou@nxp.com>
> > >
> > > Introduce the compatible string 'fsl,imx8ulp-edma' to enable support for
> > > the i.MX8ULP's eDMA, alongside adjusting the clock numbering. The i.MX8ULP
> > > eDMA architecture features one clock for each DMA channel and an additional
> > > clock for the core controller. Given a maximum of 32 DMA channels, the
> > > maximum clock number consequently increases to 33.
> > >
> > > Signed-off-by: Joy Zou <joy.zou@nxp.com>
> > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > ---
> > >  .../devicetree/bindings/dma/fsl,edma.yaml          | 26 ++++++++++++++++++++--
> > >  1 file changed, 24 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/Documentation/devicetree/bindings/dma/fsl,edma.yaml b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > index aa51d278cb67b..55cce79c759f8 100644
> > > --- a/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > +++ b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > @@ -23,6 +23,7 @@ properties:
> > >            - fsl,imx7ulp-edma
> > >            - fsl,imx8qm-adma
> > >            - fsl,imx8qm-edma
> > > +          - fsl,imx8ulp-edma
> > >            - fsl,imx93-edma3
> > >            - fsl,imx93-edma4
> > >            - fsl,imx95-edma5
> > > @@ -53,11 +54,11 @@ properties:
> > >
> > >    clocks:
> > >      minItems: 1
> > > -    maxItems: 2
> > > +    maxItems: 33
> > >
> > >    clock-names:
> > >      minItems: 1
> > > -    maxItems: 2
> > > +    maxItems: 33
> > >
> > >    big-endian:
> > >      description: |
> > > @@ -108,6 +109,7 @@ allOf:
> > >        properties:
> > >          clocks:
> > >            minItems: 2
> > > +          maxItems: 2
> > >          clock-names:
> > >            items:
> > >              - const: dmamux0
> > > @@ -136,6 +138,7 @@ allOf:
> > >        properties:
> > >          clock:
> > >            minItems: 2
> > > +          maxItems: 2
> > >          clock-names:
> > >            items:
> > >              - const: dma
> > > @@ -151,6 +154,25 @@ allOf:
> > >          dma-channels:
> > >            const: 32
> > >
> > > +  - if:
> > > +      properties:
> > > +        compatible:
> > > +          contains:
> > > +            const: fsl,imx8ulp-edma
> > > +    then:
> > > +      properties:
> > > +        clock:
> >
> > clocks
> >
> > > +          maxItems: 33
> >
> > That is already the max. I think you want 'minItems: 33' here.
> >
> > > +        clock-names:
> > > +          items:
> > > +            - const: dma
> > > +            - pattern: "^CH[0-31]-clk$"
> >
> > '-clk' is redundant. [0-31] is not how you do a range of numbers with
> > regex.
> >
> > This doesn't cover clocks 3-33. Not a great way to express in
> > json-schema, but this should do it:
> >
> > allOf:
> >   - items:
> >       - const: dma
> >   - items:
> >       oneOf:
> >         - const: dma
> >         - pattern: "^ch([0-9]|[1-2][0-9]|[3[01])$"
>
> I understand pattern is wrong. But I don't understand why need 'allOf'.

The first 'items' says the 1st entry must be 'dma'. (It might need a
'maxItems: 33' too now that I look at it.) The 2nd 'items' says all
entries must be either 'dma' or the CHn pattern.

> 8ulp need clock 'dma" and "ch*". I think
>
> items:
>     - const: dma
>     - pattern: "^CH[0-31]-clk$"
>
> should be enough.

If it was, then I would not have said anything. If you don't believe
me see if this passes validation:

clock-names = "dma", "CH0", "foobar";

> If you means put on top allOf, other platform use clock name such as
> 'dmamux0'.

What? It's under an if/then schema.

Rob

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

* Re: [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string
  2024-03-06 20:40       ` Rob Herring
@ 2024-03-07 21:41         ` Frank Li
  2024-03-11  2:38         ` Frank Li
  1 sibling, 0 replies; 12+ messages in thread
From: Frank Li @ 2024-03-07 21:41 UTC (permalink / raw)
  To: Rob Herring
  Cc: Vinod Koul, Krzysztof Kozlowski, Conor Dooley, Peng Fan, imx,
	dmaengine, linux-kernel, devicetree, Joy Zou

On Wed, Mar 06, 2024 at 02:40:23PM -0600, Rob Herring wrote:
> On Mon, Mar 4, 2024 at 5:31 PM Frank Li <Frank.li@nxp.com> wrote:
> >
> > On Mon, Mar 04, 2024 at 10:44:23AM -0600, Rob Herring wrote:
> > > On Thu, Feb 29, 2024 at 03:58:10PM -0500, Frank Li wrote:
> > > > From: Joy Zou <joy.zou@nxp.com>
> > > >
> > > > Introduce the compatible string 'fsl,imx8ulp-edma' to enable support for
> > > > the i.MX8ULP's eDMA, alongside adjusting the clock numbering. The i.MX8ULP
> > > > eDMA architecture features one clock for each DMA channel and an additional
> > > > clock for the core controller. Given a maximum of 32 DMA channels, the
> > > > maximum clock number consequently increases to 33.
> > > >
> > > > Signed-off-by: Joy Zou <joy.zou@nxp.com>
> > > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > > ---
> > > >  .../devicetree/bindings/dma/fsl,edma.yaml          | 26 ++++++++++++++++++++--
> > > >  1 file changed, 24 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/dma/fsl,edma.yaml b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > > index aa51d278cb67b..55cce79c759f8 100644
> > > > --- a/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > > +++ b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > > @@ -23,6 +23,7 @@ properties:
> > > >            - fsl,imx7ulp-edma
> > > >            - fsl,imx8qm-adma
> > > >            - fsl,imx8qm-edma
> > > > +          - fsl,imx8ulp-edma
> > > >            - fsl,imx93-edma3
> > > >            - fsl,imx93-edma4
> > > >            - fsl,imx95-edma5
> > > > @@ -53,11 +54,11 @@ properties:
> > > >
> > > >    clocks:
> > > >      minItems: 1
> > > > -    maxItems: 2
> > > > +    maxItems: 33
> > > >
> > > >    clock-names:
> > > >      minItems: 1
> > > > -    maxItems: 2
> > > > +    maxItems: 33
> > > >
> > > >    big-endian:
> > > >      description: |
> > > > @@ -108,6 +109,7 @@ allOf:
> > > >        properties:
> > > >          clocks:
> > > >            minItems: 2
> > > > +          maxItems: 2
> > > >          clock-names:
> > > >            items:
> > > >              - const: dmamux0
> > > > @@ -136,6 +138,7 @@ allOf:
> > > >        properties:
> > > >          clock:
> > > >            minItems: 2
> > > > +          maxItems: 2
> > > >          clock-names:
> > > >            items:
> > > >              - const: dma
> > > > @@ -151,6 +154,25 @@ allOf:
> > > >          dma-channels:
> > > >            const: 32
> > > >
> > > > +  - if:
> > > > +      properties:
> > > > +        compatible:
> > > > +          contains:
> > > > +            const: fsl,imx8ulp-edma
> > > > +    then:
> > > > +      properties:
> > > > +        clock:
> > >
> > > clocks
> > >
> > > > +          maxItems: 33
> > >
> > > That is already the max. I think you want 'minItems: 33' here.
> > >
> > > > +        clock-names:
> > > > +          items:
> > > > +            - const: dma
> > > > +            - pattern: "^CH[0-31]-clk$"
> > >
> > > '-clk' is redundant. [0-31] is not how you do a range of numbers with
> > > regex.
> > >
> > > This doesn't cover clocks 3-33. Not a great way to express in
> > > json-schema, but this should do it:
> > >
> > > allOf:
> > >   - items:
> > >       - const: dma
> > >   - items:
> > >       oneOf:
> > >         - const: dma
> > >         - pattern: "^ch([0-9]|[1-2][0-9]|[3[01])$"
> >
> > I understand pattern is wrong. But I don't understand why need 'allOf'.
> 
> The first 'items' says the 1st entry must be 'dma'. (It might need a
> 'maxItems: 33' too now that I look at it.) The 2nd 'items' says all
> entries must be either 'dma' or the CHn pattern.
> 
> > 8ulp need clock 'dma" and "ch*". I think
> >
> > items:
> >     - const: dma
> >     - pattern: "^CH[0-31]-clk$"
> >
> > should be enough.
> 
> If it was, then I would not have said anything. If you don't believe
> me see if this passes validation:
> 
> clock-names = "dma", "CH0", "foobar";

        clock-names:                                                       
          minItems: 33                                                     
          items:                                                           
            oneOf:                                                         
              - const: dma                                                 
              - pattern: "^ch(0[0-9]|[1-2][0-9]|3[01])$"   

Above code can pass check and detect error of "foobar", it should miss
restriction about first item must be 'dma'.


Your previous allOf block, 
 allOf:                                                               
   - items:                                                           
       - const: dma                                                   
   - items:                                                           
       oneOf:                                                         
         - const: dma                                                 
         - pattern: "^ch([0-9]|[1-2][0-9]|[3[01])$" 

It reported clock-names too long.

Frank


> 
> > If you means put on top allOf, other platform use clock name such as
> > 'dmamux0'.
> 
> What? It's under an if/then schema.
> 
> Rob

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

* Re: [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string
  2024-03-06 20:40       ` Rob Herring
  2024-03-07 21:41         ` Frank Li
@ 2024-03-11  2:38         ` Frank Li
  2024-03-19 20:12           ` Frank Li
  1 sibling, 1 reply; 12+ messages in thread
From: Frank Li @ 2024-03-11  2:38 UTC (permalink / raw)
  To: Rob Herring
  Cc: Vinod Koul, Krzysztof Kozlowski, Conor Dooley, Peng Fan, imx,
	dmaengine, linux-kernel, devicetree, Joy Zou

On Wed, Mar 06, 2024 at 02:40:23PM -0600, Rob Herring wrote:
> On Mon, Mar 4, 2024 at 5:31 PM Frank Li <Frank.li@nxp.com> wrote:
> >
> > On Mon, Mar 04, 2024 at 10:44:23AM -0600, Rob Herring wrote:
> > > On Thu, Feb 29, 2024 at 03:58:10PM -0500, Frank Li wrote:
> > > > From: Joy Zou <joy.zou@nxp.com>
> > > >
> > > > Introduce the compatible string 'fsl,imx8ulp-edma' to enable support for
> > > > the i.MX8ULP's eDMA, alongside adjusting the clock numbering. The i.MX8ULP
> > > > eDMA architecture features one clock for each DMA channel and an additional
> > > > clock for the core controller. Given a maximum of 32 DMA channels, the
> > > > maximum clock number consequently increases to 33.
> > > >
> > > > Signed-off-by: Joy Zou <joy.zou@nxp.com>
> > > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > > ---
> > > >  .../devicetree/bindings/dma/fsl,edma.yaml          | 26 ++++++++++++++++++++--
> > > >  1 file changed, 24 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/dma/fsl,edma.yaml b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > > index aa51d278cb67b..55cce79c759f8 100644
> > > > --- a/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > > +++ b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > > @@ -23,6 +23,7 @@ properties:
> > > >            - fsl,imx7ulp-edma
> > > >            - fsl,imx8qm-adma
> > > >            - fsl,imx8qm-edma
> > > > +          - fsl,imx8ulp-edma
> > > >            - fsl,imx93-edma3
> > > >            - fsl,imx93-edma4
> > > >            - fsl,imx95-edma5
> > > > @@ -53,11 +54,11 @@ properties:
> > > >
> > > >    clocks:
> > > >      minItems: 1
> > > > -    maxItems: 2
> > > > +    maxItems: 33
> > > >
> > > >    clock-names:
> > > >      minItems: 1
> > > > -    maxItems: 2
> > > > +    maxItems: 33
> > > >
> > > >    big-endian:
> > > >      description: |
> > > > @@ -108,6 +109,7 @@ allOf:
> > > >        properties:
> > > >          clocks:
> > > >            minItems: 2
> > > > +          maxItems: 2
> > > >          clock-names:
> > > >            items:
> > > >              - const: dmamux0
> > > > @@ -136,6 +138,7 @@ allOf:
> > > >        properties:
> > > >          clock:
> > > >            minItems: 2
> > > > +          maxItems: 2
> > > >          clock-names:
> > > >            items:
> > > >              - const: dma
> > > > @@ -151,6 +154,25 @@ allOf:
> > > >          dma-channels:
> > > >            const: 32
> > > >
> > > > +  - if:
> > > > +      properties:
> > > > +        compatible:
> > > > +          contains:
> > > > +            const: fsl,imx8ulp-edma
> > > > +    then:
> > > > +      properties:
> > > > +        clock:
> > >
> > > clocks
> > >
> > > > +          maxItems: 33
> > >
> > > That is already the max. I think you want 'minItems: 33' here.
> > >
> > > > +        clock-names:
> > > > +          items:
> > > > +            - const: dma
> > > > +            - pattern: "^CH[0-31]-clk$"
> > >
> > > '-clk' is redundant. [0-31] is not how you do a range of numbers with
> > > regex.
> > >
> > > This doesn't cover clocks 3-33. Not a great way to express in
> > > json-schema, but this should do it:
> > >
> > > allOf:
> > >   - items:
> > >       - const: dma
> > >   - items:
> > >       oneOf:
> > >         - const: dma
> > >         - pattern: "^ch([0-9]|[1-2][0-9]|[3[01])$"
> >
> > I understand pattern is wrong. But I don't understand why need 'allOf'.
> 
> The first 'items' says the 1st entry must be 'dma'. (It might need a
> 'maxItems: 33' too now that I look at it.) The 2nd 'items' says all
> entries must be either 'dma' or the CHn pattern.

After dig into dt_scheme and json scheme, I start understand what your
means.

"clock-names": {                                   
    "minItems": 33,                                
    "allOf": [                                     
         {                                          
            "items": [                             
                 {                                  
                     "const": "dma"                 
                 }                                  
            ],                                     
            "maxItems": 33, 
            ^^^^^^^^
      Here need a maxItem 33 and make sure first item is "dma" and total
array is 33.                       

            "type": "array",                       
            "minItems": 1                          
         },                                         
         {                                          
            "items": {                             
            "oneOf": [                         
                 {                              
                      "const": "dma"             
                 },                             
                 {                              
                       "pattern": "^ch(0[0-9]|[1-2][0-9]|3[01])$"
                 }                              
                 ]                                  
            },                                     
            "type": "array"                        
         }                                          
    ]                                              
}

The yaml source is

          allOf:                                                           
            - items:                                                       
                - const: dma                                               
              maxItems: 33                                                 
            - items:                                                       
                oneOf:                                                     
                  - const: dma                                             
                  - pattern: "^ch(0[0-9]|[1-2][0-9]|3[01])$"


But unfortunately, 

dtschema/meta-schemas/items.yaml

    type: object                                                         
      properties:                                                          
        items:                                                             
          type: array                                                      
        additionalItems: false                                             
      required:                                                            
        - items                                                            
        - maxItems                                                         
    then:                                                                  
      description: '"maxItems" is not needed with an "items" list'         
      not:                                                                 
        required:                                                          
          - maxItem


dt_binding check will complain
	'"maxItems" is not needed with an "items" list'


I am not sure how to go futher. Maybe below 'stupid' method is less impact.

items
  - const: dma
  - const: ch00
  ...
  - const: ch31
	  

Frank

> 
> > 8ulp need clock 'dma" and "ch*". I think
> >
> > items:
> >     - const: dma
> >     - pattern: "^CH[0-31]-clk$"
> >
> > should be enough.
> 
> If it was, then I would not have said anything. If you don't believe
> me see if this passes validation:
> 
> clock-names = "dma", "CH0", "foobar";
> 
> > If you means put on top allOf, other platform use clock name such as
> > 'dmamux0'.
> 
> What? It's under an if/then schema.
> 
> Rob

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

* Re: [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string
  2024-03-11  2:38         ` Frank Li
@ 2024-03-19 20:12           ` Frank Li
  0 siblings, 0 replies; 12+ messages in thread
From: Frank Li @ 2024-03-19 20:12 UTC (permalink / raw)
  To: Rob Herring
  Cc: Vinod Koul, Krzysztof Kozlowski, Conor Dooley, Peng Fan, imx,
	dmaengine, linux-kernel, devicetree, Joy Zou

On Sun, Mar 10, 2024 at 10:38:42PM -0400, Frank Li wrote:
> On Wed, Mar 06, 2024 at 02:40:23PM -0600, Rob Herring wrote:
> > On Mon, Mar 4, 2024 at 5:31 PM Frank Li <Frank.li@nxp.com> wrote:
> > >
> > > On Mon, Mar 04, 2024 at 10:44:23AM -0600, Rob Herring wrote:
> > > > On Thu, Feb 29, 2024 at 03:58:10PM -0500, Frank Li wrote:
> > > > > From: Joy Zou <joy.zou@nxp.com>
> > > > >
> > > > > Introduce the compatible string 'fsl,imx8ulp-edma' to enable support for
> > > > > the i.MX8ULP's eDMA, alongside adjusting the clock numbering. The i.MX8ULP
> > > > > eDMA architecture features one clock for each DMA channel and an additional
> > > > > clock for the core controller. Given a maximum of 32 DMA channels, the
> > > > > maximum clock number consequently increases to 33.
> > > > >
> > > > > Signed-off-by: Joy Zou <joy.zou@nxp.com>
> > > > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > > > ---
> > > > >  .../devicetree/bindings/dma/fsl,edma.yaml          | 26 ++++++++++++++++++++--
> > > > >  1 file changed, 24 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/Documentation/devicetree/bindings/dma/fsl,edma.yaml b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > > > index aa51d278cb67b..55cce79c759f8 100644
> > > > > --- a/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > > > +++ b/Documentation/devicetree/bindings/dma/fsl,edma.yaml
> > > > > @@ -23,6 +23,7 @@ properties:
> > > > >            - fsl,imx7ulp-edma
> > > > >            - fsl,imx8qm-adma
> > > > >            - fsl,imx8qm-edma
> > > > > +          - fsl,imx8ulp-edma
> > > > >            - fsl,imx93-edma3
> > > > >            - fsl,imx93-edma4
> > > > >            - fsl,imx95-edma5
> > > > > @@ -53,11 +54,11 @@ properties:
> > > > >
> > > > >    clocks:
> > > > >      minItems: 1
> > > > > -    maxItems: 2
> > > > > +    maxItems: 33
> > > > >
> > > > >    clock-names:
> > > > >      minItems: 1
> > > > > -    maxItems: 2
> > > > > +    maxItems: 33
> > > > >
> > > > >    big-endian:
> > > > >      description: |
> > > > > @@ -108,6 +109,7 @@ allOf:
> > > > >        properties:
> > > > >          clocks:
> > > > >            minItems: 2
> > > > > +          maxItems: 2
> > > > >          clock-names:
> > > > >            items:
> > > > >              - const: dmamux0
> > > > > @@ -136,6 +138,7 @@ allOf:
> > > > >        properties:
> > > > >          clock:
> > > > >            minItems: 2
> > > > > +          maxItems: 2
> > > > >          clock-names:
> > > > >            items:
> > > > >              - const: dma
> > > > > @@ -151,6 +154,25 @@ allOf:
> > > > >          dma-channels:
> > > > >            const: 32
> > > > >
> > > > > +  - if:
> > > > > +      properties:
> > > > > +        compatible:
> > > > > +          contains:
> > > > > +            const: fsl,imx8ulp-edma
> > > > > +    then:
> > > > > +      properties:
> > > > > +        clock:
> > > >
> > > > clocks
> > > >
> > > > > +          maxItems: 33
> > > >
> > > > That is already the max. I think you want 'minItems: 33' here.
> > > >
> > > > > +        clock-names:
> > > > > +          items:
> > > > > +            - const: dma
> > > > > +            - pattern: "^CH[0-31]-clk$"
> > > >
> > > > '-clk' is redundant. [0-31] is not how you do a range of numbers with
> > > > regex.
> > > >
> > > > This doesn't cover clocks 3-33. Not a great way to express in
> > > > json-schema, but this should do it:
> > > >
> > > > allOf:
> > > >   - items:
> > > >       - const: dma
> > > >   - items:
> > > >       oneOf:
> > > >         - const: dma
> > > >         - pattern: "^ch([0-9]|[1-2][0-9]|[3[01])$"
> > >
> > > I understand pattern is wrong. But I don't understand why need 'allOf'.
> > 
> > The first 'items' says the 1st entry must be 'dma'. (It might need a
> > 'maxItems: 33' too now that I look at it.) The 2nd 'items' says all
> > entries must be either 'dma' or the CHn pattern.
> 
> After dig into dt_scheme and json scheme, I start understand what your
> means.
> 
> "clock-names": {                                   
>     "minItems": 33,                                
>     "allOf": [                                     
>          {                                          
>             "items": [                             
>                  {                                  
>                      "const": "dma"                 
>                  }                                  
>             ],                                     
>             "maxItems": 33, 
>             ^^^^^^^^
>       Here need a maxItem 33 and make sure first item is "dma" and total
> array is 33.                       
> 
>             "type": "array",                       
>             "minItems": 1                          
>          },                                         
>          {                                          
>             "items": {                             
>             "oneOf": [                         
>                  {                              
>                       "const": "dma"             
>                  },                             
>                  {                              
>                        "pattern": "^ch(0[0-9]|[1-2][0-9]|3[01])$"
>                  }                              
>                  ]                                  
>             },                                     
>             "type": "array"                        
>          }                                          
>     ]                                              
> }
> 
> The yaml source is
> 
>           allOf:                                                           
>             - items:                                                       
>                 - const: dma                                               
>               maxItems: 33                                                 
>             - items:                                                       
>                 oneOf:                                                     
>                   - const: dma                                             
>                   - pattern: "^ch(0[0-9]|[1-2][0-9]|3[01])$"
> 
> 
> But unfortunately, 
> 
> dtschema/meta-schemas/items.yaml
> 
>     type: object                                                         
>       properties:                                                          
>         items:                                                             
>           type: array                                                      
>         additionalItems: false                                             
>       required:                                                            
>         - items                                                            
>         - maxItems                                                         
>     then:                                                                  
>       description: '"maxItems" is not needed with an "items" list'         
>       not:                                                                 
>         required:                                                          
>           - maxItem
> 
> 
> dt_binding check will complain
> 	'"maxItems" is not needed with an "items" list'
> 
> 
> I am not sure how to go futher. Maybe below 'stupid' method is less impact.
> 
> items
>   - const: dma
>   - const: ch00
>   ...
>   - const: ch31
> 	  
> 
> Frank

@rob:

       I can't found out a way to to handle this case. 
dtschema/meta-schemas/items.yaml not allow 'maxItems' for 'items'.

       Any suggestion?

Frank

> 
> > 
> > > 8ulp need clock 'dma" and "ch*". I think
> > >
> > > items:
> > >     - const: dma
> > >     - pattern: "^CH[0-31]-clk$"
> > >
> > > should be enough.
> > 
> > If it was, then I would not have said anything. If you don't believe
> > me see if this passes validation:
> > 
> > clock-names = "dma", "CH0", "foobar";
> > 
> > > If you means put on top allOf, other platform use clock name such as
> > > 'dmamux0'.
> > 
> > What? It's under an if/then schema.
> > 
> > Rob

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

end of thread, other threads:[~2024-03-19 20:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29 20:58 [PATCH v2 0/5] dmaengine: fsl-edma: add 8ulp support Frank Li
2024-02-29 20:58 ` [PATCH v2 1/5] dmaengine: fsl-edma: remove 'slave_id' from fsl_edma_chan Frank Li
2024-02-29 20:58 ` [PATCH v2 2/5] dmaengine: fsl-edma: add safety check for 'srcid' Frank Li
2024-02-29 20:58 ` [PATCH v2 3/5] dmaengine: fsl-edma: clean up chclk and FSL_EDMA_DRV_HAS_CHCLK Frank Li
2024-02-29 20:58 ` [PATCH v2 4/5] dt-bindings: dma: fsl-edma: add fsl,imx8ulp-edma compatible string Frank Li
2024-03-04 16:44   ` Rob Herring
2024-03-04 23:31     ` Frank Li
2024-03-06 20:40       ` Rob Herring
2024-03-07 21:41         ` Frank Li
2024-03-11  2:38         ` Frank Li
2024-03-19 20:12           ` Frank Li
2024-02-29 20:58 ` [PATCH v2 5/5] dmaengine: fsl-edma: add i.MX8ULP edma support 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).