[ARM] dma: make DMA_MODE_xxx reflect ISA DMA settings
[linux-2.6/kvm.git] / arch / arm / include / asm / dma.h
blob59f59c6c79f7b7a0e4485856f896ce2828e3424b
1 #ifndef __ASM_ARM_DMA_H
2 #define __ASM_ARM_DMA_H
4 #include <asm/memory.h>
6 /*
7 * This is the maximum virtual address which can be DMA'd from.
8 */
9 #ifndef MAX_DMA_ADDRESS
10 #define MAX_DMA_ADDRESS 0xffffffff
11 #endif
13 #ifdef CONFIG_ISA_DMA_API
15 * This is used to support drivers written for the x86 ISA DMA API.
16 * It should not be re-used except for that purpose.
18 #include <linux/spinlock.h>
19 #include <asm/system.h>
20 #include <asm/scatterlist.h>
22 #include <mach/isa-dma.h>
25 * DMA modes
27 typedef unsigned int dmamode_t;
30 * The DMA modes reflect the settings for the ISA DMA controller
32 #define DMA_MODE_MASK 0xcc
34 #define DMA_MODE_READ 0x44
35 #define DMA_MODE_WRITE 0x48
36 #define DMA_MODE_CASCADE 0xc0
37 #define DMA_AUTOINIT 0x10
39 extern spinlock_t dma_spin_lock;
41 static inline unsigned long claim_dma_lock(void)
43 unsigned long flags;
44 spin_lock_irqsave(&dma_spin_lock, flags);
45 return flags;
48 static inline void release_dma_lock(unsigned long flags)
50 spin_unlock_irqrestore(&dma_spin_lock, flags);
53 /* Clear the 'DMA Pointer Flip Flop'.
54 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
56 #define clear_dma_ff(chan)
58 /* Set only the page register bits of the transfer address.
60 * NOTE: This is an architecture specific function, and should
61 * be hidden from the drivers
63 extern void set_dma_page(unsigned int chan, char pagenr);
65 /* Request a DMA channel
67 * Some architectures may need to do allocate an interrupt
69 extern int request_dma(unsigned int chan, const char * device_id);
71 /* Free a DMA channel
73 * Some architectures may need to do free an interrupt
75 extern void free_dma(unsigned int chan);
77 /* Enable DMA for this channel
79 * On some architectures, this may have other side effects like
80 * enabling an interrupt and setting the DMA registers.
82 extern void enable_dma(unsigned int chan);
84 /* Disable DMA for this channel
86 * On some architectures, this may have other side effects like
87 * disabling an interrupt or whatever.
89 extern void disable_dma(unsigned int chan);
91 /* Test whether the specified channel has an active DMA transfer
93 extern int dma_channel_active(unsigned int chan);
95 /* Set the DMA scatter gather list for this channel
97 * This should not be called if a DMA channel is enabled,
98 * especially since some DMA architectures don't update the
99 * DMA address immediately, but defer it to the enable_dma().
101 extern void set_dma_sg(unsigned int chan, struct scatterlist *sg, int nr_sg);
103 /* Set the DMA address for this channel
105 * This should not be called if a DMA channel is enabled,
106 * especially since some DMA architectures don't update the
107 * DMA address immediately, but defer it to the enable_dma().
109 extern void __set_dma_addr(unsigned int chan, void *addr);
110 #define set_dma_addr(chan, addr) \
111 __set_dma_addr(chan, bus_to_virt(addr))
113 /* Set the DMA byte count for this channel
115 * This should not be called if a DMA channel is enabled,
116 * especially since some DMA architectures don't update the
117 * DMA count immediately, but defer it to the enable_dma().
119 extern void set_dma_count(unsigned int chan, unsigned long count);
121 /* Set the transfer direction for this channel
123 * This should not be called if a DMA channel is enabled,
124 * especially since some DMA architectures don't update the
125 * DMA transfer direction immediately, but defer it to the
126 * enable_dma().
128 extern void set_dma_mode(unsigned int chan, dmamode_t mode);
130 /* Set the transfer speed for this channel
132 extern void set_dma_speed(unsigned int chan, int cycle_ns);
134 /* Get DMA residue count. After a DMA transfer, this
135 * should return zero. Reading this while a DMA transfer is
136 * still in progress will return unpredictable results.
137 * If called before the channel has been used, it may return 1.
138 * Otherwise, it returns the number of _bytes_ left to transfer.
140 extern int get_dma_residue(unsigned int chan);
142 #ifndef NO_DMA
143 #define NO_DMA 255
144 #endif
146 #ifdef CONFIG_PCI
147 extern int isa_dma_bridge_buggy;
148 #else
149 #define isa_dma_bridge_buggy (0)
150 #endif
152 #endif /* CONFIG_ISA_DMA_API */
154 #endif /* __ASM_ARM_DMA_H */