.. | .. |
---|
13 | 13 | |
---|
14 | 14 | #include <linux/iommu.h> |
---|
15 | 15 | #include <linux/dma-mapping.h> |
---|
| 16 | +#include <linux/interrupt.h> |
---|
16 | 17 | |
---|
17 | 18 | struct mpp_dma_buffer { |
---|
18 | 19 | /* link to dma session buffer list */ |
---|
.. | .. |
---|
64 | 65 | u32 is_paged; |
---|
65 | 66 | }; |
---|
66 | 67 | |
---|
| 68 | +struct mpp_dev; |
---|
| 69 | + |
---|
67 | 70 | struct mpp_iommu_info { |
---|
68 | 71 | struct rw_semaphore rw_sem; |
---|
69 | 72 | |
---|
.. | .. |
---|
73 | 76 | struct iommu_group *group; |
---|
74 | 77 | struct mpp_rk_iommu *iommu; |
---|
75 | 78 | iommu_fault_handler_t hdl; |
---|
| 79 | + |
---|
| 80 | + spinlock_t dev_lock; |
---|
| 81 | + struct mpp_dev *dev_active; |
---|
| 82 | + |
---|
| 83 | + u32 av1d_iommu; |
---|
| 84 | + int irq; |
---|
| 85 | + int got_irq; |
---|
76 | 86 | }; |
---|
77 | 87 | |
---|
78 | 88 | struct mpp_dma_session * |
---|
.. | .. |
---|
94 | 104 | struct mpp_dma_buffer *buffer); |
---|
95 | 105 | int mpp_dma_map_kernel(struct mpp_dma_session *dma, |
---|
96 | 106 | struct mpp_dma_buffer *buffer); |
---|
| 107 | +struct mpp_dma_buffer *mpp_dma_find_buffer_fd(struct mpp_dma_session *dma, int fd); |
---|
| 108 | +void mpp_dma_buf_sync(struct mpp_dma_buffer *buffer, u32 offset, u32 length, |
---|
| 109 | + enum dma_data_direction dir, bool for_cpu); |
---|
97 | 110 | |
---|
98 | 111 | struct mpp_iommu_info * |
---|
99 | 112 | mpp_iommu_probe(struct device *dev); |
---|
.. | .. |
---|
104 | 117 | |
---|
105 | 118 | int mpp_iommu_refresh(struct mpp_iommu_info *info, struct device *dev); |
---|
106 | 119 | int mpp_iommu_flush_tlb(struct mpp_iommu_info *info); |
---|
| 120 | +int mpp_av1_iommu_disable(struct device *dev); |
---|
| 121 | +int mpp_av1_iommu_enable(struct device *dev); |
---|
| 122 | + |
---|
| 123 | +int mpp_iommu_dev_activate(struct mpp_iommu_info *info, struct mpp_dev *dev); |
---|
| 124 | +int mpp_iommu_dev_deactivate(struct mpp_iommu_info *info, struct mpp_dev *dev); |
---|
107 | 125 | |
---|
108 | 126 | static inline int mpp_iommu_down_read(struct mpp_iommu_info *info) |
---|
109 | 127 | { |
---|
.. | .. |
---|
137 | 155 | return 0; |
---|
138 | 156 | } |
---|
139 | 157 | |
---|
| 158 | +static inline void mpp_iommu_enable_irq(struct mpp_iommu_info *info) |
---|
| 159 | +{ |
---|
| 160 | + if (info && info->got_irq) |
---|
| 161 | + enable_irq(info->irq); |
---|
| 162 | +} |
---|
| 163 | + |
---|
| 164 | +static inline void mpp_iommu_disable_irq(struct mpp_iommu_info *info) |
---|
| 165 | +{ |
---|
| 166 | + if (info && info->got_irq) |
---|
| 167 | + disable_irq(info->irq); |
---|
| 168 | +} |
---|
| 169 | + |
---|
140 | 170 | #endif |
---|