summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2000-07-01 03:19:16 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2000-07-01 03:19:16 +0000
commit55d7285dc37b52c197b83bd8c4a938c486012a9b (patch)
treebd04003d80381d5457daaedb47d4a717e9b63a64 /sys/dev
parente43d235e99fc4d0e97286cd5e6042cead013b980 (diff)
- Make the 3CCFE575BT work.
- Add support for the 3CCFEM656C. - Lots of code cleanup.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/cardbus/if_xl_cardbus.c118
-rw-r--r--sys/dev/ic/xl.c39
-rw-r--r--sys/dev/ic/xlreg.h34
-rw-r--r--sys/dev/pci/if_xl_pci.c5
4 files changed, 79 insertions, 117 deletions
diff --git a/sys/dev/cardbus/if_xl_cardbus.c b/sys/dev/cardbus/if_xl_cardbus.c
index 390ac1a54fb..5d3d6391a5d 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.3 2000/06/09 15:35:29 aaron Exp $ */
+/* $OpenBSD: if_xl_cardbus.c,v 1.4 2000/07/01 03:19:14 aaron Exp $ */
/* $NetBSD: if_xl_cardbus.c,v 1.13 2000/03/07 00:32:52 mycroft Exp $ */
/*
@@ -74,9 +74,6 @@
#include <dev/ic/xlreg.h>
-#undef XL_DEBUG
-#define XL_POWER_STATIC /* do not use enable/disable functions */
-
#if defined XL_DEBUG
#define DPRINTF(a) printf a
#else
@@ -84,18 +81,13 @@
#endif
#define CARDBUS_3C575BTX_FUNCSTAT_PCIREG CARDBUS_BASE2_REG /* means 0x18 */
-#define XL_CB_INTR 4 /* intr acknowledge reg. CardBus only */
-#define XL_CB_INTR_ACK 0x8000 /* intr acknowledge bit */
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 *));
-#if !defined XL_POWER_STATIC
-int xl_cardbus_enable __P((struct xl_softc *sc));
-void xl_cardbus_disable __P((struct xl_softc *sc));
-#endif /* !defined XL_POWER_STATIC */
+#define XL_3C575 0x01
+#define XL_3C575B 0x02
struct xl_cardbus_softc {
struct xl_softc sc_softc;
@@ -103,18 +95,14 @@ struct xl_cardbus_softc {
cardbus_devfunc_t sc_ct;
int sc_intrline;
u_int8_t sc_cardbus_flags;
-#define XL_REATTACH 0x01
-#define XL_ABSENT 0x02
u_int8_t sc_cardtype;
-#define XL_3C575 1
-#define XL_3C575B 2
/* CardBus function status space. 575B requests it. */
bus_space_tag_t sc_funct;
bus_space_handle_t sc_funch;
bus_size_t sc_funcsize;
- bus_size_t sc_mapsize; /* the size of mapped bus space region */
+ bus_size_t sc_mapsize; /* size of mapped bus space region */
};
struct cfattach xl_cardbus_ca = {
@@ -129,33 +117,47 @@ const struct xl_cardbus_product {
int ecp_cardtype; /* card type */
const char *ecp_name; /* device name */
} xl_cardbus_products[] = {
- { CARDBUS_PRODUCT_3COM_3C575TX,
+ { CARDBUS_PRODUCT_3COM_3C575,
0,
CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE,
XL_3C575,
"3c575-TX Ethernet" },
- { CARDBUS_PRODUCT_3COM_3C575BTX,
- 0,
+ { CARDBUS_PRODUCT_3COM_3CCFE575BT,
+ XL_CARDBUS_INVERT_LED_PWR,
CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE |
CARDBUS_COMMAND_MASTER_ENABLE,
XL_3C575B,
"3c575B-TX Ethernet" },
{ CARDBUS_PRODUCT_3COM_3CCFE575CT,
- 0,
+ XL_CARDBUS_INVERT_MII_PWR,
CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE |
CARDBUS_COMMAND_MASTER_ENABLE,
XL_3C575B,
"3c575C-TX Ethernet" },
- { CARDBUS_PRODUCT_3COM_3CCFE656B,
- 0,
+ { CARDBUS_PRODUCT_3COM_3CCFEM656,
+ XL_CARDBUS_INVERT_LED_PWR | XL_CARDBUS_INVERT_MII_PWR,
CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE |
CARDBUS_COMMAND_MASTER_ENABLE,
XL_3C575B,
"3c656-TX Ethernet" },
+ { CARDBUS_PRODUCT_3COM_3CCFEM656B,
+ XL_CARDBUS_INVERT_LED_PWR | XL_CARDBUS_INVERT_MII_PWR,
+ CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE |
+ CARDBUS_COMMAND_MASTER_ENABLE,
+ XL_3C575B,
+ "3c656B-TX Ethernet" },
+
+ { CARDBUS_PRODUCT_3COM_3CCFEM656C,
+ XL_CARDBUS_INVERT_MII_PWR,
+ CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE |
+ CARDBUS_COMMAND_MASTER_ENABLE,
+ XL_3C575B,
+ "3c656C-TX Ethernet" },
+
{ 0,
0,
0,
@@ -225,19 +227,8 @@ xl_cardbus_attach(parent, self, aux)
printf(": 3Com %s", ecp->ecp_name);
-#if 0
-#if !defined XL_POWER_STATIC
- sc->enable = xl_cardbus_enable;
- sc->disable = xl_cardbus_disable;
-#else
- sc->enable = NULL;
- sc->disable = NULL;
-#endif
- sc->enabled = 1;
- sc->sc_dmat = ca->ca_dmat;
- sc->xl_conf = ecp->ecp_flags;
-#endif
sc->xl_bustype = XL_BUS_CARDBUS;
+ sc->xl_cb_flags = ecp->ecp_flags;
iob = adr;
sc->xl_bhandle = ioh;
@@ -269,9 +260,6 @@ xl_cardbus_attach(parent, self, aux)
* enable it.
*/
(ct->ct_cf->cardbus_ctrl)(cc, CARDBUS_MEM_ENABLE);
-
- /* Setup interrupt acknowledge hook */
- sc->intr_ack = xl_cardbus_intr_ack;
}
(ct->ct_cf->cardbus_ctrl)(cc, CARDBUS_BM_ENABLE);
@@ -294,7 +282,6 @@ xl_cardbus_attach(parent, self, aux)
psc->sc_ct = ca->ca_ct;
psc->sc_intrline = ca->ca_intrline;
-#if defined XL_POWER_STATIC
/* Map and establish the interrupt. */
sc->xl_intrhand = cardbus_intr_establish(cc, cf, ca->ca_intrline,
@@ -307,7 +294,6 @@ xl_cardbus_attach(parent, self, aux)
return;
}
printf(": irq %d", ca->ca_intrline);
-#endif
bus_space_write_2(sc->xl_btag, sc->xl_bhandle, XL_COMMAND,
XL_CMD_RESET);
@@ -332,22 +318,8 @@ xl_cardbus_attach(parent, self, aux)
if (psc->sc_cardtype == XL_3C575B)
bus_space_write_4(psc->sc_funct, psc->sc_funch,
- XL_CB_INTR, XL_CB_INTR_ACK);
-
-#if !defined XL_POWER_STATIC
- cardbus_function_disable(psc->sc_ct);
- sc->enabled = 0;
-#endif
-}
-
-void
-xl_cardbus_intr_ack(sc)
- struct xl_softc *sc;
-{
- struct xl_cardbus_softc *psc = (struct xl_cardbus_softc *)sc;
+ XL_CARDBUS_INTR, XL_CARDBUS_INTR_ACK);
- bus_space_write_4(psc->sc_funct, psc->sc_funch, XL_CB_INTR,
- XL_CB_INTR_ACK);
}
int
@@ -388,41 +360,3 @@ xl_cardbus_detach(self, arg)
return (rv);
}
-#if !defined XL_POWER_STATIC
-int
-xl_cardbus_enable(sc)
- struct xl_softc *sc;
-{
- struct xl_cardbus_softc *csc = (struct xl_cardbus_softc *)sc;
- cardbus_function_tag_t cf = csc->sc_ct->ct_cf;
- cardbus_chipset_tag_t cc = csc->sc_ct->ct_cc;
-
- Cardbus_function_enable(csc->sc_ct);
- cardbus_restore_bar(csc->sc_ct);
-
- sc->xl_intrhand = cardbus_intr_establish(cc, cf, csc->sc_intrline,
- IPL_NET, xl_intr, sc);
- if (NULL == sc->xl_intrhand) {
- printf("%s: couldn't establish interrupt\n",
- sc->sc_dev.dv_xname);
- return (1);
- }
-
- return (0);
-}
-
-void
-xl_cardbus_disable(sc)
- struct xl_softc *sc;
-{
- struct xl_cardbus_softc *csc = (struct xl_cardbus_softc *)sc;
- cardbus_function_tag_t cf = csc->sc_ct->ct_cf;
- cardbus_chipset_tag_t cc = csc->sc_ct->ct_cc;
-
- cardbus_save_bar(csc->sc_ct);
-
- Cardbus_function_disable(csc->sc_ct);
-
- cardbus_intr_disestablish(cc, cf, sc->xl_intrhand);
-}
-#endif /* XL_POWER_STATIC */
diff --git a/sys/dev/ic/xl.c b/sys/dev/ic/xl.c
index a6b273f477a..f34c7783a46 100644
--- a/sys/dev/ic/xl.c
+++ b/sys/dev/ic/xl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xl.c,v 1.4 2000/06/29 14:07:03 jason Exp $ */
+/* $OpenBSD: xl.c,v 1.5 2000/07/01 03:19:14 aaron Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -57,8 +57,11 @@
* 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
- * 3Com 3C575BTX 10/100Mbps LAN CardBus PC Card
+ * 3Com 3CCFE575BT 10/100Mbps LAN CardBus PC Card
* 3Com 3CCFE575CT 10/100Mbps LAN CardBus PC Card
+ * 3Com 3CCFEM656 10/100Mbps LAN+56k Modem CardBus PC Card
+ * 3Com 3CCFEM656B 10/100Mbps LAN+56k Modem CardBus PC Card
+ * 3Com 3CCFEM656C 10/100Mbps LAN+56k Global Modem CardBus PC Card
* 3Com 3cSOHO100-TX 10/100Mbps/RJ-45 (Hurricane ASIC)
* Dell Optiplex GX1 on-board 3c918 10/100Mbps/RJ-45
* Dell on-board 3c920 10/100Mbps/RJ-45
@@ -983,9 +986,12 @@ void xl_choose_xcvr(sc, verbose)
printf("xl%d: guessing 10/100 plus BNC/AUI\n",
sc->xl_unit);
break;
- case TC_DEVICEID_3CCFE575_CARDBUS:
+ case TC_DEVICEID_3C575_CARDBUS:
case TC_DEVICEID_3CCFE575BT_CARDBUS:
case TC_DEVICEID_3CCFE575CT_CARDBUS:
+ case TC_DEVICEID_3CCFEM656_CARDBUS:
+ case TC_DEVICEID_3CCFEM656B_CARDBUS:
+ case TC_DEVICEID_3CCFEM656C_CARDBUS:
sc->xl_media = XL_MEDIAOPT_MII;
sc->xl_xcvr = XL_XCVR_MII;
break;
@@ -1435,7 +1441,8 @@ int xl_intr(arg)
XL_CMD_INTR_ACK|(status & XL_INTRS));
if (sc->xl_bustype == XL_BUS_CARDBUS)
- bus_space_write_4(sc->xl_funct,sc->xl_funch, 4, 0x8000);
+ bus_space_write_4(sc->xl_funct,sc->xl_funch,
+ XL_CARDBUS_INTR, XL_CARDBUS_INTR_ACK);
if (status & XL_STAT_UP_COMPLETE) {
int curpkts;
@@ -2015,7 +2022,8 @@ 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, 4, 0x8000);
+ bus_space_write_4(sc->xl_funct, sc->xl_funch, XL_CARDBUS_INTR,
+ XL_CARDBUS_INTR_ACK);
CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_STAT_ENB|XL_INTRS);
CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ENB|XL_INTRS);
@@ -2318,7 +2326,8 @@ void xl_stop(sc)
CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ENB|0);
if (sc->xl_bustype == XL_BUS_CARDBUS)
- bus_space_write_4(sc->xl_funct, sc->xl_funch, 4, 0x8000);
+ bus_space_write_4(sc->xl_funct, sc->xl_funch, XL_CARDBUS_INTR,
+ XL_CARDBUS_INTR_ACK);
/* Stop the stats updater. */
untimeout(xl_stats_update, sc);
@@ -2378,16 +2387,15 @@ xl_attach(sc)
printf(" address %s\n", ether_sprintf(sc->arpcom.ac_enaddr));
if (sc->xl_bustype == XL_BUS_CARDBUS) {
- u_int16_t devid;
u_int16_t n;
XL_SEL_WIN(2);
n = CSR_READ_2(sc, 12);
- xl_read_eeprom(sc, (caddr_t)&devid, XL_EE_PRODID, 1, 0);
- if (devid != 0x5257)
+ if (sc->xl_cb_flags & XL_CARDBUS_INVERT_LED_PWR)
n |= 0x0010;
- if (devid == 0x5257 || devid == 0x6560 || devid == 0x6562)
+
+ if (sc->xl_cb_flags & XL_CARDBUS_INVERT_MII_PWR)
n |= 0x4000;
CSR_WRITE_2(sc, 12, n);
@@ -2449,18 +2457,17 @@ xl_attach(sc)
sc->xl_xcvr &= XL_ICFG_CONNECTOR_MASK;
sc->xl_xcvr >>= XL_ICFG_CONNECTOR_BITS;
- if (sc->xl_bustype == XL_BUS_CARDBUS) {
- XL_SEL_WIN(2);
- CSR_WRITE_2(sc, 12, 0x4000 | CSR_READ_2(sc, 12));
- }
DELAY(100000);
xl_mediacheck(sc);
if (sc->xl_bustype == XL_BUS_CARDBUS) {
- XL_SEL_WIN(2);
- CSR_WRITE_2(sc, 12, 0x4000 | CSR_READ_2(sc, 12));
+ 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));
+ }
}
+
DELAY(100000);
if (sc->xl_media & XL_MEDIAOPT_MII || sc->xl_media & XL_MEDIAOPT_BTX
diff --git a/sys/dev/ic/xlreg.h b/sys/dev/ic/xlreg.h
index e14e5913d63..708038260d2 100644
--- a/sys/dev/ic/xlreg.h
+++ b/sys/dev/ic/xlreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: xlreg.h,v 1.2 2000/04/18 14:32:49 aaron Exp $ */
+/* $OpenBSD: xlreg.h,v 1.3 2000/07/01 03:19:14 aaron Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -34,8 +34,8 @@
* $FreeBSD: if_xlreg.h,v 1.17 1999/05/30 18:09:17 wpaul Exp $
*/
-#define XL_BUS_PCI 0x00
-#define XL_BUS_CARDBUS 0x01
+#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 */
@@ -572,7 +572,8 @@ 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; /* i.e., PCI or CardBus? */
+ 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;
@@ -631,7 +632,7 @@ struct xl_stats {
#define TC_VENDORID 0x10B7
/*
- * 3Com chip device IDs.
+ * 3Com PCI chip device IDs.
*/
#define TC_DEVICEID_TORNADO_HOMECONNECT 0x4500
#define TC_DEVICEID_BOOMERANG_10BT 0x9000
@@ -650,9 +651,26 @@ struct xl_stats {
#define TC_DEVICEID_HURRICANE_10_100BT_SERV 0x9800
#define TC_DEVICEID_TORNADO_10_100BT_SERV 0x9805
#define TC_DEVICEID_HURRICANE_SOHO100TX 0x7646
-#define TC_DEVICEID_3CCFE575_CARDBUS 0x5057
-#define TC_DEVICEID_3CCFE575BT_CARDBUS 0x5157
-#define TC_DEVICEID_3CCFE575CT_CARDBUS 0x5257
+
+/*
+ * 3Com CardBus chip device IDs.
+ *
+ * The third character of the model number indicates either a dongle ('C')
+ * or X-Jack ('X') connector. Presumably, "FE" means "Fast Ethernet", and
+ * the 'M' indicates a NIC/modem combo card.
+ */
+#define TC_DEVICEID_3C575_CARDBUS 0x5057
+#define TC_DEVICEID_3CCFE575BT_CARDBUS 0x5157 /* also 3CXFE575BT */
+#define TC_DEVICEID_3CCFE575CT_CARDBUS 0x5257 /* also 3CXFE575CT */
+#define TC_DEVICEID_3CCFEM656_CARDBUS 0x6560 /* also 3CXFEM656 */
+#define TC_DEVICEID_3CCFEM656B_CARDBUS 0x6562
+#define TC_DEVICEID_3CCFEM656C_CARDBUS 0x6564 /* also 3CXFEM656C */
+
+#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
diff --git a/sys/dev/pci/if_xl_pci.c b/sys/dev/pci/if_xl_pci.c
index decaf81bd8f..af5bc506f23 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.2 2000/04/18 03:52:36 jason Exp $ */
+/* $OpenBSD: if_xl_pci.c,v 1.3 2000/07/01 03:19:15 aaron Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -142,6 +142,9 @@ 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;
+
/*
* If this is a 3c905B, we have to check one extra thing.
* The 905B supports power management and may be placed in