blob: aba71385f9d15afcbdd82262df9b905c69ef9c22 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASM_DMA_MAPPING_H
2#define _ASM_DMA_MAPPING_H
3
Christoph Hellwig84be4562015-05-01 12:46:15 +02004#include <linux/scatterlist.h>
Steven J. Hillb6d92b42013-03-25 13:47:29 -05005#include <asm/dma-coherence.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <asm/cache.h>
7
Ralf Baechle70342282013-01-22 12:59:30 +01008#ifndef CONFIG_SGI_IP27 /* Kludge to fix 2.6.39 build for IP27 */
David Daney48e1fd52010-10-01 13:27:32 -07009#include <dma-coherence.h>
Ralf Baechlea5602a32011-05-18 13:14:36 +010010#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Bart Van Assche52997092017-01-20 13:04:01 -080012extern const struct dma_map_ops *mips_dma_map_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Bart Van Assche815dd182017-01-20 13:04:04 -080014static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
Atsushi Nemoto4f29c052009-01-23 00:42:11 +090015{
Bart Van Assche815dd182017-01-20 13:04:04 -080016 return mips_dma_map_ops;
Atsushi Nemoto4f29c052009-01-23 00:42:11 +090017}
18
David Daney48e1fd52010-10-01 13:27:32 -070019static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
20{
21 if (!dev->dma_mask)
Joe Perches3db27422015-03-30 16:46:03 -070022 return false;
David Daney48e1fd52010-10-01 13:27:32 -070023
24 return addr + size <= *dev->dma_mask;
25}
26
27static inline void dma_mark_clean(void *addr, size_t size) {}
28
Ralf Baechled3fa72e2006-12-06 20:38:56 -080029extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 enum dma_data_direction direction);
31
Paul Burton20d33062016-10-05 18:18:16 +010032#define arch_setup_dma_ops arch_setup_dma_ops
33static 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#endif /* _ASM_DMA_MAPPING_H */