devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] dmaengine: ti-dma-crossbar: Support for eDMA
@ 2015-06-05 15:34 Peter Ujfalusi
  2015-06-05 15:34 ` [PATCH 1/3] dmaengine: ti-dma-crossbar: Change the compatible string to ti,dra7-sdma-crossbar Peter Ujfalusi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2015-06-05 15:34 UTC (permalink / raw)
  To: vinod.koul, Tony Lindgren, robh+dt, pawel.moll, mark.rutland
  Cc: devicetree, linux-kernel, dmaengine, linux-omap, misael.lopez

Hi,

The ti-dma-crossbar driver in it's current form can work when it is used with
sDMA (omap-dma). On DRA7x class of devices we have both sDMA and eDMA available.
The DT bindings for sDMA has been done in a way that DMA users need to specify
the required DMA request number + 1 when they request for channel and the driver
stack has been written in this way also for sDMA.
Since right now we do not have the crossbar enabled we can still change the
compatible string to reflect the crossbar use. The TRM also refers the crossbars
in this way.

Regards,
Peter
---
Misael Lopez Cruz (2):
  dmaengine: ti-dma-crossbar: Make idr xbar instance-specific
  dmaengine: ti-dma-crossbar: Add support for eDMA xbar

Peter Ujfalusi (1):
  dmaengine: ti-dma-crossbar: Change the compatible string to
    ti,dra7-sdma-crossbar

 Documentation/devicetree/bindings/dma/dma.txt      |  2 +-
 .../devicetree/bindings/dma/ti-dma-crossbar.txt    |  5 +--
 drivers/dma/ti-dma-crossbar.c                      | 37 ++++++++++++++++------
 3 files changed, 31 insertions(+), 13 deletions(-)

-- 
2.4.2

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

* [PATCH 1/3] dmaengine: ti-dma-crossbar: Change the compatible string to ti,dra7-sdma-crossbar
  2015-06-05 15:34 [PATCH 0/3] dmaengine: ti-dma-crossbar: Support for eDMA Peter Ujfalusi
@ 2015-06-05 15:34 ` Peter Ujfalusi
  2015-06-05 15:34 ` [PATCH 2/3] dmaengine: ti-dma-crossbar: Make idr xbar instance-specific Peter Ujfalusi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2015-06-05 15:34 UTC (permalink / raw)
  To: vinod.koul, Tony Lindgren, robh+dt, pawel.moll, mark.rutland
  Cc: devicetree, linux-kernel, dmaengine, linux-omap, misael.lopez

Currently the driver can be used with sDMA only due to the fact that the
sDMA bindings are using "real DMA_REQ + 1" indexing of the DMA requests.
This is not a case with the eDMA for example so the driver in current form
can not handle the case when it is used with eDMA.
Be precise with the compatible.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 Documentation/devicetree/bindings/dma/dma.txt             | 2 +-
 Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt | 4 ++--
 drivers/dma/ti-dma-crossbar.c                             | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/dma.txt b/Documentation/devicetree/bindings/dma/dma.txt
index 6312fb00ce8d..2ba51ca37cda 100644
--- a/Documentation/devicetree/bindings/dma/dma.txt
+++ b/Documentation/devicetree/bindings/dma/dma.txt
@@ -52,7 +52,7 @@ Optional properties:
 
 Example:
 	sdma_xbar: dma-router@4a002b78 {
-		compatible = "ti,dra7-dma-crossbar";
+		compatible = "ti,dra7-sdma-crossbar";
 		reg = <0x4a002b78 0xfc>;
 		#dma-cells = <1>;
 		dma-requests = <205>;
diff --git a/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt b/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt
index 63a48928f3a8..76a10d0724b7 100644
--- a/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt
+++ b/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt
@@ -1,7 +1,7 @@
 Texas Instruments DMA Crossbar (DMA request router)
 
 Required properties:
-- compatible:	"ti,dra7-dma-crossbar" for DRA7xx DMA crossbar
+- compatible:	"ti,dra7-sdma-crossbar" for DRA7xx sDMA crossbar
 - reg:		Memory map for accessing module
 - #dma-cells:	Should be set to <1>.
 		Clients should use the crossbar request number (input)
@@ -31,7 +31,7 @@ sdma: dma-controller@4a056000 {
 
 /* DMA crossbar */
 sdma_xbar: dma-router@4a002b78 {
-	compatible = "ti,dra7-dma-crossbar";
+	compatible = "ti,dra7-sdma-crossbar";
 	reg = <0x4a002b78 0xfc>;
 	#dma-cells = <1>;
 	dma-requests = <205>;
diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
index 24f5ca2356bf..73ecd0a1e312 100644
--- a/drivers/dma/ti-dma-crossbar.c
+++ b/drivers/dma/ti-dma-crossbar.c
@@ -169,7 +169,7 @@ static int ti_dma_xbar_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id ti_dma_xbar_match[] = {
-	{ .compatible = "ti,dra7-dma-crossbar" },
+	{ .compatible = "ti,dra7-sdma-crossbar" },
 	{},
 };
 
-- 
2.4.2

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

* [PATCH 2/3] dmaengine: ti-dma-crossbar: Make idr xbar instance-specific
  2015-06-05 15:34 [PATCH 0/3] dmaengine: ti-dma-crossbar: Support for eDMA Peter Ujfalusi
  2015-06-05 15:34 ` [PATCH 1/3] dmaengine: ti-dma-crossbar: Change the compatible string to ti,dra7-sdma-crossbar Peter Ujfalusi
