xref: /linux/drivers/media/pci/intel/ipu6/ipu6-dma.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (C) 2013--2024 Intel Corporation */
3 
4 #ifndef IPU6_DMA_H
5 #define IPU6_DMA_H
6 
7 #include <linux/dma-map-ops.h>
8 #include <linux/dma-mapping.h>
9 #include <linux/iova.h>
10 #include <linux/iova.h>
11 #include <linux/scatterlist.h>
12 #include <linux/types.h>
13 
14 #include "ipu6-bus.h"
15 
16 struct ipu6_mmu_info;
17 
18 struct ipu6_dma_mapping {
19 	struct ipu6_mmu_info *mmu_info;
20 	struct iova_domain iovad;
21 };
22 
23 void ipu6_dma_sync_single(struct ipu6_bus_device *sys, dma_addr_t dma_handle,
24 			  size_t size);
25 void ipu6_dma_sync_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist,
26 		      int nents);
27 void ipu6_dma_sync_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt);
28 void *ipu6_dma_alloc(struct ipu6_bus_device *sys, size_t size,
29 		     dma_addr_t *dma_handle, gfp_t gfp,
30 		     unsigned long attrs);
31 void ipu6_dma_free(struct ipu6_bus_device *sys, size_t size, void *vaddr,
32 		   dma_addr_t dma_handle, unsigned long attrs);
33 int ipu6_dma_mmap(struct ipu6_bus_device *sys, struct vm_area_struct *vma,
34 		  void *addr, dma_addr_t iova, size_t size,
35 		  unsigned long attrs);
36 int ipu6_dma_map_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist,
37 		    int nents, enum dma_data_direction dir,
38 		    unsigned long attrs);
39 void ipu6_dma_unmap_sg(struct ipu6_bus_device *sys, struct scatterlist *sglist,
40 		       int nents, enum dma_data_direction dir,
41 		       unsigned long attrs);
42 int ipu6_dma_map_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
43 			 enum dma_data_direction dir, unsigned long attrs);
44 void ipu6_dma_unmap_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
45 			    enum dma_data_direction dir, unsigned long attrs);
46 int ipu6_dma_get_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
47 			 void *cpu_addr, dma_addr_t handle, size_t size,
48 			 unsigned long attrs);
49 #endif /* IPU6_DMA_H */
50