Skip to contentSkip to conversation

dmaengine: imx-sdma: Add DMA event remapping for imx6sx-sdma

PATCH In review Nicolin Chen 2 participants 4 messages Apr 15, 2015 – Apr 27, 2015

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

PATCH 1/1 dmaengine: imx-sdma: Add DMA event remapping for imx6sx-sdma

The SDMA on imx6sx has a few DMA event remapping configurations inside the GPR (General Purpose Register) of that SoC. When users want to use a non-default DMA event, they need to configure the GPR register. So this patch gives an interface of the GPR and implements it in the SDMA driver so as to finish the DMA event remapping.

---
 .../devicetree/bindings/dma/fsl-imx-sdma.txt       |  9 ++++
 drivers/dma/imx-sdma.c                             | 58 ++++++++++++++++++++++
 2 files changed, 67 insertions(+)
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +9 -0
index dc8d3aa..03315a6 100644
@@ -8,6 +8,7 @@ Required properties:
       "fsl,imx51-sdma"
       "fsl,imx53-sdma"
       "fsl,imx6q-sdma"
+      "fsl,imx6sx-sdma"
   The -to variants should be preferred since they allow to determine the
   correct ROM script addresses needed for the driver to work without additional
   firmware.
@@ -19,6 +20,14 @@ Required properties:
 - fsl,sdma-ram-script-name : Should contain the full path of SDMA RAM
   scripts firmware
 
+Optional properties:
+- fsl, sdma-event-remap : List of one or more DMA event remapping
+  configurations. Its format: <&gpr addr shift val>
+	gpr : the gpr phandle
+	addr : the register address of the GPR
+	shift : the bit shift of the GPR register
+	val : the value of that bit
+
 The second cell of dma phandle specifies the peripheral type of DMA transfer.
 The full ID of peripheral types can be found below.
 
drivers/dma/imx-sdma.c +58 -0

94 lines not on this page · raw message

Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#1 lore raw
Quoted 26 lines · Nicolin Chen

The SDMA on imx6sx has a few DMA event remapping configurations inside the GPR (General Purpose Register) of that SoC. When users want to use a non-default DMA event, they need to configure the GPR register. So this patch gives an interface of the GPR and implements it in the SDMA driver so as to finish the DMA event remapping.

---
 .../devicetree/bindings/dma/fsl-imx-sdma.txt       |  9 ++++
 drivers/dma/imx-sdma.c                             | 58 ++++++++++++++++++++++
 2 files changed, 67 insertions(+)
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +1 -0
index dc8d3aa..03315a6 100644
@@ -8,6 +8,7 @@ Required properties:
       "fsl,imx51-sdma"
       "fsl,imx53-sdma"
       "fsl,imx6q-sdma"
+      "fsl,imx6sx-sdma"
   The -to variants should be preferred since they allow to determine the
   correct ROM script addresses needed for the driver to work without additional
   firmware.

Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt Required properties: · line 29

Quoted 10 lines
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +7 -0
@@ -19,6 +20,14 @@ Required properties:
 - fsl,sdma-ram-script-name : Should contain the full path of SDMA RAM
   scripts firmware
 
+Optional properties:
+- fsl, sdma-event-remap : List of one or more DMA event remapping
+  configurations. Its format: <&gpr addr shift val>
+	gpr : the gpr phandle
+	addr : the register address of the GPR
+	shift : the bit shift of the GPR register
+	val : the value of that bit

This binding allows arbitrary register writes to the GPR register space. I don't think we want to allow that. A binding for this if necessary at all must be higher level.

