Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 1 | /* DMA mapping. Nothing tricky here, just virt_to_phys */ |
| 2 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | #ifndef _ASM_CRIS_DMA_MAPPING_H |
| 4 | #define _ASM_CRIS_DMA_MAPPING_H |
| 5 | |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 6 | #include <linux/mm.h> |
| 7 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 9 | #include <asm/cache.h> |
| 10 | #include <asm/io.h> |
| 11 | #include <asm/scatterlist.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 13 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) |
| 14 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 16 | #ifdef CONFIG_PCI |
| 17 | void *dma_alloc_coherent(struct device *dev, size_t size, |
Al Viro | 43b7eae | 2005-10-21 03:21:13 -0400 | [diff] [blame] | 18 | dma_addr_t *dma_handle, gfp_t flag); |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 19 | |
| 20 | void dma_free_coherent(struct device *dev, size_t size, |
| 21 | void *vaddr, dma_addr_t dma_handle); |
| 22 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | static inline void * |
| 24 | dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, |
Al Viro | 43b7eae | 2005-10-21 03:21:13 -0400 | [diff] [blame] | 25 | gfp_t flag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | { |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 27 | BUG(); |
| 28 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | static inline void |
| 32 | dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 33 | dma_addr_t dma_handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | { |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 35 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | } |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 37 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | static inline dma_addr_t |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 39 | dma_map_single(struct device *dev, void *ptr, size_t size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | enum dma_data_direction direction) |
| 41 | { |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 42 | BUG_ON(direction == DMA_NONE); |
| 43 | return virt_to_phys(ptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | static inline void |
| 47 | dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, |
| 48 | enum dma_data_direction direction) |
| 49 | { |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 50 | BUG_ON(direction == DMA_NONE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | static inline int |
| 54 | dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, |
| 55 | enum dma_data_direction direction) |
| 56 | { |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 57 | printk("Map sg\n"); |
| 58 | return nents; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 61 | static inline dma_addr_t |
| 62 | dma_map_page(struct device *dev, struct page *page, unsigned long offset, |
| 63 | size_t size, enum dma_data_direction direction) |
| 64 | { |
| 65 | BUG_ON(direction == DMA_NONE); |
| 66 | return page_to_phys(page) + offset; |
| 67 | } |
| 68 | |
| 69 | static inline void |
| 70 | dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, |
| 71 | enum dma_data_direction direction) |
| 72 | { |
| 73 | BUG_ON(direction == DMA_NONE); |
| 74 | } |
| 75 | |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | static inline void |
| 78 | dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, |
| 79 | enum dma_data_direction direction) |
| 80 | { |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 81 | BUG_ON(direction == DMA_NONE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | static inline void |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 85 | dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size, |
| 86 | enum dma_data_direction direction) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | static inline void |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 91 | dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size, |
| 92 | enum dma_data_direction direction) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 96 | static inline void |
| 97 | dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, |
| 98 | unsigned long offset, size_t size, |
| 99 | enum dma_data_direction direction) |
| 100 | { |
| 101 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 103 | static inline void |
| 104 | dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, |
| 105 | unsigned long offset, size_t size, |
| 106 | enum dma_data_direction direction) |
| 107 | { |
| 108 | } |
| 109 | |
| 110 | static inline void |
| 111 | dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, |
| 112 | enum dma_data_direction direction) |
| 113 | { |
| 114 | } |
| 115 | |
| 116 | static inline void |
| 117 | dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems, |
| 118 | enum dma_data_direction direction) |
| 119 | { |
| 120 | } |
| 121 | |
| 122 | static inline int |
| 123 | dma_mapping_error(dma_addr_t dma_addr) |
| 124 | { |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | static inline int |
| 129 | dma_supported(struct device *dev, u64 mask) |
| 130 | { |
| 131 | /* |
| 132 | * we fall back to GFP_DMA when the mask isn't all 1s, |
| 133 | * so we can't guarantee allocations that must be |
| 134 | * within a tighter range than GFP_DMA.. |
| 135 | */ |
| 136 | if(mask < 0x00ffffff) |
| 137 | return 0; |
| 138 | |
| 139 | return 1; |
| 140 | } |
| 141 | |
| 142 | static inline int |
| 143 | dma_set_mask(struct device *dev, u64 mask) |
| 144 | { |
| 145 | if(!dev->dma_mask || !dma_supported(dev, mask)) |
| 146 | return -EIO; |
| 147 | |
| 148 | *dev->dma_mask = mask; |
| 149 | |
| 150 | return 0; |
| 151 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
| 153 | static inline int |
| 154 | dma_get_cache_alignment(void) |
| 155 | { |
Ravikiran G Thirumalai | 1fd73c6 | 2006-01-08 01:01:28 -0800 | [diff] [blame] | 156 | return (1 << INTERNODE_CACHE_SHIFT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Ralf Baechle | f67637e | 2006-12-06 20:38:54 -0800 | [diff] [blame] | 159 | #define dma_is_consistent(d, h) (1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
| 161 | static inline void |
Ralf Baechle | d3fa72e | 2006-12-06 20:38:56 -0800 | [diff] [blame] | 162 | dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | enum dma_data_direction direction) |
| 164 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Mikael Starvik | 59c6113 | 2005-07-27 11:44:40 -0700 | [diff] [blame] | 167 | |
| 168 | #endif |