Linux-2.6.12-rc2
[linux-2.6/next.git] / arch / sh / boards / overdrive / pcidma.c
blob1c9bfeda00b7aa52a0823104dd407a3729df103a
1 /*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
7 * Dynamic DMA mapping support.
9 * On the overdrive, we can only DMA from memory behind the PCI bus!
10 * this means that all DMA'able memory must come from there.
11 * this restriction will not apply to later boards.
14 #include <linux/types.h>
15 #include <linux/mm.h>
16 #include <linux/string.h>
17 #include <linux/pci.h>
18 #include <asm/io.h>
20 void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
21 dma_addr_t * dma_handle)
23 void *ret;
24 int gfp = GFP_ATOMIC;
26 printk("BUG: pci_alloc_consistent() called - not yet supported\n");
27 /* We ALWAYS need DMA memory on the overdrive hardware,
28 * due to it's extreme weirdness
29 * Need to flush the cache here as well, since the memory
30 * can still be seen through the cache!
32 gfp |= GFP_DMA;
33 ret = (void *) __get_free_pages(gfp, get_order(size));
35 if (ret != NULL) {
36 memset(ret, 0, size);
37 *dma_handle = virt_to_bus(ret);
39 return ret;
42 void pci_free_consistent(struct pci_dev *hwdev, size_t size,
43 void *vaddr, dma_addr_t dma_handle)
45 free_pages((unsigned long) vaddr, get_order(size));