Quoted 5 lines
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +5 -0
+static int sdma_event_remap(struct sdma_engine *sdma)
+{
+	struct device_node *np = sdma->dev->of_node;
+	char propname[] = "fsl,sdma-event-remap";
+	struct of_phandle_args gpr_spec;

Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt Required properties:

Quoted 10 lines
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +10 -0
+	struct regmap *gpr;
+	int i = 0, ret = 0;
+
+	/* Only support DT */
+	if (IS_ERR(np))
+		return ret;
+
+	/* Only apply to imx6sx platform */
+	if (!of_device_is_compatible(np, "fsl,imx6sx-sdma"))
+		return ret;

We already have struct sdma_driver_data. Please add a have_remap field or similar there.

Quoted 19 lines
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +19 -0
+
+	/* Bypass if no need to remap */
+	if (!of_find_property(np, propname, NULL))
+		return ret;
+
+	/* Fetch the remap configurations of GPR */
+	ret = of_parse_phandle_with_args(np, propname, "#gpr-cells", i++,
+					 &gpr_spec);
+	if (ret) {
+		dev_err(sdma->dev, "failed to get a correct %s property: %d\n",
+				propname, ret);
+		return ret;
+	}
+
+next:
+	gpr = syscon_node_to_regmap(gpr_spec.np);
+	if (IS_ERR(gpr)) {
+		ret = PTR_ERR(gpr);
+		dev_err(sdma->dev, "failed to get gpr regmap: %d\n", reg);

Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt

Quoted 10 lines
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +10 -0
+		return ret;
+	}
+
+	/* 0 : Register address, 1 : Bit shift, 2 : Bit value */
+	regmap_update_bits(gpr, gpr_spec.args[0], BIT(gpr_spec.args[1]),
+			   gpr_spec.args[2] << gpr_spec.args[1]);
+
+	if (!of_parse_phandle_with_args(np, propname, "#gpr-cells", i++,
+					&gpr_spec))
+		goto next;

C has native support for loops. Please use it.

Sascha

Signature · 8 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Hi Sascha,

Thank you for the comments.

Quoted 26 lines · Sascha Hauer
Quoted 25 lines · Nicolin Chen

The SDMA on imx6sx has a few DMA event remapping configurations inside the GPR (General Purpose Register) of that SoC. When users want to use a non-default DMA event, they need to configure the GPR register. So this patch gives an interface of the GPR and implements it in the SDMA driver so as to finish the DMA event remapping.

Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +1 -0
index dc8d3aa..03315a6 100644
@@ -8,6 +8,7 @@ Required properties:
       "fsl,imx51-sdma"
       "fsl,imx53-sdma"
       "fsl,imx6q-sdma"
+      "fsl,imx6sx-sdma"
   The -to variants should be preferred since they allow to determine the
   correct ROM script addresses needed for the driver to work without additional
   firmware.
@@ -19,6 +20,14 @@ Required properties:
 - fsl,sdma-ram-script-name : Should contain the full path of SDMA RAM
   scripts firmware
 
Quoted 11 lines

Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt Required properties: · line 29

Quoted 7 lines
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +7 -0
+Optional properties:
+- fsl, sdma-event-remap : List of one or more DMA event remapping
+  configurations. Its format: <&gpr addr shift val>
+	gpr : the gpr phandle
+	addr : the register address of the GPR
+	shift : the bit shift of the GPR register
+	val : the value of that bit

This binding allows arbitrary register writes to the GPR register space. I don't think we want to allow that. A binding for this if necessary at all must be higher level.

I was actually wondering where could be the best place to put this in. But I couldn't figure out a better place than this driver while being worried about the violation as you mentioned.

But what could be that higher level?

Thank you
Nicolin

maintainer
#3 lore raw
Quoted 43 lines · Nicolin Chen

Hi Sascha,

Thank you for the comments.

Quoted 26 lines · Sascha Hauer
Quoted 25 lines · Nicolin Chen

The SDMA on imx6sx has a few DMA event remapping configurations inside the GPR (General Purpose Register) of that SoC. When users want to use a non-default DMA event, they need to configure the GPR register. So this patch gives an interface of the GPR and implements it in the SDMA driver so as to finish the DMA event remapping.

Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +1 -0
index dc8d3aa..03315a6 100644
@@ -8,6 +8,7 @@ Required properties:
       "fsl,imx51-sdma"
       "fsl,imx53-sdma"
       "fsl,imx6q-sdma"
+      "fsl,imx6sx-sdma"
   The -to variants should be preferred since they allow to determine the
   correct ROM script addresses needed for the driver to work without additional
   firmware.
@@ -19,6 +20,14 @@ Required properties:
 - fsl,sdma-ram-script-name : Should contain the full path of SDMA RAM
   scripts firmware
 
Quoted 11 lines

Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt Required properties: · line 29

Quoted 7 lines
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +7 -0
+Optional properties:
+- fsl, sdma-event-remap : List of one or more DMA event remapping
+  configurations. Its format: <&gpr addr shift val>
+	gpr : the gpr phandle
+	addr : the register address of the GPR
+	shift : the bit shift of the GPR register
+	val : the value of that bit

This binding allows arbitrary register writes to the GPR register space. I don't think we want to allow that. A binding for this if necessary at all must be higher level.

Quoted 5 lines

I was actually wondering where could be the best place to put this in. But I couldn't figure out a better place than this driver while being worried about the violation as you mentioned.

But what could be that higher level?

This gpr register effectivly increases the number of event IDs available by muxing them with existing event IDs. Looking at the SDMA event mapping table we have:

0 UART6 UART6 Rx FIFO; controlled by IOMUXC register GPR0[0]
1 ADC1 / I2C4 ADC1 DMA request ;Muxed I2C4 DMA event by IOMUXC register GPR0[1]
ADC1 DMA request
2 IOMUX / CSI2 Muxed with external DMA pad #1, controlled by IOMUXC
register GPR0[20].
...
47 UART6 UART6 Tx FIFO; controlled by IOMUXC register GPR0[19]

So I would extend that list by additional entries for the muxed dma events. event 48 then means event 0 alternative, with GPR0[0] set to 1.

BTW. Using defines for the SDMA events like done nowadays for clocks and other stuff would improve readability, especially when the list of dma events gets extended by non obvious numbers which do not directly map to hardware numbers.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |