forked from Minki/linux
38e4fb6672
If PCI enumerated controller has a companion device, register it in the ACPI DMA controllers as well. Fixes:f7c799e950
("dmaengine: dw: we do support Merrifield SoC in PCI mode") Depends-on:b685fe26e9
("dmaengine: dw: platform: Split ACPI helpers to separate module") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200526182416.52805-1-andriy.shevchenko@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (C) 2013,2019 Intel Corporation
|
|
|
|
#include <linux/acpi.h>
|
|
#include <linux/acpi_dma.h>
|
|
|
|
#include "internal.h"
|
|
|
|
static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param)
|
|
{
|
|
struct acpi_dma_spec *dma_spec = param;
|
|
struct dw_dma_slave slave = {
|
|
.dma_dev = dma_spec->dev,
|
|
.src_id = dma_spec->slave_id,
|
|
.dst_id = dma_spec->slave_id,
|
|
.m_master = 0,
|
|
.p_master = 1,
|
|
};
|
|
|
|
return dw_dma_filter(chan, &slave);
|
|
}
|
|
|
|
void dw_dma_acpi_controller_register(struct dw_dma *dw)
|
|
{
|
|
struct device *dev = dw->dma.dev;
|
|
struct acpi_dma_filter_info *info;
|
|
int ret;
|
|
|
|
if (!has_acpi_companion(dev))
|
|
return;
|
|
|
|
info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
|
|
if (!info)
|
|
return;
|
|
|
|
dma_cap_zero(info->dma_cap);
|
|
dma_cap_set(DMA_SLAVE, info->dma_cap);
|
|
info->filter_fn = dw_dma_acpi_filter;
|
|
|
|
ret = acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info);
|
|
if (ret)
|
|
dev_err(dev, "could not register acpi_dma_controller\n");
|
|
}
|
|
EXPORT_SYMBOL_GPL(dw_dma_acpi_controller_register);
|
|
|
|
void dw_dma_acpi_controller_free(struct dw_dma *dw)
|
|
{
|
|
struct device *dev = dw->dma.dev;
|
|
|
|
if (!has_acpi_companion(dev))
|
|
return;
|
|
|
|
acpi_dma_controller_free(dev);
|
|
}
|
|
EXPORT_SYMBOL_GPL(dw_dma_acpi_controller_free);
|