[POWERPC] spufs: Add bit definition
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-sparc64 / dma-mapping.h
blob4e21c2f3065ca16988802fab9067f80c43e2dddc
1 #ifndef _ASM_SPARC64_DMA_MAPPING_H
2 #define _ASM_SPARC64_DMA_MAPPING_H
5 #ifdef CONFIG_PCI
7 /* we implement the API below in terms of the existing PCI one,
8 * so include it */
9 #include <linux/pci.h>
10 /* need struct page definitions */
11 #include <linux/mm.h>
13 #include <asm/of_device.h>
15 static inline int
16 dma_supported(struct device *dev, u64 mask)
18 BUG_ON(dev->bus != &pci_bus_type &&
19 dev->bus != &ebus_bus_type);
21 return pci_dma_supported(to_pci_dev(dev), mask);
24 static inline int
25 dma_set_mask(struct device *dev, u64 dma_mask)
27 BUG_ON(dev->bus != &pci_bus_type &&
28 dev->bus != &ebus_bus_type);
30 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
33 static inline void *
34 dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
35 gfp_t flag)
37 BUG_ON(dev->bus != &pci_bus_type &&
38 dev->bus != &ebus_bus_type);
40 return pci_iommu_ops->alloc_consistent(to_pci_dev(dev), size, dma_handle, flag);
43 static inline void
44 dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
45 dma_addr_t dma_handle)
47 BUG_ON(dev->bus != &pci_bus_type &&
48 dev->bus != &ebus_bus_type);
50 pci_free_consistent(to_pci_dev(dev), size, cpu_addr, dma_handle);
53 static inline dma_addr_t
54 dma_map_single(struct device *dev, void *cpu_addr, size_t size,
55 enum dma_data_direction direction)
57 BUG_ON(dev->bus != &pci_bus_type &&
58 dev->bus != &ebus_bus_type);
60 return pci_map_single(to_pci_dev(dev), cpu_addr, size, (int)direction);
63 static inline void
64 dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
65 enum dma_data_direction direction)
67 BUG_ON(dev->bus != &pci_bus_type &&
68 dev->bus != &ebus_bus_type);
70 pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
73 static inline dma_addr_t
74 dma_map_page(struct device *dev, struct page *page,
75 unsigned long offset, size_t size,
76 enum dma_data_direction direction)
78 BUG_ON(dev->bus != &pci_bus_type &&
79 dev->bus != &ebus_bus_type);
81 return pci_map_page(to_pci_dev(dev), page, offset, size, (int)direction);
84 static inline void
85 dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
86 enum dma_data_direction direction)
88 BUG_ON(dev->bus != &pci_bus_type &&
89 dev->bus != &ebus_bus_type);
91 pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
94 static inline int
95 dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
96 enum dma_data_direction direction)
98 BUG_ON(dev->bus != &pci_bus_type &&
99 dev->bus != &ebus_bus_type);
101 return pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
104 static inline void
105 dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
106 enum dma_data_direction direction)
108 BUG_ON(dev->bus != &pci_bus_type &&
109 dev->bus != &ebus_bus_type);
111 pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
114 static inline void
115 dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
116 enum dma_data_direction direction)
118 BUG_ON(dev->bus != &pci_bus_type &&
119 dev->bus != &ebus_bus_type);
121 pci_dma_sync_single_for_cpu(to_pci_dev(dev), dma_handle,
122 size, (int)direction);
125 static inline void
126 dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
127 enum dma_data_direction direction)
129 BUG_ON(dev->bus != &pci_bus_type &&
130 dev->bus != &ebus_bus_type);
132 pci_dma_sync_single_for_device(to_pci_dev(dev), dma_handle,
133 size, (int)direction);
136 static inline void
137 dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
138 enum dma_data_direction direction)
140 BUG_ON(dev->bus != &pci_bus_type &&
141 dev->bus != &ebus_bus_type);
143 pci_dma_sync_sg_for_cpu(to_pci_dev(dev), sg, nelems, (int)direction);
146 static inline void
147 dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
148 enum dma_data_direction direction)
150 BUG_ON(dev->bus != &pci_bus_type &&
151 dev->bus != &ebus_bus_type);
153 pci_dma_sync_sg_for_device(to_pci_dev(dev), sg, nelems, (int)direction);
156 static inline int
157 dma_mapping_error(dma_addr_t dma_addr)
159 return pci_dma_mapping_error(dma_addr);
162 #else
164 struct device;
165 struct page;
166 struct scatterlist;
168 static inline int
169 dma_supported(struct device *dev, u64 mask)
171 BUG();
172 return 0;
175 static inline int
176 dma_set_mask(struct device *dev, u64 dma_mask)
178 BUG();
179 return 0;
182 static inline void *dma_alloc_coherent(struct device *dev, size_t size,
183 dma_addr_t *dma_handle, gfp_t flag)
185 BUG();
186 return NULL;
189 static inline void dma_free_coherent(struct device *dev, size_t size,
190 void *vaddr, dma_addr_t dma_handle)
192 BUG();
195 static inline dma_addr_t
196 dma_map_single(struct device *dev, void *cpu_addr, size_t size,
197 enum dma_data_direction direction)
199 BUG();
200 return 0;
203 static inline void
204 dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
205 enum dma_data_direction direction)
207 BUG();
210 static inline dma_addr_t
211 dma_map_page(struct device *dev, struct page *page,
212 unsigned long offset, size_t size,
213 enum dma_data_direction direction)
215 BUG();
216 return 0;
219 static inline void
220 dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
221 enum dma_data_direction direction)
223 BUG();
226 static inline int
227 dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
228 enum dma_data_direction direction)
230 BUG();
231 return 0;
234 static inline void
235 dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
236 enum dma_data_direction direction)
238 BUG();
241 static inline void
242 dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
243 enum dma_data_direction direction)
245 BUG();
248 static inline void
249 dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
250 enum dma_data_direction direction)
252 BUG();
255 static inline void
256 dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
257 enum dma_data_direction direction)
259 BUG();
262 static inline void
263 dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
264 enum dma_data_direction direction)
266 BUG();
269 static inline int
270 dma_mapping_error(dma_addr_t dma_addr)
272 BUG();
273 return 0;
276 #endif /* PCI */
279 /* Now for the API extensions over the pci_ one */
281 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
282 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
283 #define dma_is_consistent(d, h) (1)
285 static inline int
286 dma_get_cache_alignment(void)
288 /* no easy way to get cache size on all processors, so return
289 * the maximum possible, to be safe */
290 return (1 << INTERNODE_CACHE_SHIFT);
293 static inline void
294 dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
295 unsigned long offset, size_t size,
296 enum dma_data_direction direction)
298 /* just sync everything, that's all the pci API can do */
299 dma_sync_single_for_cpu(dev, dma_handle, offset+size, direction);
302 static inline void
303 dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
304 unsigned long offset, size_t size,
305 enum dma_data_direction direction)
307 /* just sync everything, that's all the pci API can do */
308 dma_sync_single_for_device(dev, dma_handle, offset+size, direction);
311 static inline void
312 dma_cache_sync(struct device *dev, void *vaddr, size_t size,
313 enum dma_data_direction direction)
315 /* could define this in terms of the dma_cache ... operations,
316 * but if you get this on a platform, you should convert the platform
317 * to using the generic device DMA API */
318 BUG();
321 #endif /* _ASM_SPARC64_DMA_MAPPING_H */