Commit | Line | Data |
---|---|---|
59c61138 MS |
1 | /* DMA mapping. Nothing tricky here, just virt_to_phys */ |
2 | ||
1da177e4 LT |
3 | #ifndef _ASM_CRIS_DMA_MAPPING_H |
4 | #define _ASM_CRIS_DMA_MAPPING_H | |
5 | ||
59c61138 MS |
6 | #include <linux/mm.h> |
7 | #include <linux/kernel.h> | |
84be456f | 8 | #include <linux/scatterlist.h> |
1da177e4 | 9 | |
59c61138 MS |
10 | #include <asm/cache.h> |
11 | #include <asm/io.h> | |
1da177e4 | 12 | |
59c61138 MS |
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) | |
15 | ||
16 | #ifdef CONFIG_PCI | |
8fa8b9fb DB |
17 | #include <asm-generic/dma-coherent.h> |
18 | ||
59c61138 | 19 | void *dma_alloc_coherent(struct device *dev, size_t size, |
43b7eae1 | 20 | dma_addr_t *dma_handle, gfp_t flag); |
1da177e4 | 21 | |
59c61138 MS |
22 | void dma_free_coherent(struct device *dev, size_t size, |
23 | void *vaddr, dma_addr_t dma_handle); | |
24 | #else | |
1da177e4 LT |
25 | static inline void * |
26 | dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, | |
43b7eae1 | 27 | gfp_t flag) |
1da177e4 | 28 | { |
59c61138 MS |
29 | BUG(); |
30 | return NULL; | |
1da177e4 LT |
31 | } |
32 | ||
33 | static inline void | |
34 | dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, | |
59c61138 | 35 | dma_addr_t dma_handle) |
1da177e4 | 36 | { |
59c61138 | 37 | BUG(); |
1da177e4 | 38 | } |
59c61138 | 39 | #endif |
1da177e4 | 40 | static inline dma_addr_t |
59c61138 | 41 | dma_map_single(struct device *dev, void *ptr, size_t size, |
1da177e4 LT |
42 | enum dma_data_direction direction) |
43 | { | |
59c61138 MS |
44 | BUG_ON(direction == DMA_NONE); |
45 | return virt_to_phys(ptr); | |
1da177e4 LT |
46 | } |
47 | ||
48 | static inline void | |
49 | dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | |
50 | enum dma_data_direction direction) | |
51 | { | |
59c61138 MS |
52 | BUG_ON(direction == DMA_NONE); |
53 | } | |
54 | ||
55 | static inline int | |
56 | dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | |
57 | enum dma_data_direction direction) | |
58 | { | |
59 | printk("Map sg\n"); | |
60 | return nents; | |
1da177e4 LT |
61 | } |
62 | ||
63 | static inline dma_addr_t | |
59c61138 MS |
64 | dma_map_page(struct device *dev, struct page *page, unsigned long offset, |
65 | size_t size, enum dma_data_direction direction) | |
1da177e4 | 66 | { |
59c61138 MS |
67 | BUG_ON(direction == DMA_NONE); |
68 | return page_to_phys(page) + offset; | |
1da177e4 LT |
69 | } |
70 | ||
71 | static inline void | |
72 | dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, | |
73 | enum dma_data_direction direction) | |
74 | { | |
59c61138 | 75 | BUG_ON(direction == DMA_NONE); |
1da177e4 LT |
76 | } |
77 | ||
1da177e4 LT |
78 | |
79 | static inline void | |
80 | dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, | |
81 | enum dma_data_direction direction) | |
82 | { | |
59c61138 | 83 | BUG_ON(direction == DMA_NONE); |
1da177e4 LT |
84 | } |
85 | ||
86 | static inline void | |
59c61138 MS |
87 | dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size, |
88 | enum dma_data_direction direction) | |
1da177e4 | 89 | { |
1da177e4 LT |
90 | } |
91 | ||
92 | static inline void | |
59c61138 MS |
93 | dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size, |
94 | enum dma_data_direction direction) | |
1da177e4 | 95 | { |
1da177e4 LT |
96 | } |
97 | ||
59c61138 MS |
98 | static inline void |
99 | dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, | |
100 | unsigned long offset, size_t size, | |
101 | enum dma_data_direction direction) | |
102 | { | |
103 | } | |
1da177e4 | 104 | |
59c61138 MS |
105 | static inline void |
106 | dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, | |
107 | unsigned long offset, size_t size, | |
108 | enum dma_data_direction direction) | |
109 | { | |
110 | } | |
1da177e4 | 111 | |
59c61138 MS |
112 | static inline void |
113 | dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, | |
114 | enum dma_data_direction direction) | |
1da177e4 | 115 | { |
1da177e4 LT |
116 | } |
117 | ||
118 | static inline void | |
59c61138 MS |
119 | dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems, |
120 | enum dma_data_direction direction) | |
1da177e4 | 121 | { |
1da177e4 LT |
122 | } |
123 | ||
59c61138 | 124 | static inline int |
8d8bb39b | 125 | dma_mapping_error(struct device *dev, dma_addr_t dma_addr) |
59c61138 MS |
126 | { |
127 | return 0; | |
128 | } | |
129 | ||
130 | static inline int | |
131 | dma_supported(struct device *dev, u64 mask) | |
132 | { | |
133 | /* | |
134 | * we fall back to GFP_DMA when the mask isn't all 1s, | |
135 | * so we can't guarantee allocations that must be | |
136 | * within a tighter range than GFP_DMA.. | |
137 | */ | |
138 | if(mask < 0x00ffffff) | |
139 | return 0; | |
140 | ||
141 | return 1; | |
142 | } | |
143 | ||
144 | static inline int | |
145 | dma_set_mask(struct device *dev, u64 mask) | |
146 | { | |
147 | if(!dev->dma_mask || !dma_supported(dev, mask)) | |
148 | return -EIO; | |
149 | ||
150 | *dev->dma_mask = mask; | |
151 | ||
152 | return 0; | |
153 | } | |
154 | ||
1da177e4 | 155 | static inline void |
d3fa72e4 | 156 | dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
1da177e4 LT |
157 | enum dma_data_direction direction) |
158 | { | |
1da177e4 LT |
159 | } |
160 | ||
063aceba GU |
161 | /* drivers/base/dma-mapping.c */ |
162 | extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma, | |
163 | void *cpu_addr, dma_addr_t dma_addr, size_t size); | |
164 | extern int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt, | |
165 | void *cpu_addr, dma_addr_t dma_addr, | |
166 | size_t size); | |
167 | ||
168 | #define dma_mmap_coherent(d, v, c, h, s) dma_common_mmap(d, v, c, h, s) | |
169 | #define dma_get_sgtable(d, t, v, h, s) dma_common_get_sgtable(d, t, v, h, s) | |
170 | ||
59c61138 MS |
171 | |
172 | #endif |