Commit 0f73f3e8 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Vinod Koul

dmaengine: ti-dma-crossbar: dra7: Support for reserving DMA event ranges

In eDMA the events are directly mapped to a DMA channel (for example DMA
event 14 can only be handled by DMA channel 14). If the memcpy is enabled
on the eDMA, there is a possibility that the crossbar driver would assign
DMA event number already allocated in eDMA for memcpy. Furthermore the
eDMA can be shared with DSP in which case the crossbar driver should also
avoid mapping xbar events to DSP used event numbers (or channels).
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent ec9bfa1e
...@@ -14,6 +14,10 @@ The DMA controller node need to have the following poroperties: ...@@ -14,6 +14,10 @@ The DMA controller node need to have the following poroperties:
Optional properties: Optional properties:
- ti,dma-safe-map: Safe routing value for unused request lines - ti,dma-safe-map: Safe routing value for unused request lines
- ti,reserved-dma-request-ranges: DMA request ranges which should not be used
when mapping xbar input to DMA request, they are either
allocated to be used by for example the DSP or they are used as
memcpy channels in eDMA.
Notes: Notes:
When requesting channel via ti,dra7-dma-crossbar, the DMA clinet must request When requesting channel via ti,dra7-dma-crossbar, the DMA clinet must request
...@@ -46,6 +50,8 @@ sdma_xbar: dma-router@4a002b78 { ...@@ -46,6 +50,8 @@ sdma_xbar: dma-router@4a002b78 {
#dma-cells = <1>; #dma-cells = <1>;
dma-requests = <205>; dma-requests = <205>;
ti,dma-safe-map = <0>; ti,dma-safe-map = <0>;
/* Protect the sDMA request ranges: 10-14 and 100-126 */
ti,reserved-dma-request-ranges = <10 5>, <100 27>;
dma-masters = <&sdma>; dma-masters = <&sdma>;
}; };
......
...@@ -296,14 +296,22 @@ static const struct of_device_id ti_dra7_master_match[] = { ...@@ -296,14 +296,22 @@ static const struct of_device_id ti_dra7_master_match[] = {
{}, {},
}; };
static inline void ti_dra7_xbar_reserve(int offset, int len, unsigned long *p)
{
for (; len > 0; len--)
clear_bit(offset + (len - 1), p);
}
static int ti_dra7_xbar_probe(struct platform_device *pdev) static int ti_dra7_xbar_probe(struct platform_device *pdev)
{ {
struct device_node *node = pdev->dev.of_node; struct device_node *node = pdev->dev.of_node;
const struct of_device_id *match; const struct of_device_id *match;
struct device_node *dma_node; struct device_node *dma_node;
struct ti_dra7_xbar_data *xbar; struct ti_dra7_xbar_data *xbar;
struct property *prop;
struct resource *res; struct resource *res;
u32 safe_val; u32 safe_val;
size_t sz;
void __iomem *iomem; void __iomem *iomem;
int i, ret; int i, ret;
...@@ -351,6 +359,33 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev) ...@@ -351,6 +359,33 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev)
if (!of_property_read_u32(node, "ti,dma-safe-map", &safe_val)) if (!of_property_read_u32(node, "ti,dma-safe-map", &safe_val))
xbar->safe_val = (u16)safe_val; xbar->safe_val = (u16)safe_val;
prop = of_find_property(node, "ti,reserved-dma-request-ranges", &sz);
if (prop) {
const char pname[] = "ti,reserved-dma-request-ranges";
u32 (*rsv_events)[2];
size_t nelm = sz / sizeof(*rsv_events);
int i;
if (!nelm)
return -EINVAL;
rsv_events = kcalloc(nelm, sizeof(*rsv_events), GFP_KERNEL);
if (!rsv_events)
return -ENOMEM;
ret = of_property_read_u32_array(node, pname, (u32 *)rsv_events,
nelm * 2);
if (ret)
return ret;
for (i = 0; i < nelm; i++) {
ti_dra7_xbar_reserve(rsv_events[i][0], rsv_events[i][1],
xbar->dma_inuse);
}
kfree(rsv_events);
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
iomem = devm_ioremap_resource(&pdev->dev, res); iomem = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(iomem)) if (IS_ERR(iomem))
...@@ -366,15 +401,19 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev) ...@@ -366,15 +401,19 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, xbar); platform_set_drvdata(pdev, xbar);
/* Reset the crossbar */ /* Reset the crossbar */
for (i = 0; i < xbar->dma_requests; i++) for (i = 0; i < xbar->dma_requests; i++) {
ti_dra7_xbar_write(xbar->iomem, i, xbar->safe_val); if (!test_bit(i, xbar->dma_inuse))
ti_dra7_xbar_write(xbar->iomem, i, xbar->safe_val);
}
ret = of_dma_router_register(node, ti_dra7_xbar_route_allocate, ret = of_dma_router_register(node, ti_dra7_xbar_route_allocate,
&xbar->dmarouter); &xbar->dmarouter);
if (ret) { if (ret) {
/* Restore the defaults for the crossbar */ /* Restore the defaults for the crossbar */
for (i = 0; i < xbar->dma_requests; i++) for (i = 0; i < xbar->dma_requests; i++) {
ti_dra7_xbar_write(xbar->iomem, i, i); if (!test_bit(i, xbar->dma_inuse))
ti_dra7_xbar_write(xbar->iomem, i, i);
}
} }
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment