0001
0002
0003
0004 #include <linux/acpi.h>
0005 #include <linux/acpi_dma.h>
0006
0007 #include "internal.h"
0008
0009 static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param)
0010 {
0011 struct acpi_dma_spec *dma_spec = param;
0012 struct dw_dma_slave slave = {
0013 .dma_dev = dma_spec->dev,
0014 .src_id = dma_spec->slave_id,
0015 .dst_id = dma_spec->slave_id,
0016 .m_master = 0,
0017 .p_master = 1,
0018 };
0019
0020 return dw_dma_filter(chan, &slave);
0021 }
0022
0023 void dw_dma_acpi_controller_register(struct dw_dma *dw)
0024 {
0025 struct device *dev = dw->dma.dev;
0026 struct acpi_dma_filter_info *info;
0027 int ret;
0028
0029 if (!has_acpi_companion(dev))
0030 return;
0031
0032 info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
0033 if (!info)
0034 return;
0035
0036 dma_cap_zero(info->dma_cap);
0037 dma_cap_set(DMA_SLAVE, info->dma_cap);
0038 info->filter_fn = dw_dma_acpi_filter;
0039
0040 ret = acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info);
0041 if (ret)
0042 dev_err(dev, "could not register acpi_dma_controller\n");
0043 }
0044 EXPORT_SYMBOL_GPL(dw_dma_acpi_controller_register);
0045
0046 void dw_dma_acpi_controller_free(struct dw_dma *dw)
0047 {
0048 struct device *dev = dw->dma.dev;
0049
0050 if (!has_acpi_companion(dev))
0051 return;
0052
0053 acpi_dma_controller_free(dev);
0054 }
0055 EXPORT_SYMBOL_GPL(dw_dma_acpi_controller_free);