Goodbye mips64. 31704 lines of code bite the dust.
[linux-2.6/linux-mips.git] / arch / mips / kernel / pci-dma.c
blob0bcdad3980d7af0841675db1da6a46474fcebf76
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.
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>
17 #include <asm/io.h>
19 #ifndef UNCAC_BASE /* Hack ... */
20 #define UNCAC_BASE 0x9000000000000000UL
21 #endif
23 void *dma_alloc_coherent(struct device *dev, size_t size,
24 dma_addr_t * dma_handle, int gfp)
26 void *ret;
27 /* ignore region specifiers */
28 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
30 if (dev == NULL || (*dev->dma_mask < 0xffffffff))
31 gfp |= GFP_DMA;
32 ret = (void *) __get_free_pages(gfp, get_order(size));
34 if (ret != NULL) {
35 memset(ret, 0, size);
36 #if 0 /* Broken support for some platforms ... */
37 if (hwdev)
38 bus = hwdev->bus;
39 *dma_handle = bus_to_baddr(bus, __pa(ret));
40 #else
41 *dma_handle = virt_to_phys(ret);
42 #endif
43 #ifdef CONFIG_NONCOHERENT_IO
44 dma_cache_wback_inv((unsigned long) ret, size);
45 ret = UNCAC_ADDR(ret);
46 #endif
49 return ret;
52 void dma_free_coherent(struct device *dev, size_t size,
53 void *vaddr, dma_addr_t dma_handle)
55 unsigned long addr = (unsigned long) vaddr;
57 #ifdef CONFIG_NONCOHERENT_IO
58 addr = CAC_ADDR(addr);
59 #endif
60 free_pages(addr, get_order(size));
63 EXPORT_SYMBOL(pci_alloc_consistent);
64 EXPORT_SYMBOL(pci_free_consistent);