summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraaron <aaron@openbsd.org>2001-03-29 01:39:31 +0000
committeraaron <aaron@openbsd.org>2001-03-29 01:39:31 +0000
commit454a6013da76e620c35a0481a3701ebd9e5bee03 (patch)
tree200115512fb20a0ccabb04d8293caa13920b5530
parentregen (diff)
downloadwireguard-openbsd-454a6013da76e620c35a0481a3701ebd9e5bee03.tar.xz
wireguard-openbsd-454a6013da76e620c35a0481a3701ebd9e5bee03.zip
Add MII support to NE2000 PCMCIA driver. Both the Netgear FA410TXC and
New Media LiveWire Fast Ethernet adapters now work after these changes, although the Netgear card still requires media to be set manually.
-rw-r--r--sys/conf/files4
-rw-r--r--sys/dev/ic/dp8390.c24
-rw-r--r--sys/dev/ic/dp8390var.h13
-rw-r--r--sys/dev/ic/ne2000.c11
-rw-r--r--sys/dev/ic/ne2000var.h7
-rw-r--r--sys/dev/pcmcia/files.pcmcia4
-rw-r--r--sys/dev/pcmcia/if_ne_pcmcia.c59
7 files changed, 98 insertions, 24 deletions
diff --git a/sys/conf/files b/sys/conf/files
index 8a4bb09da49..a5d10adc8d4 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.193 2001/03/29 01:26:46 aaron Exp $
+# $OpenBSD: files,v 1.194 2001/03/29 01:39:31 aaron Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -188,7 +188,7 @@ file dev/ic/smc91cxx.c sm
# Novell NE2000-compatible Ethernet cards, based on the
# National Semiconductor DS8390.
-device ne: ether, ifnet, dp8390nic, ifmedia
+device ne: ether, ifnet, dp8390nic, ifmedia, mii
file dev/ic/ne2000.c ne
# D-Link DL10019/10022 NE2000-compatible network interface subroutines
diff --git a/sys/dev/ic/dp8390.c b/sys/dev/ic/dp8390.c
index 036595984fc..a12e0f1e541 100644
--- a/sys/dev/ic/dp8390.c
+++ b/sys/dev/ic/dp8390.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dp8390.c,v 1.11 2001/03/25 06:17:33 fgsch Exp $ */
+/* $OpenBSD: dp8390.c,v 1.12 2001/03/29 01:39:32 aaron Exp $ */
/* $NetBSD: dp8390.c,v 1.13 1998/07/05 06:49:11 jonathan Exp $ */
/*
@@ -1251,3 +1251,25 @@ dp8390_disable(sc)
sc->sc_enabled = 0;
}
}
+
+int
+dp8390_detach(sc, flags)
+ struct dp8390_softc *sc;
+ int flags;
+{
+ struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+
+ /* dp8390_disable() checks sc->sc_enabled */
+ dp8390_disable(sc);
+
+ if (sc->sc_media_fini != NULL)
+ (*sc->sc_media_fini)(sc);
+
+ /* Delete all reamining media. */
+ ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
+
+ ether_ifdetach(ifp);
+ if_detach(ifp);
+
+ return (0);
+}
diff --git a/sys/dev/ic/dp8390var.h b/sys/dev/ic/dp8390var.h
index fcd6b9f802c..d04b3f88a5d 100644
--- a/sys/dev/ic/dp8390var.h
+++ b/sys/dev/ic/dp8390var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dp8390var.h,v 1.4 2001/03/12 05:36:58 aaron Exp $ */
+/* $OpenBSD: dp8390var.h,v 1.5 2001/03/29 01:39:32 aaron Exp $ */
/* $NetBSD: dp8390var.h,v 1.8 1998/08/12 07:19:09 scottr Exp $ */
/*
@@ -14,6 +14,12 @@
* the author assume any responsibility for damages incurred with its use.
*/
+/*
+ * We include MII glue here -- some DP8390 compatible chips have
+ * MII interfaces on them (scary, isn't it...).
+ */
+#include <dev/mii/miivar.h>
+
#define INTERFACE_NAME_LEN 32
/*
@@ -25,7 +31,8 @@ struct dp8390_softc {
int sc_flags; /* interface flags, from config */
struct arpcom sc_arpcom; /* ethernet common */
- struct ifmedia sc_media; /* supported media information */
+ struct mii_data sc_mii; /* MII glue */
+#define sc_media sc_mii.mii_media /* compatibility definition */
bus_space_tag_t sc_regt; /* NIC register space tag */
bus_space_handle_t sc_regh; /* NIC register space handle */
@@ -148,6 +155,8 @@ void dp8390_mediastatus __P((struct ifnet *, struct ifmediareq *));
void dp8390_media_init __P((struct dp8390_softc *));
+int dp8390_detach __P((struct dp8390_softc *, int));
+
void dp8390_rint __P((struct dp8390_softc *));
void dp8390_getmcaf __P((struct arpcom *, u_int8_t *));
diff --git a/sys/dev/ic/ne2000.c b/sys/dev/ic/ne2000.c
index e49dd3e2f81..fdeede4cc0d 100644
--- a/sys/dev/ic/ne2000.c
+++ b/sys/dev/ic/ne2000.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ne2000.c,v 1.10 2001/03/13 06:02:00 aaron Exp $ */
+/* $OpenBSD: ne2000.c,v 1.11 2001/03/29 01:39:32 aaron Exp $ */
/* $NetBSD: ne2000.c,v 1.12 1998/06/10 01:15:50 thorpej Exp $ */
/*-
@@ -166,6 +166,7 @@ ne2000_attach(nsc, myea)
case NE2000_TYPE_NE2000:
case NE2000_TYPE_AX88190: /* XXX really? */
case NE2000_TYPE_DL10019:
+ case NE2000_TYPE_DL10022:
memsize = 8192 * 2;
break;
}
@@ -790,3 +791,11 @@ ne2000_writemem(nict, nich, asict, asich, src, dst, len, useword)
while (((bus_space_read_1(nict, nich, ED_P0_ISR) & ED_ISR_RDC) !=
ED_ISR_RDC) && --maxwait);
}
+
+int
+ne2000_detach(sc, flags)
+ struct ne2000_softc *sc;
+ int flags;
+{
+ return (dp8390_detach(&sc->sc_dp8390, flags));
+}
diff --git a/sys/dev/ic/ne2000var.h b/sys/dev/ic/ne2000var.h
index ded41f5b100..4f4cc08efa5 100644
--- a/sys/dev/ic/ne2000var.h
+++ b/sys/dev/ic/ne2000var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ne2000var.h,v 1.5 2001/03/12 05:36:58 aaron Exp $ */
+/* $OpenBSD: ne2000var.h,v 1.6 2001/03/29 01:39:32 aaron Exp $ */
/* $NetBSD: ne2000var.h,v 1.2 1997/10/14 22:54:12 thorpej Exp $ */
/*-
@@ -54,14 +54,17 @@ struct ne2000_softc {
#define NE2000_TYPE_NE1000 1
#define NE2000_TYPE_NE2000 2
#define NE2000_TYPE_DL10019 3
-#define NE2000_TYPE_AX88190 4
+#define NE2000_TYPE_DL10022 4
+#define NE2000_TYPE_AX88190 5
#define NE2000_USE_WORD(sc) \
(((sc)->sc_type == NE2000_TYPE_NE2000) || \
((sc)->sc_type == NE2000_TYPE_DL10019) || \
+ ((sc)->sc_type == NE2000_TYPE_DL10022) || \
((sc)->sc_type == NE2000_TYPE_AX88190))
int ne2000_attach __P((struct ne2000_softc *, u_int8_t *));
int ne2000_detect __P((struct ne2000_softc *));
+int ne2000_detach __P((struct ne2000_softc *, int));
#endif /* _DEV_IC_NE2000VAR_H_ */
diff --git a/sys/dev/pcmcia/files.pcmcia b/sys/dev/pcmcia/files.pcmcia
index cea7d0a1b67..01a10c0dd11 100644
--- a/sys/dev/pcmcia/files.pcmcia
+++ b/sys/dev/pcmcia/files.pcmcia
@@ -1,4 +1,4 @@
-# $OpenBSD: files.pcmcia,v 1.33 2000/08/17 16:16:31 mickey Exp $
+# $OpenBSD: files.pcmcia,v 1.34 2001/03/29 01:39:32 aaron Exp $
# $NetBSD: files.pcmcia,v 1.9 1998/06/21 18:45:41 christos Exp $
#
# Config.new file and device description for machine-independent PCMCIA code.
@@ -19,7 +19,7 @@ file dev/pcmcia/if_ep_pcmcia.c ep_pcmcia
# National Semiconductor DS8390/WD83C690-based boards
# (NE[12]000, and clones)
-attach ne at pcmcia with ne_pcmcia: rtl80x9
+attach ne at pcmcia with ne_pcmcia: rtl80x9, dl10019, mii_bitbang
file dev/pcmcia/if_ne_pcmcia.c ne_pcmcia
# Adaptec APA-14[56]0 / NewMedia BusToaster SCSI Host Adapter
diff --git a/sys/dev/pcmcia/if_ne_pcmcia.c b/sys/dev/pcmcia/if_ne_pcmcia.c
index 2518b84440b..46af95933d7 100644
--- a/sys/dev/pcmcia/if_ne_pcmcia.c
+++ b/sys/dev/pcmcia/if_ne_pcmcia.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ne_pcmcia.c,v 1.38 2001/03/27 10:23:44 peter Exp $ */
+/* $OpenBSD: if_ne_pcmcia.c,v 1.39 2001/03/29 01:39:33 aaron Exp $ */
/* $NetBSD: if_ne_pcmcia.c,v 1.17 1998/08/15 19:00:04 thorpej Exp $ */
/*
@@ -49,12 +49,18 @@
#include <dev/pcmcia/pcmciavar.h>
#include <dev/pcmcia/pcmciadevs.h>
+#include <dev/mii/miivar.h>
+#include <dev/mii/mii_bitbang.h>
+
#include <dev/ic/dp8390reg.h>
#include <dev/ic/dp8390var.h>
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
+#include <dev/ic/dl10019reg.h>
+#include <dev/ic/dl10019var.h>
+
#include <dev/ic/rtl80x9reg.h>
#include <dev/ic/rtl80x9var.h>
@@ -98,8 +104,8 @@ const struct ne2000dev {
int enet_maddr;
unsigned char enet_vendor[3];
int flags;
-#define NE2000DVF_DL10019 0x0001 /* chip is D-Link DL10019 */
-#define NE2000DVF_AX88190 0x0002 /* chip is ASIX AX88190 */
+#define NE2000DVF_DL10019 0x0001 /* chip is D-Link DL10019 */
+#define NE2000DVF_AX88190 0x0002 /* chip is ASIX AX88190 */
} ne2000devs[] = {
{ PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
PCMCIA_CIS_AMBICOM_AMB8002T,
@@ -162,6 +168,10 @@ const struct ne2000dev {
0, -1, { 0x00, 0x80, 0xc6 } },
{ PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
+ PCMCIA_CIS_NETGEAR_FA410TX,
+ 0, -1, { 0x00, 0xe0, 0x98 } },
+
+ { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
PCMCIA_CIS_TAMARACK_NE2000,
0, -1, { 0x00, 0x47, 0x43 } },
@@ -613,6 +623,15 @@ again:
dsc->sc_media_init = rtl80x9_media_init;
}
+ if (nsc->sc_type == NE2000_TYPE_DL10019 ||
+ nsc->sc_type == NE2000_TYPE_DL10022) {
+ dsc->sc_mediachange = dl10019_mediachange;
+ dsc->sc_mediastatus = dl10019_mediastatus;
+ dsc->init_card = dl10019_init_card;
+ dsc->sc_media_init = dl10019_media_init;
+ dsc->sc_media_fini = dl10019_media_fini;
+ }
+
/* set up the interrupt */
psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, dp8390_intr,
dsc);
@@ -654,22 +673,24 @@ ne_pcmcia_detach(dev, flags)
int flags;
{
struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dev;
- struct dp8390_softc *dsc = &psc->sc_ne2000.sc_dp8390;
- struct ifnet *ifp = &dsc->sc_arpcom.ac_if;
- int rv = 0;
+ int error;
if (psc->sc_nic_io_window == -1)
/* Nothing to detach. */
return (0);
+ error = ne2000_detach(&psc->sc_ne2000, flags);
+ if (error != 0)
+ return (error);
+
+ /* Unmap our i/o windows. */
pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
- pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
- ether_ifdetach(ifp);
- if_detach(ifp);
+ /* Free our i/o space. */
+ pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
- return (rv);
+ return (0);
}
int
@@ -779,17 +800,27 @@ ne_pcmcia_dl10019_get_enaddr(psc, myea)
{
struct ne2000_softc *nsc = &psc->sc_ne2000;
u_int8_t sum;
- int j;
+ int j, type;
- for (j = 0, sum = 0; j < 8; j++)
+ for (j = 0, sum = 0; j < 8; j++) {
sum += bus_space_read_1(nsc->sc_asict, nsc->sc_asich,
0x04 + j);
+ }
if (sum != 0xff)
return (NULL);
- for (j = 0; j < ETHER_ADDR_LEN; j++)
+
+ for (j = 0; j < ETHER_ADDR_LEN; j++) {
myea[j] = bus_space_read_1(nsc->sc_asict,
nsc->sc_asich, 0x04 + j);
- nsc->sc_type = NE2000_TYPE_DL10019;
+ }
+
+ /* XXX - magic values from Linux */
+ type = bus_space_read_1(nsc->sc_asict, nsc->sc_asich, 0x0f);
+ if (type == 0x91 || type == 0x99)
+ nsc->sc_type = NE2000_TYPE_DL10022;
+ else
+ nsc->sc_type = NE2000_TYPE_DL10019;
+
return (myea);
}