Lines Matching +full:chan +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
24 * of_dma_find_controller - Get a DMA controller in DT DMA helpers list
37 if (ofdma->of_node == dma_spec->np) in of_dma_find_controller()
41 dma_spec->np); in of_dma_find_controller()
47 * of_dma_router_xlate - translation function for router devices
58 struct dma_chan *chan; in of_dma_router_xlate() local
65 route_data = ofdma->of_dma_route_allocate(&dma_spec_target, ofdma); in of_dma_router_xlate()
71 ofdma->dma_router->route_free(ofdma->dma_router->dev, in of_dma_router_xlate()
73 chan = ERR_PTR(-EPROBE_DEFER); in of_dma_router_xlate()
77 chan = ofdma_target->of_dma_xlate(&dma_spec_target, ofdma_target); in of_dma_router_xlate()
78 if (IS_ERR_OR_NULL(chan)) { in of_dma_router_xlate()
79 ofdma->dma_router->route_free(ofdma->dma_router->dev, in of_dma_router_xlate()
84 chan->router = ofdma->dma_router; in of_dma_router_xlate()
85 chan->route_data = route_data; in of_dma_router_xlate()
87 if (chan->device->device_router_config) in of_dma_router_xlate()
88 ret = chan->device->device_router_config(chan); in of_dma_router_xlate()
91 dma_release_channel(chan); in of_dma_router_xlate()
92 chan = ERR_PTR(ret); in of_dma_router_xlate()
98 * Need to put the node back since the ofdma->of_dma_route_allocate in of_dma_router_xlate()
102 return chan; in of_dma_router_xlate()
106 * of_dma_controller_register - Register a DMA controller to DT DMA helpers
127 return -EINVAL; in of_dma_controller_register()
132 return -ENOMEM; in of_dma_controller_register()
134 ofdma->of_node = np; in of_dma_controller_register()
135 ofdma->of_dma_xlate = of_dma_xlate; in of_dma_controller_register()
136 ofdma->of_dma_data = data; in of_dma_controller_register()
140 list_add_tail(&ofdma->of_dma_controllers, &of_dma_list); in of_dma_controller_register()
148 * of_dma_controller_free - Remove a DMA controller from DT DMA helpers list
160 if (ofdma->of_node == np) { in of_dma_controller_free()
161 list_del(&ofdma->of_dma_controllers); in of_dma_controller_free()
171 * of_dma_router_register - Register a DMA router to DT DMA helpers as a
194 return -EINVAL; in of_dma_router_register()
199 return -ENOMEM; in of_dma_router_register()
201 ofdma->of_node = np; in of_dma_router_register()
202 ofdma->of_dma_xlate = of_dma_router_xlate; in of_dma_router_register()
203 ofdma->of_dma_route_allocate = of_dma_route_allocate; in of_dma_router_register()
204 ofdma->dma_router = dma_router; in of_dma_router_register()
208 list_add_tail(&ofdma->of_dma_controllers, &of_dma_list); in of_dma_router_register()
216 * of_dma_match_channel - Check if a DMA specifier matches name
218 * @name: channel name to be matched
223 * specifiers, matches the name provided. Returns 0 if the name matches and
224 * a valid pointer to the DMA specifier is found. Otherwise returns -ENODEV.
226 static int of_dma_match_channel(struct device_node *np, const char *name, in of_dma_match_channel() argument
231 if (of_property_read_string_index(np, "dma-names", index, &s)) in of_dma_match_channel()
232 return -ENODEV; in of_dma_match_channel()
234 if (strcmp(name, s)) in of_dma_match_channel()
235 return -ENODEV; in of_dma_match_channel()
237 if (of_parse_phandle_with_args(np, "dmas", "#dma-cells", index, in of_dma_match_channel()
239 return -ENODEV; in of_dma_match_channel()
245 * of_dma_request_slave_channel - Get the DMA slave channel
247 * @name: name of desired channel
252 const char *name) in of_dma_request_slave_channel() argument
256 struct dma_chan *chan; in of_dma_request_slave_channel() local
258 int ret_no_channel = -ENODEV; in of_dma_request_slave_channel()
261 if (!np || !name) { in of_dma_request_slave_channel()
263 return ERR_PTR(-ENODEV); in of_dma_request_slave_channel()
268 return ERR_PTR(-ENODEV); in of_dma_request_slave_channel()
270 count = of_property_count_strings(np, "dma-names"); in of_dma_request_slave_channel()
272 pr_err("%s: dma-names property of node '%pOF' missing or empty\n", in of_dma_request_slave_channel()
274 return ERR_PTR(-ENODEV); in of_dma_request_slave_channel()
279 * entries with the same name in of_dma_request_slave_channel()
283 if (of_dma_match_channel(np, name, in of_dma_request_slave_channel()
292 chan = ofdma->of_dma_xlate(&dma_spec, ofdma); in of_dma_request_slave_channel()
294 ret_no_channel = -EPROBE_DEFER; in of_dma_request_slave_channel()
295 chan = NULL; in of_dma_request_slave_channel()
302 if (chan) in of_dma_request_slave_channel()
303 return chan; in of_dma_request_slave_channel()
311 * of_dma_simple_xlate - Simple DMA engine translation function
315 * A simple translation function for devices that use a 32-bit value for the
317 * Note that this translation function requires that #dma-cells is equal to 1
318 * and the argument of the dma specifier is the 32-bit filter_param. Returns
324 int count = dma_spec->args_count; in of_dma_simple_xlate()
325 struct of_dma_filter_info *info = ofdma->of_dma_data; in of_dma_simple_xlate()
327 if (!info || !info->filter_fn) in of_dma_simple_xlate()
333 return __dma_request_channel(&info->dma_cap, info->filter_fn, in of_dma_simple_xlate()
334 &dma_spec->args[0], dma_spec->np); in of_dma_simple_xlate()
339 * of_dma_xlate_by_chan_id - Translate dt property to DMA channel by channel id
345 * the #dma-cells propety of the DMA controller dt node needs to be set to 1.
354 struct dma_device *dev = ofdma->of_dma_data; in of_dma_xlate_by_chan_id()
355 struct dma_chan *chan, *candidate = NULL; in of_dma_xlate_by_chan_id() local
357 if (!dev || dma_spec->args_count != 1) in of_dma_xlate_by_chan_id()
360 list_for_each_entry(chan, &dev->channels, device_node) in of_dma_xlate_by_chan_id()
361 if (chan->chan_id == dma_spec->args[0]) { in of_dma_xlate_by_chan_id()
362 candidate = chan; in of_dma_xlate_by_chan_id()