Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Deal with some more Winbond differences, after a ...
details: https://anonhg.NetBSD.org/src/rev/2a8f16c8fe5c
branches: trunk
changeset: 475995:2a8f16c8fe5c
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Sep 02 23:25:28 1999 +0000
description:
Deal with some more Winbond differences, after a more-thorough-than-before
reading of its manual.
diffstat:
sys/dev/ic/tulip.c | 231 ++++++++++++++++++++++++++++++++++++-------------
sys/dev/ic/tulipreg.h | 54 +++++++++--
sys/dev/ic/tulipvar.h | 8 +-
3 files changed, 218 insertions(+), 75 deletions(-)
diffs (truncated from 635 to 300 lines):
diff -r ce55c1346c05 -r 2a8f16c8fe5c sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c Thu Sep 02 23:23:03 1999 +0000
+++ b/sys/dev/ic/tulip.c Thu Sep 02 23:25:28 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tulip.c,v 1.4 1999/09/01 20:56:15 thorpej Exp $ */
+/* $NetBSD: tulip.c,v 1.5 1999/09/02 23:25:28 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -117,6 +117,23 @@
#define TXTH_160 3
#define TXTH_SF 4
+/*
+ * The Winbond 89C840F does transmit threshold control totally
+ * differently. It simply has a 7-bit field which indicates
+ * the threshold:
+ *
+ * txth = ((OPMODE & OPMODE_WINB_TTH) >> OPMODE_WINB_TTH_SHIFT) * 16;
+ *
+ * However, we just do Store-and-Forward mode on these chips, since
+ * the DMA engines seem to be flaky.
+ */
+const struct tulip_txthresh_tab tlp_winb_txthresh_tab[] = {
+ { 0, "store and forward mode" },
+ { 0, NULL },
+};
+
+#define TXTH_WINB_SF 0
+
void tlp_start __P((struct ifnet *));
void tlp_watchdog __P((struct ifnet *));
int tlp_ioctl __P((struct ifnet *, u_long, caddr_t));
@@ -139,6 +156,7 @@
void tlp_mii_tick __P((void *));
void tlp_mii_statchg __P((struct device *));
+void tlp_winb_mii_statchg __P((struct device *));
void tlp_mii_getmedia __P((struct tulip_softc *, struct ifmediareq *));
int tlp_mii_setmedia __P((struct tulip_softc *));
@@ -156,9 +174,10 @@
(TULIP_MCHASHSIZE - 1))
#ifdef TLP_DEBUG
-#define DPRINTF(x) printf x
+#define DPRINTF(sc, x) if ((sc)->sc_ethercom.ec_if.if_flags & IFF_DEBUG) \
+ printf x
#else
-#define DPRINTF(x) /* nothing */
+#define DPRINTF(sc, x) /* nothing */
#endif
/*
@@ -209,6 +228,19 @@
}
/*
+ * Set up the media status change function.
+ */
+ switch (sc->sc_chip) {
+ case TULIP_CHIP_WB89C840F:
+ sc->sc_statchg = tlp_winb_mii_statchg;
+ break;
+
+ default:
+ sc->sc_statchg = tlp_mii_statchg;
+ break;
+ }
+
+ /*
* Set up various chip-specific quirks.
*/
switch (sc->sc_chip) {
@@ -394,7 +426,7 @@
bus_dmamap_t dmamap;
int error, firsttx, nexttx, lasttx, ofree, seg;
- DPRINTF(("%s: tlp_start: sc_flags 0x%08x, if_flags 0x%08x\n",
+ DPRINTF(sc, ("%s: tlp_start: sc_flags 0x%08x, if_flags 0x%08x\n",
sc->sc_dev.dv_xname, sc->sc_flags, ifp->if_flags));
/*
@@ -415,7 +447,7 @@
ofree = sc->sc_txfree;
firsttx = sc->sc_txnext;
- DPRINTF(("%s: tlp_start: txfree %d, txnext %d\n",
+ DPRINTF(sc, ("%s: tlp_start: txfree %d, txnext %d\n",
sc->sc_dev.dv_xname, ofree, firsttx));
/*
@@ -529,19 +561,21 @@
sc->sc_txdescs[lasttx].td_ctl |= TDCTL_Tx_LS;
#ifdef TLP_DEBUG
- printf(" txsoft %p trainsmit chain:\n", txs);
- for (seg = sc->sc_txnext;; seg = TULIP_NEXTTX(seg)) {
- printf(" descriptor %d:\n", seg);
- printf(" td_status: 0x%08x\n",
- sc->sc_txdescs[seg].td_status);
- printf(" td_ctl: 0x%08x\n",
- sc->sc_txdescs[seg].td_ctl);
- printf(" td_bufaddr1: 0x%08x\n",
- sc->sc_txdescs[seg].td_bufaddr1);
- printf(" td_bufaddr2: 0x%08x\n",
- sc->sc_txdescs[seg].td_bufaddr2);
- if (seg == lasttx)
- break;
+ if (ifp->if_flags & IFF_DEBUG) {
+ printf(" txsoft %p trainsmit chain:\n", txs);
+ for (seg = sc->sc_txnext;; seg = TULIP_NEXTTX(seg)) {
+ printf(" descriptor %d:\n", seg);
+ printf(" td_status: 0x%08x\n",
+ sc->sc_txdescs[seg].td_status);
+ printf(" td_ctl: 0x%08x\n",
+ sc->sc_txdescs[seg].td_ctl);
+ printf(" td_bufaddr1: 0x%08x\n",
+ sc->sc_txdescs[seg].td_bufaddr1);
+ printf(" td_bufaddr2: 0x%08x\n",
+ sc->sc_txdescs[seg].td_bufaddr2);
+ if (seg == lasttx)
+ break;
+ }
}
#endif
@@ -582,7 +616,7 @@
}
if (sc->sc_txfree != ofree) {
- DPRINTF(("%s: packets enqueued, IC on %d, OWN on %d\n",
+ DPRINTF(sc, ("%s: packets enqueued, IC on %d, OWN on %d\n",
sc->sc_dev.dv_xname, lasttx, firsttx));
/*
* Cause a transmit interrupt to happen on the
@@ -781,10 +815,10 @@
{
struct tulip_softc *sc = arg;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
- u_int32_t status;
+ u_int32_t status, rxstatus, txstatus;
int handled = 0, txthresh;
- DPRINTF(("%s: tlp_intr\n", sc->sc_dev.dv_xname));
+ DPRINTF(sc, ("%s: tlp_intr\n", sc->sc_dev.dv_xname));
for (;;) {
status = TULIP_READ(sc, CSR_STATUS);
@@ -796,15 +830,18 @@
handled = 1;
- if (status & (STATUS_RI|STATUS_RU|STATUS_RWT)) {
+ rxstatus = status & sc->sc_rxint_mask;
+ txstatus = status & sc->sc_txint_mask;
+
+ if (rxstatus) {
/* Grab new any new packets. */
tlp_rxintr(sc);
- if (status & STATUS_RWT)
+ if (rxstatus & STATUS_RWT)
printf("%s: receive watchdog timeout\n",
sc->sc_dev.dv_xname);
- if (status & STATUS_RU) {
+ if (rxstatus & STATUS_RU) {
printf("%s: receive ring overrun\n",
sc->sc_dev.dv_xname);
/* Get the receive process going again. */
@@ -817,15 +854,15 @@
}
}
- if (status & (STATUS_TI|STATUS_UNF|STATUS_TJT)) {
+ if (txstatus) {
/* Sweep up transmit descriptors. */
tlp_txintr(sc);
- if (status & STATUS_TJT)
+ if (txstatus & STATUS_TJT)
printf("%s: transmit jabber timeout\n",
sc->sc_dev.dv_xname);
- if (status & STATUS_UNF) {
+ if (txstatus & STATUS_UNF) {
/*
* Increase our transmit threshold if
* another is available.
@@ -1099,7 +1136,7 @@
struct tulip_txsoft *txs;
u_int32_t txstat;
- DPRINTF(("%s: tlp_txintr: sc_flags 0x%08x\n",
+ DPRINTF(sc, ("%s: tlp_txintr: sc_flags 0x%08x\n",
sc->sc_dev.dv_xname, sc->sc_flags));
ifp->if_flags &= ~IFF_OACTIVE;
@@ -1123,21 +1160,23 @@
BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
#ifdef TLP_DEBUG
- { int i;
- printf(" txsoft %p trainsmit chain:\n", txs);
- for (i = txs->txs_firstdesc;; i = TULIP_NEXTTX(i)) {
- printf(" descriptor %d:\n", i);
- printf(" td_status: 0x%08x\n",
- sc->sc_txdescs[i].td_status);
- printf(" td_ctl: 0x%08x\n",
- sc->sc_txdescs[i].td_ctl);
- printf(" td_bufaddr1: 0x%08x\n",
- sc->sc_txdescs[i].td_bufaddr1);
- printf(" td_bufaddr2: 0x%08x\n",
- sc->sc_txdescs[i].td_bufaddr2);
- if (i == txs->txs_lastdesc)
- break;
- }}
+ if (ifp->if_flags & IFF_DEBUG) {
+ int i;
+ printf(" txsoft %p trainsmit chain:\n", txs);
+ for (i = txs->txs_firstdesc;; i = TULIP_NEXTTX(i)) {
+ printf(" descriptor %d:\n", i);
+ printf(" td_status: 0x%08x\n",
+ sc->sc_txdescs[i].td_status);
+ printf(" td_ctl: 0x%08x\n",
+ sc->sc_txdescs[i].td_ctl);
+ printf(" td_bufaddr1: 0x%08x\n",
+ sc->sc_txdescs[i].td_bufaddr1);
+ printf(" td_bufaddr2: 0x%08x\n",
+ sc->sc_txdescs[i].td_bufaddr2);
+ if (i == txs->txs_lastdesc)
+ break;
+ }
+ }
#endif
txstat = sc->sc_txdescs[txs->txs_firstdesc].td_status;
@@ -1301,17 +1340,23 @@
}
if (sc->sc_flags & TULIPF_HAS_MII) {
- /* Enable the MII port. */
- sc->sc_opmode |= OPMODE_PS;
-
switch (sc->sc_chip) {
case TULIP_CHIP_82C168:
case TULIP_CHIP_82C169:
+ /* Enable the MII port. */
+ sc->sc_opmode |= OPMODE_PS;
+
TULIP_WRITE(sc, CSR_PNIC_ENDEC, PNIC_ENDEC_JABBERDIS);
break;
+ case TULIP_CHIP_WB89C840F:
+ /* Nothing. */
+ break;
+
default:
- /* Nothing. */
+ /* Enable the MII port. */
+ sc->sc_opmode |= OPMODE_PS;
+ break;
}
}
@@ -1387,10 +1432,30 @@
*/
/* normal interrupts */
sc->sc_inten = STATUS_TI | STATUS_TU | STATUS_RI | STATUS_NIS;
+
/* abnormal interrupts */
sc->sc_inten |= STATUS_TPS | STATUS_TJT | STATUS_UNF |
STATUS_RU | STATUS_RPS | STATUS_RWT | STATUS_SE | STATUS_AIS;
+ sc->sc_rxint_mask = STATUS_RI|STATUS_RU|STATUS_RWT;
+ sc->sc_txint_mask = STATUS_TI|STATUS_UNF|STATUS_TJT;
+
+ switch (sc->sc_chip) {
+ case TULIP_CHIP_WB89C840F:
+ /*
+ * Clear bits that we don't want that happen to
+ * overlap or don't exist.
+ */
+ sc->sc_inten &= ~(STATUS_WINB_REI|STATUS_RWT);
+ break;
+
+ default:
+ /* Nothing. */
+ }
+
+ sc->sc_rxint_mask &= sc->sc_inten;
+ sc->sc_txint_mask &= sc->sc_inten;
+
TULIP_WRITE(sc, CSR_INTEN, sc->sc_inten);
TULIP_WRITE(sc, CSR_STATUS, 0xffffffff);
@@ -1408,7 +1473,7 @@
/* XXX Do this with stream writes? */
for (i = 0; i < ETHER_ADDR_LEN; i++) {
Home |
Main Index |
Thread Index |
Old Index