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 {
27 IOMMU_PAGEFAULT,
28 IOMMU_BUSERROR,
29 IOMMU_FAULT_UNKNOWN,
30 IOMMU_FAULTS_NUM
31 };
32
33 struct iommu_drvdata;
34
35 /*
36 * @itype: type of fault.
37 * @pgtable_base: the physical address of page table base. This is 0 if @itype
38 * is IOMMU_BUSERROR.
39 * @fault_addr: the device (virtual) address that the System MMU tried to
40 * translated. This is 0 if @itype is IOMMU_BUSERROR.
41 */
42 typedef int (*rockchip_iommu_fault_handler_t)(struct device *dev,
43 enum rk_iommu_inttype itype,
44 unsigned long pgtable_base,
45 unsigned long fault_addr,
46 unsigned int statu
47 );
48
49
50 struct scatterlist;
51 struct device;
52
rockchip_iovmm_activate(struct device * dev)53 static inline int rockchip_iovmm_activate(struct device *dev)
54 {
55 return -ENOSYS;
56 }
57
rockchip_iovmm_deactivate(struct device * dev)58 static inline void rockchip_iovmm_deactivate(struct device *dev)
59 {
60 }
61
rockchip_iovmm_map(struct device * dev,struct scatterlist * sg,off_t offset,size_t size)62 static inline dma_addr_t rockchip_iovmm_map(struct device *dev,
63 struct scatterlist *sg, off_t offset, size_t size)
64 {
65 return -ENOSYS;
66 }
67
rockchip_iovmm_unmap(struct device * dev,dma_addr_t iova)68 static inline void rockchip_iovmm_unmap(struct device *dev, dma_addr_t iova)
69 {
70 }
71
rockchip_iovmm_map_oto(struct device * dev,phys_addr_t phys,size_t size)72 static inline int rockchip_iovmm_map_oto(struct device *dev, phys_addr_t phys,
73 size_t size)
74 {
75 return -ENOSYS;
76 }
77
rockchip_iovmm_unmap_oto(struct device * dev,phys_addr_t phys)78 static inline void rockchip_iovmm_unmap_oto(struct device *dev, phys_addr_t phys)
79 {
80 }
81
rockchip_iovmm_set_fault_handler(struct device * dev,rockchip_iommu_fault_handler_t handler)82 static inline void rockchip_iovmm_set_fault_handler(struct device *dev,
83 rockchip_iommu_fault_handler_t handler)
84 {
85 }
rockchip_iovmm_invalidate_tlb(struct device * dev)86 static inline int rockchip_iovmm_invalidate_tlb(struct device *dev)
87 {
88 return -ENOSYS;
89 }
90
91 #endif /*__ASM_PLAT_IOVMM_H*/
92