This source file includes following definitions.
- enable_dma
- disable_dma
- clear_dma_ff
- set_dma_mode
- set_dma_page
- set_dma_addr
- set_dma_count
- get_dma_residue
1
2
3
4
5
6
7
8 #ifndef __ASM_MIPS_DMA_H
9 #define __ASM_MIPS_DMA_H
10
11 #include <asm/io.h>
12
13
14 #ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
15 #define dma_outb outb_p
16 #else
17 #define dma_outb outb
18 #endif
19
20 #define dma_inb inb
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 #define MAX_DMA_CHANNELS 8
71
72
73 #define MAX_DMA_ADDRESS 0x1000000
74
75
76 #define MAX_DMA_ADDRESS 0x1000000
77
78
79 #define IO_DMA1_BASE 0x00
80 #define IO_DMA2_BASE 0xC0
81
82
83 #define DMA1_CMD_REG 0x08
84 #define DMA1_STAT_REG 0x08
85 #define DMA1_REQ_REG 0x09
86 #define DMA1_MASK_REG 0x0A
87 #define DMA1_MODE_REG 0x0B
88 #define DMA1_CLEAR_FF_REG 0x0C
89 #define DMA1_TEMP_REG 0x0D
90 #define DMA1_RESET_REG 0x0D
91 #define DMA1_CLR_MASK_REG 0x0E
92 #define DMA1_MASK_ALL_REG 0x0F
93
94 #define DMA2_CMD_REG 0xD0
95 #define DMA2_STAT_REG 0xD0
96 #define DMA2_REQ_REG 0xD2
97 #define DMA2_MASK_REG 0xD4
98 #define DMA2_MODE_REG 0xD6
99 #define DMA2_CLEAR_FF_REG 0xD8
100 #define DMA2_TEMP_REG 0xDA
101 #define DMA2_RESET_REG 0xDA
102 #define DMA2_CLR_MASK_REG 0xDC
103 #define DMA2_MASK_ALL_REG 0xDE
104
105 #define DMA_ADDR_0 0x00
106 #define DMA_ADDR_1 0x02
107 #define DMA_ADDR_2 0x04
108 #define DMA_ADDR_3 0x06
109 #define DMA_ADDR_4 0xC0
110 #define DMA_ADDR_5 0xC4
111 #define DMA_ADDR_6 0xC8
112 #define DMA_ADDR_7 0xCC
113
114 #define DMA_CNT_0 0x01
115 #define DMA_CNT_1 0x03
116 #define DMA_CNT_2 0x05
117 #define DMA_CNT_3 0x07
118 #define DMA_CNT_4 0xC2
119 #define DMA_CNT_5 0xC6
120 #define DMA_CNT_6 0xCA
121 #define DMA_CNT_7 0xCE
122
123 #define DMA_PAGE_0 0x87
124 #define DMA_PAGE_1 0x83
125 #define DMA_PAGE_2 0x81
126 #define DMA_PAGE_3 0x82
127 #define DMA_PAGE_5 0x8B
128 #define DMA_PAGE_6 0x89
129 #define DMA_PAGE_7 0x8A
130
131 #define DMA_MODE_READ 0x44
132 #define DMA_MODE_WRITE 0x48
133 #define DMA_MODE_CASCADE 0xC0
134
135
136 static __inline__ void enable_dma(unsigned int dmanr)
137 {
138 if (dmanr<=3)
139 dma_outb(dmanr, DMA1_MASK_REG);
140 else
141 dma_outb(dmanr & 3, DMA2_MASK_REG);
142 }
143
144 static __inline__ void disable_dma(unsigned int dmanr)
145 {
146 if (dmanr<=3)
147 dma_outb(dmanr | 4, DMA1_MASK_REG);
148 else
149 dma_outb((dmanr & 3) | 4, DMA2_MASK_REG);
150 }
151
152
153
154
155
156
157
158
159 static __inline__ void clear_dma_ff(unsigned int dmanr)
160 {
161 if (dmanr<=3)
162 dma_outb(0, DMA1_CLEAR_FF_REG);
163 else
164 dma_outb(0, DMA2_CLEAR_FF_REG);
165 }
166
167
168 static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
169 {
170 if (dmanr<=3)
171 dma_outb(mode | dmanr, DMA1_MODE_REG);
172 else
173 dma_outb(mode | (dmanr&3), DMA2_MODE_REG);
174 }
175
176
177
178
179
180
181 static __inline__ void set_dma_page(unsigned int dmanr, char pagenr)
182 {
183 switch(dmanr) {
184 case 0:
185 dma_outb(pagenr, DMA_PAGE_0);
186 break;
187 case 1:
188 dma_outb(pagenr, DMA_PAGE_1);
189 break;
190 case 2:
191 dma_outb(pagenr, DMA_PAGE_2);
192 break;
193 case 3:
194 dma_outb(pagenr, DMA_PAGE_3);
195 break;
196 case 5:
197 dma_outb(pagenr & 0xfe, DMA_PAGE_5);
198 break;
199 case 6:
200 dma_outb(pagenr & 0xfe, DMA_PAGE_6);
201 break;
202 case 7:
203 dma_outb(pagenr & 0xfe, DMA_PAGE_7);
204 break;
205 }
206 }
207
208
209
210
211
212 static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
213 {
214 set_dma_page(dmanr, a>>16);
215 if (dmanr <= 3) {
216 dma_outb( a & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
217 dma_outb( (a>>8) & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
218 } else {
219 dma_outb( (a>>1) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
220 dma_outb( (a>>9) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
221 }
222 }
223
224
225
226
227
228
229
230
231
232
233 static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
234 {
235 count--;
236 if (dmanr <= 3) {
237 dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
238 dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
239 } else {
240 dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
241 dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
242 }
243 }
244
245
246
247
248
249
250
251
252
253
254 static __inline__ int get_dma_residue(unsigned int dmanr)
255 {
256 unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE
257 : ((dmanr&3)<<2) + 2 + IO_DMA2_BASE;
258
259
260 unsigned short count;
261
262 count = 1 + dma_inb(io_port);
263 count += dma_inb(io_port) << 8;
264
265 return (dmanr<=3)? count : (count<<1);
266 }
267
268
269
270 extern int request_dma(unsigned int dmanr, char * device_id);
271 extern void free_dma(unsigned int dmanr);
272
273
274 #endif