Merge tag 'u-boot-at91-2023.07-a' of https://source.denx.de/u-boot/custodians/u-boot...
[platform/kernel/u-boot.git] / include / iommu.h
1 #ifndef _IOMMU_H
2 #define _IOMMU_H
3
4 struct udevice;
5
6 struct iommu_ops {
7         /**
8          * map() - map DMA memory
9          *
10          * @dev:        device for which to map DMA memory
11          * @addr:       CPU address of the memory
12          * @size:       size of the memory
13          * @return DMA address for the device
14          */
15         dma_addr_t (*map)(struct udevice *dev, void *addr, size_t size);
16
17         /**
18          * unmap() - unmap DMA memory
19          *
20          * @dev:        device for which to unmap DMA memory
21          * @addr:       DMA address of the memory
22          * @size:       size of the memory
23          */
24         void (*unmap)(struct udevice *dev, dma_addr_t addr, size_t size);
25 };
26
27 #if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) && \
28         CONFIG_IS_ENABLED(IOMMU)
29 int dev_iommu_enable(struct udevice *dev);
30 #else
31 static inline int dev_iommu_enable(struct udevice *dev)
32 {
33         return 0;
34 }
35 #endif
36
37 dma_addr_t dev_iommu_dma_map(struct udevice *dev, void *addr, size_t size);
38 void dev_iommu_dma_unmap(struct udevice *dev, dma_addr_t addr, size_t size);
39
40 #endif