Re: [PATCH 10/13] dmaengine: ti-dma-crossbar: Add support for crossbar on AM33xx/AM43xx

2015-10-14 Thread Vinod Koul
On Wed, Oct 14, 2015 at 04:12:21PM +0300, Peter Ujfalusi wrote:
> The DMA event crossbar on AM33xx/AM43xx is different from the one found in
> DRA7x family.
> Instead of a single event crossbar it has 64 identical mux attached to each
> eDMA event line. When the 0 event mux is selected, the default mapped event
> is going to be routed to the corresponding eDMA event line. If different
> mux is selected, then the selected event is going to be routed to the given
> eDMA event.

Why is crossbar patch in edma series?

> +static void ti_am335x_xbar_free(struct device *dev, void *route_data)
> +{
> + struct ti_am335x_xbar_data *xbar = dev_get_drvdata(dev);
> + struct ti_am335x_xbar_map *map = route_data;
> +
> + dev_err(dev, "Unmapping XBAR event %u on channel %u\n",
> + map->mux_val, map->dma_line);

Err ?

-- 
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/13] dmaengine: ti-dma-crossbar: Add support for crossbar on AM33xx/AM43xx

2015-10-14 Thread Peter Ujfalusi
On 10/14/2015 05:48 PM, Vinod Koul wrote:
> On Wed, Oct 14, 2015 at 04:12:21PM +0300, Peter Ujfalusi wrote:
>> The DMA event crossbar on AM33xx/AM43xx is different from the one found in
>> DRA7x family.
>> Instead of a single event crossbar it has 64 identical mux attached to each
>> eDMA event line. When the 0 event mux is selected, the default mapped event
>> is going to be routed to the corresponding eDMA event line. If different
>> mux is selected, then the selected event is going to be routed to the given
>> eDMA event.
> 
> Why is crossbar patch in edma series?

The old eDMA binding had xbar support which is not supported by the new
binding since it does not belong to the eDMA driver at all.
We have couple of boards where the crossbar is in use so I included the
crossbar support in this series.

>> +static void ti_am335x_xbar_free(struct device *dev, void *route_data)
>> +{
>> +struct ti_am335x_xbar_data *xbar = dev_get_drvdata(dev);
>> +struct ti_am335x_xbar_map *map = route_data;
>> +
>> +dev_err(dev, "Unmapping XBAR event %u on channel %u\n",
>> +map->mux_val, map->dma_line);
> 
> Err ?

Aargh, leftover from debugging.

-- 
Péter
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/13] dmaengine: ti-dma-crossbar: Add support for crossbar on AM33xx/AM43xx

2015-10-14 Thread Peter Ujfalusi
The DMA event crossbar on AM33xx/AM43xx is different from the one found in
DRA7x family.
Instead of a single event crossbar it has 64 identical mux attached to each
eDMA event line. When the 0 event mux is selected, the default mapped event
is going to be routed to the corresponding eDMA event line. If different
mux is selected, then the selected event is going to be routed to the given
eDMA event.

Signed-off-by: Peter Ujfalusi 
---
 .../devicetree/bindings/dma/ti-dma-crossbar.txt|  15 +-
 drivers/dma/ti-dma-crossbar.c  | 237 ++---
 2 files changed, 226 insertions(+), 26 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt 
b/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt
index 63a48928f3a8..b152a75dceae 100644
--- a/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt
+++ b/Documentation/devicetree/bindings/dma/ti-dma-crossbar.txt
@@ -2,9 +2,10 @@ Texas Instruments DMA Crossbar (DMA request router)
 
 Required properties:
 - compatible:  "ti,dra7-dma-crossbar" for DRA7xx DMA crossbar
+   "ti,am335x-edma-crossbar" for AM335x and AM437x
 - reg: Memory map for accessing module
-- #dma-cells:  Should be set to <1>.
-   Clients should use the crossbar request number (input)
+- #dma-cells:  Should be set to to match with the DMA controller's dma-cells
+   for ti,dra7-dma-crossbar and <3> for ti,am335x-edma-crossbar.
 - dma-requests:Number of DMA requests the crossbar can receive
 - dma-masters: phandle pointing to the DMA controller
 
