ARM: multi_v7_defconfig: Switch BCM2835 to sdhci-iproc.c for MMC
[linux/fpc-iii.git] / arch / m68k / include / asm / sun3xflop.h
bloba02ea3a7bb20a0299e0f1bd2bf2306c484a4bc92
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)
7 */
9 #ifndef __ASM_SUN3X_FLOPPY_H
10 #define __ASM_SUN3X_FLOPPY_H
12 #include <asm/page.h>
13 #include <asm/pgtable.h>
14 #include <asm/irq.h>
15 #include <asm/sun3x.h>
17 /* default interrupt vector */
18 #define SUN3X_FDC_IRQ 0x40
20 /* some constants */
21 #define FCR_TC 0x1
22 #define FCR_EJECT 0x2
23 #define FCR_MTRON 0x4
24 #define FCR_DSEL1 0x8
25 #define FCR_DSEL0 0x10
27 /* We don't need no stinkin' I/O port allocation crap. */
28 #undef release_region
29 #undef request_region
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;
38 unsigned char fcr;
39 } sun3x_fdc;
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)
47 static int once = 0;
48 // udelay(5);
49 switch(port & 7) {
50 default:
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;
55 case 5: /* FD_DATA */
56 return (*sun3x_fdc.data_r);
57 case 7: /* FD_DIR */
58 /* ugly hack, I can't find a way to actually detect the disk */
59 if(!once) {
60 once = 1;
61 return 0x80;
63 return 0;
65 panic("sun_82072_fd_inb: How did I get here?");
68 static void sun3x_82072_fd_outb(unsigned char value, int port)
70 // udelay(5);
71 switch(port & 7) {
72 default:
73 printk("floppy: Asked to write to unknown port %d\n", port);
74 panic("floppy: Port bolixed.");
75 case 2: /* FD_DOR */
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;
87 if(value & 0x10) {
88 fcr |= (FCR_DSEL0 | FCR_MTRON);
89 } else
90 fcr &= ~(FCR_DSEL0 | FCR_MTRON);
93 if(fcr != sun3x_fdc.fcr) {
94 *(sun3x_fdc.fcr_r) = fcr;
95 sun3x_fdc.fcr = fcr;
98 break;
99 case 5: /* FD_DATA */
100 *(sun3x_fdc.data_r) = value;
101 break;
102 case 7: /* FD_DCR */
103 *(sun3x_fdc.status_r) = value;
104 break;
105 case 4: /* FD_STATUS */
106 *(sun3x_fdc.status_r) = value;
107 break;
109 return;
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
121 static int calls=0;
122 static int bytes=0;
123 static int dma_wait=0;
124 #endif
125 if(!doing_pdma) {
126 floppy_interrupt(irq, dev_id);
127 return IRQ_HANDLED;
130 // printk("doing pdma\n");// st %x\n", sun_fdc->status_82072);
132 #ifdef TRACE_FLPY_INT
133 if(!calls)
134 bytes = virtual_dma_count;
135 #endif
138 register int lcount;
139 register char *lptr;
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);
145 /* if(st != 0xa0) */
146 /* break; */
148 if((st & 0x80) == 0) {
149 virtual_dma_count = lcount;
150 virtual_dma_addr = lptr;
151 return IRQ_HANDLED;
154 if((st & 0x20) == 0)
155 break;
157 if(virtual_dma_mode)
158 /* fd_outb(*lptr, virtual_dma_port+5); */
159 *(sun3x_fdc.data_r) = *lptr;
160 else
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
172 calls++;
173 #endif
174 // printk("st=%02x\n", st);
175 if(st == 0x20)
176 return IRQ_HANDLED;
177 if(!(st & 0x20)) {
178 virtual_dma_residue += virtual_dma_count;
179 virtual_dma_count=0;
180 doing_pdma = 0;
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,
185 dma_wait);
186 calls = 0;
187 dma_wait=0;
188 #endif
190 floppy_interrupt(irq, dev_id);
191 return IRQ_HANDLED;
195 #ifdef TRACE_FLPY_INT
196 if(!virtual_dma_count)
197 dma_wait++;
198 #endif
199 return IRQ_HANDLED;
202 static int sun3xflop_request_irq(void)
204 static int once = 0;
205 int error;
207 if(!once) {
208 once = 1;
209 error = request_irq(FLOPPY_IRQ, sun3xflop_hardint,
210 0, "floppy", NULL);
211 return ((error == 0) ? 0 : -1);
212 } else return 0;
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;
226 sun3x_fdc.fcr = 0;
228 /* Last minute sanity check... */
229 if(*sun3x_fdc.status_r == 0xff) {
230 return -1;
233 *sun3x_fdc.fvr_r = FLOPPY_IRQ;
235 *sun3x_fdc.fcr_r = FCR_TC;
236 udelay(10);
237 *sun3x_fdc.fcr_r = 0;
239 /* Success... */
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)
248 if(MACH_IS_SUN3X) {
250 sun3x_fdc.fcr |= (FCR_DSEL0 | FCR_EJECT);
251 *(sun3x_fdc.fcr_r) = sun3x_fdc.fcr;
252 udelay(10);
253 sun3x_fdc.fcr &= ~(FCR_DSEL0 | FCR_EJECT);
254 *(sun3x_fdc.fcr_r) = sun3x_fdc.fcr;
257 return 0;
260 #define fd_eject(drive) sun3x_eject()
262 #endif /* !(__ASM_SUN3X_FLOPPY_H) */