--- ata-lowlevel.c.orig Sat Sep 20 17:38:33 2003 +++ ata-lowlevel.c Thu Sep 25 23:29:21 2003 @@ -486,29 +486,43 @@ static void ata_reset(struct ata_channel *ch) { - u_int8_t err, lsb, msb, ostat0, ostat1; + u_int8_t err, lsb, msb; + u_int8_t ostat0 = 0, ostat1 = 0; u_int8_t stat0 = 0, stat1 = 0; int mask = 0, timeout; /* do we have any signs of ATA/ATAPI HW being present ? */ - ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_MASTER); - DELAY(10); - ostat0 = ATA_IDX_INB(ch, ATA_STATUS); - if ((ostat0 & 0xf8) != 0xf8 && ostat0 != 0xa5) { - stat0 = ATA_S_BUSY; - mask |= 0x01; - } - - ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); - DELAY(10); - ostat1 = ATA_IDX_INB(ch, ATA_STATUS); - - /* in some setups we dont want to test for a slave */ - if (!(ch->flags & ATA_NO_SLAVE)) { - if ((ostat1 & 0xf8) != 0xf8 && ostat1 != 0xa5) { - stat1 = ATA_S_BUSY; - mask |= 0x02; - } + if (ch->devices == 0) { + ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_MASTER); + DELAY(10); + ostat0 = ATA_IDX_INB(ch, ATA_STATUS); + if ((ostat0 & 0xf8) != 0xf8 && ostat0 != 0xa5) { + stat0 = ATA_S_BUSY; + mask |= 0x01; + } + + ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); + DELAY(10); + ostat1 = ATA_IDX_INB(ch, ATA_STATUS); + + /* in some setups we dont want to test for a slave */ + if (!(ch->flags & ATA_NO_SLAVE)) { + if ((ostat1 & 0xf8) != 0xf8 && ostat1 != 0xa5) { + stat1 = ATA_S_BUSY; + mask |= 0x02; + } + } + } else { + if (ch->devices & (ATA_ATA_MASTER | ATA_ATAPI_MASTER)) { + ostat0 = ATA_S_BUSY; + stat0 = ATA_S_BUSY; + mask |= 0x01; + } + if (ch->devices & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE)) { + ostat1 = ATA_S_BUSY; + stat1 = ATA_S_BUSY; + mask |= 0x02; + } } /* if nothing showed up no need to get any further */ @@ -604,7 +618,7 @@ "reset tp2 mask=%02x stat0=%02x stat1=%02x devices=0x%b\n", mask, stat0, stat1, ch->devices, "\20\4ATAPI_SLAVE\3ATAPI_MASTER\2ATA_SLAVE\1ATA_MASTER"); -#if 0 +#if 1 if (!mask) return;