Mark Kettenis | 40dbf03 | 2021-10-23 16:58:01 +0200 | [diff] [blame] | 1 | #ifndef _IOMMU_H |
| 2 | #define _IOMMU_H |
| 3 | |
| 4 | struct udevice; |
| 5 | |
Mark Kettenis | dd6b68e | 2023-01-21 20:27:52 +0100 | [diff] [blame^] | 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 | |
Mark Kettenis | 40dbf03 | 2021-10-23 16:58:01 +0200 | [diff] [blame] | 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 | |
Mark Kettenis | dd6b68e | 2023-01-21 20:27:52 +0100 | [diff] [blame^] | 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 | |
Mark Kettenis | 40dbf03 | 2021-10-23 16:58:01 +0200 | [diff] [blame] | 40 | #endif |