@@ -14,6 +15,15 @@ The DMA controller node need to have the following 
poroperties:
 Optional properties:
 - ti,dma-safe-map: Safe routing value for unused request lines
 
+Notes:
+When requesting channel via ti,dra7-dma-crossbar, the DMA clinet must request
+the DMA event number as crossbar ID (input to the DMA crossbar).
+
+For ti,am335x-edma-crossbar: the meaning of parameters of dmas for clients:
+dmas = <_xbar 12 0 1>; where <12> is the DMA request number, <0> is the TC
+the event should be assigned and <1> is the mux selection for in the crossbar.
+When mux 0 is used the DMA channel can be requested directly from edma node.
+
 Example:
 
 /* DMA controller */
@@ -47,6 +57,7 @@ uart1: serial@4806a000 {
ti,hwmods = "uart1";
clock-frequency = <4800>;
status = "disabled";
+   /* Requesting crossbar input 49 and 50 */
dmas = <_xbar 49>, <_xbar 50>;
dma-names = "tx", "rx";
 };
diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
index 5cce8c9d0026..9c5ee2149052 100644
--- a/drivers/dma/ti-dma-crossbar.c
+++ b/drivers/dma/ti-dma-crossbar.c
@@ -23,7 +23,176 @@
 #define TI_XBAR_EDMA_OFFSET0
 #define TI_XBAR_SDMA_OFFSET1
 
-struct ti_dma_xbar_data {
+#define TI_XBAR_DRA7   0
+#define TI_XBAR_AM335X 1
+
+static const struct of_device_id ti_dma_xbar_match[] = {
+   {
+   .compatible = "ti,dra7-dma-crossbar",
+   .data = (void *)TI_XBAR_DRA7,
+   },
+   {
+   .compatible = "ti,am335x-edma-crossbar",
+   .data = (void *)TI_XBAR_AM335X,
+   },
+   {},
+};
+
+/* Crossbar on AM335x/AM437x family */
+struct ti_am335x_xbar_data {
+   void __iomem *iomem;
+
+   struct dma_router dmarouter;
+
+   u32 xbar_events; /* maximum number of events to select in xbar */
+   u32 dma_requests; /* number of DMA requests on eDMA */
+};
+
+struct ti_am335x_xbar_map {
+   u16 dma_line;
+   u16 mux_val;
+};
+
+static inline void ti_am335x_xbar_write(void __iomem *iomem, int event, u16 
val)
+{
+   writeb_relaxed(val & 0x1f, iomem + event);
+}
+
+static void ti_am335x_xbar_free(struct device *dev, void *route_data)
+{
+   struct ti_am335x_xbar_data *xbar = dev_get_drvdata(dev);
+   struct ti_am335x_xbar_map *map = route_data;
+
+   dev_err(dev, "Unmapping XBAR event %u on channel %u\n",
+   map->mux_val, map->dma_line);
+
+   ti_am335x_xbar_write(xbar->iomem, map->dma_line, 0);
+   kfree(map);
+}
+
+static void *ti_am335x_xbar_route_allocate(struct of_phandle_args *dma_spec,
+  struct of_dma *ofdma)
+{
+   struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
+   struct ti_am335x_xbar_data *xbar = platform_get_drvdata(pdev);
+   struct ti_am335x_xbar_map *map;
+
+   if (dma_spec->args_count != 3)
+   return ERR_PTR(-EINVAL);
+
+   if (dma_spec->args[2] >= xbar->xbar_events) {
+   dev_err(>dev, "Invalid XBAR event number: %d\n",
+   dma_spec->args[2]);
+   return ERR_PTR(-EINVAL);
+   }
+
+   if (dma_spec->args[0] >= xbar->dma_requests) {
+   dev_err(>dev, "Invalid DMA request line number: %d\n",
+   dma_spec->args[0]);
+   return ERR_PTR(-EINVAL);
+