blob: 98308c497162c22e15e88e17e452918eae00f4ba [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
Paul Mundt73c926b2009-10-20 12:55:56 +090016static inline int dma_supported(struct device *dev, u64 mask)
17{
18 struct dma_map_ops *ops = get_dma_ops(dev);
19
20 if (ops->dma_supported)
21 return ops->dma_supported(dev, mask);
22
23 return 1;
24}
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26static inline int dma_set_mask(struct device *dev, u64 mask)
27{
Paul Mundt73c926b2009-10-20 12:55:56 +090028 struct dma_map_ops *ops = get_dma_ops(dev);
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 if (!dev->dma_mask || !dma_supported(dev, mask))
31 return -EIO;
Paul Mundt73c926b2009-10-20 12:55:56 +090032 if (ops->set_dma_mask)
33 return ops->set_dma_mask(dev, mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35 *dev->dma_mask = mask;
36
37 return 0;
38}
39
Magnus Dammf93e97e2008-01-24 18:35:10 +090040void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
41 enum dma_data_direction dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
Paul Mundtf32154c92009-10-26 09:50:51 +090043/* arch/sh/mm/consistent.c */
44extern void *dma_generic_alloc_coherent(struct device *dev, size_t size,
Andrzej Pietrasiewicz552c0d32011-12-14 12:11:13 +010045 dma_addr_t *dma_addr, gfp_t flag,
46 struct dma_attrs *attrs);
Paul Mundtf32154c92009-10-26 09:50:51 +090047extern void dma_generic_free_coherent(struct device *dev, size_t size,
Andrzej Pietrasiewicz552c0d32011-12-14 12:11:13 +010048 void *vaddr, dma_addr_t dma_handle,
49 struct dma_attrs *attrs);
Magnus Dammf93e97e2008-01-24 18:35:10 +090050
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#endif /* __ASM_SH_DMA_MAPPING_H */