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> |
Yoichi Yuasa | f8ac042 | 2009-06-04 00:16:04 +0900 | [diff] [blame] | 6 | #include <asm-generic/dma-coherent.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
| 8 | void *dma_alloc_noncoherent(struct device *dev, size_t size, |
Al Viro | 185a8ff | 2005-10-21 03:21:23 -0400 | [diff] [blame] | 9 | dma_addr_t *dma_handle, gfp_t flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
| 11 | void dma_free_noncoherent(struct device *dev, size_t size, |
| 12 | void *vaddr, dma_addr_t dma_handle); |
| 13 | |
| 14 | void *dma_alloc_coherent(struct device *dev, size_t size, |
Al Viro | 185a8ff | 2005-10-21 03:21:23 -0400 | [diff] [blame] | 15 | dma_addr_t *dma_handle, gfp_t flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | void dma_free_coherent(struct device *dev, size_t size, |
| 18 | void *vaddr, dma_addr_t dma_handle); |
| 19 | |
| 20 | extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, |
| 21 | enum dma_data_direction direction); |
| 22 | extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, |
| 23 | size_t size, enum dma_data_direction direction); |
| 24 | extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, |
| 25 | enum dma_data_direction direction); |
| 26 | extern dma_addr_t dma_map_page(struct device *dev, struct page *page, |
| 27 | unsigned long offset, size_t size, enum dma_data_direction direction); |
Atsushi Nemoto | 4f29c05 | 2009-01-23 00:42:11 +0900 | [diff] [blame] | 28 | |
| 29 | static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, |
| 30 | size_t size, enum dma_data_direction direction) |
| 31 | { |
| 32 | dma_unmap_single(dev, dma_address, size, direction); |
| 33 | } |
| 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg, |
| 36 | int nhwentries, enum dma_data_direction direction); |
| 37 | extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, |
| 38 | size_t size, enum dma_data_direction direction); |
| 39 | extern void dma_sync_single_for_device(struct device *dev, |
| 40 | dma_addr_t dma_handle, size_t size, enum dma_data_direction direction); |
| 41 | extern void dma_sync_single_range_for_cpu(struct device *dev, |
| 42 | dma_addr_t dma_handle, unsigned long offset, size_t size, |
| 43 | enum dma_data_direction direction); |
| 44 | extern void dma_sync_single_range_for_device(struct device *dev, |
| 45 | dma_addr_t dma_handle, unsigned long offset, size_t size, |
| 46 | enum dma_data_direction direction); |
| 47 | extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, |
| 48 | int nelems, enum dma_data_direction direction); |
| 49 | extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, |
| 50 | int nelems, enum dma_data_direction direction); |
FUJITA Tomonori | 8d8bb39 | 2008-07-25 19:44:49 -0700 | [diff] [blame] | 51 | extern int dma_mapping_error(struct device *dev, dma_addr_t dma_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | extern int dma_supported(struct device *dev, u64 mask); |
| 53 | |
| 54 | static inline int |
| 55 | dma_set_mask(struct device *dev, u64 mask) |
| 56 | { |
| 57 | if(!dev->dma_mask || !dma_supported(dev, mask)) |
| 58 | return -EIO; |
| 59 | |
| 60 | *dev->dma_mask = mask; |
| 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | static inline int |
| 66 | dma_get_cache_alignment(void) |
| 67 | { |
| 68 | /* XXX Largest on any MIPS */ |
| 69 | return 128; |
| 70 | } |
| 71 | |
Ralf Baechle | f67637e | 2006-12-06 20:38:54 -0800 | [diff] [blame] | 72 | 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] | 73 | |
Ralf Baechle | d3fa72e | 2006-12-06 20:38:56 -0800 | [diff] [blame] | 74 | 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] | 75 | enum dma_data_direction direction); |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | #endif /* _ASM_DMA_MAPPING_H */ |