blob: 088f6e5f1a927caabe43f515fd92e6fd28e6726a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SH_DMA_MAPPING_H
2#define __ASM_SH_DMA_MAPPING_H
3
Paul Mundt73c926b2009-10-20 12:55:56 +09004extern struct dma_map_ops *dma_ops;
5extern void no_iommu_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
Paul Mundt73c926b2009-10-20 12:55:56 +09007static inline struct dma_map_ops *get_dma_ops(struct device *dev)
8{
9 return dma_ops;
10}
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Christoph Hellwigefa21e42015-09-09 15:39:46 -070012#define DMA_ERROR_CODE 0
13
Paul Mundtf32154c92009-10-26 09:50:51 +090014#include <asm-generic/dma-mapping-common.h>
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016static inline int dma_set_mask(struct device *dev, u64 mask)
17{
Paul Mundt73c926b2009-10-20 12:55:56 +090018 struct dma_map_ops *ops = get_dma_ops(dev);
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 if (!dev->dma_mask || !dma_supported(dev, mask))
21 return -EIO;
Paul Mundt73c926b2009-10-20 12:55:56 +090022 if (ops->set_dma_mask)
23 return ops->set_dma_mask(dev, mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25 *dev->dma_mask = mask;
26
27 return 0;
28}
29
Magnus Dammf93e97e2008-01-24 18:35:10 +090030void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
31 enum dma_data_direction dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Paul Mundtf32154c92009-10-26 09:50:51 +090033/* arch/sh/mm/consistent.c */
34extern void *dma_generic_alloc_coherent(struct device *dev, size_t size,
Andrzej Pietrasiewicz552c0d32011-12-14 12:11:13 +010035 dma_addr_t *dma_addr, gfp_t flag,
36 struct dma_attrs *attrs);
Paul Mundtf32154c92009-10-26 09:50:51 +090037extern void dma_generic_free_coherent(struct device *dev, size_t size,
Andrzej Pietrasiewicz552c0d32011-12-14 12:11:13 +010038 void *vaddr, dma_addr_t dma_handle,
39 struct dma_attrs *attrs);
Magnus Dammf93e97e2008-01-24 18:35:10 +090040
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#endif /* __ASM_SH_DMA_MAPPING_H */