blob: cf9719c5e91c182fb2aa2be45c84f1d6d92341e8 [file] [log] [blame]
Mark Kettenise1311b62021-10-23 16:58:01 +02001#ifndef _IOMMU_H
2#define _IOMMU_H
3
4struct udevice;
5
Mark Kettenis1c653ac2023-01-21 20:27:52 +01006struct 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
Mark Kettenise1311b62021-10-23 16:58:01 +020027#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) && \
28 CONFIG_IS_ENABLED(IOMMU)
29int dev_iommu_enable(struct udevice *dev);
30#else
31static inline int dev_iommu_enable(struct udevice *dev)
32{
33 return 0;
34}
35#endif
36
Mark Kettenis1c653ac2023-01-21 20:27:52 +010037dma_addr_t dev_iommu_dma_map(struct udevice *dev, void *addr, size_t size);
38void dev_iommu_dma_unmap(struct udevice *dev, dma_addr_t addr, size_t size);
39
Mark Kettenise1311b62021-10-23 16:58:01 +020040#endif