Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/sys/dev/pci Pull up revision 1.3 (requested by mrg in t...
details: https://anonhg.NetBSD.org/src/rev/4d97c3f8c91c
branches: netbsd-1-6
changeset: 530827:4d97c3f8c91c
user: tron <tron%NetBSD.org@localhost>
date: Sun Oct 05 11:55:52 2003 +0000
description:
Pull up revision 1.3 (requested by mrg in ticket #1486):
- convert to new aprint*() autoconfig print mechanism
- clean up some magic numbers
- make 1.6 friendly
diffstat:
sys/dev/pci/if_bce.c | 118 ++++++++++++++++++++---------------------------
sys/dev/pci/if_bcereg.h | 29 ++++++++---
2 files changed, 71 insertions(+), 76 deletions(-)
diffs (283 lines):
diff -r 7a138da5f72b -r 4d97c3f8c91c sys/dev/pci/if_bce.c
--- a/sys/dev/pci/if_bce.c Sun Oct 05 11:54:43 2003 +0000
+++ b/sys/dev/pci/if_bce.c Sun Oct 05 11:55:52 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bce.c,v 1.3.2.3 2003/10/05 11:51:16 tron Exp $ */
+/* $NetBSD: if_bce.c,v 1.3.2.4 2003/10/05 11:55:52 tron Exp $ */
/*
* Copyright (c) 2003 Clifford Wright. All rights reserved.
@@ -195,13 +195,21 @@
#define DPRINTFN(n,x)
#endif
-#ifdef OLDNETBSD
+#if __NetBSD_Version__ >= 106080000
+CFATTACH_DECL(bce, sizeof(struct bce_softc),
+ bce_probe, bce_attach, NULL, NULL);
+#else
struct cfattach bce_ca = {
sizeof(struct bce_softc), bce_probe, bce_attach
};
+#endif
+
+#if __NetBSD_Version__ >= 106120000
+#define APRINT_ERROR aprint_error
+#define APRINT_NORMAL aprint_normal
#else
-CFATTACH_DECL(bce, sizeof(struct bce_softc),
- bce_probe, bce_attach, NULL, NULL);
+#define APRINT_ERROR printf
+#define APRINT_NORMAL printf
#endif
@@ -284,11 +292,10 @@
sc->bce_pa = *pa;
sc->bce_dmatag = pa->pa_dmat;
- printf(": %s\n", bp->bp_name);
- /*
- * following is for new aprint_naive(": Ethernet controller\n");
- * aprint_normal(": %s\n", bp->bp_name);
- */
+#if __NetBSD_Version__ >= 106120000
+ aprint_naive(": Ethernet controller\n");
+#endif
+ APRINT_NORMAL(": %s\n", bp->bp_name);
/*
* Map control/status registers.
@@ -299,12 +306,8 @@
command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
if (!(command & PCI_COMMAND_MEM_ENABLE)) {
- printf("%s: failed to enable memory mapping!\n",
- /*
- * following line for new aprint_error("%s: failed to enable
- * memory mapping!\n",
- */
- sc->bce_dev.dv_xname);
+ APRINT_ERROR("%s: failed to enable memory mapping!\n",
+ sc->bce_dev.dv_xname);
return;
}
memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, BCE_PCI_BAR0);
@@ -315,12 +318,8 @@
&sc->bce_bhandle, &memaddr, &memsize) == 0)
break;
default:
- printf("%s: unable to find mem space\n",
- /*
- * following for new aprint_error("%s: unable to find mem
- * space\n",
- */
- sc->bce_dev.dv_xname);
+ APRINT_ERROR("%s: unable to find mem space\n",
+ sc->bce_dev.dv_xname);
return;
}
@@ -343,12 +342,8 @@
}
}
if (pci_intr_map(pa, &ih)) {
- printf("%s: couldn't map interrupt\n",
- /*
- * following for new aprint_error("%s: couldn't map
- * interrupt\n",
- */
- sc->bce_dev.dv_xname);
+ APRINT_ERROR("%s: couldn't map interrupt\n",
+ sc->bce_dev.dv_xname);
return;
}
intrstr = pci_intr_string(pc, ih);
@@ -356,28 +351,15 @@
sc->bce_intrhand = pci_intr_establish(pc, ih, IPL_NET, bce_intr, sc);
if (sc->bce_intrhand == NULL) {
- printf("%s: couldn't establish interrupt",
- /*
- * following for new aprint_error("%s: couldn't establish
- * interrupt",
- */
- sc->bce_dev.dv_xname);
+ APRINT_ERROR("%s: couldn't establish interrupt",
+ sc->bce_dev.dv_xname);
if (intrstr != NULL)
- printf(" at %s", intrstr);
- /*
- * following for new aprint_normal(" at %s", intrstr);
- */
- printf("\n");
- /*
- * following for new aprint_normal("\n");
- */
+ APRINT_NORMAL(" at %s", intrstr);
+ APRINT_NORMAL("\n");
return;
}
- printf("%s: interrupting at %s\n",
- /*
- * following for new aprint_normal("%s: interrupting at %s\n",
- */
- sc->bce_dev.dv_xname, intrstr);
+ APRINT_NORMAL("%s: interrupting at %s\n",
+ sc->bce_dev.dv_xname, intrstr);
/* reset the chip */
bce_reset(sc);
@@ -389,7 +371,7 @@
*/
/*
* XXX PAGE_SIZE is wasteful; we only need 1KB + 1KB, but
- * due to the limition above.
+ * due to the limition above. ??
*/
if ((error = bus_dmamem_alloc(sc->bce_dmatag,
2 * PAGE_SIZE, PAGE_SIZE, 2 * PAGE_SIZE,
@@ -476,33 +458,33 @@
} else
ifmedia_set(&sc->bce_mii.mii_media, IFM_ETHER | IFM_AUTO);
/* get the phy */
- sc->bce_phy =
- bus_space_read_1(sc->bce_btag, sc->bce_bhandle, 4096 + 90) & 0x1f; /* MAGIC */
+ sc->bce_phy = bus_space_read_1(sc->bce_btag, sc->bce_bhandle,
+ BCE_MAGIC_PHY) & 0x1f;
/*
* Enable activity led.
* XXX This should be in a phy driver, but not currently.
*/
bce_mii_write((struct device *) sc, 1, 26, /* MAGIC */
- bce_mii_read((struct device *) sc, 1, 26) & 0x7fff); /* MAGIC */
+ bce_mii_read((struct device *) sc, 1, 26) & 0x7fff); /* MAGIC */
/* enable traffic meter led mode */
bce_mii_write((struct device *) sc, 1, 26, /* MAGIC */
- bce_mii_read((struct device *) sc, 1, 27) | (1 << 6)); /* MAGIC */
+ bce_mii_read((struct device *) sc, 1, 27) | (1 << 6)); /* MAGIC */
/* Attach the interface */
if_attach(ifp);
- sc->enaddr[0] =
- bus_space_read_1(sc->bce_btag, sc->bce_bhandle, 4096 + 79); /* MAGIC */
- sc->enaddr[1] =
- bus_space_read_1(sc->bce_btag, sc->bce_bhandle, 4096 + 78); /* MAGIC */
- sc->enaddr[2] =
- bus_space_read_1(sc->bce_btag, sc->bce_bhandle, 4096 + 81); /* MAGIC */
- sc->enaddr[3] =
- bus_space_read_1(sc->bce_btag, sc->bce_bhandle, 4096 + 80); /* MAGIC */
- sc->enaddr[4] =
- bus_space_read_1(sc->bce_btag, sc->bce_bhandle, 4096 + 83); /* MAGIC */
- sc->enaddr[5] =
- bus_space_read_1(sc->bce_btag, sc->bce_bhandle, 4096 + 82); /* MAGIC */
+ sc->enaddr[0] = bus_space_read_1(sc->bce_btag, sc->bce_bhandle,
+ BCE_MAGIC_ENET0);
+ sc->enaddr[1] = bus_space_read_1(sc->bce_btag, sc->bce_bhandle,
+ BCE_MAGIC_ENET1);
+ sc->enaddr[2] = bus_space_read_1(sc->bce_btag, sc->bce_bhandle,
+ BCE_MAGIC_ENET2);
+ sc->enaddr[3] = bus_space_read_1(sc->bce_btag, sc->bce_bhandle,
+ BCE_MAGIC_ENET3);
+ sc->enaddr[4] = bus_space_read_1(sc->bce_btag, sc->bce_bhandle,
+ BCE_MAGIC_ENET4);
+ sc->enaddr[5] = bus_space_read_1(sc->bce_btag, sc->bce_bhandle,
+ BCE_MAGIC_ENET5);
printf("%s: Ethernet address %s\n", sc->bce_dev.dv_xname,
ether_sprintf(sc->enaddr));
ether_ifattach(ifp, sc->enaddr);
@@ -999,7 +981,7 @@
memset(sc->bce_rx_ring, 0, BCE_NRXDESC * sizeof(struct bce_dma_slot));
/* enable receive */
bus_space_write_4(sc->bce_btag, sc->bce_bhandle, BCE_DMA_RXCTL,
- 30 << 1 | 1);
+ 30 << 1 | 1); /* MAGIC */
bus_space_write_4(sc->bce_btag, sc->bce_bhandle, BCE_DMA_RXADDR,
sc->bce_ring_map->dm_segs[0].ds_addr + 0x40000000); /* MAGIC */
@@ -1217,11 +1199,11 @@
bus_space_write_4(sc->bce_btag, sc->bce_bhandle, BCE_DMA_TXCTL, 0);
val = bus_space_read_4(sc->bce_btag, sc->bce_bhandle, BCE_DMA_RXSTATUS);
/* if error on receive, wait to go idle */
- if (val & 0xf0000) { /* MAGIC */
+ if (val & RS_ERROR) {
for (i = 0; i < 100; i++) {
val = bus_space_read_4(sc->bce_btag,
sc->bce_bhandle, BCE_DMA_RXSTATUS);
- if (val & 0x2000) /* MAGIC */
+ if (val & RS_DMA_IDLE)
break;
delay(10);
}
@@ -1324,9 +1306,9 @@
bus_space_write_4(sc->bce_btag, sc->bce_bhandle, BCE_SBTMSTATEHI,
0);
val = bus_space_read_4(sc->bce_btag, sc->bce_bhandle, BCE_SBIMSTATE);
- if (val & 0x60000) /* MAGIC */
+ if (val & SBIM_MAGIC_ERRORBITS)
bus_space_write_4(sc->bce_btag, sc->bce_bhandle, BCE_SBIMSTATE,
- val & ~0x60000); /* MAGIC */
+ val & ~SBIM_MAGIC_ERRORBITS);
/* clear reset and allow it to propagate throughout the core */
bus_space_write_4(sc->bce_btag, sc->bce_bhandle, BCE_SBTMSTATELOW,
diff -r 7a138da5f72b -r 4d97c3f8c91c sys/dev/pci/if_bcereg.h
--- a/sys/dev/pci/if_bcereg.h Sun Oct 05 11:54:43 2003 +0000
+++ b/sys/dev/pci/if_bcereg.h Sun Oct 05 11:55:52 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bcereg.h,v 1.3.2.3 2003/10/05 11:51:16 tron Exp $ */
+/* $NetBSD: if_bcereg.h,v 1.3.2.4 2003/10/05 11:55:52 tron Exp $ */
/*
* Copyright (c) 2003 Clifford Wright. All rights reserved.
@@ -71,7 +71,7 @@
/* Ethernet MAC Control */
#define BCE_MACCTL 0x00A8 /* ethernet mac control */
/* mac control bits */
-#define BCE_EMC_CG 0x00000001 /* crc32 generation */
+#define BCE_EMC_CG 0x00000001 /* crc32 generation */
/* DMA Interrupt control */
#define BCE_DMAI_CTL 0x0100
@@ -90,6 +90,8 @@
#define BCE_DMA_RXSTATUS 0x021C /* active desc, etc */
/* receive status bits */
#define RS_CD_MASK 0x0fff /* current descriptor pointer */
+#define RS_DMA_IDLE 0x2000 /* DMA is idle */
+#define RS_ERROR 0xf0000 /* had an error */
/* Ethernet MAC control registers */
#define BCE_RX_CTL 0x0400 /* receive config */
@@ -127,14 +129,25 @@
#define BCE_SBIMSTATE 0x0f90
#define BCE_SBTMSTATELOW 0x0f98
#define BCE_SBTMSTATEHI 0x0f9C
-#define SBTML_RESET 0x1 /* reset */
-#define SBTML_REJ 0x2 /* reject */
-#define SBTML_CLK 0x10000 /* clock enable */
-#define SBTML_FGC 0x20000 /* force gated clocks on */
+#define SBTML_RESET 0x1 /* reset */
+#define SBTML_REJ 0x2 /* reject */
+#define SBTML_CLK 0x10000 /* clock enable */
+#define SBTML_FGC 0x20000 /* force gated clocks on */
/* MI communication register */
#define BCE_MICOMM_DATA 0x0000FFFF
+#define BCE_MIREG(x) ((x & 0x1F) << 18)
+#define BCE_MIPHY(x) ((x & 0x1F) << 23)
-#define BCE_MIREG(x) ((x & 0x1F) << 18)
-#define BCE_MIPHY(x) ((x & 0x1F) << 23)
+/* Magic constants.... */
+#define BCE_MAGIC_PHYEMAC_BASE 0x1000
+#define BCE_MAGIC_PHY (BCE_MAGIC_PHYEMAC_BASE + 90)
+#define BCE_MAGIC_ENET0 (BCE_MAGIC_PHYEMAC_BASE + 79)
+#define BCE_MAGIC_ENET1 (BCE_MAGIC_PHYEMAC_BASE + 78)
+#define BCE_MAGIC_ENET2 (BCE_MAGIC_PHYEMAC_BASE + 81)
+#define BCE_MAGIC_ENET3 (BCE_MAGIC_PHYEMAC_BASE + 80)
+#define BCE_MAGIC_ENET4 (BCE_MAGIC_PHYEMAC_BASE + 83)
+#define BCE_MAGIC_ENET5 (BCE_MAGIC_PHYEMAC_BASE + 82)
+
+#define SBIM_MAGIC_ERRORBITS 0x60000
Home |
Main Index |
Thread Index |
Old Index