xref: /linux/arch/mips/include/asm/dma-mapping.h (revision c5e2bbb45d28d53d278f25068142a283a0a74f7a)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_DMA_MAPPING_H
3 #define _ASM_DMA_MAPPING_H
4 
5 #include <linux/scatterlist.h>
6 #include <asm/dma-coherence.h>
7 #include <asm/cache.h>
8 
9 #ifndef CONFIG_SGI_IP27 /* Kludge to fix 2.6.39 build for IP27 */
10 #include <dma-coherence.h>
11 #endif
12 
13 extern const struct dma_map_ops jazz_dma_ops;
14 extern const struct dma_map_ops mips_default_dma_map_ops;
15 extern const struct dma_map_ops mips_swiotlb_ops;
16 
17 static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
18 {
19 #if defined(CONFIG_MACH_JAZZ)
20 	return &jazz_dma_ops;
21 #elif defined(CONFIG_SWIOTLB)
22 	return &mips_swiotlb_ops;
23 #elif defined(CONFIG_MIPS_DMA_DEFAULT)
24 	return &mips_default_dma_map_ops;
25 #elif defined(CONFIG_DMA_NONCOHERENT_OPS)
26 	return &dma_noncoherent_ops;
27 #else
28 	return &dma_direct_ops;
29 #endif
30 }
31 
32 #define arch_setup_dma_ops arch_setup_dma_ops
33 static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
34 				      u64 size, const struct iommu_ops *iommu,
35 				      bool coherent)
36 {
37 #ifdef CONFIG_DMA_PERDEV_COHERENT
38 	dev->archdata.dma_coherent = coherent;
39 #endif
40 }
41 
42 #endif /* _ASM_DMA_MAPPING_H */
43