Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Fixes for 21143 and MII in full-duplex mode.
details: https://anonhg.NetBSD.org/src/rev/e4cf2c5ebc6f
branches: trunk
changeset: 480559:e4cf2c5ebc6f
user: matt <matt%NetBSD.org@localhost>
date: Sat Jan 15 18:39:31 2000 +0000
description:
Fixes for 21143 and MII in full-duplex mode.
diffstat:
sys/dev/pci/if_de.c | 97 +++++++++++++++++++++++++++++++++++++++----------
sys/dev/pci/if_devar.h | 4 +-
2 files changed, 79 insertions(+), 22 deletions(-)
diffs (233 lines):
diff -r 1be448bc1da5 -r e4cf2c5ebc6f sys/dev/pci/if_de.c
--- a/sys/dev/pci/if_de.c Sat Jan 15 18:13:22 2000 +0000
+++ b/sys/dev/pci/if_de.c Sat Jan 15 18:39:31 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_de.c,v 1.87 1999/12/04 12:11:13 ragge Exp $ */
+/* $NetBSD: if_de.c,v 1.88 2000/01/15 18:39:31 matt Exp $ */
/*-
* Copyright (c) 1994-1997 Matt Thomas (matt%3am-software.com@localhost)
@@ -306,13 +306,37 @@
if (mi == NULL)
return;
+ /* Reset the SIA first
+ */
+ if (mi->mi_type == TULIP_MEDIAINFO_SIA || (sc->tulip_features & TULIP_HAVE_SIANWAY)) {
+ TULIP_CSR_WRITE(sc, csr_sia_connectivity, TULIP_SIACONN_RESET);
+ }
+
+ /* Next, set full duplex if needed.
+ */
+ if (sc->tulip_flags & TULIP_FULLDUPLEX) {
+#ifdef TULIP_DEBUG
+ if (TULIP_CSR_READ(sc, csr_command) & (TULIP_CMD_RXRUN|TULIP_CMD_TXRUN)) {
+ printf(TULIP_PRINTF_FMT ": warning: board is running (FD).\n",
+ TULIP_PRINTF_ARGS);
+ }
+#endif
+ if ((TULIP_CSR_READ(sc, csr_command) & TULIP_CMD_FULLDUPLEX) == 0) {
+ loudprintf(TULIP_PRINTF_FMT ": setting full duplex.\n",
+ TULIP_PRINTF_ARGS);
+ }
+ sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX;
+ TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode & ~(TULIP_CMD_RXRUN|TULIP_CMD_TXRUN));
+ }
+
+ /* Now setup the media.
+ */
/*
* If we are switching media, make sure we don't think there's
* any stale RX activity
*/
sc->tulip_flags &= ~TULIP_RXACT;
if (mi->mi_type == TULIP_MEDIAINFO_SIA) {
- TULIP_CSR_WRITE(sc, csr_sia_connectivity, TULIP_SIACONN_RESET);
TULIP_CSR_WRITE(sc, csr_sia_tx_rx, mi->mi_sia_tx_rx);
if (sc->tulip_features & TULIP_HAVE_SIAGP) {
TULIP_CSR_WRITE(sc, csr_sia_general, mi->mi_sia_gp_control|mi->mi_sia_general|TULIP_SIAGEN_WATCHDOG);
@@ -375,6 +399,14 @@
TULIP_CSR_WRITE(sc, csr_gp, sc->tulip_rombuf[mi->mi_gpr_offset + idx]);
}
}
+
+ if (sc->tulip_features & TULIP_HAVE_SIANWAY) {
+ /* Set the SIA port into MII mode */
+ TULIP_CSR_WRITE(sc, csr_sia_general, 1);
+ TULIP_CSR_WRITE(sc, csr_sia_tx_rx, 0);
+ TULIP_CSR_WRITE(sc, csr_sia_status, 0);
+ }
+
if (sc->tulip_flags & TULIP_TRYNWAY) {
tulip_mii_autonegotiate(sc, sc->tulip_phyaddr);
} else if ((sc->tulip_flags & TULIP_DIDNWAY) == 0) {
@@ -419,9 +451,9 @@
sc->tulip_media = media;
sc->tulip_flags |= TULIP_PRINTMEDIA;
if (TULIP_IS_MEDIA_FD(sc->tulip_media)) {
- sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX;
+ sc->tulip_flags |= TULIP_FULLDUPLEX;
} else if (sc->tulip_chipid != TULIP_21041 || (sc->tulip_flags & TULIP_DIDNWAY) == 0) {
- sc->tulip_cmdmode &= ~TULIP_CMD_FULLDUPLEX;
+ sc->tulip_flags &= ~TULIP_FULLDUPLEX;
}
}
/*
@@ -555,7 +587,8 @@
/*
* Read the PHY status register.
*/
- status = tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_STATUS);
+ status = tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_STATUS)
+ | tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_STATUS);
if (status & PHYSTS_AUTONEG_DONE) {
/*
* If the PHY has completed autonegotiation, see the if the
@@ -1254,6 +1287,17 @@
"Seeq 80C240"
#endif
},
+ { 0x0281F400, 3, /* 00-A0-7D */
+ {
+ { 0x12, 0x0080, 0x0000 }, /* 10T */
+ { 0x12, 0x0080, 0x0080 }, /* 100TX */
+ { }, /* 100T4 */
+ { 0x12, 0x0040, 0x0040 }, /* FULL_DUPLEX */
+ },
+#if defined(TULIP_DEBUG)
+ "Seeq 80225"
+#endif
+ },
#if 0
{ 0x0015F420, 0, /* 00-A0-7D */
{
@@ -1303,7 +1347,8 @@
/*
* Don't read phy specific registers if link is not up.
*/
- data = tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_STATUS);
+ data = tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_STATUS)
+ | tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_STATUS);
if ((data & (PHYSTS_LINK_UP|PHYSTS_EXTENDED_REGS)) != (PHYSTS_LINK_UP|PHYSTS_EXTENDED_REGS))
return TULIP_MEDIA_UNKNOWN;
@@ -1420,7 +1465,8 @@
sc->tulip_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
return;
}
- status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
+ status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS)
+ | tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
if ((status & PHYSTS_CAN_AUTONEG) == 0) {
#if defined(TULIP_DEBUG)
loudprintf(TULIP_PRINTF_FMT "(phy%d): autonegotiation disabled\n",
@@ -1439,8 +1485,9 @@
loudprintf(TULIP_PRINTF_FMT "(phy%d): oops: enable autonegotiation failed: 0x%04x\n",
TULIP_PRINTF_ARGS, phyaddr, data);
else
- loudprintf(TULIP_PRINTF_FMT "(phy%d): autonegotiation restarted: 0x%04x\n",
- TULIP_PRINTF_ARGS, phyaddr, data);
+ loudprintf(TULIP_PRINTF_FMT "(phy%d): autonegotiation restarted: 0x%04x (ad=0x%04x)\n",
+ TULIP_PRINTF_ARGS, phyaddr, data,
+ tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ADVERTISEMENT));
sc->tulip_dbg.dbg_nway_starts++;
#endif
sc->tulip_probe_state = TULIP_PROBE_PHYAUTONEG;
@@ -1448,7 +1495,8 @@
/* FALL THROUGH */
}
case TULIP_PROBE_PHYAUTONEG: {
- u_int32_t status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
+ u_int32_t status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS)
+ | tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
u_int32_t data;
if ((status & PHYSTS_AUTONEG_DONE) == 0) {
if (sc->tulip_probe_timeout > 0) {
@@ -1464,10 +1512,11 @@
sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
return;
}
- data = tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ABILITIES);
+ data = tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ABILITIES)
+ | tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ABILITIES);
#if defined(TULIP_DEBUG)
- loudprintf(TULIP_PRINTF_FMT "(phy%d): autonegotiation complete: 0x%04x\n",
- TULIP_PRINTF_ARGS, phyaddr, data);
+ loudprintf(TULIP_PRINTF_FMT "(phy%d): autonegotiation complete: 0x%04x (sts=0x%04x)\n",
+ TULIP_PRINTF_ARGS, phyaddr, data, status);
#endif
data = (data << 6) & status;
if (!tulip_mii_map_abilities(sc, data))
@@ -1500,8 +1549,9 @@
else
media = sc->tulip_probe_media;
- sc->tulip_cmdmode &= ~TULIP_CMD_PORTSELECT;
- sc->tulip_flags &= ~TULIP_SQETEST;
+ sc->tulip_cmdmode &= ~(TULIP_CMD_PORTSELECT|TULIP_CMD_NOHEARTBEAT
+ |TULIP_CMD_FULLDUPLEX|TULIP_CMD_TXTHRSHLDCTL);
+ sc->tulip_flags &= ~(TULIP_SQETEST|TULIP_FULLDUPLEX);
if (media != TULIP_MEDIA_UNKNOWN && media != TULIP_MEDIA_MAX) {
#if defined(TULIP_DEBUG)
if (media < TULIP_MEDIA_MAX && sc->tulip_mediums[media] != NULL) {
@@ -1527,30 +1577,37 @@
case TULIP_MEDIA_BNC:
case TULIP_MEDIA_AUI:
case TULIP_MEDIA_10BASET: {
- sc->tulip_cmdmode &= ~TULIP_CMD_FULLDUPLEX;
sc->tulip_cmdmode |= TULIP_CMD_TXTHRSHLDCTL;
sc->tulip_if.if_baudrate = 10000000;
sc->tulip_flags |= TULIP_SQETEST;
break;
}
case TULIP_MEDIA_10BASET_FD: {
- sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX|TULIP_CMD_TXTHRSHLDCTL;
+ sc->tulip_flags |= TULIP_FULLDUPLEX;
+ sc->tulip_cmdmode |= TULIP_CMD_TXTHRSHLDCTL|TULIP_CMD_FULLDUPLEX;
sc->tulip_if.if_baudrate = 10000000;
break;
}
case TULIP_MEDIA_100BASEFX:
case TULIP_MEDIA_100BASET4:
case TULIP_MEDIA_100BASETX: {
- sc->tulip_cmdmode &= ~(TULIP_CMD_FULLDUPLEX|TULIP_CMD_TXTHRSHLDCTL);
sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT;
sc->tulip_if.if_baudrate = 100000000;
+ if (mi->mi_type == TULIP_MEDIAINFO_SYM
+ || mi->mi_type == TULIP_MEDIAINFO_MII) {
+ sc->tulip_cmdmode |= TULIP_CMD_NOHEARTBEAT;
+ }
break;
}
case TULIP_MEDIA_100BASEFX_FD:
case TULIP_MEDIA_100BASETX_FD: {
- sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX|TULIP_CMD_PORTSELECT;
- sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL;
+ sc->tulip_flags |= TULIP_FULLDUPLEX;
+ sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT|TULIP_CMD_FULLDUPLEX;
sc->tulip_if.if_baudrate = 100000000;
+ if (mi->mi_type == TULIP_MEDIAINFO_SYM
+ || mi->mi_type == TULIP_MEDIAINFO_MII) {
+ sc->tulip_cmdmode |= TULIP_CMD_NOHEARTBEAT;
+ }
break;
}
default: {
diff -r 1be448bc1da5 -r e4cf2c5ebc6f sys/dev/pci/if_devar.h
--- a/sys/dev/pci/if_devar.h Sat Jan 15 18:13:22 2000 +0000
+++ b/sys/dev/pci/if_devar.h Sat Jan 15 18:39:31 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_devar.h,v 1.32 1999/04/01 14:55:25 tsubai Exp $ */
+/* $NetBSD: if_devar.h,v 1.33 2000/01/15 18:39:32 matt Exp $ */
/*-
* Copyright (c) 1994-1997 Matt Thomas (matt%3am-software.com@localhost)
@@ -533,7 +533,7 @@
#define TULIP_INRESET 0x00000200
#define TULIP_NEEDRESET 0x00000400
#define TULIP_SQETEST 0x00000800
-#define TULIP_xxxxxx0 0x00001000
+#define TULIP_FULLDUPLEX 0x00001000
#define TULIP_xxxxxx1 0x00002000
#define TULIP_WANTTXSTART 0x00004000
#define TULIP_NEWTXTHRESH 0x00008000
Home |
Main Index |
Thread Index |
Old Index