1 #ifndef __ASM_ARM_DMA_H
2 #define __ASM_ARM_DMA_H
4 #include <asm/memory.h>
7 * This is the maximum virtual address which can be DMA'd from.
9 #ifndef MAX_DMA_ADDRESS
10 #define MAX_DMA_ADDRESS 0xffffffff
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 typedef unsigned int dmach_t;
24 #include <mach/isa-dma.h>
29 typedef unsigned int dmamode_t;
31 #define DMA_MODE_MASK 3
33 #define DMA_MODE_READ 0
34 #define DMA_MODE_WRITE 1
35 #define DMA_MODE_CASCADE 2
36 #define DMA_AUTOINIT 4
38 extern spinlock_t dma_spin_lock;
40 static inline unsigned long claim_dma_lock(void)
43 spin_lock_irqsave(&dma_spin_lock, flags);
47 static inline void release_dma_lock(unsigned long flags)
49 spin_unlock_irqrestore(&dma_spin_lock, flags);
52 /* Clear the 'DMA Pointer Flip Flop'.
53 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
55 #define clear_dma_ff(channel)
57 /* Set only the page register bits of the transfer address.
59 * NOTE: This is an architecture specific function, and should
60 * be hidden from the drivers
62 extern void set_dma_page(dmach_t channel, char pagenr);
64 /* Request a DMA channel
66 * Some architectures may need to do allocate an interrupt
68 extern int request_dma(dmach_t channel, const char * device_id);
72 * Some architectures may need to do free an interrupt
74 extern void free_dma(dmach_t channel);
76 /* Enable DMA for this channel
78 * On some architectures, this may have other side effects like
79 * enabling an interrupt and setting the DMA registers.
81 extern void enable_dma(dmach_t channel);
83 /* Disable DMA for this channel
85 * On some architectures, this may have other side effects like
86 * disabling an interrupt or whatever.
88 extern void disable_dma(dmach_t channel);
90 /* Test whether the specified channel has an active DMA transfer
92 extern int dma_channel_active(dmach_t channel);
94 /* Set the DMA scatter gather list for this channel
96 * This should not be called if a DMA channel is enabled,
97 * especially since some DMA architectures don't update the
98 * DMA address immediately, but defer it to the enable_dma().
100 extern void set_dma_sg(dmach_t channel, struct scatterlist *sg, int nr_sg);
102 /* Set the DMA address for this channel
104 * This should not be called if a DMA channel is enabled,
105 * especially since some DMA architectures don't update the
106 * DMA address immediately, but defer it to the enable_dma().
108 extern void __set_dma_addr(dmach_t channel, void *addr);
109 #define set_dma_addr(channel, addr) \
110 __set_dma_addr(channel, bus_to_virt(addr))
112 /* Set the DMA byte count for this channel
114 * This should not be called if a DMA channel is enabled,
115 * especially since some DMA architectures don't update the
116 * DMA count immediately, but defer it to the enable_dma().
118 extern void set_dma_count(dmach_t channel, unsigned long count);
120 /* Set the transfer direction for this channel
122 * This should not be called if a DMA channel is enabled,
123 * especially since some DMA architectures don't update the
124 * DMA transfer direction immediately, but defer it to the
127 extern void set_dma_mode(dmach_t channel, dmamode_t mode);
129 /* Set the transfer speed for this channel
131 extern void set_dma_speed(dmach_t channel, int cycle_ns);
133 /* Get DMA residue count. After a DMA transfer, this
134 * should return zero. Reading this while a DMA transfer is
135 * still in progress will return unpredictable results.
136 * If called before the channel has been used, it may return 1.
137 * Otherwise, it returns the number of _bytes_ left to transfer.
139 extern int get_dma_residue(dmach_t channel);
146 extern int isa_dma_bridge_buggy;
148 #define isa_dma_bridge_buggy (0)
151 #endif /* CONFIG_ISA_DMA_API */
153 #endif /* __ASM_ARM_DMA_H */