Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/dev/mii Pull up the following, requested by msaitoh i...
details: https://anonhg.NetBSD.org/src/rev/106c67a7b1b2
branches: netbsd-8
changeset: 744252:106c67a7b1b2
user: martin <martin%NetBSD.org@localhost>
date: Tue Jan 28 09:34:29 2020 +0000
description:
Pull up the following, requested by msaitoh in ticket #1493:
sys/dev/mii/makphy.c 1.61, 1.63-1.64 via patch
sys/dev/mii/makphyreg.h 1.10
- Remove ESSR_FIBER_LINK bit check in makphyattach(). This bit is
valid only when the link is up, so it's not good to check in the
attach function.
- There is an environment that both copper and fiber bits are set in
EXTSR but it support copper only. To resolve this problem, check the
ESSR register's HWCFG_MODE bit and drop unsupported bits.
- If the chip is in Fiber/Copper auto select mode, check which media is
selected. Currently, the code supports 88E1011, 88E1111 and 88E1112
only.
- Fix comment. KNF.
diffstat:
sys/dev/mii/makphy.c | 110 +++++++++++++++++++++++++++++++++++++++--------
sys/dev/mii/makphyreg.h | 35 +++++++++++---
2 files changed, 116 insertions(+), 29 deletions(-)
diffs (230 lines):
diff -r 0d1410e88e48 -r 106c67a7b1b2 sys/dev/mii/makphy.c
--- a/sys/dev/mii/makphy.c Fri Jan 24 18:50:19 2020 +0000
+++ b/sys/dev/mii/makphy.c Tue Jan 28 09:34:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: makphy.c,v 1.42.8.3 2019/08/01 14:27:30 martin Exp $ */
+/* $NetBSD: makphy.c,v 1.42.8.4 2020/01/28 09:34:29 martin Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.42.8.3 2019/08/01 14:27:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.42.8.4 2020/01/28 09:34:29 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -204,7 +204,7 @@
const struct mii_phydesc *mpd;
struct makphy_softc *maksc = (struct makphy_softc *)sc;
const char *name;
- int model, val;
+ int reg, model;
mpd = mii_phy_match(ma, makphys);
aprint_naive(": Media interface\n");
@@ -245,24 +245,61 @@
break;
}
- switch (model) {
- case MII_MODEL_xxMARVELL_E1011:
- case MII_MODEL_xxMARVELL_E1112:
- val = PHY_READ(sc, MAKPHY_ESSR);
- if ((val != 0) && (((u_int)val & 0x0000ffffU) != 0x0000ffffU)
- && ((val & ESSR_FIBER_LINK) != 0))
- sc->mii_flags |= MIIF_HAVEFIBER;
- break;
- default:
- break;
- }
-
PHY_RESET(sc);
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
if (sc->mii_capabilities & BMSR_EXTSTAT)
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
+ if (((sc->mii_extcapabilities & (EXTSR_1000TFDX | EXTSR_1000THDX))
+ != 0)
+ && ((sc->mii_extcapabilities & (EXTSR_1000XFDX | EXTSR_1000XHDX))
+ != 0)) {
+ bool fiberonly = false, copperonly = false;
+
+ /* Both copper and fiber are set. check MODE[] */
+ switch (sc->mii_mpd_model) {
+ case MII_MODEL_xxMARVELL_E1011:
+ case MII_MODEL_xxMARVELL_E1111:
+ /* These devices have ESSR register */
+ reg = PHY_READ(sc, MAKPHY_ESSR);
+ if ((reg & ESSR_AUTOSEL_DISABLE) != 0) {
+ switch (reg & ESSR_HWCFG_MODE) {
+ case ESSR_RTBI_FIBER:
+ case ESSR_RGMII_FIBER:
+ case ESSR_RGMII_SGMII: /* right? */
+ case ESSR_TBI_FIBER:
+ case ESSR_GMII_FIBER:
+ fiberonly = true;
+ break;
+ case ESSR_SGMII_WC_COPPER:
+ case ESSR_SGMII_WOC_COPPER:
+ case ESSR_RTBI_COPPER:
+ case ESSR_RGMII_COPPER:
+ case ESSR_GMII_COPPER:
+ copperonly = true;
+ default:
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ if (fiberonly || copperonly)
+ aprint_debug_dev(self, "both copper and fiber are set "
+ "but MODE[] is %s only.\n",
+ fiberonly ? "fiber" : "copper");
+ if (fiberonly)
+ sc->mii_extcapabilities
+ &= ~(EXTSR_1000TFDX | EXTSR_1000THDX);
+ else if (copperonly) {
+ sc->mii_extcapabilities
+ &= ~(EXTSR_1000XFDX | EXTSR_1000XHDX);
+ sc->mii_flags &= ~MIIF_IS_1000X;
+ }
+ }
+
aprint_normal_dev(self, "");
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 &&
(sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0)
@@ -280,9 +317,7 @@
mii_phy_reset(sc);
- /*
- * Initialize PHY Specific Control Register.
- */
+ /* Initialize PHY Specific Control Register. */
reg = PHY_READ(sc, MAKPHY_PSCR);
/* Assert CRS on transmit. */
@@ -425,7 +460,7 @@
makphy_status(struct mii_softc *sc)
{
struct mii_data *mii = sc->mii_pdata;
- int bmcr, gsr, pssr;
+ int bmcr, gsr, pssr, essr;
mii->mii_media_status = IFM_AVALID;
mii->mii_media_active = IFM_ETHER;
@@ -463,10 +498,45 @@
}
}
- /* XXX FIXME: Use different page for Fiber on newer chips */
+ /*
+ * XXX The following code support Fiber/Copper auto select mode
+ * only for 88E1011, 88E1111 and 88E1112. For other chips, the document
+ * is required.
+ */
if (sc->mii_flags & MIIF_IS_1000X) {
+ /* Not in Fiber/Copper auto select mode */
mii->mii_media_active |= IFM_1000_SX;
+ } else if ((sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1011) ||
+ (sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1111)) {
+ /* Fiber/Copper auto select mode */
+
+ essr = PHY_READ(sc, MAKPHY_ESSR);
+ if ((essr & ESSR_FIBER_LINK) == 0)
+ goto copper;
+
+ /* XXX Assume 1000BASE-SX only */
+ mii->mii_media_active |= IFM_1000_SX;
+ } else if (sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1112) {
+ /* Fiber/Copper auto select mode */
+
+ pssr = PHY_READ(sc, MAKPHY_PSSR);
+ if ((pssr & PSSR_RESOLUTION_FIBER) == 0)
+ goto copper;
+
+ switch (PSSR_SPEED_get(pssr)) {
+ case SPEED_1000:
+ mii->mii_media_active |= IFM_1000_SX;
+ break;
+ case SPEED_100:
+ mii->mii_media_active |= IFM_100_FX;
+ break;
+ default: /* Undefined (reserved) value */
+ mii->mii_media_active |= IFM_NONE;
+ mii->mii_media_status = 0;
+ return;
+ }
} else {
+copper:
switch (PSSR_SPEED_get(pssr)) {
case SPEED_1000:
mii->mii_media_active |= IFM_1000_T;
diff -r 0d1410e88e48 -r 106c67a7b1b2 sys/dev/mii/makphyreg.h
--- a/sys/dev/mii/makphyreg.h Fri Jan 24 18:50:19 2020 +0000
+++ b/sys/dev/mii/makphyreg.h Tue Jan 28 09:34:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: makphyreg.h,v 1.6.20.1 2019/01/17 17:23:02 martin Exp $ */
+/* $NetBSD: makphyreg.h,v 1.6.20.2 2020/01/28 09:34:29 martin Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -107,6 +107,12 @@
#define SPEED_1000 2
#define SPEED_reserved 3
+/* For 88E1112 */
+#define PSSR_RESOLUTION_FIBER (1U << 7) /*
+ * Fiber/Copper resolution
+ * 1 = Fiber, 0 = Copper
+ */
+
#define MAKPHY_IE 0x12 /* Interrupt enable */
#define IE_JABBER (1U << 0) /* jabber indication */
#define IE_POL_CHANGED (1U << 1) /* polarity changed */
@@ -143,6 +149,7 @@
#define LEDCTRL_PULSE_STRCH(x) ((x) << 12)
#define LEDCTRL_DISABLE (1U << 15) /* disable LED */
+/* For 88E1011, 88E1111 */
#define MAKPHY_ESSR 0x1b /* Extended PHY specific status */
#define ESSR_AUTOSEL_DISABLE 0x8000 /* Fiber/Copper autoselect disable */
#define ESSR_FIBER_LINK 0x2000 /* Fiber/Copper resolution */
@@ -153,13 +160,23 @@
#define ESSR_DTE_DROP_HYST 0x01e0 /* DTE detect status drop hysteresis */
#define ESSR_DTE_POWER 0x0010
#define ESSR_HWCFG_MODE 0x000f
-#define ESSR_GMII_COPPER 0x000f
-#define ESSR_GMII_FIBER 0x0007
-#define ESSR_RGMII_COPPER 0x000b
-#define ESSR_RGMII_FIBER 0x0003
-#define ESSR_RGMII_SGMII 0x0006
-#define ESSR_TBI_COPPER 0x000d
-#define ESSR_TBI_FIBER 0x0005
-
+#define ESSR_SGMII_WC_COPPER 0x0000 /* SGMII w/ Clock w/ SGMII AN Copper */
+#define ESSR_RTBI_FIBER 0x0001 /* RTBI to Fiber */
+#define ESSR_RGMII_FIBER 0x0003 /* RGMII to Fiber */
+#define ESSR_SGMII_WOC_COPPER 0x0004 /* SGMII w/o Clock w/ SGMII AN Copp. */
+#define ESSR_TBI_FIBER 0x0005 /* TBI to Fiber */
+#define ESSR_RGMII_SGMII 0x0006 /* RGMII to SGMII */
+#define ESSR_GMII_FIBER 0x0007 /* GMII to Fiber */
+#define ESSR_SERIAL_WAN 0x0008 /* 88E1011: Serial w 1000KX AN */
+#define ESSR_GBIC 0x0008 /* 88E1111: GBIC */
+#define ESSR_RTBI_COPPER 0x0009 /* RTBI to Copper */
+#define ESSR_RGMII_COPPER 0x000b /* RGMII to Copper */
+#define ESSR_RGMII_AUTOSEL 0x000b /* RGMII with Auto-Selection */
+#define ESSR_SERIAL_WOAN 0x000c /* 88E1011: Serial w/o 1000KX AN */
+#define ESSR_1000X_WOAN 0x000c /* 88E1111: 1000X w/o AN Copper */
+#define ESSR_TBI_COPPER 0x000d /* TBI to Copper */
+#define ESSR_GMII_SGMII 0x000e /* GMII to SGMII */
+#define ESSR_GMII_COPPER 0x000f /* GMII to Copper */
+#define ESSR_GMII_AUTOSEL 0x000f /* GMII with Auto-Selection */
#endif /* _DEV_MII_MAKPHYREG_H_ */
Home |
Main Index |
Thread Index |
Old Index