blob: ca51143f97f179132ffa2117443172f4da612c57 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_ARM_DMA_H
2#define __ASM_ARM_DMA_H
3
Russell Kingb9c78022008-11-29 10:50:22 +00004#include <asm/memory.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6/*
Russell Kingd4c6fc92006-01-04 15:30:48 +00007 * 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
Russell Kingdcea83a2008-11-29 11:40:28 +000013#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
Russell Kingf40b1212008-11-29 18:48:07 +000022#include <mach/isa-dma.h>
Russell Kingdcea83a2008-11-29 11:40:28 +000023
Russell Kingd4c6fc92006-01-04 15:30:48 +000024/*
Russell Kingbc6447b2009-01-02 12:18:53 +000025 * The DMA modes reflect the settings for the ISA DMA controller
26 */
27#define DMA_MODE_MASK 0xcc
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Russell Kingbc6447b2009-01-02 12:18:53 +000029#define DMA_MODE_READ 0x44
30#define DMA_MODE_WRITE 0x48
31#define DMA_MODE_CASCADE 0xc0
32#define DMA_AUTOINIT 0x10
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34extern spinlock_t dma_spin_lock;
35
36static 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
43static 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 */
Russell King1df81302008-12-08 15:58:50 +000051#define clear_dma_ff(chan)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
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 */
Russell King1df81302008-12-08 15:58:50 +000058extern void set_dma_page(unsigned int chan, char pagenr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60/* Request a DMA channel
61 *
62 * Some architectures may need to do allocate an interrupt
63 */
Russell King1df81302008-12-08 15:58:50 +000064extern int request_dma(unsigned int chan, const char * device_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66/* Free a DMA channel
67 *
68 * Some architectures may need to do free an interrupt
69 */
Russell King1df81302008-12-08 15:58:50 +000070extern void free_dma(unsigned int chan);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
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 */
Russell King1df81302008-12-08 15:58:50 +000077extern void enable_dma(unsigned int chan);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
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 */
Russell King1df81302008-12-08 15:58:50 +000084extern void disable_dma(unsigned int chan);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
86/* Test whether the specified channel has an active DMA transfer
87 */
Russell King1df81302008-12-08 15:58:50 +000088extern int dma_channel_active(unsigned int chan);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
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 */
Russell King1df81302008-12-08 15:58:50 +000096extern void set_dma_sg(unsigned int chan, struct scatterlist *sg, int nr_sg);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
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 */
Russell King1df81302008-12-08 15:58:50 +0000104extern 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))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
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 */
Russell King1df81302008-12-08 15:58:50 +0000114extern void set_dma_count(unsigned int chan, unsigned long count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
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 */
Russell Kingf0ffc812009-01-02 12:34:55 +0000123extern void set_dma_mode(unsigned int chan, unsigned int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
125/* Set the transfer speed for this channel
126 */
Russell King1df81302008-12-08 15:58:50 +0000127extern void set_dma_speed(unsigned int chan, int cycle_ns);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
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 */
Russell King1df81302008-12-08 15:58:50 +0000135extern int get_dma_residue(unsigned int chan);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137#ifndef NO_DMA
138#define NO_DMA 255
139#endif
140
Peter Hüwef8920272010-01-09 13:46:08 +0100141#endif /* CONFIG_ISA_DMA_API */
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143#ifdef CONFIG_PCI
144extern int isa_dma_bridge_buggy;
145#else
146#define isa_dma_bridge_buggy (0)
147#endif
148
Russell Kingdcea83a2008-11-29 11:40:28 +0000149#endif /* __ASM_ARM_DMA_H */