summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-11-22 15:51:26 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-11-22 15:51:26 +0000
commit4a13312b4c9256ff4bc5eba83ac242448bf1cd4b (patch)
treeaa7d33f4d9b05a7419cb9d8656c0f4ac58367bee
parent316578bcc36452acee5f116b547d968c9b7b64bd (diff)
Unify the dozen pci-dma copies we had.
-rw-r--r--arch/mips/ddb5074/Makefile2
-rw-r--r--arch/mips/ddb5476/Makefile2
-rw-r--r--arch/mips/ddb5476/pci-dma.c48
-rw-r--r--arch/mips/galileo-boards/ev96100/Makefile3
-rw-r--r--arch/mips/galileo-boards/ev96100/pci-dma.c49
-rw-r--r--arch/mips/kernel/Makefile7
-rw-r--r--arch/mips/kernel/pci-dma.c (renamed from arch/mips/ddb5074/pci-dma.c)11
-rw-r--r--arch/mips/mips-boards/generic/Makefile2
-rw-r--r--arch/mips/mips-boards/generic/pci-dma.c57
9 files changed, 15 insertions, 166 deletions
diff --git a/arch/mips/ddb5074/Makefile b/arch/mips/ddb5074/Makefile
index 559e0bc8e..d041acef5 100644
--- a/arch/mips/ddb5074/Makefile
+++ b/arch/mips/ddb5074/Makefile
@@ -17,6 +17,6 @@
$(CC) $(CFLAGS) -c $< -o $*.o
O_TARGET = ddb5074.a
-O_OBJS = setup.o irq.o time.o prom.o pci.o pci-dma.o int-handler.o nile4.o
+O_OBJS = setup.o irq.o time.o prom.o pci.o int-handler.o nile4.o
include $(TOPDIR)/Rules.make
diff --git a/arch/mips/ddb5476/Makefile b/arch/mips/ddb5476/Makefile
index 330aed8a1..cb061ab5f 100644
--- a/arch/mips/ddb5476/Makefile
+++ b/arch/mips/ddb5476/Makefile
@@ -15,7 +15,7 @@
$(CC) $(CFLAGS) -c $< -o $*.o
O_TARGET = ddb5476.a
-O_OBJS = setup.o irq.o time.o prom.o pci.o pci-dma.o int-handler.o nile4.o
+O_OBJS = setup.o irq.o time.o prom.o pci.o int-handler.o nile4.o
ifdef CONFIG_REMOTE_DEBUG
O_OBJS += dbg_io.o
diff --git a/arch/mips/ddb5476/pci-dma.c b/arch/mips/ddb5476/pci-dma.c
deleted file mode 100644
index 1e824cc93..000000000
--- a/arch/mips/ddb5476/pci-dma.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Ani Joshi <ajoshi@unixbox.com>
- *
- *
- * Dynamic DMA mapping support.
- *
- * swiped from i386, and cloned for MIPS by Geert.
- *
- */
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-
-#include <asm/io.h>
-
-/*
- * [jsun] We want to return non-cached area so that data can be consistent
- * Apparently on x86, this is not an issue because cache is automatically
- * invalidated.
- *
- * To make we are doing the right thing, I add some extra debug macros.
- */
-
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
- dma_addr_t * dma_handle)
-{
- void *ret;
- int gfp = GFP_ATOMIC;
-
- if (hwdev == NULL || hwdev->dma_mask != 0xffffffff)
- gfp |= GFP_DMA;
- ret = (void *) __get_free_pages(gfp, get_order(size));
-
- if (ret != NULL) {
- dma_cache_inv((unsigned long) ret, size);
- *dma_handle = virt_to_bus(ret);
- }
- ret = (void *) ((unsigned long) ret | 0x20000000);
- return ret;
-}
-
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
- void *vaddr, dma_addr_t dma_handle)
-{
- vaddr = (void *) ((unsigned long) vaddr & ~0x20000000);
- free_pages((unsigned long) vaddr, get_order(size));
-}
diff --git a/arch/mips/galileo-boards/ev96100/Makefile b/arch/mips/galileo-boards/ev96100/Makefile
index 90034f016..8759aa161 100644
--- a/arch/mips/galileo-boards/ev96100/Makefile
+++ b/arch/mips/galileo-boards/ev96100/Makefile
@@ -19,7 +19,8 @@ all: ev96100.o
O_TARGET:= ev96100.o
-O_OBJS:= prom.o time.o rtc.o irq.o int-handler.o setup.o puts.o uart.o pci-dma.o memory.o
+O_OBJS:= prom.o time.o rtc.o irq.o int-handler.o setup.o puts.o uart.o \
+ memory.o
dep:
$(CPP) -M *.c > .depend
diff --git a/arch/mips/galileo-boards/ev96100/pci-dma.c b/arch/mips/galileo-boards/ev96100/pci-dma.c
deleted file mode 100644
index b338b286a..000000000
--- a/arch/mips/galileo-boards/ev96100/pci-dma.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2000 Ani Joshi <ajoshi@unixbox.com>
- *
- *
- * Dynamic DMA mapping support.
- *
- * swiped from i386, and cloned for MIPS by Geert.
- *
- */
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <asm/io.h>
-
-/*
- * [jsun] We want to return non-cached area so that data can be consistent
- * Apparently on x86, this is not an issue because cache is automatically
- * invalidated.
- *
- * To make we are doing the right thing, I add some extra debug macros.
- */
-
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
- dma_addr_t *dma_handle)
-{
- void *ret;
- int gfp = GFP_ATOMIC;
-
- if (hwdev == NULL || hwdev->dma_mask != 0xffffffff)
- gfp |= GFP_DMA;
- ret = (void *)__get_free_pages(gfp, get_order(size));
-
- if (ret != NULL) {
- dma_cache_inv((unsigned long)ret, size);
- *dma_handle = virt_to_bus(ret);
- }
- ret = (void*) ((unsigned long)ret | 0xA0000000);
-
- return ret;
-}
-
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
- void *vaddr, dma_addr_t dma_handle)
-{
- vaddr = (void*) ((unsigned long)vaddr & ~0xA0000000);
- free_pages((unsigned long)vaddr, get_order(size));
-}
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 5346c9d38..01b2148bf 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -64,9 +64,10 @@ ifdef CONFIG_REMOTE_DEBUG
O_OBJS += gdb-low.o gdb-stub.o
endif
-#
-# Depending from some other kernel option
-#
+ifdef CONFIG_PCI
+O_OBJS += pci-dma.o
+endif
+
ifdef CONFIG_PROC_FS
O_OBJS += proc.o
endif
diff --git a/arch/mips/ddb5074/pci-dma.c b/arch/mips/kernel/pci-dma.c
index e1f881a36..de9cb90aa 100644
--- a/arch/mips/ddb5074/pci-dma.c
+++ b/arch/mips/kernel/pci-dma.c
@@ -1,9 +1,9 @@
/*
- * Copyright (C) 2000 Ani Joshi <ajoshi@unixbox.com>
*
* Dynamic DMA mapping support.
*
- * swiped from i386, and cloned for MIPS by Geert.
+ * Copyright (C) 2000 Ani Joshi <ajoshi@unixbox.com>
+ * swiped from i386, and cloned for MIPS by Geert, polished by Ralf.
*/
#include <linux/types.h>
#include <linux/mm.h>
@@ -23,14 +23,15 @@ void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
ret = (void *) __get_free_pages(gfp, get_order(size));
if (ret != NULL) {
- memset(ret, 0, size);
+ dma_cache_inv((unsigned long) ret, size);
*dma_handle = virt_to_bus(ret);
}
- return ret;
+
+ return KSEG1ADDR(ret);
}
void pci_free_consistent(struct pci_dev *hwdev, size_t size,
void *vaddr, dma_addr_t dma_handle)
{
- free_pages((unsigned long) vaddr, get_order(size));
+ free_pages((unsigned long) KSEG0ADDR(vaddr), get_order(size));
}
diff --git a/arch/mips/mips-boards/generic/Makefile b/arch/mips/mips-boards/generic/Makefile
index 40aeccfff..c76f6fd46 100644
--- a/arch/mips/mips-boards/generic/Makefile
+++ b/arch/mips/mips-boards/generic/Makefile
@@ -37,6 +37,6 @@ all: mipsboards.o
O_TARGET := mipsboards.o
O_OBJS := mipsIRQ.o pci.o reset.o display.o init.o memory.o printf.o \
- cmdline.o time.o pci-dma.o
+ cmdline.o time.o
include $(TOPDIR)/Rules.make
diff --git a/arch/mips/mips-boards/generic/pci-dma.c b/arch/mips/mips-boards/generic/pci-dma.c
deleted file mode 100644
index 316ec9029..000000000
--- a/arch/mips/mips-boards/generic/pci-dma.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Carsten Langgaard, carstenl@mips.com
- * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
- *
- * ########################################################################
- *
- * This program is free software; you can distribute it and/or modify it
- * under the terms of the GNU General Public License (Version 2) as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * ########################################################################
- *
- * Dynamic DMA mapping support.
- *
- */
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-
-#include <asm/io.h>
-
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
- dma_addr_t * dma_handle)
-{
- void *ret;
- int gfp = GFP_ATOMIC;
-
- if (hwdev == NULL || hwdev->dma_mask != 0xffffffff)
- gfp |= GFP_DMA;
- ret = (void *) __get_free_pages(gfp, get_order(size));
-
- if (ret != NULL) {
- memset(ret, 0, size);
- *dma_handle = virt_to_bus(ret);
- }
-
- dma_cache_wback_inv((unsigned long)ret, size);
- return KSEG1ADDR(ret);
-}
-
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
- void *vaddr, dma_addr_t dma_handle)
-{
- free_pages((unsigned long) KSEG0ADDR(vaddr), get_order(size));
-}
-
-