dma-swiotlb.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Contains routines needed to support swiotlb for UniCore32.
  3. *
  4. * Copyright (C) 2010 Guan Xuetao
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #include <linux/pci.h>
  12. #include <linux/cache.h>
  13. #include <linux/module.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/swiotlb.h>
  16. #include <linux/bootmem.h>
  17. #include <asm/dma.h>
  18. static void *unicore_swiotlb_alloc_coherent(struct device *dev, size_t size,
  19. dma_addr_t *dma_handle, gfp_t flags,
  20. struct dma_attrs *attrs)
  21. {
  22. return swiotlb_alloc_coherent(dev, size, dma_handle, flags);
  23. }
  24. static void unicore_swiotlb_free_coherent(struct device *dev, size_t size,
  25. void *vaddr, dma_addr_t dma_addr,
  26. struct dma_attrs *attrs)
  27. {
  28. swiotlb_free_coherent(dev, size, vaddr, dma_addr);
  29. }
  30. struct dma_map_ops swiotlb_dma_map_ops = {
  31. .alloc = unicore_swiotlb_alloc_coherent,
  32. .free = unicore_swiotlb_free_coherent,
  33. .map_sg = swiotlb_map_sg_attrs,
  34. .unmap_sg = swiotlb_unmap_sg_attrs,
  35. .dma_supported = swiotlb_dma_supported,
  36. .map_page = swiotlb_map_page,
  37. .unmap_page = swiotlb_unmap_page,
  38. .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
  39. .sync_single_for_device = swiotlb_sync_single_for_device,
  40. .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
  41. .sync_sg_for_device = swiotlb_sync_sg_for_device,
  42. .mapping_error = swiotlb_dma_mapping_error,
  43. };
  44. EXPORT_SYMBOL(swiotlb_dma_map_ops);