[PATCH] blk: remove blk_queue_tag->real_max_depth optimization
[linux-2.6/libata-dev.git] / include / asm-sparc64 / floppy.h
blobe071b4b4edfd8ec8b92ceb4d3d8edcfc4cd644dc
1 /* $Id: floppy.h,v 1.32 2001/10/26 17:59:36 davem Exp $
2 * asm-sparc64/floppy.h: Sparc specific parts of the Floppy driver.
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 * Ultra/PCI support added: Sep 1997 Eddie C. Dost (ecd@skynet.be)
8 */
10 #ifndef __ASM_SPARC64_FLOPPY_H
11 #define __ASM_SPARC64_FLOPPY_H
13 #include <linux/config.h>
14 #include <linux/init.h>
16 #include <asm/page.h>
17 #include <asm/pgtable.h>
18 #include <asm/system.h>
19 #include <asm/idprom.h>
20 #include <asm/oplib.h>
21 #include <asm/auxio.h>
22 #include <asm/sbus.h>
23 #include <asm/irq.h>
27 * Define this to enable exchanging drive 0 and 1 if only drive 1 is
28 * probed on PCI machines.
30 #undef PCI_FDC_SWAP_DRIVES
33 /* References:
34 * 1) Netbsd Sun floppy driver.
35 * 2) NCR 82077 controller manual
36 * 3) Intel 82077 controller manual
38 struct sun_flpy_controller {
39 volatile unsigned char status1_82077; /* Auxiliary Status reg. 1 */
40 volatile unsigned char status2_82077; /* Auxiliary Status reg. 2 */
41 volatile unsigned char dor_82077; /* Digital Output reg. */
42 volatile unsigned char tapectl_82077; /* Tape Control reg */
43 volatile unsigned char status_82077; /* Main Status Register. */
44 #define drs_82077 status_82077 /* Digital Rate Select reg. */
45 volatile unsigned char data_82077; /* Data fifo. */
46 volatile unsigned char ___unused;
47 volatile unsigned char dir_82077; /* Digital Input reg. */
48 #define dcr_82077 dir_82077 /* Config Control reg. */
51 /* You'll only ever find one controller on an Ultra anyways. */
52 static struct sun_flpy_controller *sun_fdc = (struct sun_flpy_controller *)-1;
53 unsigned long fdc_status;
54 static struct sbus_dev *floppy_sdev = NULL;
56 struct sun_floppy_ops {
57 unsigned char (*fd_inb) (unsigned long port);
58 void (*fd_outb) (unsigned char value, unsigned long port);
59 void (*fd_enable_dma) (void);
60 void (*fd_disable_dma) (void);
61 void (*fd_set_dma_mode) (int);
62 void (*fd_set_dma_addr) (char *);
63 void (*fd_set_dma_count) (int);
64 unsigned int (*get_dma_residue) (void);
65 int (*fd_request_irq) (void);
66 void (*fd_free_irq) (void);
67 int (*fd_eject) (int);
70 static struct sun_floppy_ops sun_fdops;
72 #define fd_inb(port) sun_fdops.fd_inb(port)
73 #define fd_outb(value,port) sun_fdops.fd_outb(value,port)
74 #define fd_enable_dma() sun_fdops.fd_enable_dma()
75 #define fd_disable_dma() sun_fdops.fd_disable_dma()
76 #define fd_request_dma() (0) /* nothing... */
77 #define fd_free_dma() /* nothing... */
78 #define fd_clear_dma_ff() /* nothing... */
79 #define fd_set_dma_mode(mode) sun_fdops.fd_set_dma_mode(mode)
80 #define fd_set_dma_addr(addr) sun_fdops.fd_set_dma_addr(addr)
81 #define fd_set_dma_count(count) sun_fdops.fd_set_dma_count(count)
82 #define get_dma_residue(x) sun_fdops.get_dma_residue()
83 #define fd_cacheflush(addr, size) /* nothing... */
84 #define fd_request_irq() sun_fdops.fd_request_irq()
85 #define fd_free_irq() sun_fdops.fd_free_irq()
86 #define fd_eject(drive) sun_fdops.fd_eject(drive)
88 static int FLOPPY_MOTOR_MASK = 0x10;
90 /* Super paranoid... */
91 #undef HAVE_DISABLE_HLT
93 static int sun_floppy_types[2] = { 0, 0 };
95 /* Here is where we catch the floppy driver trying to initialize,
96 * therefore this is where we call the PROM device tree probing
97 * routine etc. on the Sparc.
99 #define FLOPPY0_TYPE sun_floppy_init()
100 #define FLOPPY1_TYPE sun_floppy_types[1]
102 #define FDC1 ((unsigned long)sun_fdc)
104 #define N_FDC 1
105 #define N_DRIVE 8
107 /* No 64k boundary crossing problems on the Sparc. */
108 #define CROSS_64KB(a,s) (0)
110 static unsigned char sun_82077_fd_inb(unsigned long port)
112 udelay(5);
113 switch(port & 7) {
114 default:
115 printk("floppy: Asked to read unknown port %lx\n", port);
116 panic("floppy: Port bolixed.");
117 case 4: /* FD_STATUS */
118 return sbus_readb(&sun_fdc->status_82077) & ~STATUS_DMA;
119 case 5: /* FD_DATA */
120 return sbus_readb(&sun_fdc->data_82077);
121 case 7: /* FD_DIR */
122 /* XXX: Is DCL on 0x80 in sun4m? */
123 return sbus_readb(&sun_fdc->dir_82077);
125 panic("sun_82072_fd_inb: How did I get here?");
128 static void sun_82077_fd_outb(unsigned char value, unsigned long port)
130 udelay(5);
131 switch(port & 7) {
132 default:
133 printk("floppy: Asked to write to unknown port %lx\n", port);
134 panic("floppy: Port bolixed.");
135 case 2: /* FD_DOR */
136 /* Happily, the 82077 has a real DOR register. */
137 sbus_writeb(value, &sun_fdc->dor_82077);
138 break;
139 case 5: /* FD_DATA */
140 sbus_writeb(value, &sun_fdc->data_82077);
141 break;
142 case 7: /* FD_DCR */
143 sbus_writeb(value, &sun_fdc->dcr_82077);
144 break;
145 case 4: /* FD_STATUS */
146 sbus_writeb(value, &sun_fdc->status_82077);
147 break;
149 return;
152 /* For pseudo-dma (Sun floppy drives have no real DMA available to
153 * them so we must eat the data fifo bytes directly ourselves) we have
154 * three state variables. doing_pdma tells our inline low-level
155 * assembly floppy interrupt entry point whether it should sit and eat
156 * bytes from the fifo or just transfer control up to the higher level
157 * floppy interrupt c-code. I tried very hard but I could not get the
158 * pseudo-dma to work in c-code without getting many overruns and
159 * underruns. If non-zero, doing_pdma encodes the direction of
160 * the transfer for debugging. 1=read 2=write
162 char *pdma_vaddr;
163 unsigned long pdma_size;
164 volatile int doing_pdma = 0;
166 /* This is software state */
167 char *pdma_base = NULL;
168 unsigned long pdma_areasize;
170 /* Common routines to all controller types on the Sparc. */
171 static void sun_fd_disable_dma(void)
173 doing_pdma = 0;
174 if (pdma_base) {
175 mmu_unlockarea(pdma_base, pdma_areasize);
176 pdma_base = NULL;
180 static void sun_fd_set_dma_mode(int mode)
182 switch(mode) {
183 case DMA_MODE_READ:
184 doing_pdma = 1;
185 break;
186 case DMA_MODE_WRITE:
187 doing_pdma = 2;
188 break;
189 default:
190 printk("Unknown dma mode %d\n", mode);
191 panic("floppy: Giving up...");
195 static void sun_fd_set_dma_addr(char *buffer)
197 pdma_vaddr = buffer;
200 static void sun_fd_set_dma_count(int length)
202 pdma_size = length;
205 static void sun_fd_enable_dma(void)
207 pdma_vaddr = mmu_lockarea(pdma_vaddr, pdma_size);
208 pdma_base = pdma_vaddr;
209 pdma_areasize = pdma_size;
212 /* Our low-level entry point in arch/sparc/kernel/entry.S */
213 extern irqreturn_t floppy_hardint(int irq, void *unused, struct pt_regs *regs);
215 static int sun_fd_request_irq(void)
217 static int once = 0;
218 int error;
220 if(!once) {
221 once = 1;
223 error = request_fast_irq(FLOPPY_IRQ, floppy_hardint,
224 SA_INTERRUPT, "floppy", NULL);
226 return ((error == 0) ? 0 : -1);
228 return 0;
231 static void sun_fd_free_irq(void)
235 static unsigned int sun_get_dma_residue(void)
237 /* XXX This isn't really correct. XXX */
238 return 0;
241 static int sun_fd_eject(int drive)
243 set_dor(0x00, 0xff, 0x90);
244 udelay(500);
245 set_dor(0x00, 0x6f, 0x00);
246 udelay(500);
247 return 0;
250 #ifdef CONFIG_PCI
251 #include <asm/ebus.h>
252 #include <asm/isa.h>
253 #include <asm/ns87303.h>
255 static struct ebus_dma_info sun_pci_fd_ebus_dma;
256 static struct pci_dev *sun_pci_ebus_dev;
257 static int sun_pci_broken_drive = -1;
259 struct sun_pci_dma_op {
260 unsigned int addr;
261 int len;
262 int direction;
263 char *buf;
265 static struct sun_pci_dma_op sun_pci_dma_current = { -1U, 0, 0, NULL};
266 static struct sun_pci_dma_op sun_pci_dma_pending = { -1U, 0, 0, NULL};
268 extern irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs *regs);
270 static unsigned char sun_pci_fd_inb(unsigned long port)
272 udelay(5);
273 return inb(port);
276 static void sun_pci_fd_outb(unsigned char val, unsigned long port)
278 udelay(5);
279 outb(val, port);
282 static void sun_pci_fd_broken_outb(unsigned char val, unsigned long port)
284 udelay(5);
286 * XXX: Due to SUN's broken floppy connector on AX and AXi
287 * we need to turn on MOTOR_0 also, if the floppy is
288 * jumpered to DS1 (like most PC floppies are). I hope
289 * this does not hurt correct hardware like the AXmp.
290 * (Eddie, Sep 12 1998).
292 if (port == ((unsigned long)sun_fdc) + 2) {
293 if (((val & 0x03) == sun_pci_broken_drive) && (val & 0x20)) {
294 val |= 0x10;
297 outb(val, port);
300 #ifdef PCI_FDC_SWAP_DRIVES
301 static void sun_pci_fd_lde_broken_outb(unsigned char val, unsigned long port)
303 udelay(5);
305 * XXX: Due to SUN's broken floppy connector on AX and AXi
306 * we need to turn on MOTOR_0 also, if the floppy is
307 * jumpered to DS1 (like most PC floppies are). I hope
308 * this does not hurt correct hardware like the AXmp.
309 * (Eddie, Sep 12 1998).
311 if (port == ((unsigned long)sun_fdc) + 2) {
312 if (((val & 0x03) == sun_pci_broken_drive) && (val & 0x10)) {
313 val &= ~(0x03);
314 val |= 0x21;
317 outb(val, port);
319 #endif /* PCI_FDC_SWAP_DRIVES */
321 static void sun_pci_fd_enable_dma(void)
323 BUG_ON((NULL == sun_pci_dma_pending.buf) ||
324 (0 == sun_pci_dma_pending.len) ||
325 (0 == sun_pci_dma_pending.direction));
327 sun_pci_dma_current.buf = sun_pci_dma_pending.buf;
328 sun_pci_dma_current.len = sun_pci_dma_pending.len;
329 sun_pci_dma_current.direction = sun_pci_dma_pending.direction;
331 sun_pci_dma_pending.buf = NULL;
332 sun_pci_dma_pending.len = 0;
333 sun_pci_dma_pending.direction = 0;
334 sun_pci_dma_pending.addr = -1U;
336 sun_pci_dma_current.addr =
337 pci_map_single(sun_pci_ebus_dev,
338 sun_pci_dma_current.buf,
339 sun_pci_dma_current.len,
340 sun_pci_dma_current.direction);
342 ebus_dma_enable(&sun_pci_fd_ebus_dma, 1);
344 if (ebus_dma_request(&sun_pci_fd_ebus_dma,
345 sun_pci_dma_current.addr,
346 sun_pci_dma_current.len))
347 BUG();
350 static void sun_pci_fd_disable_dma(void)
352 ebus_dma_enable(&sun_pci_fd_ebus_dma, 0);
353 if (sun_pci_dma_current.addr != -1U)
354 pci_unmap_single(sun_pci_ebus_dev,
355 sun_pci_dma_current.addr,
356 sun_pci_dma_current.len,
357 sun_pci_dma_current.direction);
358 sun_pci_dma_current.addr = -1U;
361 static void sun_pci_fd_set_dma_mode(int mode)
363 if (mode == DMA_MODE_WRITE)
364 sun_pci_dma_pending.direction = PCI_DMA_TODEVICE;
365 else
366 sun_pci_dma_pending.direction = PCI_DMA_FROMDEVICE;
368 ebus_dma_prepare(&sun_pci_fd_ebus_dma, mode != DMA_MODE_WRITE);
371 static void sun_pci_fd_set_dma_count(int length)
373 sun_pci_dma_pending.len = length;
376 static void sun_pci_fd_set_dma_addr(char *buffer)
378 sun_pci_dma_pending.buf = buffer;
381 static unsigned int sun_pci_get_dma_residue(void)
383 return ebus_dma_residue(&sun_pci_fd_ebus_dma);
386 static int sun_pci_fd_request_irq(void)
388 return ebus_dma_irq_enable(&sun_pci_fd_ebus_dma, 1);
391 static void sun_pci_fd_free_irq(void)
393 ebus_dma_irq_enable(&sun_pci_fd_ebus_dma, 0);
396 static int sun_pci_fd_eject(int drive)
398 return -EINVAL;
401 void sun_pci_fd_dma_callback(struct ebus_dma_info *p, int event, void *cookie)
403 floppy_interrupt(0, NULL, NULL);
407 * Floppy probing, we'd like to use /dev/fd0 for a single Floppy on PCI,
408 * even if this is configured using DS1, thus looks like /dev/fd1 with
409 * the cabling used in Ultras.
411 #define DOR (port + 2)
412 #define MSR (port + 4)
413 #define FIFO (port + 5)
415 static void sun_pci_fd_out_byte(unsigned long port, unsigned char val,
416 unsigned long reg)
418 unsigned char status;
419 int timeout = 1000;
421 while (!((status = inb(MSR)) & 0x80) && --timeout)
422 udelay(100);
423 outb(val, reg);
426 static unsigned char sun_pci_fd_sensei(unsigned long port)
428 unsigned char result[2] = { 0x70, 0x00 };
429 unsigned char status;
430 int i = 0;
432 sun_pci_fd_out_byte(port, 0x08, FIFO);
433 do {
434 int timeout = 1000;
436 while (!((status = inb(MSR)) & 0x80) && --timeout)
437 udelay(100);
439 if (!timeout)
440 break;
442 if ((status & 0xf0) == 0xd0)
443 result[i++] = inb(FIFO);
444 else
445 break;
446 } while (i < 2);
448 return result[0];
451 static void sun_pci_fd_reset(unsigned long port)
453 unsigned char mask = 0x00;
454 unsigned char status;
455 int timeout = 10000;
457 outb(0x80, MSR);
458 do {
459 status = sun_pci_fd_sensei(port);
460 if ((status & 0xc0) == 0xc0)
461 mask |= 1 << (status & 0x03);
462 else
463 udelay(100);
464 } while ((mask != 0x0f) && --timeout);
467 static int sun_pci_fd_test_drive(unsigned long port, int drive)
469 unsigned char status, data;
470 int timeout = 1000;
471 int ready;
473 sun_pci_fd_reset(port);
475 data = (0x10 << drive) | 0x0c | drive;
476 sun_pci_fd_out_byte(port, data, DOR);
478 sun_pci_fd_out_byte(port, 0x07, FIFO);
479 sun_pci_fd_out_byte(port, drive & 0x03, FIFO);
481 do {
482 udelay(100);
483 status = sun_pci_fd_sensei(port);
484 } while (((status & 0xc0) == 0x80) && --timeout);
486 if (!timeout)
487 ready = 0;
488 else
489 ready = (status & 0x10) ? 0 : 1;
491 sun_pci_fd_reset(port);
492 return ready;
494 #undef FIFO
495 #undef MSR
496 #undef DOR
498 #endif /* CONFIG_PCI */
500 #ifdef CONFIG_PCI
501 static int __init ebus_fdthree_p(struct linux_ebus_device *edev)
503 if (!strcmp(edev->prom_name, "fdthree"))
504 return 1;
505 if (!strcmp(edev->prom_name, "floppy")) {
506 char compat[16];
507 prom_getstring(edev->prom_node,
508 "compatible",
509 compat, sizeof(compat));
510 compat[15] = '\0';
511 if (!strcmp(compat, "fdthree"))
512 return 1;
514 return 0;
516 #endif
518 #ifdef CONFIG_PCI
519 #undef ISA_FLOPPY_WORKS
521 #ifdef ISA_FLOPPY_WORKS
522 static unsigned long __init isa_floppy_init(void)
524 struct sparc_isa_bridge *isa_br;
525 struct sparc_isa_device *isa_dev = NULL;
527 for_each_isa(isa_br) {
528 for_each_isadev(isa_dev, isa_br) {
529 if (!strcmp(isa_dev->prom_name, "dma")) {
530 struct sparc_isa_device *child =
531 isa_dev->child;
533 while (child) {
534 if (!strcmp(child->prom_name,
535 "floppy")) {
536 isa_dev = child;
537 goto isa_done;
539 child = child->next;
544 isa_done:
545 if (!isa_dev)
546 return 0;
548 /* We could use DMA on devices behind the ISA bridge, but...
550 * There is a slight problem. Normally on x86 kit the x86 processor
551 * delays I/O port instructions when the ISA bus "dma in progress"
552 * signal is active. Well, sparc64 systems do not monitor this
553 * signal thus we would need to block all I/O port accesses in software
554 * when a dma transfer is active for some device.
557 sun_fdc = (struct sun_flpy_controller *)isa_dev->resource.start;
558 FLOPPY_IRQ = isa_dev->irq;
560 sun_fdops.fd_inb = sun_pci_fd_inb;
561 sun_fdops.fd_outb = sun_pci_fd_outb;
563 can_use_virtual_dma = use_virtual_dma = 1;
564 sun_fdops.fd_enable_dma = sun_fd_enable_dma;
565 sun_fdops.fd_disable_dma = sun_fd_disable_dma;
566 sun_fdops.fd_set_dma_mode = sun_fd_set_dma_mode;
567 sun_fdops.fd_set_dma_addr = sun_fd_set_dma_addr;
568 sun_fdops.fd_set_dma_count = sun_fd_set_dma_count;
569 sun_fdops.get_dma_residue = sun_get_dma_residue;
571 sun_fdops.fd_request_irq = sun_fd_request_irq;
572 sun_fdops.fd_free_irq = sun_fd_free_irq;
574 /* Floppy eject is manual. Actually, could determine this
575 * via presence of 'manual' property in OBP node.
577 sun_fdops.fd_eject = sun_pci_fd_eject;
579 fdc_status = (unsigned long) &sun_fdc->status_82077;
580 FLOPPY_MOTOR_MASK = 0xf0;
582 allowed_drive_mask = 0;
583 sun_floppy_types[0] = 0;
584 sun_floppy_types[1] = 4;
586 sun_pci_broken_drive = 1;
587 sun_fdops.fd_outb = sun_pci_fd_broken_outb;
589 return sun_floppy_types[0];
591 #endif /* ISA_FLOPPY_WORKS */
593 #endif
595 static unsigned long __init sun_floppy_init(void)
597 char state[128];
598 struct sbus_bus *bus;
599 struct sbus_dev *sdev = NULL;
600 static int initialized = 0;
602 if (initialized)
603 return sun_floppy_types[0];
604 initialized = 1;
606 for_all_sbusdev (sdev, bus) {
607 if (!strcmp(sdev->prom_name, "SUNW,fdtwo"))
608 break;
610 if(sdev) {
611 floppy_sdev = sdev;
612 FLOPPY_IRQ = sdev->irqs[0];
613 } else {
614 #ifdef CONFIG_PCI
615 struct linux_ebus *ebus;
616 struct linux_ebus_device *edev = NULL;
617 unsigned long config = 0;
618 unsigned long auxio_reg;
620 for_each_ebus(ebus) {
621 for_each_ebusdev(edev, ebus) {
622 if (ebus_fdthree_p(edev))
623 goto ebus_done;
626 ebus_done:
627 if (!edev) {
628 #ifdef ISA_FLOPPY_WORKS
629 return isa_floppy_init();
630 #else
631 return 0;
632 #endif
635 prom_getproperty(edev->prom_node, "status",
636 state, sizeof(state));
637 if (!strncmp(state, "disabled", 8))
638 return 0;
640 FLOPPY_IRQ = edev->irqs[0];
642 /* Make sure the high density bit is set, some systems
643 * (most notably Ultra5/Ultra10) come up with it clear.
645 auxio_reg = edev->resource[2].start;
646 writel(readl(auxio_reg)|0x2, auxio_reg);
648 sun_pci_ebus_dev = ebus->self;
650 spin_lock_init(&sun_pci_fd_ebus_dma.lock);
652 /* XXX ioremap */
653 sun_pci_fd_ebus_dma.regs = edev->resource[1].start;
654 if (!sun_pci_fd_ebus_dma.regs)
655 return 0;
657 sun_pci_fd_ebus_dma.flags = (EBUS_DMA_FLAG_USE_EBDMA_HANDLER |
658 EBUS_DMA_FLAG_TCI_DISABLE);
659 sun_pci_fd_ebus_dma.callback = sun_pci_fd_dma_callback;
660 sun_pci_fd_ebus_dma.client_cookie = NULL;
661 sun_pci_fd_ebus_dma.irq = FLOPPY_IRQ;
662 strcpy(sun_pci_fd_ebus_dma.name, "floppy");
663 if (ebus_dma_register(&sun_pci_fd_ebus_dma))
664 return 0;
666 /* XXX ioremap */
667 sun_fdc = (struct sun_flpy_controller *)edev->resource[0].start;
669 sun_fdops.fd_inb = sun_pci_fd_inb;
670 sun_fdops.fd_outb = sun_pci_fd_outb;
672 can_use_virtual_dma = use_virtual_dma = 0;
673 sun_fdops.fd_enable_dma = sun_pci_fd_enable_dma;
674 sun_fdops.fd_disable_dma = sun_pci_fd_disable_dma;
675 sun_fdops.fd_set_dma_mode = sun_pci_fd_set_dma_mode;
676 sun_fdops.fd_set_dma_addr = sun_pci_fd_set_dma_addr;
677 sun_fdops.fd_set_dma_count = sun_pci_fd_set_dma_count;
678 sun_fdops.get_dma_residue = sun_pci_get_dma_residue;
680 sun_fdops.fd_request_irq = sun_pci_fd_request_irq;
681 sun_fdops.fd_free_irq = sun_pci_fd_free_irq;
683 sun_fdops.fd_eject = sun_pci_fd_eject;
685 fdc_status = (unsigned long) &sun_fdc->status_82077;
686 FLOPPY_MOTOR_MASK = 0xf0;
689 * XXX: Find out on which machines this is really needed.
691 if (1) {
692 sun_pci_broken_drive = 1;
693 sun_fdops.fd_outb = sun_pci_fd_broken_outb;
696 allowed_drive_mask = 0;
697 if (sun_pci_fd_test_drive((unsigned long)sun_fdc, 0))
698 sun_floppy_types[0] = 4;
699 if (sun_pci_fd_test_drive((unsigned long)sun_fdc, 1))
700 sun_floppy_types[1] = 4;
703 * Find NS87303 SuperIO config registers (through ecpp).
705 for_each_ebus(ebus) {
706 for_each_ebusdev(edev, ebus) {
707 if (!strcmp(edev->prom_name, "ecpp")) {
708 config = edev->resource[1].start;
709 goto config_done;
713 config_done:
716 * Sanity check, is this really the NS87303?
718 switch (config & 0x3ff) {
719 case 0x02e:
720 case 0x15c:
721 case 0x26e:
722 case 0x398:
723 break;
724 default:
725 config = 0;
728 if (!config)
729 return sun_floppy_types[0];
731 /* Enable PC-AT mode. */
732 ns87303_modify(config, ASC, 0, 0xc0);
734 #ifdef PCI_FDC_SWAP_DRIVES
736 * If only Floppy 1 is present, swap drives.
738 if (!sun_floppy_types[0] && sun_floppy_types[1]) {
740 * Set the drive exchange bit in FCR on NS87303,
741 * make shure other bits are sane before doing so.
743 ns87303_modify(config, FER, FER_EDM, 0);
744 ns87303_modify(config, ASC, ASC_DRV2_SEL, 0);
745 ns87303_modify(config, FCR, 0, FCR_LDE);
747 config = sun_floppy_types[0];
748 sun_floppy_types[0] = sun_floppy_types[1];
749 sun_floppy_types[1] = config;
751 if (sun_pci_broken_drive != -1) {
752 sun_pci_broken_drive = 1 - sun_pci_broken_drive;
753 sun_fdops.fd_outb = sun_pci_fd_lde_broken_outb;
756 #endif /* PCI_FDC_SWAP_DRIVES */
758 return sun_floppy_types[0];
759 #else
760 return 0;
761 #endif
763 prom_getproperty(sdev->prom_node, "status", state, sizeof(state));
764 if(!strncmp(state, "disabled", 8))
765 return 0;
768 * We cannot do sbus_ioremap here: it does request_region,
769 * which the generic floppy driver tries to do once again.
770 * But we must use the sdev resource values as they have
771 * had parent ranges applied.
773 sun_fdc = (struct sun_flpy_controller *)
774 (sdev->resource[0].start +
775 ((sdev->resource[0].flags & 0x1ffUL) << 32UL));
777 /* Last minute sanity check... */
778 if(sbus_readb(&sun_fdc->status1_82077) == 0xff) {
779 sun_fdc = (struct sun_flpy_controller *)-1;
780 return 0;
783 sun_fdops.fd_inb = sun_82077_fd_inb;
784 sun_fdops.fd_outb = sun_82077_fd_outb;
786 can_use_virtual_dma = use_virtual_dma = 1;
787 sun_fdops.fd_enable_dma = sun_fd_enable_dma;
788 sun_fdops.fd_disable_dma = sun_fd_disable_dma;
789 sun_fdops.fd_set_dma_mode = sun_fd_set_dma_mode;
790 sun_fdops.fd_set_dma_addr = sun_fd_set_dma_addr;
791 sun_fdops.fd_set_dma_count = sun_fd_set_dma_count;
792 sun_fdops.get_dma_residue = sun_get_dma_residue;
794 sun_fdops.fd_request_irq = sun_fd_request_irq;
795 sun_fdops.fd_free_irq = sun_fd_free_irq;
797 sun_fdops.fd_eject = sun_fd_eject;
799 fdc_status = (unsigned long) &sun_fdc->status_82077;
801 /* Success... */
802 allowed_drive_mask = 0x01;
803 sun_floppy_types[0] = 4;
804 sun_floppy_types[1] = 0;
806 return sun_floppy_types[0];
809 #define EXTRA_FLOPPY_PARAMS
811 #endif /* !(__ASM_SPARC64_FLOPPY_H) */