xref: /openbmc/linux/arch/arm/include/asm/dma.h (revision b627b4ed)
1 #ifndef __ASM_ARM_DMA_H
2 #define __ASM_ARM_DMA_H
3 
4 #include <asm/memory.h>
5 
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
12 
13 #ifdef CONFIG_ISA_DMA_API
14 /*
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.
17  */
18 #include <linux/spinlock.h>
19 #include <asm/system.h>
20 #include <asm/scatterlist.h>
21 
22 #include <mach/isa-dma.h>
23 
24 /*
25  * The DMA modes reflect the settings for the ISA DMA controller
26  */
27 #define DMA_MODE_MASK	 0xcc
28 
29 #define DMA_MODE_READ	 0x44
30 #define DMA_MODE_WRITE	 0x48
31 #define DMA_MODE_CASCADE 0xc0
32 #define DMA_AUTOINIT	 0x10
33 
34 extern spinlock_t  dma_spin_lock;
35 
36 static inline unsigned long claim_dma_lock(void)
37 {
38 	unsigned long flags;
39 	spin_lock_irqsave(&dma_spin_lock, flags);
40 	return flags;
41 }
42 
43 static inline void release_dma_lock(unsigned long flags)
44 {
45 	spin_unlock_irqrestore(&dma_spin_lock, flags);
46 }
47 
48 /* Clear the 'DMA Pointer Flip Flop'.
49  * Write 0 for LSB/MSB, 1 for MSB/LSB access.
50  */
51 #define clear_dma_ff(chan)
52 
53 /* Set only the page register bits of the transfer address.
54  *
55  * NOTE: This is an architecture specific function, and should
56  *       be hidden from the drivers
57  */
58 extern void set_dma_page(unsigned int chan, char pagenr);
59 
60 /* Request a DMA channel
61  *
62  * Some architectures may need to do allocate an interrupt
63  */
64 extern int  request_dma(unsigned int chan, const char * device_id);
65 
66 /* Free a DMA channel
67  *
68  * Some architectures may need to do free an interrupt
69  */
70 extern void free_dma(unsigned int chan);
71 
72 /* Enable DMA for this channel
73  *
74  * On some architectures, this may have other side effects like
75  * enabling an interrupt and setting the DMA registers.
76  */
77 extern void enable_dma(unsigned int chan);
78 
79 /* Disable DMA for this channel
80  *
81  * On some architectures, this may have other side effects like
82  * disabling an interrupt or whatever.
83  */
84 extern void disable_dma(unsigned int chan);
85 
86 /* Test whether the specified channel has an active DMA transfer
87  */
88 extern int dma_channel_active(unsigned int chan);
89 
90 /* Set the DMA scatter gather list for this channel
91  *
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().
95  */
96 extern void set_dma_sg(unsigned int chan, struct scatterlist *sg, int nr_sg);
97 
98 /* Set the DMA address for this channel
99  *
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().
103  */
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))
107 
108 /* Set the DMA byte count for this channel
109  *
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().
113  */
114 extern void set_dma_count(unsigned int chan, unsigned long count);
115 
116 /* Set the transfer direction for this channel
117  *
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
121  * enable_dma().
122  */
123 extern void set_dma_mode(unsigned int chan, unsigned int mode);
124 
125 /* Set the transfer speed for this channel
126  */
127 extern void set_dma_speed(unsigned int chan, int cycle_ns);
128 
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.
134  */
135 extern int  get_dma_residue(unsigned int chan);
136 
137 #ifndef NO_DMA
138 #define NO_DMA	255
139 #endif
140 
141 #ifdef CONFIG_PCI
142 extern int isa_dma_bridge_buggy;
143 #else
144 #define isa_dma_bridge_buggy    (0)
145 #endif
146 
147 #endif /* CONFIG_ISA_DMA_API */
148 
149 #endif /* __ASM_ARM_DMA_H */
150