dma-iommu.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef ASMARM_DMA_IOMMU_H
  3. #define ASMARM_DMA_IOMMU_H
  4. #ifdef __KERNEL__
  5. #include <linux/mm_types.h>
  6. #include <linux/scatterlist.h>
  7. #include <linux/dma-debug.h>
  8. #include <linux/kref.h>
  9. #define ARM_MAPPING_ERROR (~(dma_addr_t)0x0)
  10. struct dma_iommu_mapping {
  11. /* iommu specific data */
  12. struct iommu_domain *domain;
  13. unsigned long **bitmaps; /* array of bitmaps */
  14. unsigned int nr_bitmaps; /* nr of elements in array */
  15. unsigned int extensions;
  16. size_t bitmap_size; /* size of a single bitmap */
  17. size_t bits; /* per bitmap */
  18. dma_addr_t base;
  19. spinlock_t lock;
  20. struct kref kref;
  21. };
  22. struct dma_iommu_mapping *
  23. arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size);
  24. void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping);
  25. int arm_iommu_attach_device(struct device *dev,
  26. struct dma_iommu_mapping *mapping);
  27. void arm_iommu_detach_device(struct device *dev);
  28. int arm_dma_supported(struct device *dev, u64 mask);
  29. #endif /* __KERNEL__ */
  30. #endif