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.
This commit is contained in:
parent
72b77eb9e9
commit
df8e298ddb
|
@ -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;
|
||||
u_char i;
|
||||
u_int j = 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;
|
||||
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
|
||||
|
|
|
@ -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) */
|
||||
|
|
Loading…
Reference in New Issue