Deleted Added
full compact
tlphy.c (95722) tlphy.c (96026)
1/* $NetBSD: tlphy.c,v 1.18 1999/05/14 11:40:28 drochner Exp $ */
2
3/*-
4 * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,

--- 80 unchanged lines hidden (view full) ---

89#include <dev/mii/miidevs.h>
90
91#include <dev/mii/tlphyreg.h>
92
93#include "miibus_if.h"
94
95#if !defined(lint)
96static const char rcsid[] =
1/* $NetBSD: tlphy.c,v 1.18 1999/05/14 11:40:28 drochner Exp $ */
2
3/*-
4 * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,

--- 80 unchanged lines hidden (view full) ---

89#include <dev/mii/miidevs.h>
90
91#include <dev/mii/tlphyreg.h>
92
93#include "miibus_if.h"
94
95#if !defined(lint)
96static const char rcsid[] =
97 "$FreeBSD: head/sys/dev/mii/tlphy.c 95722 2002-04-29 13:07:38Z phk $";
97 "$FreeBSD: head/sys/dev/mii/tlphy.c 96026 2002-05-04 11:00:30Z phk $";
98#endif
99
100struct tlphy_softc {
101 struct mii_softc sc_mii; /* generic PHY */
102 int sc_need_acomp;
103};
104
105static int tlphy_probe (device_t);

--- 14 unchanged lines hidden (view full) ---

120 "tlphy",
121 tlphy_methods,
122 sizeof(struct tlphy_softc)
123};
124
125DRIVER_MODULE(tlphy, miibus, tlphy_driver, tlphy_devclass, 0, 0);
126
127static int tlphy_service(struct mii_softc *, struct mii_data *, int);
98#endif
99
100struct tlphy_softc {
101 struct mii_softc sc_mii; /* generic PHY */
102 int sc_need_acomp;
103};
104
105static int tlphy_probe (device_t);

--- 14 unchanged lines hidden (view full) ---

