]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/sh/include/asm/dma-mapping.h
3c78059e66ffb2ada51ff2ffef03b5592bfcfd4e
[karo-tx-linux.git] / arch / sh / include / asm / dma-mapping.h
1 #ifndef __ASM_SH_DMA_MAPPING_H
2 #define __ASM_SH_DMA_MAPPING_H
3
4 extern struct dma_map_ops *dma_ops;
5 extern void no_iommu_init(void);
6
7 static inline struct dma_map_ops *get_dma_ops(struct device *dev)
8 {
9         return dma_ops;
10 }
11
12 #include <asm-generic/dma-mapping-common.h>
13
14 static inline int dma_supported(struct device *dev, u64 mask)
15 {
16         struct dma_map_ops *ops = get_dma_ops(dev);
17
18         if (ops->dma_supported)
19                 return ops->dma_supported(dev, mask);
20
21         return 1;
22 }
23
24 static inline int dma_set_mask(struct device *dev, u64 mask)
25 {
26         struct dma_map_ops *ops = get_dma_ops(dev);
27
28         if (!dev->dma_mask || !dma_supported(dev, mask))
29                 return -EIO;
30         if (ops->set_dma_mask)
31                 return ops->set_dma_mask(dev, mask);
32
33         *dev->dma_mask = mask;
34
35         return 0;
36 }
37
38 void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
39                     enum dma_data_direction dir);
40
41 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
42 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
43
44 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
45 {
46         struct dma_map_ops *ops = get_dma_ops(dev);
47
48         debug_dma_mapping_error(dev, dma_addr);
49         if (ops->mapping_error)
50                 return ops->mapping_error(dev, dma_addr);
51
52         return dma_addr == 0;
53 }
54
55 /* arch/sh/mm/consistent.c */
56 extern void *dma_generic_alloc_coherent(struct device *dev, size_t size,
57                                         dma_addr_t *dma_addr, gfp_t flag,
58                                         struct dma_attrs *attrs);
59 extern void dma_generic_free_coherent(struct device *dev, size_t size,
60                                       void *vaddr, dma_addr_t dma_handle,
61                                       struct dma_attrs *attrs);
62
63 #endif /* __ASM_SH_DMA_MAPPING_H */