summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormycroft <mycroft@NetBSD.org>2003-09-23 21:36:07 +0000
committermycroft <mycroft@NetBSD.org>2003-09-23 21:36:07 +0000
commitdf8e298ddbb57c24c6b4c31f090cd3fa55f1a2d4 (patch)
treeb55278b292d50502e3a6c430f340627337f64338 /sys/dev
parent72b77eb9e9d551898d6ec52afe5d6203589e17b5 (diff)
Small changes -- if your controller clears DRV_BUSY when recalibrate completes,
you get lucky and the probe is faster. A more complete fix will require making the probe use interrupts, since there is no reliable way to poll.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/isa/fd.c35
-rw-r--r--sys/dev/isa/fdreg.h4
2 files changed, 24 insertions, 15 deletions
diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c
index 3a9b6f3cb0d..34a469c0425 100644
--- a/sys/dev/isa/fd.c
+++ b/sys/dev/isa/fd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fd.c,v 1.46 2003/08/07 16:31:06 agc Exp $ */
+/* $NetBSD: fd.c,v 1.47 2003/09/23 21:36:07 mycroft Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.46 2003/08/07 16:31:06 agc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.47 2003/09/23 21:36:07 mycroft Exp $");
#include "rnd.h"
#include "opt_ddb.h"
@@ -410,8 +410,12 @@ fdprobe(parent, match, aux)
delay(250000);
out_fdc(iot, ioh, NE7CMD_RECAL);
out_fdc(iot, ioh, drive);
- /* wait for recalibrate */
- delay(2000000);
+ /* 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;
+ }
out_fdc(iot, ioh, NE7CMD_SENSEI);
n = fdcresult(fdc);
#ifdef FD_DEBUG
@@ -773,16 +777,19 @@ out_fdc(iot, ioh, x)
bus_space_handle_t ioh;
u_char x;
{
- int i = 100000;
-
- while ((bus_space_read_1(iot, ioh, fdsts) & NE7_DIO) && i-- > 0);
- if (i <= 0)
- return -1;
- while ((bus_space_read_1(iot, ioh, fdsts) & NE7_RQM) == 0 && i-- > 0);
- if (i <= 0)
- return -1;
- bus_space_write_1(iot, ioh, fddata, x);
- return 0;
+ u_char i;
+ u_int j = 100000;
+
+ for (; j; j--) {
+ i = bus_space_read_1(iot, ioh, fdsts) &
+ (NE7_DIO | NE7_RQM);
+ if (i == NE7_RQM) {
+ bus_space_write_1(iot, ioh, fddata, x);
+ return 0;
+ }
+ delay(10);
+ }
+ return -1;
}
int
diff --git a/sys/dev/isa/fdreg.h b/sys/dev/isa/fdreg.h
index dba20c0a8e0..57de935fdfc 100644
--- a/sys/dev/isa/fdreg.h
+++ b/sys/dev/isa/fdreg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: fdreg.h,v 1.3 2003/08/07 16:31:07 agc Exp $ */
+/* $NetBSD: fdreg.h,v 1.4 2003/09/23 21:36:08 mycroft Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -46,6 +46,8 @@
#define FDO_MOEN(n) ((1 << n) * 0x10) /* motor enable */
#define fdsts 2 /* NEC 765 Main Status Register (R) */
+#define FDS_DRVBUSY(n) ((1 << n) * 0x01) /* drive busy */
+
#define fddata 3 /* NEC 765 Data Register (R/W) */
#define fdctl 5 /* Control Register (W) */