blob: e81c4e97ff1a28f47ef337069b22518bdce933ca [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _ASM_DMA_MAPPING_H
3#define _ASM_DMA_MAPPING_H
4
Christoph Hellwiga9999332018-07-27 19:26:06 +02005#include <linux/swiotlb.h>
6
Christoph Hellwigc5e2bbb2018-06-15 13:08:50 +02007extern const struct dma_map_ops jazz_dma_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Bart Van Assche815dd182017-01-20 13:04:04 -08009static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
Atsushi Nemoto4f29c052009-01-23 00:42:11 +090010{
Christoph Hellwigc5e2bbb2018-06-15 13:08:50 +020011#if defined(CONFIG_MACH_JAZZ)
12 return &jazz_dma_ops;
13#elif defined(CONFIG_SWIOTLB)
Christoph Hellwiga9999332018-07-27 19:26:06 +020014 return &swiotlb_dma_ops;
Christoph Hellwigf8c55dc2018-06-15 13:08:46 +020015#elif defined(CONFIG_DMA_NONCOHERENT_OPS)
16 return &dma_noncoherent_ops;
Christoph Hellwig3369ddb2018-06-15 13:08:38 +020017#else
Christoph Hellwigdffbfde2018-06-15 13:08:43 +020018 return &dma_direct_ops;
Christoph Hellwigf6d302e2018-06-15 13:08:36 +020019#endif
Atsushi Nemoto4f29c052009-01-23 00:42:11 +090020}
21
Paul Burton20d33062016-10-05 18:18:16 +010022#define arch_setup_dma_ops arch_setup_dma_ops
23static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
24 u64 size, const struct iommu_ops *iommu,
25 bool coherent)
26{
27#ifdef CONFIG_DMA_PERDEV_COHERENT
28 dev->archdata.dma_coherent = coherent;
29#endif
30}
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#endif /* _ASM_DMA_MAPPING_H */