ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-sh / dma.h
1 /*
2  * include/asm-sh/dma.h
3  *
4  * Copyright (C) 2003  Paul Mundt
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License.  See the file "COPYING" in the main directory of this archive
8  * for more details.
9  */
10 #ifndef __ASM_SH_DMA_H
11 #define __ASM_SH_DMA_H
12
13 #include <linux/config.h>
14 #include <linux/spinlock.h>
15 #include <linux/wait.h>
16 #include <asm/cpu/dma.h>
17 #include <asm/semaphore.h>
18
19 /* The maximum address that we can perform a DMA transfer to on this platform */
20 /* Don't define MAX_DMA_ADDRESS; it's useless on the SuperH and any
21    occurrence should be flagged as an error.  */
22 /* But... */
23 /* XXX: This is not applicable to SuperH, just needed for alloc_bootmem */
24 #define MAX_DMA_ADDRESS         (PAGE_OFFSET+0x10000000)
25
26 #ifdef CONFIG_NR_DMA_CHANNELS
27 #  define MAX_DMA_CHANNELS      (CONFIG_NR_DMA_CHANNELS)
28 #else
29 #  define MAX_DMA_CHANNELS      (CONFIG_NR_ONCHIP_DMA_CHANNELS)
30 #endif
31
32 /* 
33  * Read and write modes can mean drastically different things depending on the
34  * channel configuration. Consult your DMAC documentation and module
35  * implementation for further clues.
36  */
37 #define DMA_MODE_READ           0x00
38 #define DMA_MODE_WRITE          0x01
39 #define DMA_MODE_MASK           0x01
40
41 extern spinlock_t dma_spin_lock;
42
43 struct dma_info;
44
45 struct dma_ops {
46         const char *name;
47
48         int (*request)(struct dma_info *info);
49         void (*free)(struct dma_info *info);
50
51         int (*get_residue)(struct dma_info *info);
52         int (*xfer)(struct dma_info *info);
53         void (*configure)(struct dma_info *info, unsigned long flags);
54 };
55
56 struct dma_info {
57         const char *dev_id;
58
59         unsigned int chan;
60         unsigned int mode;
61         unsigned int count;
62         
63         unsigned long sar;
64         unsigned long dar;
65
66         unsigned int configured:1;
67         unsigned int tei_capable:1;
68         atomic_t busy;
69
70         struct semaphore sem;
71         wait_queue_head_t wait_queue;
72         struct dma_ops *ops;
73 };
74
75 /* arch/sh/drivers/dma/dma-api.c */
76 extern int dma_xfer(unsigned int chan, unsigned long from,
77                     unsigned long to, size_t size, unsigned int mode);
78
79 #define dma_write(chan, from, to, size) \
80         dma_xfer(chan, from, to, size, DMA_MODE_WRITE)
81 #define dma_write_page(chan, from, to)  \
82         dma_write(chan, from, to, PAGE_SIZE)
83
84 #define dma_read(chan, from, to, size)  \
85         dma_xfer(chan, from, to, size, DMA_MODE_READ)
86 #define dma_read_page(chan, from, to)   \
87         dma_read(chan, from, to, PAGE_SIZE)
88
89 extern int request_dma(unsigned int chan, const char *dev_id);
90 extern void free_dma(unsigned int chan);
91 extern int get_dma_residue(unsigned int chan);
92 extern struct dma_info *get_dma_info(unsigned int chan);
93 extern void dma_wait_for_completion(unsigned int chan);
94 extern void dma_configure_channel(unsigned int chan, unsigned long flags);
95
96 extern int register_dmac(struct dma_ops *ops);
97
98 extern struct dma_info dma_info[];
99
100 #ifdef CONFIG_PCI
101 extern int isa_dma_bridge_buggy;
102 #else
103 #define isa_dma_bridge_buggy    (0)
104 #endif
105
106 #endif /* __ASM_SH_DMA_H */