Lines Matching +full:dma +full:- +full:mem
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
47 resource_size_t mem = 0, irq = 0; in acpi_dma_parse_resource_group() local
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()
68 if (mem == 0 && irq == 0) 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()
76 si->gsi_interrupt != irq) in acpi_dma_parse_resource_group()
79 dev_dbg(&adev->dev, "matches with %.4s%04X (rev %u)\n", in acpi_dma_parse_resource_group()
80 (char *)&grp->vendor_id, grp->device_id, grp->revision); in acpi_dma_parse_resource_group()
83 if (si->base_request_line == 0 && si->num_handshake_signals == 0) in acpi_dma_parse_resource_group()
86 /* Set up DMA mask based on value from CSRT */ in acpi_dma_parse_resource_group()
87 ret = dma_coerce_mask_and_coherent(&adev->dev, in acpi_dma_parse_resource_group()
88 DMA_BIT_MASK(si->dma_address_width)); in acpi_dma_parse_resource_group()
92 adma->base_request_line = si->base_request_line; in acpi_dma_parse_resource_group()
93 adma->end_request_line = si->base_request_line + in acpi_dma_parse_resource_group()
94 si->num_handshake_signals - 1; in acpi_dma_parse_resource_group()
96 dev_dbg(&adev->dev, "request line base: 0x%04x end: 0x%04x\n", in acpi_dma_parse_resource_group()
97 adma->base_request_line, adma->end_request_line); in acpi_dma_parse_resource_group()
103 * acpi_dma_parse_csrt - parse CSRT to exctract additional DMA resources
105 * @adma: struct acpi_dma of the given DMA controller
109 * the system DSDT table. In particular DMA controllers might be described
112 * We are using this table to get the request line range of the specific DMA
126 dev_warn(&adev->dev, "failed to get the CSRT table\n"); in acpi_dma_parse_csrt()
131 end = (struct acpi_csrt_group *)((void *)csrt + csrt->header.length); in acpi_dma_parse_csrt()
136 dev_warn(&adev->dev, in acpi_dma_parse_csrt()
141 grp = (struct acpi_csrt_group *)((void *)grp + grp->length); in acpi_dma_parse_csrt()
148 * acpi_dma_controller_register - Register a DMA controller to ACPI DMA helpers
149 * @dev: struct device of DMA controller
150 * @acpi_dma_xlate: translation function which converts a dma specifier
170 return -EINVAL; in acpi_dma_controller_register()
175 return -EINVAL; in acpi_dma_controller_register()
179 return -ENOMEM; in acpi_dma_controller_register()
181 adma->dev = dev; in acpi_dma_controller_register()
182 adma->acpi_dma_xlate = acpi_dma_xlate; in acpi_dma_controller_register()
183 adma->data = data; in acpi_dma_controller_register()
189 list_add_tail(&adma->dma_controllers, &acpi_dma_list); in acpi_dma_controller_register()
197 * acpi_dma_controller_free - Remove a DMA controller from ACPI DMA helpers list
198 * @dev: struct device of DMA controller
210 return -EINVAL; in acpi_dma_controller_free()
215 if (adma->dev == dev) { in acpi_dma_controller_free()
216 list_del(&adma->dma_controllers); in acpi_dma_controller_free()
223 return -ENODEV; in acpi_dma_controller_free()
233 * devm_acpi_dma_controller_register - resource managed acpi_dma_controller_register()
234 * @dev: device that is registering this DMA controller
238 * Managed acpi_dma_controller_register(). DMA controller registered by this
255 return -ENOMEM; in devm_acpi_dma_controller_register()
268 * devm_acpi_dma_controller_free - resource managed acpi_dma_controller_free()
269 * @dev: device that is unregistering as DMA controller
271 * Unregister a DMA controller registered with
283 * acpi_dma_update_dma_spec - prepare dma specifier to pass to translation function
284 * @adma: struct acpi_dma of DMA controller
285 * @dma_spec: dma specifier to update
287 * Accordingly to ACPI 5.0 Specification Table 6-170 "Fixed DMA Resource
289 * DMA Request Line bits is a platform-relative number uniquely
290 * identifying the request line assigned. Request line-to-Controller
291 * mapping is done in a controller-specific OS driver.
296 * 0, if no information is avaiable, -1 on mismatch, and 1 otherwise.
301 /* Set link to the DMA controller device */ in acpi_dma_update_dma_spec()
302 dma_spec->dev = adma->dev; in acpi_dma_update_dma_spec()
305 if (adma->base_request_line == 0 && adma->end_request_line == 0) in acpi_dma_update_dma_spec()
309 if (dma_spec->slave_id < adma->base_request_line || in acpi_dma_update_dma_spec()
310 dma_spec->slave_id > adma->end_request_line) in acpi_dma_update_dma_spec()
311 return -1; in acpi_dma_update_dma_spec()
317 dma_spec->slave_id -= adma->base_request_line; in acpi_dma_update_dma_spec()
329 * acpi_dma_parse_fixed_dma - Parse FixedDMA ACPI resources to a DMA specifier
337 if (res->type == ACPI_RESOURCE_TYPE_FIXED_DMA) { in acpi_dma_parse_fixed_dma()
338 struct acpi_resource_fixed_dma *dma = &res->data.fixed_dma; in acpi_dma_parse_fixed_dma() local
340 if (pdata->n++ == pdata->index) { in acpi_dma_parse_fixed_dma()
341 pdata->dma_spec.chan_id = dma->channels; in acpi_dma_parse_fixed_dma()
342 pdata->dma_spec.slave_id = dma->request_lines; in acpi_dma_parse_fixed_dma()
351 * acpi_dma_request_slave_chan_by_index - Get the DMA slave channel
352 * @dev: struct device to get DMA request from
356 * Pointer to appropriate dma channel on success or an error pointer.
374 dma_spec->chan_id = -1; in acpi_dma_request_slave_chan_by_index()
375 dma_spec->slave_id = -1; in acpi_dma_request_slave_chan_by_index()
384 if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0) in acpi_dma_request_slave_chan_by_index()
385 return ERR_PTR(-ENODEV); in acpi_dma_request_slave_chan_by_index()
397 chan = adma->acpi_dma_xlate(dma_spec, adma); in acpi_dma_request_slave_chan_by_index()
399 * Try to get a channel only from the DMA controller that in acpi_dma_request_slave_chan_by_index()
408 return chan ? chan : ERR_PTR(-EPROBE_DEFER); in acpi_dma_request_slave_chan_by_index()
413 * acpi_dma_request_slave_chan_by_name - Get the DMA slave channel
414 * @dev: struct device to get DMA request from
421 * If the device has "dma-names" property the FixedDMA descriptor indices
426 * Pointer to appropriate dma channel on success or an error pointer.
433 index = device_property_match_string(dev, "dma-names", name); in acpi_dma_request_slave_chan_by_name()
440 return ERR_PTR(-ENODEV); in acpi_dma_request_slave_chan_by_name()
443 dev_dbg(dev, "Looking for DMA channel \"%s\" at index %d...\n", name, index); in acpi_dma_request_slave_chan_by_name()
449 * acpi_dma_simple_xlate - Simple ACPI DMA engine translation helper
450 * @dma_spec: pointer to ACPI DMA specifier
451 * @adma: pointer to ACPI DMA controller data
454 * dma_spec to the DMA controller driver provided filter function.
462 struct acpi_dma_filter_info *info = adma->data; in acpi_dma_simple_xlate()
464 if (!info || !info->filter_fn) in acpi_dma_simple_xlate()
467 return dma_request_channel(info->dma_cap, info->filter_fn, dma_spec); in acpi_dma_simple_xlate()