Lines Matching +full:controller +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0-only
3 * ACPI helpers for DMA request / controller
5 * Based on of-dma.c
13 #include <linux/dma-mapping.h>
29 * acpi_dma_parse_resource_group - match device and parse resource group
32 * @adma: struct acpi_dma of the given DMA controller
50 if (grp->shared_info_length != sizeof(struct acpi_csrt_shared_info)) in acpi_dma_parse_resource_group()
51 return -ENODEV; in acpi_dma_parse_resource_group()
59 if (resource_type(rentry->res) == IORESOURCE_MEM) in acpi_dma_parse_resource_group()
60 mem = rentry->res->start; in acpi_dma_parse_resource_group()
61 else if (resource_type(rentry->res) == IORESOURCE_IRQ) in acpi_dma_parse_resource_group()
62 irq = rentry->res->start; in acpi_dma_parse_resource_group()
74 if (si->mmio_base_low != lower_32_bits(mem) || in acpi_dma_parse_resource_group()
75 si->mmio_base_high != upper_32_bits(mem)) in acpi_dma_parse_resource_group()
83 ret = acpi_register_gsi(NULL, si->gsi_interrupt, si->interrupt_mode, si->interrupt_polarity); in acpi_dma_parse_resource_group()
91 dev_dbg(&adev->dev, "matches with %.4s%04X (rev %u)\n", in acpi_dma_parse_resource_group()
92 (char *)&grp->vendor_id, grp->device_id, grp->revision); in acpi_dma_parse_resource_group()
95 if (si->base_request_line == 0 && si->num_handshake_signals == 0) in acpi_dma_parse_resource_group()
99 ret = dma_coerce_mask_and_coherent(&adev->dev, in acpi_dma_parse_resource_group()
100 DMA_BIT_MASK(si->dma_address_width)); in acpi_dma_parse_resource_group()
104 adma->base_request_line = si->base_request_line; in acpi_dma_parse_resource_group()
105 adma->end_request_line = si->base_request_line + in acpi_dma_parse_resource_group()
106 si->num_handshake_signals - 1; in acpi_dma_parse_resource_group()
108 dev_dbg(&adev->dev, "request line base: 0x%04x end: 0x%04x\n", in acpi_dma_parse_resource_group()
109 adma->base_request_line, adma->end_request_line); in acpi_dma_parse_resource_group()
115 * acpi_dma_parse_csrt - parse CSRT to extract additional DMA resources
117 * @adma: struct acpi_dma of the given DMA controller
125 * controller to be used later.
138 dev_warn(&adev->dev, "failed to get the CSRT table\n"); in acpi_dma_parse_csrt()
143 end = (struct acpi_csrt_group *)((void *)csrt + csrt->header.length); in acpi_dma_parse_csrt()
148 dev_warn(&adev->dev, in acpi_dma_parse_csrt()
153 grp = (struct acpi_csrt_group *)((void *)grp + grp->length); in acpi_dma_parse_csrt()
160 * acpi_dma_controller_register - Register a DMA controller to ACPI DMA helpers
161 * @dev: struct device of DMA controller
164 * @data: pointer to controller specific data to be used by
176 void *data) in acpi_dma_controller_register() argument
182 return -EINVAL; in acpi_dma_controller_register()
187 return -EINVAL; in acpi_dma_controller_register()
191 return -ENOMEM; in acpi_dma_controller_register()
193 adma->dev = dev; in acpi_dma_controller_register()
194 adma->acpi_dma_xlate = acpi_dma_xlate; in acpi_dma_controller_register()
195 adma->data = data; in acpi_dma_controller_register()
199 /* Now queue acpi_dma controller structure in list */ in acpi_dma_controller_register()
201 list_add_tail(&adma->dma_controllers, &acpi_dma_list); in acpi_dma_controller_register()
209 * acpi_dma_controller_free - Remove a DMA controller from ACPI DMA helpers list
210 * @dev: struct device of DMA controller
222 return -EINVAL; in acpi_dma_controller_free()
227 if (adma->dev == dev) { in acpi_dma_controller_free()
228 list_del(&adma->dma_controllers); in acpi_dma_controller_free()
235 return -ENODEV; in acpi_dma_controller_free()
245 * devm_acpi_dma_controller_register - resource managed acpi_dma_controller_register()
246 * @dev: device that is registering this DMA controller
248 * @data: pointer to controller specific data
250 * Managed acpi_dma_controller_register(). DMA controller registered by this
260 void *data) in devm_acpi_dma_controller_register() argument
267 return -ENOMEM; in devm_acpi_dma_controller_register()
269 ret = acpi_dma_controller_register(dev, acpi_dma_xlate, data); in devm_acpi_dma_controller_register()
280 * devm_acpi_dma_controller_free - resource managed acpi_dma_controller_free()
281 * @dev: device that is unregistering as DMA controller
283 * Unregister a DMA controller registered with
295 * acpi_dma_update_dma_spec - prepare dma specifier to pass to translation function
296 * @adma: struct acpi_dma of DMA controller
299 * Accordingly to ACPI 5.0 Specification Table 6-170 "Fixed DMA Resource
301 * DMA Request Line bits is a platform-relative number uniquely
302 * identifying the request line assigned. Request line-to-Controller
303 * mapping is done in a controller-specific OS driver.
304 * That's why we can safely adjust slave_id when the appropriate controller is
308 * 0, if no information is available, -1 on mismatch, and 1 otherwise.
313 /* Set link to the DMA controller device */ in acpi_dma_update_dma_spec()
314 dma_spec->dev = adma->dev; in acpi_dma_update_dma_spec()
317 if (adma->base_request_line == 0 && adma->end_request_line == 0) in acpi_dma_update_dma_spec()
321 if (dma_spec->slave_id < adma->base_request_line || in acpi_dma_update_dma_spec()
322 dma_spec->slave_id > adma->end_request_line) in acpi_dma_update_dma_spec()
323 return -1; in acpi_dma_update_dma_spec()
329 dma_spec->slave_id -= adma->base_request_line; in acpi_dma_update_dma_spec()
341 * acpi_dma_parse_fixed_dma - Parse FixedDMA ACPI resources to a DMA specifier
343 * @data: pointer to a helper struct acpi_dma_parser_data
345 static int acpi_dma_parse_fixed_dma(struct acpi_resource *res, void *data) in acpi_dma_parse_fixed_dma() argument
347 struct acpi_dma_parser_data *pdata = data; in acpi_dma_parse_fixed_dma()
349 if (res->type == ACPI_RESOURCE_TYPE_FIXED_DMA) { in acpi_dma_parse_fixed_dma()
350 struct acpi_resource_fixed_dma *dma = &res->data.fixed_dma; in acpi_dma_parse_fixed_dma()
352 if (pdata->n++ == pdata->index) { in acpi_dma_parse_fixed_dma()
353 pdata->dma_spec.chan_id = dma->channels; in acpi_dma_parse_fixed_dma()
354 pdata->dma_spec.slave_id = dma->request_lines; in acpi_dma_parse_fixed_dma()
363 * acpi_dma_request_slave_chan_by_index - Get the DMA slave channel
386 dma_spec->chan_id = -1; in acpi_dma_request_slave_chan_by_index()
387 dma_spec->slave_id = -1; in acpi_dma_request_slave_chan_by_index()
396 if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0) in acpi_dma_request_slave_chan_by_index()
397 return ERR_PTR(-ENODEV); in acpi_dma_request_slave_chan_by_index()
409 chan = adma->acpi_dma_xlate(dma_spec, adma); in acpi_dma_request_slave_chan_by_index()
411 * Try to get a channel only from the DMA controller that in acpi_dma_request_slave_chan_by_index()
420 return chan ? chan : ERR_PTR(-EPROBE_DEFER); in acpi_dma_request_slave_chan_by_index()
425 * acpi_dma_request_slave_chan_by_name - Get the DMA slave channel
433 * If the device has "dma-names" property the FixedDMA descriptor indices
445 index = device_property_match_string(dev, "dma-names", name); in acpi_dma_request_slave_chan_by_name()
452 return ERR_PTR(-ENODEV); in acpi_dma_request_slave_chan_by_name()
461 * acpi_dma_simple_xlate - Simple ACPI DMA engine translation helper
463 * @adma: pointer to ACPI DMA controller data
466 * dma_spec to the DMA controller driver provided filter function.
474 struct acpi_dma_filter_info *info = adma->data; in acpi_dma_simple_xlate()
476 if (!info || !info->filter_fn) in acpi_dma_simple_xlate()
479 return dma_request_channel(info->dma_cap, info->filter_fn, dma_spec); in acpi_dma_simple_xlate()