2 * Data structure definition for Rockchip IOMMU driver
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 #ifndef __ASM_PLAT_IOMMU_H
9 #define __ASM_PLAT_IOMMU_H
11 #include <linux/kernel.h>
12 #include <linux/spinlock.h>
13 #include <linux/list.h>
14 #include <linux/device.h>
15 #include <linux/platform_device.h>
16 #include <linux/genalloc.h>
17 #include <linux/iommu.h>
19 #include <linux/rockchip-iovmm.h>
23 struct iommu_domain *domain; /* iommu domain for this iovmm */
24 struct gen_pool *vmm_pool;
25 struct list_head regions_list; /* list of rk_vm_region */
26 spinlock_t lock; /* lock for updating regions_list */
29 struct iommu_drvdata {
30 struct list_head node; /* entry of rk_iommu_domain.clients */
31 struct device *iommu; /* IOMMU's device descriptor */
32 struct device *dev; /* Owner of IOMMU */
36 void __iomem **res_bases;
39 struct iommu_domain *domain; /* domain given to iommu_attach_device() */
40 rockchip_iommu_fault_handler_t fault_handler;
41 unsigned long pgtable;
45 #ifdef CONFIG_ROCKCHIP_IOVMM
47 #define IOVA_START 0x10000000
48 #define IOVM_SIZE (SZ_1G - SZ_4K) /* last 4K is for error values */
51 struct list_head node;
56 static inline struct rk_iovmm *rockchip_get_iovmm(struct device *dev)
58 struct iommu_drvdata *data = dev_get_drvdata(dev->archdata.iommu);
60 BUG_ON(!dev->archdata.iommu || !data);
65 int rockchip_init_iovmm(struct device *iommu, struct rk_iovmm *vmm);
67 static inline int rockchip_init_iovmm(struct device *iommu,
75 #ifdef CONFIG_ROCKCHIP_IOMMU
78 * rockchip_iommu_disable() - disable iommu mmu of ip
79 * @owner: The device whose IOMMU is about to be disabled.
81 * This function disable iommu to transfer address
82 * from virtual address to physical address
84 bool rockchip_iommu_disable(struct device *owner);
87 * rockchip_iommu_tlb_invalidate() - flush all TLB entry in iommu
88 * @owner: The device whose IOMMU.
90 * This function flush all TLB entry in iommu
92 void rockchip_iommu_tlb_invalidate(struct device *owner);
94 #else /* CONFIG_ROCKCHIP_IOMMU */
95 static inline bool rockchip_iommu_disable(struct device *owner)
99 static inline void rockchip_iommu_tlb_invalidate(struct device *owner)
106 #endif /*__ASM_PLAT_IOMMU_H*/