1 /* sun3xflop.h: Sun3/80 specific parts of the floppy driver.
3 * Derived partially from asm-sparc/floppy.h, which is:
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 * Sun3x version 2/4/2000 Sam Creasey (sammy@sammy.net)
9 #ifndef __ASM_SUN3X_FLOPPY_H
10 #define __ASM_SUN3X_FLOPPY_H
13 #include <asm/pgtable.h>
14 #include <asm/system.h>
16 #include <asm/sun3x.h>
18 /* default interrupt vector */
19 #define SUN3X_FDC_IRQ 0x40
26 #define FCR_DSEL0 0x10
28 /* We don't need no stinkin' I/O port allocation crap. */
31 #define release_region(X, Y) do { } while(0)
32 #define request_region(X, Y, Z) (1)
34 struct sun3xflop_private
{
35 volatile unsigned char *status_r
;
36 volatile unsigned char *data_r
;
37 volatile unsigned char *fcr_r
;
38 volatile unsigned char *fvr_r
;
42 /* Super paranoid... */
43 #undef HAVE_DISABLE_HLT
45 /* Routines unique to each controller type on a Sun. */
46 static unsigned char sun3x_82072_fd_inb(int port
)
52 printk("floppy: Asked to read unknown port %d\n", port
);
53 panic("floppy: Port bolixed.");
54 case 4: /* FD_STATUS */
55 return (*sun3x_fdc
.status_r
) & ~STATUS_DMA
;
57 return (*sun3x_fdc
.data_r
);
59 /* ugly hack, I can't find a way to actually detect the disk */
66 panic("sun_82072_fd_inb: How did I get here?");
69 static void sun3x_82072_fd_outb(unsigned char value
, int port
)
74 printk("floppy: Asked to write to unknown port %d\n", port
);
75 panic("floppy: Port bolixed.");
77 /* Oh geese, 82072 on the Sun has no DOR register,
78 * so we make do with taunting the FCR.
80 * ASSUMPTIONS: There will only ever be one floppy
81 * drive attached to a Sun controller
82 * and it will be at drive zero.
86 unsigned char fcr
= sun3x_fdc
.fcr
;
89 fcr
|= (FCR_DSEL0
| FCR_MTRON
);
91 fcr
&= ~(FCR_DSEL0
| FCR_MTRON
);
94 if(fcr
!= sun3x_fdc
.fcr
) {
95 *(sun3x_fdc
.fcr_r
) = fcr
;
100 case 5: /* FD_DATA */
101 *(sun3x_fdc
.data_r
) = value
;
104 *(sun3x_fdc
.status_r
) = value
;
106 case 4: /* FD_STATUS */
107 *(sun3x_fdc
.status_r
) = value
;
114 asmlinkage irqreturn_t
sun3xflop_hardint(int irq
, void *dev_id
)
116 register unsigned char st
;
118 #undef TRACE_FLPY_INT
119 #define NO_FLOPPY_ASSEMBLER
121 #ifdef TRACE_FLPY_INT
124 static int dma_wait
=0;
127 floppy_interrupt(irq
, dev_id
);
131 // printk("doing pdma\n");// st %x\n", sun_fdc->status_82072);
133 #ifdef TRACE_FLPY_INT
135 bytes
= virtual_dma_count
;
142 for(lcount
=virtual_dma_count
, lptr
=virtual_dma_addr
;
143 lcount
; lcount
--, lptr
++) {
144 /* st=fd_inb(virtual_dma_port+4) & 0x80 ; */
145 st
= *(sun3x_fdc
.status_r
);
149 if((st
& 0x80) == 0) {
150 virtual_dma_count
= lcount
;
151 virtual_dma_addr
= lptr
;
159 /* fd_outb(*lptr, virtual_dma_port+5); */
160 *(sun3x_fdc
.data_r
) = *lptr
;
162 /* *lptr = fd_inb(virtual_dma_port+5); */
163 *lptr
= *(sun3x_fdc
.data_r
);
166 virtual_dma_count
= lcount
;
167 virtual_dma_addr
= lptr
;
168 /* st = fd_inb(virtual_dma_port+4); */
169 st
= *(sun3x_fdc
.status_r
);
172 #ifdef TRACE_FLPY_INT
175 // printk("st=%02x\n", st);
179 virtual_dma_residue
+= virtual_dma_count
;
183 #ifdef TRACE_FLPY_INT
184 printk("count=%x, residue=%x calls=%d bytes=%x dma_wait=%d\n",
185 virtual_dma_count
, virtual_dma_residue
, calls
, bytes
,
191 floppy_interrupt(irq
, dev_id
);
196 #ifdef TRACE_FLPY_INT
197 if(!virtual_dma_count
)
203 static int sun3xflop_request_irq(void)
210 error
= request_irq(FLOPPY_IRQ
, sun3xflop_hardint
,
211 IRQF_DISABLED
, "floppy", NULL
);
212 return ((error
== 0) ? 0 : -1);
216 static void __init
floppy_set_flags(int *ints
,int param
, int param2
);
218 static int sun3xflop_init(void)
220 if(FLOPPY_IRQ
< 0x40)
221 FLOPPY_IRQ
= SUN3X_FDC_IRQ
;
223 sun3x_fdc
.status_r
= (volatile unsigned char *)SUN3X_FDC
;
224 sun3x_fdc
.data_r
= (volatile unsigned char *)(SUN3X_FDC
+1);
225 sun3x_fdc
.fcr_r
= (volatile unsigned char *)SUN3X_FDC_FCR
;
226 sun3x_fdc
.fvr_r
= (volatile unsigned char *)SUN3X_FDC_FVR
;
229 /* Last minute sanity check... */
230 if(*sun3x_fdc
.status_r
== 0xff) {
234 *sun3x_fdc
.fvr_r
= FLOPPY_IRQ
;
236 *sun3x_fdc
.fcr_r
= FCR_TC
;
238 *sun3x_fdc
.fcr_r
= 0;
241 floppy_set_flags(NULL
, 1, FD_BROKEN_DCL
); // I don't know how to detect this.
242 allowed_drive_mask
= 0x01;
243 return (int) SUN3X_FDC
;
246 /* I'm not precisely sure this eject routine works */
247 static int sun3x_eject(void)
251 sun3x_fdc
.fcr
|= (FCR_DSEL0
| FCR_EJECT
);
252 *(sun3x_fdc
.fcr_r
) = sun3x_fdc
.fcr
;
254 sun3x_fdc
.fcr
&= ~(FCR_DSEL0
| FCR_EJECT
);
255 *(sun3x_fdc
.fcr_r
) = sun3x_fdc
.fcr
;
261 #define fd_eject(drive) sun3x_eject()
263 #endif /* !(__ASM_SUN3X_FLOPPY_H) */