ARM: change ARM_DMA_ZONE_SIZE into a variable
[pandora-kernel.git] / arch / arm / include / asm / dma.h
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 CONFIG_ZONE_DMA
10 #define MAX_DMA_ADDRESS 0xffffffffUL
11 #else
12 #define MAX_DMA_ADDRESS ({ \
13         extern unsigned long arm_dma_zone_size; \
14         arm_dma_zone_size ? \
15                 (PAGE_OFFSET + arm_dma_zone_size) : 0xffffffffUL; })
16 #endif
17
18 #ifdef CONFIG_ISA_DMA_API
19 /*
20  * This is used to support drivers written for the x86 ISA DMA API.
21  * It should not be re-used except for that purpose.
22  */
23 #include <linux/spinlock.h>
24 #include <asm/system.h>
25 #include <asm/scatterlist.h>
26
27 #include <mach/isa-dma.h>
28
29 /*
30  * The DMA modes reflect the settings for the ISA DMA controller
31  */
32 #define DMA_MODE_MASK    0xcc
33
34 #define DMA_MODE_READ    0x44
35 #define DMA_MODE_WRITE   0x48
36 #define DMA_MODE_CASCADE 0xc0
37 #define DMA_AUTOINIT     0x10
38
39 extern spinlock_t  dma_spin_lock;
40
41 static inline unsigned long claim_dma_lock(void)
42 {
43         unsigned long flags;
44         spin_lock_irqsave(&dma_spin_lock, flags);
45         return flags;
46 }
47
48 static inline void release_dma_lock(unsigned long flags)
49 {
50         spin_unlock_irqrestore(&dma_spin_lock, flags);
51 }
52
53 /* Clear the 'DMA Pointer Flip Flop'.
54  * Write 0 for LSB/MSB, 1 for MSB/LSB access.
55  */
56 #define clear_dma_ff(chan)
57
58 /* Set only the page register bits of the transfer address.
59  *
60  * NOTE: This is an architecture specific function, and should
61  *       be hidden from the drivers
62  */
63 extern void set_dma_page(unsigned int chan, char pagenr);
64
65 /* Request a DMA channel
66  *
67  * Some architectures may need to do allocate an interrupt
68  */
69 extern int  request_dma(unsigned int chan, const char * device_id);
70
71 /* Free a DMA channel
72  *
73  * Some architectures may need to do free an interrupt
74  */
75 extern void free_dma(unsigned int chan);
76
77 /* Enable DMA for this channel
78  *
79  * On some architectures, this may have other side effects like
80  * enabling an interrupt and setting the DMA registers.
81  */
82 extern void enable_dma(unsigned int chan);
83
84 /* Disable DMA for this channel
85  *
86  * On some architectures, this may have other side effects like
87  * disabling an interrupt or whatever.
88  */
89 extern void disable_dma(unsigned int chan);
90
91 /* Test whether the specified channel has an active DMA transfer
92  */
93 extern int dma_channel_active(unsigned int chan);
94
95 /* Set the DMA scatter gather list for this channel
96  *
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().
100  */
101 extern void set_dma_sg(unsigned int chan, struct scatterlist *sg, int nr_sg);
102
103 /* Set the DMA address for this channel
104  *
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().
108  */
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))
112
113 /* Set the DMA byte count for this channel
114  *
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().
118  */
119 extern void set_dma_count(unsigned int chan, unsigned long count);
120
121 /* Set the transfer direction for this channel
122  *
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().
127  */
128 extern void set_dma_mode(unsigned int chan, unsigned int mode);
129
130 /* Set the transfer speed for this channel
131  */
132 extern void set_dma_speed(unsigned int chan, int cycle_ns);
133
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.
139  */
140 extern int  get_dma_residue(unsigned int chan);
141
142 #ifndef NO_DMA
143 #define NO_DMA  255
144 #endif
145
146 #endif /* CONFIG_ISA_DMA_API */
147
148 #ifdef CONFIG_PCI
149 extern int isa_dma_bridge_buggy;
150 #else
151 #define isa_dma_bridge_buggy    (0)
152 #endif
153
154 #endif /* __ASM_ARM_DMA_H */