dcphy.c (f34fa851e0b97ea3637d73827346927014e1b137) | dcphy.c (d9730b8b5308cdb98f8c628dc0a02c8182eca8af) |
---|---|
1/* 2 * Copyright (c) 1997, 1998, 1999 3 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 102 unchanged lines hidden (view full) --- 111static driver_t dcphy_driver = { 112 "dcphy", 113 dcphy_methods, 114 sizeof(struct mii_softc) 115}; 116 117DRIVER_MODULE(dcphy, miibus, dcphy_driver, dcphy_devclass, 0, 0); 118 | 1/* 2 * Copyright (c) 1997, 1998, 1999 3 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 102 unchanged lines hidden (view full) --- 111static driver_t dcphy_driver = { 112 "dcphy", 113 dcphy_methods, 114 sizeof(struct mii_softc) 115}; 116 117DRIVER_MODULE(dcphy, miibus, dcphy_driver, dcphy_devclass, 0, 0); 118 |
119int dcphy_service __P((struct mii_softc *, struct mii_data *, int)); 120void dcphy_status __P((struct mii_softc *)); 121static int dcphy_auto __P((struct mii_softc *, int)); 122static void dcphy_reset __P((struct mii_softc *)); | 119static int dcphy_service __P((struct mii_softc *, struct mii_data *, int)); 120static void dcphy_status __P((struct mii_softc *)); 121static void dcphy_reset __P((struct mii_softc *)); 122static int dcphy_auto __P((struct mii_softc *, int)); |
123 124static int dcphy_probe(dev) 125 device_t dev; 126{ 127 struct mii_attach_args *ma; 128 129 ma = device_get_ivars(dev); 130 --- 85 unchanged lines hidden (view full) --- 216 sc = device_get_softc(dev); 217 mii = device_get_softc(device_get_parent(dev)); 218 sc->mii_dev = NULL; 219 LIST_REMOVE(sc, mii_list); 220 221 return(0); 222} 223 | 123 124static int dcphy_probe(dev) 125 device_t dev; 126{ 127 struct mii_attach_args *ma; 128 129 ma = device_get_ivars(dev); 130 --- 85 unchanged lines hidden (view full) --- 216 sc = device_get_softc(dev); 217 mii = device_get_softc(device_get_parent(dev)); 218 sc->mii_dev = NULL; 219 LIST_REMOVE(sc, mii_list); 220 221 return(0); 222} 223 |
224int | 224static int |
225dcphy_service(sc, mii, cmd) 226 struct mii_softc *sc; 227 struct mii_data *mii; 228 int cmd; 229{ 230 struct dc_softc *dc_sc; 231 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 232 int reg; --- 80 unchanged lines hidden (view full) --- 313 case MII_TICK: 314 /* 315 * If we're not currently selected, just return. 316 */ 317 if (IFM_INST(ife->ifm_media) != sc->mii_inst) 318 return (0); 319 320 /* | 225dcphy_service(sc, mii, cmd) 226 struct mii_softc *sc; 227 struct mii_data *mii; 228 int cmd; 229{ 230 struct dc_softc *dc_sc; 231 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 232 int reg; --- 80 unchanged lines hidden (view full) --- 313 case MII_TICK: 314 /* 315 * If we're not currently selected, just return. 316 */ 317 if (IFM_INST(ife->ifm_media) != sc->mii_inst) 318 return (0); 319 320 /* |
321 * Only used for autonegotiation. | 321 * Is the interface even up? |
322 */ | 322 */ |
323 if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) | 323 if ((mii->mii_ifp->if_flags & IFF_UP) == 0) |
324 return (0); 325 326 /* | 324 return (0); 325 326 /* |
327 * Is the interface even up? | 327 * Only used for autonegotiation. |
328 */ | 328 */ |
329 if ((mii->mii_ifp->if_flags & IFF_UP) == 0) 330 return (0); | 329 if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) 330 break; |
331 332 reg = CSR_READ_4(dc_sc, DC_10BTSTAT) & 333 (DC_TSTAT_LS10|DC_TSTAT_LS100); 334 335 if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100)) | 331 332 reg = CSR_READ_4(dc_sc, DC_10BTSTAT) & 333 (DC_TSTAT_LS10|DC_TSTAT_LS100); 334 335 if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100)) |
336 return(0); | 336 break; |
337 338 /* 339 * Only retry autonegotiation every 5 seconds. 340 */ 341 if (++sc->mii_ticks != 50) 342 return (0); 343 344 sc->mii_ticks = 0; 345 /*if (DC_IS_INTEL(dc_sc))*/ 346 sc->mii_flags &= ~MIIF_DOINGAUTO; 347 dcphy_auto(sc, 0); 348 349 break; 350 } 351 352 /* Update the media status. */ 353 dcphy_status(sc); 354 355 /* Callback if something changed. */ | 337 338 /* 339 * Only retry autonegotiation every 5 seconds. 340 */ 341 if (++sc->mii_ticks != 50) 342 return (0); 343 344 sc->mii_ticks = 0; 345 /*if (DC_IS_INTEL(dc_sc))*/ 346 sc->mii_flags &= ~MIIF_DOINGAUTO; 347 dcphy_auto(sc, 0); 348 349 break; 350 } 351 352 /* Update the media status. */ 353 dcphy_status(sc); 354 355 /* Callback if something changed. */ |
356 if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { 357 MIIBUS_STATCHG(sc->mii_dev); 358 sc->mii_active = mii->mii_media_active; 359 } | 356 mii_phy_update(sc, cmd); |
360 return (0); 361} 362 | 357 return (0); 358} 359 |
363void | 360static void |
364dcphy_status(sc) 365 struct mii_softc *sc; 366{ 367 struct mii_data *mii = sc->mii_pdata; 368 int reg, anlpar, tstat = 0; 369 struct dc_softc *dc_sc; 370 371 dc_sc = mii->mii_ifp->if_softc; --- 142 unchanged lines hidden --- | 361dcphy_status(sc) 362 struct mii_softc *sc; 363{ 364 struct mii_data *mii = sc->mii_pdata; 365 int reg, anlpar, tstat = 0; 366 struct dc_softc *dc_sc; 367 368 dc_sc = mii->mii_ifp->if_softc; --- 142 unchanged lines hidden --- |