1 #ifndef _ASM_DMA_MAPPING_H
2 #define _ASM_DMA_MAPPING_H
4 #include <asm/scatterlist.h>
6 #include <asm-generic/dma-coherent.h>
8 #include <dma-coherence.h>
10 extern struct dma_map_ops *mips_dma_map_ops;
12 static inline struct dma_map_ops *get_dma_ops(struct device *dev)
14 if (dev && dev->archdata.dma_ops)
15 return dev->archdata.dma_ops;
17 return mips_dma_map_ops;
20 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
25 return addr + size <= *dev->dma_mask;
28 static inline void dma_mark_clean(void *addr, size_t size) {}
30 #include <asm-generic/dma-mapping-common.h>
32 static inline int dma_supported(struct device *dev, u64 mask)
34 struct dma_map_ops *ops = get_dma_ops(dev);
35 return ops->dma_supported(dev, mask);
38 static inline int dma_mapping_error(struct device *dev, u64 mask)
40 struct dma_map_ops *ops = get_dma_ops(dev);
41 return ops->mapping_error(dev, mask);
45 dma_set_mask(struct device *dev, u64 mask)
47 if(!dev->dma_mask || !dma_supported(dev, mask))
50 *dev->dma_mask = mask;
55 extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
56 enum dma_data_direction direction);
58 static inline void *dma_alloc_coherent(struct device *dev, size_t size,
59 dma_addr_t *dma_handle, gfp_t gfp)
62 struct dma_map_ops *ops = get_dma_ops(dev);
64 ret = ops->alloc_coherent(dev, size, dma_handle, gfp);
66 debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
71 static inline void dma_free_coherent(struct device *dev, size_t size,
72 void *vaddr, dma_addr_t dma_handle)
74 struct dma_map_ops *ops = get_dma_ops(dev);
76 ops->free_coherent(dev, size, vaddr, dma_handle);
78 debug_dma_free_coherent(dev, size, vaddr, dma_handle);
82 void *dma_alloc_noncoherent(struct device *dev, size_t size,
83 dma_addr_t *dma_handle, gfp_t flag);
85 void dma_free_noncoherent(struct device *dev, size_t size,
86 void *vaddr, dma_addr_t dma_handle);
88 #endif /* _ASM_DMA_MAPPING_H */