Skip to content

Commit 3f4232e

Browse files
westerirafaeljw
authored andcommitted
acpi-dma: Add support for "dma-names" device property
The current implementation hard codes the two supported channels so that "tx" is always 0 and "rx" is always 1. This is because there has been no suitable way in ACPI to name resources. With _DSD device properties we can finally do this: Device (SPI1) { Name (_CRS, ResourceTemplate () { ... FixedDMA (0x0000, 0x0000, Width32bit) FixedDMA (0x0001, 0x0001, Width32bit) }) Name (_DSD, Package () { ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package () { Package () {"dma-names", Package () {"tx", "rx"}} }, }) } The names "tx" and "rx" now provide index of the FixedDMA resource in question. Modify acpi_dma_request_slave_chan_by_name() so that it looks for "dma-names" property first and only then fall back using hardcoded indices. The DT "dma-names" binding that we reuse for ACPI is documented in Documentation/devicetree/bindings/dma/dma.txt. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 3f5c8d3 commit 3f4232e

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

drivers/dma/acpi-dma.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/ioport.h>
2222
#include <linux/acpi.h>
2323
#include <linux/acpi_dma.h>
24+
#include <linux/property.h>
2425

2526
static LIST_HEAD(acpi_dma_list);
2627
static DEFINE_MUTEX(acpi_dma_lock);
@@ -413,21 +414,29 @@ EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_index);
413414
* translate the names "tx" and "rx" here based on the most common case where
414415
* the first FixedDMA descriptor is TX and second is RX.
415416
*
417+
* If the device has "dma-names" property the FixedDMA descriptor indices
418+
* are retrieved based on those. Otherwise the function falls back using
419+
* hardcoded indices.
420+
*
416421
* Return:
417422
* Pointer to appropriate dma channel on success or an error pointer.
418423
*/
419424
struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
420425
const char *name)
421426
{
422-
size_t index;
423-
424-
if (!strcmp(name, "tx"))
425-
index = 0;
426-
else if (!strcmp(name, "rx"))
427-
index = 1;
428-
else
429-
return ERR_PTR(-ENODEV);
427+
int index;
428+
429+
index = device_property_match_string(dev, "dma-names", name);
430+
if (index < 0) {
431+
if (!strcmp(name, "tx"))
432+
index = 0;
433+
else if (!strcmp(name, "rx"))
434+
index = 1;
435+
else
436+
return ERR_PTR(-ENODEV);
437+
}
430438

439+
dev_dbg(dev, "found DMA channel \"%s\" at index %d\n", name, index);
431440
return acpi_dma_request_slave_chan_by_index(dev, index);
432441
}
433442
EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_name);

0 commit comments

Comments
 (0)