diff options
author | Aaron Campbell <aaron@cvs.openbsd.org> | 2000-09-29 05:28:30 +0000 |
---|---|---|
committer | Aaron Campbell <aaron@cvs.openbsd.org> | 2000-09-29 05:28:30 +0000 |
commit | 7b67dfe22f54691e095c09ee1af7c88660e85007 (patch) | |
tree | 241ae9d02f7da7dfc5ca24e836b91b24a5a54a1d /sys/dev | |
parent | 9fb3a5dae5ef0af29860bc8070b89981c40984f1 (diff) |
- Add support for 3Com 3C555 MiniPCI.
- Clean up configuration flags mess. The MiniPCI adapters share some properties
with the CardBus adapters.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/cardbus/if_xl_cardbus.c | 66 | ||||
-rw-r--r-- | sys/dev/ic/xl.c | 39 | ||||
-rw-r--r-- | sys/dev/ic/xlreg.h | 16 | ||||
-rw-r--r-- | sys/dev/pci/if_xl_pci.c | 68 |
4 files changed, 108 insertions, 81 deletions
diff --git a/sys/dev/cardbus/if_xl_cardbus.c b/sys/dev/cardbus/if_xl_cardbus.c index af381e276a8..1ee5cfa955d 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.8 2000/09/16 21:42:17 aaron Exp $ */ +/* $OpenBSD: if_xl_cardbus.c,v 1.9 2000/09/29 05:28:28 aaron Exp $ */ /* $NetBSD: if_xl_cardbus.c,v 1.13 2000/03/07 00:32:52 mycroft Exp $ */ /* @@ -82,12 +82,16 @@ #define CARDBUS_3C575BTX_FUNCSTAT_PCIREG CARDBUS_BASE2_REG /* means 0x18 */ -int xl_cardbus_match __P((struct device *, void *, void *)); -void xl_cardbus_attach __P((struct device *, struct device *,void *)); -int xl_cardbus_detach __P((struct device *, int)); +int xl_cardbus_match __P((struct device *, void *, void *)); +void xl_cardbus_attach __P((struct device *, struct device *,void *)); +int xl_cardbus_detach __P((struct device *, int)); +void xl_cardbus_intr_ack __P((struct xl_softc *)); -#define XL_CB_BOOMERANG 0x01 -#define XL_CB_CYCLONE 0x02 +#define XL_CARDBUS_BOOMERANG 0x0001 +#define XL_CARDBUS_CYCLONE 0x0002 + +#define XL_CARDBUS_INTR 0x0004 +#define XL_CARDBUS_INTR_ACK 0x8000 struct xl_cardbus_softc { struct xl_softc sc_softc; @@ -118,44 +122,49 @@ const struct xl_cardbus_product { const char *ecp_name; /* device name */ } xl_cardbus_products[] = { { CARDBUS_PRODUCT_3COM_3C575, - 0, + XL_FLAG_PHYOK | XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_8BITROM, CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE, - XL_CB_BOOMERANG, + XL_CARDBUS_BOOMERANG, "3c575-TX Ethernet" }, { CARDBUS_PRODUCT_3COM_3CCFE575BT, - XL_CARDBUS_INVERT_LED_PWR, + XL_FLAG_PHYOK | XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_8BITROM | + XL_FLAG_INVERT_LED_PWR, CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE, - XL_CB_CYCLONE, + XL_CARDBUS_CYCLONE, "3c575B-TX Ethernet" }, { CARDBUS_PRODUCT_3COM_3CCFE575CT, - XL_CARDBUS_INVERT_MII_PWR, + XL_FLAG_PHYOK | XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_8BITROM | + XL_FLAG_INVERT_MII_PWR, CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE, - XL_CB_CYCLONE, + XL_CARDBUS_CYCLONE, "3c575C-TX Ethernet" }, { CARDBUS_PRODUCT_3COM_3CCFEM656, - XL_CARDBUS_INVERT_LED_PWR | XL_CARDBUS_INVERT_MII_PWR, + XL_FLAG_PHYOK | XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_8BITROM | + XL_FLAG_INVERT_LED_PWR | XL_FLAG_INVERT_MII_PWR, CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE, - XL_CB_CYCLONE, + XL_CARDBUS_CYCLONE, "3c656-TX Ethernet" }, { CARDBUS_PRODUCT_3COM_3CCFEM656B, - XL_CARDBUS_INVERT_LED_PWR | XL_CARDBUS_INVERT_MII_PWR, + XL_FLAG_PHYOK | XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_8BITROM | + XL_FLAG_INVERT_LED_PWR | XL_FLAG_INVERT_MII_PWR, CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE, - XL_CB_CYCLONE, + XL_CARDBUS_CYCLONE, "3c656B-TX Ethernet" }, { CARDBUS_PRODUCT_3COM_3CCFEM656C, - XL_CARDBUS_INVERT_MII_PWR, + XL_FLAG_PHYOK | XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_8BITROM | + XL_FLAG_INVERT_MII_PWR, CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE, - XL_CB_CYCLONE, + XL_CARDBUS_CYCLONE, "3c656C-TX Ethernet" }, { 0, @@ -227,9 +236,7 @@ xl_cardbus_attach(parent, self, aux) printf(": 3Com %s", ecp->ecp_name); - sc->xl_bustype = XL_BUS_CARDBUS; - sc->xl_cb_flags = ecp->ecp_flags; - sc->xl_flags = XL_FLAG_EEPROM_OFFSET_30|XL_FLAG_8BITROM; + sc->xl_flags = ecp->ecp_flags; iob = adr; sc->xl_bhandle = ioh; @@ -245,7 +252,7 @@ xl_cardbus_attach(parent, self, aux) command |= ecp->ecp_csr; csc->sc_cardtype = ecp->ecp_cardtype; - if (csc->sc_cardtype == XL_CB_CYCLONE) { + if (csc->sc_cardtype == XL_CARDBUS_CYCLONE) { /* map CardBus function status window */ if (Cardbus_mapreg_map(ct, CARDBUS_BASE2_REG, CARDBUS_MAPREG_TYPE_MEM, 0, &csc->sc_funct, @@ -296,9 +303,11 @@ xl_cardbus_attach(parent, self, aux) } printf(": irq %d", ca->ca_intrline); + sc->intr_ack = xl_cardbus_intr_ack; + xl_attach(sc); - if (csc->sc_cardtype == XL_CB_CYCLONE) + if (csc->sc_cardtype == XL_CARDBUS_CYCLONE) bus_space_write_4(csc->sc_funct, csc->sc_funch, XL_CARDBUS_INTR, XL_CARDBUS_INTR_ACK); @@ -328,7 +337,7 @@ xl_cardbus_detach(self, arg) cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, sc->xl_intrhand); - if (csc->sc_cardtype == XL_CB_CYCLONE) { + if (csc->sc_cardtype == XL_CARDBUS_CYCLONE) { Cardbus_mapreg_unmap(ct, CARDBUS_BASE2_REG, csc->sc_funct, csc->sc_funch, csc->sc_funcsize); } @@ -339,3 +348,12 @@ xl_cardbus_detach(self, arg) return (rv); } +void +xl_cardbus_intr_ack(sc) + struct xl_softc *sc; +{ + struct xl_cardbus_softc *csc = (struct xl_cardbus_softc *)sc; + + bus_space_write_4(csc->sc_funct, csc->sc_funch, XL_CARDBUS_INTR, + XL_CARDBUS_INTR_ACK); +} diff --git a/sys/dev/ic/xl.c b/sys/dev/ic/xl.c index 261cf070b52..cd5c8090395 100644 --- a/sys/dev/ic/xl.c +++ b/sys/dev/ic/xl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xl.c,v 1.9 2000/09/16 21:50:56 aaron Exp $ */ +/* $OpenBSD: xl.c,v 1.10 2000/09/29 05:28:28 aaron Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -54,6 +54,7 @@ * 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 3c555 10/100Mbps/RJ-45 (MiniPCI, Hurricane 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) @@ -446,8 +447,7 @@ xl_miibus_readreg(self, phy, reg) struct xl_softc *sc = (struct xl_softc *)self; struct xl_mii_frame frame; - if (!(sc->xl_flags & XL_FLAG_PHYOK) && - sc->xl_bustype != XL_BUS_CARDBUS && phy != 24) + if (!(sc->xl_flags & XL_FLAG_PHYOK) && phy != 24) return (0); bzero((char *)&frame, sizeof(frame)); @@ -467,8 +467,7 @@ xl_miibus_writereg(self, phy, reg, data) struct xl_softc *sc = (struct xl_softc *)self; struct xl_mii_frame frame; - if (!(sc->xl_flags & XL_FLAG_PHYOK) && - sc->xl_bustype != XL_BUS_CARDBUS && phy != 24) + if (!(sc->xl_flags & XL_FLAG_PHYOK) && phy != 24) return; bzero((char *)&frame, sizeof(frame)); @@ -1459,9 +1458,8 @@ int xl_intr(arg) CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ACK|(status & XL_INTRS)); - if (sc->xl_bustype == XL_BUS_CARDBUS) - bus_space_write_4(sc->xl_funct,sc->xl_funch, - XL_CARDBUS_INTR, XL_CARDBUS_INTR_ACK); + if (sc->intr_ack) + (*sc->intr_ack)(sc); if (status & XL_STAT_UP_COMPLETE) { int curpkts; @@ -2040,14 +2038,11 @@ void xl_init(xsc) */ CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ACK|0xFF); - if (sc->xl_bustype == XL_BUS_CARDBUS) - bus_space_write_4(sc->xl_funct, sc->xl_funch, XL_CARDBUS_INTR, - XL_CARDBUS_INTR_ACK); + if (sc->intr_ack) + (*sc->intr_ack)(sc); 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)); @@ -2374,12 +2369,12 @@ 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 0 if (sc->xl_bustype == XL_BUS_CARDBUS) bus_space_write_4(sc->xl_funct, sc->xl_funch, XL_CARDBUS_INTR, XL_CARDBUS_INTR_ACK); +#endif /* Stop the stats updater. */ untimeout(xl_stats_update, sc); @@ -2417,16 +2412,16 @@ xl_attach(sc) printf(" address %s\n", ether_sprintf(sc->arpcom.ac_enaddr)); - if (sc->xl_bustype == XL_BUS_CARDBUS) { + if (sc->xl_flags & (XL_FLAG_INVERT_LED_PWR|XL_FLAG_INVERT_MII_PWR)) { u_int16_t n; XL_SEL_WIN(2); n = CSR_READ_2(sc, 12); - if (sc->xl_cb_flags & XL_CARDBUS_INVERT_LED_PWR) + if (sc->xl_flags & XL_FLAG_INVERT_LED_PWR) n |= 0x0010; - if (sc->xl_cb_flags & XL_CARDBUS_INVERT_MII_PWR) + if (sc->xl_flags & XL_FLAG_INVERT_MII_PWR) n |= 0x4000; CSR_WRITE_2(sc, 12, n); @@ -2492,11 +2487,9 @@ xl_attach(sc) xl_mediacheck(sc); - if (sc->xl_bustype == XL_BUS_CARDBUS) { - if (sc->xl_cb_flags & XL_CARDBUS_INVERT_MII_PWR) { - XL_SEL_WIN(2); - CSR_WRITE_2(sc, 12, 0x4000 | CSR_READ_2(sc, 12)); - } + if (sc->xl_flags & XL_FLAG_INVERT_MII_PWR) { + XL_SEL_WIN(2); + CSR_WRITE_2(sc, 12, 0x4000 | CSR_READ_2(sc, 12)); } DELAY(100000); diff --git a/sys/dev/ic/xlreg.h b/sys/dev/ic/xlreg.h index 39dcc0bdbbb..822a3fcb6b3 100644 --- a/sys/dev/ic/xlreg.h +++ b/sys/dev/ic/xlreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xlreg.h,v 1.5 2000/09/16 21:42:16 aaron Exp $ */ +/* $OpenBSD: xlreg.h,v 1.6 2000/09/29 05:28:29 aaron Exp $ */ /* * Copyright (c) 1997, 1998 @@ -34,9 +34,6 @@ * $FreeBSD: if_xlreg.h,v 1.26 2000/08/28 20:40:03 wpaul Exp $ */ -#define XL_BUS_PCI 0x01 -#define XL_BUS_CARDBUS 0x02 - #define XL_EE_READ 0x0080 /* read, 5 bit address */ #define XL_EE_WRITE 0x0040 /* write, 5 bit address */ #define XL_EE_ERASE 0x00c0 /* erase, 5 bit address */ @@ -558,6 +555,8 @@ struct xl_mii_frame { #define XL_FLAG_EEPROM_OFFSET_30 0x0004 #define XL_FLAG_WEIRDRESET 0x0008 #define XL_FLAG_8BITROM 0x0010 +#define XL_FLAG_INVERT_LED_PWR 0x0020 +#define XL_FLAG_INVERT_MII_PWR 0x0040 struct xl_softc { struct device sc_dev; /* generic device structure */ @@ -578,15 +577,11 @@ struct xl_softc { u_int16_t xl_caps; u_int8_t xl_stats_no_timeout; u_int16_t xl_tx_thresh; - u_int8_t xl_bustype; /* PCI or CardBus? */ - int xl_cb_flags; /* CardBus flags */ int xl_if_flags; 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; }; @@ -645,6 +640,7 @@ struct xl_stats { * 3Com PCI chip device IDs. */ #define TC_DEVICEID_TORNADO_HOMECONNECT 0x4500 +#define TC_DEVICEID_HURRICANE_555 0x5055 #define TC_DEVICEID_HURRICANE_556 0x6055 #define TC_DEVICEID_HURRICANE_556B 0x6056 #define TC_DEVICEID_BOOMERANG_10BT 0x9000 @@ -681,9 +677,6 @@ struct xl_stats { #define XL_CARDBUS_INTR 0x0004 #define XL_CARDBUS_INTR_ACK 0x8000 -#define XL_CARDBUS_INVERT_LED_PWR 0x0001 -#define XL_CARDBUS_INVERT_MII_PWR 0x0002 - /* * PCI low memory base and low I/O base register, and * other PCI registers. Note: some are only available on @@ -699,7 +692,6 @@ 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 bce9f060050..bb2fdb66aec 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.4 2000/09/16 21:42:17 aaron Exp $ */ +/* $OpenBSD: if_xl_pci.c,v 1.5 2000/09/29 05:28:29 aaron Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -86,10 +86,20 @@ */ #define XL_USEIOSPACE +#define XL_PCI_FUNCMEM 0x0018 +#define XL_PCI_INTRACK 0x8000 + #include <dev/ic/xlreg.h> -int xl_pci_match __P((struct device *, void *, void *)); -void xl_pci_attach __P((struct device *, struct device *, void *)); +struct xl_pci_softc { + struct xl_softc sc_xl; + pci_chipset_tag_t sc_chiptag; + pcitag_t sc_pcitag; +}; + +int xl_pci_match __P((struct device *, void *, void *)); +void xl_pci_attach __P((struct device *, struct device *, void *)); +void xl_pci_intr_ack __P((struct xl_softc *)); int xl_pci_match(parent, match, aux) @@ -120,6 +130,7 @@ 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_3C555: case PCI_PRODUCT_3COM_3C556: case PCI_PRODUCT_3COM_3C556B: return (1); @@ -135,6 +146,7 @@ xl_pci_attach(parent, self, aux) { struct xl_softc *sc = (struct xl_softc *)self; struct pci_attach_args *pa = aux; + struct xl_pci_softc *psc = (void *)self; pci_chipset_tag_t pc = pa->pa_pc; pci_intr_handle_t ih; const char *intrstr = NULL; @@ -144,17 +156,26 @@ xl_pci_attach(parent, self, aux) sc->xl_unit = sc->sc_dev.dv_unit; - 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) + + /* set flags required for 3Com MiniPCI adapters */ + switch (PCI_PRODUCT(pa->pa_id)) { + case TC_DEVICEID_HURRICANE_555: + sc->xl_flags |= XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_8BITROM; + break; + case TC_DEVICEID_HURRICANE_556: 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; - + break; + case TC_DEVICEID_HURRICANE_556B: + sc->xl_flags |= XL_FLAG_FUNCREG | XL_FLAG_PHYOK | + XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_WEIRDRESET; + break; + default: + break; + } + /* * If this is a 3c905B, we have to check one extra thing. * The 905B supports power management and may be placed in @@ -244,17 +265,9 @@ xl_pci_attach(parent, self, aux) #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; + sc->intr_ack = xl_pci_intr_ack; + psc->sc_chiptag = pa->pa_pc; + psc->sc_pcitag = pa->pa_tag; } /* @@ -280,6 +293,17 @@ xl_pci_attach(parent, self, aux) xl_attach(sc); } + +void +xl_pci_intr_ack(sc) + struct xl_softc *sc; +{ + struct xl_pci_softc *psc = (struct xl_pci_softc *)sc; + + pci_conf_write(psc->sc_chiptag, psc->sc_pcitag, XL_PCI_FUNCMEM + 4, + XL_PCI_INTRACK); +} + struct cfattach xl_pci_ca = { - sizeof(struct xl_softc), xl_pci_match, xl_pci_attach, + sizeof(struct xl_pci_softc), xl_pci_match, xl_pci_attach, }; |