acpi.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (C) 2013,2019 Intel Corporation
  3. #include <linux/acpi.h>
  4. #include <linux/acpi_dma.h>
  5. #include "internal.h"
  6. static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param)
  7. {
  8. struct acpi_dma_spec *dma_spec = param;
  9. struct dw_dma_slave slave = {
  10. .dma_dev = dma_spec->dev,
  11. .src_id = dma_spec->slave_id,
  12. .dst_id = dma_spec->slave_id,
  13. .m_master = 0,
  14. .p_master = 1,
  15. };
  16. return dw_dma_filter(chan, &slave);
  17. }
  18. void dw_dma_acpi_controller_register(struct dw_dma *dw)
  19. {
  20. struct device *dev = dw->dma.dev;
  21. struct acpi_dma_filter_info *info;
  22. int ret;
  23. if (!has_acpi_companion(dev))
  24. return;
  25. info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
  26. if (!info)
  27. return;
  28. dma_cap_zero(info->dma_cap);
  29. dma_cap_set(DMA_SLAVE, info->dma_cap);
  30. info->filter_fn = dw_dma_acpi_filter;
  31. ret = acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info);
  32. if (ret)
  33. dev_err(dev, "could not register acpi_dma_controller\n");
  34. }
  35. EXPORT_SYMBOL_GPL(dw_dma_acpi_controller_register);
  36. void dw_dma_acpi_controller_free(struct dw_dma *dw)
  37. {
  38. struct device *dev = dw->dma.dev;
  39. if (!has_acpi_companion(dev))
  40. return;
  41. acpi_dma_controller_free(dev);
  42. }
  43. EXPORT_SYMBOL_GPL(dw_dma_acpi_controller_free);