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