forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/video/rockchip/mpp/mpp_iommu.h
....@@ -13,6 +13,7 @@
1313
1414 #include <linux/iommu.h>
1515 #include <linux/dma-mapping.h>
16
+#include <linux/interrupt.h>
1617
1718 struct mpp_dma_buffer {
1819 /* link to dma session buffer list */
....@@ -64,6 +65,8 @@
6465 u32 is_paged;
6566 };
6667
68
+struct mpp_dev;
69
+
6770 struct mpp_iommu_info {
6871 struct rw_semaphore rw_sem;
6972
....@@ -73,6 +76,13 @@
7376 struct iommu_group *group;
7477 struct mpp_rk_iommu *iommu;
7578 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;
7686 };
7787
7888 struct mpp_dma_session *
....@@ -94,6 +104,9 @@
94104 struct mpp_dma_buffer *buffer);
95105 int mpp_dma_map_kernel(struct mpp_dma_session *dma,
96106 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);
97110
98111 struct mpp_iommu_info *
99112 mpp_iommu_probe(struct device *dev);
....@@ -104,6 +117,11 @@
104117
105118 int mpp_iommu_refresh(struct mpp_iommu_info *info, struct device *dev);
106119 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);
107125
108126 static inline int mpp_iommu_down_read(struct mpp_iommu_info *info)
109127 {
....@@ -137,4 +155,16 @@
137155 return 0;
138156 }
139157
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
+
140170 #endif