Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASM_DMA_MAPPING_H |
| 2 | #define _ASM_DMA_MAPPING_H |
| 3 | |
| 4 | #include <asm/scatterlist.h> |
| 5 | #include <asm/cache.h> |
| 6 | |
| 7 | void *dma_alloc_noncoherent(struct device *dev, size_t size, |
Al Viro | 185a8ff | 2005-10-21 03:21:23 -0400 | [diff] [blame] | 8 | dma_addr_t *dma_handle, gfp_t flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
| 10 | void dma_free_noncoherent(struct device *dev, size_t size, |
| 11 | void *vaddr, dma_addr_t dma_handle); |
| 12 | |
| 13 | void *dma_alloc_coherent(struct device *dev, size_t size, |
Al Viro | 185a8ff | 2005-10-21 03:21:23 -0400 | [diff] [blame] | 14 | dma_addr_t *dma_handle, gfp_t flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | void dma_free_coherent(struct device *dev, size_t size, |
| 17 | void *vaddr, dma_addr_t dma_handle); |
| 18 | |
| 19 | extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, |
| 20 | enum dma_data_direction direction); |
| 21 | extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, |
| 22 | size_t size, enum dma_data_direction direction); |
| 23 | extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, |
| 24 | enum dma_data_direction direction); |
| 25 | extern dma_addr_t dma_map_page(struct device *dev, struct page *page, |
| 26 | unsigned long offset, size_t size, enum dma_data_direction direction); |
| 27 | extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address, |
| 28 | size_t size, enum dma_data_direction direction); |
| 29 | extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg, |
| 30 | int nhwentries, enum dma_data_direction direction); |
| 31 | extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, |
| 32 | size_t size, enum dma_data_direction direction); |
| 33 | extern void dma_sync_single_for_device(struct device *dev, |
| 34 | dma_addr_t dma_handle, size_t size, enum dma_data_direction direction); |
| 35 | extern void dma_sync_single_range_for_cpu(struct device *dev, |
| 36 | dma_addr_t dma_handle, unsigned long offset, size_t size, |
| 37 | enum dma_data_direction direction); |
| 38 | extern void dma_sync_single_range_for_device(struct device *dev, |
| 39 | dma_addr_t dma_handle, unsigned long offset, size_t size, |
| 40 | enum dma_data_direction direction); |
| 41 | extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, |
| 42 | int nelems, enum dma_data_direction direction); |
| 43 | extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, |
| 44 | int nelems, enum dma_data_direction direction); |
| 45 | extern int dma_mapping_error(dma_addr_t dma_addr); |
| 46 | extern int dma_supported(struct device *dev, u64 mask); |
| 47 | |
| 48 | static inline int |
| 49 | dma_set_mask(struct device *dev, u64 mask) |
| 50 | { |
| 51 | if(!dev->dma_mask || !dma_supported(dev, mask)) |
| 52 | return -EIO; |
| 53 | |
| 54 | *dev->dma_mask = mask; |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | static inline int |
| 60 | dma_get_cache_alignment(void) |
| 61 | { |
| 62 | /* XXX Largest on any MIPS */ |
| 63 | return 128; |
| 64 | } |
| 65 | |
Ralf Baechle | f67637e | 2006-12-06 20:38:54 -0800 | [diff] [blame] | 66 | extern int dma_is_consistent(struct device *dev, dma_addr_t dma_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
Ralf Baechle | d3fa72e | 2006-12-06 20:38:56 -0800 | [diff] [blame] | 68 | extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | enum dma_data_direction direction); |
| 70 | |
Ralf Baechle | 84b47a9 | 2007-02-12 22:22:53 +0000 | [diff] [blame^] | 71 | #if 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY |
| 73 | |
| 74 | extern int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, |
| 75 | dma_addr_t device_addr, size_t size, int flags); |
| 76 | extern void dma_release_declared_memory(struct device *dev); |
| 77 | extern void * dma_mark_declared_memory_occupied(struct device *dev, |
| 78 | dma_addr_t device_addr, size_t size); |
Ralf Baechle | 84b47a9 | 2007-02-12 22:22:53 +0000 | [diff] [blame^] | 79 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
| 81 | #endif /* _ASM_DMA_MAPPING_H */ |