dma.c 581 B

12345678910111213141516171819202122232425
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  4. */
  5. #include <linux/acpi.h>
  6. #include <linux/dma-direct.h>
  7. void acpi_arch_dma_setup(struct device *dev)
  8. {
  9. int ret;
  10. u64 mask, end;
  11. const struct bus_dma_region *map = NULL;
  12. ret = acpi_dma_get_range(dev, &map);
  13. if (!ret && map) {
  14. end = dma_range_map_max(map);
  15. mask = DMA_BIT_MASK(ilog2(end) + 1);
  16. dev->bus_dma_limit = end;
  17. dev->dma_range_map = map;
  18. dev->coherent_dma_mask = min(dev->coherent_dma_mask, mask);
  19. *dev->dma_mask = min(*dev->dma_mask, mask);
  20. }
  21. }