Linux Audio

Check our new training course

Loading...
 1#ifndef __ASM_SH_DMA_MAPPING_H
 2#define __ASM_SH_DMA_MAPPING_H
 3
 4extern struct dma_map_ops *dma_ops;
 5extern void no_iommu_init(void);
 6
 7static inline struct dma_map_ops *get_dma_ops(struct device *dev)
 8{
 9	return dma_ops;
10}
11
12#define DMA_ERROR_CODE 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
14void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
15		    enum dma_data_direction dir);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
17/* arch/sh/mm/consistent.c */
18extern void *dma_generic_alloc_coherent(struct device *dev, size_t size,
19					dma_addr_t *dma_addr, gfp_t flag,
20					struct dma_attrs *attrs);
21extern void dma_generic_free_coherent(struct device *dev, size_t size,
22				      void *vaddr, dma_addr_t dma_handle,
23				      struct dma_attrs *attrs);
24
25#endif /* __ASM_SH_DMA_MAPPING_H */
  1#ifndef __ASM_SH_DMA_MAPPING_H
  2#define __ASM_SH_DMA_MAPPING_H
  3
  4extern struct dma_map_ops *dma_ops;
  5extern void no_iommu_init(void);
  6
  7static inline struct dma_map_ops *get_dma_ops(struct device *dev)
  8{
  9	return dma_ops;
 10}
 11
 12#include <asm-generic/dma-coherent.h>
 13#include <asm-generic/dma-mapping-common.h>
 14
 15static inline int dma_supported(struct device *dev, u64 mask)
 16{
 17	struct dma_map_ops *ops = get_dma_ops(dev);
 18
 19	if (ops->dma_supported)
 20		return ops->dma_supported(dev, mask);
 21
 22	return 1;
 23}
 24
 25static inline int dma_set_mask(struct device *dev, u64 mask)
 26{
 27	struct dma_map_ops *ops = get_dma_ops(dev);
 28
 29	if (!dev->dma_mask || !dma_supported(dev, mask))
 30		return -EIO;
 31	if (ops->set_dma_mask)
 32		return ops->set_dma_mask(dev, mask);
 33
 34	*dev->dma_mask = mask;
 35
 36	return 0;
 37}
 38
 39void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 40		    enum dma_data_direction dir);
 41
 42#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 43#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
 44
 45static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 46{
 47	struct dma_map_ops *ops = get_dma_ops(dev);
 48
 49	debug_dma_mapping_error(dev, dma_addr);
 50	if (ops->mapping_error)
 51		return ops->mapping_error(dev, dma_addr);
 52
 53	return dma_addr == 0;
 54}
 55
 56#define dma_alloc_coherent(d,s,h,f)	dma_alloc_attrs(d,s,h,f,NULL)
 57
 58static inline void *dma_alloc_attrs(struct device *dev, size_t size,
 59				    dma_addr_t *dma_handle, gfp_t gfp,
 60				    struct dma_attrs *attrs)
 61{
 62	struct dma_map_ops *ops = get_dma_ops(dev);
 63	void *memory;
 64
 65	if (dma_alloc_from_coherent(dev, size, dma_handle, &memory))
 66		return memory;
 67	if (!ops->alloc)
 68		return NULL;
 69
 70	memory = ops->alloc(dev, size, dma_handle, gfp, attrs);
 71	debug_dma_alloc_coherent(dev, size, *dma_handle, memory);
 72
 73	return memory;
 74}
 75
 76#define dma_free_coherent(d,s,c,h) dma_free_attrs(d,s,c,h,NULL)
 77
 78static inline void dma_free_attrs(struct device *dev, size_t size,
 79				  void *vaddr, dma_addr_t dma_handle,
 80				  struct dma_attrs *attrs)
 81{
 82	struct dma_map_ops *ops = get_dma_ops(dev);
 83
 84	if (dma_release_from_coherent(dev, get_order(size), vaddr))
 85		return;
 86
 87	debug_dma_free_coherent(dev, size, vaddr, dma_handle);
 88	if (ops->free)
 89		ops->free(dev, size, vaddr, dma_handle, attrs);
 90}
 91
 92/* arch/sh/mm/consistent.c */
 93extern void *dma_generic_alloc_coherent(struct device *dev, size_t size,
 94					dma_addr_t *dma_addr, gfp_t flag,
 95					struct dma_attrs *attrs);
 96extern void dma_generic_free_coherent(struct device *dev, size_t size,
 97				      void *vaddr, dma_addr_t dma_handle,
 98				      struct dma_attrs *attrs);
 99
100#endif /* __ASM_SH_DMA_MAPPING_H */