diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2007-02-17 05:39:16 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2007-02-17 05:39:16 +0000 |
commit | c8813f85dbdebc8539f5ce599ee1b77849a2a60f (patch) | |
tree | 21127689852b1ceca9e7f86e29301b36f031cbde /sys/dev | |
parent | 5f034b83d155298e36231df19daeae6396bf97ba (diff) |
only reset the controller if it is already enabled.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/ahci.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/dev/pci/ahci.c b/sys/dev/pci/ahci.c index d345b3a57d3..48735c2a1db 100644 --- a/sys/dev/pci/ahci.c +++ b/sys/dev/pci/ahci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ahci.c,v 1.40 2007/02/14 04:36:53 dlg Exp $ */ +/* $OpenBSD: ahci.c,v 1.41 2007/02/17 05:39:15 dlg Exp $ */ /* * Copyright (c) 2006 David Gwynne <dlg@openbsd.org> @@ -520,12 +520,17 @@ ahci_init(struct ahci_softc *sc) u_int32_t reg; const char *revision; - /* reset the controller */ - ahci_write(sc, AHCI_REG_GHC, AHCI_REG_GHC_HR); - if (ahci_wait_ne(sc, AHCI_REG_GHC, AHCI_REG_GHC_HR, - AHCI_REG_GHC_HR) != 0) { - printf(": unable to reset controller\n"); - return (1); + DPRINTF(AHCI_D_VERBOSE, " GHC 0x%b", ahci_read(sc, AHCI_REG_GHC), + AHCI_FMT_GHC); + + if (ISSET(AHCI_REG_GHC_AE, ahci_read(sc, AHCI_REG_GHC))) { + /* reset the controller */ + ahci_write(sc, AHCI_REG_GHC, AHCI_REG_GHC_HR); + if (ahci_wait_ne(sc, AHCI_REG_GHC, AHCI_REG_GHC_HR, + AHCI_REG_GHC_HR) != 0) { + printf(": unable to reset controller\n"); + return (1); + } } /* enable ahci */ |