brgphy.c (83597) | brgphy.c (84145) |
---|---|
1/* 2 * Copyright (c) 2000 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 --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * | 1/* 2 * Copyright (c) 2000 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 --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * |
32 * $FreeBSD: head/sys/dev/mii/brgphy.c 83597 2001-09-18 00:31:19Z wpaul $ | 32 * $FreeBSD: head/sys/dev/mii/brgphy.c 84145 2001-09-29 19:18:52Z jlemon $ |
33 */ 34 35/* 36 * Driver for the Broadcom BCR5400 1000baseTX PHY. Speed is always 37 * 1000mbps; all we need to negotiate here is full or half duplex. 38 */ 39 40#include <sys/param.h> --- 13 unchanged lines hidden (view full) --- 54#include <dev/mii/miidevs.h> 55 56#include <dev/mii/brgphyreg.h> 57 58#include "miibus_if.h" 59 60#if !defined(lint) 61static const char rcsid[] = | 33 */ 34 35/* 36 * Driver for the Broadcom BCR5400 1000baseTX PHY. Speed is always 37 * 1000mbps; all we need to negotiate here is full or half duplex. 38 */ 39 40#include <sys/param.h> --- 13 unchanged lines hidden (view full) --- 54#include <dev/mii/miidevs.h> 55 56#include <dev/mii/brgphyreg.h> 57 58#include "miibus_if.h" 59 60#if !defined(lint) 61static const char rcsid[] = |
62 "$FreeBSD: head/sys/dev/mii/brgphy.c 83597 2001-09-18 00:31:19Z wpaul $"; | 62 "$FreeBSD: head/sys/dev/mii/brgphy.c 84145 2001-09-29 19:18:52Z jlemon $"; |
63#endif 64 65static int brgphy_probe __P((device_t)); 66static int brgphy_attach __P((device_t)); 67static int brgphy_detach __P((device_t)); 68 69static device_method_t brgphy_methods[] = { 70 /* device interface */ --- 9 unchanged lines hidden (view full) --- 80static driver_t brgphy_driver = { 81 "brgphy", 82 brgphy_methods, 83 sizeof(struct mii_softc) 84}; 85 86DRIVER_MODULE(brgphy, miibus, brgphy_driver, brgphy_devclass, 0, 0); 87 | 63#endif 64 65static int brgphy_probe __P((device_t)); 66static int brgphy_attach __P((device_t)); 67static int brgphy_detach __P((device_t)); 68 69static device_method_t brgphy_methods[] = { 70 /* device interface */ --- 9 unchanged lines hidden (view full) --- 80static driver_t brgphy_driver = { 81 "brgphy", 82 brgphy_methods, 83 sizeof(struct mii_softc) 84}; 85 86DRIVER_MODULE(brgphy, miibus, brgphy_driver, brgphy_devclass, 0, 0); 87 |
88int brgphy_service __P((struct mii_softc *, struct mii_data *, int)); 89void brgphy_status __P((struct mii_softc *)); 90 | 88static int brgphy_service(struct mii_softc *, struct mii_data *, int); 89static void brgphy_status(struct mii_softc *); |
91static int brgphy_mii_phy_auto __P((struct mii_softc *, int)); 92extern void mii_phy_auto_timeout __P((void *)); 93 94static int brgphy_probe(dev) 95 device_t dev; 96{ 97 struct mii_attach_args *ma; 98 --- 88 unchanged lines hidden (view full) --- 187 if (sc->mii_flags & MIIF_DOINGAUTO) 188 untimeout(mii_phy_auto_timeout, sc, sc->mii_auto_ch); 189 190 sc->mii_dev = NULL; 191 LIST_REMOVE(sc, mii_list); 192 193 return(0); 194} | 90static int brgphy_mii_phy_auto __P((struct mii_softc *, int)); 91extern void mii_phy_auto_timeout __P((void *)); 92 93static int brgphy_probe(dev) 94 device_t dev; 95{ 96 struct mii_attach_args *ma; 97 --- 88 unchanged lines hidden (view full) --- 186 if (sc->mii_flags & MIIF_DOINGAUTO) 187 untimeout(mii_phy_auto_timeout, sc, sc->mii_auto_ch); 188 189 sc->mii_dev = NULL; 190 LIST_REMOVE(sc, mii_list); 191 192 return(0); 193} |
195int | 194 195static int |
196brgphy_service(sc, mii, cmd) 197 struct mii_softc *sc; 198 struct mii_data *mii; 199 int cmd; 200{ 201 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 202 int reg, speed; 203 --- 90 unchanged lines hidden (view full) --- 294 case MII_TICK: 295 /* 296 * If we're not currently selected, just return. 297 */ 298 if (IFM_INST(ife->ifm_media) != sc->mii_inst) 299 return (0); 300 301 /* | 196brgphy_service(sc, mii, cmd) 197 struct mii_softc *sc; 198 struct mii_data *mii; 199 int cmd; 200{ 201 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 202 int reg, speed; 203 --- 90 unchanged lines hidden (view full) --- 294 case MII_TICK: 295 /* 296 * If we're not currently selected, just return. 297 */ 298 if (IFM_INST(ife->ifm_media) != sc->mii_inst) 299 return (0); 300 301 /* |
302 * Only used for autonegotiation. 303 */ 304 if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) 305 return (0); 306 307 /* | |
308 * Is the interface even up? 309 */ 310 if ((mii->mii_ifp->if_flags & IFF_UP) == 0) 311 return (0); 312 313 /* | 302 * Is the interface even up? 303 */ 304 if ((mii->mii_ifp->if_flags & IFF_UP) == 0) 305 return (0); 306 307 /* |
314 * Only retry autonegotiation every 5 seconds. | 308 * Only used for autonegotiation. |
315 */ | 309 */ |
316 if (++sc->mii_ticks != 5) 317 return (0); 318 319 sc->mii_ticks = 0; | 310 if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) 311 break; |
320 321 /* 322 * Check to see if we have link. If we do, we don't 323 * need to restart the autonegotiation process. Read 324 * the BMSR twice in case it's latched. 325 */ 326 reg = PHY_READ(sc, BRGPHY_MII_AUXSTS); 327 if (reg & BRGPHY_AUXSTS_LINK) 328 break; 329 | 312 313 /* 314 * Check to see if we have link. If we do, we don't 315 * need to restart the autonegotiation process. Read 316 * the BMSR twice in case it's latched. 317 */ 318 reg = PHY_READ(sc, BRGPHY_MII_AUXSTS); 319 if (reg & BRGPHY_AUXSTS_LINK) 320 break; 321 |
322 /* 323 * Only retry autonegotiation every 5 seconds. 324 */ 325 if (++sc->mii_ticks != 5) 326 return (0); 327 328 sc->mii_ticks = 0; |
|
330 mii_phy_reset(sc); 331 if (brgphy_mii_phy_auto(sc, 0) == EJUSTRETURN) | 329 mii_phy_reset(sc); 330 if (brgphy_mii_phy_auto(sc, 0) == EJUSTRETURN) |
332 return(0); | 331 return (0); |
333 break; 334 } 335 336 /* Update the media status. */ 337 brgphy_status(sc); 338 339 /* Callback if something changed. */ | 332 break; 333 } 334 335 /* Update the media status. */ 336 brgphy_status(sc); 337 338 /* Callback if something changed. */ |
340 if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { 341 MIIBUS_STATCHG(sc->mii_dev); 342 sc->mii_active = mii->mii_media_active; 343 } | 339 mii_phy_update(sc, cmd); |
344 return (0); 345} 346 | 340 return (0); 341} 342 |
347void | 343static void |
348brgphy_status(sc) 349 struct mii_softc *sc; 350{ 351 struct mii_data *mii = sc->mii_pdata; 352 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 353 int bmsr, bmcr; 354 355 mii->mii_media_status = IFM_AVALID; --- 111 unchanged lines hidden --- | 344brgphy_status(sc) 345 struct mii_softc *sc; 346{ 347 struct mii_data *mii = sc->mii_pdata; 348 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 349 int bmsr, bmcr; 350 351 mii->mii_media_status = IFM_AVALID; --- 111 unchanged lines hidden --- |