static int ruephy_probe(device_t dev) { struct mii_attach_args *ma; device_t parent; ma = device_get_ivars(dev); parent = device_get_parent(device_get_parent(dev)); /* * RealTek RTL8150 PHY doesn't have vendor/device ID registers: * the rue driver fakes up a return value of all zeros. */ if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 || MII_MODEL(ma->mii_id2) != 0) return (ENXIO); /* * Make sure the parent is an 'rue'. */ if (strcmp(device_get_name(parent), "rue") != 0) return (ENXIO); device_set_desc(dev, "RealTek RTL8150 internal media interface"); return (0); }
void ipgphy_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; const struct mii_phydesc *mpd; mpd = mii_phy_match(ma, ipgphys); 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 = &ipgphy_funcs; sc->mii_model = MII_MODEL(ma->mii_id2); sc->mii_pdata = mii; sc->mii_flags = ma->mii_flags; sc->mii_flags |= MIIF_NOISOLATE; PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; if (sc->mii_capabilities & BMSR_EXTSTAT) sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); mii_phy_add_media(sc); }
static void ciphy_fixup(struct mii_softc *sc) { uint16_t model, status, speed; device_t parent; model = MII_MODEL(PHY_READ(sc, CIPHY_MII_PHYIDR2)); status = PHY_READ(sc, CIPHY_MII_AUXCSR); speed = status & CIPHY_AUXCSR_SPEED; parent = device_get_parent(sc->mii_dev); if (strncmp(device_get_name(parent), "nfe", 3) == 0) { /* Need to set for 2.5V RGMII for NVIDIA adapters */ PHY_SETBIT(sc, CIPHY_MII_ECTL1, CIPHY_INTSEL_RGMII); PHY_SETBIT(sc, CIPHY_MII_ECTL1, CIPHY_IOVOL_2500MV); } switch (model) { case MII_MODEL_CICADA_CS8201: /* MII_MODEL_xxCICADA_CS8201 */ /* Turn off "aux mode" (whatever that means) */ PHY_SETBIT(sc, CIPHY_MII_AUXCSR, CIPHY_AUXCSR_MDPPS); /* * Work around speed polling bug in VT3119/VT3216 * when using MII in full duplex mode. */ if ((speed == CIPHY_SPEED10 || speed == CIPHY_SPEED100) && (status & CIPHY_AUXCSR_FDX)) { PHY_SETBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); } else { PHY_CLRBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); } /* Enable link/activity LED blink. */ PHY_SETBIT(sc, CIPHY_MII_LED, CIPHY_LED_LINKACTBLINK); break; case MII_MODEL_CICADA_CS8201A: /* MII_MODEL_xxCICADA_CS8201A */ case MII_MODEL_CICADA_CS8201B: /* MII_MODEL_xxCICADA_CS8201B */ /* * Work around speed polling bug in VT3119/VT3216 * when using MII in full duplex mode. */ if ((speed == CIPHY_SPEED10 || speed == CIPHY_SPEED100) && (status & CIPHY_AUXCSR_FDX)) { PHY_SETBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); } else { PHY_CLRBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); } break; case MII_MODEL_VITESSE_VSC8601: break; default: device_printf(sc->mii_dev, "unknown CICADA PHY model %x\n", model); break; } }
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"); }
int rlphymatch(struct device *parent, void *match, void *aux) { struct mii_attach_args *ma = aux; char *devname; devname = parent->dv_cfdata->cf_driver->cd_name; if (mii_phy_match(ma, rlphys) != NULL) return (10); if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 || MII_MODEL(ma->mii_id2) != 0) return (0); if ((strcmp(devname, "re") != 0) && (strcmp(devname, "rl") != 0)) return (0); /* * A "real" phy should get preference, but on the 8139 there * is no phyid register. */ return (5); }
int rlphymatch(device_t parent, cfdata_t match, void *aux) { struct mii_attach_args *ma = aux; struct mii_data *mii = ma->mii_data; if (mii->mii_instance != 0) return 0; if (mii_phy_match(ma, rlphys) != NULL) return (10); if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 || MII_MODEL(ma->mii_id2) != 0) return 0; if (!device_is_a(parent, "rtk") && !device_is_a(parent, "re")) return 0; /* * A "real" phy should get preference, but on the 8139 there * is no phyid register. */ return 5; }
void bmtphyattach(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, bmtphys); printf(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2)); sc->mii_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; if (sc->mii_capabilities & BMSR_MEDIAMASK) mii_phy_add_media(sc); }
static void icsphyattach(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, icsphys); 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 = &icsphy_funcs; sc->mii_pdata = mii; sc->mii_flags = ma->mii_flags; sc->mii_anegticks = MII_ANEGTICKS; 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"); }
void ukphyattach(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(": Generic IEEE 802.3u media interface, rev. %d:", MII_REV(ma->mii_id2)); printf(" OUI 0x%06x, model 0x%04x\n", MII_OUI(ma->mii_id1, ma->mii_id2), MII_MODEL(ma->mii_id2)); sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; sc->mii_funcs = &ukphy_funcs; sc->mii_pdata = mii; sc->mii_flags = ma->mii_flags; /* * Don't do loopback on unknown PHYs. It might confuse some of them. */ sc->mii_flags |= MIIF_NOLOOP; PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; if (sc->mii_capabilities & BMSR_EXTSTAT) sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 && (sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0) printf("%s: no media present\n", sc->mii_dev.dv_xname); else mii_phy_add_media(sc); }
static int mlphy_probe(device_t dev) { struct mii_attach_args *ma; device_t parent; ma = device_get_ivars(dev); parent = device_get_parent(device_get_parent(dev)); /* * Micro Linear PHY reports oui == 0 model == 0 */ if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 || MII_MODEL(ma->mii_id2) != 0) return (ENXIO); /* * Make sure the parent is a `tl'. So far, I have only * encountered the 6692 on an Olicom card with a ThunderLAN * controller chip. */ if (strcmp(device_get_name(parent), "tl") != 0) return (ENXIO); device_set_desc(dev, "Micro Linear 6692 media interface"); return (0); }
int exphymatch(struct device *parent, void *match, void *aux) { struct mii_attach_args *ma = aux; /* * Since 3com's PHY for some xl adapters is braindead and doesn't * report the proper OUI/MODEL information, we have this stupid * match function. */ if ((strcmp(parent->dv_cfdata->cf_driver->cd_name, "xl") == 0) && ((MII_OUI(ma->mii_id1, ma->mii_id2) == 0 && MII_MODEL(ma->mii_id2) == 0) || (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_3COM && MII_MODEL(ma->mii_id2) == 0))) return (10); return (0); }
const struct mii_phydesc * mii_phy_match(const struct mii_attach_args *ma, const struct mii_phydesc *mpd) { for (; mpd->mpd_name != NULL; mpd++) { if (MII_OUI(ma->mii_id1, ma->mii_id2) == mpd->mpd_oui && MII_MODEL(ma->mii_id2) == mpd->mpd_model) return (mpd); } return (NULL); }
static int tdkphy_probe(device_t dev) { struct mii_attach_args *ma; ma = device_get_ivars(dev); if ((MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_TDK || MII_MODEL(ma->mii_id2) != MII_MODEL_TDK_78Q2120)) return (ENXIO); device_set_desc(dev, MII_STR_TDK_78Q2120); return (0); }
static int rgephy_attach(device_t dev) { struct rgephy_softc *rsc; struct mii_softc *sc; struct mii_attach_args *ma; struct mii_data *mii; const char *sep = ""; rsc = device_get_softc(dev); sc = &rsc->mii_sc; 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); sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; sc->mii_service = rgephy_service; sc->mii_pdata = mii; mii->mii_instance++; rsc->mii_model = MII_MODEL(ma->mii_id2); rsc->mii_revision = MII_REV(ma->mii_id2); #define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) #define PRINT(s) printf("%s%s", sep, s); sep = ", " #if 0 ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst), BMCR_LOOP|BMCR_S100); #endif sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; sc->mii_capabilities &= ~BMSR_ANEG; if (sc->mii_capabilities & BMSR_EXTSTAT) sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); device_printf(dev, " "); mii_phy_add_media(sc); /* RTL8169S do not report auto-sense; add manually. */ ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst), MII_NMEDIA); sep = ", "; PRINT("auto"); printf("\n"); #undef ADD #undef PRINT rgephy_reset(sc); MIIBUS_MEDIAINIT(sc->mii_dev); return (0); }
int mii_print(void *aux, const char *pnp) { struct mii_attach_args *ma = aux; if (pnp != NULL) printf("OUI 0x%06x model 0x%04x rev %d at %s", MII_OUI(ma->mii_id1, ma->mii_id2), MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2), pnp); printf(" phy %d", ma->mii_phyno); return (UNCONF); }
const struct mii_phydesc * mii_phy_match_gen(const struct mii_attach_args *ma, const struct mii_phydesc *mpd, size_t len) { for (; mpd->mpd_name != NULL; mpd = (const struct mii_phydesc *)((const char *)mpd + len)) { if (MII_OUI(ma->mii_id1, ma->mii_id2) == mpd->mpd_oui && MII_MODEL(ma->mii_id2) == mpd->mpd_model) return (mpd); } return (NULL); }
static void gentbiattach(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; int oui = MII_OUI(ma->mii_id1, ma->mii_id2); int model = MII_MODEL(ma->mii_id2); int rev = MII_REV(ma->mii_id2); const char *descr; if ((descr = mii_get_descr(oui, model)) != NULL) aprint_normal(": %s (OUI 0x%06x, model 0x%04x), rev. %d\n", descr, oui, model, rev); else aprint_normal(": OUI 0x%06x, model 0x%04x, rev. %d\n", oui, model, rev); aprint_naive(": Generic ten-bit interface\n"); sc->mii_dev = self; sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; sc->mii_mpd_oui = oui; sc->mii_mpd_model = model; sc->mii_mpd_rev = rev; sc->mii_funcs = &gentbi_funcs; sc->mii_pdata = mii; sc->mii_flags = ma->mii_flags; sc->mii_anegticks = MII_ANEGTICKS; PHY_RESET(sc); /* * Mask out all media in the BMSR. We only are really interested * in "auto". */ sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask & ~BMSR_MEDIAMASK; if (sc->mii_capabilities & BMSR_EXTSTAT) sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); aprint_normal_dev(self, ""); if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 && (sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0) aprint_error("no media present"); else mii_phy_add_media(sc); aprint_normal("\n"); }
int ukphy_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); mii_softc_init(sc, ma); 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_service = ukphy_service; sc->mii_pdata = mii; mii->mii_instance++; /* * Don't do loopback on unknown PHYs. It might confuse some of them. */ sc->mii_flags |= MIIF_NOLOOP; mii_phy_reset(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; if (sc->mii_capabilities & BMSR_EXTSTAT) sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); device_printf(dev, " "); if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 && (sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0) kprintf("no media present"); else mii_phy_add_media(sc); kprintf("\n"); MIIBUS_MEDIAINIT(sc->mii_dev); return(0); }
static int ip1000phy_attach(device_t dev) { struct mii_attach_args *ma; u_int flags; ma = device_get_ivars(dev); flags = MIIF_NOISOLATE | MIIF_NOMANPAUSE; if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxICPLUS_IP1000A && mii_dev_mac_match(dev, "stge") && (miibus_get_flags(dev) & MIIF_MACPRIV0) != 0) flags |= MIIF_PHYPRIV0; mii_phy_dev_attach(dev, flags, &ip1000phy_funcs, 1); return (0); }
int dcphy_match(struct device *parent, void *match, void *aux) { struct mii_attach_args *ma = aux; /* * The dc driver will report the 21143 vendor and device * ID to let us know that it wants us to attach. */ if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxDEC && MII_MODEL(ma->mii_id2) == MII_MODEL_xxDEC_xxDC) return (10); return (0); }
static int tqphymatch(device_t parent, cfdata_t match, void *aux) { struct mii_attach_args *ma = aux; if (mii_phy_match(ma, tqphys) != NULL) { /* The DIAG register is unreliable on early revisions. */ if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxTSC_78Q2120 && MII_REV(ma->mii_id2) <= 3) return (0); return (10); } return (0); }
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++; sc->mii_flags |= MIIF_NOISOLATE; #define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), BMCR_ISO); #if 0 ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst), BMCR_LOOP|BMCR_S100); #endif mii_phy_reset(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; device_printf(dev, " "); mii_add_media(mii, sc->mii_capabilities, sc->mii_inst); printf("\n"); #undef ADD MIIBUS_MEDIAINIT(sc->mii_dev); return(0); }
static int smcphy_attach(device_t dev) { struct mii_softc *sc; struct mii_attach_args *ma; const struct mii_phy_funcs *mpf; sc = device_get_softc(dev); ma = device_get_ivars(dev); if (MII_MODEL(ma->mii_id2) == MII_MODEL_SEEQ_80220) mpf = &smcphy80220_funcs; else mpf = &smcphy_funcs; mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE, mpf, 1); mii_phy_setmedia(sc); return (0); }
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"); if (!pmf_device_register(self, NULL, mii_phy_resume)) aprint_error_dev(self, "couldn't establish power handler\n"); }
void mii_phy_dev_attach(device_t dev, u_int flags, const struct mii_phy_funcs *mpf, int add_media) { 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 = ma->mii_data; LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); sc->mii_flags = flags | miibus_get_flags(dev); sc->mii_mpd_oui = MII_OUI(ma->mii_id1, ma->mii_id2); sc->mii_mpd_model = MII_MODEL(ma->mii_id2); sc->mii_mpd_rev = MII_REV(ma->mii_id2); sc->mii_capmask = ma->mii_capmask; sc->mii_inst = mii->mii_instance++; sc->mii_phy = ma->mii_phyno; sc->mii_offset = ma->mii_offset; sc->mii_funcs = mpf; sc->mii_pdata = mii; if (bootverbose) device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n", sc->mii_mpd_oui, sc->mii_mpd_model, sc->mii_mpd_rev); if (add_media == 0) return; PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask; if (sc->mii_capabilities & BMSR_EXTSTAT) sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); device_printf(dev, " "); mii_phy_add_media(sc); printf("\n"); MIIBUS_MEDIAINIT(sc->mii_dev); }
static int atphy_attach(device_t dev) { struct atphy_softc *asc; struct mii_softc *sc; struct mii_attach_args *ma; struct mii_data *mii; asc = device_get_softc(dev); sc = &asc->mii_sc; 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); sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; sc->mii_service = atphy_service; sc->mii_pdata = mii; sc->mii_anegticks = MII_ANEGTICKS_GIGE; mii->mii_instance++; asc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2); asc->mii_model = MII_MODEL(ma->mii_id2); asc->mii_rev = MII_REV(ma->mii_id2); if (bootverbose) device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n", asc->mii_oui, asc->mii_model, asc->mii_rev); atphy_reset(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; if (sc->mii_capabilities & BMSR_EXTSTAT) sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); device_printf(dev, " "); mii_phy_add_media(sc); printf("\n"); MIIBUS_MEDIAINIT(sc->mii_dev); return(0); }
int urlphy_match(struct device *parent, void *match, void *aux) { struct mii_attach_args *ma = aux; /* * RTL8150 reports OUT == 0, MODEL == 0 */ if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 && MII_MODEL(ma->mii_id2) != 0) return (0); /* * Make sure the parent is an 'url' device. */ if (strcmp(parent->dv_cfdata->cf_driver->cd_name, "url") != 0) return (0); return (10); }
static int urlphy_match(device_t parent, cfdata_t match, void *aux) { struct mii_attach_args *ma = aux; /* * RTL8150 reports OUI == 0, MODEL == 0 */ if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 && MII_MODEL(ma->mii_id2) != 0) return (0); /* * Make sure the parent is an 'url' device. */ if (!device_is_a(parent, "url")) return(0); return (10); }
int mlphy_probe(struct device *parent, void *match, void *aux) { struct mii_attach_args *ma = aux; /* * Micro Linear PHY reports oui == 0 model == 0 */ if (MII_OUI(ma->mii_id1, ma->mii_id2) != 0 || MII_MODEL(ma->mii_id2) != 0) return (0); /* * Make sure the parent is a `tl'. So far, I have only * encountered the 6692 on an Olicom card with a ThunderLAN * controller chip. */ if (strcmp(parent->dv_cfdata->cf_driver->cd_name, "tl") != 0) return (0); return (10); }
void atphy_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; const struct mii_phydesc *mpd; uint16_t bmsr; mpd = mii_phy_match(ma, etphys); 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_mpd_oui = MII_OUI(ma->mii_id1, ma->mii_id2); sc->mii_mpd_model = MII_MODEL(ma->mii_id2); sc->mii_mpd_rev = MII_REV(ma->mii_id2); sc->mii_funcs = &atphy_funcs; sc->mii_pdata = mii; sc->mii_flags = ma->mii_flags; if (atphy_is_gige(mpd)) sc->mii_anegticks = MII_ANEGTICKS_GIGE; else sc->mii_anegticks = MII_ANEGTICKS; sc->mii_flags |= MIIF_NOLOOP; PHY_RESET(sc); bmsr = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); sc->mii_capabilities = bmsr & ma->mii_capmask; if (atphy_is_gige(mpd) && (sc->mii_capabilities & BMSR_EXTSTAT)) sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); aprint_normal_dev(self, ""); mii_phy_add_media(sc); aprint_normal("\n"); }