1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2013,2019 Intel Corporation
4 #include <linux/acpi.h>
5 #include <linux/acpi_dma.h>
9 static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param)
11 struct dw_dma *dw = to_dw_dma(chan->device);
12 struct dw_dma_chip_pdata *data = dev_get_drvdata(dw->dma.dev);
13 struct acpi_dma_spec *dma_spec = param;
14 struct dw_dma_slave slave = {
15 .dma_dev = dma_spec->dev,
16 .src_id = dma_spec->slave_id,
17 .dst_id = dma_spec->slave_id,
18 .m_master = data->m_master,
19 .p_master = data->p_master,
22 return dw_dma_filter(chan, &slave);
25 void dw_dma_acpi_controller_register(struct dw_dma *dw)
27 struct device *dev = dw->dma.dev;
28 struct acpi_dma_filter_info *info;
31 if (!has_acpi_companion(dev))
34 info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
38 dma_cap_zero(info->dma_cap);
39 dma_cap_set(DMA_SLAVE, info->dma_cap);
40 info->filter_fn = dw_dma_acpi_filter;
42 ret = acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info);
44 dev_err(dev, "could not register acpi_dma_controller\n");
46 EXPORT_SYMBOL_GPL(dw_dma_acpi_controller_register);
48 void dw_dma_acpi_controller_free(struct dw_dma *dw)
50 struct device *dev = dw->dma.dev;
52 if (!has_acpi_companion(dev))
55 acpi_dma_controller_free(dev);
57 EXPORT_SYMBOL_GPL(dw_dma_acpi_controller_free);