Lines Matching refs:phy

70 static inline int mtkswitch_portforphy(int phy);
112 int phy, err = 0; in mtkswitch_attach_phys() local
117 for (phy = 0; phy < sc->numphys; phy++) { in mtkswitch_attach_phys()
118 if ((sc->phymap & (1u << phy)) == 0) { in mtkswitch_attach_phys()
119 sc->ifp[phy] = NULL; in mtkswitch_attach_phys()
120 sc->ifname[phy] = NULL; in mtkswitch_attach_phys()
121 sc->miibus[phy] = NULL; in mtkswitch_attach_phys()
124 sc->ifp[phy] = if_alloc(IFT_ETHER); in mtkswitch_attach_phys()
125 if (sc->ifp[phy] == NULL) { in mtkswitch_attach_phys()
131 sc->ifp[phy]->if_softc = sc; in mtkswitch_attach_phys()
132 sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST | in mtkswitch_attach_phys()
134 sc->ifname[phy] = malloc(strlen(name) + 1, M_DEVBUF, M_WAITOK); in mtkswitch_attach_phys()
135 bcopy(name, sc->ifname[phy], strlen(name) + 1); in mtkswitch_attach_phys()
136 if_initname(sc->ifp[phy], sc->ifname[phy], in mtkswitch_attach_phys()
137 mtkswitch_portforphy(phy)); in mtkswitch_attach_phys()
138 err = mii_attach(sc->sc_dev, &sc->miibus[phy], sc->ifp[phy], in mtkswitch_attach_phys()
140 BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0); in mtkswitch_attach_phys()
144 phy); in mtkswitch_attach_phys()
147 "%s\n", device_get_nameunit(sc->miibus[phy]), in mtkswitch_attach_phys()
148 sc->ifp[phy]->if_xname); in mtkswitch_attach_phys()
261 int phy; in mtkswitch_detach() local
265 for (phy = 0; phy < MTKSWITCH_MAX_PHYS; phy++) { in mtkswitch_detach()
266 if (sc->miibus[phy] != NULL) in mtkswitch_detach()
267 device_delete_child(dev, sc->miibus[phy]); in mtkswitch_detach()
268 if (sc->ifp[phy] != NULL) in mtkswitch_detach()
269 if_free(sc->ifp[phy]); in mtkswitch_detach()
270 free(sc->ifname[phy], M_DEVBUF); in mtkswitch_detach()
281 mtkswitch_portforphy(int phy) in mtkswitch_portforphy() argument
284 return (phy); in mtkswitch_portforphy()
297 int phy = mtkswitch_phyforport(port); in mtkswitch_miiforport() local
299 if (phy < 0 || phy >= MTKSWITCH_MAX_PHYS || sc->miibus[phy] == NULL) in mtkswitch_miiforport()
302 return (device_get_softc(sc->miibus[phy])); in mtkswitch_miiforport()
308 int phy = mtkswitch_phyforport(port); in mtkswitch_ifpforport() local
310 if (phy < 0 || phy >= MTKSWITCH_MAX_PHYS) in mtkswitch_ifpforport()
313 return (sc->ifp[phy]); in mtkswitch_ifpforport()
596 mtkswitch_readphy(device_t dev, int phy, int reg) in mtkswitch_readphy() argument
600 return (sc->hal.mtkswitch_phy_read(dev, phy, reg)); in mtkswitch_readphy()
604 mtkswitch_writephy(device_t dev, int phy, int reg, int val) in mtkswitch_writephy() argument
608 return (sc->hal.mtkswitch_phy_write(dev, phy, reg, val)); in mtkswitch_writephy()