Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_SH_DMA_MAPPING_H |
| 2 | #define __ASM_SH_DMA_MAPPING_H |
| 3 | |
Paul Mundt | 73c926b | 2009-10-20 12:55:56 +0900 | [diff] [blame] | 4 | extern struct dma_map_ops *dma_ops; |
| 5 | extern void no_iommu_init(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
Paul Mundt | 73c926b | 2009-10-20 12:55:56 +0900 | [diff] [blame] | 7 | static inline struct dma_map_ops *get_dma_ops(struct device *dev) |
| 8 | { |
| 9 | return dma_ops; |
| 10 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Christoph Hellwig | efa21e4 | 2015-09-09 15:39:46 -0700 | [diff] [blame] | 12 | #define DMA_ERROR_CODE 0 |
| 13 | |
Paul Mundt | f32154c9 | 2009-10-26 09:50:51 +0900 | [diff] [blame] | 14 | #include <asm-generic/dma-mapping-common.h> |
| 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | static inline int dma_set_mask(struct device *dev, u64 mask) |
| 17 | { |
Paul Mundt | 73c926b | 2009-10-20 12:55:56 +0900 | [diff] [blame] | 18 | struct dma_map_ops *ops = get_dma_ops(dev); |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | if (!dev->dma_mask || !dma_supported(dev, mask)) |
| 21 | return -EIO; |
Paul Mundt | 73c926b | 2009-10-20 12:55:56 +0900 | [diff] [blame] | 22 | if (ops->set_dma_mask) |
| 23 | return ops->set_dma_mask(dev, mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | *dev->dma_mask = mask; |
| 26 | |
| 27 | return 0; |
| 28 | } |
| 29 | |
Magnus Damm | f93e97e | 2008-01-24 18:35:10 +0900 | [diff] [blame] | 30 | void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
| 31 | enum dma_data_direction dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Paul Mundt | f32154c9 | 2009-10-26 09:50:51 +0900 | [diff] [blame] | 33 | /* arch/sh/mm/consistent.c */ |
| 34 | extern void *dma_generic_alloc_coherent(struct device *dev, size_t size, |
Andrzej Pietrasiewicz | 552c0d3 | 2011-12-14 12:11:13 +0100 | [diff] [blame] | 35 | dma_addr_t *dma_addr, gfp_t flag, |
| 36 | struct dma_attrs *attrs); |
Paul Mundt | f32154c9 | 2009-10-26 09:50:51 +0900 | [diff] [blame] | 37 | extern void dma_generic_free_coherent(struct device *dev, size_t size, |
Andrzej Pietrasiewicz | 552c0d3 | 2011-12-14 12:11:13 +0100 | [diff] [blame] | 38 | void *vaddr, dma_addr_t dma_handle, |
| 39 | struct dma_attrs *attrs); |
Magnus Damm | f93e97e | 2008-01-24 18:35:10 +0900 | [diff] [blame] | 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #endif /* __ASM_SH_DMA_MAPPING_H */ |