If the SET_FEATURE for piomode is rejected, fallback to mode 0 instead of

reporting an error.
This fixes the "piomode error (0x4)" problem with some ATAPI ZIP drives
reported on port-i386.
This commit is contained in:
bouyer 2000-08-03 23:14:31 +00:00
parent 75713daa92
commit 8464bde7e8
1 changed files with 18 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: atapi_wdc.c,v 1.37 2000/06/28 16:39:28 mrg Exp $ */
/* $NetBSD: atapi_wdc.c,v 1.38 2000/08/03 23:14:31 bouyer Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer.
@ -833,13 +833,12 @@ again:
WDSD_IBM | (xfer->drive << 4));
switch (drvp->state) {
case PIOMODE:
piomode:
/* Don't try to set mode if controller can't be adjusted */
if ((chp->wdc->cap & WDC_CAPABILITY_MODE) == 0)
goto ready;
/* Also don't try if the drive didn't report its mode */
if ((drvp->drive_flags & DRIVE_MODE) == 0)
goto ready;;
goto ready;
wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
0x08 | drvp->PIO_mode, WDSF_SET_MODE);
drvp->state = PIOMODE_WAIT;
@ -851,12 +850,23 @@ piomode:
if (chp->wdc->cap & WDC_CAPABILITY_IRQACK)
chp->wdc->irqack(chp);
if (chp->ch_status & WDCS_ERR) {
if (drvp->PIO_mode < 3) {
drvp->PIO_mode = 3;
goto piomode;
} else {
goto error;
if (chp->ch_error == WDCE_ABRT) {
/*
* some ATAPI drives rejects pio settings.
* all we can do here is fall back to PIO 0
*/
drvp->drive_flags &= ~DRIVE_MODE;
drvp->drive_flags &= ~(DRIVE_DMA|DRIVE_UDMA);
drvp->PIO_mode = 0;
drvp->DMA_mode = 0;
printf("%s:%d:%d: pio setting rejected, "
"falling back to PIO mode 0\n",
chp->wdc->sc_dev.dv_xname,
chp->channel, xfer->drive);
chp->wdc->set_modes(chp);
goto ready;
}
goto error;
}
/* fall through */