diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2008-12-08 11:33:30 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-12-11 09:32:43 -0500 |
commit | 2f757f2ab7411cf0e2779012d8cda0cbf2f80d26 (patch) | |
tree | 880e0c661948132d54ce238eb45cba9bb71314d4 /arch/arm/kernel | |
parent | 3afb6e9c635f735c751148beddc195daec0e35ec (diff) |
[ARM] dma: rejig DMA initialization
Rather than having the central DMA multiplexer call the architecture
specific DMA initialization function, have each architecture DMA
initialization function use core_initcall(), and register each DMA
channel separately with the multiplexer.
This removes the array of dma structures in the central multiplexer,
replacing it with an array of pointers instead; this is more flexible
since it allows the drivers to wrap the DMA structure (eventually
allowing us to transition non-ISA DMA drivers away.)
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/kernel')
-rw-r--r-- | arch/arm/kernel/dma-isa.c | 18 | ||||
-rw-r--r-- | arch/arm/kernel/dma.c | 25 |
2 files changed, 28 insertions, 15 deletions
diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c index 29eca48925d8..da02a7ff3419 100644 --- a/arch/arm/kernel/dma-isa.c +++ b/arch/arm/kernel/dma-isa.c | |||
@@ -160,7 +160,12 @@ static struct resource dma_resources[] = { { | |||
160 | .end = 0x048f | 160 | .end = 0x048f |
161 | } }; | 161 | } }; |
162 | 162 | ||
163 | void __init isa_init_dma(dma_t *dma) | 163 | static dma_t isa_dma[8]; |
164 | |||
165 | /* | ||
166 | * ISA DMA always starts at channel 0 | ||
167 | */ | ||
168 | void __init isa_init_dma(void) | ||
164 | { | 169 | { |
165 | /* | 170 | /* |
166 | * Try to autodetect presence of an ISA DMA controller. | 171 | * Try to autodetect presence of an ISA DMA controller. |
@@ -178,10 +183,10 @@ void __init isa_init_dma(dma_t *dma) | |||
178 | outb(0xaa, 0x00); | 183 | outb(0xaa, 0x00); |
179 | 184 | ||
180 | if (inb(0) == 0x55 && inb(0) == 0xaa) { | 185 | if (inb(0) == 0x55 && inb(0) == 0xaa) { |
181 | int chan, i; | 186 | unsigned int chan, i; |
182 | 187 | ||
183 | for (chan = 0; chan < 8; chan++) { | 188 | for (chan = 0; chan < 8; chan++) { |
184 | dma[chan].d_ops = &isa_dma_ops; | 189 | isa_dma[chan].d_ops = &isa_dma_ops; |
185 | isa_disable_dma(chan, NULL); | 190 | isa_disable_dma(chan, NULL); |
186 | } | 191 | } |
187 | 192 | ||
@@ -217,5 +222,12 @@ void __init isa_init_dma(dma_t *dma) | |||
217 | 222 | ||
218 | for (i = 0; i < ARRAY_SIZE(dma_resources); i++) | 223 | for (i = 0; i < ARRAY_SIZE(dma_resources); i++) |
219 | request_resource(&ioport_resource, dma_resources + i); | 224 | request_resource(&ioport_resource, dma_resources + i); |
225 | |||
226 | for (chan = 0; chan < 8; chan++) { | ||
227 | int ret = isa_dma_add(chan, &isa_dma[chan]); | ||
228 | if (ret) | ||
229 | printk(KERN_ERR "ISADMA%u: unable to register: %d\n", | ||
230 | chan, ret); | ||
231 | } | ||
220 | } | 232 | } |
221 | } | 233 | } |
diff --git a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c index 0ffea3fc22db..aab24f03ea14 100644 --- a/arch/arm/kernel/dma.c +++ b/arch/arm/kernel/dma.c | |||
@@ -23,16 +23,24 @@ | |||
23 | DEFINE_SPINLOCK(dma_spin_lock); | 23 | DEFINE_SPINLOCK(dma_spin_lock); |
24 | EXPORT_SYMBOL(dma_spin_lock); | 24 | EXPORT_SYMBOL(dma_spin_lock); |
25 | 25 | ||
26 | static dma_t dma_chan[MAX_DMA_CHANNELS]; | 26 | static dma_t *dma_chan[MAX_DMA_CHANNELS]; |
27 | 27 | ||
28 | static inline dma_t *dma_channel(unsigned int chan) | 28 | static inline dma_t *dma_channel(unsigned int chan) |
29 | { | 29 | { |
30 | dma_t *dma = dma_chan + chan; | 30 | if (chan >= MAX_DMA_CHANNELS) |
31 | |||
32 | if (chan >= MAX_DMA_CHANNELS || !dma->d_ops) | ||
33 | return NULL; | 31 | return NULL; |
34 | 32 | ||
35 | return dma; | 33 | return dma_chan[chan]; |
34 | } | ||
35 | |||
36 | int __init isa_dma_add(unsigned int chan, dma_t *dma) | ||
37 | { | ||
38 | if (!dma->d_ops) | ||
39 | return -EINVAL; | ||
40 | if (dma_chan[chan]) | ||
41 | return -EBUSY; | ||
42 | dma_chan[chan] = dma; | ||
43 | return 0; | ||
36 | } | 44 | } |
37 | 45 | ||
38 | /* | 46 | /* |
@@ -252,10 +260,3 @@ int get_dma_residue(unsigned int chan) | |||
252 | return ret; | 260 | return ret; |
253 | } | 261 | } |
254 | EXPORT_SYMBOL(get_dma_residue); | 262 | EXPORT_SYMBOL(get_dma_residue); |
255 | |||
256 | static int __init init_dma(void) | ||
257 | { | ||
258 | arch_dma_init(dma_chan); | ||
259 | return 0; | ||
260 | } | ||
261 | core_initcall(init_dma); | ||