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>
15 #include <asm/sun3x.h>
17 /* default interrupt vector */
18 #define SUN3X_FDC_IRQ 0x40
25 #define FCR_DSEL0 0x10
27 /* We don't need no stinkin' I/O port allocation crap. */
30 #define release_region(X, Y) do { } while(0)
31 #define request_region(X, Y, Z) (1)
33 struct sun3xflop_private {
34 volatile unsigned char *status_r;
35 volatile unsigned char *data_r;
36 volatile unsigned char *fcr_r;
37 volatile unsigned char *fvr_r;
41 /* Super paranoid... */
42 #undef HAVE_DISABLE_HLT
44 /* Routines unique to each controller type on a Sun. */
45 static unsigned char sun3x_82072_fd_inb(int port)
51 printk("floppy: Asked to read unknown port %d\n", port);
52 panic("floppy: Port bolixed.");
53 case 4: /* FD_STATUS */
54 return (*sun3x_fdc.status_r) & ~STATUS_DMA;
56 return (*sun3x_fdc.data_r);
58 /* ugly hack, I can't find a way to actually detect the disk */
65 panic("sun_82072_fd_inb: How did I get here?");
68 static void sun3x_82072_fd_outb(unsigned char value, int port)
73 printk("floppy: Asked to write to unknown port %d\n", port);
74 panic("floppy: Port bolixed.");
76 /* Oh geese, 82072 on the Sun has no DOR register,
77 * so we make do with taunting the FCR.
79 * ASSUMPTIONS: There will only ever be one floppy
80 * drive attached to a Sun controller
81 * and it will be at drive zero.
85 unsigned char fcr = sun3x_fdc.fcr;
88 fcr |= (FCR_DSEL0 | FCR_MTRON);
90 fcr &= ~(FCR_DSEL0 | FCR_MTRON);
93 if(fcr != sun3x_fdc.fcr) {
94 *(sun3x_fdc.fcr_r) = fcr;
100 *(sun3x_fdc.data_r) = value;
103 *(sun3x_fdc.status_r) = value;
105 case 4: /* FD_STATUS */
106 *(sun3x_fdc.status_r) = value;
113 asmlinkage irqreturn_t sun3xflop_hardint(int irq, void *dev_id)
115 register unsigned char st;
117 #undef TRACE_FLPY_INT
118 #define NO_FLOPPY_ASSEMBLER
120 #ifdef TRACE_FLPY_INT
123 static int dma_wait=0;
126 floppy_interrupt(irq, dev_id);
130 // printk("doing pdma\n");// st %x\n", sun_fdc->status_82072);
132 #ifdef TRACE_FLPY_INT
134 bytes = virtual_dma_count;
141 for(lcount=virtual_dma_count, lptr=virtual_dma_addr;
142 lcount; lcount--, lptr++) {
143 /* st=fd_inb(virtual_dma_port+4) & 0x80 ; */
144 st = *(sun3x_fdc.status_r);
148 if((st & 0x80) == 0) {
149 virtual_dma_count = lcount;
150 virtual_dma_addr = lptr;
158 /* fd_outb(*lptr, virtual_dma_port+5); */
159 *(sun3x_fdc.data_r) = *lptr;
161 /* *lptr = fd_inb(virtual_dma_port+5); */
162 *lptr = *(sun3x_fdc.data_r);
165 virtual_dma_count = lcount;
166 virtual_dma_addr = lptr;
167 /* st = fd_inb(virtual_dma_port+4); */
168 st = *(sun3x_fdc.status_r);
171 #ifdef TRACE_FLPY_INT
174 // printk("st=%02x\n", st);
178 virtual_dma_residue += virtual_dma_count;
182 #ifdef TRACE_FLPY_INT
183 printk("count=%x, residue=%x calls=%d bytes=%x dma_wait=%d\n",
184 virtual_dma_count, virtual_dma_residue, calls, bytes,
190 floppy_interrupt(irq, dev_id);
195 #ifdef TRACE_FLPY_INT
196 if(!virtual_dma_count)
202 static int sun3xflop_request_irq(void)
209 error = request_irq(FLOPPY_IRQ, sun3xflop_hardint,
210 IRQF_DISABLED, "floppy", NULL);
211 return ((error == 0) ? 0 : -1);
215 static void __init floppy_set_flags(int *ints,int param, int param2);
217 static int sun3xflop_init(void)
219 if(FLOPPY_IRQ < 0x40)
220 FLOPPY_IRQ = SUN3X_FDC_IRQ;
222 sun3x_fdc.status_r = (volatile unsigned char *)SUN3X_FDC;
223 sun3x_fdc.data_r = (volatile unsigned char *)(SUN3X_FDC+1);
224 sun3x_fdc.fcr_r = (volatile unsigned char *)SUN3X_FDC_FCR;
225 sun3x_fdc.fvr_r = (volatile unsigned char *)SUN3X_FDC_FVR;
228 /* Last minute sanity check... */
229 if(*sun3x_fdc.status_r == 0xff) {
233 *sun3x_fdc.fvr_r = FLOPPY_IRQ;
235 *sun3x_fdc.fcr_r = FCR_TC;
237 *sun3x_fdc.fcr_r = 0;
240 floppy_set_flags(NULL, 1, FD_BROKEN_DCL); // I don't know how to detect this.
241 allowed_drive_mask = 0x01;
242 return (int) SUN3X_FDC;
245 /* I'm not precisely sure this eject routine works */
246 static int sun3x_eject(void)
250 sun3x_fdc.fcr |= (FCR_DSEL0 | FCR_EJECT);
251 *(sun3x_fdc.fcr_r) = sun3x_fdc.fcr;
253 sun3x_fdc.fcr &= ~(FCR_DSEL0 | FCR_EJECT);
254 *(sun3x_fdc.fcr_r) = sun3x_fdc.fcr;
260 #define fd_eject(drive) sun3x_eject()
262 #endif /* !(__ASM_SUN3X_FLOPPY_H) */