Adjust the way that media is initialized on DP8390-compatible

chips.  The dp8390_softc now has media_init and media_fini
function pointers that do the work.
This commit is contained in:
thorpej 2001-02-12 18:49:03 +00:00
parent faec1fc4fc
commit 043e519d55
16 changed files with 160 additions and 167 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ne_zbus.c,v 1.6 2000/12/29 22:39:29 is Exp $ */
/* $NetBSD: if_ne_zbus.c,v 1.7 2001/02/12 18:49:03 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -127,14 +127,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;
zsc->sc_bst.base = (u_long)zap->va + 0;
if (zap->manid == 4626)
@ -162,9 +159,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;
@ -172,7 +166,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;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_eh.c,v 1.11 2001/01/23 22:07:59 bjh21 Exp $ */
/* $NetBSD: if_eh.c,v 1.12 2001/02/12 18:49:03 thorpej Exp $ */
/*-
* Copyright (c) 2000 Ben Harris
@ -53,7 +53,7 @@
#include <sys/param.h>
__KERNEL_RCSID(0, "$NetBSD: if_eh.c,v 1.11 2001/01/23 22:07:59 bjh21 Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_eh.c,v 1.12 2001/02/12 18:49:03 thorpej Exp $");
#include <sys/systm.h>
#include <sys/device.h>
@ -110,6 +110,7 @@ struct eh_softc {
#define EHF_16BIT 0x01
#define EHF_MAU 0x02
int sc_type;
int sc_mediaset;
u_int8_t sc_ctrl; /* Current control reg state */
};
@ -124,6 +125,8 @@ static void eh_init_card(struct dp8390_softc *);
static int eh_availmedia(struct eh_softc *);
/*static*/ int eh_identifymau(struct eh_softc *);
void eh_media_init(struct dp8390_softc *);
/* if_media glue */
static int eh_mediachange(struct dp8390_softc *);
static void eh_mediastatus(struct dp8390_softc *, struct ifmediareq *);
@ -173,8 +176,7 @@ eh_attach(struct device *parent, struct device *self, void *aux)
struct podulebus_attach_args *pa = aux;
struct eh_softc *sc = (struct eh_softc *)self;
struct dp8390_softc *dsc = &sc->sc_dp;
int *media;
int mediaset, mautype, nmedia;
int mediaset, mautype;
int i;
char *ptr;
u_int8_t *myaddr;
@ -245,6 +247,8 @@ eh_attach(struct device *parent, struct device *self, void *aux)
/* dsc->sc_disable */
dsc->sc_mediachange = eh_mediachange;
dsc->sc_mediastatus = eh_mediastatus;
dsc->sc_media_init = eh_media_init;
/* dsc->sc_media_fini */
for (i = 0; i < 16; i++)
dsc->sc_reg_map[i] = i;
@ -281,8 +285,7 @@ eh_attach(struct device *parent, struct device *self, void *aux)
break;
}
}
media = media_switch[mediaset].media;
nmedia = media_switch[mediaset].nmedia;
sc->sc_mediaset = mediaset;
printf("\n");
/* i-cubed put everything behind the loader. */
@ -312,7 +315,7 @@ eh_attach(struct device *parent, struct device *self, void *aux)
}
}
dp8390_config(dsc, media, nmedia, media[0]);
dp8390_config(dsc);
dp8390_stop(dsc);
evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
@ -773,6 +776,19 @@ eh_identifymau(struct eh_softc *sc)
return id;
}
void
eh_init_media(struct dp8390_softc *dsc)
{
struct eh_softc *sc = (struct eh_softc *) dsc;
int i;
ifmedia_init(&dsc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus);
for (i = 0; i < media_switch[sc->sc_mediaset].nmedia; i++)
ifmedia_add(&dsc->sc_media,
media_switch[sc->sc_mediaset].media[i], 0, NULL);
ifmedia_set(&dsc->sc_media, media_switch[sc->sc_mediaset].media[0]);
}
/*
* Medium selection has changed.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ae_nubus.c,v 1.30 2000/07/30 21:40:09 briggs Exp $ */
/* $NetBSD: if_ae_nubus.c,v 1.31 2001/02/12 18:49:03 thorpej Exp $ */
/*
* Copyright (C) 1997 Scott Reynolds
@ -368,13 +368,14 @@ ae_nubus_attach(parent, self, aux)
#ifdef DEBUG
ifp->if_watchdog = ae_nb_watchdog; /* Override watchdog */
#endif
sc->sc_media_init = dp8390_media_init;
/* Interface is always enabled. */
sc->sc_enabled = 1;
printf(": %s, %dKB memory\n", cardtype, sc->mem_size / 1024);
if (dp8390_config(sc, NULL, 0, 0)) {
if (dp8390_config(sc)) {
bus_space_unmap(bst, bsh, NBMEMSIZE);
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ne_neptune.c,v 1.2 1999/03/16 16:30:18 minoura Exp $ */
/* $NetBSD: if_ne_neptune.c,v 1.3 2001/02/12 18:49:03 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -146,9 +146,6 @@ ne_neptune_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;
int netype;
@ -198,10 +195,10 @@ ne_neptune_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;
@ -212,10 +209,6 @@ ne_neptune_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;
@ -223,7 +216,7 @@ ne_neptune_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. */
if (neptune_intr_establish(na->na_intr, "ne", ne_neptune_intr, dsc))

View File

@ -1,4 +1,4 @@
/* $NetBSD: dp8390.c,v 1.41 2000/12/14 06:27:24 thorpej Exp $ */
/* $NetBSD: dp8390.c,v 1.42 2001/02/12 18:49:03 thorpej Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@ -80,21 +80,29 @@ static __inline__ int dp8390_write_mbuf __P((struct dp8390_softc *,
static int dp8390_test_mem __P((struct dp8390_softc *));
int dp8390_mediachange __P((struct ifnet *));
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_ec.ec_if;
int i, rv;
int rv;
rv = 1;
@ -135,15 +143,8 @@ dp8390_config(sc, media, nmedia, defmedia)
IFQ_SET_READY(&ifp->if_snd);
/* 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);
/*
* We can support 802.1Q VLAN-sized frames.
@ -1327,7 +1328,10 @@ dp8390_detach(sc, flags)
/* dp8390_disable() checks sc->sc_enabled */
dp8390_disable(sc);
/* Delete all media. */
if (sc->sc_media_fini != NULL)
(*sc->sc_media_fini)(sc);
/* Delete all remaining media. */
ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
#if NRND > 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: dp8390var.h,v 1.21 2001/02/10 17:18:02 thorpej Exp $ */
/* $NetBSD: dp8390var.h,v 1.22 2001/02/12 18:49:04 thorpej Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@ -87,6 +87,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 *));
@ -151,7 +154,7 @@ struct dp8390_softc {
#define NIC_BARRIER(t, h) bus_space_barrier(t, h, 0, 0x10, \
BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
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 *));
@ -173,6 +176,11 @@ int dp8390_activate __P((struct device *, enum devact));
int dp8390_detach __P((struct dp8390_softc *, int));
int dp8390_mediachange __P((struct ifnet *));
void dp8390_mediastatus __P((struct ifnet *, struct ifmediareq *));
void dp8390_media_init __P((struct dp8390_softc *));
#ifdef IPKDB_DP8390
int dp8390_ipkdb_attach __P((struct ipkdb_if *));
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: ne2000.c,v 1.31 2000/12/11 17:07:38 ws Exp $ */
/* $NetBSD: ne2000.c,v 1.32 2001/02/12 18:49:04 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -105,10 +105,9 @@ void ne2000_readmem __P((bus_space_tag_t, bus_space_handle_t,
bus_space_tag_t, bus_space_handle_t, int, u_int8_t *, size_t, int));
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;
@ -282,7 +281,10 @@ ne2000_attach(nsc, myea, media, nmedia, defmedia)
bus_space_write_1(nict, nich, ED_P0_ISR, 0xff);
NIC_BARRIER(nict, nich);
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);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ne2000var.h,v 1.12 2001/02/10 16:09:55 thorpej Exp $ */
/* $NetBSD: ne2000var.h,v 1.13 2001/02/12 18:49:04 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -62,8 +62,7 @@ struct ne2000_softc {
((sc)->sc_type == NE2000_TYPE_DL10022) || \
((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((bus_space_tag_t, bus_space_handle_t,
bus_space_tag_t, bus_space_handle_t));
int ne2000_detach __P((struct ne2000_softc *, int));

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtl80x9.c,v 1.4 2000/04/28 17:49:03 is Exp $ */
/* $NetBSD: rtl80x9.c,v 1.5 2001/02/12 18:49:04 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -168,9 +168,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,
@ -178,12 +177,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]);
printf("%s: 10base2, 10baseT, 10baseT-FDX, auto, default ",
sc->sc_dev.dv_xname);
@ -197,26 +196,31 @@ rtl80x9_init_media(sc, mediap, nmediap, defmediap)
switch (conf2) {
case 0:
*defmediap = IFM_ETHER|IFM_AUTO;
defmedia = IFM_ETHER|IFM_AUTO;
printf("auto\n");
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;
printf("10base2\n");
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;
printf("10baseT-FDX\n");
} else {
*defmediap = IFM_ETHER|IFM_10_T;
defmedia = IFM_ETHER|IFM_10_T;
printf("10baseT\n");
}
break;
}
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);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtl80x9var.h,v 1.1 1998/10/31 00:44:33 thorpej Exp $ */
/* $NetBSD: rtl80x9var.h,v 1.2 2001/02/12 18:49:04 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -53,8 +53,8 @@ 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_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ec.c,v 1.11 1999/03/23 21:41:08 drochner Exp $ */
/* $NetBSD: if_ec.c,v 1.12 2001/02/12 18:49:04 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -122,6 +122,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 *));
@ -145,13 +147,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)
int
ec_probe(parent, match, aux)
struct device *parent;
@ -410,6 +405,8 @@ ec_attach(parent, self, aux)
sc->read_hdr = ec_read_hdr;
sc->init_card = ec_init_card;
sc->sc_media_init = ec_media_init;
sc->sc_mediachange = ec_mediachange;
sc->sc_mediastatus = ec_mediastatus;
@ -417,7 +414,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;
}
@ -743,6 +740,16 @@ 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;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ne_isa.c,v 1.9 1998/11/01 01:04:48 christos Exp $ */
/* $NetBSD: if_ne_isa.c,v 1.10 2001/02/12 18:49:04 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -158,18 +158,11 @@ 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;
int netype;
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);
@ -210,10 +203,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;
@ -224,10 +217,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;
@ -235,7 +224,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,

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_we.c,v 1.15 1999/03/28 12:51:49 tron Exp $ */
/* $NetBSD: if_we.c,v 1.16 2001/02/12 18:49:04 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -139,6 +139,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 *));
@ -161,12 +163,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.
*/
@ -506,31 +502,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;
}
@ -785,6 +761,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;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ne_isapnp.c,v 1.11 1999/03/22 10:00:12 mycroft Exp $ */
/* $NetBSD: if_ne_isapnp.c,v 1.12 2001/02/12 18:49:04 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -134,18 +134,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;
if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
printf("%s: can't configure isapnp resources\n",
dsc->sc_dev.dv_xname);
@ -191,10 +184,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;
@ -205,10 +198,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;
@ -216,7 +205,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->ipa_ic, ipa->ipa_irq[0].num,

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ne_pci.c,v 1.17 2000/12/28 22:59:13 sommerfeld Exp $ */
/* $NetBSD: if_ne_pci.c,v 1.18 2001/02/12 18:49:05 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -110,13 +110,12 @@ 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 *));
const char *npp_name;
} ne_pci_products[] = {
{ 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,
@ -221,7 +220,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) {
@ -266,24 +264,16 @@ 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;
/*
* Do generic NE2000 attach. This will read the station address
* from the EEPROM.
*/
ne2000_attach(nsc, NULL, media, nmedia, defmedia);
ne2000_attach(nsc, NULL);
/* Map and establish the interrupt. */
if (pci_intr_map(pa, &ih)) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ne_pcmcia.c,v 1.67 2001/01/18 20:28:26 jdolecek Exp $ */
/* $NetBSD: if_ne_pcmcia.c,v 1.68 2001/02/12 18:49:05 thorpej Exp $ */
/*
* Copyright (c) 1997 Marc Horowitz. All rights reserved.
@ -495,15 +495,8 @@ 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;
const char *typestr = "";
npp_init_media = NULL;
media = NULL;
nmedia = defmedia = 0;
psc->sc_pf = pa->pf;
for (cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); cfe != NULL;
@ -674,20 +667,16 @@ again:
bus_space_read_1(dsc->sc_regt, dsc->sc_regh, NERTL_RTL0_8019ID1)
== RTL0_8019ID1) {
typestr = " (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;
}
printf("%s: %s%s Ethernet\n", dsc->sc_dev.dv_xname, ne_dev->name,
typestr);
/* 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;
pcmcia_function_disable(pa->pf);