diff options
| author | mycroft <mycroft@NetBSD.org> | 2003-09-25 01:05:06 +0000 |
|---|---|---|
| committer | mycroft <mycroft@NetBSD.org> | 2003-09-25 01:05:06 +0000 |
| commit | 516d857707f72fd8347efc1198f73dde3729113e (patch) | |
| tree | af25f918053617b30dd51648a9ff0ca7575b3792 /sys/dev | |
| parent | fc24d6a1975f0591cd8baa604a801637bef4c57d (diff) | |
Do fd probing after interrupts are enabled, and use tsleep() for delays.
Also try to accept a recalibrate interrupt to terminate the delay -- but that
doesn't seem to work reliably, so do a 2s timeout as well.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/isa/fd.c | 33 | ||||
| -rw-r--r-- | sys/dev/isa/fdc_isa.c | 6 | ||||
| -rw-r--r-- | sys/dev/isa/fdcvar.h | 5 |
3 files changed, 28 insertions, 16 deletions
diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c index 34a469c0425..694f0d33822 100644 --- a/sys/dev/isa/fd.c +++ b/sys/dev/isa/fd.c @@ -1,7 +1,7 @@ -/* $NetBSD: fd.c,v 1.47 2003/09/23 21:36:07 mycroft Exp $ */ +/* $NetBSD: fd.c,v 1.48 2003/09/25 01:05:06 mycroft Exp $ */ /*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. + * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -88,7 +88,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.47 2003/09/23 21:36:07 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.48 2003/09/25 01:05:06 mycroft Exp $"); #include "rnd.h" #include "opt_ddb.h" @@ -281,9 +281,10 @@ fdprint(aux, fdc) } void -fdcattach(fdc) - struct fdc_softc *fdc; +fdcattach(self) + struct device *self; { + struct fdc_softc *fdc = (void *)self; struct fdc_attach_args fa; bus_space_tag_t iot; bus_space_handle_t ioh; @@ -344,6 +345,7 @@ fdcattach(fdc) #endif /* i386 */ /* physical limit: four drives per controller. */ + fdc->sc_state = PROBING; for (fa.fa_drive = 0; fa.fa_drive < 4; fa.fa_drive++) { if (fdc->sc_known) { if (fdc->sc_present & (1 << fa.fa_drive)) { @@ -373,6 +375,7 @@ fdcattach(fdc) (void)config_found(&fdc->sc_dev, (void *)&fa, fdprint); } } + fdc->sc_state = DEVIDLE; } int @@ -404,18 +407,20 @@ fdprobe(parent, match, aux) if (fdc->sc_known) return 1; + /* toss any interrupt status */ + for (n = 0; n < 4; n++) { + out_fdc(iot, ioh, NE7CMD_SENSEI); + (void) fdcresult(fdc); + } /* select drive and turn on motor */ bus_space_write_1(iot, ioh, fdout, drive | FDO_FRST | FDO_MOEN(drive)); /* wait for motor to spin up */ - delay(250000); + (void) tsleep(fdc, PWAIT, "fdprobe1", hz / 4); out_fdc(iot, ioh, NE7CMD_RECAL); out_fdc(iot, ioh, drive); /* wait for recalibrate, up to 2s */ - for (n = 20000; n; n--) { - delay(100); - if ((bus_space_read_1(iot, ioh, fdsts) & FDS_DRVBUSY(drive)) == 0) - break; - } + if (tsleep(fdc, PWAIT, "fdprobe2", 2 * hz) != EWOULDBLOCK) +/*XXX*/ printf("fdprobe: got intr\n"); out_fdc(iot, ioh, NE7CMD_SENSEI); n = fdcresult(fdc); #ifdef FD_DEBUG @@ -946,6 +951,12 @@ fdcintr(arg) struct fd_type *type; struct ne7_fd_formb *finfo = NULL; + if (fdc->sc_state == PROBING) { +/*XXX*/ printf("got probe interrupt\n"); + wakeup(fdc); + return 1; + } + loop: /* Is there a drive for the controller to do a transfer with? */ fd = TAILQ_FIRST(&fdc->sc_drives); diff --git a/sys/dev/isa/fdc_isa.c b/sys/dev/isa/fdc_isa.c index 64dfc774ffd..50bc42cf075 100644 --- a/sys/dev/isa/fdc_isa.c +++ b/sys/dev/isa/fdc_isa.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdc_isa.c,v 1.8 2003/08/07 16:31:06 agc Exp $ */ +/* $NetBSD: fdc_isa.c,v 1.9 2003/09/25 01:05:06 mycroft Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdc_isa.c,v 1.8 2003/08/07 16:31:06 agc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdc_isa.c,v 1.9 2003/09/25 01:05:06 mycroft Exp $"); #include "rnd.h" @@ -225,5 +225,5 @@ fdc_isa_attach(struct device *parent, fdc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_BIO, fdcintr, fdc); - fdcattach(fdc); + config_interrupts(self, fdcattach); } diff --git a/sys/dev/isa/fdcvar.h b/sys/dev/isa/fdcvar.h index fad51f34af6..fe95430ec9b 100644 --- a/sys/dev/isa/fdcvar.h +++ b/sys/dev/isa/fdcvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: fdcvar.h,v 1.3 2003/08/07 16:31:06 agc Exp $ */ +/* $NetBSD: fdcvar.h,v 1.4 2003/09/25 01:05:06 mycroft Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -88,6 +88,7 @@ */ enum fdc_state { + PROBING = -1, DEVIDLE = 0, MOTORWAIT, DOSEEK, @@ -143,5 +144,5 @@ struct fdc_softc { int out_fdc __P((bus_space_tag_t iot, bus_space_handle_t ioh, u_char x)); -void fdcattach __P((struct fdc_softc *)); +void fdcattach __P((struct device *)); int fdcintr __P((void *)); |
