diff options
author | Alexander Yurchenko <grange@cvs.openbsd.org> | 2003-02-13 15:30:22 +0000 |
---|---|---|
committer | Alexander Yurchenko <grange@cvs.openbsd.org> | 2003-02-13 15:30:22 +0000 |
commit | e9dcaa1e5d58eda63d3c67529f0de5e8b1265325 (patch) | |
tree | 2ed762908a5efe94f97ca01e9d042480b000a411 | |
parent | 48f646adaacd6c7b2c7cef7e75e5e55d8d34002a (diff) |
Add cable detection for AMD chips, directly from AMD specs.
Tested by todd@; ok gluk@
-rw-r--r-- | sys/dev/pci/pciide.c | 16 | ||||
-rw-r--r-- | sys/dev/pci/pciide_amd_reg.h | 3 |
2 files changed, 17 insertions, 2 deletions
diff --git a/sys/dev/pci/pciide.c b/sys/dev/pci/pciide.c index 2be496fc8ff..632eef517d7 100644 --- a/sys/dev/pci/pciide.c +++ b/sys/dev/pci/pciide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pciide.c,v 1.111 2003/01/30 07:50:17 henric Exp $ */ +/* $OpenBSD: pciide.c,v 1.112 2003/02/13 15:30:21 grange Exp $ */ /* $NetBSD: pciide.c,v 1.127 2001/08/03 01:31:08 tsutsui Exp $ */ /* @@ -2135,6 +2135,7 @@ amd756_setup_channel(chp) struct ata_drive_datas *drvp; struct pciide_channel *cp = (struct pciide_channel*)chp; struct pciide_softc *sc = (struct pciide_softc *)cp->wdc_channel.wdc; + pcireg_t chanenable; #ifndef PCIIDE_AMD756_ENABLEDMA int product = PCI_PRODUCT( pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_ID_REG)); @@ -2147,6 +2148,8 @@ amd756_setup_channel(chp) udmatim_reg = pci_conf_read(sc->sc_pc, sc->sc_tag, AMD756_UDMA); datatim_reg &= ~AMD756_DATATIM_MASK(chp->channel); udmatim_reg &= ~AMD756_UDMA_MASK(chp->channel); + chanenable = pci_conf_read(sc->sc_pc, sc->sc_tag, + AMD756_CHANSTATUS_EN); /* setup DMA if needed */ pciide_channel_dma_setup(cp); @@ -2166,6 +2169,17 @@ amd756_setup_channel(chp) (drvp->drive_flags & DRIVE_UDMA)) { /* use Ultra/DMA */ drvp->drive_flags &= ~DRIVE_DMA; + + /* Check cable */ + if ((chanenable & AMD756_CABLE(chp->channel, + drive)) == 0 && drvp->UDMA_mode > 2) { + WDCDEBUG_PRINT(("%s(%s:%d:%d): 80-wire " + "cable not detected\n", drvp->drive_name, + sc->sc_wdcdev.sc_dev.dv_xname, + chp->channel, drive), DEBUG_PROBE); + drvp->UDMA_mode = 2; + } + udmatim_reg |= AMD756_UDMA_EN(chp->channel, drive) | AMD756_UDMA_EN_MTH(chp->channel, drive) | AMD756_UDMA_TIME(chp->channel, drive, diff --git a/sys/dev/pci/pciide_amd_reg.h b/sys/dev/pci/pciide_amd_reg.h index ca94a951592..94f9bbdad8b 100644 --- a/sys/dev/pci/pciide_amd_reg.h +++ b/sys/dev/pci/pciide_amd_reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pciide_amd_reg.h,v 1.4 2001/07/19 18:16:22 csapuntz Exp $ */ +/* $OpenBSD: pciide_amd_reg.h,v 1.5 2003/02/13 15:30:21 grange Exp $ */ /* $NetBSD: pciide_amd_reg.h,v 1.2 2000/07/06 15:08:11 bouyer Exp $ */ /* @@ -57,6 +57,7 @@ /* Channel enable */ #define AMD756_CHANSTATUS_EN 0x40 #define AMD756_CHAN_EN(chan) (0x01 << (1 - (chan))) +#define AMD756_CABLE(chan, drive) (0x00010000 << ((chan) * 2 + (drive))) /* Data port timing controls */ #define AMD756_DATATIM 0x48 |