1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 */
6
7 #ifndef ASM_PLAT_IOVMM_H
8 #define ASM_PLAT_IOVMM_H
9
10 #include <linux/list.h>
11 #include <linux/atomic.h>
12 #include <linux/spinlock.h>
13
14 #define IEP_IOMMU_COMPATIBLE_NAME "rockchip,iep_mmu"
15 #define VIP_IOMMU_COMPATIBLE_NAME "rockchip,vip_mmu"
16 #define ISP_IOMMU_COMPATIBLE_NAME "rockchip,isp_mmu"
17 #define ISP0_IOMMU_COMPATIBLE_NAME "rockchip,isp0_mmu"
18 #define ISP1_IOMMU_COMPATIBLE_NAME "rockchip,isp1_mmu"
19 #define VOPB_IOMMU_COMPATIBLE_NAME "rockchip,vopb_mmu"
20 #define VOPL_IOMMU_COMPATIBLE_NAME "rockchip,vopl_mmu"
21 #define VOP_IOMMU_COMPATIBLE_NAME "rockchip,vop_mmu"
22 #define HEVC_IOMMU_COMPATIBLE_NAME "rockchip,hevc_mmu"
23 #define VPU_IOMMU_COMPATIBLE_NAME "rockchip,vpu_mmu"
24 #define VDEC_IOMMU_COMPATIBLE_NAME "rockchip,vdec_mmu"
25
26 enum rk_iommu_inttype { IOMMU_PAGEFAULT, IOMMU_BUSERROR, IOMMU_FAULT_UNKNOWN, IOMMU_FAULTS_NUM };
27
28 struct iommu_drvdata;
29
30 /*
31 * @itype: type of fault.
32 * @pgtable_base: the physical address of page table base. This is 0 if @itype
33 * is IOMMU_BUSERROR.
34 * @fault_addr: the device (virtual) address that the System MMU tried to
35 * translated. This is 0 if @itype is IOMMU_BUSERROR.
36 */
37 typedef int (*rockchip_iommu_fault_handler_t)(struct device *dev, enum rk_iommu_inttype itype,
38 unsigned long pgtable_base, unsigned long fault_addr, unsigned int statu);
39
40 struct scatterlist;
41 struct device;
42
rockchip_iovmm_activate(struct device *dev)43 static inline int rockchip_iovmm_activate(struct device *dev)
44 {
45 return -ENOSYS;
46 }
47
rockchip_iovmm_deactivate(struct device *dev)48 static inline void rockchip_iovmm_deactivate(struct device *dev)
49 {
50 }
51
rockchip_iovmm_map(struct device *dev, struct scatterlist *sg, off_t offset, size_t size)52 static inline dma_addr_t rockchip_iovmm_map(struct device *dev, struct scatterlist *sg, off_t offset, size_t size)
53 {
54 return -ENOSYS;
55 }
56
rockchip_iovmm_unmap(struct device *dev, dma_addr_t iova)57 static inline void rockchip_iovmm_unmap(struct device *dev, dma_addr_t iova)
58 {
59 }
60
rockchip_iovmm_map_oto(struct device *dev, phys_addr_t phys, size_t size)61 static inline int rockchip_iovmm_map_oto(struct device *dev, phys_addr_t phys, size_t size)
62 {
63 return -ENOSYS;
64 }
65
rockchip_iovmm_unmap_oto(struct device *dev, phys_addr_t phys)66 static inline void rockchip_iovmm_unmap_oto(struct device *dev, phys_addr_t phys)
67 {
68 }
69
rockchip_iovmm_set_fault_handler(struct device *dev, rockchip_iommu_fault_handler_t handler)70 static inline void rockchip_iovmm_set_fault_handler(struct device *dev, rockchip_iommu_fault_handler_t handler)
71 {
72 }
rockchip_iovmm_invalidate_tlb(struct device *dev)73 static inline int rockchip_iovmm_invalidate_tlb(struct device *dev)
74 {
75 return -ENOSYS;
76 }
77
78 #endif /* __ASM_PLAT_IOVMM_H */
79