aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/mm/dma-coherent.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/mips/mm/dma-coherent.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/mips/mm/dma-coherent.c')
-rw-r--r--arch/mips/mm/dma-coherent.c255
1 files changed, 255 insertions, 0 deletions
diff --git a/arch/mips/mm/dma-coherent.c b/arch/mips/mm/dma-coherent.c
new file mode 100644
index 000000000000..97a50d38c98f
--- /dev/null
+++ b/arch/mips/mm/dma-coherent.c
@@ -0,0 +1,255 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2000 Ani Joshi <ajoshi@unixbox.com>
7 * Copyright (C) 2000, 2001 Ralf Baechle <ralf@gnu.org>
8 * swiped from i386, and cloned for MIPS by Geert, polished by Ralf.
9 */
10#include <linux/config.h>
11#include <linux/types.h>
12#include <linux/mm.h>
13#include <linux/module.h>
14#include <linux/string.h>
15#include <linux/pci.h>
16
17#include <asm/cache.h>
18#include <asm/io.h>
19
20void *dma_alloc_noncoherent(struct device *dev, size_t size,
21 dma_addr_t * dma_handle, int gfp)
22{
23 void *ret;
24 /* ignore region specifiers */
25 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
26
27 if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
28 gfp |= GFP_DMA;
29 ret = (void *) __get_free_pages(gfp, get_order(size));
30
31 if (ret != NULL) {
32 memset(ret, 0, size);
33 *dma_handle = virt_to_phys(ret);
34 }
35
36 return ret;
37}
38
39EXPORT_SYMBOL(dma_alloc_noncoherent);
40
41void *dma_alloc_coherent(struct device *dev, size_t size,
42 dma_addr_t * dma_handle, int gfp)
43 __attribute__((alias("dma_alloc_noncoherent")));
44
45EXPORT_SYMBOL(dma_alloc_coherent);
46
47void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
48 dma_addr_t dma_handle)
49{
50 unsigned long addr = (unsigned long) vaddr;
51
52 free_pages(addr, get_order(size));
53}
54
55EXPORT_SYMBOL(dma_free_noncoherent);
56
57void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
58 dma_addr_t dma_handle) __attribute__((alias("dma_free_noncoherent")));
59
60EXPORT_SYMBOL(dma_free_coherent);
61
62dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
63 enum dma_data_direction direction)
64{
65 BUG_ON(direction == DMA_NONE);
66
67 return __pa(ptr);
68}
69
70EXPORT_SYMBOL(dma_map_single);
71
72void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
73 enum dma_data_direction direction)
74{
75 BUG_ON(direction == DMA_NONE);
76}
77
78EXPORT_SYMBOL(dma_unmap_single);
79
80int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
81 enum dma_data_direction direction)
82{
83 int i;
84
85 BUG_ON(direction == DMA_NONE);
86
87 for (i = 0; i < nents; i++, sg++) {
88 sg->dma_address = (dma_addr_t)page_to_phys(sg->page) + sg->offset;
89 }
90
91 return nents;
92}
93
94EXPORT_SYMBOL(dma_map_sg);
95
96dma_addr_t dma_map_page(struct device *dev, struct page *page,
97 unsigned long offset, size_t size, enum dma_data_direction direction)
98{
99 BUG_ON(direction == DMA_NONE);
100
101 return page_to_phys(page) + offset;
102}
103
104EXPORT_SYMBOL(dma_map_page);
105
106void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
107 enum dma_data_direction direction)
108{
109 BUG_ON(direction == DMA_NONE);
110}
111
112EXPORT_SYMBOL(dma_unmap_page);
113
114void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
115 enum dma_data_direction direction)
116{
117 BUG_ON(direction == DMA_NONE);
118}
119
120EXPORT_SYMBOL(dma_unmap_sg);
121
122void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
123 size_t size, enum dma_data_direction direction)
124{
125 BUG_ON(direction == DMA_NONE);
126}
127
128EXPORT_SYMBOL(dma_sync_single_for_cpu);
129
130void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
131 size_t size, enum dma_data_direction direction)
132{
133 BUG_ON(direction == DMA_NONE);
134}
135
136EXPORT_SYMBOL(dma_sync_single_for_device);
137
138void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
139 unsigned long offset, size_t size,
140 enum dma_data_direction direction)
141{
142 BUG_ON(direction == DMA_NONE);
143}
144
145EXPORT_SYMBOL(dma_sync_single_range_for_cpu);
146
147void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
148 unsigned long offset, size_t size,
149 enum dma_data_direction direction)
150{
151 BUG_ON(direction == DMA_NONE);
152}
153
154EXPORT_SYMBOL(dma_sync_single_range_for_device);
155
156void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
157 enum dma_data_direction direction)
158{
159 BUG_ON(direction == DMA_NONE);
160}
161
162EXPORT_SYMBOL(dma_sync_sg_for_cpu);
163
164void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
165 enum dma_data_direction direction)
166{
167 BUG_ON(direction == DMA_NONE);
168}
169
170EXPORT_SYMBOL(dma_sync_sg_for_device);
171
172int dma_mapping_error(dma_addr_t dma_addr)
173{
174 return 0;
175}
176
177EXPORT_SYMBOL(dma_mapping_error);
178
179int dma_supported(struct device *dev, u64 mask)
180{
181 /*
182 * we fall back to GFP_DMA when the mask isn't all 1s,
183 * so we can't guarantee allocations that must be
184 * within a tighter range than GFP_DMA..
185 */
186 if (mask < 0x00ffffff)
187 return 0;
188
189 return 1;
190}
191
192EXPORT_SYMBOL(dma_supported);
193
194int dma_is_consistent(dma_addr_t dma_addr)
195{
196 return 1;
197}
198
199EXPORT_SYMBOL(dma_is_consistent);
200
201void dma_cache_sync(void *vaddr, size_t size,
202 enum dma_data_direction direction)
203{
204 BUG_ON(direction == DMA_NONE);
205}
206
207EXPORT_SYMBOL(dma_cache_sync);
208
209/* The DAC routines are a PCIism.. */
210
211#ifdef CONFIG_PCI
212
213#include <linux/pci.h>
214
215dma64_addr_t pci_dac_page_to_dma(struct pci_dev *pdev,
216 struct page *page, unsigned long offset, int direction)
217{
218 return (dma64_addr_t)page_to_phys(page) + offset;
219}
220
221EXPORT_SYMBOL(pci_dac_page_to_dma);
222
223struct page *pci_dac_dma_to_page(struct pci_dev *pdev,
224 dma64_addr_t dma_addr)
225{
226 return mem_map + (dma_addr >> PAGE_SHIFT);
227}
228
229EXPORT_SYMBOL(pci_dac_dma_to_page);
230
231unsigned long pci_dac_dma_to_offset(struct pci_dev *pdev,
232 dma64_addr_t dma_addr)
233{
234 return dma_addr & ~PAGE_MASK;
235}
236
237EXPORT_SYMBOL(pci_dac_dma_to_offset);
238
239void pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev,
240 dma64_addr_t dma_addr, size_t len, int direction)
241{
242 BUG_ON(direction == PCI_DMA_NONE);
243}
244
245EXPORT_SYMBOL(pci_dac_dma_sync_single_for_cpu);
246
247void pci_dac_dma_sync_single_for_device(struct pci_dev *pdev,
248 dma64_addr_t dma_addr, size_t len, int direction)
249{
250 BUG_ON(direction == PCI_DMA_NONE);
251}
252
253EXPORT_SYMBOL(pci_dac_dma_sync_single_for_device);
254
255#endif /* CONFIG_PCI */