convert to device_t.
been running on my inspiron 8500 for a couple of months.
This commit is contained in:
parent
25c2f01c4f
commit
aef481556c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_bce.c,v 1.35 2012/02/02 19:43:05 tls Exp $ */
|
||||
/* $NetBSD: if_bce.c,v 1.36 2012/02/20 02:14:34 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Clifford Wright. All rights reserved.
|
||||
|
@ -35,7 +35,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.35 2012/02/02 19:43:05 tls Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.36 2012/02/20 02:14:34 mrg Exp $");
|
||||
|
||||
#include "vlan.h"
|
||||
|
||||
|
@ -114,7 +114,7 @@ struct bce_chain_data {
|
|||
#define BCE_TIMEOUT 100 /* # 10us for mii read/write */
|
||||
|
||||
struct bce_softc {
|
||||
struct device bce_dev;
|
||||
device_t bce_dev;
|
||||
bus_space_tag_t bce_btag;
|
||||
bus_space_handle_t bce_bhandle;
|
||||
bus_dma_tag_t bce_dmatag;
|
||||
|
@ -179,7 +179,8 @@ static void bce_mii_write(device_t, int, int, int);
|
|||
static void bce_statchg(device_t);
|
||||
static void bce_tick(void *);
|
||||
|
||||
CFATTACH_DECL(bce, sizeof(struct bce_softc), bce_probe, bce_attach, NULL, NULL);
|
||||
CFATTACH_DECL_NEW(bce, sizeof(struct bce_softc),
|
||||
bce_probe, bce_attach, NULL, NULL);
|
||||
|
||||
static const struct bce_product {
|
||||
pci_vendor_id_t bp_vendor;
|
||||
|
@ -251,6 +252,8 @@ bce_attach(device_t parent, device_t self, void *aux)
|
|||
int error, i, pmreg, rseg;
|
||||
struct ifnet *ifp;
|
||||
|
||||
sc->bce_dev = self;
|
||||
|
||||
bp = bce_lookup(pa);
|
||||
KASSERT(bp != NULL);
|
||||
|
||||
|
@ -419,7 +422,7 @@ bce_attach(device_t parent, device_t self, void *aux)
|
|||
sc->ethercom.ec_mii = &sc->bce_mii;
|
||||
ifmedia_init(&sc->bce_mii.mii_media, 0, ether_mediachange,
|
||||
ether_mediastatus);
|
||||
mii_attach(&sc->bce_dev, &sc->bce_mii, 0xffffffff, MII_PHY_ANY,
|
||||
mii_attach(sc->bce_dev, &sc->bce_mii, 0xffffffff, MII_PHY_ANY,
|
||||
MII_OFFSET_ANY, MIIF_FORCEANEG|MIIF_DOPAUSE);
|
||||
if (LIST_FIRST(&sc->bce_mii.mii_phys) == NULL) {
|
||||
ifmedia_add(&sc->bce_mii.mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
|
||||
|
@ -433,11 +436,11 @@ bce_attach(device_t parent, device_t self, void *aux)
|
|||
* Enable activity led.
|
||||
* XXX This should be in a phy driver, but not currently.
|
||||
*/
|
||||
bce_mii_write(&sc->bce_dev, 1, 26, /* MAGIC */
|
||||
bce_mii_read(&sc->bce_dev, 1, 26) & 0x7fff); /* MAGIC */
|
||||
bce_mii_write(sc->bce_dev, 1, 26, /* MAGIC */
|
||||
bce_mii_read(sc->bce_dev, 1, 26) & 0x7fff); /* MAGIC */
|
||||
/* enable traffic meter led mode */
|
||||
bce_mii_write(&sc->bce_dev, 1, 27, /* MAGIC */
|
||||
bce_mii_read(&sc->bce_dev, 1, 27) | (1 << 6)); /* MAGIC */
|
||||
bce_mii_write(sc->bce_dev, 1, 27, /* MAGIC */
|
||||
bce_mii_read(sc->bce_dev, 1, 27) | (1 << 6)); /* MAGIC */
|
||||
|
||||
/* Attach the interface */
|
||||
if_attach(ifp);
|
||||
|
@ -537,7 +540,7 @@ bce_start(struct ifnet *ifp)
|
|||
error = bus_dmamap_load_mbuf(sc->bce_dmatag, dmamap, m0,
|
||||
BUS_DMA_WRITE | BUS_DMA_NOWAIT);
|
||||
if (error == EFBIG) {
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"Tx packet consumes too many DMA segments, "
|
||||
"dropping...\n");
|
||||
IFQ_DEQUEUE(&ifp->if_snd, m0);
|
||||
|
@ -546,7 +549,7 @@ bce_start(struct ifnet *ifp)
|
|||
continue;
|
||||
} else if (error) {
|
||||
/* short on resources, come back later */
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"unable to load Tx buffer, error = %d\n",
|
||||
error);
|
||||
break;
|
||||
|
@ -637,7 +640,7 @@ bce_watchdog(struct ifnet *ifp)
|
|||
{
|
||||
struct bce_softc *sc = ifp->if_softc;
|
||||
|
||||
aprint_error_dev(&sc->bce_dev, "device timeout\n");
|
||||
aprint_error_dev(sc->bce_dev, "device timeout\n");
|
||||
ifp->if_oerrors++;
|
||||
|
||||
(void) bce_init(ifp);
|
||||
|
@ -699,7 +702,7 @@ bce_intr(void *xsc)
|
|||
if (intstatus & I_TO)
|
||||
msg = "general purpose timeout";
|
||||
if (msg != NULL)
|
||||
aprint_error_dev(&sc->bce_dev, "%s\n", msg);
|
||||
aprint_error_dev(sc->bce_dev, "%s\n", msg);
|
||||
wantinit = 1;
|
||||
}
|
||||
}
|
||||
|
@ -954,7 +957,7 @@ bce_init(struct ifnet *ifp)
|
|||
for (i = 0; i < BCE_NRXDESC; i++) {
|
||||
if (sc->bce_cdata.bce_rx_chain[i] == NULL) {
|
||||
if ((error = bce_add_rxbuf(sc, i)) != 0) {
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"unable to allocate or map rx(%d) "
|
||||
"mbuf, error = %d\n", i, error);
|
||||
bce_rxdrain(sc);
|
||||
|
@ -1015,7 +1018,7 @@ bce_add_mac(struct bce_softc *sc, uint8_t *mac, u_long idx)
|
|||
delay(10);
|
||||
}
|
||||
if (i == 100) {
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"timed out writing pkt filter ctl\n");
|
||||
}
|
||||
}
|
||||
|
@ -1152,7 +1155,7 @@ bce_reset(struct bce_softc *sc)
|
|||
delay(10);
|
||||
}
|
||||
if (i == 200) {
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"timed out disabling ethernet mac\n");
|
||||
}
|
||||
|
||||
|
@ -1169,7 +1172,7 @@ bce_reset(struct bce_softc *sc)
|
|||
delay(10);
|
||||
}
|
||||
if (i == 100) {
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"receive dma did not go idle after"
|
||||
" error\n");
|
||||
}
|
||||
|
@ -1188,7 +1191,7 @@ bce_reset(struct bce_softc *sc)
|
|||
delay(10);
|
||||
}
|
||||
if (i == 200) {
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"timed out resetting ethernet mac\n");
|
||||
}
|
||||
} else {
|
||||
|
@ -1234,7 +1237,7 @@ bce_reset(struct bce_softc *sc)
|
|||
delay(1);
|
||||
}
|
||||
if (i == 200) {
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"while resetting core, reject did not set\n");
|
||||
}
|
||||
/* wait until busy is clear */
|
||||
|
@ -1246,7 +1249,7 @@ bce_reset(struct bce_softc *sc)
|
|||
delay(1);
|
||||
}
|
||||
if (i == 200) {
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"while resetting core, busy did not clear\n");
|
||||
}
|
||||
/* set reset and reject while enabling the clocks */
|
||||
|
@ -1386,7 +1389,7 @@ bce_mii_read(device_t self, int phy, int reg)
|
|||
}
|
||||
val = bus_space_read_4(sc->bce_btag, sc->bce_bhandle, BCE_MI_COMM);
|
||||
if (i == BCE_TIMEOUT) {
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"PHY read timed out reading phy %d, reg %d, val = "
|
||||
"0x%08x\n", phy, reg, val);
|
||||
return (0);
|
||||
|
@ -1422,7 +1425,7 @@ bce_mii_write(device_t self, int phy, int reg, int val)
|
|||
}
|
||||
rval = bus_space_read_4(sc->bce_btag, sc->bce_bhandle, BCE_MI_COMM);
|
||||
if (i == BCE_TIMEOUT) {
|
||||
aprint_error_dev(&sc->bce_dev,
|
||||
aprint_error_dev(sc->bce_dev,
|
||||
"PHY timed out writing phy %d, reg %d, val = 0x%08x\n", phy,
|
||||
reg, val);
|
||||
}
|
||||
|
@ -1448,11 +1451,11 @@ bce_statchg(device_t self)
|
|||
* Enable activity led.
|
||||
* XXX This should be in a phy driver, but not currently.
|
||||
*/
|
||||
bce_mii_write(&sc->bce_dev, 1, 26, /* MAGIC */
|
||||
bce_mii_read(&sc->bce_dev, 1, 26) & 0x7fff); /* MAGIC */
|
||||
bce_mii_write(sc->bce_dev, 1, 26, /* MAGIC */
|
||||
bce_mii_read(sc->bce_dev, 1, 26) & 0x7fff); /* MAGIC */
|
||||
/* enable traffic meter led mode */
|
||||
bce_mii_write(&sc->bce_dev, 1, 26, /* MAGIC */
|
||||
bce_mii_read(&sc->bce_dev, 1, 27) | (1 << 6)); /* MAGIC */
|
||||
bce_mii_write(sc->bce_dev, 1, 26, /* MAGIC */
|
||||
bce_mii_read(sc->bce_dev, 1, 27) | (1 << 6)); /* MAGIC */
|
||||
}
|
||||
|
||||
/* One second timer, checks link status */
|
||||
|
|
Loading…
Reference in New Issue