diff options
-rw-r--r-- | sys/dev/cardbus/if_xl_cardbus.c | 3 | ||||
-rw-r--r-- | sys/dev/ic/xl.c | 49 | ||||
-rw-r--r-- | sys/dev/ic/xlreg.h | 16 | ||||
-rw-r--r-- | sys/dev/pci/if_xl_pci.c | 26 |
4 files changed, 76 insertions, 18 deletions
diff --git a/sys/dev/cardbus/if_xl_cardbus.c b/sys/dev/cardbus/if_xl_cardbus.c index f4ca9841b38..af381e276a8 100644 --- a/sys/dev/cardbus/if_xl_cardbus.c +++ b/sys/dev/cardbus/if_xl_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xl_cardbus.c,v 1.7 2000/09/16 21:11:16 aaron Exp $ */ +/* $OpenBSD: if_xl_cardbus.c,v 1.8 2000/09/16 21:42:17 aaron Exp $ */ /* $NetBSD: if_xl_cardbus.c,v 1.13 2000/03/07 00:32:52 mycroft Exp $ */ /* @@ -229,6 +229,7 @@ xl_cardbus_attach(parent, self, aux) sc->xl_bustype = XL_BUS_CARDBUS; sc->xl_cb_flags = ecp->ecp_flags; + sc->xl_flags = XL_FLAG_EEPROM_OFFSET_30|XL_FLAG_8BITROM; iob = adr; sc->xl_bhandle = ioh; diff --git a/sys/dev/ic/xl.c b/sys/dev/ic/xl.c index 8ef84f3d7d9..e8f840e716a 100644 --- a/sys/dev/ic/xl.c +++ b/sys/dev/ic/xl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xl.c,v 1.6 2000/09/05 18:18:49 aaron Exp $ */ +/* $OpenBSD: xl.c,v 1.7 2000/09/16 21:42:16 aaron Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -31,7 +31,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: if_xl.c,v 1.72 2000/01/09 21:12:59 wpaul Exp $ + * $FreeBSD: if_xl.c,v 1.77 2000/08/28 20:40:03 wpaul Exp $ */ /* @@ -54,6 +54,8 @@ * 3Com 3c900-FL/FX 10/100Mbps/Fiber-optic * 3Com 3c905C-TX 10/100Mbps/RJ-45 (Tornado ASIC) * 3Com 3c450-TX 10/100Mbps/RJ-45 (Tornado ASIC) + * 3Com 3c556 10/100Mbps/RJ-45 (MiniPCI, Hurricane ASIC) + * 3Com 3c556B 10/100Mbps/RJ-45 (MiniPCI, Hurricane ASIC) * 3Com 3c980-TX 10/100Mbps server adapter (Hurricane ASIC) * 3Com 3c980C-TX 10/100Mbps server adapter (Tornado ASIC) * 3Com 3C575TX 10/100Mbps LAN CardBus PC Card @@ -443,7 +445,8 @@ xl_miibus_readreg(self, phy, reg) struct xl_softc *sc = (struct xl_softc *)self; struct xl_mii_frame frame; - if (sc->xl_bustype != XL_BUS_CARDBUS && phy != 24) + if (!(sc->xl_flags & XL_FLAG_PHYOK) && + sc->xl_bustype != XL_BUS_CARDBUS && phy != 24) return (0); bzero((char *)&frame, sizeof(frame)); @@ -463,7 +466,8 @@ xl_miibus_writereg(self, phy, reg, data) struct xl_softc *sc = (struct xl_softc *)self; struct xl_mii_frame frame; - if (sc->xl_bustype != XL_BUS_CARDBUS && phy != 24) + if (!(sc->xl_flags & XL_FLAG_PHYOK) && + sc->xl_bustype != XL_BUS_CARDBUS && phy != 24) return; bzero((char *)&frame, sizeof(frame)); @@ -528,21 +532,25 @@ int xl_read_eeprom(sc, dest, off, cnt, swap) { int err = 0, i; u_int16_t word = 0, *ptr; - +#define EEPROM_5BIT_OFFSET(A) ((((A) << 2) & 0x7F00) | ((A) & 0x003F)) + /* WARNING! DANGER! + * It's easy to accidentally overwrite the rom content! + * Note: the 3c575 uses 8bit EEPROM offsets. + */ XL_SEL_WIN(0); if (xl_eeprom_wait(sc)) return(1); + if (sc->xl_flags & XL_FLAG_EEPROM_OFFSET_30) + off += 0x30; + for (i = 0; i < cnt; i++) { - switch (sc->xl_bustype) { - case XL_BUS_PCI: - CSR_WRITE_2(sc, XL_W0_EE_CMD, XL_EE_READ | (off + i)); - break; - case XL_BUS_CARDBUS: - CSR_WRITE_2(sc, XL_W0_EE_CMD, 0x230 + (off + i)); - break; - } + if (sc->xl_flags & XL_FLAG_8BITROM) + CSR_WRITE_2(sc, XL_W0_EE_CMD, (2<<8) | (off + i )); + else + CSR_WRITE_2(sc, XL_W0_EE_CMD, + XL_EE_READ | EEPROM_5BIT_OFFSET(off + i)); err = xl_eeprom_wait(sc); if (err) break; @@ -840,7 +848,8 @@ void xl_reset(sc, hard) XL_SEL_WIN(0); if (hard) - CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RESET); + CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RESET | + ((sc->xl_flags & XL_FLAG_WEIRDRESET)?0xFF:0)); else CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RESET | 0x0010); xl_wait(sc); @@ -859,6 +868,12 @@ void xl_reset(sc, hard) CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_TX_RESET); xl_wait(sc); + if (sc->xl_flags & XL_FLAG_WEIRDRESET) { + XL_SEL_WIN(2); + CSR_WRITE_2(sc, XL_W2_RESET_OPTIONS, CSR_READ_2(sc, + XL_W2_RESET_OPTIONS) | 0x4010); + } + /* Wait a little while for the chip to get its brains in order. */ DELAY(100000); return; @@ -956,6 +971,8 @@ void xl_choose_xcvr(sc, verbose) printf("xl%d: guessing 10baseFL\n", sc->xl_unit); break; case TC_DEVICEID_BOOMERANG_10_100BT: /* 3c905-TX */ + case TC_DEVICEID_HURRICANE_556: /* 3c556 */ + case TC_DEVICEID_HURRICANE_556B: /* 3c556B */ sc->xl_media = XL_MEDIAOPT_MII; sc->xl_xcvr = XL_XCVR_MII; if (verbose) @@ -2028,6 +2045,8 @@ void xl_init(xsc) CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_STAT_ENB|XL_INTRS); CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ENB|XL_INTRS); + if (sc->xl_flags & XL_FLAG_FUNCREG) + bus_space_write_4(sc->xl_ftag, sc->xl_fhandle, 4, 0x8000); /* Set the RX early threshold */ CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_THRESH|(XL_PACKET_SIZE >>2)); @@ -2354,6 +2373,8 @@ void xl_stop(sc) CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ACK|XL_STAT_INTLATCH); CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_STAT_ENB|0); CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ENB|0); + if (sc->xl_flags & XL_FLAG_FUNCREG) + bus_space_write_4(sc->xl_ftag, sc->xl_fhandle, 4, 0x8000); if (sc->xl_bustype == XL_BUS_CARDBUS) bus_space_write_4(sc->xl_funct, sc->xl_funch, XL_CARDBUS_INTR, diff --git a/sys/dev/ic/xlreg.h b/sys/dev/ic/xlreg.h index b10a7b6ad21..39dcc0bdbbb 100644 --- a/sys/dev/ic/xlreg.h +++ b/sys/dev/ic/xlreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xlreg.h,v 1.4 2000/09/05 18:18:50 aaron Exp $ */ +/* $OpenBSD: xlreg.h,v 1.5 2000/09/16 21:42:16 aaron Exp $ */ /* * Copyright (c) 1997, 1998 @@ -31,7 +31,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: if_xlreg.h,v 1.17 1999/05/30 18:09:17 wpaul Exp $ + * $FreeBSD: if_xlreg.h,v 1.26 2000/08/28 20:40:03 wpaul Exp $ */ #define XL_BUS_PCI 0x01 @@ -553,6 +553,12 @@ struct xl_mii_frame { #define XL_TYPE_905B 1 #define XL_TYPE_90X 2 +#define XL_FLAG_FUNCREG 0x0001 +#define XL_FLAG_PHYOK 0x0002 +#define XL_FLAG_EEPROM_OFFSET_30 0x0004 +#define XL_FLAG_WEIRDRESET 0x0008 +#define XL_FLAG_8BITROM 0x0010 + struct xl_softc { struct device sc_dev; /* generic device structure */ void * xl_intrhand; /* interrupt handler cookie */ @@ -578,6 +584,9 @@ struct xl_softc { caddr_t xl_ldata_ptr; struct xl_list_data *xl_ldata; struct xl_chain_data xl_cdata; + int xl_flags; + bus_space_handle_t xl_fhandle; + bus_space_tag_t xl_ftag; void (*intr_ack) __P((struct xl_softc *)); void * sc_sdhook; }; @@ -636,6 +645,8 @@ struct xl_stats { * 3Com PCI chip device IDs. */ #define TC_DEVICEID_TORNADO_HOMECONNECT 0x4500 +#define TC_DEVICEID_HURRICANE_556 0x6055 +#define TC_DEVICEID_HURRICANE_556B 0x6056 #define TC_DEVICEID_BOOMERANG_10BT 0x9000 #define TC_DEVICEID_BOOMERANG_10BT_COMBO 0x9001 #define TC_DEVICEID_BOOMERANG_10_100BT 0x9050 @@ -688,6 +699,7 @@ struct xl_stats { #define XL_PCI_HEADER_TYPE 0x0E #define XL_PCI_LOIO 0x10 #define XL_PCI_LOMEM 0x14 +#define XL_PCI_FUNCMEM 0x18 #define XL_PCI_BIOSROM 0x30 #define XL_PCI_INTLINE 0x3C #define XL_PCI_INTPIN 0x3D diff --git a/sys/dev/pci/if_xl_pci.c b/sys/dev/pci/if_xl_pci.c index af5bc506f23..bce9f060050 100644 --- a/sys/dev/pci/if_xl_pci.c +++ b/sys/dev/pci/if_xl_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xl_pci.c,v 1.3 2000/07/01 03:19:15 aaron Exp $ */ +/* $OpenBSD: if_xl_pci.c,v 1.4 2000/09/16 21:42:17 aaron Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -120,6 +120,8 @@ xl_pci_match(parent, match, aux) case PCI_PRODUCT_3COM_3C980CTX: case PCI_PRODUCT_3COM_3C905CTX: case PCI_PRODUCT_3COM_3C450: + case PCI_PRODUCT_3COM_3C556: + case PCI_PRODUCT_3COM_3C556B: return (1); } @@ -145,6 +147,14 @@ xl_pci_attach(parent, self, aux) sc->xl_bustype = XL_BUS_PCI; sc->xl_cb_flags = 0; + sc->xl_flags = 0; + if (PCI_PRODUCT(pa->pa_id) == TC_DEVICEID_HURRICANE_556 || + PCI_PRODUCT(pa->pa_id) == TC_DEVICEID_HURRICANE_556B) + sc->xl_flags |= XL_FLAG_FUNCREG | XL_FLAG_PHYOK | + XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_WEIRDRESET; + if (PCI_PRODUCT(pa->pa_id) == TC_DEVICEID_HURRICANE_556) + sc->xl_flags |= XL_FLAG_8BITROM; + /* * If this is a 3c905B, we have to check one extra thing. * The 905B supports power management and may be placed in @@ -233,6 +243,20 @@ xl_pci_attach(parent, self, aux) sc->xl_btag = pa->pa_memt; #endif + if (sc->xl_flags & XL_FLAG_FUNCREG) { + if (pci_mem_find(pc, pa->pa_tag, XL_PCI_FUNCMEM, &iobase, + &iosize, NULL)) { + printf(": can't find mem space\n"); + return; + } + if (bus_space_map(pa->pa_memt, iobase, iosize, 0, + &sc->xl_fhandle)) { + printf(": can't map mem space\n"); + return; + } + sc->xl_ftag = pa->pa_memt; + } + /* * Allocate our interrupt. */ |