This source file includes following definitions.
- sun_82072_fd_inb
- sun_82072_fd_outb
- sun_82077_fd_inb
- sun_82077_fd_outb
- virtual_dma_init
- sun_fd_disable_dma
- sun_fd_set_dma_mode
- sun_fd_set_dma_addr
- sun_fd_set_dma_count
- sun_fd_enable_dma
- sun_fd_eject
- sun_fd_request_irq
- sun_floppy_init
1
2
3
4
5
6 #ifndef __ASM_SPARC_FLOPPY_H
7 #define __ASM_SPARC_FLOPPY_H
8
9 #include <asm/page.h>
10 #include <asm/pgtable.h>
11 #include <asm/system.h>
12 #include <asm/idprom.h>
13 #include <asm/machines.h>
14 #include <asm/oplib.h>
15 #include <asm/auxio.h>
16 #include <asm/irq.h>
17
18
19
20
21
22
23 struct sun_flpy_controller {
24 volatile unsigned char status_82072;
25 #define dcr_82072 status_82072
26 #define status1_82077 status_82072
27
28 volatile unsigned char data_82072;
29 #define status2_82077 data_82072
30
31 volatile unsigned char dor_82077;
32 volatile unsigned char tapectl_82077;
33
34 volatile unsigned char status_82077;
35 #define drs_82077 status_82077
36
37 volatile unsigned char data_82077;
38 volatile unsigned char ___unused;
39 volatile unsigned char dir_82077;
40 #define dcr_82077 dir_82077
41 };
42
43
44 static struct sun_flpy_controller *sun_fdc = NULL;
45 volatile unsigned char *fdc_status;
46
47 struct sun_floppy_ops {
48 unsigned char (*fd_inb)(int port);
49 void (*fd_outb)(unsigned char value, int port);
50 };
51
52 static struct sun_floppy_ops sun_fdops;
53
54 #define fd_inb(port) sun_fdops.fd_inb(port)
55 #define fd_outb(value,port) sun_fdops.fd_outb(value,port)
56 #define fd_enable_dma() sun_fd_enable_dma()
57 #define fd_disable_dma() sun_fd_disable_dma()
58 #define fd_request_dma() (0)
59 #define fd_free_dma()
60 #define fd_clear_dma_ff()
61 #define fd_set_dma_mode(mode) sun_fd_set_dma_mode(mode)
62 #define fd_set_dma_addr(addr) sun_fd_set_dma_addr(addr)
63 #define fd_set_dma_count(count) sun_fd_set_dma_count(count)
64 #define fd_enable_irq()
65 #define fd_disable_irq()
66 #define fd_cacheflush(addr, size)
67 #define fd_request_irq() sun_fd_request_irq()
68 #define fd_free_irq()
69 #define fd_eject(x) sun_fd_eject()
70
71 #define FLOPPY_MOTOR_MASK 0x10
72
73
74 #define virt_to_bus(x) (x)
75 #define bus_to_virt(x) (x)
76
77
78 #define get_dma_residue(x) (0)
79
80 #define FLOPPY0_TYPE 4
81 #define FLOPPY1_TYPE 0
82
83
84 #undef HAVE_DISABLE_HLT
85
86
87
88
89
90 #define FDC1 sun_floppy_init()
91
92 static int FDC2=-1;
93
94 #define N_FDC 1
95 #define N_DRIVE 8
96
97
98 #define CROSS_64KB(a,s) (0)
99
100
101 static unsigned char sun_82072_fd_inb(int port)
102 {
103 switch(port & 7) {
104 default:
105 printk("floppy: Asked to read unknown port %d\n", port);
106 panic("floppy: Port bolixed.");
107 case 4:
108 return sun_fdc->status_82072 & ~STATUS_DMA;
109 case 5:
110 return sun_fdc->data_82072;
111 case 7:
112
113
114
115 return 0;
116 };
117 panic("sun_82072_fd_inb: How did I get here?");
118 }
119
120 static void sun_82072_fd_outb(unsigned char value, int port)
121 {
122 switch(port & 7) {
123 default:
124 printk("floppy: Asked to write to unknown port %d\n", port);
125 panic("floppy: Port bolixed.");
126 case 2:
127
128
129
130
131
132
133
134
135 #if 0
136 if(value & 0xf0)
137 #else
138 if(value & 0x10)
139 #endif
140 set_auxio(AUXIO_FLPY_DSEL, 0);
141 else
142 set_auxio(0, AUXIO_FLPY_DSEL);
143 break;
144 case 5:
145 sun_fdc->data_82072 = value;
146 break;
147 case 7:
148 sun_fdc->dcr_82072 = value;
149 break;
150 case 4:
151 sun_fdc->status_82072 = value;
152 break;
153 };
154 return;
155 }
156
157 static unsigned char sun_82077_fd_inb(int port)
158 {
159 switch(port & 7) {
160 default:
161 printk("floppy: Asked to read unknown port %d\n", port);
162 panic("floppy: Port bolixed.");
163 case 4:
164 return sun_fdc->status_82077 & ~STATUS_DMA;
165 case 5:
166 return sun_fdc->data_82077;
167 case 7:
168
169
170
171 return 0;
172 };
173 panic("sun_82072_fd_inb: How did I get here?");
174 }
175
176 static void sun_82077_fd_outb(unsigned char value, int port)
177 {
178 switch(port & 7) {
179 default:
180 printk("floppy: Asked to write to unknown port %d\n", port);
181 panic("floppy: Port bolixed.");
182 case 2:
183
184 sun_fdc->dor_82077 = value;
185 break;
186 case 5:
187 sun_fdc->data_82077 = value;
188 break;
189 case 7:
190 sun_fdc->dcr_82077 = value;
191 break;
192 case 4:
193 sun_fdc->status_82077 = value;
194 break;
195 };
196 return;
197 }
198
199
200
201
202
203
204
205
206
207
208
209 char *pdma_vaddr;
210 unsigned long pdma_size;
211 volatile int doing_pdma = 0;
212
213
214 char *pdma_base = 0;
215 unsigned long pdma_areasize;
216
217
218 static inline void virtual_dma_init(void)
219 {
220
221 }
222
223 static inline void sun_fd_disable_dma(void)
224 {
225 doing_pdma = 0;
226 if (pdma_base) {
227 mmu_unlockarea(pdma_base, pdma_areasize);
228 pdma_base = 0;
229 }
230 }
231
232 static inline void sun_fd_set_dma_mode(int mode)
233 {
234 switch(mode) {
235 case DMA_MODE_READ:
236 doing_pdma = 1;
237 break;
238 case DMA_MODE_WRITE:
239 doing_pdma = 2;
240 break;
241 default:
242 printk("Unknown dma mode %d\n", mode);
243 panic("floppy: Giving up...");
244 }
245 }
246
247 static inline void sun_fd_set_dma_addr(char *buffer)
248 {
249 pdma_vaddr = buffer;
250 }
251
252 static inline void sun_fd_set_dma_count(int length)
253 {
254 pdma_size = length;
255 }
256
257 static inline void sun_fd_enable_dma(void)
258 {
259 pdma_vaddr = mmu_lockarea(pdma_vaddr, pdma_size);
260 pdma_base = pdma_vaddr;
261 pdma_areasize = pdma_size;
262 }
263
264 static int sun_fd_eject(void)
265 {
266 set_auxio(AUXIO_FLPY_DSEL, AUXIO_FLPY_EJCT);
267 udelay(1000);
268 set_auxio(AUXIO_FLPY_EJCT, AUXIO_FLPY_DSEL);
269 return 0;
270 }
271
272
273 extern void floppy_hardint(int irq, void *unused, struct pt_regs *regs);
274
275 static int sun_fd_request_irq(void)
276 {
277 static int once = 0;
278 int error;
279
280 if(!once) {
281 once = 1;
282 error = request_fast_irq(FLOPPY_IRQ, floppy_hardint, SA_INTERRUPT, "floppy");
283 return ((error == 0) ? 0 : -1);
284 } else return 0;
285 }
286
287 static struct linux_prom_registers fd_regs[2];
288
289 static int sun_floppy_init(void)
290 {
291 char state[128];
292 int tnode, fd_node, num_regs;
293
294 FLOPPY_IRQ = 11;
295
296
297
298 if((sparc_cpu_model != sun4c && sparc_cpu_model != sun4m) ||
299 ((idprom->id_machtype == (SM_SUN4C | SM_4C_SLC)) ||
300 (idprom->id_machtype == (SM_SUN4C | SM_4C_ELC)))) {
301
302 goto no_sun_fdc;
303 }
304
305 tnode = prom_getchild(prom_root_node);
306 fd_node = prom_searchsiblings(tnode, "obio");
307 if(fd_node != 0) {
308 tnode = prom_getchild(fd_node);
309 fd_node = prom_searchsiblings(tnode, "SUNW,fdtwo");
310 } else {
311 fd_node = prom_searchsiblings(tnode, "fd");
312 }
313 if(fd_node == 0) {
314 goto no_sun_fdc;
315 }
316
317
318 if(sparc_cpu_model == sun4m) {
319 prom_getproperty(fd_node, "status", state, sizeof(state));
320 if(!strcmp(state, "disabled")) {
321 goto no_sun_fdc;
322 }
323 }
324 num_regs = prom_getproperty(fd_node, "reg", (char *) fd_regs, sizeof(fd_regs));
325 num_regs = (num_regs / sizeof(fd_regs[0]));
326 prom_apply_obio_ranges(fd_regs, num_regs);
327 sun_fdc = (struct sun_flpy_controller *) sparc_alloc_io(fd_regs[0].phys_addr,
328 0x0,
329 fd_regs[0].reg_size,
330 "floppy",
331 fd_regs[0].which_io,
332 0x0);
333
334 if(sun_fdc->status_82072 == 0xff) {
335 sun_fdc = NULL;
336 goto no_sun_fdc;
337 }
338
339
340
341
342
343 sun_fdops.fd_inb = sun_82077_fd_inb;
344 sun_fdops.fd_outb = sun_82077_fd_outb;
345 fdc_status = &sun_fdc->status_82077;
346
347
348
349
350
351 if(sun_fdc->dor_82077 == 0x80) {
352 sun_fdc->dor_82077 = 2;
353 if(sun_fdc->dor_82077 == 0x80) {
354
355 sun_fdops.fd_inb = sun_82072_fd_inb;
356 sun_fdops.fd_outb = sun_82072_fd_outb;
357 fdc_status = &sun_fdc->status_82072;
358 }
359 }
360
361
362
363
364 set_auxio(AUXIO_FLPY_EJCT, 0);
365 udelay(1000);
366 sun_fd_eject(0);
367
368
369 return (int) sun_fdc;
370
371 no_sun_fdc:
372 return -1;
373 }
374
375 #endif