aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2006-01-04 10:08:30 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-01-04 10:08:30 -0500
commit7cdad482974792419cfe4b0affca689170116f49 (patch)
treef9ee204f8848274ffb3323f425ad039cf4807de6
parent333c9624b728a9e83b741ea75836aa114ec35272 (diff)
[ARM] Remove '__address' from scatterlist and convert to DMA API
The old __address element in struct scatterlist remained from older kernels because the ARM DMA emulation code made use of it. Move this field into struct dma_struct, and convert DMA emulation code to setup a SG entry as required. Also, convert DMA emulation code to use the new DMA API rather than the PCI DMA API. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/kernel/dma-isa.c22
-rw-r--r--arch/arm/kernel/dma.c13
-rw-r--r--arch/arm/mach-rpc/dma.c19
-rw-r--r--include/asm-arm/mach/dma.h4
-rw-r--r--include/asm-arm/scatterlist.h1
5 files changed, 31 insertions, 28 deletions
diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c
index e9a36304ec3e..03532769a97f 100644
--- a/arch/arm/kernel/dma-isa.c
+++ b/arch/arm/kernel/dma-isa.c
@@ -18,7 +18,7 @@
18 */ 18 */
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/pci.h> 21#include <linux/dma-mapping.h>
22 22
23#include <asm/dma.h> 23#include <asm/dma.h>
24#include <asm/io.h> 24#include <asm/io.h>
@@ -65,37 +65,41 @@ static void isa_enable_dma(dmach_t channel, dma_t *dma)
65{ 65{
66 if (dma->invalid) { 66 if (dma->invalid) {
67 unsigned long address, length; 67 unsigned long address, length;
68 unsigned int mode, direction; 68 unsigned int mode;
69 enum dma_data_direction direction;
69 70
70 mode = channel & 3; 71 mode = channel & 3;
71 switch (dma->dma_mode & DMA_MODE_MASK) { 72 switch (dma->dma_mode & DMA_MODE_MASK) {
72 case DMA_MODE_READ: 73 case DMA_MODE_READ:
73 mode |= ISA_DMA_MODE_READ; 74 mode |= ISA_DMA_MODE_READ;
74 direction = PCI_DMA_FROMDEVICE; 75 direction = DMA_FROM_DEVICE;
75 break; 76 break;
76 77
77 case DMA_MODE_WRITE: 78 case DMA_MODE_WRITE:
78 mode |= ISA_DMA_MODE_WRITE; 79 mode |= ISA_DMA_MODE_WRITE;
79 direction = PCI_DMA_TODEVICE; 80 direction = DMA_TO_DEVICE;
80 break; 81 break;
81 82
82 case DMA_MODE_CASCADE: 83 case DMA_MODE_CASCADE:
83 mode |= ISA_DMA_MODE_CASCADE; 84 mode |= ISA_DMA_MODE_CASCADE;
84 direction = PCI_DMA_BIDIRECTIONAL; 85 direction = DMA_BIDIRECTIONAL;
85 break; 86 break;
86 87
87 default: 88 default:
88 direction = PCI_DMA_NONE; 89 direction = DMA_NONE;
89 break; 90 break;
90 } 91 }
91 92
92 if (!dma->using_sg) { 93 if (!dma->sg) {
93 /* 94 /*
94 * Cope with ISA-style drivers which expect cache 95 * Cope with ISA-style drivers which expect cache
95 * coherence. 96 * coherence.
96 */ 97 */
97 dma->buf.dma_address = pci_map_single(NULL, 98 dma->sg = &dma->buf;
98 dma->buf.__address, dma->buf.length, 99 dma->sgcount = 1;
100 dma->buf.length = dma->count;
101 dma->buf.dma_address = dma_map_single(NULL,
102 dma->addr, dma->count,
99 direction); 103 direction);
100 } 104 }
101 105
diff --git a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c
index 3aedada71046..913fd947528c 100644
--- a/arch/arm/kernel/dma.c
+++ b/arch/arm/kernel/dma.c
@@ -123,7 +123,6 @@ void set_dma_sg (dmach_t channel, struct scatterlist *sg, int nr_sg)
123 123
124 dma->sg = sg; 124 dma->sg = sg;
125 dma->sgcount = nr_sg; 125 dma->sgcount = nr_sg;
126 dma->using_sg = 1;
127 dma->invalid = 1; 126 dma->invalid = 1;
128} 127}
129 128
@@ -139,10 +138,8 @@ void __set_dma_addr (dmach_t channel, void *addr)
139 printk(KERN_ERR "dma%d: altering DMA address while " 138 printk(KERN_ERR "dma%d: altering DMA address while "
140 "DMA active\n", channel); 139 "DMA active\n", channel);
141 140
142 dma->sg = &dma->buf; 141 dma->sg = NULL;
143 dma->sgcount = 1; 142 dma->addr = addr;
144 dma->buf.__address = addr;
145 dma->using_sg = 0;
146 dma->invalid = 1; 143 dma->invalid = 1;
147} 144}
148 145
@@ -158,10 +155,8 @@ void set_dma_count (dmach_t channel, unsigned long count)
158 printk(KERN_ERR "dma%d: altering DMA count while " 155 printk(KERN_ERR "dma%d: altering DMA count while "
159 "DMA active\n", channel); 156 "DMA active\n", channel);
160 157
161 dma->sg = &dma->buf; 158 dma->sg = NULL;
162 dma->sgcount = 1; 159 dma->count = count;
163 dma->buf.length = count;
164 dma->using_sg = 0;
165 dma->invalid = 1; 160 dma->invalid = 1;
166} 161}
167 162
diff --git a/arch/arm/mach-rpc/dma.c b/arch/arm/mach-rpc/dma.c
index bc0747439fb3..bd86ffba8810 100644
--- a/arch/arm/mach-rpc/dma.c
+++ b/arch/arm/mach-rpc/dma.c
@@ -13,7 +13,7 @@
13#include <linux/mman.h> 13#include <linux/mman.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/pci.h> 16#include <linux/dma-mapping.h>
17 17
18#include <asm/page.h> 18#include <asm/page.h>
19#include <asm/dma.h> 19#include <asm/dma.h>
@@ -148,11 +148,14 @@ static void iomd_enable_dma(dmach_t channel, dma_t *dma)
148 * Cope with ISA-style drivers which expect cache 148 * Cope with ISA-style drivers which expect cache
149 * coherence. 149 * coherence.
150 */ 150 */
151 if (!dma->using_sg) { 151 if (!dma->sg) {
152 dma->buf.dma_address = pci_map_single(NULL, 152 dma->sg = &dma->buf;
153 dma->buf.__address, dma->buf.length, 153 dma->sgcount = 1;
154 dma->buf.length = dma->count;
155 dma->buf.dma_address = dma_map_single(NULL,
156 dma->addr, dma->count,
154 dma->dma_mode == DMA_MODE_READ ? 157 dma->dma_mode == DMA_MODE_READ ?
155 PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); 158 DMA_FROM_DEVICE : DMA_TO_DEVICE);
156 } 159 }
157 160
158 iomd_writeb(DMA_CR_C, dma_base + CR); 161 iomd_writeb(DMA_CR_C, dma_base + CR);
@@ -239,7 +242,7 @@ static void floppy_enable_dma(dmach_t channel, dma_t *dma)
239 unsigned int fiqhandler_length; 242 unsigned int fiqhandler_length;
240 struct pt_regs regs; 243 struct pt_regs regs;
241 244
242 if (dma->using_sg) 245 if (dma->sg)
243 BUG(); 246 BUG();
244 247
245 if (dma->dma_mode == DMA_MODE_READ) { 248 if (dma->dma_mode == DMA_MODE_READ) {
@@ -252,8 +255,8 @@ static void floppy_enable_dma(dmach_t channel, dma_t *dma)
252 fiqhandler_length = &floppy_fiqout_end - &floppy_fiqout_start; 255 fiqhandler_length = &floppy_fiqout_end - &floppy_fiqout_start;
253 } 256 }
254 257
255 regs.ARM_r9 = dma->buf.length; 258 regs.ARM_r9 = dma->count;
256 regs.ARM_r10 = (unsigned long)dma->buf.__address; 259 regs.ARM_r10 = (unsigned long)dma->addr;
257 regs.ARM_fp = (unsigned long)FLOPPYDMA_BASE; 260 regs.ARM_fp = (unsigned long)FLOPPYDMA_BASE;
258 261
259 if (claim_fiq(&fh)) { 262 if (claim_fiq(&fh)) {
diff --git a/include/asm-arm/mach/dma.h b/include/asm-arm/mach/dma.h
index 31bf716106ee..e7c4a20aad53 100644
--- a/include/asm-arm/mach/dma.h
+++ b/include/asm-arm/mach/dma.h
@@ -25,13 +25,15 @@ struct dma_ops {
25}; 25};
26 26
27struct dma_struct { 27struct dma_struct {
28 void *addr; /* single DMA address */
29 unsigned long count; /* single DMA size */
28 struct scatterlist buf; /* single DMA */ 30 struct scatterlist buf; /* single DMA */
29 int sgcount; /* number of DMA SG */ 31 int sgcount; /* number of DMA SG */
30 struct scatterlist *sg; /* DMA Scatter-Gather List */ 32 struct scatterlist *sg; /* DMA Scatter-Gather List */
31 33
32 unsigned int active:1; /* Transfer active */ 34 unsigned int active:1; /* Transfer active */
33 unsigned int invalid:1; /* Address/Count changed */ 35 unsigned int invalid:1; /* Address/Count changed */
34 unsigned int using_sg:1; /* using scatter list? */ 36
35 dmamode_t dma_mode; /* DMA mode */ 37 dmamode_t dma_mode; /* DMA mode */
36 int speed; /* DMA speed */ 38 int speed; /* DMA speed */
37 39
diff --git a/include/asm-arm/scatterlist.h b/include/asm-arm/scatterlist.h
index 83b876fb04cc..de2f65eb42ed 100644
--- a/include/asm-arm/scatterlist.h
+++ b/include/asm-arm/scatterlist.h
@@ -9,7 +9,6 @@ struct scatterlist {
9 unsigned int offset; /* buffer offset */ 9 unsigned int offset; /* buffer offset */
10 dma_addr_t dma_address; /* dma address */ 10 dma_addr_t dma_address; /* dma address */
11 unsigned int length; /* length */ 11 unsigned int length; /* length */
12 char *__address; /* for set_dma_addr */
13}; 12};
14 13
15/* 14/*