diff options
author | mjacob <mjacob@FreeBSD.org> | 2002-08-23 06:56:08 +0000 |
---|---|---|
committer | mjacob <mjacob@FreeBSD.org> | 2002-08-23 06:56:08 +0000 |
commit | f862e4d733eb527d5a30eee5193e963fabf5bedb (patch) | |
tree | e3efa9e409859ec5778208451e71f6b3956309ae /sys/dev/mpt | |
parent | 00febb565fe89c9f65a3565d5638b1e8995ad225 (diff) | |
download | FreeBSD-src-f862e4d733eb527d5a30eee5193e963fabf5bedb.zip FreeBSD-src-f862e4d733eb527d5a30eee5193e963fabf5bedb.tar.gz |
Pick a cleaner method (and put in a separate function) for finding
the peer device on a dual board.
Diffstat (limited to 'sys/dev/mpt')
-rw-r--r-- | sys/dev/mpt/mpt_pci.c | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/sys/dev/mpt/mpt_pci.c b/sys/dev/mpt/mpt_pci.c index 6012eb4..3f1d48a 100644 --- a/sys/dev/mpt/mpt_pci.c +++ b/sys/dev/mpt/mpt_pci.c @@ -65,6 +65,10 @@ #define PCI_PRODUCT_LSI_1030 0x0030 #endif +#ifndef PCIM_CMD_SERRESPEN +#define PCIM_CMD_SERRESPEN 0x0100 +#endif + #define MEM_MAP_REG 0x14 @@ -166,7 +170,6 @@ mpt_set_options(mpt_softc_t *mpt) } } - cmd = pci_read_config(dev, PCIR_COMMAND, 2); } #else static void @@ -188,6 +191,38 @@ mpt_set_options(mpt_softc_t *mpt) #endif +static void +mpt_link_peer(mpt_softc_t *mpt) +{ + mpt_softc_t *mpt2; + + if (mpt->unit == 0) { + return; + } + + /* + * XXX: depends on probe order + */ + mpt2 = (mpt_softc_t *) devclass_get_softc(mpt_devclass, mpt->unit-1); + + if (mpt2 == NULL) { + return; + } + if (pci_get_vendor(mpt2->dev) != pci_get_vendor(mpt->dev)) { + return; + } + if (pci_get_device(mpt2->dev) != pci_get_device(mpt->dev)) { + return; + } + mpt->mpt2 = mpt2; + mpt2->mpt2 = mpt; + if (mpt->verbose) { + device_printf(mpt->dev, "linking with peer (mpt%d)\n", + device_get_unit(mpt2->dev)); + } +} + + static int mpt_attach(device_t dev) { @@ -238,26 +273,13 @@ mpt_attach(device_t dev) pci_write_config(dev, PCIR_BIOS, data, 4); - /* Is this part a dual? */ - if ((pci_get_device(dev) & ~1) == PCI_PRODUCT_LSI_FC929) { - /* Yes; is the previous device the counterpart? */ - if (mpt->unit) { - mpt->mpt2 = (mpt_softc_t *) - devclass_get_softc(mpt_devclass, mpt->unit-1); - - if ((mpt->mpt2->mpt2 == NULL) - && (pci_get_vendor(mpt->mpt2->dev) == PCI_VENDOR_LSI) - && ((pci_get_device(mpt->mpt2->dev) & ~1) == PCI_PRODUCT_LSI_FC929) ) { - /* Yes */ - mpt->mpt2->mpt2 = mpt; - if (mpt->verbose) { - device_printf(dev, "Detected dual\n"); - } - } else { - /* Nope */ - mpt->mpt2 = NULL; - } - } + /* + * Is this part a dual? + * If so, link with our partner (around yet) + */ + if ((pci_get_device(dev) & ~1) == PCI_PRODUCT_LSI_FC929 || + (pci_get_device(dev) & ~1) == PCI_PRODUCT_LSI_1030) { + mpt_link_peer(mpt); } /* Set up the memory regions */ |