patch-2.4.0-test9 linux/arch/arm/kernel/dma-isa.c

Next file: linux/arch/arm/kernel/dma-rpc.c
Previous file: linux/arch/arm/kernel/dma-footbridge.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test8/linux/arch/arm/kernel/dma-isa.c linux/arch/arm/kernel/dma-isa.c
@@ -1,24 +1,30 @@
 /*
- * arch/arm/kernel/dma-isa.c: ISA DMA primitives
+ *  linux/arch/arm/kernel/dma-isa.c
  *
- * Copyright (C) 1999-2000 Russell King
+ *  Copyright (C) 1999-2000 Russell King
  *
- * Taken from various sources, including:
- *  linux/include/asm/dma.h: Defines for using and allocating dma channels.
- *    Written by Hennus Bergman, 1992.
- *    High DMA channel support & info by Hannu Savolainen and John Boyd,
- *    Nov. 1992.
- *  arch/arm/kernel/dma-ebsa285.c
- *  Copyright (C) 1998 Phil Blundell
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  ISA DMA primitives
+ *  Taken from various sources, including:
+ *   linux/include/asm/dma.h: Defines for using and allocating dma channels.
+ *     Written by Hennus Bergman, 1992.
+ *     High DMA channel support & info by Hannu Savolainen and John Boyd,
+ *     Nov. 1992.
+ *   arch/arm/kernel/dma-ebsa285.c
+ *   Copyright (C) 1998 Phil Blundell
  */
 #include <linux/sched.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
+#include <linux/pci.h>
 
 #include <asm/dma.h>
 #include <asm/io.h>
 
-#include "dma.h"
+#include <asm/mach/dma.h>
 
 #define ISA_DMA_MODE_READ	0x44
 #define ISA_DMA_MODE_WRITE	0x48
@@ -60,47 +66,57 @@
 {
 	if (dma->invalid) {
 		unsigned long address, length;
-		unsigned int mode;
-
-		address = dma->buf.address;
-		length  = dma->buf.length - 1;
-
-		outb(address >> 16, isa_dma_port[channel][ISA_DMA_PGLO]);
-		outb(address >> 24, isa_dma_port[channel][ISA_DMA_PGHI]);
-
-		if (channel >= 4) {
-			address >>= 1;
-			length >>= 1;
-		}
-
-		outb(0, isa_dma_port[channel][ISA_DMA_CLRFF]);
-
-		outb(address, isa_dma_port[channel][ISA_DMA_ADDR]);
-		outb(address >> 8, isa_dma_port[channel][ISA_DMA_ADDR]);
-
-		outb(length, isa_dma_port[channel][ISA_DMA_COUNT]);
-		outb(length >> 8, isa_dma_port[channel][ISA_DMA_COUNT]);
+		unsigned int mode, direction;
 
 		mode = channel & 3;
-
 		switch (dma->dma_mode & DMA_MODE_MASK) {
 		case DMA_MODE_READ:
 			mode |= ISA_DMA_MODE_READ;
-			dma_cache_inv(__bus_to_virt(dma->buf.address), dma->buf.length);
+			direction = PCI_DMA_FROMDEVICE;
 			break;
 
 		case DMA_MODE_WRITE:
 			mode |= ISA_DMA_MODE_WRITE;
-			dma_cache_wback(__bus_to_virt(dma->buf.address), dma->buf.length);
+			direction = PCI_DMA_TODEVICE;
 			break;
 
 		case DMA_MODE_CASCADE:
 			mode |= ISA_DMA_MODE_CASCADE;
+			direction = PCI_DMA_BIDIRECTIONAL;
 			break;
 
 		default:
 			break;
 		}
+
+		if (!dma->using_sg) {
+			/*
+			 * Cope with ISA-style drivers which expect cache
+			 * coherence.
+			 */
+			dma->buf.dma_address = pci_map_single(NULL,
+				dma->buf.address, dma->buf.length,
+				direction);
+		}
+
+		address = dma->buf.dma_address;
+		length  = dma->buf.length - 1;
+
+		outb(address >> 16, isa_dma_port[channel][ISA_DMA_PGLO]);
+		outb(address >> 24, isa_dma_port[channel][ISA_DMA_PGHI]);
+
+		if (channel >= 4) {
+			address >>= 1;
+			length >>= 1;
+		}
+
+		outb(0, isa_dma_port[channel][ISA_DMA_CLRFF]);
+
+		outb(address, isa_dma_port[channel][ISA_DMA_ADDR]);
+		outb(address >> 8, isa_dma_port[channel][ISA_DMA_ADDR]);
+
+		outb(length, isa_dma_port[channel][ISA_DMA_COUNT]);
+		outb(length >> 8, isa_dma_port[channel][ISA_DMA_COUNT]);
 
 		if (dma->dma_mode & DMA_AUTOINIT)
 			mode |= ISA_DMA_AUTOINIT;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)