-/* $OpenBSD: eephy.c,v 1.62 2023/12/07 09:46:58 uwe Exp $ */
+/* $OpenBSD: eephy.c,v 1.63 2023/12/28 14:03:21 uwe Exp $ */
/*
* Principal Author: Parag Patel
* Copyright (c) 2001
PHY_WRITE(sc, E1000_EADR, page);
}
- /* Switch to SGMII-to-copper mode if necessary. */
- if (sc->mii_model == MII_MODEL_MARVELL_E1512 &&
- sc->mii_flags & MIIF_SGMII) {
+ /*
+ * GCR1 MII mode defaults to an invalid value on E1512/E1514
+ * and must be programmed with the desired mode of operation.
+ */
+ if (sc->mii_model == MII_MODEL_MARVELL_E1512) {
+ uint32_t mode;
+
page = PHY_READ(sc, E1000_EADR);
PHY_WRITE(sc, E1000_EADR, 18);
+
reg = PHY_READ(sc, E1000_GCR1);
+ mode = reg & E1000_GCR1_MODE_MASK;
+
+ if (mode == E1000_GCR1_MODE_UNSET)
+ mode = E1000_GCR1_MODE_RGMII;
+ if (sc->mii_flags & MIIF_SGMII)
+ mode = E1000_GCR1_MODE_SGMII;
+
reg &= ~E1000_GCR1_MODE_MASK;
- reg |= E1000_GCR1_MODE_SGMII;
- reg |= E1000_GCR1_RESET;
+ reg |= E1000_GCR1_RESET | mode;
PHY_WRITE(sc, E1000_GCR1, reg);
+
PHY_WRITE(sc, E1000_EADR, page);
}
-/* $OpenBSD: eephyreg.h,v 1.10 2023/12/07 09:46:58 uwe Exp $ */
+/* $OpenBSD: eephyreg.h,v 1.11 2023/12/28 14:03:21 uwe Exp $ */
/*
* Principal Author: Parag Patel
* Copyright (c) 2001
#define E1000_GCR1 0x14 /* General Control Register 1 */
#define E1000_GCR1_RESET 0x8000
#define E1000_GCR1_MODE_MASK 0x0007
+#define E1000_GCR1_MODE_RGMII 0x0000
#define E1000_GCR1_MODE_SGMII 0x0001
+#define E1000_GCR1_MODE_RGMII_1000X 0x0002
+#define E1000_GCR1_MODE_RGMII_100FX 0x0003
+#define E1000_GCR1_MODE_RGMII_TO_SGMII 0x0004
+#define E1000_GCR1_MODE_UNSET 0x0007