120 "tlphy",
121 tlphy_methods,
122 sizeof(struct tlphy_softc)
123};
124
125DRIVER_MODULE(tlphy, miibus, tlphy_driver, tlphy_devclass, 0, 0);
126
127static int tlphy_service(struct mii_softc *, struct mii_data *, int);
128static int tlphy_auto(struct tlphy_softc *, int);
128static int tlphy_auto(struct tlphy_softc *);
129static void tlphy_acomp(struct tlphy_softc *);
130static void tlphy_status(struct tlphy_softc *);
131
132static int tlphy_probe(dev)
133 device_t dev;
134{
135 struct mii_attach_args *ma;
136

--- 93 unchanged lines hidden (view full) ---

230 struct mii_softc *self;
231 struct mii_data *mii;
232 int cmd;
233{
234 struct tlphy_softc *sc = (struct tlphy_softc *)self;
235 struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
236 int reg;
237
129static void tlphy_acomp(struct tlphy_softc *);
130static void tlphy_status(struct tlphy_softc *);
131
132static int tlphy_probe(dev)
133 device_t dev;
134{
135 struct mii_attach_args *ma;
136

--- 93 unchanged lines hidden (view full) ---

230 struct mii_softc *self;
231 struct mii_data *mii;
232 int cmd;
233{
234 struct tlphy_softc *sc = (struct tlphy_softc *)self;
235 struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
236 int reg;
237
238 if ((sc->sc_mii.mii_flags & MIIF_DOINGAUTO) == 0 && sc->sc_need_acomp)
238 if (sc->sc_need_acomp)
239 tlphy_acomp(sc);
240
241 switch (cmd) {
242 case MII_POLLSTAT:
243 /*
244 * If we're not polling our PHY instance, just return.
245 */
246 if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)

--- 19 unchanged lines hidden (view full) ---

266
267 switch (IFM_SUBTYPE(ife->ifm_media)) {
268 case IFM_AUTO:
269 /*
270 * The ThunderLAN PHY doesn't self-configure after
271 * an autonegotiation cycle, so there's no such
272 * thing as "already in auto mode".
273 */
239 tlphy_acomp(sc);
240
241 switch (cmd) {
242 case MII_POLLSTAT:
243 /*
244 * If we're not polling our PHY instance, just return.
245 */
246 if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)

--- 19 unchanged lines hidden (view full) ---

266
267 switch (IFM_SUBTYPE(ife->ifm_media)) {
268 case IFM_AUTO:
269 /*
270 * The ThunderLAN PHY doesn't self-configure after
271 * an autonegotiation cycle, so there's no such
272 * thing as "already in auto mode".
273 */
274 (void) tlphy_auto(sc, 1);
274 (void) tlphy_auto(sc);
275 break;
276 case IFM_10_2:
277 case IFM_10_5:
278 PHY_WRITE(&sc->sc_mii, MII_BMCR, 0);
279 PHY_WRITE(&sc->sc_mii, MII_TLPHY_CTRL, CTRL_AUISEL);
280 DELAY(100000);
281 break;
282 default:

--- 39 unchanged lines hidden (view full) ---

322 /*
323 * Only retry autonegotiation every 5 seconds.
324 */
325 if (++sc->sc_mii.mii_ticks != 5)
326 return (0);
327
328 sc->sc_mii.mii_ticks = 0;
329 mii_phy_reset(&sc->sc_mii);
275 break;
276 case IFM_10_2:
277 case IFM_10_5:
278 PHY_WRITE(&sc->sc_mii, MII_BMCR, 0);
279 PHY_WRITE(&sc->sc_mii, MII_TLPHY_CTRL, CTRL_AUISEL);
280 DELAY(100000);
281 break;
282 default:

--- 39 unchanged lines hidden (view full) ---

322 /*
323 * Only retry autonegotiation every 5 seconds.
324 */
325 if (++sc->sc_mii.mii_ticks != 5)
326 return (0);
327
328 sc->sc_mii.mii_ticks = 0;
329 mii_phy_reset(&sc->sc_mii);
330 if (tlphy_auto(sc, 0) == EJUSTRETURN)
331 return (0);
332 break;
330 tlphy_auto(sc);
331 return (0);
333 }
334
335 /* Update the media status. */
336 tlphy_status(sc);
337
338 /* Callback if something changed. */
339 mii_phy_update(&sc->sc_mii, cmd);
340 return (0);

--- 38 unchanged lines hidden (view full) ---

379 * just have to report what's in the BMCR.
380 */
381 if (bmcr & BMCR_FDX)
382 mii->mii_media_active |= IFM_FDX;
383 mii->mii_media_active |= IFM_10_T;
384}
385
386static int
332 }
333
334 /* Update the media status. */
335 tlphy_status(sc);
336
337 /* Callback if something changed. */
338 mii_phy_update(&sc->sc_mii, cmd);
339 return (0);

--- 38 unchanged lines hidden (view full) ---

378 * just have to report what's in the BMCR.
379 */
380 if (bmcr & BMCR_FDX)
381 mii->mii_media_active |= IFM_FDX;
382 mii->mii_media_active |= IFM_10_T;
383}
384
385static int
387tlphy_auto(sc, waitfor)
386tlphy_auto(sc)
388 struct tlphy_softc *sc;
387 struct tlphy_softc *sc;
389 int waitfor;
390{
391 int error;
392
388{
389 int error;
390
393 switch ((error = mii_phy_auto(&sc->sc_mii, waitfor))) {
391 switch ((error = mii_phy_auto(&sc->sc_mii))) {
394 case EIO:
395 /*
396 * Just assume we're not in full-duplex mode.
397 * XXX Check link and try AUI/BNC?
398 */
399 PHY_WRITE(&sc->sc_mii, MII_BMCR, 0);
400 break;
401

--- 37 unchanged lines hidden ---
392 case EIO:
393 /*
394 * Just assume we're not in full-duplex mode.
395 * XXX Check link and try AUI/BNC?
396 */
397 PHY_WRITE(&sc->sc_mii, MII_BMCR, 0);
398 break;
399

--- 37 unchanged lines hidden ---