blob: b8ba0b8e707795c375be123d13b319eab0a60408 [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 /**
Caleb Connolly5cac4b82023-12-11 18:41:41 +00008 * init() - Connect a device to it's IOMMU, called before probe()
9 * The iommu device can be fetched through dev->iommu
10 *
11 * @iommu_dev: IOMMU device
12 * @dev: Device to connect
13 * @return 0 if OK, -errno on error
14 */
15 int (*connect)(struct udevice *dev);
16 /**
Mark Kettenis1c653ac2023-01-21 20:27:52 +010017 * map() - map DMA memory
18 *
19 * @dev: device for which to map DMA memory
20 * @addr: CPU address of the memory
21 * @size: size of the memory
22 * @return DMA address for the device
23 */
24 dma_addr_t (*map)(struct udevice *dev, void *addr, size_t size);
25
26 /**
27 * unmap() - unmap DMA memory
28 *
29 * @dev: device for which to unmap DMA memory
30 * @addr: DMA address of the memory
31 * @size: size of the memory
32 */
33 void (*unmap)(struct udevice *dev, dma_addr_t addr, size_t size);
34};
35
Mark Kettenise1311b62021-10-23 16:58:01 +020036#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) && \
37 CONFIG_IS_ENABLED(IOMMU)
38int dev_iommu_enable(struct udevice *dev);
39#else
40static inline int dev_iommu_enable(struct udevice *dev)
41{
42 return 0;
43}
44#endif
45
Mark Kettenis1c653ac2023-01-21 20:27:52 +010046dma_addr_t dev_iommu_dma_map(struct udevice *dev, void *addr, size_t size);
47void dev_iommu_dma_unmap(struct udevice *dev, dma_addr_t addr, size_t size);
48
Mark Kettenise1311b62021-10-23 16:58:01 +020049#endif