-/* $OpenBSD: miivar.h,v 1.36 2020/11/03 21:49:42 patrick Exp $ */
+/* $OpenBSD: miivar.h,v 1.37 2023/04/05 10:45:07 kettenis Exp $ */
/* $NetBSD: miivar.h,v 1.17 2000/03/06 20:56:57 thorpej Exp $ */
/*-
#define MIIF_DOPAUSE 0x0100 /* advertise PAUSE capability */
#define MIIF_IS_HPNA 0x0200 /* is a HomePNA device */
#define MIIF_FORCEANEG 0x0400 /* force autonegotiation */
-#define MIIF_RXID 0x0800 /* add Rx delay */
-#define MIIF_TXID 0x1000 /* add Tx delay */
-#define MIIF_SGMII 0x2000 /* MAC to PHY interface is SGMII */
+#define MIIF_SETDELAY 0x0800 /* set internal delay */
+#define MIIF_RXID 0x1000 /* add Rx delay */
+#define MIIF_TXID 0x2000 /* add Tx delay */
+#define MIIF_SGMII 0x4000 /* MAC to PHY interface is SGMII */
#define MIIF_INHERIT_MASK (MIIF_NOISOLATE|MIIF_NOLOOP|MIIF_AUTOTSLEEP)
-/* $OpenBSD: rgephy.c,v 1.42 2023/04/02 11:28:23 kettenis Exp $ */
+/* $OpenBSD: rgephy.c,v 1.43 2023/04/05 10:45:07 kettenis Exp $ */
/*
* Copyright (c) 2003
* Bill Paul <wpaul@windriver.com>. All rights reserved.
int rgephy_mii_phy_auto(struct mii_softc *);
void rgephy_reset(struct mii_softc *);
void rgephy_loop(struct mii_softc *);
+void rgephy_init_rtl8211f(struct mii_softc *);
void rgephy_load_dspcode(struct mii_softc *);
const struct mii_phy_funcs rgephy_funcs = {
(sc->mii_extcapabilities & EXTSR_MEDIAMASK))
mii_phy_add_media(sc);
+ if (sc->mii_model == MII_MODEL_xxREALTEK_RTL8211FVD ||
+ (sc->mii_model == MII_MODEL_xxREALTEK_RTL8169S &&
+ sc->mii_rev == RGEPHY_8211F))
+ rgephy_init_rtl8211f(sc);
+
PHY_RESET(sc);
}
}
}
+void
+rgephy_init_rtl8211f(struct mii_softc *sc)
+{
+ if (sc->mii_flags & MIIF_SETDELAY) {
+ int page, val;
+
+ /* save page */
+ page = PHY_READ(sc, RGEPHY_PS);
+ PHY_WRITE(sc, RGEPHY_PS, RGEPHY_PS_PAGE_MII);
+
+ val = PHY_READ(sc, RGEPHY_MIICR1);
+ if (sc->mii_flags & MIIF_TXID)
+ val |= RGEPHY_MIICR1_TXDLY_EN;
+ else
+ val &= ~RGEPHY_MIICR1_TXDLY_EN;
+ PHY_WRITE(sc, RGEPHY_MIICR1, val);
+
+ val = PHY_READ(sc, RGEPHY_MIICR2);
+ if (sc->mii_flags & MIIF_RXID)
+ val |= RGEPHY_MIICR2_RXDLY_EN;
+ else
+ val &= ~RGEPHY_MIICR2_RXDLY_EN;
+ PHY_WRITE(sc, RGEPHY_MIICR2, val);
+
+ /* restore page */
+ PHY_WRITE(sc, RGEPHY_PS, page);
+ }
+}
+
#define PHY_SETBIT(x, y, z) \
PHY_WRITE(x, y, (PHY_READ(x, y) | (z)))
#define PHY_CLRBIT(x, y, z) \
-/* $OpenBSD: rgephyreg.h,v 1.9 2018/02/27 19:47:10 kettenis Exp $ */
+/* $OpenBSD: rgephyreg.h,v 1.10 2023/04/05 10:45:07 kettenis Exp $ */
/*
* Copyright (c) 2003
* Bill Paul <wpaul@windriver.com>. All rights reserved.
#define RGEPHY_PS_PAGE_3 0x0003
#define RGEPHY_PS_PAGE_4 0x0004
+/* RTL8211F */
+#define RGEPHY_PS_PAGE_MII 0x0d08
+#define RGEPHY_MIICR1 0x11
+#define RGEPHY_MIICR1_TXDLY_EN 0x0100
+#define RGEPHY_MIICR2 0x15
+#define RGEPHY_MIICR2_RXDLY_EN 0x0008
+
#endif /* _DEV_RGEPHY_MIIREG_H_ */