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. */
32 #define release_region(X, Y) do { } while(0)
33 #define check_region(X, Y) (0)
34 #define request_region(X, Y, Z) (1)
36 struct sun3xflop_private
{
37 volatile unsigned char *status_r
;
38 volatile unsigned char *data_r
;
39 volatile unsigned char *fcr_r
;
40 volatile unsigned char *fvr_r
;
44 /* Super paranoid... */
45 #undef HAVE_DISABLE_HLT
47 /* Routines unique to each controller type on a Sun. */
48 static unsigned char sun3x_82072_fd_inb(int port
)
54 printk("floppy: Asked to read unknown port %d\n", port
);
55 panic("floppy: Port bolixed.");
56 case 4: /* FD_STATUS */
57 return (*sun3x_fdc
.status_r
) & ~STATUS_DMA
;
59 return (*sun3x_fdc
.data_r
);
61 /* ugly hack, I can't find a way to actually detect the disk */
68 panic("sun_82072_fd_inb: How did I get here?");
71 static void sun3x_82072_fd_outb(unsigned char value
, int port
)
76 printk("floppy: Asked to write to unknown port %d\n", port
);
77 panic("floppy: Port bolixed.");
79 /* Oh geese, 82072 on the Sun has no DOR register,
80 * so we make do with taunting the FCR.
82 * ASSUMPTIONS: There will only ever be one floppy
83 * drive attached to a Sun controller
84 * and it will be at drive zero.
88 unsigned char fcr
= sun3x_fdc
.fcr
;
91 fcr
|= (FCR_DSEL0
| FCR_MTRON
);
93 fcr
&= ~(FCR_DSEL0
| FCR_MTRON
);
96 if(fcr
!= sun3x_fdc
.fcr
) {
97 *(sun3x_fdc
.fcr_r
) = fcr
;
102 case 5: /* FD_DATA */
103 *(sun3x_fdc
.data_r
) = value
;
106 *(sun3x_fdc
.status_r
) = value
;
108 case 4: /* FD_STATUS */
109 *(sun3x_fdc
.status_r
) = value
;
116 asmlinkage irqreturn_t
sun3xflop_hardint(int irq
, void *dev_id
,
117 struct pt_regs
* regs
)
119 register unsigned char st
;
121 #undef TRACE_FLPY_INT
122 #define NO_FLOPPY_ASSEMBLER
124 #ifdef TRACE_FLPY_INT
127 static int dma_wait
=0;
130 floppy_interrupt(irq
, dev_id
, regs
);
134 // printk("doing pdma\n");// st %x\n", sun_fdc->status_82072);
136 #ifdef TRACE_FLPY_INT
138 bytes
= virtual_dma_count
;
145 for(lcount
=virtual_dma_count
, lptr
=virtual_dma_addr
;
146 lcount
; lcount
--, lptr
++) {
147 /* st=fd_inb(virtual_dma_port+4) & 0x80 ; */
148 st
= *(sun3x_fdc
.status_r
);
152 if((st
& 0x80) == 0) {
153 virtual_dma_count
= lcount
;
154 virtual_dma_addr
= lptr
;
162 /* fd_outb(*lptr, virtual_dma_port+5); */
163 *(sun3x_fdc
.data_r
) = *lptr
;
165 /* *lptr = fd_inb(virtual_dma_port+5); */
166 *lptr
= *(sun3x_fdc
.data_r
);
169 virtual_dma_count
= lcount
;
170 virtual_dma_addr
= lptr
;
171 /* st = fd_inb(virtual_dma_port+4); */
172 st
= *(sun3x_fdc
.status_r
);
175 #ifdef TRACE_FLPY_INT
178 // printk("st=%02x\n", st);
182 virtual_dma_residue
+= virtual_dma_count
;
186 #ifdef TRACE_FLPY_INT
187 printk("count=%x, residue=%x calls=%d bytes=%x dma_wait=%d\n",
188 virtual_dma_count
, virtual_dma_residue
, calls
, bytes
,
194 floppy_interrupt(irq
, dev_id
, regs
);
199 #ifdef TRACE_FLPY_INT
200 if(!virtual_dma_count
)
206 static int sun3xflop_request_irq(void)
213 error
= request_irq(FLOPPY_IRQ
, sun3xflop_hardint
, SA_INTERRUPT
, "floppy", 0);
214 return ((error
== 0) ? 0 : -1);
218 static void __init
floppy_set_flags(int *ints
,int param
, int param2
);
220 static int sun3xflop_init(void)
222 if(FLOPPY_IRQ
< 0x40)
223 FLOPPY_IRQ
= SUN3X_FDC_IRQ
;
225 sun3x_fdc
.status_r
= (volatile unsigned char *)SUN3X_FDC
;
226 sun3x_fdc
.data_r
= (volatile unsigned char *)(SUN3X_FDC
+1);
227 sun3x_fdc
.fcr_r
= (volatile unsigned char *)SUN3X_FDC_FCR
;
228 sun3x_fdc
.fvr_r
= (volatile unsigned char *)SUN3X_FDC_FVR
;
231 /* Last minute sanity check... */
232 if(*sun3x_fdc
.status_r
== 0xff) {
236 *sun3x_fdc
.fvr_r
= FLOPPY_IRQ
;
238 *sun3x_fdc
.fcr_r
= FCR_TC
;
240 *sun3x_fdc
.fcr_r
= 0;
243 floppy_set_flags(0, 1, FD_BROKEN_DCL
); // I don't know how to detect this.
244 allowed_drive_mask
= 0x01;
245 return (int) SUN3X_FDC
;
248 /* I'm not precisely sure this eject routine works */
249 static int sun3x_eject(void)
253 sun3x_fdc
.fcr
|= (FCR_DSEL0
| FCR_EJECT
);
254 *(sun3x_fdc
.fcr_r
) = sun3x_fdc
.fcr
;
256 sun3x_fdc
.fcr
&= ~(FCR_DSEL0
| FCR_EJECT
);
257 *(sun3x_fdc
.fcr_r
) = sun3x_fdc
.fcr
;
263 #define fd_eject(drive) sun3x_eject()
265 #endif /* !(__ASM_SUN3X_FLOPPY_H) */