本文整理汇总了C++中PHY_READ函数的典型用法代码示例。如果您正苦于以下问题:C++ PHY_READ函数的具体用法?C++ PHY_READ怎么用?C++ PHY_READ使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PHY_READ函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ipgphy_reset
void
ipgphy_reset(struct mii_softc *sc)
{
struct ifnet *ifp = sc->mii_pdata->mii_ifp;
struct stge_softc *stge_sc;
uint32_t reg;
mii_phy_reset(sc);
/* clear autoneg/full-duplex as we don't want it after reset */
reg = PHY_READ(sc, IPGPHY_MII_BMCR);
reg &= ~(IPGPHY_BMCR_AUTOEN | IPGPHY_BMCR_FDX);
PHY_WRITE(sc, MII_BMCR, reg);
if (sc->mii_model == MII_MODEL_ICPLUS_IP1000A &&
strcmp(ifp->if_xname, "stge") == 0) {
stge_sc = ifp->if_softc;
if (stge_sc->sc_rev >= 0x40 && stge_sc->sc_rev <= 0x4e)
ipgphy_load_dspcode(sc);
}
}
示例2: rgephy_loop
static void
rgephy_loop(struct mii_softc *sc)
{
int i;
if (sc->mii_mpd_model != MII_MODEL_REALTEK_RTL8251 &&
sc->mii_mpd_rev < 2) {
PHY_WRITE(sc, RGEPHY_MII_BMCR, RGEPHY_BMCR_PDOWN);
DELAY(1000);
}
for (i = 0; i < 15000; i++) {
if (!(PHY_READ(sc, RGEPHY_MII_BMSR) & RGEPHY_BMSR_LINK)) {
#if 0
device_printf(sc->mii_dev, "looped %d\n", i);
#endif
break;
}
DELAY(10);
}
}
示例3: sqphyattach
static void
sqphyattach(device_t parent, device_t self, void *aux)
{
struct mii_softc *sc = device_private(self);
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
const struct mii_phydesc *mpd;
mpd = mii_phy_match(ma, sqphys);
aprint_naive(": Media interface\n");
aprint_normal(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
sc->mii_dev = self;
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
sc->mii_pdata = mii;
sc->mii_flags = ma->mii_flags;
sc->mii_anegticks = MII_ANEGTICKS;
switch (MII_MODEL(ma->mii_id2)) {
case MII_MODEL_SEEQ_84220:
sc->mii_funcs = &sqphy_84220_funcs;
aprint_normal_dev(self, "using Seeq 84220 isolate/reset hack\n");
break;
default:
sc->mii_funcs = &sqphy_funcs;
}
PHY_RESET(sc);
sc->mii_capabilities =
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
aprint_normal_dev(self, "");
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
aprint_error("no media present");
else
mii_phy_add_media(sc);
aprint_normal("\n");
}
示例4: mvphyattach
static void
mvphyattach(device_t parent, device_t self, void *aux)
{
struct mii_softc *sc = device_private(self);
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
const struct mii_phydesc *mpd;
mpd = mii_phy_match(ma, mvphys);
aprint_naive(": Media interface\n");
aprint_normal(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
sc->mii_dev = self;
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
sc->mii_funcs = &mvphy_funcs;
sc->mii_pdata = mii;
sc->mii_flags = ma->mii_flags;
sc->mii_anegticks = MII_ANEGTICKS;
if (MV_PORT(sc) == 0) { /* NB: only when attaching first PHY */
/*
* Set the global switch settings and configure the
* CPU port since it does not probe as a visible PHY.
*/
MV_WRITE(sc, MII_MV_SWITCH_GLOBAL_ADDR, MV_ATU_CONTROL,
SM(MV_ATUCTRL_AGE_TIME_DEFAULT, MV_ATUCTRL_AGE_TIME)
| SM(MV_ATUCTRL_ATU_SIZE_DEFAULT, MV_ATUCTRL_ATU_SIZE));
mvphy_switchconfig(sc, MV_CPU_PORT);
}
PHY_RESET(sc);
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
aprint_normal_dev(self, "");
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
aprint_error("no media present");
else
mii_phy_add_media(sc);
aprint_normal("\n");
}
示例5: tdkphy_attach
static int
tdkphy_attach(device_t dev)
{
struct mii_softc *sc;
struct mii_attach_args *ma;
struct mii_data *mii;
sc = device_get_softc(dev);
ma = device_get_ivars(dev);
sc->mii_dev = device_get_parent(dev);
mii = device_get_softc(sc->mii_dev);
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
if (bootverbose)
device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
MII_OUI(ma->mii_id1, ma->mii_id2),
MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
sc->mii_service = tdkphy_service;
sc->mii_pdata = mii;
mii->mii_instance++;
/*
* Apparently, we can't do loopback on this PHY.
*/
sc->mii_flags |= MIIF_NOLOOP;
mii_phy_reset(sc);
sc->mii_capabilities =
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
device_printf(dev, " ");
mii_phy_add_media(sc);
printf("\n");
MIIBUS_MEDIAINIT(sc->mii_dev);
return (0);
}
示例6: mii_phy_reset
void
mii_phy_reset(struct mii_softc *sc)
{
int reg, i;
if (sc->mii_flags & MIIF_NOISOLATE)
reg = BMCR_RESET;
else
reg = BMCR_RESET | BMCR_ISO;
PHY_WRITE(sc, MII_BMCR, reg);
/* Wait 100ms for it to complete. */
for (i = 0; i < 100; i++) {
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);
}
示例7: brgphy_mii_phy_auto
static void
brgphy_mii_phy_auto(struct mii_softc *sc)
{
int ktcr;
brgphy_reset(sc);
PHY_WRITE(sc, BRGPHY_MII_ANAR,
BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA);
DELAY(1000);
ktcr = BRGPHY_1000CTL_AFD|BRGPHY_1000CTL_AHD;
if (sc->mii_model == MII_MODEL_xxBROADCOM_BCM5701)
ktcr |= BRGPHY_1000CTL_MSE|BRGPHY_1000CTL_MSC;
PHY_WRITE(sc, BRGPHY_MII_1000CTL, ktcr);
ktcr = PHY_READ(sc, BRGPHY_MII_1000CTL);
DELAY(1000);
PHY_WRITE(sc, BRGPHY_MII_BMCR,
BRGPHY_BMCR_AUTOEN | BRGPHY_BMCR_STARTNEG);
PHY_WRITE(sc, BRGPHY_MII_IMR, 0xFF00);
}
示例8: acphyattach
void
acphyattach(struct device *parent, struct device *self, void *aux)
{
struct mii_softc *sc = (struct mii_softc *)self;
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
const struct mii_phydesc *mpd;
mpd = mii_phy_match(ma, acphys);
printf(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
sc->mii_funcs = &acphy_funcs;
sc->mii_pdata = mii;
sc->mii_flags = ma->mii_flags;
sc->mii_anegticks = MII_ANEGTICKS;
PHY_RESET(sc);
/*
* XXX Check MCR_FX_SEL to set MIIF_HAVE_FIBER?
*/
sc->mii_capabilities =
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
if (sc->mii_flags & MIIF_HAVEFIBER) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_FX, 0, sc->mii_inst),
MII_MEDIA_100_TX);
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_FX, IFM_FDX, sc->mii_inst),
MII_MEDIA_100_TX);
}
#undef ADD
if (sc->mii_capabilities & BMSR_MEDIAMASK)
mii_phy_add_media(sc);
}
示例9: urlphy_attach
static void
urlphy_attach(device_t parent, device_t self, void *aux)
{
struct mii_softc *sc = device_private(self);
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
aprint_naive(": Media interface\n");
aprint_normal(": Realtek RTL8150L internal media interface\n");
DPRINTF(("%s: %s: enter\n", device_xname(self), __func__));
sc->mii_dev = self;
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
sc->mii_funcs = &urlphy_funcs;
sc->mii_pdata = mii;
sc->mii_flags = mii->mii_flags;
sc->mii_anegticks = MII_ANEGTICKS_GIGE;
/* Don't do loopback on this PHY. */
sc->mii_flags |= MIIF_NOLOOP;
/* Don't do isolate on this PHY. */
sc->mii_flags |= MIIF_NOISOLATE;
if (mii->mii_instance != 0) {
aprint_error_dev(self, "ignoring this PHY, non-zero instance\n");
return;
}
PHY_RESET(sc);
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
aprint_normal_dev(self, "");
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
aprint_error("no media present");
else
mii_phy_add_media(sc);
aprint_normal("\n");
}
示例10: urlphy_attach
void
urlphy_attach(struct device *parent, struct device *self, void *aux)
{
struct mii_softc *sc = (struct mii_softc *)self;
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
printf(": Realtek RTL8150L internal media interface\n");
DPRINTF(("%s: %s: enter\n", sc->mii_dev.dv_xname, __FUNCTION__));
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
sc->mii_funcs = &urlphy_funcs;
sc->mii_pdata = mii;
sc->mii_flags = mii->mii_flags;
sc->mii_anegticks = 10;
/* Don't do loopback on this PHY. */
sc->mii_flags |= MIIF_NOLOOP;
/* Don't do isolate on this PHY. */
sc->mii_flags |= MIIF_NOISOLATE;
if (mii->mii_instance != 0) {
printf("%s: ignoring this PHY, non-zero instance\n",
sc->mii_dev.dv_xname);
return;
}
PHY_RESET(sc);
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
printf("%s: ", sc->mii_dev.dv_xname);
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
printf("no media present");
else
mii_phy_add_media(sc);
printf("\n");
}
示例11: smcphy_reset
static void
smcphy_reset(struct mii_softc *sc)
{
u_int bmcr;
int timeout;
PHY_WRITE(sc, MII_BMCR, BMCR_RESET);
for (timeout = 2; timeout > 0; timeout--) {
DELAY(50000);
bmcr = PHY_READ(sc, MII_BMCR);
if ((bmcr & BMCR_RESET) == 0)
break;
}
if (bmcr & BMCR_RESET)
device_printf(sc->mii_dev, "reset failed\n");
PHY_WRITE(sc, MII_BMCR, 0x3000);
/* Mask interrupts, we poll instead. */
PHY_WRITE(sc, 0x1e, 0xffc0);
}
示例12: nsphy_reset
static void
nsphy_reset(struct mii_softc *sc)
{
int reg, i;
if (sc->mii_flags & MIIF_NOISOLATE)
reg = BMCR_RESET;
else
reg = BMCR_RESET | BMCR_ISO;
PHY_WRITE(sc, MII_BMCR, reg);
/*
* Give it a little time to settle in case we just got power.
* The DP83840A data sheet suggests that a soft reset not happen
* within 500us of power being applied. Be conservative.
*/
delay(1000);
/*
* Wait another 2s for it to complete.
* This is only a little overkill as under normal circumstances
* the PHY can take up to 1s to complete reset.
* This is also a bit odd because after a reset, the BMCR will
* clear the reset bit and simply reports 0 even though the reset
* is not yet complete.
*/
for (i = 0; i < 1000; i++) {
reg = PHY_READ(sc, MII_BMCR);
if (reg && ((reg & BMCR_RESET) == 0))
break;
delay(2000);
}
if (sc->mii_inst != 0 && ((sc->mii_flags & MIIF_NOISOLATE) == 0)) {
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
}
}
示例13: rlphyattach
void
rlphyattach(device_t parent, device_t self, void *aux)
{
struct rlphy_softc *rsc = device_private(self);
struct mii_softc *sc = &rsc->sc_mii;
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
aprint_naive("\n");
if (MII_MODEL(ma->mii_id2) == MII_MODEL_yyREALTEK_RTL8201L) {
rsc->sc_rtl8201l = 1;
aprint_normal(": %s, rev. %d\n", MII_STR_yyREALTEK_RTL8201L,
MII_REV(ma->mii_id2));
} else
aprint_normal(": Realtek internal PHY\n");
sc->mii_dev = self;
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
sc->mii_funcs = &rlphy_funcs;
sc->mii_pdata = mii;
sc->mii_flags = ma->mii_flags;
sc->mii_flags |= MIIF_NOISOLATE;
PHY_RESET(sc);
aprint_normal_dev(self, "");
sc->mii_capabilities =
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
if (sc->mii_capabilities & BMSR_MEDIAMASK)
mii_phy_add_media(sc);
aprint_normal("\n");
if (!pmf_device_register(self, NULL, mii_phy_resume))
aprint_error_dev(self, "couldn't establish power handler\n");
}
示例14: eephy_reset
static void
eephy_reset(struct mii_softc *sc)
{
u_int32_t reg;
int i;
/* initialize custom E1000 registers to magic values */
reg = PHY_READ(sc, E1000_SCR);
reg &= ~E1000_SCR_AUTO_X_MODE;
PHY_WRITE(sc, E1000_SCR, reg);
/* normal PHY reset */
/*mii_phy_reset(sc);*/
reg = PHY_READ(sc, E1000_CR);
reg |= E1000_CR_RESET;
PHY_WRITE(sc, E1000_CR, reg);
for (i = 0; i < 500; i++) {
DELAY(1);
reg = PHY_READ(sc, E1000_CR);
if (!(reg & E1000_CR_RESET))
break;
}
/* set more custom E1000 registers to magic values */
#if defined(OCELOT_G)
reg = PHY_READ(sc, E1000_LCR);
reg |= E1000_LCR_LINK;
PHY_WRITE(sc, E1000_LCR, reg);
#endif
reg = PHY_READ(sc, E1000_SCR);
reg |= E1000_SCR_ASSERT_CRS_ON_TX;
PHY_WRITE(sc, E1000_SCR, reg);
reg = PHY_READ(sc, E1000_ESCR);
reg |= E1000_ESCR_TX_CLK_25;
PHY_WRITE(sc, E1000_ESCR, reg);
/* even more magic to reset DSP? */
PHY_WRITE(sc, 29, 0x1d);
PHY_WRITE(sc, 30, 0xc1);
PHY_WRITE(sc, 30, 0x00);
}
示例15: bmtphyattach
static void
bmtphyattach(device_t parent, device_t self, void *aux)
{
struct mii_softc *sc = device_private(self);
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
const struct mii_phydesc *mpd;
mpd = mii_phy_match(ma, bmtphys);
aprint_naive(": Media interface\n");
aprint_normal(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
sc->mii_dev = self;
sc->mii_mpd_model = MII_MODEL(ma->mii_id2);
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
sc->mii_funcs = &bmtphy_funcs;
sc->mii_pdata = mii;
sc->mii_flags = ma->mii_flags;
sc->mii_anegticks = MII_ANEGTICKS;
PHY_RESET(sc);
/*
* XXX Check AUX_STS_FX_MODE to set MIIF_HAVE_FIBER?
*/
sc->mii_capabilities =
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
aprint_normal_dev(self, "");
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
aprint_error("no media present");
else
mii_phy_add_media(sc);
aprint_normal("\n");
}