Lines Matching +full:dma +full:- +full:requests
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
24 .compatible = "ti,dra7-dma-crossbar",
28 .compatible = "ti,am335x-edma-crossbar",
43 u32 dma_requests; /* number of DMA requests on eDMA */
59 writeb_relaxed(val, iomem + (63 - event % 4)); in ti_am335x_xbar_write()
70 map->mux_val, map->dma_line); in ti_am335x_xbar_free()
72 ti_am335x_xbar_write(xbar->iomem, map->dma_line, 0); in ti_am335x_xbar_free()
79 struct platform_device *pdev = of_find_device_by_node(ofdma->of_node); in ti_am335x_xbar_route_allocate()
83 if (dma_spec->args_count != 3) in ti_am335x_xbar_route_allocate()
84 return ERR_PTR(-EINVAL); in ti_am335x_xbar_route_allocate()
86 if (dma_spec->args[2] >= xbar->xbar_events) { in ti_am335x_xbar_route_allocate()
87 dev_err(&pdev->dev, "Invalid XBAR event number: %d\n", in ti_am335x_xbar_route_allocate()
88 dma_spec->args[2]); in ti_am335x_xbar_route_allocate()
89 return ERR_PTR(-EINVAL); in ti_am335x_xbar_route_allocate()
92 if (dma_spec->args[0] >= xbar->dma_requests) { in ti_am335x_xbar_route_allocate()
93 dev_err(&pdev->dev, "Invalid DMA request line number: %d\n", in ti_am335x_xbar_route_allocate()
94 dma_spec->args[0]); in ti_am335x_xbar_route_allocate()
95 return ERR_PTR(-EINVAL); in ti_am335x_xbar_route_allocate()
99 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); in ti_am335x_xbar_route_allocate()
100 if (!dma_spec->np) { in ti_am335x_xbar_route_allocate()
101 dev_err(&pdev->dev, "Can't get DMA master\n"); in ti_am335x_xbar_route_allocate()
102 return ERR_PTR(-EINVAL); in ti_am335x_xbar_route_allocate()
107 of_node_put(dma_spec->np); in ti_am335x_xbar_route_allocate()
108 return ERR_PTR(-ENOMEM); in ti_am335x_xbar_route_allocate()
111 map->dma_line = (u16)dma_spec->args[0]; in ti_am335x_xbar_route_allocate()
112 map->mux_val = (u8)dma_spec->args[2]; in ti_am335x_xbar_route_allocate()
114 dma_spec->args[2] = 0; in ti_am335x_xbar_route_allocate()
115 dma_spec->args_count = 2; in ti_am335x_xbar_route_allocate()
117 dev_dbg(&pdev->dev, "Mapping XBAR event%u to DMA%u\n", in ti_am335x_xbar_route_allocate()
118 map->mux_val, map->dma_line); in ti_am335x_xbar_route_allocate()
120 ti_am335x_xbar_write(xbar->iomem, map->dma_line, map->mux_val); in ti_am335x_xbar_route_allocate()
126 { .compatible = "ti,edma3-tpcc", },
132 struct device_node *node = pdev->dev.of_node; in ti_am335x_xbar_probe()
140 return -ENODEV; in ti_am335x_xbar_probe()
142 xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL); in ti_am335x_xbar_probe()
144 return -ENOMEM; in ti_am335x_xbar_probe()
146 dma_node = of_parse_phandle(node, "dma-masters", 0); in ti_am335x_xbar_probe()
148 dev_err(&pdev->dev, "Can't get DMA master node\n"); in ti_am335x_xbar_probe()
149 return -ENODEV; in ti_am335x_xbar_probe()
154 dev_err(&pdev->dev, "DMA master is not supported\n"); in ti_am335x_xbar_probe()
156 return -EINVAL; in ti_am335x_xbar_probe()
159 if (of_property_read_u32(dma_node, "dma-requests", in ti_am335x_xbar_probe()
160 &xbar->dma_requests)) { in ti_am335x_xbar_probe()
161 dev_info(&pdev->dev, in ti_am335x_xbar_probe()
164 xbar->dma_requests = TI_AM335X_XBAR_LINES; in ti_am335x_xbar_probe()
168 if (of_property_read_u32(node, "dma-requests", &xbar->xbar_events)) { in ti_am335x_xbar_probe()
169 dev_info(&pdev->dev, in ti_am335x_xbar_probe()
172 xbar->xbar_events = TI_AM335X_XBAR_LINES; in ti_am335x_xbar_probe()
179 xbar->iomem = iomem; in ti_am335x_xbar_probe()
181 xbar->dmarouter.dev = &pdev->dev; in ti_am335x_xbar_probe()
182 xbar->dmarouter.route_free = ti_am335x_xbar_free; in ti_am335x_xbar_probe()
187 for (i = 0; i < xbar->dma_requests; i++) in ti_am335x_xbar_probe()
188 ti_am335x_xbar_write(xbar->iomem, i, 0); in ti_am335x_xbar_probe()
191 &xbar->dmarouter); in ti_am335x_xbar_probe()
208 u32 xbar_requests; /* number of DMA requests connected to XBAR */
209 u32 dma_requests; /* number of DMA requests forwarded to DMA */
229 map->xbar_in, map->xbar_out); in ti_dra7_xbar_free()
231 ti_dra7_xbar_write(xbar->iomem, map->xbar_out, xbar->safe_val); in ti_dra7_xbar_free()
232 mutex_lock(&xbar->mutex); in ti_dra7_xbar_free()
233 clear_bit(map->xbar_out, xbar->dma_inuse); in ti_dra7_xbar_free()
234 mutex_unlock(&xbar->mutex); in ti_dra7_xbar_free()
241 struct platform_device *pdev = of_find_device_by_node(ofdma->of_node); in ti_dra7_xbar_route_allocate()
245 if (dma_spec->args[0] >= xbar->xbar_requests) { in ti_dra7_xbar_route_allocate()
246 dev_err(&pdev->dev, "Invalid XBAR request number: %d\n", in ti_dra7_xbar_route_allocate()
247 dma_spec->args[0]); in ti_dra7_xbar_route_allocate()
248 put_device(&pdev->dev); in ti_dra7_xbar_route_allocate()
249 return ERR_PTR(-EINVAL); in ti_dra7_xbar_route_allocate()
253 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); in ti_dra7_xbar_route_allocate()
254 if (!dma_spec->np) { in ti_dra7_xbar_route_allocate()
255 dev_err(&pdev->dev, "Can't get DMA master\n"); in ti_dra7_xbar_route_allocate()
256 put_device(&pdev->dev); in ti_dra7_xbar_route_allocate()
257 return ERR_PTR(-EINVAL); in ti_dra7_xbar_route_allocate()
262 of_node_put(dma_spec->np); in ti_dra7_xbar_route_allocate()
263 put_device(&pdev->dev); in ti_dra7_xbar_route_allocate()
264 return ERR_PTR(-ENOMEM); in ti_dra7_xbar_route_allocate()
267 mutex_lock(&xbar->mutex); in ti_dra7_xbar_route_allocate()
268 map->xbar_out = find_first_zero_bit(xbar->dma_inuse, in ti_dra7_xbar_route_allocate()
269 xbar->dma_requests); in ti_dra7_xbar_route_allocate()
270 if (map->xbar_out == xbar->dma_requests) { in ti_dra7_xbar_route_allocate()
271 mutex_unlock(&xbar->mutex); in ti_dra7_xbar_route_allocate()
272 dev_err(&pdev->dev, "Run out of free DMA requests\n"); in ti_dra7_xbar_route_allocate()
274 of_node_put(dma_spec->np); in ti_dra7_xbar_route_allocate()
275 put_device(&pdev->dev); in ti_dra7_xbar_route_allocate()
276 return ERR_PTR(-ENOMEM); in ti_dra7_xbar_route_allocate()
278 set_bit(map->xbar_out, xbar->dma_inuse); in ti_dra7_xbar_route_allocate()
279 mutex_unlock(&xbar->mutex); in ti_dra7_xbar_route_allocate()
281 map->xbar_in = (u16)dma_spec->args[0]; in ti_dra7_xbar_route_allocate()
283 dma_spec->args[0] = map->xbar_out + xbar->dma_offset; in ti_dra7_xbar_route_allocate()
285 dev_dbg(&pdev->dev, "Mapping XBAR%u to DMA%d\n", in ti_dra7_xbar_route_allocate()
286 map->xbar_in, map->xbar_out); in ti_dra7_xbar_route_allocate()
288 ti_dra7_xbar_write(xbar->iomem, map->xbar_out, map->xbar_in); in ti_dra7_xbar_route_allocate()
302 .compatible = "ti,omap4430-sdma",
310 .compatible = "ti,edma3-tpcc",
318 for (; len > 0; len--) in ti_dra7_xbar_reserve()
319 set_bit(offset + (len - 1), p); in ti_dra7_xbar_reserve()
324 struct device_node *node = pdev->dev.of_node; in ti_dra7_xbar_probe()
335 return -ENODEV; in ti_dra7_xbar_probe()
337 xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL); in ti_dra7_xbar_probe()
339 return -ENOMEM; in ti_dra7_xbar_probe()
341 dma_node = of_parse_phandle(node, "dma-masters", 0); in ti_dra7_xbar_probe()
343 dev_err(&pdev->dev, "Can't get DMA master node\n"); in ti_dra7_xbar_probe()
344 return -ENODEV; in ti_dra7_xbar_probe()
349 dev_err(&pdev->dev, "DMA master is not supported\n"); in ti_dra7_xbar_probe()
351 return -EINVAL; in ti_dra7_xbar_probe()
354 if (of_property_read_u32(dma_node, "dma-requests", in ti_dra7_xbar_probe()
355 &xbar->dma_requests)) { in ti_dra7_xbar_probe()
356 dev_info(&pdev->dev, in ti_dra7_xbar_probe()
359 xbar->dma_requests = TI_DRA7_XBAR_OUTPUTS; in ti_dra7_xbar_probe()
363 xbar->dma_inuse = devm_kcalloc(&pdev->dev, in ti_dra7_xbar_probe()
364 BITS_TO_LONGS(xbar->dma_requests), in ti_dra7_xbar_probe()
366 if (!xbar->dma_inuse) in ti_dra7_xbar_probe()
367 return -ENOMEM; in ti_dra7_xbar_probe()
369 if (of_property_read_u32(node, "dma-requests", &xbar->xbar_requests)) { in ti_dra7_xbar_probe()
370 dev_info(&pdev->dev, in ti_dra7_xbar_probe()
373 xbar->xbar_requests = TI_DRA7_XBAR_INPUTS; in ti_dra7_xbar_probe()
376 if (!of_property_read_u32(node, "ti,dma-safe-map", &safe_val)) in ti_dra7_xbar_probe()
377 xbar->safe_val = (u16)safe_val; in ti_dra7_xbar_probe()
380 prop = of_find_property(node, "ti,reserved-dma-request-ranges", &sz); in ti_dra7_xbar_probe()
382 const char pname[] = "ti,reserved-dma-request-ranges"; in ti_dra7_xbar_probe()
388 return -EINVAL; in ti_dra7_xbar_probe()
392 return -ENOMEM; in ti_dra7_xbar_probe()
403 xbar->dma_inuse); in ti_dra7_xbar_probe()
412 xbar->iomem = iomem; in ti_dra7_xbar_probe()
414 xbar->dmarouter.dev = &pdev->dev; in ti_dra7_xbar_probe()
415 xbar->dmarouter.route_free = ti_dra7_xbar_free; in ti_dra7_xbar_probe()
416 xbar->dma_offset = *(u32 *)match->data; in ti_dra7_xbar_probe()
418 mutex_init(&xbar->mutex); in ti_dra7_xbar_probe()
422 for (i = 0; i < xbar->dma_requests; i++) { in ti_dra7_xbar_probe()
423 if (!test_bit(i, xbar->dma_inuse)) in ti_dra7_xbar_probe()
424 ti_dra7_xbar_write(xbar->iomem, i, xbar->safe_val); in ti_dra7_xbar_probe()
428 &xbar->dmarouter); in ti_dra7_xbar_probe()
431 for (i = 0; i < xbar->dma_requests; i++) { in ti_dra7_xbar_probe()
432 if (!test_bit(i, xbar->dma_inuse)) in ti_dra7_xbar_probe()
433 ti_dra7_xbar_write(xbar->iomem, i, i); in ti_dra7_xbar_probe()
445 match = of_match_node(ti_dma_xbar_match, pdev->dev.of_node); in ti_dma_xbar_probe()
447 return -EINVAL; in ti_dma_xbar_probe()
449 switch (*(u32 *)match->data) { in ti_dma_xbar_probe()
457 dev_err(&pdev->dev, "Unsupported crossbar\n"); in ti_dma_xbar_probe()
458 ret = -ENODEV; in ti_dma_xbar_probe()
467 .name = "ti-dma-crossbar",