diff options
author | Aaron Campbell <aaron@cvs.openbsd.org> | 2001-03-12 05:37:02 +0000 |
---|---|---|
committer | Aaron Campbell <aaron@cvs.openbsd.org> | 2001-03-12 05:37:02 +0000 |
commit | ae5b9c617251f0bbde3b4bc036c9c4fa6ac03be0 (patch) | |
tree | fd8d5ce0859f439ce531740d6f199e6f7f58e0ec /sys | |
parent | 6132c34e3bdb7699e0b9c86920b8c517208deef2 (diff) |
Adjust the way that media is initialized on DP8390-compatibles; from NetBSD.
The dp8390_softc now has media_init and media_fini function pointers that
do the work. fgsch@ ok
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amiga/dev/if_ne_zbus.c | 12 | ||||
-rw-r--r-- | sys/dev/ic/dp8390.c | 40 | ||||
-rw-r--r-- | sys/dev/ic/dp8390var.h | 12 | ||||
-rw-r--r-- | sys/dev/ic/ne2000.c | 10 | ||||
-rw-r--r-- | sys/dev/ic/ne2000var.h | 5 | ||||
-rw-r--r-- | sys/dev/ic/rtl80x9.c | 24 | ||||
-rw-r--r-- | sys/dev/ic/rtl80x9var.h | 4 | ||||
-rw-r--r-- | sys/dev/isa/if_ec.c | 24 | ||||
-rw-r--r-- | sys/dev/isa/if_ne_isa.c | 17 | ||||
-rw-r--r-- | sys/dev/isa/if_ne_isapnp.c | 17 | ||||
-rw-r--r-- | sys/dev/isa/if_we.c | 72 | ||||
-rw-r--r-- | sys/dev/pci/if_ne_pci.c | 26 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_ne_pcmcia.c | 17 |
13 files changed, 130 insertions, 150 deletions
diff --git a/sys/arch/amiga/dev/if_ne_zbus.c b/sys/arch/amiga/dev/if_ne_zbus.c index c854917c68a..76ff6e86cea 100644 --- a/sys/arch/amiga/dev/if_ne_zbus.c +++ b/sys/arch/amiga/dev/if_ne_zbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ne_zbus.c,v 1.1 2000/02/29 19:05:22 niklas Exp $ */ +/* $OpenBSD: if_ne_zbus.c,v 1.2 2001/03/12 05:36:57 aaron Exp $ */ /* $NetBSD: if_ne_zbus.c,v 1.5 2000/01/23 21:06:13 aymeric Exp $ */ /*- @@ -150,14 +150,11 @@ ne_zbus_attach(parent, self, aux) bus_space_handle_t nich; bus_space_tag_t asict = nict; bus_space_handle_t asich; - int *media, nmedia, defmedia; - - media = NULL; - nmedia = defmedia = 0; dsc->sc_mediachange = rtl80x9_mediachange; dsc->sc_mediastatus = rtl80x9_mediastatus; dsc->init_card = rtl80x9_init_card; + dsc->sc_media_init = rtl80x9_media_init; #ifdef __NetBSD__ zsc->sc_bst.base = (u_long)zap->va + 0; @@ -194,9 +191,6 @@ ne_zbus_attach(parent, self, aux) nsc->sc_asict = asict; nsc->sc_asich = asich; - /* Initialize media. */ - rtl80x9_init_media(dsc, &media, &nmedia, &defmedia); - /* This interface is always enabled. */ dsc->sc_enabled = 1; @@ -204,7 +198,7 @@ ne_zbus_attach(parent, self, aux) * Do generic NE2000 attach. This will read the station address * from the EEPROM. */ - ne2000_attach(nsc, NULL, media, nmedia, defmedia); + ne2000_attach(nsc, NULL); zsc->sc_isr.isr_intr = dp8390_intr; zsc->sc_isr.isr_arg = dsc; diff --git a/sys/dev/ic/dp8390.c b/sys/dev/ic/dp8390.c index e66847ca392..87d8ea7b5a1 100644 --- a/sys/dev/ic/dp8390.c +++ b/sys/dev/ic/dp8390.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dp8390.c,v 1.9 2001/02/20 19:39:37 mickey Exp $ */ +/* $OpenBSD: dp8390.c,v 1.10 2001/03/12 05:36:57 aaron Exp $ */ /* $NetBSD: dp8390.c,v 1.13 1998/07/05 06:49:11 jonathan Exp $ */ /* @@ -71,9 +71,6 @@ static int dp8390_test_mem __P((struct dp8390_softc *)); int dp8390_enable __P((struct dp8390_softc *)); void dp8390_disable __P((struct dp8390_softc *)); -int dp8390_mediachange __P((struct ifnet *)); -void dp8390_mediastatus __P((struct ifnet *, struct ifmediareq *)); - #define ETHER_MIN_LEN 64 #define ETHER_MAX_LEN 1518 #define ETHER_ADDR_LEN 6 @@ -81,15 +78,25 @@ void dp8390_mediastatus __P((struct ifnet *, struct ifmediareq *)); int dp8390_debug = 0; /* + * Standard media init routine for the dp8390. + */ +void +dp8390_media_init(struct dp8390_softc *sc) +{ + ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus); + ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL); + ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_MANUAL); +} + +/* * Do bus-independent setup. */ int -dp8390_config(sc, media, nmedia, defmedia) +dp8390_config(sc) struct dp8390_softc *sc; - int *media, nmedia, defmedia; { struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int i, rv; + int rv; rv = 1; @@ -129,25 +136,17 @@ dp8390_config(sc, media, nmedia, defmedia) IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + /* Print additional info when attached. */ + printf("%s: address %s\n", sc->sc_dev.dv_xname, + ether_sprintf(sc->sc_arpcom.ac_enaddr)); + /* Initialize media goo. */ - ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus); - if (media != NULL) { - for (i = 0; i < nmedia; i++) - ifmedia_add(&sc->sc_media, media[i], 0, NULL); - ifmedia_set(&sc->sc_media, defmedia); - } else { - ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL); - ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_MANUAL); - } + (*sc->sc_media_init)(sc); /* Attach the interface. */ if_attach(ifp); ether_ifattach(ifp); - /* Print additional info when attached. */ - printf("%s: address %s\n", sc->sc_dev.dv_xname, - ether_sprintf(sc->sc_arpcom.ac_enaddr)); - rv = 0; out: return (rv); @@ -164,6 +163,7 @@ dp8390_mediachange(ifp) if (sc->sc_mediachange) return ((*sc->sc_mediachange)(sc)); + return (EINVAL); } diff --git a/sys/dev/ic/dp8390var.h b/sys/dev/ic/dp8390var.h index 00792026afa..fcd6b9f802c 100644 --- a/sys/dev/ic/dp8390var.h +++ b/sys/dev/ic/dp8390var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dp8390var.h,v 1.3 2000/05/29 17:08:51 fgsch Exp $ */ +/* $OpenBSD: dp8390var.h,v 1.4 2001/03/12 05:36:58 aaron Exp $ */ /* $NetBSD: dp8390var.h,v 1.8 1998/08/12 07:19:09 scottr Exp $ */ /* @@ -70,6 +70,9 @@ struct dp8390_softc { int (*sc_enable) __P((struct dp8390_softc *)); void (*sc_disable) __P((struct dp8390_softc *)); + void (*sc_media_init) __P((struct dp8390_softc *)); + void (*sc_media_fini) __P((struct dp8390_softc *)); + int (*sc_mediachange) __P((struct dp8390_softc *)); void (*sc_mediastatus) __P((struct dp8390_softc *, struct ifmediareq *)); @@ -131,7 +134,7 @@ struct dp8390_softc { #define NIC_PUT(t, h, reg, val) bus_space_write_1(t, h, \ ((sc)->sc_reg_map[reg]), (val)) -int dp8390_config __P((struct dp8390_softc *, int *, int, int)); +int dp8390_config __P((struct dp8390_softc *)); int dp8390_intr __P((void *)); int dp8390_ioctl __P((struct ifnet *, u_long, caddr_t)); void dp8390_start __P((struct ifnet *)); @@ -140,6 +143,11 @@ void dp8390_reset __P((struct dp8390_softc *)); void dp8390_init __P((struct dp8390_softc *)); void dp8390_stop __P((struct dp8390_softc *)); +int dp8390_mediachange __P((struct ifnet *)); +void dp8390_mediastatus __P((struct ifnet *, struct ifmediareq *)); + +void dp8390_media_init __P((struct dp8390_softc *)); + 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 ac92cae70c2..cd6906f2591 100644 --- a/sys/dev/ic/ne2000.c +++ b/sys/dev/ic/ne2000.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ne2000.c,v 1.8 2000/05/30 14:31:39 fgsch Exp $ */ +/* $OpenBSD: ne2000.c,v 1.9 2001/03/12 05:36:58 aaron Exp $ */ /* $NetBSD: ne2000.c,v 1.12 1998/06/10 01:15:50 thorpej Exp $ */ /*- @@ -103,10 +103,9 @@ struct cfdriver ne_cd = { }; int -ne2000_attach(nsc, myea, media, nmedia, defmedia) +ne2000_attach(nsc, myea) struct ne2000_softc *nsc; u_int8_t *myea; - int *media, nmedia, defmedia; { struct dp8390_softc *dsc = &nsc->sc_dp8390; bus_space_tag_t nict = dsc->sc_regt; @@ -280,7 +279,10 @@ ne2000_attach(nsc, myea, media, nmedia, defmedia) /* Clear any pending interrupts that might have occurred above. */ bus_space_write_1(nict, nich, ED_P0_ISR, 0xff); - if (dp8390_config(dsc, media, nmedia, defmedia)) { + if (dsc->sc_media_init == NULL) + dsc->sc_media_init = dp8390_media_init; + + if (dp8390_config(dsc)) { printf("%s: setup failed\n", dsc->sc_dev.dv_xname); return (1); } diff --git a/sys/dev/ic/ne2000var.h b/sys/dev/ic/ne2000var.h index 5a347eed078..ded41f5b100 100644 --- a/sys/dev/ic/ne2000var.h +++ b/sys/dev/ic/ne2000var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ne2000var.h,v 1.4 2000/05/30 14:31:39 fgsch Exp $ */ +/* $OpenBSD: ne2000var.h,v 1.5 2001/03/12 05:36:58 aaron Exp $ */ /* $NetBSD: ne2000var.h,v 1.2 1997/10/14 22:54:12 thorpej Exp $ */ /*- @@ -61,8 +61,7 @@ struct ne2000_softc { ((sc)->sc_type == NE2000_TYPE_DL10019) || \ ((sc)->sc_type == NE2000_TYPE_AX88190)) -int ne2000_attach __P((struct ne2000_softc *, u_int8_t *, - int *, int, int)); +int ne2000_attach __P((struct ne2000_softc *, u_int8_t *)); int ne2000_detect __P((struct ne2000_softc *)); #endif /* _DEV_IC_NE2000VAR_H_ */ diff --git a/sys/dev/ic/rtl80x9.c b/sys/dev/ic/rtl80x9.c index 72236389abc..38a3426fe4f 100644 --- a/sys/dev/ic/rtl80x9.c +++ b/sys/dev/ic/rtl80x9.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtl80x9.c,v 1.5 2000/06/20 09:27:25 fgsch Exp $ */ +/* $OpenBSD: rtl80x9.c,v 1.6 2001/03/12 05:36:58 aaron Exp $ */ /* $NetBSD: rtl80x9.c,v 1.1 1998/10/31 00:44:33 thorpej Exp $ */ /*- @@ -167,9 +167,8 @@ rtl80x9_init_card(sc) } void -rtl80x9_init_media(sc, mediap, nmediap, defmediap) +rtl80x9_media_init(sc) struct dp8390_softc *sc; - int **mediap, *nmediap, *defmediap; { static int rtl80x9_media[] = { IFM_ETHER|IFM_AUTO, @@ -177,12 +176,12 @@ rtl80x9_init_media(sc, mediap, nmediap, defmediap) IFM_ETHER|IFM_10_T|IFM_FDX, IFM_ETHER|IFM_10_2, }; + static const int rtl80x9_nmedia = + sizeof(rtl80x9_media) / sizeof(rtl80x9_media[0]); + int i, defmedia; u_int8_t conf2, conf3; - *mediap = rtl80x9_media; - *nmediap = sizeof(rtl80x9_media) / sizeof(rtl80x9_media[0]); - /* Set NIC to page 3 registers. */ bus_space_write_1(sc->sc_regt, sc->sc_regh, ED_P0_CR, ED_CR_PAGE_3); @@ -193,22 +192,27 @@ rtl80x9_init_media(sc, mediap, nmediap, defmediap) switch (conf2) { case 0: - *defmediap = IFM_ETHER|IFM_AUTO; + defmedia = IFM_ETHER|IFM_AUTO; break; case RTL3_CONFIG2_PL1|RTL3_CONFIG2_PL0: case RTL3_CONFIG2_PL1: /* XXX rtl docs sys 10base5, but chip cant do */ - *defmediap = IFM_ETHER|IFM_10_2; + defmedia = IFM_ETHER|IFM_10_2; break; case RTL3_CONFIG2_PL0: if (conf3 & RTL3_CONFIG3_FUDUP) - *defmediap = IFM_ETHER|IFM_10_T|IFM_FDX; + defmedia = IFM_ETHER|IFM_10_T|IFM_FDX; else - *defmediap = IFM_ETHER|IFM_10_T; + defmedia = IFM_ETHER|IFM_10_T; break; } /* Set NIC to page 0 registers. */ bus_space_write_1(sc->sc_regt, sc->sc_regh, ED_P0_CR, ED_CR_PAGE_0); + + ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus); + for (i = 0; i < rtl80x9_nmedia; i++) + ifmedia_add(&sc->sc_media, rtl80x9_media[i], 0, NULL); + ifmedia_set(&sc->sc_media, defmedia); } diff --git a/sys/dev/ic/rtl80x9var.h b/sys/dev/ic/rtl80x9var.h index 94fc7242bb6..41ebd5714e3 100644 --- a/sys/dev/ic/rtl80x9var.h +++ b/sys/dev/ic/rtl80x9var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rtl80x9var.h,v 1.2 2000/06/20 09:27:25 fgsch Exp $ */ +/* $OpenBSD: rtl80x9var.h,v 1.3 2001/03/12 05:36:59 aaron Exp $ */ /* $NetBSD: rtl80x9var.h,v 1.1 1998/10/31 00:44:33 thorpej Exp $ */ /*- @@ -53,7 +53,7 @@ int rtl80x9_mediachange __P((struct dp8390_softc *)); void rtl80x9_mediastatus __P((struct dp8390_softc *, struct ifmediareq *)); void rtl80x9_init_card __P((struct dp8390_softc *)); -void rtl80x9_init_media __P((struct dp8390_softc *, int **, int *, int *)); +void rtl80x9_media_init __P((struct dp8390_softc *)); #endif /* _KERNEL */ #endif /* _DEV_IC_RTL80x9_VAR_H_ */ diff --git a/sys/dev/isa/if_ec.c b/sys/dev/isa/if_ec.c index b86abfd0c4f..df1c7e576ee 100644 --- a/sys/dev/isa/if_ec.c +++ b/sys/dev/isa/if_ec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ec.c,v 1.2 1998/10/04 22:28:14 niklas Exp $ */ +/* $OpenBSD: if_ec.c,v 1.3 2001/03/12 05:36:59 aaron Exp $ */ /* $NetBSD: if_ec.c,v 1.9 1998/07/05 06:49:12 jonathan Exp $ */ /*- @@ -126,6 +126,8 @@ struct cfattach ec_ca = { int ec_set_media __P((struct ec_softc *, int)); +void ec_media_init __P((struct dp8390_softc *)); + int ec_mediachange __P((struct dp8390_softc *)); void ec_mediastatus __P((struct dp8390_softc *, struct ifmediareq *)); @@ -149,13 +151,6 @@ static const int ec_membase[] = { }; #define NEC_MEMBASE (sizeof(ec_membase) / sizeof(ec_membase[0])) -int ec_media[] = { - IFM_ETHER|IFM_10_2, - IFM_ETHER|IFM_10_5, -}; -#define NEC_MEDIA (sizeof(ec_media) / sizeof(ec_media[0])) -#define EC_DEFMEDIA (IFM_ETHER|IFM_10_2) - struct cfdriver ec_cd = { NULL, "ec", DV_IFNET }; @@ -420,6 +415,8 @@ ec_attach(parent, self, aux) sc->write_mbuf = ec_write_mbuf; sc->read_hdr = ec_read_hdr; + sc->sc_media_init = ec_media_init; + sc->sc_mediachange = ec_mediachange; sc->sc_mediastatus = ec_mediastatus; @@ -427,7 +424,7 @@ ec_attach(parent, self, aux) sc->mem_size = memsize; /* Do generic parts of attach. */ - if (dp8390_config(sc, ec_media, NEC_MEDIA, EC_DEFMEDIA)) { + if (dp8390_config(sc)) { printf("%s: configuration failed\n", sc->sc_dev.dv_xname); return; } @@ -758,6 +755,15 @@ ec_read_hdr(sc, packet_ptr, packet_hdrp) #endif } +void +ec_media_init(struct dp8390_softc *sc) +{ + ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus); + ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_10_2, 0, NULL); + ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_10_5, 0, NULL); + ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_10_2); +} + int ec_mediachange(sc) struct dp8390_softc *sc; diff --git a/sys/dev/isa/if_ne_isa.c b/sys/dev/isa/if_ne_isa.c index 76484db6f86..025ae84abdb 100644 --- a/sys/dev/isa/if_ne_isa.c +++ b/sys/dev/isa/if_ne_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ne_isa.c,v 1.4 1999/04/30 07:20:29 fgsch Exp $ */ +/* $OpenBSD: if_ne_isa.c,v 1.5 2001/03/12 05:36:59 aaron Exp $ */ /* $NetBSD: if_ne_isa.c,v 1.6 1998/07/05 06:49:13 jonathan Exp $ */ /*- @@ -170,17 +170,10 @@ ne_isa_attach(parent, self, aux) bus_space_handle_t nich; bus_space_tag_t asict = nict; bus_space_handle_t asich; - void (*npp_init_media) __P((struct dp8390_softc *, int **, - int *, int *)); - int *media, nmedia, defmedia; const char *typestr; printf("\n"); - npp_init_media = NULL; - media = NULL; - nmedia = defmedia = 0; - /* Map i/o space. */ if (bus_space_map(nict, ia->ia_iobase, NE2000_NPORTS, 0, &nich)) { printf("%s: can't map i/o space\n", dsc->sc_dev.dv_xname); @@ -216,10 +209,10 @@ ne_isa_attach(parent, self, aux) bus_space_read_1(nict, nich, NERTL_RTL0_8019ID1) == RTL0_8019ID1) { typestr = "NE2000 (RTL8019)"; - npp_init_media = rtl80x9_init_media; dsc->sc_mediachange = rtl80x9_mediachange; dsc->sc_mediastatus = rtl80x9_mediastatus; dsc->init_card = rtl80x9_init_card; + dsc->sc_media_init = rtl80x9_media_init; } break; @@ -230,10 +223,6 @@ ne_isa_attach(parent, self, aux) printf("%s: %s Ethernet\n", dsc->sc_dev.dv_xname, typestr); - /* Initialize media, if we have it. */ - if (npp_init_media != NULL) - (*npp_init_media)(dsc, &media, &nmedia, &defmedia); - /* This interface is always enabled. */ dsc->sc_enabled = 1; @@ -241,7 +230,7 @@ ne_isa_attach(parent, self, aux) * Do generic NE2000 attach. This will read the station address * from the EEPROM. */ - ne2000_attach(nsc, NULL, media, nmedia, defmedia); + ne2000_attach(nsc, NULL); /* Establish the interrupt handler. */ isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, diff --git a/sys/dev/isa/if_ne_isapnp.c b/sys/dev/isa/if_ne_isapnp.c index 5c336bc725b..eacb4830aa1 100644 --- a/sys/dev/isa/if_ne_isapnp.c +++ b/sys/dev/isa/if_ne_isapnp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ne_isapnp.c,v 1.3 1999/03/26 06:34:27 fgsch Exp $ */ +/* $OpenBSD: if_ne_isapnp.c,v 1.4 2001/03/12 05:37:00 aaron Exp $ */ /* $NetBSD: if_ne_isapnp.c,v 1.7 1998/07/23 19:30:45 christos Exp $ */ /*- @@ -135,18 +135,11 @@ ne_isapnp_attach( bus_space_handle_t nich; bus_space_tag_t asict; bus_space_handle_t asich; - void (*npp_init_media) __P((struct dp8390_softc *, int **, - int *, int *)); - int *media, nmedia, defmedia; const char *typestr; int netype; printf("\n"); - npp_init_media = NULL; - media = NULL; - nmedia = defmedia = 0; - nict = ipa->ia_iot; nich = ipa->ipa_io[0].h; @@ -186,10 +179,10 @@ ne_isapnp_attach( bus_space_read_1(nict, nich, NERTL_RTL0_8019ID1) == RTL0_8019ID1) { typestr = "NE2000 (RTL8019)"; - npp_init_media = rtl80x9_init_media; dsc->sc_mediachange = rtl80x9_mediachange; dsc->sc_mediastatus = rtl80x9_mediastatus; dsc->init_card = rtl80x9_init_card; + dsc->sc_media_init = rtl80x9_media_init; } break; @@ -200,10 +193,6 @@ ne_isapnp_attach( printf("%s: %s Ethernet\n", dsc->sc_dev.dv_xname, typestr); - /* Initialize media, if we have it. */ - if (npp_init_media != NULL) - (*npp_init_media)(dsc, &media, &nmedia, &defmedia); - /* This interface is always enabled. */ dsc->sc_enabled = 1; @@ -211,7 +200,7 @@ ne_isapnp_attach( * Do generic NE2000 attach. This will read the station address * from the EEPROM. */ - ne2000_attach(nsc, NULL, media, nmedia, defmedia); + ne2000_attach(nsc, NULL); /* Establish the interrupt handler. */ isc->sc_ih = isa_intr_establish(ipa->ia_ic, ipa->ipa_irq[0].num, diff --git a/sys/dev/isa/if_we.c b/sys/dev/isa/if_we.c index c1a6f2b9552..4bb11ff8fb1 100644 --- a/sys/dev/isa/if_we.c +++ b/sys/dev/isa/if_we.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_we.c,v 1.8 2000/04/03 07:43:53 deraadt Exp $ */ +/* $OpenBSD: if_we.c,v 1.9 2001/03/12 05:37:00 aaron Exp $ */ /* $NetBSD: if_we.c,v 1.11 1998/07/05 06:49:14 jonathan Exp $ */ /*- @@ -155,6 +155,8 @@ const char *we_params __P((bus_space_tag_t, bus_space_handle_t, u_int8_t *, bus_size_t *, int *, int *)); void we_set_media __P((struct we_softc *, int)); +void we_media_init __P((struct dp8390_softc *)); + int we_mediachange __P((struct dp8390_softc *)); void we_mediastatus __P((struct dp8390_softc *, struct ifmediareq *)); @@ -177,12 +179,6 @@ static const int we_790_irq[] = { }; #define NWE_790_IRQ (sizeof(we_790_irq) / sizeof(we_790_irq[0])) -int we_media[] = { - IFM_ETHER|IFM_10_2, - IFM_ETHER|IFM_10_5, -}; -#define NWE_MEDIA (sizeof(we_media) / sizeof(we_media[0])) - /* * Delay needed when switching 16-bit access to shared memory. */ @@ -528,31 +524,11 @@ we_attach(parent, self, aux) sc->sc_flags = self->dv_cfdata->cf_flags; /* Do generic parts of attach. */ - if (wsc->sc_type & WE_SOFTCONFIG) { - int defmedia = IFM_ETHER; - - if (sc->is790) { - x = bus_space_read_1(asict, asich, WE790_HWR); - bus_space_write_1(asict, asich, WE790_HWR, - x | WE790_HWR_SWH); - if (bus_space_read_1(asict, asich, WE790_GCR) & - WE790_GCR_GPOUT) - defmedia |= IFM_10_2; - else - defmedia |= IFM_10_5; - bus_space_write_1(asict, asich, WE790_HWR, - x & ~WE790_HWR_SWH); - } else { - x = bus_space_read_1(asict, asich, WE_IRR); - if (x & WE_IRR_OUT2) - defmedia |= IFM_10_2; - else - defmedia |= IFM_10_5; - } - i = dp8390_config(sc, we_media, NWE_MEDIA, defmedia); - } else - i = dp8390_config(sc, NULL, 0, 0); - if (i) { + if (wsc->sc_type & WE_SOFTCONFIG) + sc->sc_media_init = we_media_init; + else + sc->sc_media_init = dp8390_media_init; + if (dp8390_config(sc)) { printf("%s: configuration failed\n", sc->sc_dev.dv_xname); return; } @@ -812,6 +788,38 @@ we_recv_int(sc) WE_MEM_DISABLE(wsc); } +void +we_media_init(struct dp8390_softc *sc) +{ + struct we_softc *wsc = (void *)sc; + int defmedia = IFM_ETHER; + u_int8_t x; + + if (sc->is790) { + x = bus_space_read_1(wsc->sc_asict, wsc->sc_asich, WE790_HWR); + bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE790_HWR, + x | WE790_HWR_SWH); + if (bus_space_read_1(wsc->sc_asict, wsc->sc_asich, WE790_GCR) & + WE790_GCR_GPOUT) + defmedia |= IFM_10_2; + else + defmedia |= IFM_10_5; + bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE790_HWR, + x &~ WE790_HWR_SWH); + } else { + x = bus_space_read_1(wsc->sc_asict, wsc->sc_asich, WE_IRR); + if (x & WE_IRR_OUT2) + defmedia |= IFM_10_2; + else + defmedia |= IFM_10_5; + } + + ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus); + ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_10_2, 0, NULL); + ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_10_5, 0, NULL); + ifmedia_set(&sc->sc_media, defmedia); +} + int we_mediachange(sc) struct dp8390_softc *sc; diff --git a/sys/dev/pci/if_ne_pci.c b/sys/dev/pci/if_ne_pci.c index 32cd4ffc11c..5bd92585fa9 100644 --- a/sys/dev/pci/if_ne_pci.c +++ b/sys/dev/pci/if_ne_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ne_pci.c,v 1.7 2000/04/03 21:13:48 deraadt Exp $ */ +/* $OpenBSD: if_ne_pci.c,v 1.8 2001/03/12 05:37:00 aaron Exp $ */ /* $NetBSD: if_ne_pci.c,v 1.8 1998/07/05 00:51:24 jonathan Exp $ */ /*- @@ -69,6 +69,8 @@ #include <dev/pci/pcivar.h> #include <dev/pci/pcidevs.h> +#include <dev/mii/miivar.h> + #include <dev/ic/dp8390reg.h> #include <dev/ic/dp8390var.h> @@ -99,12 +101,11 @@ const struct ne_pci_product { void (*npp_mediastatus) __P((struct dp8390_softc *, struct ifmediareq *)); void (*npp_init_card) __P((struct dp8390_softc *)); - void (*npp_init_media) __P((struct dp8390_softc *, int **, - int *, int *)); + void (*npp_media_init) __P((struct dp8390_softc *)); } ne_pci_prod[] = { { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8029, rtl80x9_mediachange, rtl80x9_mediastatus, - rtl80x9_init_card, rtl80x9_init_media, + rtl80x9_init_card, rtl80x9_media_init, /* RealTek 8029 */ }, { PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W89C940F, @@ -203,7 +204,6 @@ ne_pci_attach(parent, self, aux) const struct ne_pci_product *npp; pci_intr_handle_t ih; pcireg_t csr; - int *media, nmedia, defmedia; npp = ne_pci_lookup(pa); if (npp == NULL) { @@ -253,17 +253,9 @@ ne_pci_attach(parent, self, aux) /* This interface is always enabled. */ dsc->sc_enabled = 1; - if (npp->npp_init_media != NULL) { - (*npp->npp_init_media)(dsc, &media, &nmedia, &defmedia); - dsc->sc_mediachange = npp->npp_mediachange; - dsc->sc_mediastatus = npp->npp_mediastatus; - } else { - media = NULL; - nmedia = 0; - defmedia = 0; - } - - /* Always fill in init_card; it might be used for non-media stuff. */ + dsc->sc_mediachange = npp->npp_mediachange; + dsc->sc_mediastatus = npp->npp_mediastatus; + dsc->sc_media_init = npp->npp_media_init; dsc->init_card = npp->npp_init_card; /* Map and establish the interrupt. */ @@ -288,5 +280,5 @@ ne_pci_attach(parent, self, aux) * Do generic NE2000 attach. This will read the station address * from the EEPROM. */ - ne2000_attach(nsc, NULL, media, nmedia, defmedia); + ne2000_attach(nsc, NULL); } diff --git a/sys/dev/pcmcia/if_ne_pcmcia.c b/sys/dev/pcmcia/if_ne_pcmcia.c index b158cb98396..7a525b95453 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.35 2001/02/27 08:41:51 fgsch Exp $ */ +/* $OpenBSD: if_ne_pcmcia.c,v 1.36 2001/03/12 05:37:01 aaron Exp $ */ /* $NetBSD: if_ne_pcmcia.c,v 1.17 1998/08/15 19:00:04 thorpej Exp $ */ /* @@ -443,13 +443,6 @@ ne_pcmcia_attach(parent, self, aux) const struct ne2000dev *ne_dev; int i; u_int8_t myea[6], *enaddr; - void (*npp_init_media) __P((struct dp8390_softc *, int **, - int *, int *)); - int *media, nmedia, defmedia; - - npp_init_media = NULL; - media = NULL; - nmedia = defmedia = 0; psc->sc_pf = pa->pf; @@ -610,10 +603,10 @@ again: == RTL0_8019ID0 && bus_space_read_1(dsc->sc_regt, dsc->sc_regh, NERTL_RTL0_8019ID1) == RTL0_8019ID1) { - npp_init_media = rtl80x9_init_media; dsc->sc_mediachange = rtl80x9_mediachange; dsc->sc_mediastatus = rtl80x9_mediastatus; dsc->init_card = rtl80x9_init_card; + dsc->sc_media_init = rtl80x9_media_init; } /* set up the interrupt */ @@ -624,11 +617,7 @@ again: printf("\n"); - /* Initialize media, if we have it. */ - if (npp_init_media != NULL) - (*npp_init_media)(dsc, &media, &nmedia, &defmedia); - - if (ne2000_attach(nsc, enaddr, media, nmedia, defmedia)) + if (ne2000_attach(nsc, enaddr)) goto fail_5; #if notyet |