blob: 69cc627779f25ffa5c01f226f65adcd29be8a193 [file] [log] [blame]
Sam Ravnborga439fe52008-07-27 23:00:59 +02001#ifndef ___ASM_SPARC_DMA_MAPPING_H
2#define ___ASM_SPARC_DMA_MAPPING_H
FUJITA Tomonorid6986412009-05-14 16:23:11 +00003
4#include <linux/scatterlist.h>
5#include <linux/mm.h>
FUJITA Tomonori02f7a182009-08-10 11:53:13 +09006#include <linux/dma-debug.h>
FUJITA Tomonorib9f69f42009-05-14 16:23:08 +00007
8#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
9
Christoph Hellwigee196372015-09-09 15:39:49 -070010#define HAVE_ARCH_DMA_SUPPORTED 1
Sam Ravnborgf05a6862014-05-16 23:25:50 +020011int dma_supported(struct device *dev, u64 mask);
FUJITA Tomonorib9f69f42009-05-14 16:23:08 +000012
David S. Miller0d1d9092014-11-26 13:36:41 -080013static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
14 enum dma_data_direction dir)
15{
16 /* Since dma_{alloc,free}_noncoherent() allocated coherent memory, this
17 * routine can be a nop.
18 */
19}
20
Bart Van Assche52997092017-01-20 13:04:01 -080021extern const struct dma_map_ops *dma_ops;
22extern const struct dma_map_ops *leon_dma_ops;
23extern const struct dma_map_ops pci32_dma_ops;
Sam Ravnborg87e677c2012-05-26 15:56:03 +020024
FUJITA Tomonoriee664a92009-08-10 11:53:16 +090025extern struct bus_type pci_bus_type;
FUJITA Tomonori02f7a182009-08-10 11:53:13 +090026
Bart Van Assche815dd182017-01-20 13:04:04 -080027static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
FUJITA Tomonori02f7a182009-08-10 11:53:13 +090028{
Andreas Larssonb84ca922014-09-08 09:48:52 +020029#ifdef CONFIG_SPARC_LEON
Sam Ravnborg87e677c2012-05-26 15:56:03 +020030 if (sparc_cpu_model == sparc_leon)
31 return leon_dma_ops;
Andreas Larssonb84ca922014-09-08 09:48:52 +020032#endif
33#if defined(CONFIG_SPARC32) && defined(CONFIG_PCI)
Bart Van Assche815dd182017-01-20 13:04:04 -080034 if (bus == &pci_bus_type)
FUJITA Tomonoriee664a92009-08-10 11:53:16 +090035 return &pci32_dma_ops;
36#endif
FUJITA Tomonori02f7a182009-08-10 11:53:13 +090037 return dma_ops;
38}
39
Sam Ravnborga439fe52008-07-27 23:00:59 +020040#endif