Lines Matching +full:edma +full:- +full:err
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
8 #include <linux/err.h>
25 .compatible = "ti,dra7-dma-crossbar",
29 .compatible = "ti,am335x-edma-crossbar",
44 u32 dma_requests; /* number of DMA requests on eDMA */
60 writeb_relaxed(val, iomem + (63 - event % 4)); in ti_am335x_xbar_write()
71 map->mux_val, map->dma_line); in ti_am335x_xbar_free()
73 ti_am335x_xbar_write(xbar->iomem, map->dma_line, 0); in ti_am335x_xbar_free()
80 struct platform_device *pdev = of_find_device_by_node(ofdma->of_node); in ti_am335x_xbar_route_allocate()
84 if (dma_spec->args_count != 3) in ti_am335x_xbar_route_allocate()
85 return ERR_PTR(-EINVAL); in ti_am335x_xbar_route_allocate()
87 if (dma_spec->args[2] >= xbar->xbar_events) { in ti_am335x_xbar_route_allocate()
88 dev_err(&pdev->dev, "Invalid XBAR event number: %d\n", in ti_am335x_xbar_route_allocate()
89 dma_spec->args[2]); in ti_am335x_xbar_route_allocate()
90 return ERR_PTR(-EINVAL); in ti_am335x_xbar_route_allocate()
93 if (dma_spec->args[0] >= xbar->dma_requests) { in ti_am335x_xbar_route_allocate()
94 dev_err(&pdev->dev, "Invalid DMA request line number: %d\n", in ti_am335x_xbar_route_allocate()
95 dma_spec->args[0]); in ti_am335x_xbar_route_allocate()
96 return ERR_PTR(-EINVAL); in ti_am335x_xbar_route_allocate()
100 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); in ti_am335x_xbar_route_allocate()
101 if (!dma_spec->np) { in ti_am335x_xbar_route_allocate()
102 dev_err(&pdev->dev, "Can't get DMA master\n"); in ti_am335x_xbar_route_allocate()
103 return ERR_PTR(-EINVAL); in ti_am335x_xbar_route_allocate()
108 of_node_put(dma_spec->np); in ti_am335x_xbar_route_allocate()
109 return ERR_PTR(-ENOMEM); in ti_am335x_xbar_route_allocate()
112 map->dma_line = (u16)dma_spec->args[0]; in ti_am335x_xbar_route_allocate()
113 map->mux_val = (u8)dma_spec->args[2]; in ti_am335x_xbar_route_allocate()
115 dma_spec->args[2] = 0; in ti_am335x_xbar_route_allocate()
116 dma_spec->args_count = 2; in ti_am335x_xbar_route_allocate()
118 dev_dbg(&pdev->dev, "Mapping XBAR event%u to DMA%u\n", in ti_am335x_xbar_route_allocate()
119 map->mux_val, map->dma_line); in ti_am335x_xbar_route_allocate()
121 ti_am335x_xbar_write(xbar->iomem, map->dma_line, map->mux_val); in ti_am335x_xbar_route_allocate()
127 { .compatible = "ti,edma3-tpcc", },
133 struct device_node *node = pdev->dev.of_node; in ti_am335x_xbar_probe()
141 return -ENODEV; in ti_am335x_xbar_probe()
143 xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL); in ti_am335x_xbar_probe()
145 return -ENOMEM; in ti_am335x_xbar_probe()
147 dma_node = of_parse_phandle(node, "dma-masters", 0); in ti_am335x_xbar_probe()
149 dev_err(&pdev->dev, "Can't get DMA master node\n"); in ti_am335x_xbar_probe()
150 return -ENODEV; in ti_am335x_xbar_probe()
155 dev_err(&pdev->dev, "DMA master is not supported\n"); in ti_am335x_xbar_probe()
157 return -EINVAL; in ti_am335x_xbar_probe()
160 if (of_property_read_u32(dma_node, "dma-requests", in ti_am335x_xbar_probe()
161 &xbar->dma_requests)) { in ti_am335x_xbar_probe()
162 dev_info(&pdev->dev, in ti_am335x_xbar_probe()
165 xbar->dma_requests = TI_AM335X_XBAR_LINES; in ti_am335x_xbar_probe()
169 if (of_property_read_u32(node, "dma-requests", &xbar->xbar_events)) { in ti_am335x_xbar_probe()
170 dev_info(&pdev->dev, in ti_am335x_xbar_probe()
173 xbar->xbar_events = TI_AM335X_XBAR_LINES; in ti_am335x_xbar_probe()
180 xbar->iomem = iomem; in ti_am335x_xbar_probe()
182 xbar->dmarouter.dev = &pdev->dev; in ti_am335x_xbar_probe()
183 xbar->dmarouter.route_free = ti_am335x_xbar_free; in ti_am335x_xbar_probe()
188 for (i = 0; i < xbar->dma_requests; i++) in ti_am335x_xbar_probe()
189 ti_am335x_xbar_write(xbar->iomem, i, 0); in ti_am335x_xbar_probe()
192 &xbar->dmarouter); in ti_am335x_xbar_probe()
230 map->xbar_in, map->xbar_out); in ti_dra7_xbar_free()
232 ti_dra7_xbar_write(xbar->iomem, map->xbar_out, xbar->safe_val); in ti_dra7_xbar_free()
233 mutex_lock(&xbar->mutex); in ti_dra7_xbar_free()
234 clear_bit(map->xbar_out, xbar->dma_inuse); in ti_dra7_xbar_free()
235 mutex_unlock(&xbar->mutex); in ti_dra7_xbar_free()
242 struct platform_device *pdev = of_find_device_by_node(ofdma->of_node); in ti_dra7_xbar_route_allocate()
246 if (dma_spec->args[0] >= xbar->xbar_requests) { in ti_dra7_xbar_route_allocate()
247 dev_err(&pdev->dev, "Invalid XBAR request number: %d\n", in ti_dra7_xbar_route_allocate()
248 dma_spec->args[0]); in ti_dra7_xbar_route_allocate()
249 put_device(&pdev->dev); in ti_dra7_xbar_route_allocate()
250 return ERR_PTR(-EINVAL); in ti_dra7_xbar_route_allocate()
254 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); in ti_dra7_xbar_route_allocate()
255 if (!dma_spec->np) { in ti_dra7_xbar_route_allocate()
256 dev_err(&pdev->dev, "Can't get DMA master\n"); in ti_dra7_xbar_route_allocate()
257 put_device(&pdev->dev); in ti_dra7_xbar_route_allocate()
258 return ERR_PTR(-EINVAL); in ti_dra7_xbar_route_allocate()
263 of_node_put(dma_spec->np); in ti_dra7_xbar_route_allocate()
264 put_device(&pdev->dev); in ti_dra7_xbar_route_allocate()
265 return ERR_PTR(-ENOMEM); in ti_dra7_xbar_route_allocate()
268 mutex_lock(&xbar->mutex); in ti_dra7_xbar_route_allocate()
269 map->xbar_out = find_first_zero_bit(xbar->dma_inuse, in ti_dra7_xbar_route_allocate()
270 xbar->dma_requests); in ti_dra7_xbar_route_allocate()
271 if (map->xbar_out == xbar->dma_requests) { in ti_dra7_xbar_route_allocate()
272 mutex_unlock(&xbar->mutex); in ti_dra7_xbar_route_allocate()
273 dev_err(&pdev->dev, "Run out of free DMA requests\n"); in ti_dra7_xbar_route_allocate()
275 of_node_put(dma_spec->np); in ti_dra7_xbar_route_allocate()
276 put_device(&pdev->dev); in ti_dra7_xbar_route_allocate()
277 return ERR_PTR(-ENOMEM); in ti_dra7_xbar_route_allocate()
279 set_bit(map->xbar_out, xbar->dma_inuse); in ti_dra7_xbar_route_allocate()
280 mutex_unlock(&xbar->mutex); in ti_dra7_xbar_route_allocate()
282 map->xbar_in = (u16)dma_spec->args[0]; in ti_dra7_xbar_route_allocate()
284 dma_spec->args[0] = map->xbar_out + xbar->dma_offset; in ti_dra7_xbar_route_allocate()
286 dev_dbg(&pdev->dev, "Mapping XBAR%u to DMA%d\n", in ti_dra7_xbar_route_allocate()
287 map->xbar_in, map->xbar_out); in ti_dra7_xbar_route_allocate()
289 ti_dra7_xbar_write(xbar->iomem, map->xbar_out, map->xbar_in); in ti_dra7_xbar_route_allocate()
303 .compatible = "ti,omap4430-sdma",
311 .compatible = "ti,edma3-tpcc",
319 for (; len > 0; len--) in ti_dra7_xbar_reserve()
320 set_bit(offset + (len - 1), p); in ti_dra7_xbar_reserve()
325 struct device_node *node = pdev->dev.of_node; in ti_dra7_xbar_probe()
336 return -ENODEV; in ti_dra7_xbar_probe()
338 xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL); in ti_dra7_xbar_probe()
340 return -ENOMEM; in ti_dra7_xbar_probe()
342 dma_node = of_parse_phandle(node, "dma-masters", 0); in ti_dra7_xbar_probe()
344 dev_err(&pdev->dev, "Can't get DMA master node\n"); in ti_dra7_xbar_probe()
345 return -ENODEV; in ti_dra7_xbar_probe()
350 dev_err(&pdev->dev, "DMA master is not supported\n"); in ti_dra7_xbar_probe()
352 return -EINVAL; in ti_dra7_xbar_probe()
355 if (of_property_read_u32(dma_node, "dma-requests", in ti_dra7_xbar_probe()
356 &xbar->dma_requests)) { in ti_dra7_xbar_probe()
357 dev_info(&pdev->dev, in ti_dra7_xbar_probe()
360 xbar->dma_requests = TI_DRA7_XBAR_OUTPUTS; in ti_dra7_xbar_probe()
364 xbar->dma_inuse = devm_kcalloc(&pdev->dev, in ti_dra7_xbar_probe()
365 BITS_TO_LONGS(xbar->dma_requests), in ti_dra7_xbar_probe()
367 if (!xbar->dma_inuse) in ti_dra7_xbar_probe()
368 return -ENOMEM; in ti_dra7_xbar_probe()
370 if (of_property_read_u32(node, "dma-requests", &xbar->xbar_requests)) { in ti_dra7_xbar_probe()
371 dev_info(&pdev->dev, in ti_dra7_xbar_probe()
374 xbar->xbar_requests = TI_DRA7_XBAR_INPUTS; in ti_dra7_xbar_probe()
377 if (!of_property_read_u32(node, "ti,dma-safe-map", &safe_val)) in ti_dra7_xbar_probe()
378 xbar->safe_val = (u16)safe_val; in ti_dra7_xbar_probe()
381 prop = of_find_property(node, "ti,reserved-dma-request-ranges", &sz); in ti_dra7_xbar_probe()
383 const char pname[] = "ti,reserved-dma-request-ranges"; in ti_dra7_xbar_probe()
389 return -EINVAL; in ti_dra7_xbar_probe()
393 return -ENOMEM; in ti_dra7_xbar_probe()
404 xbar->dma_inuse); in ti_dra7_xbar_probe()
413 xbar->iomem = iomem; in ti_dra7_xbar_probe()
415 xbar->dmarouter.dev = &pdev->dev; in ti_dra7_xbar_probe()
416 xbar->dmarouter.route_free = ti_dra7_xbar_free; in ti_dra7_xbar_probe()
417 xbar->dma_offset = *(u32 *)match->data; in ti_dra7_xbar_probe()
419 mutex_init(&xbar->mutex); in ti_dra7_xbar_probe()
423 for (i = 0; i < xbar->dma_requests; i++) { in ti_dra7_xbar_probe()
424 if (!test_bit(i, xbar->dma_inuse)) in ti_dra7_xbar_probe()
425 ti_dra7_xbar_write(xbar->iomem, i, xbar->safe_val); in ti_dra7_xbar_probe()
429 &xbar->dmarouter); in ti_dra7_xbar_probe()
432 for (i = 0; i < xbar->dma_requests; i++) { in ti_dra7_xbar_probe()
433 if (!test_bit(i, xbar->dma_inuse)) in ti_dra7_xbar_probe()
434 ti_dra7_xbar_write(xbar->iomem, i, i); in ti_dra7_xbar_probe()
446 match = of_match_node(ti_dma_xbar_match, pdev->dev.of_node); in ti_dma_xbar_probe()
448 return -EINVAL; in ti_dma_xbar_probe()
450 switch (*(u32 *)match->data) { in ti_dma_xbar_probe()
458 dev_err(&pdev->dev, "Unsupported crossbar\n"); in ti_dma_xbar_probe()
459 ret = -ENODEV; in ti_dma_xbar_probe()
468 .name = "ti-dma-crossbar",