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 | /** |
Caleb Connolly | 76c53da | 2023-12-11 18:41:41 +0000 | [diff] [blame] | 8 | * 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 Kettenis | dd6b68e | 2023-01-21 20:27:52 +0100 | [diff] [blame] | 17 | * 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 Kettenis | 40dbf03 | 2021-10-23 16:58:01 +0200 | [diff] [blame] | 36 | #if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) && \ |
| 37 | CONFIG_IS_ENABLED(IOMMU) |
| 38 | int dev_iommu_enable(struct udevice *dev); |
| 39 | #else |
| 40 | static inline int dev_iommu_enable(struct udevice *dev) |
| 41 | { |
| 42 | return 0; |
| 43 | } |
| 44 | #endif |
| 45 | |
Mark Kettenis | dd6b68e | 2023-01-21 20:27:52 +0100 | [diff] [blame] | 46 | dma_addr_t dev_iommu_dma_map(struct udevice *dev, void *addr, size_t size); |
| 47 | void dev_iommu_dma_unmap(struct udevice *dev, dma_addr_t addr, size_t size); |
| 48 | |
Mark Kettenis | 40dbf03 | 2021-10-23 16:58:01 +0200 | [diff] [blame] | 49 | #endif |