@ 2015-06-05 15:34 ` Peter Ujfalusi
  2015-06-05 15:34 ` [PATCH 3/3] dmaengine: ti-dma-crossbar: Add support for eDMA xbar Peter Ujfalusi
  2015-06-05 16:17 ` [PATCH 0/3] dmaengine: ti-dma-crossbar: Support for eDMA Peter Ujfalusi
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2015-06-05 15:34 UTC (permalink / raw)
  To: vinod.koul, Tony Lindgren, robh+dt, pawel.moll, mark.rutland
  Cc: devicetree, linux-kernel, dmaengine, linux-omap, misael.lopez

From: Misael Lopez Cruz <misael.lopez@ti.com>

In preparation for supporting multiple DMA crossbar instances,
make the idr xbar instance specific.

Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/dma/ti-dma-crossbar.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
index 73ecd0a1e312..887cfe676b6d 100644
--- a/drivers/dma/ti-dma-crossbar.c
+++ b/drivers/dma/ti-dma-crossbar.c
@@ -20,12 +20,11 @@
 #define TI_XBAR_OUTPUTS	127
 #define TI_XBAR_INPUTS	256
 
-static DEFINE_IDR(map_idr);
-
 struct ti_dma_xbar_data {
 	void __iomem *iomem;
 
 	struct dma_router dmarouter;
+	struct idr map_idr;
 
 	u16 safe_val; /* Value to rest the crossbar lines */
 	u32 xbar_requests; /* number of DMA requests connected to XBAR */
@@ -51,7 +50,7 @@ static void ti_dma_xbar_free(struct device *dev, void *route_data)
 		map->xbar_in, map->xbar_out);
 
 	ti_dma_xbar_write(xbar->iomem, map->xbar_out, xbar->safe_val);
-	idr_remove(&map_idr, map->xbar_out);
+	idr_remove(&xbar->map_idr, map->xbar_out);
 	kfree(map);
 }
 
@@ -81,7 +80,7 @@ static void *ti_dma_xbar_route_allocate(struct of_phandle_args *dma_spec,
 		return ERR_PTR(-ENOMEM);
 	}
 
-	map->xbar_out = idr_alloc(&map_idr, NULL, 0, xbar->dma_requests,
+	map->xbar_out = idr_alloc(&xbar->map_idr, NULL, 0, xbar->dma_requests,
 				  GFP_KERNEL);
 	map->xbar_in = (u16)dma_spec->args[0];
 
@@ -113,6 +112,8 @@ static int ti_dma_xbar_probe(struct platform_device *pdev)
 	if (!xbar)
 		return -ENOMEM;
 
+	idr_init(&xbar->map_idr);
+
 	dma_node = of_parse_phandle(node, "dma-masters", 0);
 	if (!dma_node) {
 		dev_err(&pdev->dev, "Can't get DMA master node\n");
-- 
2.4.2

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

* [PATCH 3/3] dmaengine: ti-dma-crossbar: Add support for eDMA xbar
  2015-06-05 15:34 [PATCH 0/3] dmaengine: ti-dma-crossbar: Support for eDMA Peter Ujfalusi
  2015-06-05 15:34 ` [PATCH 1/3] dmaengine: ti-dma-crossbar: Change the compatible string to ti,dra7-sdma-crossbar Peter Ujfalusi
  2015-06-05 15:34 ` [PATCH 2/3] dmaengine: ti-dma-crossbar: Make idr xbar instance-specific Peter Ujfalusi
@ 2015-06-05 15:34 ` Peter Ujfalusi
  2015-06-05 16:17 ` [PATCH 0/3] dmaengine: ti-dma-crossbar: Support for eDMA Peter Ujfalusi
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2015-06-05 15:34 UTC (permalink / raw)
  To: vinod.koul, Tony Lindgren, robh+dt, pawel.moll, mark.rutland
  Cc: devicetree, linux-kernel, dmaengine, linux-omap, misael.lopez

From: Misael Lopez Cruz <misael.lopez@ti.com>

eDMA crossbar works exactly the same way as sDMA, but sDMA
requires an offset of 1, while no offset is needed for eDMA.

Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 .../devicetree/bindings/dma/ti-dma-crossbar.txt    |  1 +
 drivers/dma/ti-dma-crossbar.c                      | 30 +++++++++++++++++-----
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt b/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt
index 76a10d0724b7..da46dddc78ef 100644
--- a/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt
+++ b/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt
@@ -2,6 +2,7 @@ Texas Instruments DMA Crossbar (DMA request router)
 
 Required properties:
 - compatible:	"ti,dra7-sdma-crossbar" for DRA7xx sDMA crossbar
+		"ti,dra7-edma-crossbar" for DRA7xx eDMA crossbar
 - reg:		Memory map for accessing module
 - #dma-cells:	Should be set to <1>.
 		Clients should use the crossbar request number (input)
diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
index 887cfe676b6d..c21690ed954f 100644
--- a/drivers/dma/ti-dma-crossbar.c
+++ b/drivers/dma/ti-dma-crossbar.c
@@ -20,6 +20,9 @@
 #define TI_XBAR_OUTPUTS	127
 #define TI_XBAR_INPUTS	256
 
+#define TI_XBAR_EDMA_OFFSET	0
+#define TI_XBAR_SDMA_OFFSET	1
+
 struct ti_dma_xbar_data {
 	void __iomem *iomem;
 
@@ -29,6 +32,7 @@ struct ti_dma_xbar_data {
 	u16 safe_val; /* Value to rest the crossbar lines */
 	u32 xbar_requests; /* number of DMA requests connected to XBAR */
 	u32 dma_requests; /* number of DMA requests forwarded to DMA */
+	u32 dma_offset;
 };
 
 struct ti_dma_xbar_map {
@@ -84,8 +88,7 @@ static void *ti_dma_xbar_route_allocate(struct of_phandle_args *dma_spec,
 				  GFP_KERNEL);
 	map->xbar_in = (u16)dma_spec->args[0];
 
-	/* The DMA request is 1 based in sDMA */
-	dma_spec->args[0] = map->xbar_out + 1;
+	dma_spec->args[0] = map->xbar_out + xbar->dma_offset;
 
 	dev_dbg(&pdev->dev, "Mapping XBAR%u to DMA%d\n",
 		map->xbar_in, map->xbar_out);
@@ -95,9 +98,22 @@ static void *ti_dma_xbar_route_allocate(struct of_phandle_args *dma_spec,
 	return map;
 }
 
+static const struct of_device_id ti_dma_xbar_match[] = {
+	{
+		.compatible = "ti,dra7-sdma-crossbar",
+		.data = (void *)TI_XBAR_SDMA_OFFSET,
+	},
+	{
+		.compatible = "ti,dra7-edma-crossbar",
+		.data = (void *)TI_XBAR_EDMA_OFFSET,
+	},
+	{},
+};
+
 static int ti_dma_xbar_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
+	const struct of_device_id *match;
 	struct device_node *dma_node;
 	struct ti_dma_xbar_data *xbar;
 	struct resource *res;
@@ -108,6 +124,10 @@ static int ti_dma_xbar_probe(struct platform_device *pdev)
 	if (!node)
 		return -ENODEV;
 
+	match = of_match_device(ti_dma_xbar_match, &pdev->dev);
+	if (!match)
+		return -EINVAL;
+
 	xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL);
 	if (!xbar)
 		return -ENOMEM;
@@ -151,6 +171,7 @@ static int ti_dma_xbar_probe(struct platform_device *pdev)
 
 	xbar->dmarouter.dev = &pdev->dev;
 	xbar->dmarouter.route_free = ti_dma_xbar_free;
+	xbar->dma_offset = (u32)match->data;
 
 	platform_set_drvdata(pdev, xbar);
 
@@ -169,11 +190,6 @@ static int ti_dma_xbar_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static const struct of_device_id ti_dma_xbar_match[] = {
-	{ .compatible = "ti,dra7-sdma-crossbar" },
-	{},
-};
-
 static struct platform_driver ti_dma_xbar_driver = {
 	.driver = {
 		.name = "ti-dma-crossbar",
-- 
2.4.2

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

* Re: [PATCH 0/3] dmaengine: ti-dma-crossbar: Support for eDMA
  2015-06-05 15:34 [PATCH 0/3] dmaengine: ti-dma-crossbar: Support for eDMA Peter Ujfalusi
                   ` (2 preceding siblings ...)
  2015-06-05 15:34 ` [PATCH 3/3] dmaengine: ti-dma-crossbar: Add support for eDMA xbar Peter Ujfalusi
@ 2015-06-05 16:17 ` Peter Ujfalusi
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2015-06-05 16:17 UTC (permalink / raw)
  To: vinod.koul, Tony Lindgren, robh+dt, pawel.moll, mark.rutland
  Cc: devicetree, linux-kernel, dmaengine, linux-omap, misael.lopez

