Greg Ungerer | 9a4048a | 2009-01-29 15:35:34 +1000 | [diff] [blame] | 1 | #ifndef _M68K_DMA_MAPPING_H |
| 2 | #define _M68K_DMA_MAPPING_H |
| 3 | |
| 4 | #include <asm/cache.h> |
| 5 | |
| 6 | struct scatterlist; |
| 7 | |
| 8 | #ifndef CONFIG_MMU_SUN3 |
| 9 | static inline int dma_supported(struct device *dev, u64 mask) |
| 10 | { |
| 11 | return 1; |
| 12 | } |
| 13 | |
| 14 | static inline int dma_set_mask(struct device *dev, u64 mask) |
| 15 | { |
| 16 | return 0; |
| 17 | } |
| 18 | |
Greg Ungerer | 9a4048a | 2009-01-29 15:35:34 +1000 | [diff] [blame] | 19 | extern void *dma_alloc_coherent(struct device *, size_t, |
| 20 | dma_addr_t *, gfp_t); |
| 21 | extern void dma_free_coherent(struct device *, size_t, |
| 22 | void *, dma_addr_t); |
| 23 | |
Geert Uytterhoeven | 4a09ab6 | 2012-12-16 18:27:33 +0100 | [diff] [blame^] | 24 | static inline void *dma_alloc_attrs(struct device *dev, size_t size, |
| 25 | dma_addr_t *dma_handle, gfp_t flag, |
| 26 | struct dma_attrs *attrs) |
| 27 | { |
| 28 | /* attrs is not supported and ignored */ |
| 29 | return dma_alloc_coherent(dev, size, dma_handle, flag); |
| 30 | } |
| 31 | |
| 32 | static inline void dma_free_attrs(struct device *dev, size_t size, |
| 33 | void *cpu_addr, dma_addr_t dma_handle, |
| 34 | struct dma_attrs *attrs) |
| 35 | { |
| 36 | /* attrs is not supported and ignored */ |
| 37 | dma_free_coherent(dev, size, cpu_addr, dma_handle); |
| 38 | } |
| 39 | |
Greg Ungerer | 9a4048a | 2009-01-29 15:35:34 +1000 | [diff] [blame] | 40 | static inline void *dma_alloc_noncoherent(struct device *dev, size_t size, |
| 41 | dma_addr_t *handle, gfp_t flag) |
| 42 | { |
| 43 | return dma_alloc_coherent(dev, size, handle, flag); |
| 44 | } |
| 45 | static inline void dma_free_noncoherent(struct device *dev, size_t size, |
| 46 | void *addr, dma_addr_t handle) |
| 47 | { |
| 48 | dma_free_coherent(dev, size, addr, handle); |
| 49 | } |
| 50 | static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
| 51 | enum dma_data_direction dir) |
| 52 | { |
| 53 | /* we use coherent allocation, so not much to do here. */ |
| 54 | } |
| 55 | |
| 56 | extern dma_addr_t dma_map_single(struct device *, void *, size_t, |
| 57 | enum dma_data_direction); |
| 58 | static inline void dma_unmap_single(struct device *dev, dma_addr_t addr, |
| 59 | size_t size, enum dma_data_direction dir) |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | extern dma_addr_t dma_map_page(struct device *, struct page *, |
| 64 | unsigned long, size_t size, |
| 65 | enum dma_data_direction); |
| 66 | static inline void dma_unmap_page(struct device *dev, dma_addr_t address, |
| 67 | size_t size, enum dma_data_direction dir) |
| 68 | { |
| 69 | } |
| 70 | |
| 71 | extern int dma_map_sg(struct device *, struct scatterlist *, int, |
| 72 | enum dma_data_direction); |
| 73 | static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, |
| 74 | int nhwentries, enum dma_data_direction dir) |
| 75 | { |
| 76 | } |
| 77 | |
| 78 | extern void dma_sync_single_for_device(struct device *, dma_addr_t, size_t, |
| 79 | enum dma_data_direction); |
| 80 | extern void dma_sync_sg_for_device(struct device *, struct scatterlist *, int, |
| 81 | enum dma_data_direction); |
| 82 | |
| 83 | static inline void dma_sync_single_range_for_device(struct device *dev, |
| 84 | dma_addr_t dma_handle, unsigned long offset, size_t size, |
| 85 | enum dma_data_direction direction) |
| 86 | { |
| 87 | /* just sync everything for now */ |
| 88 | dma_sync_single_for_device(dev, dma_handle, offset + size, direction); |
| 89 | } |
| 90 | |
| 91 | static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle, |
| 92 | size_t size, enum dma_data_direction dir) |
| 93 | { |
| 94 | } |
| 95 | |
| 96 | static inline void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, |
| 97 | int nents, enum dma_data_direction dir) |
| 98 | { |
| 99 | } |
| 100 | |
| 101 | static inline void dma_sync_single_range_for_cpu(struct device *dev, |
| 102 | dma_addr_t dma_handle, unsigned long offset, size_t size, |
| 103 | enum dma_data_direction direction) |
| 104 | { |
| 105 | /* just sync everything for now */ |
| 106 | dma_sync_single_for_cpu(dev, dma_handle, offset + size, direction); |
| 107 | } |
| 108 | |
| 109 | static inline int dma_mapping_error(struct device *dev, dma_addr_t handle) |
| 110 | { |
| 111 | return 0; |
| 112 | } |
| 113 | |
Sam Ravnborg | 4914802 | 2009-01-16 21:58:10 +1000 | [diff] [blame] | 114 | #else |
Greg Ungerer | 9a4048a | 2009-01-29 15:35:34 +1000 | [diff] [blame] | 115 | #include <asm-generic/dma-mapping-broken.h> |
Sam Ravnborg | 4914802 | 2009-01-16 21:58:10 +1000 | [diff] [blame] | 116 | #endif |
Greg Ungerer | 9a4048a | 2009-01-29 15:35:34 +1000 | [diff] [blame] | 117 | |
| 118 | #endif /* _M68K_DMA_MAPPING_H */ |