xref: /linux/arch/mips/include/asm/dma-mapping.h (revision f3a8b6645dc2e60d11f20c1c23afd964ff4e55ae)
1 #ifndef _ASM_DMA_MAPPING_H
2 #define _ASM_DMA_MAPPING_H
3 
4 #include <linux/scatterlist.h>
5 #include <asm/dma-coherence.h>
6 #include <asm/cache.h>
7 
8 #ifndef CONFIG_SGI_IP27 /* Kludge to fix 2.6.39 build for IP27 */
9 #include <dma-coherence.h>
10 #endif
11 
12 extern struct dma_map_ops *mips_dma_map_ops;
13 
14 static inline struct dma_map_ops *get_dma_ops(struct device *dev)
15 {
16 	if (dev && dev->archdata.dma_ops)
17 		return dev->archdata.dma_ops;
18 	else
19 		return mips_dma_map_ops;
20 }
21 
22 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
23 {
24 	if (!dev->dma_mask)
25 		return false;
26 
27 	return addr + size <= *dev->dma_mask;
28 }
29 
30 static inline void dma_mark_clean(void *addr, size_t size) {}
31 
32 extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
33 	       enum dma_data_direction direction);
34 
35 #define arch_setup_dma_ops arch_setup_dma_ops
36 static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
37 				      u64 size, const struct iommu_ops *iommu,
38 				      bool coherent)
39 {
40 #ifdef CONFIG_DMA_PERDEV_COHERENT
41 	dev->archdata.dma_coherent = coherent;
42 #endif
43 }
44 
45 #endif /* _ASM_DMA_MAPPING_H */
46