On 06/05/2015 06:34 PM, Peter Ujfalusi wrote:
> Hi,
> 
> The ti-dma-crossbar driver in it's current form can work when it is used with
> sDMA (omap-dma). On DRA7x class of devices we have both sDMA and eDMA available.
> The DT bindings for sDMA has been done in a way that DMA users need to specify
> the required DMA request number + 1 when they request for channel and the driver
> stack has been written in this way also for sDMA.
> Since right now we do not have the crossbar enabled we can still change the
> compatible string to reflect the crossbar use. The TRM also refers the crossbars
> in this way.

Now that I have sent this series...
Would it be better to not touch the compatible strings, but add of_device_id
table in the ti-dma-crossbar driver containing the supported dma controllers,
like "ti,omap4430-sdma" and "ti,edma3" and to of_match_node() against the node
we got via dma-masters?

So we would keep the ti,dra7-dma-crossbar and depending on where the
dma-masters point us we can decide in the code on how to handle?

Just a thought.

> 
> Regards,
> Peter
> ---
> Misael Lopez Cruz (2):
>   dmaengine: ti-dma-crossbar: Make idr xbar instance-specific
>   dmaengine: ti-dma-crossbar: Add support for eDMA xbar
> 
> Peter Ujfalusi (1):
>   dmaengine: ti-dma-crossbar: Change the compatible string to
>     ti,dra7-sdma-crossbar
> 
>  Documentation/devicetree/bindings/dma/dma.txt      |  2 +-
>  .../devicetree/bindings/dma/ti-dma-crossbar.txt    |  5 +--
>  drivers/dma/ti-dma-crossbar.c                      | 37 ++++++++++++++++------
>  3 files changed, 31 insertions(+), 13 deletions(-)
> 


-- 
Péter

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

end of thread, other threads:[~2015-06-05 16:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-05 15:34 [PATCH 0/3] dmaengine: ti-dma-crossbar: Support for eDMA Peter Ujfalusi
2015-06-05 15:34 ` [PATCH 1/3] dmaengine: ti-dma-crossbar: Change the compatible string to ti,dra7-sdma-crossbar Peter Ujfalusi
2015-06-05 15:34 ` [PATCH 2/3] dmaengine: ti-dma-crossbar: Make idr xbar instance-specific Peter Ujfalusi
2015-06-05 15:34 ` [PATCH 3/3] dmaengine: ti-dma-crossbar: Add support for eDMA xbar Peter Ujfalusi
2015-06-05 16:17 ` [PATCH 0/3] dmaengine: ti-dma-crossbar: Support for eDMA Peter Ujfalusi

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