blob: 174a74e63882215e06020fb9aa0009e0642ad355 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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,2002-2005 Silicon Graphics, Inc. All rights reserved.
7 *
8 * Routines for PCI DMA mapping. See Documentation/DMA-API.txt for
9 * a description of how these routines should be used.
10 */
11
12#include <linux/module.h>
Arthur Kepner309df0c2008-04-29 01:00:32 -070013#include <linux/dma-attrs.h>
FUJITA Tomonorib4391dd2009-01-05 23:36:10 +090014#include <linux/dma-mapping.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/dma.h>
Mark Maule83821d32006-04-14 16:03:54 -050016#include <asm/sn/intr.h>
Mark Maule9b08ebd2005-04-25 11:32:16 -070017#include <asm/sn/pcibus_provider_defs.h>
18#include <asm/sn/pcidev.h>
Prarit Bhargavac13cf372005-07-06 15:26:51 -070019#include <asm/sn/sn_sal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Jens Axboe58b053e2007-10-22 20:02:46 +020021#define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#define SG_ENT_PHYS_ADDRESS(SG) virt_to_phys(SG_ENT_VIRT_ADDRESS(SG))
23
24/**
25 * sn_dma_supported - test a DMA mask
26 * @dev: device to test
27 * @mask: DMA mask to test
28 *
29 * Return whether the given PCI device DMA address mask can be supported
30 * properly. For example, if your device can only drive the low 24-bits
31 * during PCI bus mastering, then you would pass 0x00ffffff as the mask to
32 * this function. Of course, SN only supports devices that have 32 or more
33 * address bits when using the PMU.
34 */
35int sn_dma_supported(struct device *dev, u64 mask)
36{
37 BUG_ON(dev->bus != &pci_bus_type);
38
39 if (mask < 0x7fffffff)
40 return 0;
41 return 1;
42}
43EXPORT_SYMBOL(sn_dma_supported);
44
45/**
46 * sn_dma_set_mask - set the DMA mask
47 * @dev: device to set
48 * @dma_mask: new mask
49 *
50 * Set @dev's DMA mask if the hw supports it.
51 */
52int sn_dma_set_mask(struct device *dev, u64 dma_mask)
53{
54 BUG_ON(dev->bus != &pci_bus_type);
55
56 if (!sn_dma_supported(dev, dma_mask))
57 return 0;
58
59 *dev->dma_mask = dma_mask;
60 return 1;
61}
62EXPORT_SYMBOL(sn_dma_set_mask);
63
64/**
65 * sn_dma_alloc_coherent - allocate memory for coherent DMA
66 * @dev: device to allocate for
67 * @size: size of the region
68 * @dma_handle: DMA (bus) address
69 * @flags: memory allocation flags
70 *
71 * dma_alloc_coherent() returns a pointer to a memory region suitable for
72 * coherent DMA traffic to/from a PCI device. On SN platforms, this means
73 * that @dma_handle will have the %PCIIO_DMA_CMD flag set.
74 *
75 * This interface is usually used for "command" streams (e.g. the command
76 * queue for a SCSI controller). See Documentation/DMA-API.txt for
77 * more information.
78 */
79void *sn_dma_alloc_coherent(struct device *dev, size_t size,
Al Viro06a54492005-10-21 03:21:03 -040080 dma_addr_t * dma_handle, gfp_t flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070081{
82 void *cpuaddr;
83 unsigned long phys_addr;
Christoph Lameter7c2a6c62005-07-12 16:03:00 -070084 int node;
Mark Maulee955d822005-04-25 11:26:03 -070085 struct pci_dev *pdev = to_pci_dev(dev);
86 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88 BUG_ON(dev->bus != &pci_bus_type);
89
90 /*
91 * Allocate the memory.
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 */
Christoph Lameter7c2a6c62005-07-12 16:03:00 -070093 node = pcibus_to_node(pdev->bus);
94 if (likely(node >=0)) {
Takashi Iwaidc641612006-01-24 14:30:56 -080095 struct page *p = alloc_pages_node(node, flags, get_order(size));
Christoph Lameter7c2a6c62005-07-12 16:03:00 -070096
97 if (likely(p))
98 cpuaddr = page_address(p);
99 else
100 return NULL;
101 } else
Takashi Iwaidc641612006-01-24 14:30:56 -0800102 cpuaddr = (void *)__get_free_pages(flags, get_order(size));
Christoph Lameter7c2a6c62005-07-12 16:03:00 -0700103
104 if (unlikely(!cpuaddr))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 return NULL;
106
107 memset(cpuaddr, 0x0, size);
108
109 /* physical addr. of the memory we just got */
110 phys_addr = __pa(cpuaddr);
111
112 /*
113 * 64 bit address translations should never fail.
114 * 32 bit translations can fail if there are insufficient mapping
115 * resources.
116 */
117
Mark Maule83821d32006-04-14 16:03:54 -0500118 *dma_handle = provider->dma_map_consistent(pdev, phys_addr, size,
119 SN_DMA_ADDR_PHYS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 if (!*dma_handle) {
Harvey Harrisond4ed8082008-03-04 15:15:00 -0800121 printk(KERN_ERR "%s: out of ATEs\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 free_pages((unsigned long)cpuaddr, get_order(size));
123 return NULL;
124 }
125
126 return cpuaddr;
127}
128EXPORT_SYMBOL(sn_dma_alloc_coherent);
129
130/**
131 * sn_pci_free_coherent - free memory associated with coherent DMAable region
132 * @dev: device to free for
133 * @size: size to free
134 * @cpu_addr: kernel virtual address to free
135 * @dma_handle: DMA address associated with this region
136 *
137 * Frees the memory allocated by dma_alloc_coherent(), potentially unmapping
138 * any associated IOMMU mappings.
139 */
140void sn_dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
141 dma_addr_t dma_handle)
142{
Mark Maulee955d822005-04-25 11:26:03 -0700143 struct pci_dev *pdev = to_pci_dev(dev);
144 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
146 BUG_ON(dev->bus != &pci_bus_type);
147
Mark Maulee955d822005-04-25 11:26:03 -0700148 provider->dma_unmap(pdev, dma_handle, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 free_pages((unsigned long)cpu_addr, get_order(size));
150}
151EXPORT_SYMBOL(sn_dma_free_coherent);
152
153/**
Arthur Kepner309df0c2008-04-29 01:00:32 -0700154 * sn_dma_map_single_attrs - map a single page for DMA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 * @dev: device to map for
156 * @cpu_addr: kernel virtual address of the region to map
157 * @size: size of the region
158 * @direction: DMA direction
Arthur Kepner309df0c2008-04-29 01:00:32 -0700159 * @attrs: optional dma attributes
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 *
161 * Map the region pointed to by @cpu_addr for DMA and return the
162 * DMA address.
163 *
164 * We map this to the one step pcibr_dmamap_trans interface rather than
165 * the two step pcibr_dmamap_alloc/pcibr_dmamap_addr because we have
166 * no way of saving the dmamap handle from the alloc to later free
167 * (which is pretty much unacceptable).
168 *
Arthur Kepner309df0c2008-04-29 01:00:32 -0700169 * mappings with the DMA_ATTR_WRITE_BARRIER get mapped with
170 * dma_map_consistent() so that writes force a flush of pending DMA.
171 * (See "SGI Altix Architecture Considerations for Linux Device Drivers",
172 * Document Number: 007-4763-001)
173 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 * TODO: simplify our interface;
175 * figure out how to save dmamap handle so can use two step.
176 */
Arthur Kepner309df0c2008-04-29 01:00:32 -0700177dma_addr_t sn_dma_map_single_attrs(struct device *dev, void *cpu_addr,
178 size_t size, int direction,
179 struct dma_attrs *attrs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180{
181 dma_addr_t dma_addr;
182 unsigned long phys_addr;
Mark Maulee955d822005-04-25 11:26:03 -0700183 struct pci_dev *pdev = to_pci_dev(dev);
184 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
Arthur Kepner309df0c2008-04-29 01:00:32 -0700185 int dmabarr;
186
187 dmabarr = dma_get_attr(DMA_ATTR_WRITE_BARRIER, attrs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189 BUG_ON(dev->bus != &pci_bus_type);
190
191 phys_addr = __pa(cpu_addr);
Arthur Kepner309df0c2008-04-29 01:00:32 -0700192 if (dmabarr)
193 dma_addr = provider->dma_map_consistent(pdev, phys_addr,
194 size, SN_DMA_ADDR_PHYS);
195 else
196 dma_addr = provider->dma_map(pdev, phys_addr, size,
197 SN_DMA_ADDR_PHYS);
198
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 if (!dma_addr) {
Harvey Harrisond4ed8082008-03-04 15:15:00 -0800200 printk(KERN_ERR "%s: out of ATEs\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 return 0;
202 }
203 return dma_addr;
204}
Arthur Kepner309df0c2008-04-29 01:00:32 -0700205EXPORT_SYMBOL(sn_dma_map_single_attrs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207/**
Arthur Kepner309df0c2008-04-29 01:00:32 -0700208 * sn_dma_unmap_single_attrs - unamp a DMA mapped page
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 * @dev: device to sync
210 * @dma_addr: DMA address to sync
211 * @size: size of region
212 * @direction: DMA direction
Arthur Kepner309df0c2008-04-29 01:00:32 -0700213 * @attrs: optional dma attributes
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 *
215 * This routine is supposed to sync the DMA region specified
216 * by @dma_handle into the coherence domain. On SN, we're always cache
217 * coherent, so we just need to free any ATEs associated with this mapping.
218 */
Arthur Kepner309df0c2008-04-29 01:00:32 -0700219void sn_dma_unmap_single_attrs(struct device *dev, dma_addr_t dma_addr,
220 size_t size, int direction,
221 struct dma_attrs *attrs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222{
Mark Maulee955d822005-04-25 11:26:03 -0700223 struct pci_dev *pdev = to_pci_dev(dev);
224 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
226 BUG_ON(dev->bus != &pci_bus_type);
Mark Maulee955d822005-04-25 11:26:03 -0700227
228 provider->dma_unmap(pdev, dma_addr, direction);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229}
Arthur Kepner309df0c2008-04-29 01:00:32 -0700230EXPORT_SYMBOL(sn_dma_unmap_single_attrs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232/**
Arthur Kepner309df0c2008-04-29 01:00:32 -0700233 * sn_dma_unmap_sg_attrs - unmap a DMA scatterlist
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 * @dev: device to unmap
235 * @sg: scatterlist to unmap
236 * @nhwentries: number of scatterlist entries
237 * @direction: DMA direction
Arthur Kepner309df0c2008-04-29 01:00:32 -0700238 * @attrs: optional dma attributes
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 *
240 * Unmap a set of streaming mode DMA translations.
241 */
Arthur Kepner309df0c2008-04-29 01:00:32 -0700242void sn_dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sgl,
243 int nhwentries, int direction,
244 struct dma_attrs *attrs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245{
246 int i;
Mark Maulee955d822005-04-25 11:26:03 -0700247 struct pci_dev *pdev = to_pci_dev(dev);
248 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
Jens Axboe9b6eccf2007-10-16 11:27:26 +0200249 struct scatterlist *sg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250
251 BUG_ON(dev->bus != &pci_bus_type);
252
Jens Axboe9b6eccf2007-10-16 11:27:26 +0200253 for_each_sg(sgl, sg, nhwentries, i) {
Mark Maulee955d822005-04-25 11:26:03 -0700254 provider->dma_unmap(pdev, sg->dma_address, direction);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 sg->dma_address = (dma_addr_t) NULL;
256 sg->dma_length = 0;
257 }
258}
Arthur Kepner309df0c2008-04-29 01:00:32 -0700259EXPORT_SYMBOL(sn_dma_unmap_sg_attrs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261/**
Arthur Kepner309df0c2008-04-29 01:00:32 -0700262 * sn_dma_map_sg_attrs - map a scatterlist for DMA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 * @dev: device to map for
264 * @sg: scatterlist to map
265 * @nhwentries: number of entries
266 * @direction: direction of the DMA transaction
Arthur Kepner309df0c2008-04-29 01:00:32 -0700267 * @attrs: optional dma attributes
268 *
269 * mappings with the DMA_ATTR_WRITE_BARRIER get mapped with
270 * dma_map_consistent() so that writes force a flush of pending DMA.
271 * (See "SGI Altix Architecture Considerations for Linux Device Drivers",
272 * Document Number: 007-4763-001)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 *
274 * Maps each entry of @sg for DMA.
275 */
Arthur Kepner309df0c2008-04-29 01:00:32 -0700276int sn_dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl,
277 int nhwentries, int direction, struct dma_attrs *attrs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278{
279 unsigned long phys_addr;
Jens Axboe9b6eccf2007-10-16 11:27:26 +0200280 struct scatterlist *saved_sg = sgl, *sg;
Mark Maulee955d822005-04-25 11:26:03 -0700281 struct pci_dev *pdev = to_pci_dev(dev);
282 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 int i;
Arthur Kepner309df0c2008-04-29 01:00:32 -0700284 int dmabarr;
285
286 dmabarr = dma_get_attr(DMA_ATTR_WRITE_BARRIER, attrs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
288 BUG_ON(dev->bus != &pci_bus_type);
289
290 /*
291 * Setup a DMA address for each entry in the scatterlist.
292 */
Jens Axboe9b6eccf2007-10-16 11:27:26 +0200293 for_each_sg(sgl, sg, nhwentries, i) {
Arthur Kepner309df0c2008-04-29 01:00:32 -0700294 dma_addr_t dma_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 phys_addr = SG_ENT_PHYS_ADDRESS(sg);
Arthur Kepner309df0c2008-04-29 01:00:32 -0700296 if (dmabarr)
297 dma_addr = provider->dma_map_consistent(pdev,
298 phys_addr,
299 sg->length,
300 SN_DMA_ADDR_PHYS);
301 else
302 dma_addr = provider->dma_map(pdev, phys_addr,
303 sg->length,
304 SN_DMA_ADDR_PHYS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
Arthur Kepner309df0c2008-04-29 01:00:32 -0700306 sg->dma_address = dma_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 if (!sg->dma_address) {
Harvey Harrisond4ed8082008-03-04 15:15:00 -0800308 printk(KERN_ERR "%s: out of ATEs\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310 /*
311 * Free any successfully allocated entries.
312 */
313 if (i > 0)
Arthur Kepner309df0c2008-04-29 01:00:32 -0700314 sn_dma_unmap_sg_attrs(dev, saved_sg, i,
315 direction, attrs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 return 0;
317 }
318
319 sg->dma_length = sg->length;
320 }
321
322 return nhwentries;
323}
Arthur Kepner309df0c2008-04-29 01:00:32 -0700324EXPORT_SYMBOL(sn_dma_map_sg_attrs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
326void sn_dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
327 size_t size, int direction)
328{
329 BUG_ON(dev->bus != &pci_bus_type);
330}
331EXPORT_SYMBOL(sn_dma_sync_single_for_cpu);
332
333void sn_dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
334 size_t size, int direction)
335{
336 BUG_ON(dev->bus != &pci_bus_type);
337}
338EXPORT_SYMBOL(sn_dma_sync_single_for_device);
339
340void sn_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
341 int nelems, int direction)
342{
343 BUG_ON(dev->bus != &pci_bus_type);
344}
345EXPORT_SYMBOL(sn_dma_sync_sg_for_cpu);
346
347void sn_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
348 int nelems, int direction)
349{
350 BUG_ON(dev->bus != &pci_bus_type);
351}
352EXPORT_SYMBOL(sn_dma_sync_sg_for_device);
353
FUJITA Tomonori8d8bb392008-07-25 19:44:49 -0700354int sn_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355{
356 return 0;
357}
358EXPORT_SYMBOL(sn_dma_mapping_error);
359
360char *sn_pci_get_legacy_mem(struct pci_bus *bus)
361{
362 if (!SN_PCIBUS_BUSSOFT(bus))
363 return ERR_PTR(-ENODEV);
364
365 return (char *)(SN_PCIBUS_BUSSOFT(bus)->bs_legacy_mem | __IA64_UNCACHED_OFFSET);
366}
367
368int sn_pci_legacy_read(struct pci_bus *bus, u16 port, u32 *val, u8 size)
369{
370 unsigned long addr;
371 int ret;
Mark Maule61b9cf72005-09-23 12:31:53 -0500372 struct ia64_sal_retval isrv;
373
374 /*
375 * First, try the SN_SAL_IOIF_PCI_SAFE SAL call which can work
376 * around hw issues at the pci bus level. SGI proms older than
Simon Arlott72fdbdc2007-05-11 14:55:43 -0700377 * 4.10 don't implement this.
Mark Maule61b9cf72005-09-23 12:31:53 -0500378 */
379
380 SAL_CALL(isrv, SN_SAL_IOIF_PCI_SAFE,
Jes Sorensen8ed9b2c2006-02-13 05:29:57 -0500381 pci_domain_nr(bus), bus->number,
382 0, /* io */
383 0, /* read */
384 port, size, __pa(val));
Mark Maule61b9cf72005-09-23 12:31:53 -0500385
386 if (isrv.status == 0)
387 return size;
388
389 /*
390 * If the above failed, retry using the SAL_PROBE call which should
391 * be present in all proms (but which cannot work round PCI chipset
Simon Arlott72fdbdc2007-05-11 14:55:43 -0700392 * bugs). This code is retained for compatibility with old
Mark Maule61b9cf72005-09-23 12:31:53 -0500393 * pre-4.10 proms, and should be removed at some point in the future.
394 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
396 if (!SN_PCIBUS_BUSSOFT(bus))
397 return -ENODEV;
398
399 addr = SN_PCIBUS_BUSSOFT(bus)->bs_legacy_io | __IA64_UNCACHED_OFFSET;
400 addr += port;
401
402 ret = ia64_sn_probe_mem(addr, (long)size, (void *)val);
403
404 if (ret == 2)
405 return -EINVAL;
406
407 if (ret == 1)
408 *val = -1;
409
410 return size;
411}
412
413int sn_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size)
414{
415 int ret = size;
416 unsigned long paddr;
417 unsigned long *addr;
Mark Maule61b9cf72005-09-23 12:31:53 -0500418 struct ia64_sal_retval isrv;
419
420 /*
421 * First, try the SN_SAL_IOIF_PCI_SAFE SAL call which can work
422 * around hw issues at the pci bus level. SGI proms older than
Simon Arlott72fdbdc2007-05-11 14:55:43 -0700423 * 4.10 don't implement this.
Mark Maule61b9cf72005-09-23 12:31:53 -0500424 */
425
426 SAL_CALL(isrv, SN_SAL_IOIF_PCI_SAFE,
Jes Sorensen8ed9b2c2006-02-13 05:29:57 -0500427 pci_domain_nr(bus), bus->number,
428 0, /* io */
429 1, /* write */
430 port, size, __pa(&val));
Mark Maule61b9cf72005-09-23 12:31:53 -0500431
432 if (isrv.status == 0)
433 return size;
434
435 /*
436 * If the above failed, retry using the SAL_PROBE call which should
437 * be present in all proms (but which cannot work round PCI chipset
Simon Arlott72fdbdc2007-05-11 14:55:43 -0700438 * bugs). This code is retained for compatibility with old
Mark Maule61b9cf72005-09-23 12:31:53 -0500439 * pre-4.10 proms, and should be removed at some point in the future.
440 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
442 if (!SN_PCIBUS_BUSSOFT(bus)) {
443 ret = -ENODEV;
444 goto out;
445 }
446
447 /* Put the phys addr in uncached space */
448 paddr = SN_PCIBUS_BUSSOFT(bus)->bs_legacy_io | __IA64_UNCACHED_OFFSET;
449 paddr += port;
450 addr = (unsigned long *)paddr;
451
452 switch (size) {
453 case 1:
454 *(volatile u8 *)(addr) = (u8)(val);
455 break;
456 case 2:
457 *(volatile u16 *)(addr) = (u16)(val);
458 break;
459 case 4:
460 *(volatile u32 *)(addr) = (u32)(val);
461 break;
462 default:
463 ret = -EINVAL;
464 break;
465 }
466 out:
467 return ret;
468}
FUJITA Tomonorib4391dd2009-01-05 23:36:10 +0900469
470struct dma_mapping_ops sn_dma_ops = {
471 .alloc_coherent = sn_dma_alloc_coherent,
472 .free_coherent = sn_dma_free_coherent,
473 .map_single_attrs = sn_dma_map_single_attrs,
474 .unmap_single_attrs = sn_dma_unmap_single_attrs,
475 .map_sg_attrs = sn_dma_map_sg_attrs,
476 .unmap_sg_attrs = sn_dma_unmap_sg_attrs,
477 .sync_single_for_cpu = sn_dma_sync_single_for_cpu,
478 .sync_sg_for_cpu = sn_dma_sync_sg_for_cpu,
479 .sync_single_for_device = sn_dma_sync_single_for_device,
480 .sync_sg_for_device = sn_dma_sync_sg_for_device,
481 .mapping_error = sn_dma_mapping_error,
482 .dma_supported_op = sn_dma_supported,
483};
FUJITA Tomonori4d9b9772009-01-05 23:36:12 +0900484
485void sn_dma_init(void)
486{
487 dma_ops = &sn_dma_ops;
488}