From 6d92de35c9439fc3df4bddceba4ad78a4c21cd6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Schmidt?= Date: Wed, 1 Oct 2003 09:58:19 +0000 Subject: [PATCH] Fix the problem with accessing certain FLASH devices. The problem was that accessing the status reg could occour too fast, confusing the logic in the flash part. Could not have been located without: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HW donated by: Jonas Bülow --- sys/dev/ata/ata-lowlevel.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/dev/ata/ata-lowlevel.c b/sys/dev/ata/ata-lowlevel.c index 2c0809d1d9d..2a2b6ac34dc 100644 --- a/sys/dev/ata/ata-lowlevel.c +++ b/sys/dev/ata/ata-lowlevel.c @@ -644,11 +644,13 @@ ata_reset(struct ata_channel *ch) static int ata_wait(struct ata_device *atadev, u_int8_t mask) { - int timeout = 0; u_int8_t status; + int timeout = 0; DELAY(1); - while (timeout < 5000000) { /* timeout 5 secs */ + + /* wait 5 seconds for device to get !BUSY */ + while (timeout < 5000000) { status = ATA_IDX_INB(atadev->channel, ATA_STATUS); /* if drive fails status, reselect the drive just to be sure */ @@ -678,8 +680,10 @@ ata_wait(struct ata_device *atadev, u_int8_t mask) return -1; if (!mask) return (status & ATA_S_ERROR); + + DELAY(1); - /* wait 50 msec for bits wanted. */ + /* wait 50 msec for bits wanted */ timeout = 5000; while (timeout--) { status = ATA_IDX_INB(atadev->channel, ATA_STATUS);