diff options
author | Magnus Damm <magnus.damm@gmail.com> | 2008-01-24 04:40:50 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-01-27 23:19:04 -0500 |
commit | a724605cb7a66d423a494a395f9a8ba871b8a1eb (patch) | |
tree | 4f6345db7b6fb3001782c688c6fd1f07ae9be1b6 /arch/sh/drivers/pci | |
parent | f93e97eaead5c50af35d73cca7301ebbfdff116c (diff) |
sh: use declared coherent memory for dreamcast pci ethernet adapter
This patch makes the dreamcast use the recently added declared coherent
memory functions to point out the memory window suitable for dma.
Apart from cleaning up, this gives the dreamcast a proper memory allocator
for pci dma memory.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/drivers/pci')
-rw-r--r-- | arch/sh/drivers/pci/Makefile | 3 | ||||
-rw-r--r-- | arch/sh/drivers/pci/dma-dreamcast.c | 70 | ||||
-rw-r--r-- | arch/sh/drivers/pci/fixups-dreamcast.c | 10 |
3 files changed, 11 insertions, 72 deletions
diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile index 7bf2a2c823f3..0718805774e8 100644 --- a/arch/sh/drivers/pci/Makefile +++ b/arch/sh/drivers/pci/Makefile | |||
@@ -12,8 +12,7 @@ obj-$(CONFIG_CPU_SUBTYPE_SH7780) += pci-sh7780.o ops-sh4.o | |||
12 | obj-$(CONFIG_CPU_SUBTYPE_SH7785) += pci-sh7780.o ops-sh4.o | 12 | obj-$(CONFIG_CPU_SUBTYPE_SH7785) += pci-sh7780.o ops-sh4.o |
13 | obj-$(CONFIG_CPU_SH5) += pci-sh5.o ops-sh5.o | 13 | obj-$(CONFIG_CPU_SH5) += pci-sh5.o ops-sh5.o |
14 | 14 | ||
15 | obj-$(CONFIG_SH_DREAMCAST) += ops-dreamcast.o fixups-dreamcast.o \ | 15 | obj-$(CONFIG_SH_DREAMCAST) += ops-dreamcast.o fixups-dreamcast.o |
16 | dma-dreamcast.o | ||
17 | obj-$(CONFIG_SH_SECUREEDGE5410) += ops-snapgear.o | 16 | obj-$(CONFIG_SH_SECUREEDGE5410) += ops-snapgear.o |
18 | obj-$(CONFIG_SH_RTS7751R2D) += ops-rts7751r2d.o fixups-rts7751r2d.o | 17 | obj-$(CONFIG_SH_RTS7751R2D) += ops-rts7751r2d.o fixups-rts7751r2d.o |
19 | obj-$(CONFIG_SH_SH03) += ops-sh03.o fixups-sh03.o | 18 | obj-$(CONFIG_SH_SH03) += ops-sh03.o fixups-sh03.o |
diff --git a/arch/sh/drivers/pci/dma-dreamcast.c b/arch/sh/drivers/pci/dma-dreamcast.c deleted file mode 100644 index 888a34050599..000000000000 --- a/arch/sh/drivers/pci/dma-dreamcast.c +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | /* | ||
2 | * arch/sh/drivers/pci/dma-dreamcast.c | ||
3 | * | ||
4 | * PCI DMA support for the Sega Dreamcast | ||
5 | * | ||
6 | * Copyright (C) 2001, 2002 M. R. Brown | ||
7 | * Copyright (C) 2002, 2003 Paul Mundt | ||
8 | * | ||
9 | * This file originally bore the message (with enclosed-$): | ||
10 | * Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp | ||
11 | * Dreamcast PCI: Supports SEGA Broadband Adaptor only. | ||
12 | * | ||
13 | * This file is subject to the terms and conditions of the GNU General Public | ||
14 | * License. See the file "COPYING" in the main directory of this archive | ||
15 | * for more details. | ||
16 | */ | ||
17 | |||
18 | #include <linux/sched.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/param.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/irq.h> | ||
24 | #include <linux/pci.h> | ||
25 | #include <linux/dma-mapping.h> | ||
26 | #include <linux/device.h> | ||
27 | |||
28 | #include <asm/io.h> | ||
29 | #include <asm/irq.h> | ||
30 | #include <asm/mach/pci.h> | ||
31 | |||
32 | static int gapspci_dma_used = 0; | ||
33 | |||
34 | void *dreamcast_consistent_alloc(struct device *dev, size_t size, | ||
35 | dma_addr_t *dma_handle, gfp_t flag) | ||
36 | { | ||
37 | unsigned long buf; | ||
38 | |||
39 | if (dev && dev->bus != &pci_bus_type) | ||
40 | return NULL; | ||
41 | |||
42 | if (gapspci_dma_used + size > GAPSPCI_DMA_SIZE) | ||
43 | return ERR_PTR(-EINVAL); | ||
44 | |||
45 | buf = GAPSPCI_DMA_BASE + gapspci_dma_used; | ||
46 | |||
47 | gapspci_dma_used = PAGE_ALIGN(gapspci_dma_used+size); | ||
48 | |||
49 | *dma_handle = (dma_addr_t)buf; | ||
50 | |||
51 | buf = P2SEGADDR(buf); | ||
52 | |||
53 | /* Flush the dcache before we hand off the buffer */ | ||
54 | __flush_purge_region((void *)buf, size); | ||
55 | |||
56 | return (void *)buf; | ||
57 | } | ||
58 | |||
59 | int dreamcast_consistent_free(struct device *dev, size_t size, | ||
60 | void *vaddr, dma_addr_t dma_handle) | ||
61 | { | ||
62 | if (dev && dev->bus != &pci_bus_type) | ||
63 | return -EINVAL; | ||
64 | |||
65 | /* XXX */ | ||
66 | gapspci_dma_used = 0; | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
diff --git a/arch/sh/drivers/pci/fixups-dreamcast.c b/arch/sh/drivers/pci/fixups-dreamcast.c index 6f53f8200dc3..c44699301eeb 100644 --- a/arch/sh/drivers/pci/fixups-dreamcast.c +++ b/arch/sh/drivers/pci/fixups-dreamcast.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/irq.h> | 23 | #include <linux/irq.h> |
24 | #include <linux/pci.h> | 24 | #include <linux/pci.h> |
25 | #include <linux/dma-mapping.h> | ||
25 | 26 | ||
26 | #include <asm/io.h> | 27 | #include <asm/io.h> |
27 | #include <asm/irq.h> | 28 | #include <asm/irq.h> |
@@ -40,6 +41,15 @@ static void __init gapspci_fixup_resources(struct pci_dev *dev) | |||
40 | */ | 41 | */ |
41 | dev->resource[1].start = p->io_resource->start + 0x100; | 42 | dev->resource[1].start = p->io_resource->start + 0x100; |
42 | dev->resource[1].end = dev->resource[1].start + 0x200 - 1; | 43 | dev->resource[1].end = dev->resource[1].start + 0x200 - 1; |
44 | /* | ||
45 | * Redirect dma memory allocations to special memory window. | ||
46 | */ | ||
47 | BUG_ON(!dma_declare_coherent_memory(&dev->dev, | ||
48 | GAPSPCI_DMA_BASE, | ||
49 | GAPSPCI_DMA_BASE, | ||
50 | GAPSPCI_DMA_SIZE, | ||
51 | DMA_MEMORY_MAP | | ||
52 | DMA_MEMORY_EXCLUSIVE)); | ||
43 | break; | 53 | break; |
44 | default: | 54 | default: |
45 | printk("PCI: Failed resource fixup\n"); | 55 | printk("PCI: Failed resource fixup\n"); |