1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * IOMMU driver for BCM2712
5 * Copyright (c) 2023 Raspberry Pi Ltd.
8 #ifndef _BCM2712_IOMMU_H
9 #define _BCM2712_IOMMU_H
11 #include <linux/iommu.h>
12 #include <linux/scatterlist.h>
14 struct bcm2712_iommu_cache {
16 spinlock_t hw_lock; /* to protect HW registers */
17 void __iomem *reg_base;
20 void bcm2712_iommu_cache_flush(struct bcm2712_iommu_cache *cache);
22 struct bcm2712_iommu {
24 struct iommu_device iommu;
25 struct iommu_group *group;
26 struct bcm2712_iommu_domain *domain;
28 struct sg_table *sgt; /* allocated memory for page tables */
29 u32 *tables; /* kernel mapping for page tables */
30 struct bcm2712_iommu_cache *cache;
31 spinlock_t hw_lock; /* to protect HW registers */
32 void __iomem *reg_base;
33 u64 dma_iova_offset; /* Hack for IOMMU attached to PCIe RC */
36 unsigned int nmapped_pages;
37 bool dirty; /* true when tables are oriented towards CPU */
40 struct bcm2712_iommu_domain {
41 struct iommu_domain base;
42 struct bcm2712_iommu *mmu;