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 #include <mach/isa-dma.h>
25 * The DMA modes reflect the settings for the ISA DMA controller
27 #define DMA_MODE_MASK 0xcc
29 #define DMA_MODE_READ 0x44
30 #define DMA_MODE_WRITE 0x48
31 #define DMA_MODE_CASCADE 0xc0
32 #define DMA_AUTOINIT 0x10
34 extern spinlock_t dma_spin_lock
;
36 static inline unsigned long claim_dma_lock(void)
39 spin_lock_irqsave(&dma_spin_lock
, flags
);
43 static inline void release_dma_lock(unsigned long flags
)
45 spin_unlock_irqrestore(&dma_spin_lock
, flags
);
48 /* Clear the 'DMA Pointer Flip Flop'.
49 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
51 #define clear_dma_ff(chan)
53 /* Set only the page register bits of the transfer address.
55 * NOTE: This is an architecture specific function, and should
56 * be hidden from the drivers
58 extern void set_dma_page(unsigned int chan
, char pagenr
);
60 /* Request a DMA channel
62 * Some architectures may need to do allocate an interrupt
64 extern int request_dma(unsigned int chan
, const char * device_id
);
68 * Some architectures may need to do free an interrupt
70 extern void free_dma(unsigned int chan
);
72 /* Enable DMA for this channel
74 * On some architectures, this may have other side effects like
75 * enabling an interrupt and setting the DMA registers.
77 extern void enable_dma(unsigned int chan
);
79 /* Disable DMA for this channel
81 * On some architectures, this may have other side effects like
82 * disabling an interrupt or whatever.
84 extern void disable_dma(unsigned int chan
);
86 /* Test whether the specified channel has an active DMA transfer
88 extern int dma_channel_active(unsigned int chan
);
90 /* Set the DMA scatter gather list for this channel
92 * This should not be called if a DMA channel is enabled,
93 * especially since some DMA architectures don't update the
94 * DMA address immediately, but defer it to the enable_dma().
96 extern void set_dma_sg(unsigned int chan
, struct scatterlist
*sg
, int nr_sg
);
98 /* Set the DMA address for this channel
100 * This should not be called if a DMA channel is enabled,
101 * especially since some DMA architectures don't update the
102 * DMA address immediately, but defer it to the enable_dma().
104 extern void __set_dma_addr(unsigned int chan
, void *addr
);
105 #define set_dma_addr(chan, addr) \
106 __set_dma_addr(chan, bus_to_virt(addr))
108 /* Set the DMA byte count for this channel
110 * This should not be called if a DMA channel is enabled,
111 * especially since some DMA architectures don't update the
112 * DMA count immediately, but defer it to the enable_dma().
114 extern void set_dma_count(unsigned int chan
, unsigned long count
);
116 /* Set the transfer direction for this channel
118 * This should not be called if a DMA channel is enabled,
119 * especially since some DMA architectures don't update the
120 * DMA transfer direction immediately, but defer it to the
123 extern void set_dma_mode(unsigned int chan
, unsigned int mode
);
125 /* Set the transfer speed for this channel
127 extern void set_dma_speed(unsigned int chan
, int cycle_ns
);
129 /* Get DMA residue count. After a DMA transfer, this
130 * should return zero. Reading this while a DMA transfer is
131 * still in progress will return unpredictable results.
132 * If called before the channel has been used, it may return 1.
133 * Otherwise, it returns the number of _bytes_ left to transfer.
135 extern int get_dma_residue(unsigned int chan
);
141 #endif /* CONFIG_ISA_DMA_API */
144 extern int isa_dma_bridge_buggy
;
146 #define isa_dma_bridge_buggy (0)
149 #endif /* __ASM_ARM_DMA_H */