summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>1998-09-16 22:41:23 +0000
committerJason Wright <jason@cvs.openbsd.org>1998-09-16 22:41:23 +0000
commit5adc1bdecf265b0650027a384d1d4bcc97b2040a (patch)
tree165bac954226e7478cb2765fb4094c8c1396867e /sys/arch
parentbe750c7755842395b37ff183abb8d18887abc1a5 (diff)
o if_media'fied am7990
o if_media'fied sun4m le.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amiga/dev/if_le_zbus.c4
-rw-r--r--sys/arch/hp300/dev/if_le.c4
-rw-r--r--sys/arch/kbus/dev/if_le.c3
-rw-r--r--sys/arch/mvme68k/dev/if_le.c4
-rw-r--r--sys/arch/sparc/dev/if_le.c225
-rw-r--r--sys/arch/sun3/dev/if_le.c4
-rw-r--r--sys/arch/vax/if/if_le.c4
7 files changed, 125 insertions, 123 deletions
diff --git a/sys/arch/amiga/dev/if_le_zbus.c b/sys/arch/amiga/dev/if_le_zbus.c
index 17898a8afab..68523abac19 100644
--- a/sys/arch/amiga/dev/if_le_zbus.c
+++ b/sys/arch/amiga/dev/if_le_zbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le_zbus.c,v 1.7 1997/08/08 08:30:14 downsj Exp $ */
+/* $OpenBSD: if_le_zbus.c,v 1.8 1998/09/16 22:41:16 jason Exp $ */
/* $NetBSD: if_le.c,v 1.22 1996/12/23 09:10:18 veego Exp $ */
/*-
@@ -56,6 +56,8 @@
#include <netinet/if_ether.h>
#endif
+#include <net/if_media.h>
+
#include <machine/cpu.h>
#include <machine/mtpr.h>
diff --git a/sys/arch/hp300/dev/if_le.c b/sys/arch/hp300/dev/if_le.c
index ac278f5087c..faac9aff311 100644
--- a/sys/arch/hp300/dev/if_le.c
+++ b/sys/arch/hp300/dev/if_le.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le.c,v 1.11 1997/08/08 08:26:31 downsj Exp $ */
+/* $OpenBSD: if_le.c,v 1.12 1998/09/16 22:41:17 jason Exp $ */
/* $NetBSD: if_le.c,v 1.43 1997/05/05 21:05:32 thorpej Exp $ */
/*-
@@ -56,6 +56,8 @@
#include <netinet/if_ether.h>
#endif
+#include <net/if_media.h>
+
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <machine/intr.h>
diff --git a/sys/arch/kbus/dev/if_le.c b/sys/arch/kbus/dev/if_le.c
index d9c779fc906..3ec005410fc 100644
--- a/sys/arch/kbus/dev/if_le.c
+++ b/sys/arch/kbus/dev/if_le.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le.c,v 1.1 1997/10/14 07:25:29 gingold Exp $ */
+/* $OpenBSD: if_le.c,v 1.2 1998/09/16 22:41:18 jason Exp $ */
/* $NetBSD: if_le.c,v 1.33 1996/11/20 18:56:52 gwr Exp $ */
/*-
@@ -47,6 +47,7 @@
#include <sys/device.h>
#include <net/if.h>
+#include <net/if_media.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
diff --git a/sys/arch/mvme68k/dev/if_le.c b/sys/arch/mvme68k/dev/if_le.c
index e415922494e..9414d06c491 100644
--- a/sys/arch/mvme68k/dev/if_le.c
+++ b/sys/arch/mvme68k/dev/if_le.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le.c,v 1.11 1997/08/08 08:31:50 downsj Exp $ */
+/* $OpenBSD: if_le.c,v 1.12 1998/09/16 22:41:18 jason Exp $ */
/*-
* Copyright (c) 1982, 1992, 1993
@@ -52,6 +52,8 @@
#include <netinet/if_ether.h>
#endif
+#include <net/if_media.h>
+
#include <machine/autoconf.h>
#include <machine/cpu.h>
diff --git a/sys/arch/sparc/dev/if_le.c b/sys/arch/sparc/dev/if_le.c
index e2842f36bad..137a84d6000 100644
--- a/sys/arch/sparc/dev/if_le.c
+++ b/sys/arch/sparc/dev/if_le.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le.c,v 1.8 1997/09/17 06:47:09 downsj Exp $ */
+/* $OpenBSD: if_le.c,v 1.9 1998/09/16 22:41:18 jason Exp $ */
/* $NetBSD: if_le.c,v 1.50 1997/09/09 20:54:48 pk Exp $ */
/*-
@@ -58,18 +58,11 @@
#include <sys/malloc.h>
#include <net/if.h>
-#if defined(__NetBSD__)
-#include <net/if_ether.h>
#include <net/if_media.h>
-#endif /* __NetBSD__ */
#ifdef INET
#include <netinet/in.h>
-#if defined(__NetBSD__)
-#include <netinet/if_inarp.h>
-#else
#include <netinet/if_ether.h>
-#endif /* __NetBSD__ */
#endif
#include <machine/autoconf.h>
@@ -86,13 +79,23 @@
#include <sparc/dev/if_lereg.h>
#include <sparc/dev/if_levar.h>
-#if defined(__NetBSD__)
-int lematch __P((struct device *, struct cfdata *, void *));
-#else
int lematch __P((struct device *, void *, void *));
-#endif /* __NetBSD__ */
void leattach __P((struct device *, struct device *, void *));
+/*
+ * ifmedia interfaces
+ */
+int lemediachange __P((struct ifnet *));
+void lemediastatus __P((struct ifnet *, struct ifmediareq *));
+
+#if defined(SUN4M)
+/*
+ * media change methods (only for sun4m)
+ */
+void lesetutp __P((struct am7990_softc *));
+void lesetaui __P((struct am7990_softc *));
+#endif /* SUN4M */
+
#if defined(SUN4M) /* XXX */
int myleintr __P((void *));
int ledmaintr __P((struct dma_softc *));
@@ -120,28 +123,6 @@ static int dodrain=0;
}
#endif
-#if defined(SUN4M)
-#if defined(__NetBSD__)
-/*
- * Media types supported by the Sun4m.
- */
-int lemediasun4m[] = {
- IFM_ETHER|IFM_10_T,
- IFM_ETHER|IFM_10_5,
- IFM_ETHER|IFM_AUTO,
-};
-#define NLEMEDIASUN4M (sizeof(lemediasun4m) / sizeof(lemediasun4m[0]))
-#endif /* __NetBSD__ */
-
-void lesetutp __P((struct am7990_softc *));
-void lesetaui __P((struct am7990_softc *));
-
-int lemediachange __P((struct am7990_softc *));
-#if defined(__NetBSD__)
-void lemediastatus __P((struct am7990_softc *, struct ifmediareq *));
-#endif /* __NetBSD__ */
-#endif /* SUN4M */
-
struct cfattach le_ca = {
sizeof(struct le_softc), lematch, leattach
};
@@ -194,9 +175,18 @@ lesetutp(sc)
struct am7990_softc *sc;
{
struct le_softc *lesc = (struct le_softc *)sc;
-
- lesc->sc_dma->sc_regs->csr |= DE_AUI_TP;
- delay(20000); /* must not touch le for 20ms */
+ u_int32_t csr;
+ int tries = 5;
+
+ while (--tries) {
+ csr = lesc->sc_dma->sc_regs->csr;
+ csr |= DE_AUI_TP;
+ lesc->sc_dma->sc_regs->csr = csr;
+ delay(20000); /* must not touch le for 20ms */
+ if (lesc->sc_dma->sc_regs->csr & DE_AUI_TP)
+ return;
+ }
+ printf("Setting utp: bit won't stick\n");
}
void
@@ -204,17 +194,27 @@ lesetaui(sc)
struct am7990_softc *sc;
{
struct le_softc *lesc = (struct le_softc *)sc;
-
- lesc->sc_dma->sc_regs->csr &= ~DE_AUI_TP;
- delay(20000); /* must not touch le for 20ms */
+ u_int32_t csr;
+ int tries = 5;
+
+ while (--tries) {
+ csr = lesc->sc_dma->sc_regs->csr;
+ csr &= ~DE_AUI_TP;
+ lesc->sc_dma->sc_regs->csr = csr;
+ delay(20000); /* must not touch le for 20ms */
+ if ((lesc->sc_dma->sc_regs->csr & DE_AUI_TP) == 0)
+ return;
+ }
+ printf("Setting aui: bit won't stick\n");
}
+#endif
int
-lemediachange(sc)
- struct am7990_softc *sc;
+lemediachange(ifp)
+ struct ifnet *ifp;
{
-#if defined(__NetBSD__)
- struct ifmedia *ifm = &sc->sc_media;
+ struct am7990_softc *sc = ifp->if_softc;
+ struct ifmedia *ifm = &sc->sc_ifmedia;
if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
return (EINVAL);
@@ -226,52 +226,68 @@ lemediachange(sc)
* carrier.
*/
switch (IFM_SUBTYPE(ifm->ifm_media)) {
+#if defined(SUN4M)
case IFM_10_T:
- lesetutp(sc);
+ if (CPU_ISSUN4M)
+ lesetutp(sc);
+ else
+ return (EOPNOTSUPP);
break;
- case IFM_10_5:
- lesetaui(sc);
+ case IFM_AUTO:
+ if (CPU_ISSUN4M)
+ return (0);
+ else
+ return (EOPNOTSUPP);
break;
+#endif
- case IFM_AUTO:
+ case IFM_10_5:
+#if defined(SUN4M)
+ if (CPU_ISSUN4M)
+ lesetaui(sc);
+#else
+ return (0);
+#endif
break;
+
default:
return (EINVAL);
}
-#else
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
- if (ifp->if_flags & IFF_LINK0)
- lesetutp(sc);
- else if (ifp->if_flags & IFF_LINK1)
- lesetaui(sc);
-#endif /* __NetBSD__ */
return (0);
}
-#if defined(__NetBSD__)
void
-lemediastatus(sc, ifmr)
- struct am7990_softc *sc;
+lemediastatus(ifp, ifmr)
+ struct ifnet *ifp;
struct ifmediareq *ifmr;
{
+#if defined(SUN4M)
+ struct am7990_softc *sc = ifp->if_softc;
struct le_softc *lesc = (struct le_softc *)sc;
- if (lesc->sc_dma == NULL)
+ if (lesc->sc_dma == NULL) {
+ ifmr->ifm_active = IFM_ETHER | IFM_10_5;
return;
+ }
- /*
- * Notify the world which media we're currently using.
- */
- if (lesc->sc_dma->sc_regs->csr & DE_AUI_TP)
- ifmr->ifm_active = IFM_ETHER|IFM_10_T;
+ if (CPU_ISSUN4M) {
+ /*
+ * Notify the world which media we're currently using.
+ */
+ if (lesc->sc_dma->sc_regs->csr & DE_AUI_TP)
+ ifmr->ifm_active = IFM_ETHER | IFM_10_T;
+ else
+ ifmr->ifm_active = IFM_ETHER | IFM_10_5;
+ }
else
- ifmr->ifm_active = IFM_ETHER|IFM_10_5;
+ ifmr->ifm_active = IFM_ETHER | IFM_10_5;
+#else
+ ifmr->ifm_active = IFM_ETHER | IFM_10_5;
+#endif
}
-#endif /* __NetBSD__ */
-#endif /* SUN4M */
hide void
lehwreset(sc)
@@ -301,13 +317,8 @@ lehwinit(sc)
#if defined(SUN4M)
struct le_softc *lesc = (struct le_softc *)sc;
- /*
- * Make sure we're using the currently-enabled media type.
- * XXX Actually, this is probably unnecessary, now.
- */
if (CPU_ISSUN4M && lesc->sc_dma) {
-#if defined(__NetBSD__)
- switch (IFM_SUBTYPE(sc->sc_media.ifm_cur->ifm_media)) {
+ switch (IFM_SUBTYPE(sc->sc_ifmedia.ifm_cur->ifm_media)) {
case IFM_10_T:
lesetutp(sc);
break;
@@ -315,15 +326,15 @@ lehwinit(sc)
case IFM_10_5:
lesetaui(sc);
break;
- }
-#else
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
- if (ifp->if_flags & IFF_LINK0)
+ case IFM_AUTO:
lesetutp(sc);
- else if (ifp->if_flags & IFF_LINK1)
- lesetaui(sc);
-#endif /* __NetBSD__ */
+ break;
+
+ default: /* XXX shouldn't happen */
+ lesetutp(sc);
+ break;
+ }
}
#endif
}
@@ -334,9 +345,6 @@ lenocarrier(sc)
{
#if defined(SUN4M)
struct le_softc *lesc = (struct le_softc *)sc;
-#if !defined(__NetBSD__)
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
-#endif /* __NetBSD__ */
if (CPU_ISSUN4M && lesc->sc_dma) {
/*
@@ -346,34 +354,20 @@ lenocarrier(sc)
printf("%s: lost carrier on ", sc->sc_dev.dv_xname);
if (lesc->sc_dma->sc_regs->csr & DE_AUI_TP) {
printf("UTP port");
-#if defined(__NetBSD__)
- switch (IFM_SUBTYPE(sc->sc_media.ifm_media)) {
+ switch (IFM_SUBTYPE(sc->sc_ifmedia.ifm_media)) {
case IFM_10_5:
case IFM_AUTO:
printf(", switching to AUI port");
lesetaui(sc);
}
-#else
- if (!(ifp->if_flags & IFF_LINK0)) {
- printf(", switching to AUI port");
- lesetaui(sc);
- }
-#endif /* __NetBSD__ */
} else {
printf("AUI port");
-#if defined(__NetBSD__)
- switch (IFM_SUBTYPE(sc->sc_media.ifm_media)) {
+ switch (IFM_SUBTYPE(sc->sc_ifmedia.ifm_media)) {
case IFM_10_T:
case IFM_AUTO:
printf(", switching to UTP port");
lesetutp(sc);
}
-#else
- if (!(ifp->if_flags & IFF_LINK1)) {
- printf(", switching to UTP port");
- lesetutp(sc);
- }
-#endif /* __NetBSD__ */
}
printf("\n");
} else
@@ -382,19 +376,11 @@ lenocarrier(sc)
}
int
-#if defined(__NetBSD__)
-lematch(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
-{
-#else
lematch(parent, vcf, aux)
struct device *parent;
void *vcf, *aux;
{
struct cfdata *cf = vcf;
-#endif /* __NetBSD__ */
struct confargs *ca = aux;
register struct romaux *ra = &ca->ca_ra;
@@ -433,6 +419,8 @@ leattach(parent, self, aux)
pri = ca->ca_ra.ra_intr[0].int_pri;
printf(" pri %d", pri);
+ sc->sc_hasifmedia = 1;
+
lesc->sc_r1 = (struct lereg1 *)
mapiodev(ca->ca_ra.ra_reg, 0, sizeof(struct lereg1));
@@ -519,11 +507,7 @@ leattach(parent, self, aux)
break;
}
-#if defined(__NetBSD__)
- myetheraddr(sc->sc_enaddr);
-#else
myetheraddr(sc->sc_arpcom.ac_enaddr);
-#endif /* __NetBSD__ */
sc->sc_copytodesc = am7990_copytobuf_contig;
sc->sc_copyfromdesc = am7990_copyfrombuf_contig;
@@ -537,14 +521,21 @@ leattach(parent, self, aux)
sc->sc_nocarrier = lenocarrier;
sc->sc_hwreset = lehwreset;
-#if defined(SUN4M) && defined(__NetBSD__)
+ ifmedia_init(&sc->sc_ifmedia, 0, lemediachange, lemediastatus);
+#if defined(SUN4M)
if (CPU_ISSUN4M && lesc->sc_dma) {
- sc->sc_mediachange = lemediachange;
- sc->sc_mediastatus = lemediastatus;
- sc->sc_supmedia = lemediasun4m;
- sc->sc_nsupmedia = NLEMEDIASUN4M;
- sc->sc_defaultmedia = IFM_ETHER|IFM_AUTO;
+ ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_10_T, 0, NULL);
+ ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_10_5, 0, NULL);
+ ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO, 0, NULL);
+ ifmedia_set(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO);
}
+ else {
+ ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_10_5, 0, NULL);
+ ifmedia_set(&sc->sc_ifmedia, IFM_ETHER | IFM_10_5);
+ }
+#else
+ ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_10_5, 0, NULL);
+ ifmedia_set(&sc->sc_ifmedia, IFM_ETHER | IFM_10_5);
#endif
am7990_config(sc);
diff --git a/sys/arch/sun3/dev/if_le.c b/sys/arch/sun3/dev/if_le.c
index fed9c69e7a5..7d6ec439e73 100644
--- a/sys/arch/sun3/dev/if_le.c
+++ b/sys/arch/sun3/dev/if_le.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le.c,v 1.10 1997/08/08 08:27:39 downsj Exp $ */
+/* $OpenBSD: if_le.c,v 1.11 1998/09/16 22:41:19 jason Exp $ */
/* $NetBSD: if_le.c,v 1.33 1996/11/20 18:56:52 gwr Exp $ */
/*-
@@ -53,6 +53,8 @@
#include <netinet/if_ether.h>
#endif
+#include <net/if_media.h>
+
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <machine/dvma.h>
diff --git a/sys/arch/vax/if/if_le.c b/sys/arch/vax/if/if_le.c
index 2982f30160b..3b9528685d1 100644
--- a/sys/arch/vax/if/if_le.c
+++ b/sys/arch/vax/if/if_le.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le.c,v 1.3 1997/09/10 08:28:40 maja Exp $ */
+/* $OpenBSD: if_le.c,v 1.4 1998/09/16 22:41:19 jason Exp $ */
/* $NetBSD: if_le.c,v 1.8 1997/04/21 22:04:23 ragge Exp $ */
/* #define LE_CHIP_IS_POKEY /* does VS2000 need this ??? */
@@ -57,6 +57,8 @@
#include <netinet/if_ether.h>
#endif
+#include <net/if_media.h>
+
/*
* This would be nice, but it's not yet there...
*