1 #ifndef __ASM_ARM_DMA_H
2 #define __ASM_ARM_DMA_H
3 
4 typedef unsigned int dmach_t;
5 
6 #include <linux/config.h>
7 #include <linux/spinlock.h>
8 #include <asm/system.h>
9 #include <asm/memory.h>
10 #include <asm/scatterlist.h>
11 #include <asm/arch/dma.h>
12 
13 /*
14  * DMA modes
15  */
16 typedef unsigned int dmamode_t;
17 
18 #define DMA_MODE_MASK	3
19 
20 #define DMA_MODE_READ	 0
21 #define DMA_MODE_WRITE	 1
22 #define DMA_MODE_CASCADE 2
23 #define DMA_AUTOINIT	 4
24 
25 extern spinlock_t  dma_spin_lock;
26 
claim_dma_lock(void)27 static inline unsigned long claim_dma_lock(void)
28 {
29 	unsigned long flags;
30 	spin_lock_irqsave(&dma_spin_lock, flags);
31 	return flags;
32 }
33 
release_dma_lock(unsigned long flags)34 static inline void release_dma_lock(unsigned long flags)
35 {
36 	spin_unlock_irqrestore(&dma_spin_lock, flags);
37 }
38 
39 /* Clear the 'DMA Pointer Flip Flop'.
40  * Write 0 for LSB/MSB, 1 for MSB/LSB access.
41  */
42 #define clear_dma_ff(channel)
43 
44 /* Set only the page register bits of the transfer address.
45  *
46  * NOTE: This is an architecture specific function, and should
47  *       be hidden from the drivers
48  */
49 extern void set_dma_page(dmach_t channel, char pagenr);
50 
51 /* Request a DMA channel
52  *
53  * Some architectures may need to do allocate an interrupt
54  */
55 extern int  request_dma(dmach_t channel, const char * device_id);
56 
57 /* Free a DMA channel
58  *
59  * Some architectures may need to do free an interrupt
60  */
61 extern void free_dma(dmach_t channel);
62 
63 /* Enable DMA for this channel
64  *
65  * On some architectures, this may have other side effects like
66  * enabling an interrupt and setting the DMA registers.
67  */
68 extern void enable_dma(dmach_t channel);
69 
70 /* Disable DMA for this channel
71  *
72  * On some architectures, this may have other side effects like
73  * disabling an interrupt or whatever.
74  */
75 extern void disable_dma(dmach_t channel);
76 
77 /* Test whether the specified channel has an active DMA transfer
78  */
79 extern int dma_channel_active(dmach_t channel);
80 
81 /* Set the DMA scatter gather list for this channel
82  *
83  * This should not be called if a DMA channel is enabled,
84  * especially since some DMA architectures don't update the
85  * DMA address immediately, but defer it to the enable_dma().
86  */
87 extern void set_dma_sg(dmach_t channel, struct scatterlist *sg, int nr_sg);
88 
89 /* Set the DMA address for this channel
90  *
91  * This should not be called if a DMA channel is enabled,
92  * especially since some DMA architectures don't update the
93  * DMA address immediately, but defer it to the enable_dma().
94  */
95 extern void set_dma_addr(dmach_t channel, unsigned long physaddr);
96 
97 /* Set the DMA byte count for this channel
98  *
99  * This should not be called if a DMA channel is enabled,
100  * especially since some DMA architectures don't update the
101  * DMA count immediately, but defer it to the enable_dma().
102  */
103 extern void set_dma_count(dmach_t channel, unsigned long count);
104 
105 /* Set the transfer direction for this channel
106  *
107  * This should not be called if a DMA channel is enabled,
108  * especially since some DMA architectures don't update the
109  * DMA transfer direction immediately, but defer it to the
110  * enable_dma().
111  */
112 extern void set_dma_mode(dmach_t channel, dmamode_t mode);
113 
114 /* Set the transfer speed for this channel
115  */
116 extern void set_dma_speed(dmach_t channel, int cycle_ns);
117 
118 /* Get DMA residue count. After a DMA transfer, this
119  * should return zero. Reading this while a DMA transfer is
120  * still in progress will return unpredictable results.
121  * If called before the channel has been used, it may return 1.
122  * Otherwise, it returns the number of _bytes_ left to transfer.
123  */
124 extern int  get_dma_residue(dmach_t channel);
125 
126 #ifndef NO_DMA
127 #define NO_DMA	255
128 #endif
129 
130 #ifdef CONFIG_PCI
131 extern int isa_dma_bridge_buggy;
132 #else
133 #define isa_dma_bridge_buggy    (0)
134 #endif
135 
136 #ifndef arch_adjust_zones
137 #define arch_adjust_zones(node,size,holes)
138 #endif
139 
140 #endif /* _ARM_DMA_H */
141