diff options
author | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2000-07-20 07:40:34 +0000 |
---|---|---|
committer | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2000-07-20 07:40:34 +0000 |
commit | 4102e47a146ec457668af3567e31fc3831116054 (patch) | |
tree | 36497063240b5984571224da233896a1b54548a6 /sys/dev/ata | |
parent | 3dc6d2b7b2aa9826763759e522e39385dda07520 (diff) |
Fix to ATA detect. Some devices seem to be comatose after reset
(return 0x00 status persistently). Send them identify to wake them up.
Flag value 0x10000 will enable probe messages for a channel/controller.
When UKC supports setting flags, this will be useful debugging
failing IDE detects without kernel recompiles.
Diffstat (limited to 'sys/dev/ata')
-rw-r--r-- | sys/dev/ata/ata.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/sys/dev/ata/ata.c b/sys/dev/ata/ata.c index 43925922e60..0f4eb3adea0 100644 --- a/sys/dev/ata/ata.c +++ b/sys/dev/ata/ata.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ata.c,v 1.5 2000/04/07 11:22:46 niklas Exp $ */ +/* $OpenBSD: ata.c,v 1.6 2000/07/20 07:40:32 csapuntz Exp $ */ /* $NetBSD: ata.c,v 1.9 1999/04/15 09:41:09 bouyer Exp $ */ /* * Copyright (c) 1998 Manuel Bouyer. All rights reserved. @@ -38,9 +38,14 @@ #include <sys/device.h> #include <sys/syslog.h> -#include <dev/ic/wdcreg.h> +#include <machine/bus.h> + #include <dev/ata/atareg.h> #include <dev/ata/atavar.h> +#include <dev/ic/wdcreg.h> +#include <dev/ic/wdcvar.h> + +#define WDCDEBUG #define DEBUG_FUNCS 0x08 #define DEBUG_PROBE 0x10 @@ -67,16 +72,18 @@ ata_get_params(drvp, flags, prms) int i; u_int16_t *p; + int try = 0; WDCDEBUG_PRINT(("ata_get_parms\n"), DEBUG_FUNCS); + again: bzero(tb, sizeof(tb)); bzero(prms, sizeof(struct ataparams)); bzero(&wdc_c, sizeof(struct wdc_command)); if (drvp->drive_flags & DRIVE_ATA) { wdc_c.r_command = WDCC_IDENTIFY; - wdc_c.r_st_bmask = WDCS_DRDY; + wdc_c.r_st_bmask = (try == 0) ? WDCS_DRDY : 0; wdc_c.r_st_pmask = WDCS_DRQ; wdc_c.timeout = 1000; /* 1s */ } else if (drvp->drive_flags & DRIVE_ATAPI) { @@ -100,6 +107,22 @@ ata_get_params(drvp, flags, prms) } if (wdc_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) { + struct channel_softc *chp = drvp->chnl_softc; + + WDCDEBUG_PRINT(("IDENTIFY failed: 0x%x\n", wdc_c.flags) + , DEBUG_PROBE); + + /* Andreas Gunnarsson reports a setup with a flash + disk where the ATA drive remains comatose until + it is sent a command */ + if (try == 0 && (drvp->drive_flags & DRIVE_ATA) && + (wdc_c.flags & AT_TIMEOU) && + !(chp->ch_flags & WDCS_BSY)) { + WDCDEBUG_PRINT(("Retrying IDENTIFY\n"), DEBUG_PROBE); + try++; + goto again; + } + return CMD_ERR; } else { #if BYTE_ORDER == BIG_ENDIAN |