Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Add support for the Davicom DM9102 and DM9102A 10/10...
details: https://anonhg.NetBSD.org/src/rev/683377cd68c6
branches: trunk
changeset: 486598:683377cd68c6
user: thorpej <thorpej%NetBSD.org@localhost>
date: Fri May 26 16:38:13 2000 +0000
description:
Add support for the Davicom DM9102 and DM9102A 10/100 Ethernet chips.
Partially based on diffs submitted by Matthew Orgass <darkstar%pgh.net@localhost>
and IWAMOTO Toshihiro <iwamoto%sat.t.u-tokyo.ac.jp@localhost>.
diffstat:
sys/dev/ic/tulip.c | 276 ++++++++++++++++++++++++++++++++++++++++++++++-
sys/dev/ic/tulipvar.h | 26 +++-
sys/dev/pci/if_tlp_pci.c | 29 ++++-
3 files changed, 319 insertions(+), 12 deletions(-)
diffs (truncated from 538 to 300 lines):
diff -r 70d709230e53 -r 683377cd68c6 sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c Fri May 26 15:13:43 2000 +0000
+++ b/sys/dev/ic/tulip.c Fri May 26 16:38:13 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tulip.c,v 1.67 2000/05/25 18:46:07 thorpej Exp $ */
+/* $NetBSD: tulip.c,v 1.68 2000/05/26 16:38:13 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -101,6 +101,9 @@
const struct tulip_txthresh_tab tlp_winb_txthresh_tab[] =
TLP_TXTHRESH_TAB_WINB;
+const struct tulip_txthresh_tab tlp_dm9102_txthresh_tab[] =
+ TLP_TXTHRESH_TAB_DM9102;
+
void tlp_start __P((struct ifnet *));
void tlp_watchdog __P((struct ifnet *));
int tlp_ioctl __P((struct ifnet *, u_long, caddr_t));
@@ -130,6 +133,7 @@
void tlp_mii_tick __P((void *));
void tlp_mii_statchg __P((struct device *));
void tlp_winb_mii_statchg __P((struct device *));
+void tlp_dm9102_mii_statchg __P((struct device *));
void tlp_mii_getmedia __P((struct tulip_softc *, struct ifmediareq *));
int tlp_mii_setmedia __P((struct tulip_softc *));
@@ -146,10 +150,12 @@
void tlp_2114x_preinit __P((struct tulip_softc *));
void tlp_2114x_mii_preinit __P((struct tulip_softc *));
void tlp_pnic_preinit __P((struct tulip_softc *));
+void tlp_dm9102_preinit __P((struct tulip_softc *));
void tlp_21140_reset __P((struct tulip_softc *));
void tlp_21142_reset __P((struct tulip_softc *));
void tlp_pmac_reset __P((struct tulip_softc *));
+void tlp_dm9102_reset __P((struct tulip_softc *));
#define tlp_mchash(addr, sz) \
(ether_crc32_le((addr), ETHER_ADDR_LEN) & ((sz) - 1))
@@ -219,6 +225,11 @@
sc->sc_txth = tlp_10_txthresh_tab;
break;
+ case TULIP_CHIP_DM9102:
+ case TULIP_CHIP_DM9102A:
+ sc->sc_txth = tlp_dm9102_txthresh_tab;
+ break;
+
default:
sc->sc_txth = tlp_10_100_txthresh_tab;
break;
@@ -249,6 +260,11 @@
sc->sc_statchg = tlp_winb_mii_statchg;
break;
+ case TULIP_CHIP_DM9102:
+ case TULIP_CHIP_DM9102A:
+ sc->sc_statchg = tlp_dm9102_mii_statchg;
+ break;
+
default:
/*
* We may override this if we have special media
@@ -331,6 +347,24 @@
sc->sc_flags |= TULIPF_IC_FS;
break;
+ case TULIP_CHIP_DM9102:
+ case TULIP_CHIP_DM9102A:
+ /*
+ * Run these chips in chained mode.
+ */
+ sc->sc_tdctl_ch = TDCTL_CH;
+ sc->sc_tdctl_er = 0;
+ sc->sc_preinit = tlp_dm9102_preinit;
+
+ /*
+ * These chips have a broken bus interface, so we
+ * can't use any optimized bus commands. For this
+ * reason, we tend to underrun pretty quickly, so
+ * just to Store-and-Forward mode from the get-go.
+ */
+ sc->sc_txthresh = TXTH_DM9102_SF;
+ break;
+
default:
/*
* Default to running in ring mode.
@@ -397,9 +431,14 @@
* 4-byte aligned. We're almost guaranteed to have to copy
* the packet in that case, so we just limit ourselves to
* one segment.
+ *
+ * On the DM9102, the transmit logic can only handle one
+ * DMA segment.
*/
switch (sc->sc_chip) {
case TULIP_CHIP_X3201_3:
+ case TULIP_CHIP_DM9102:
+ case TULIP_CHIP_DM9102A:
sc->sc_ntxsegs = 1;
break;
@@ -1076,6 +1115,17 @@
(sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
return (0);
+ /* Disable interrupts on the DM9102 (interrupt edge bug). */
+ switch (sc->sc_chip) {
+ case TULIP_CHIP_DM9102:
+ case TULIP_CHIP_DM9102A:
+ TULIP_WRITE(sc, CSR_INTEN, 0);
+ break;
+
+ default:
+ /* Nothing. */
+ }
+
for (;;) {
status = TULIP_READ(sc, CSR_STATUS);
if (status)
@@ -1206,6 +1256,17 @@
*/
}
+ /* Bring interrupts back up on the DM9102. */
+ switch (sc->sc_chip) {
+ case TULIP_CHIP_DM9102:
+ case TULIP_CHIP_DM9102A:
+ TULIP_WRITE(sc, CSR_INTEN, sc->sc_inten);
+ break;
+
+ default:
+ /* Nothing. */
+ }
+
/* Try to get more packets going. */
tlp_start(ifp);
@@ -1659,6 +1720,20 @@
* always work.
*/
#endif
+
+ /*
+ * Some chips have a broken bus interface.
+ */
+ switch (sc->sc_chip) {
+ case TULIP_CHIP_DM9102:
+ case TULIP_CHIP_DM9102A:
+ sc->sc_busmode = 0;
+ break;
+
+ default:
+ /* Nothing. */
+ }
+
TULIP_WRITE(sc, CSR_BUSMODE, sc->sc_busmode);
/*
@@ -2839,7 +2914,7 @@
struct tulip_softc *sc;
u_int32_t bits;
{
- static const char *tx_state_names[] = {
+ static const char *tlp_tx_state_names[] = {
"STOPPED",
"RUNNING - FETCH",
"RUNNING - WAIT",
@@ -2849,7 +2924,7 @@
"SUSPENDED",
"RUNNING - CLOSE",
};
- static const char *rx_state_names[] = {
+ static const char *tlp_rx_state_names[] = {
"STOPPED",
"RUNNING - FETCH",
"RUNNING - CHECK",
@@ -2859,9 +2934,44 @@
"RUNNING - FLUSH",
"RUNNING - QUEUE",
};
+ static const char *dm9102_tx_state_names[] = {
+ "STOPPED",
+ "RUNNING - FETCH",
+ "RUNNING - SETUP",
+ "RUNNING - READING",
+ "RUNNING - CLOSE - CLEAR OWNER",
+ "RUNNING - WAIT",
+ "RUNNING - CLOSE - WRITE STATUS",
+ "SUSPENDED",
+ };
+ static const char *dm9102_rx_state_names[] = {
+ "STOPPED",
+ "RUNNING - FETCH",
+ "RUNNING - WAIT",
+ "RUNNING - QUEUE",
+ "RUNNING - CLOSE - CLEAR OWNER",
+ "RUNNING - CLOSE - WRITE STATUS",
+ "SUSPENDED",
+ "RUNNING - FLUSH",
+ };
+
+ const char **tx_state_names, **rx_state_names;
u_int32_t csr, ackmask = 0;
int i;
+ switch (sc->sc_chip) {
+ case TULIP_CHIP_DM9102:
+ case TULIP_CHIP_DM9102A:
+ tx_state_names = dm9102_tx_state_names;
+ rx_state_names = dm9102_rx_state_names;
+ break;
+
+ default:
+ tx_state_names = tlp_tx_state_names;
+ rx_state_names = tlp_rx_state_names;
+ break;
+ }
+
if (bits & OPMODE_ST)
ackmask |= STATUS_TPS;
@@ -3019,6 +3129,36 @@
}
/*
+ * tlp_dm9102_mii_statchg: [mii interface function]
+ *
+ * Callback from PHY when media changes. This version is
+ * for the DM9102.
+ */
+void
+tlp_dm9102_mii_statchg(self)
+ struct device *self;
+{
+ struct tulip_softc *sc = (struct tulip_softc *)self;
+
+ /*
+ * Don't idle the transmit and receive processes, here. It
+ * seems to fail, and just causes excess noise.
+ */
+ sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD);
+
+ if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) != IFM_100_TX)
+ sc->sc_opmode |= OPMODE_TTM;
+
+ if (sc->sc_mii.mii_media_active & IFM_FDX)
+ sc->sc_opmode |= OPMODE_FD;
+
+ /*
+ * Write new OPMODE bits.
+ */
+ TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
+}
+
+/*
* tlp_mii_getmedia:
*
* Callback from ifmedia to request current media status.
@@ -3326,6 +3466,36 @@
}
/*
+ * tlp_dm9102_preinit:
+ *
+ * Pre-init function for the Davicom DM9102.
+ */
+void
+tlp_dm9102_preinit(sc)
+ struct tulip_softc *sc;
+{
+
+ switch (sc->sc_chip) {
+ case TULIP_CHIP_DM9102:
+ sc->sc_opmode |= OPMODE_MBO|OPMODE_HBD|OPMODE_PS;
+ break;
+
+ case TULIP_CHIP_DM9102A:
+ /*
+ * XXX Figure out how to actually deal with the HomePNA
+ * XXX portion of the DM9102A.
+ */
+ sc->sc_opmode |= OPMODE_MBO|OPMODE_HBD;
+ break;
+
+ default:
+ /* Nothing. */
+ }
+
+ TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
+}
+
+/*
* tlp_21140_reset:
*
* Issue a reset sequence on the 21140 via the GPIO facility.
@@ -3421,6 +3591,21 @@
}
Home |
Main Index |
Thread Index |
Old Index