Linux Audio

Check our new training course

Loading...
v4.17
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef _ASM_DMA_MAPPING_H
 3#define _ASM_DMA_MAPPING_H
 4
 5#include <linux/scatterlist.h>
 6#include <asm/dma-coherence.h>
 7#include <asm/cache.h>
 
 8
 9#ifndef CONFIG_SGI_IP27 /* Kludge to fix 2.6.39 build for IP27 */
10#include <dma-coherence.h>
11#endif
12
13extern const struct dma_map_ops *mips_dma_map_ops;
14
15static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
16{
17	return mips_dma_map_ops;
 
 
 
18}
19
20#define arch_setup_dma_ops arch_setup_dma_ops
21static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
22				      u64 size, const struct iommu_ops *iommu,
23				      bool coherent)
24{
25#ifdef CONFIG_DMA_PERDEV_COHERENT
26	dev->archdata.dma_coherent = coherent;
27#endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
30#endif /* _ASM_DMA_MAPPING_H */
v3.1
 
 1#ifndef _ASM_DMA_MAPPING_H
 2#define _ASM_DMA_MAPPING_H
 3
 4#include <asm/scatterlist.h>
 
 5#include <asm/cache.h>
 6#include <asm-generic/dma-coherent.h>
 7
 8#ifndef CONFIG_SGI_IP27	/* Kludge to fix 2.6.39 build for IP27 */
 9#include <dma-coherence.h>
10#endif
11
12extern struct dma_map_ops *mips_dma_map_ops;
13
14static 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
22static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
 
 
 
23{
24	if (!dev->dma_mask)
25		return 0;
26
27	return addr + size <= *dev->dma_mask;
28}
29
30static inline void dma_mark_clean(void *addr, size_t size) {}
31
32#include <asm-generic/dma-mapping-common.h>
33
34static inline int dma_supported(struct device *dev, u64 mask)
35{
36	struct dma_map_ops *ops = get_dma_ops(dev);
37	return ops->dma_supported(dev, mask);
38}
39
40static inline int dma_mapping_error(struct device *dev, u64 mask)
41{
42	struct dma_map_ops *ops = get_dma_ops(dev);
43	return ops->mapping_error(dev, mask);
44}
45
46static inline int
47dma_set_mask(struct device *dev, u64 mask)
48{
49	if(!dev->dma_mask || !dma_supported(dev, mask))
50		return -EIO;
51
52	*dev->dma_mask = mask;
53
54	return 0;
55}
56
57extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
58	       enum dma_data_direction direction);
59
60static inline void *dma_alloc_coherent(struct device *dev, size_t size,
61				       dma_addr_t *dma_handle, gfp_t gfp)
62{
63	void *ret;
64	struct dma_map_ops *ops = get_dma_ops(dev);
65
66	ret = ops->alloc_coherent(dev, size, dma_handle, gfp);
67
68	debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
69
70	return ret;
71}
72
73static inline void dma_free_coherent(struct device *dev, size_t size,
74				     void *vaddr, dma_addr_t dma_handle)
75{
76	struct dma_map_ops *ops = get_dma_ops(dev);
77
78	ops->free_coherent(dev, size, vaddr, dma_handle);
79
80	debug_dma_free_coherent(dev, size, vaddr, dma_handle);
81}
82
83
84void *dma_alloc_noncoherent(struct device *dev, size_t size,
85			   dma_addr_t *dma_handle, gfp_t flag);
86
87void dma_free_noncoherent(struct device *dev, size_t size,
88			 void *vaddr, dma_addr_t dma_handle);
89
90#endif /* _ASM_DMA_MAPPING_H */