aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/include/asm/dma.h
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-10-09 18:18:12 -0400
committerMike Frysinger <vapier@gentoo.org>2009-12-15 00:14:18 -0500
commitd2e015d65fc692475b8513259d6afacd2cded8e8 (patch)
treee296f8daa8a7ba957d0ae080c71212f77172d382 /arch/blackfin/include/asm/dma.h
parentadfc046740b4161cbb1f0a3ea0d4200e21113489 (diff)
Blackfin: convert DMA mutex to an atomic and drop redundant code
The DMA channel status field was encoding redundant info wrt the DMA MMR config register, and it was doing an incomplete job of checking all DMA channels (some drivers write directly to the config register). So drop the tristate field in favor of a binary atomic field. This simplifies the code in general, removes the implicit need for sleeping, and forces the suspend code to handle all channels properly. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin/include/asm/dma.h')
-rw-r--r--arch/blackfin/include/asm/dma.h17
1 files changed, 3 insertions, 14 deletions
diff --git a/arch/blackfin/include/asm/dma.h b/arch/blackfin/include/asm/dma.h
index c9a59622e23f..e3c0dfa73d1b 100644
--- a/arch/blackfin/include/asm/dma.h
+++ b/arch/blackfin/include/asm/dma.h
@@ -10,6 +10,7 @@
10 10
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <mach/dma.h> 12#include <mach/dma.h>
13#include <asm/atomic.h>
13#include <asm/blackfin.h> 14#include <asm/blackfin.h>
14#include <asm/page.h> 15#include <asm/page.h>
15 16
@@ -19,11 +20,6 @@
19* Generic DMA Declarations 20* Generic DMA Declarations
20* 21*
21****************************************************************************/ 22****************************************************************************/
22enum dma_chan_status {
23 DMA_CHANNEL_FREE,
24 DMA_CHANNEL_REQUESTED,
25 DMA_CHANNEL_ENABLED,
26};
27 23
28/*------------------------- 24/*-------------------------
29 * config reg bits value 25 * config reg bits value
@@ -104,11 +100,9 @@ struct dma_register {
104 100
105}; 101};
106 102
107struct mutex;
108struct dma_channel { 103struct dma_channel {
109 struct mutex dmalock;
110 const char *device_id; 104 const char *device_id;
111 enum dma_chan_status chan_status; 105 atomic_t chan_status;
112 volatile struct dma_register *regs; 106 volatile struct dma_register *regs;
113 struct dmasg *sg; /* large mode descriptor */ 107 struct dmasg *sg; /* large mode descriptor */
114 unsigned int irq; 108 unsigned int irq;
@@ -220,24 +214,19 @@ static inline void set_dma_sg(unsigned int channel, struct dmasg *sg, int ndsize
220 214
221static inline int dma_channel_active(unsigned int channel) 215static inline int dma_channel_active(unsigned int channel)
222{ 216{
223 if (dma_ch[channel].chan_status == DMA_CHANNEL_FREE) 217 return atomic_read(&dma_ch[channel].chan_status);
224 return 0;
225 else
226 return 1;
227} 218}
228 219
229static inline void disable_dma(unsigned int channel) 220static inline void disable_dma(unsigned int channel)
230{ 221{
231 dma_ch[channel].regs->cfg &= ~DMAEN; 222 dma_ch[channel].regs->cfg &= ~DMAEN;
232 SSYNC(); 223 SSYNC();
233 dma_ch[channel].chan_status = DMA_CHANNEL_REQUESTED;
234} 224}
235static inline void enable_dma(unsigned int channel) 225static inline void enable_dma(unsigned int channel)
236{ 226{
237 dma_ch[channel].regs->curr_x_count = 0; 227 dma_ch[channel].regs->curr_x_count = 0;
238 dma_ch[channel].regs->curr_y_count = 0; 228 dma_ch[channel].regs->curr_y_count = 0;
239 dma_ch[channel].regs->cfg |= DMAEN; 229 dma_ch[channel].regs->cfg |= DMAEN;
240 dma_ch[channel].chan_status = DMA_CHANNEL_ENABLED;
241} 230}
242void free_dma(unsigned int channel); 231void free_dma(unsigned int channel);
243int request_dma(unsigned int channel, const char *device_id); 232int request_dma(unsigned int channel, const char *device_id);