Some style changes to a couple of PHY drivers:
- Fix some whitespace nits. - Fix some spelling in comments. - Use MII_ANEGTICKS instead of 5. - Don't define variables in nested scope. - Remove superfluous returns at the end of void functions. - Remove unused static global rgephy_mii_model. - Remove dupe $Id$ in tdkphy(4). - Sort brgphys table. MFC after: 2 weeks
This commit is contained in:
parent
d00947d83a
commit
028ccec463
@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/bus.h>
|
#include <sys/bus.h>
|
||||||
|
|
||||||
|
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
#include <net/if_media.h>
|
#include <net/if_media.h>
|
||||||
@ -102,16 +101,16 @@ static const struct mii_phydesc brgphys[] = {
|
|||||||
MII_PHY_DESC(xxBROADCOM, BCM5400),
|
MII_PHY_DESC(xxBROADCOM, BCM5400),
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5401),
|
MII_PHY_DESC(xxBROADCOM, BCM5401),
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5411),
|
MII_PHY_DESC(xxBROADCOM, BCM5411),
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5752),
|
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5701),
|
MII_PHY_DESC(xxBROADCOM, BCM5701),
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5703),
|
MII_PHY_DESC(xxBROADCOM, BCM5703),
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5704),
|
MII_PHY_DESC(xxBROADCOM, BCM5704),
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5705),
|
MII_PHY_DESC(xxBROADCOM, BCM5705),
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5750),
|
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5714),
|
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5780),
|
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5706C),
|
MII_PHY_DESC(xxBROADCOM, BCM5706C),
|
||||||
MII_PHY_DESC(xxBROADCOM, BCM5708C),
|
MII_PHY_DESC(xxBROADCOM, BCM5708C),
|
||||||
|
MII_PHY_DESC(xxBROADCOM, BCM5714),
|
||||||
|
MII_PHY_DESC(xxBROADCOM, BCM5750),
|
||||||
|
MII_PHY_DESC(xxBROADCOM, BCM5752),
|
||||||
|
MII_PHY_DESC(xxBROADCOM, BCM5780),
|
||||||
MII_PHY_END
|
MII_PHY_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -160,7 +159,6 @@ brgphy_attach(device_t dev)
|
|||||||
brgphy_mii_model = MII_MODEL(ma->mii_id2);
|
brgphy_mii_model = MII_MODEL(ma->mii_id2);
|
||||||
brgphy_reset(sc);
|
brgphy_reset(sc);
|
||||||
|
|
||||||
|
|
||||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||||
sc->mii_capabilities &= ~BMSR_ANEG;
|
sc->mii_capabilities &= ~BMSR_ANEG;
|
||||||
device_printf(dev, " ");
|
device_printf(dev, " ");
|
||||||
@ -197,7 +195,7 @@ brgphy_attach(device_t dev)
|
|||||||
#undef PRINT
|
#undef PRINT
|
||||||
|
|
||||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -266,7 +264,7 @@ setit:
|
|||||||
PHY_WRITE(sc, BRGPHY_MII_BMCR, speed);
|
PHY_WRITE(sc, BRGPHY_MII_BMCR, speed);
|
||||||
PHY_WRITE(sc, BRGPHY_MII_ANAR, BRGPHY_SEL_TYPE);
|
PHY_WRITE(sc, BRGPHY_MII_ANAR, BRGPHY_SEL_TYPE);
|
||||||
|
|
||||||
if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T)
|
if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
PHY_WRITE(sc, BRGPHY_MII_1000CTL, gig);
|
PHY_WRITE(sc, BRGPHY_MII_1000CTL, gig);
|
||||||
@ -277,7 +275,7 @@ setit:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When settning the link manually, one side must
|
* When setting the link manually, one side must
|
||||||
* be the master and the other the slave. However
|
* be the master and the other the slave. However
|
||||||
* ifmedia doesn't give us a good way to specify
|
* ifmedia doesn't give us a good way to specify
|
||||||
* this, so we fake it by using one of the LINK
|
* this, so we fake it by using one of the LINK
|
||||||
@ -334,9 +332,9 @@ setit:
|
|||||||
/*
|
/*
|
||||||
* Only retry autonegotiation every 5 seconds.
|
* Only retry autonegotiation every 5 seconds.
|
||||||
*/
|
*/
|
||||||
if (++sc->mii_ticks <= 5)
|
if (++sc->mii_ticks <= MII_ANEGTICKS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sc->mii_ticks = 0;
|
sc->mii_ticks = 0;
|
||||||
brgphy_mii_phy_auto(sc);
|
brgphy_mii_phy_auto(sc);
|
||||||
break;
|
break;
|
||||||
@ -350,7 +348,7 @@ setit:
|
|||||||
* the DSP on the Broadcom PHYs if the media changes.
|
* the DSP on the Broadcom PHYs if the media changes.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (sc->mii_media_active != mii->mii_media_active ||
|
if (sc->mii_media_active != mii->mii_media_active ||
|
||||||
sc->mii_media_status != mii->mii_media_status ||
|
sc->mii_media_status != mii->mii_media_status ||
|
||||||
cmd == MII_MEDIACHG) {
|
cmd == MII_MEDIACHG) {
|
||||||
switch (brgphy_mii_model) {
|
switch (brgphy_mii_model) {
|
||||||
@ -424,11 +422,8 @@ brgphy_status(struct mii_softc *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mii->mii_media_active = ife->ifm_media;
|
mii->mii_media_active = ife->ifm_media;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
brgphy_mii_phy_auto(struct mii_softc *mii)
|
brgphy_mii_phy_auto(struct mii_softc *mii)
|
||||||
{
|
{
|
||||||
@ -454,13 +449,11 @@ brgphy_mii_phy_auto(struct mii_softc *mii)
|
|||||||
static void
|
static void
|
||||||
brgphy_loop(struct mii_softc *sc)
|
brgphy_loop(struct mii_softc *sc)
|
||||||
{
|
{
|
||||||
u_int32_t bmsr;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
PHY_WRITE(sc, BRGPHY_MII_BMCR, BRGPHY_BMCR_LOOP);
|
PHY_WRITE(sc, BRGPHY_MII_BMCR, BRGPHY_BMCR_LOOP);
|
||||||
for (i = 0; i < 15000; i++) {
|
for (i = 0; i < 15000; i++) {
|
||||||
bmsr = PHY_READ(sc, BRGPHY_MII_BMSR);
|
if (!(PHY_READ(sc, BRGPHY_MII_BMSR) & BRGPHY_BMSR_LINK)) {
|
||||||
if (!(bmsr & BRGPHY_BMSR_LINK)) {
|
|
||||||
#if 0
|
#if 0
|
||||||
device_printf(sc->mii_dev, "looped %d\n", i);
|
device_printf(sc->mii_dev, "looped %d\n", i);
|
||||||
#endif
|
#endif
|
||||||
@ -637,31 +630,30 @@ brgphy_reset(struct mii_softc *sc)
|
|||||||
|
|
||||||
/* Enable Link LED on Dell boxes */
|
/* Enable Link LED on Dell boxes */
|
||||||
if (bge_sc->bge_flags & BGE_FLAG_NO3LED) {
|
if (bge_sc->bge_flags & BGE_FLAG_NO3LED) {
|
||||||
PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL,
|
PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL,
|
||||||
PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL)
|
PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL) &
|
||||||
& ~BRGPHY_PHY_EXTCTL_3_LED);
|
~BRGPHY_PHY_EXTCTL_3_LED);
|
||||||
}
|
}
|
||||||
} else if (bce_sc) {
|
} else if (bce_sc) {
|
||||||
|
|
||||||
/* Set or clear jumbo frame settings in the PHY. */
|
/* Set or clear jumbo frame settings in the PHY. */
|
||||||
if (ifp->if_mtu > ETHER_MAX_LEN) {
|
if (ifp->if_mtu > ETHER_MAX_LEN) {
|
||||||
PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x7);
|
PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x7);
|
||||||
val = PHY_READ(sc, BRGPHY_MII_AUXCTL);
|
val = PHY_READ(sc, BRGPHY_MII_AUXCTL);
|
||||||
PHY_WRITE(sc, BRGPHY_MII_AUXCTL,
|
PHY_WRITE(sc, BRGPHY_MII_AUXCTL,
|
||||||
val | BRGPHY_AUXCTL_LONG_PKT);
|
val | BRGPHY_AUXCTL_LONG_PKT);
|
||||||
|
|
||||||
val = PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL);
|
val = PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL);
|
||||||
PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL,
|
PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL,
|
||||||
val | BRGPHY_PHY_EXTCTL_HIGH_LA);
|
val | BRGPHY_PHY_EXTCTL_HIGH_LA);
|
||||||
} else {
|
} else {
|
||||||
PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x7);
|
PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x7);
|
||||||
val = PHY_READ(sc, BRGPHY_MII_AUXCTL);
|
val = PHY_READ(sc, BRGPHY_MII_AUXCTL);
|
||||||
PHY_WRITE(sc, BRGPHY_MII_AUXCTL,
|
PHY_WRITE(sc, BRGPHY_MII_AUXCTL,
|
||||||
val & ~(BRGPHY_AUXCTL_LONG_PKT | 0x7));
|
val & ~(BRGPHY_AUXCTL_LONG_PKT | 0x7));
|
||||||
|
|
||||||
val = PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL);
|
val = PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL);
|
||||||
PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL,
|
PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL,
|
||||||
val & ~BRGPHY_PHY_EXTCTL_HIGH_LA);
|
val & ~BRGPHY_PHY_EXTCTL_HIGH_LA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable Ethernet@Wirespeed */
|
/* Enable Ethernet@Wirespeed */
|
||||||
|
@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/bus.h>
|
#include <sys/bus.h>
|
||||||
|
|
||||||
|
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
#include <net/if_media.h>
|
#include <net/if_media.h>
|
||||||
@ -265,7 +264,7 @@ setit:
|
|||||||
/*
|
/*
|
||||||
* Only retry autonegotiation every 5 seconds.
|
* Only retry autonegotiation every 5 seconds.
|
||||||
*/
|
*/
|
||||||
if (++sc->mii_ticks <= 5/*10*/)
|
if (++sc->mii_ticks <= MII_ANEGTICKS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sc->mii_ticks = 0;
|
sc->mii_ticks = 0;
|
||||||
@ -335,17 +334,14 @@ ciphy_status(struct mii_softc *sc)
|
|||||||
|
|
||||||
if (bmsr & CIPHY_AUXCSR_FDX)
|
if (bmsr & CIPHY_AUXCSR_FDX)
|
||||||
mii->mii_media_active |= IFM_FDX;
|
mii->mii_media_active |= IFM_FDX;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ciphy_reset(struct mii_softc *sc)
|
ciphy_reset(struct mii_softc *sc)
|
||||||
{
|
{
|
||||||
|
|
||||||
mii_phy_reset(sc);
|
mii_phy_reset(sc);
|
||||||
DELAY(1000);
|
DELAY(1000);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PHY_SETBIT(x, y, z) \
|
#define PHY_SETBIT(x, y, z) \
|
||||||
@ -405,6 +401,4 @@ ciphy_fixup(struct mii_softc *sc)
|
|||||||
model);
|
model);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ mlphy_attach(dev)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
#undef ADD
|
#undef ADD
|
||||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -184,12 +184,11 @@ mlphy_service(xsc, mii, cmd)
|
|||||||
int cmd;
|
int cmd;
|
||||||
{
|
{
|
||||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||||
int reg;
|
|
||||||
struct mii_softc *other = NULL;
|
struct mii_softc *other = NULL;
|
||||||
struct mlphy_softc *msc = (struct mlphy_softc *)xsc;
|
struct mlphy_softc *msc = (struct mlphy_softc *)xsc;
|
||||||
struct mii_softc *sc = (struct mii_softc *)&msc->ml_mii;
|
struct mii_softc *sc = (struct mii_softc *)&msc->ml_mii;
|
||||||
device_t *devlist;
|
device_t *devlist;
|
||||||
int devs, i;
|
int devs, i, other_inst, reg;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See if there's another PHY on this bus with us.
|
* See if there's another PHY on this bus with us.
|
||||||
@ -244,7 +243,7 @@ mlphy_service(xsc, mii, cmd)
|
|||||||
}
|
}
|
||||||
(void) mii_phy_auto(sc);
|
(void) mii_phy_auto(sc);
|
||||||
msc->ml_linked = 0;
|
msc->ml_linked = 0;
|
||||||
return(0);
|
return (0);
|
||||||
case IFM_10_T:
|
case IFM_10_T:
|
||||||
/*
|
/*
|
||||||
* For 10baseT modes, reset and program the
|
* For 10baseT modes, reset and program the
|
||||||
@ -337,9 +336,9 @@ mlphy_service(xsc, mii, cmd)
|
|||||||
/*
|
/*
|
||||||
* Only retry autonegotiation every 5 seconds.
|
* Only retry autonegotiation every 5 seconds.
|
||||||
*/
|
*/
|
||||||
if (++sc->mii_ticks <= 5)
|
if (++sc->mii_ticks <= MII_ANEGTICKS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sc->mii_ticks = 0;
|
sc->mii_ticks = 0;
|
||||||
msc->ml_linked = 0;
|
msc->ml_linked = 0;
|
||||||
mii->mii_media_active = IFM_NONE;
|
mii->mii_media_active = IFM_NONE;
|
||||||
@ -350,13 +349,12 @@ mlphy_service(xsc, mii, cmd)
|
|||||||
PHY_WRITE(other, MII_BMCR, BMCR_ISO);
|
PHY_WRITE(other, MII_BMCR, BMCR_ISO);
|
||||||
}
|
}
|
||||||
mii_phy_auto(sc);
|
mii_phy_auto(sc);
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the media status. */
|
/* Update the media status. */
|
||||||
|
|
||||||
if (msc->ml_state == ML_STATE_AUTO_OTHER) {
|
if (msc->ml_state == ML_STATE_AUTO_OTHER) {
|
||||||
int other_inst;
|
|
||||||
other_inst = other->mii_inst;
|
other_inst = other->mii_inst;
|
||||||
other->mii_inst = sc->mii_inst;
|
other->mii_inst = sc->mii_inst;
|
||||||
(void) (*other->mii_service)(other, mii, MII_POLLSTAT);
|
(void) (*other->mii_service)(other, mii, MII_POLLSTAT);
|
||||||
@ -385,8 +383,6 @@ mlphy_reset(sc)
|
|||||||
reg = PHY_READ(sc, MII_BMCR);
|
reg = PHY_READ(sc, MII_BMCR);
|
||||||
reg &= ~BMCR_AUTOEN;
|
reg &= ~BMCR_AUTOEN;
|
||||||
PHY_WRITE(sc, MII_BMCR, reg);
|
PHY_WRITE(sc, MII_BMCR, reg);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -431,6 +427,4 @@ mlphy_status(sc)
|
|||||||
mii_phy_reset(other);
|
mii_phy_reset(other);
|
||||||
mii_phy_auto(other);
|
mii_phy_auto(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/bus.h>
|
#include <sys/bus.h>
|
||||||
|
|
||||||
|
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
#include <net/if_media.h>
|
#include <net/if_media.h>
|
||||||
@ -88,7 +87,6 @@ static int rgephy_mii_phy_auto(struct mii_softc *);
|
|||||||
static void rgephy_reset(struct mii_softc *);
|
static void rgephy_reset(struct mii_softc *);
|
||||||
static void rgephy_loop(struct mii_softc *);
|
static void rgephy_loop(struct mii_softc *);
|
||||||
static void rgephy_load_dspcode(struct mii_softc *);
|
static void rgephy_load_dspcode(struct mii_softc *);
|
||||||
static int rgephy_mii_model;
|
|
||||||
|
|
||||||
static const struct mii_phydesc rgephys[] = {
|
static const struct mii_phydesc rgephys[] = {
|
||||||
MII_PHY_DESC(xxREALTEK, RTL8169S),
|
MII_PHY_DESC(xxREALTEK, RTL8169S),
|
||||||
@ -134,8 +132,6 @@ rgephy_attach(device_t dev)
|
|||||||
BMCR_LOOP|BMCR_S100);
|
BMCR_LOOP|BMCR_S100);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rgephy_mii_model = MII_MODEL(ma->mii_id2);
|
|
||||||
|
|
||||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||||
sc->mii_capabilities &= ~BMSR_ANEG;
|
sc->mii_capabilities &= ~BMSR_ANEG;
|
||||||
|
|
||||||
@ -155,7 +151,7 @@ rgephy_attach(device_t dev)
|
|||||||
|
|
||||||
rgephy_reset(sc);
|
rgephy_reset(sc);
|
||||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -238,7 +234,7 @@ setit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When settning the link manually, one side must
|
* When setting the link manually, one side must
|
||||||
* be the master and the other the slave. However
|
* be the master and the other the slave. However
|
||||||
* ifmedia doesn't give us a good way to specify
|
* ifmedia doesn't give us a good way to specify
|
||||||
* this, so we fake it by using one of the LINK
|
* this, so we fake it by using one of the LINK
|
||||||
@ -297,9 +293,9 @@ setit:
|
|||||||
/*
|
/*
|
||||||
* Only retry autonegotiation every 5 seconds.
|
* Only retry autonegotiation every 5 seconds.
|
||||||
*/
|
*/
|
||||||
if (++sc->mii_ticks <= 5/*10*/)
|
if (++sc->mii_ticks <= MII_ANEGTICKS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sc->mii_ticks = 0;
|
sc->mii_ticks = 0;
|
||||||
rgephy_mii_phy_auto(sc);
|
rgephy_mii_phy_auto(sc);
|
||||||
return (0);
|
return (0);
|
||||||
@ -313,7 +309,7 @@ setit:
|
|||||||
* the DSP on the RealTek PHYs if the media changes.
|
* the DSP on the RealTek PHYs if the media changes.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (sc->mii_media_active != mii->mii_media_active ||
|
if (sc->mii_media_active != mii->mii_media_active ||
|
||||||
sc->mii_media_status != mii->mii_media_status ||
|
sc->mii_media_status != mii->mii_media_status ||
|
||||||
cmd == MII_MEDIACHG) {
|
cmd == MII_MEDIACHG) {
|
||||||
rgephy_load_dspcode(sc);
|
rgephy_load_dspcode(sc);
|
||||||
@ -361,14 +357,12 @@ rgephy_status(struct mii_softc *sc)
|
|||||||
mii->mii_media_active |= IFM_NONE;
|
mii->mii_media_active |= IFM_NONE;
|
||||||
if (bmsr & RL_GMEDIASTAT_FDX)
|
if (bmsr & RL_GMEDIASTAT_FDX)
|
||||||
mii->mii_media_active |= IFM_FDX;
|
mii->mii_media_active |= IFM_FDX;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rgephy_mii_phy_auto(struct mii_softc *mii)
|
rgephy_mii_phy_auto(struct mii_softc *mii)
|
||||||
{
|
{
|
||||||
|
|
||||||
rgephy_loop(mii);
|
rgephy_loop(mii);
|
||||||
rgephy_reset(mii);
|
rgephy_reset(mii);
|
||||||
|
|
||||||
@ -388,15 +382,13 @@ rgephy_mii_phy_auto(struct mii_softc *mii)
|
|||||||
static void
|
static void
|
||||||
rgephy_loop(struct mii_softc *sc)
|
rgephy_loop(struct mii_softc *sc)
|
||||||
{
|
{
|
||||||
u_int32_t bmsr;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
PHY_WRITE(sc, RGEPHY_MII_BMCR, RGEPHY_BMCR_PDOWN);
|
PHY_WRITE(sc, RGEPHY_MII_BMCR, RGEPHY_BMCR_PDOWN);
|
||||||
DELAY(1000);
|
DELAY(1000);
|
||||||
|
|
||||||
for (i = 0; i < 15000; i++) {
|
for (i = 0; i < 15000; i++) {
|
||||||
bmsr = PHY_READ(sc, RGEPHY_MII_BMSR);
|
if (!(PHY_READ(sc, RGEPHY_MII_BMSR) & RGEPHY_BMSR_LINK)) {
|
||||||
if (!(bmsr & RGEPHY_BMSR_LINK)) {
|
|
||||||
#if 0
|
#if 0
|
||||||
device_printf(sc->mii_dev, "looped %d\n", i);
|
device_printf(sc->mii_dev, "looped %d\n", i);
|
||||||
#endif
|
#endif
|
||||||
@ -468,16 +460,15 @@ rgephy_load_dspcode(struct mii_softc *sc)
|
|||||||
PHY_SETBIT(sc, 4, 0x0800);
|
PHY_SETBIT(sc, 4, 0x0800);
|
||||||
PHY_CLRBIT(sc, 4, 0x0800);
|
PHY_CLRBIT(sc, 4, 0x0800);
|
||||||
PHY_WRITE(sc, 31, 0x0000);
|
PHY_WRITE(sc, 31, 0x0000);
|
||||||
|
|
||||||
DELAY(40);
|
DELAY(40);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rgephy_reset(struct mii_softc *sc)
|
rgephy_reset(struct mii_softc *sc)
|
||||||
{
|
{
|
||||||
|
|
||||||
mii_phy_reset(sc);
|
mii_phy_reset(sc);
|
||||||
DELAY(1000);
|
DELAY(1000);
|
||||||
rgephy_load_dspcode(sc);
|
rgephy_load_dspcode(sc);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
@ -62,13 +62,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include "miibus_if.h"
|
#include "miibus_if.h"
|
||||||
|
|
||||||
#if 0
|
|
||||||
#if !defined(lint)
|
|
||||||
static const char rcsid[] =
|
|
||||||
"$Id: tdkphy.c,v 1.18 2006/05/16 14:36:28 phk Exp $";
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int tdkphy_probe(device_t);
|
static int tdkphy_probe(device_t);
|
||||||
static int tdkphy_attach(device_t);
|
static int tdkphy_attach(device_t);
|
||||||
|
|
||||||
@ -151,8 +144,7 @@ tdkphy_attach(device_t dev)
|
|||||||
#undef ADD
|
#undef ADD
|
||||||
|
|
||||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||||
|
return (0);
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -142,11 +142,13 @@ tlphy_probe(device_t dev)
|
|||||||
static int
|
static int
|
||||||
tlphy_attach(device_t dev)
|
tlphy_attach(device_t dev)
|
||||||
{
|
{
|
||||||
|
device_t *devlist;
|
||||||
struct tlphy_softc *sc;
|
struct tlphy_softc *sc;
|
||||||
|
struct mii_softc *other;
|
||||||
struct mii_attach_args *ma;
|
struct mii_attach_args *ma;
|
||||||
struct mii_data *mii;
|
struct mii_data *mii;
|
||||||
const char *sep = "";
|
const char *sep = "";
|
||||||
int capmask = 0xFFFFFFFF;
|
int capmask, devs, i;
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
ma = device_get_ivars(dev);
|
ma = device_get_ivars(dev);
|
||||||
@ -159,11 +161,8 @@ tlphy_attach(device_t dev)
|
|||||||
sc->sc_mii.mii_service = tlphy_service;
|
sc->sc_mii.mii_service = tlphy_service;
|
||||||
sc->sc_mii.mii_pdata = mii;
|
sc->sc_mii.mii_pdata = mii;
|
||||||
|
|
||||||
|
capmask = 0xFFFFFFFF;
|
||||||
if (mii->mii_instance) {
|
if (mii->mii_instance) {
|
||||||
struct mii_softc *other;
|
|
||||||
device_t *devlist;
|
|
||||||
int devs, i;
|
|
||||||
|
|
||||||
device_get_children(sc->sc_mii.mii_dev, &devlist, &devs);
|
device_get_children(sc->sc_mii.mii_dev, &devlist, &devs);
|
||||||
for (i = 0; i < devs; i++) {
|
for (i = 0; i < devs; i++) {
|
||||||
if (strcmp(device_get_name(devlist[i]), "tlphy")) {
|
if (strcmp(device_get_name(devlist[i]), "tlphy")) {
|
||||||
@ -216,7 +215,7 @@ tlphy_attach(device_t dev)
|
|||||||
#undef ADD
|
#undef ADD
|
||||||
#undef PRINT
|
#undef PRINT
|
||||||
MIIBUS_MEDIAINIT(sc->sc_mii.mii_dev);
|
MIIBUS_MEDIAINIT(sc->sc_mii.mii_dev);
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -248,7 +247,7 @@ tlphy_service(struct mii_softc *self, struct mii_data *mii, int cmd)
|
|||||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO);
|
PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the interface is not up, don't do anything.
|
* If the interface is not up, don't do anything.
|
||||||
*/
|
*/
|
||||||
@ -313,7 +312,7 @@ tlphy_service(struct mii_softc *self, struct mii_data *mii, int cmd)
|
|||||||
/*
|
/*
|
||||||
* Only retry autonegotiation every 5 seconds.
|
* Only retry autonegotiation every 5 seconds.
|
||||||
*/
|
*/
|
||||||
if (++sc->sc_mii.mii_ticks <= 5)
|
if (++sc->sc_mii.mii_ticks <= MII_ANEGTICKS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sc->sc_mii.mii_ticks = 0;
|
sc->sc_mii.mii_ticks = 0;
|
||||||
@ -342,7 +341,7 @@ tlphy_status(struct tlphy_softc *sc)
|
|||||||
bmcr = PHY_READ(&sc->sc_mii, MII_BMCR);
|
bmcr = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||||
if (bmcr & BMCR_ISO) {
|
if (bmcr & BMCR_ISO) {
|
||||||
mii->mii_media_active |= IFM_NONE;
|
mii->mii_media_active |= IFM_NONE;
|
||||||
mii->mii_media_status = 0;
|
mii->mii_media_status = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +354,7 @@ tlphy_status(struct tlphy_softc *sc)
|
|||||||
|
|
||||||
bmsr = PHY_READ(&sc->sc_mii, MII_BMSR) |
|
bmsr = PHY_READ(&sc->sc_mii, MII_BMSR) |
|
||||||
PHY_READ(&sc->sc_mii, MII_BMSR);
|
PHY_READ(&sc->sc_mii, MII_BMSR);
|
||||||
if (bmsr & BMSR_LINK)
|
if (bmsr & BMSR_LINK)
|
||||||
mii->mii_media_status |= IFM_ACTIVE;
|
mii->mii_media_status |= IFM_ACTIVE;
|
||||||
|
|
||||||
if (bmcr & BMCR_LOOP)
|
if (bmcr & BMCR_LOOP)
|
||||||
|
@ -144,7 +144,7 @@ xmphy_attach(device_t dev)
|
|||||||
#undef PRINT
|
#undef PRINT
|
||||||
|
|
||||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -239,14 +239,14 @@ xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
|||||||
/*
|
/*
|
||||||
* Only retry autonegotiation every 5 seconds.
|
* Only retry autonegotiation every 5 seconds.
|
||||||
*/
|
*/
|
||||||
if (++sc->mii_ticks <= 5)
|
if (++sc->mii_ticks <= MII_ANEGTICKS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sc->mii_ticks = 0;
|
sc->mii_ticks = 0;
|
||||||
|
|
||||||
mii_phy_reset(sc);
|
mii_phy_reset(sc);
|
||||||
xmphy_mii_phy_auto(sc);
|
xmphy_mii_phy_auto(sc);
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the media status. */
|
/* Update the media status. */
|
||||||
@ -306,11 +306,8 @@ xmphy_status(struct mii_softc *sc)
|
|||||||
mii->mii_media_active |= IFM_FDX;
|
mii->mii_media_active |= IFM_FDX;
|
||||||
else
|
else
|
||||||
mii->mii_media_active |= IFM_HDX;
|
mii->mii_media_active |= IFM_HDX;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xmphy_mii_phy_auto(struct mii_softc *mii)
|
xmphy_mii_phy_auto(struct mii_softc *mii)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user