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 return ERR_PTR(-EINVAL); in ti_dra7_xbar_route_allocate()
252 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); in ti_dra7_xbar_route_allocate()
253 if (!dma_spec->np) { in ti_dra7_xbar_route_allocate()
254 dev_err(&pdev->dev, "Can't get DMA master\n"); in ti_dra7_xbar_route_allocate()
255 return ERR_PTR(-EINVAL); in ti_dra7_xbar_route_allocate()
260 of_node_put(dma_spec->np); in ti_dra7_xbar_route_allocate()
261 return ERR_PTR(-ENOMEM); in ti_dra7_xbar_route_allocate()
264 mutex_lock(&xbar->mutex); in ti_dra7_xbar_route_allocate()
265 map->xbar_out = find_first_zero_bit(xbar->dma_inuse, in ti_dra7_xbar_route_allocate()
266 xbar->dma_requests); in ti_dra7_xbar_route_allocate()
267 if (map->xbar_out == xbar->dma_requests) { in ti_dra7_xbar_route_allocate()
268 mutex_unlock(&xbar->mutex); in ti_dra7_xbar_route_allocate()
269 dev_err(&pdev->dev, "Run out of free DMA requests\n"); in ti_dra7_xbar_route_allocate()
271 return ERR_PTR(-ENOMEM); in ti_dra7_xbar_route_allocate()
273 set_bit(map->xbar_out, xbar->dma_inuse); in ti_dra7_xbar_route_allocate()
274 mutex_unlock(&xbar->mutex); in ti_dra7_xbar_route_allocate()
276 map->xbar_in = (u16)dma_spec->args[0]; in ti_dra7_xbar_route_allocate()
278 dma_spec->args[0] = map->xbar_out + xbar->dma_offset; in ti_dra7_xbar_route_allocate()
280 dev_dbg(&pdev->dev, "Mapping XBAR%u to DMA%d\n", in ti_dra7_xbar_route_allocate()
281 map->xbar_in, map->xbar_out); in ti_dra7_xbar_route_allocate()
283 ti_dra7_xbar_write(xbar->iomem, map->xbar_out, map->xbar_in); in ti_dra7_xbar_route_allocate()
297 .compatible = "ti,omap4430-sdma",
305 .compatible = "ti,edma3-tpcc",
313 for (; len > 0; len--) in ti_dra7_xbar_reserve()
314 set_bit(offset + (len - 1), p); in ti_dra7_xbar_reserve()
319 struct device_node *node = pdev->dev.of_node; in ti_dra7_xbar_probe()
330 return -ENODEV; in ti_dra7_xbar_probe()
332 xbar = devm_kzalloc(&pdev->dev, sizeof(*xbar), GFP_KERNEL); in ti_dra7_xbar_probe()
334 return -ENOMEM; in ti_dra7_xbar_probe()
336 dma_node = of_parse_phandle(node, "dma-masters", 0); in ti_dra7_xbar_probe()
338 dev_err(&pdev->dev, "Can't get DMA master node\n"); in ti_dra7_xbar_probe()
339 return -ENODEV; in ti_dra7_xbar_probe()
344 dev_err(&pdev->dev, "DMA master is not supported\n"); in ti_dra7_xbar_probe()
346 return -EINVAL; in ti_dra7_xbar_probe()
349 if (of_property_read_u32(dma_node, "dma-requests", in ti_dra7_xbar_probe()
350 &xbar->dma_requests)) { in ti_dra7_xbar_probe()
351 dev_info(&pdev->dev, in ti_dra7_xbar_probe()
354 xbar->dma_requests = TI_DRA7_XBAR_OUTPUTS; in ti_dra7_xbar_probe()
358 xbar->dma_inuse = devm_kcalloc(&pdev->dev, in ti_dra7_xbar_probe()
359 BITS_TO_LONGS(xbar->dma_requests), in ti_dra7_xbar_probe()
361 if (!xbar->dma_inuse) in ti_dra7_xbar_probe()
362 return -ENOMEM; in ti_dra7_xbar_probe()
364 if (of_property_read_u32(node, "dma-requests", &xbar->xbar_requests)) { in ti_dra7_xbar_probe()
365 dev_info(&pdev->dev, in ti_dra7_xbar_probe()
368 xbar->xbar_requests = TI_DRA7_XBAR_INPUTS; in ti_dra7_xbar_probe()
371 if (!of_property_read_u32(node, "ti,dma-safe-map", &safe_val)) in ti_dra7_xbar_probe()
372 xbar->safe_val = (u16)safe_val; in ti_dra7_xbar_probe()
375 prop = of_find_property(node, "ti,reserved-dma-request-ranges", &sz); in ti_dra7_xbar_probe()
377 const char pname[] = "ti,reserved-dma-request-ranges"; in ti_dra7_xbar_probe()
383 return -EINVAL; in ti_dra7_xbar_probe()
387 return -ENOMEM; in ti_dra7_xbar_probe()
398 xbar->dma_inuse); in ti_dra7_xbar_probe()
407 xbar->iomem = iomem; in ti_dra7_xbar_probe()
409 xbar->dmarouter.dev = &pdev->dev; in ti_dra7_xbar_probe()
410 xbar->dmarouter.route_free = ti_dra7_xbar_free; in ti_dra7_xbar_probe()
411 xbar->dma_offset = *(u32 *)match->data; in ti_dra7_xbar_probe()
413 mutex_init(&xbar->mutex); in ti_dra7_xbar_probe()
417 for (i = 0; i < xbar->dma_requests; i++) { in ti_dra7_xbar_probe()
418 if (!test_bit(i, xbar->dma_inuse)) in ti_dra7_xbar_probe()
419 ti_dra7_xbar_write(xbar->iomem, i, xbar->safe_val); in ti_dra7_xbar_probe()
423 &xbar->dmarouter); in ti_dra7_xbar_probe()
426 for (i = 0; i < xbar->dma_requests; i++) { in ti_dra7_xbar_probe()
427 if (!test_bit(i, xbar->dma_inuse)) in ti_dra7_xbar_probe()
428 ti_dra7_xbar_write(xbar->iomem, i, i); in ti_dra7_xbar_probe()
440 match = of_match_node(ti_dma_xbar_match, pdev->dev.of_node); in ti_dma_xbar_probe()
442 return -EINVAL; in ti_dma_xbar_probe()
444 switch (*(u32 *)match->data) { in ti_dma_xbar_probe()
452 dev_err(&pdev->dev, "Unsupported crossbar\n"); in ti_dma_xbar_probe()
453 ret = -ENODEV; in ti_dma_xbar_probe()
462 .name = "ti-dma-crossbar",