- Add a MIIF_FORCEANEG flag which forces an auto-negotiation to always
take place if IFM_AUTO is selected. This allows drivers like nsphy(4), which need to force writing the ANAR according to the BMSR, to take advantage of mii_phy_setmedia(). [1] - In mii_phy_reset() once the current media is set don't isolate the PHY corresponding to the instance of the currently selected media rather than unconditionally not isolating the PHY corresponding to instance 0. This saves a isolation-unisolation-cycle of the PHY corresponding to the currently selected media for the case were it isn't instance 0. - Fix some whitespace nits. [1] Obtained from: NetBSD [1] MFC after: 2 weeks
This commit is contained in:
parent
d4875805d7
commit
0c3e319244
@ -114,7 +114,8 @@ mii_phy_setmedia(struct mii_softc *sc)
|
||||
int bmcr, anar, gtcr;
|
||||
|
||||
if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) {
|
||||
if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0)
|
||||
if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0 ||
|
||||
(sc->mii_flags & MIIF_FORCEANEG))
|
||||
(void) mii_phy_auto(sc);
|
||||
return;
|
||||
}
|
||||
@ -247,6 +248,7 @@ mii_phy_tick(struct mii_softc *sc)
|
||||
void
|
||||
mii_phy_reset(struct mii_softc *sc)
|
||||
{
|
||||
struct ifmedia_entry *ife = sc->mii_pdata->mii_media.ifm_cur;
|
||||
int reg, i;
|
||||
|
||||
if (sc->mii_flags & MIIF_NOISOLATE)
|
||||
@ -257,14 +259,17 @@ mii_phy_reset(struct mii_softc *sc)
|
||||
|
||||
/* Wait 100ms for it to complete. */
|
||||
for (i = 0; i < 100; i++) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
if ((reg & BMCR_RESET) == 0)
|
||||
break;
|
||||
DELAY(1000);
|
||||
}
|
||||
|
||||
if (sc->mii_inst != 0 && ((sc->mii_flags & MIIF_NOISOLATE) == 0))
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
if ((sc->mii_flags & MIIF_NOISOLATE) == 0) {
|
||||
if ((ife == NULL && sc->mii_inst != 0) ||
|
||||
(ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst))
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -548,5 +553,6 @@ mii_phy_match_gen(const struct mii_attach_args *ma,
|
||||
const struct mii_phydesc *
|
||||
mii_phy_match(const struct mii_attach_args *ma, const struct mii_phydesc *mpd)
|
||||
{
|
||||
|
||||
return (mii_phy_match_gen(ma, mpd, sizeof(struct mii_phydesc)));
|
||||
}
|
||||
|
@ -138,6 +138,7 @@ typedef struct mii_softc mii_softc_t;
|
||||
#define MIIF_IS_1000X 0x0080 /* is a 1000BASE-X device */
|
||||
#define MIIF_DOPAUSE 0x0100 /* advertise PAUSE capability */
|
||||
#define MIIF_IS_HPNA 0x0200 /* is a HomePNA device */
|
||||
#define MIIF_FORCEANEG 0x0400 /* force auto-negotiation */
|
||||
|
||||
/* Default mii_anegticks values */
|
||||
#define MII_ANEGTICKS 5
|
||||
|
Loading…
Reference in New Issue
Block a user