diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2004-09-26 00:59:59 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2004-09-26 00:59:59 +0000 |
commit | 8e8d95d27df054585cfa2d500a840a20e3ebf363 (patch) | |
tree | 8943a7f0c99b56b78d31cd3c72aa1427b2ebc9db /sys | |
parent | 2d35bc93d317846717f475b07c067c11816dae9d (diff) |
Restructure the PHY entry points to use a structure of
entry points instead of descrete function pointers, and
extend this to include a "reset" entry point. Make sure
any PHY-specific reset routine is always used.
From NetBSD
ok mcbride@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/mii/acphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/amphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/bmtphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/brgphy.c | 15 | ||||
-rw-r--r-- | sys/dev/mii/dcphy.c | 13 | ||||
-rw-r--r-- | sys/dev/mii/eephy.c | 22 | ||||
-rw-r--r-- | sys/dev/mii/exphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/icsphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/inphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/iophy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/lxtphy.c | 17 | ||||
-rw-r--r-- | sys/dev/mii/mii.c | 10 | ||||
-rw-r--r-- | sys/dev/mii/mii_physubr.c | 8 | ||||
-rw-r--r-- | sys/dev/mii/miivar.h | 31 | ||||
-rw-r--r-- | sys/dev/mii/mtdphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/nsgphy.c | 16 | ||||
-rw-r--r-- | sys/dev/mii/nsphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/nsphyter.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/qsphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/rgephy.c | 15 | ||||
-rw-r--r-- | sys/dev/mii/rlphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/sqphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/tlphy.c | 9 | ||||
-rw-r--r-- | sys/dev/mii/tqphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/txphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/ukphy.c | 11 | ||||
-rw-r--r-- | sys/dev/mii/urlphy.c | 13 | ||||
-rw-r--r-- | sys/dev/mii/xmphy.c | 15 |
28 files changed, 221 insertions, 139 deletions
diff --git a/sys/dev/mii/acphy.c b/sys/dev/mii/acphy.c index a1ec0e2fa1d..0d55bb070e5 100644 --- a/sys/dev/mii/acphy.c +++ b/sys/dev/mii/acphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acphy.c,v 1.1 2003/08/12 19:42:37 mickey Exp $ */ +/* $OpenBSD: acphy.c,v 1.2 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: acphy.c,v 1.13 2003/04/29 01:49:33 thorpej Exp $ */ /* @@ -71,6 +71,10 @@ struct cfdriver acphy_cd = { int acphy_service(struct mii_softc *, struct mii_data *, int); void acphy_status(struct mii_softc *); +const struct mii_phy_funcs acphy_funcs = { + acphy_service, acphy_status, mii_phy_reset, +}; + int acphymatch(struct device *parent, void *match, void *aux) { @@ -97,13 +101,12 @@ acphyattach(struct device *parent, struct device *self, void *aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = acphy_service; - sc->mii_status = acphy_status; + sc->mii_funcs = &acphy_funcs; sc->mii_pdata = mii; sc->mii_flags = ma->mii_flags; sc->mii_anegticks = 5; - mii_phy_reset(sc); + PHY_RESET(sc); /* * XXX Check MCR_FX_SEL to set MIIF_HAVE_FIBER? diff --git a/sys/dev/mii/amphy.c b/sys/dev/mii/amphy.c index a3eda893ad4..fdf8eb28e34 100644 --- a/sys/dev/mii/amphy.c +++ b/sys/dev/mii/amphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: amphy.c,v 1.6 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: amphy.c,v 1.7 2004/09/26 00:59:58 brad Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -70,6 +70,10 @@ struct cfdriver amphy_cd = { int amphy_service(struct mii_softc *, struct mii_data *, int); void amphy_status(struct mii_softc *); +const struct mii_phy_funcs amphy_funcs = { + amphy_service, amphy_status, mii_phy_reset, +}; + int amphymatch(parent, match, aux) struct device *parent; @@ -113,14 +117,13 @@ amphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = amphy_service; - sc->mii_status = amphy_status; + sc->mii_funcs = &hy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; sc->mii_flags |= MIIF_NOISOLATE; - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/bmtphy.c b/sys/dev/mii/bmtphy.c index 452684ce711..0f87f3aac29 100644 --- a/sys/dev/mii/bmtphy.c +++ b/sys/dev/mii/bmtphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bmtphy.c,v 1.6 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: bmtphy.c,v 1.7 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: nsphy.c,v 1.25 2000/02/02 23:34:57 thorpej Exp $ */ /*- @@ -63,6 +63,10 @@ int bmtphy_service(struct mii_softc *, struct mii_data *, int); void bmtphy_status(struct mii_softc *); void bmtphy_reset(struct mii_softc *); +const struct mii_phy_funcs bmtphy_funcs = { + bmtphy_service, bmtphy_status, bmtphy_reset, +}; + int bmtphymatch(parent, match, aux) struct device *parent; @@ -101,13 +105,12 @@ bmtphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = bmtphy_service; - sc->mii_status = bmtphy_status; + sc->mii_funcs = &bmtphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; sc->mii_anegticks = 5; - bmtphy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 28b215fa606..9388955bcda 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: brgphy.c,v 1.15 2003/10/13 16:18:56 krw Exp $ */ +/* $OpenBSD: brgphy.c,v 1.16 2004/09/26 00:59:58 brad Exp $ */ /* * Copyright (c) 2000 @@ -85,6 +85,10 @@ void brgphy_loop(struct mii_softc *); void brgphy_reset(struct mii_softc *); void brgphy_load_dspcode(struct mii_softc *); +const struct mii_phy_funcs brgphy_funcs = { + brgphy_service, brgphy_status, brgphy_reset, +}; + int brgphy_probe(parent, match, aux) struct device *parent; @@ -138,16 +142,15 @@ brgphy_attach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; + sc->mii_funcs = &brgphy_funcs; sc->mii_model = MII_MODEL(ma->mii_id2); sc->mii_rev = MII_REV(ma->mii_id2); - sc->mii_service = brgphy_service; - sc->mii_status = brgphy_status; sc->mii_pdata = mii; sc->mii_flags = ma->mii_flags | MIIF_NOISOLATE; sc->mii_ticks = 0; /* XXX Should be zero. Should 0 in brgphy_reset?*/ sc->mii_anegticks = 5; - brgphy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; if (sc->mii_capabilities & BMSR_EXTSTAT) @@ -196,7 +199,7 @@ brgphy_service(sc, mii, cmd) break; if (sc->mii_model != MII_MODEL_xxBROADCOM_BCM5701) - brgphy_reset(sc); /* XXX hardware bug work-around */ + PHY_RESET(sc); /* XXX hardware bug work-around */ switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: @@ -395,7 +398,7 @@ brgphy_mii_phy_auto(sc) int ktcr = 0; brgphy_loop(sc); - /* XXX need 'brgphy_reset(sc);'? Was done before getting here ... */ + /* XXX need 'PHY_RESET(sc);'? Was done before getting here ... */ ktcr = BRGPHY_1000CTL_AFD|BRGPHY_1000CTL_AHD; if (sc->mii_model == MII_MODEL_xxBROADCOM_BCM5701) ktcr |= BRGPHY_1000CTL_MSE|BRGPHY_1000CTL_MSC; diff --git a/sys/dev/mii/dcphy.c b/sys/dev/mii/dcphy.c index e99bb8a1174..c3da455f620 100644 --- a/sys/dev/mii/dcphy.c +++ b/sys/dev/mii/dcphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dcphy.c,v 1.8 2002/10/20 16:46:28 henning Exp $ */ +/* $OpenBSD: dcphy.c,v 1.9 2004/09/26 00:59:58 brad Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -102,6 +102,10 @@ void dcphy_status(struct mii_softc *); int dcphy_auto(struct mii_softc *, int); void dcphy_reset(struct mii_softc *); +const struct mii_phy_funcs dcphy_funcs = { + dcphy_service, dcphy_status, dcphy_reset, +}; + int dcphy_match(parent, match, aux) struct device *parent; @@ -134,8 +138,7 @@ dcphy_attach(parent, self, aux) printf(": internal PHY\n"); sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = dcphy_service; - sc->mii_status = dcphy_status; + sc->mii_funcs = &dcphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; @@ -226,7 +229,7 @@ dcphy_service(sc, mii, cmd) switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: - /*dcphy_reset(sc);*/ + /*PHY_RESET(sc);*/ sc->mii_flags &= ~MIIF_DOINGAUTO; (void) dcphy_auto(sc, 0); break; @@ -236,7 +239,7 @@ dcphy_service(sc, mii, cmd) */ return (EINVAL); case IFM_100_TX: - dcphy_reset(sc); + PHY_RESET(sc); DC_CLRBIT(dc_sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL); mode |= DC_NETCFG_PORTSEL|DC_NETCFG_PCS| DC_NETCFG_SCRAMBLER; diff --git a/sys/dev/mii/eephy.c b/sys/dev/mii/eephy.c index 0859dd33cee..0bbbff1e1a9 100644 --- a/sys/dev/mii/eephy.c +++ b/sys/dev/mii/eephy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eephy.c,v 1.11 2003/09/02 22:44:27 krw Exp $ */ +/* $OpenBSD: eephy.c,v 1.12 2004/09/26 00:59:58 brad Exp $ */ /* * Principal Author: Parag Patel * Copyright (c) 2001 @@ -75,6 +75,9 @@ void eephy_reset(struct mii_softc *); extern void mii_phy_auto_timeout(void *); +const struct mii_phy_funcs eephy_funcs = { + eephy_service, eephy_status, eephy_reset, +}; int eephymatch(struct device *parent, void *match, void *aux) @@ -111,8 +114,7 @@ eephyattach(struct device *parent, struct device *self, void *aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = eephy_service; - sc->mii_status = eephy_status; + sc->mii_funcs = &eephy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; sc->mii_anegticks = 10; @@ -122,7 +124,7 @@ eephyattach(struct device *parent, struct device *self, void *aux) (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK)) sc->mii_flags |= MIIF_HAVEFIBER; - eephy_reset(sc); + PHY_RESET(sc); sc->mii_flags |= MIIF_NOISOLATE; @@ -238,12 +240,12 @@ eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) if (sc->mii_flags & MIIF_DOINGAUTO) { return (0); } - eephy_reset(sc); + PHY_RESET(sc); (void)eephy_mii_phy_auto(sc, 1); break; case IFM_1000_SX: - eephy_reset(sc); + PHY_RESET(sc); PHY_WRITE(sc, E1000_CR, E1000_CR_FULL_DUPLEX | E1000_CR_SPEED_1000); @@ -254,14 +256,14 @@ eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) if (sc->mii_flags & MIIF_DOINGAUTO) return (0); - eephy_reset(sc); + PHY_RESET(sc); /* TODO - any other way to force 1000BT? */ (void)eephy_mii_phy_auto(sc, 1); break; case IFM_100_TX: - eephy_reset(sc); + PHY_RESET(sc); if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { PHY_WRITE(sc, E1000_CR, @@ -274,7 +276,7 @@ eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) break; case IFM_10_T: - eephy_reset(sc); + PHY_RESET(sc); if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { PHY_WRITE(sc, E1000_CR, @@ -333,7 +335,7 @@ eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) if (reg & E1000_SR_LINK_STATUS) break; - eephy_reset(sc); + PHY_RESET(sc); if (eephy_mii_phy_auto(sc, 0) == EJUSTRETURN) { return(0); diff --git a/sys/dev/mii/exphy.c b/sys/dev/mii/exphy.c index 82bd7235712..30df7922105 100644 --- a/sys/dev/mii/exphy.c +++ b/sys/dev/mii/exphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exphy.c,v 1.13 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: exphy.c,v 1.14 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: exphy.c,v 1.23 2000/02/02 23:34:56 thorpej Exp $ */ /*- @@ -99,6 +99,10 @@ struct cfdriver exphy_cd = { int exphy_service(struct mii_softc *, struct mii_data *, int); void exphy_reset(struct mii_softc *); +const struct mii_phy_funcs exphy_funcs = { + exphy_service, ukphy_status, exphy_reset, +}; + int exphymatch(parent, match, aux) struct device *parent; @@ -153,8 +157,7 @@ exphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = exphy_service; - sc->mii_status = ukphy_status; + sc->mii_funcs = &exphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; @@ -169,7 +172,7 @@ exphyattach(parent, self, aux) } sc->mii_flags |= MIIF_NOISOLATE; - exphy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/icsphy.c b/sys/dev/mii/icsphy.c index 903910ee4c2..9e55557cc74 100644 --- a/sys/dev/mii/icsphy.c +++ b/sys/dev/mii/icsphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icsphy.c,v 1.12 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: icsphy.c,v 1.13 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: icsphy.c,v 1.17 2000/02/02 23:34:56 thorpej Exp $ */ /*- @@ -104,6 +104,10 @@ int icsphy_service(struct mii_softc *, struct mii_data *, int); void icsphy_reset(struct mii_softc *); void icsphy_status(struct mii_softc *); +const struct mii_phy_funcs icsphy_funcs = { + icsphy_service, icsphy_status, icsphy_reset, +}; + int icsphymatch(parent, match, aux) struct device *parent; @@ -154,12 +158,11 @@ icsphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = icsphy_service; - sc->mii_status = icsphy_status; + sc->mii_funcs = &icsphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; - icsphy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/inphy.c b/sys/dev/mii/inphy.c index 7d66b23c54e..4261a0e1dd9 100644 --- a/sys/dev/mii/inphy.c +++ b/sys/dev/mii/inphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inphy.c,v 1.9 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: inphy.c,v 1.10 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: inphy.c,v 1.18 2000/02/02 23:34:56 thorpej Exp $ */ /*- @@ -103,6 +103,10 @@ struct cfdriver inphy_cd = { int inphy_service(struct mii_softc *, struct mii_data *, int); void inphy_status(struct mii_softc *); +const struct mii_phy_funcs inphy_funcs = { + inphy_service, inphy_status, mii_phy_reset, +}; + int inphymatch(parent, match, aux) struct device *parent; @@ -151,12 +155,11 @@ inphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = inphy_service; - sc->mii_status = inphy_status; + sc->mii_funcs = &inphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/iophy.c b/sys/dev/mii/iophy.c index 60f99cf471b..ab553e7079a 100644 --- a/sys/dev/mii/iophy.c +++ b/sys/dev/mii/iophy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iophy.c,v 1.8 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: iophy.c,v 1.9 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: iophy.c,v 1.8 2000/02/02 23:34:56 thorpej Exp $ */ /* @@ -101,6 +101,10 @@ struct cfdriver iophy_cd = { int iophy_service(struct mii_softc *, struct mii_data *, int); void iophy_status(struct mii_softc *); +const struct mii_phy_funcs iophy_funcs = { + iophy_service, iophy_status, mii_phy_reset, +}; + int iophymatch(parent, match, aux) struct device *parent; @@ -134,12 +138,11 @@ iophyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = iophy_service; - sc->mii_status = iophy_status; + sc->mii_funcs = &iophy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c index 0e8cffd0262..a3afb5fb6a3 100644 --- a/sys/dev/mii/lxtphy.c +++ b/sys/dev/mii/lxtphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lxtphy.c,v 1.10 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: lxtphy.c,v 1.11 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: lxtphy.c,v 1.19 2000/02/02 23:34:57 thorpej Exp $ */ /*- @@ -104,6 +104,14 @@ int lxtphy_service(struct mii_softc *, struct mii_data *, int); void lxtphy_status(struct mii_softc *); void lxtphy_reset(struct mii_softc *); +const struct mii_phy_funcs lxtphy_funcs = { + lxtphy_service, lxtphy_status, lxtphy_reset, +}; + +const struct mii_phy_funcs lxtphy971_funcs = { + lxtphy_service, ukphy_status, lxtphy_reset, +}; + int lxtphymatch(parent, match, aux) struct device *parent; @@ -136,22 +144,21 @@ lxtphyattach(parent, self, aux) MII_MODEL(ma->mii_id2) == MII_MODEL_xxLEVEL1_LXT970) { printf(": %s, rev. %d\n", MII_STR_xxLEVEL1_LXT970, MII_REV(ma->mii_id2)); - sc->mii_status = lxtphy_status; + sc->mii_funcs = &lxtphy_funcs; } if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxLEVEL1a && MII_MODEL(ma->mii_id2) == MII_MODEL_xxLEVEL1a_LXT971) { printf(": %s, rev. %d\n", MII_STR_xxLEVEL1a_LXT971, MII_REV(ma->mii_id2)); - sc->mii_status = ukphy_status; + sc->mii_funcs = &lxtphy971_funcs; } sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = lxtphy_service; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; - lxtphy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/mii.c b/sys/dev/mii/mii.c index 8bc95c8acab..5c1ad430081 100644 --- a/sys/dev/mii/mii.c +++ b/sys/dev/mii/mii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mii.c,v 1.12 2002/10/12 01:09:44 krw Exp $ */ +/* $OpenBSD: mii.c,v 1.13 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: mii.c,v 1.19 2000/02/02 17:09:44 thorpej Exp $ */ /*- @@ -271,7 +271,7 @@ mii_mediachg(mii) for (child = LIST_FIRST(&mii->mii_phys); child != NULL; child = LIST_NEXT(child, mii_list)) { - rv = (*child->mii_service)(child, mii, MII_MEDIACHG); + rv = PHY_SERVICE(child, mii, MII_MEDIACHG); if (rv) return (rv); } @@ -289,7 +289,7 @@ mii_tick(mii) for (child = LIST_FIRST(&mii->mii_phys); child != NULL; child = LIST_NEXT(child, mii_list)) - (void) (*child->mii_service)(child, mii, MII_TICK); + (void) PHY_SERVICE(child, mii, MII_TICK); } /* @@ -306,7 +306,7 @@ mii_pollstat(mii) for (child = LIST_FIRST(&mii->mii_phys); child != NULL; child = LIST_NEXT(child, mii_list)) - (void) (*child->mii_service)(child, mii, MII_POLLSTAT); + (void) PHY_SERVICE(child, mii, MII_POLLSTAT); } /* @@ -320,5 +320,5 @@ mii_down(mii) for (child = LIST_FIRST(&mii->mii_phys); child != NULL; child = LIST_NEXT(child, mii_list)) - (void) (*child->mii_service)(child, mii, MII_DOWN); + (void) PHY_SERVICE(child, mii, MII_DOWN); } diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c index 67889b95836..e05e7a9f8ac 100644 --- a/sys/dev/mii/mii_physubr.c +++ b/sys/dev/mii/mii_physubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mii_physubr.c,v 1.17 2004/08/03 19:05:56 brad Exp $ */ +/* $OpenBSD: mii_physubr.c,v 1.18 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: mii_physubr.c,v 1.20 2001/04/13 23:30:09 thorpej Exp $ */ /*- @@ -187,7 +187,7 @@ mii_phy_auto_timeout(arg) bmsr = PHY_READ(sc, MII_BMSR); /* Update the media status. */ - (void) (*sc->mii_service)(sc, sc->mii_pdata, MII_POLLSTAT); + (void) PHY_SERVICE(sc, sc->mii_pdata, MII_POLLSTAT); splx(s); } @@ -231,7 +231,7 @@ mii_phy_tick(sc) return (EJUSTRETURN); sc->mii_ticks = 0; - mii_phy_reset(sc); + PHY_RESET(sc); if (mii_phy_auto(sc, 0) == EJUSTRETURN) return (EJUSTRETURN); @@ -283,7 +283,7 @@ mii_phy_status(sc) struct mii_softc *sc; { - (*sc->mii_status)(sc); + PHY_STATUS(sc); } void diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h index 368792fd4db..b54dca67e67 100644 --- a/sys/dev/mii/miivar.h +++ b/sys/dev/mii/miivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: miivar.h,v 1.18 2004/08/02 21:53:31 brad Exp $ */ +/* $OpenBSD: miivar.h,v 1.19 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: miivar.h,v 1.17 2000/03/06 20:56:57 thorpej Exp $ */ /*- @@ -99,16 +99,11 @@ struct mii_data { }; typedef struct mii_data mii_data_t; -/* - * This call is used by the MII layer to call into the PHY driver - * to perform a `service request'. - */ -typedef int (*mii_downcall_t)(struct mii_softc *, struct mii_data *, int); - -/* - * This is a call back into the PHY driver made by a `status request'. - */ -typedef void (*mii_statusreq_t)(struct mii_softc *); +struct mii_phy_funcs { + int (*pf_service)(struct mii_softc *, struct mii_data *, int); + void (*pf_status)(struct mii_softc *); + void (*pf_reset)(struct mii_softc *); +}; /* * Requests that can be made to the downcall. @@ -134,8 +129,9 @@ struct mii_softc { int mii_offset; /* first PHY, second PHY, etc. */ int mii_inst; /* instance for ifmedia */ - mii_downcall_t mii_service; /* our downcall */ - mii_statusreq_t mii_status; /* our status request fn */ + /* Our PHY functions. */ + const struct mii_phy_funcs *mii_funcs; + struct mii_data *mii_pdata; /* pointer to parent's mii_data */ int mii_flags; /* misc. flags; see below */ @@ -222,6 +218,15 @@ struct mii_media { (*(p)->mii_pdata->mii_writereg)((p)->mii_dev.dv_parent, \ (p)->mii_phy, (r), (v)) +#define PHY_SERVICE(p, d, o) \ + (*(p)->mii_funcs->pf_service)((p), (d), (o)) + +#define PHY_STATUS(p) \ + (*(p)->mii_funcs->pf_status)((p)) + +#define PHY_RESET(p) \ + (*(p)->mii_funcs->pf_reset)((p)) + #define mii_phy_probe(x, y, z) \ mii_attach((x), (y), (z), MII_PHY_ANY, MII_OFFSET_ANY, 0) diff --git a/sys/dev/mii/mtdphy.c b/sys/dev/mii/mtdphy.c index 4adc0a89a0e..a9d64abb6c0 100644 --- a/sys/dev/mii/mtdphy.c +++ b/sys/dev/mii/mtdphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mtdphy.c,v 1.8 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: mtdphy.c,v 1.9 2004/09/26 00:59:58 brad Exp $ */ /* * Copyright (c) 1998, 1999 Jason L. Wright (jason@thought.net) @@ -59,6 +59,10 @@ struct cfdriver mtdphy_cd = { int mtdphy_service(struct mii_softc *, struct mii_data *, int); +const struct mii_phy_funcs mtdphy_funcs = { + mtdphy_service, ukphy_status, mii_phy_reset, +}; + int mtdphymatch(parent, match, aux) struct device *parent; @@ -87,12 +91,11 @@ mtdphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = mtdphy_service; - sc->mii_status = ukphy_status; + sc->mii_funcs = &mtdphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/nsgphy.c b/sys/dev/mii/nsgphy.c index 9631300dc54..ae4cbd6ff3f 100644 --- a/sys/dev/mii/nsgphy.c +++ b/sys/dev/mii/nsgphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nsgphy.c,v 1.10 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: nsgphy.c,v 1.11 2004/09/26 00:59:58 brad Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 2001 @@ -80,8 +80,11 @@ void nsgphy_status(struct mii_softc *); static int nsgphy_mii_phy_auto(struct mii_softc *, int); extern void mii_phy_auto_timeout(void *); -int +const struct mii_phy_funcs nsgphy_funcs = { + nsgphy_service, nsgphy_status, mii_phy_reset, +}; +int nsgphymatch(parent, match, aux) struct device *parent; void *match; @@ -121,13 +124,12 @@ nsgphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = nsgphy_service; - sc->mii_status = nsgphy_status; + sc->mii_funcs = &nsgphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; sc->mii_anegticks = 10; - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; @@ -268,7 +270,7 @@ nsgphy_service(sc, mii, cmd) if (reg & NSGPHY_PHYSUP_LNKSTS) break; - mii_phy_reset(sc); + PHY_RESET(sc); if (nsgphy_mii_phy_auto(sc, 0) == EJUSTRETURN) return(0); break; @@ -363,7 +365,7 @@ nsgphy_mii_phy_auto(mii, waitfor) int bmsr, ktcr = 0, i; if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) { - mii_phy_reset(mii); + PHY_RESET(mii); PHY_WRITE(mii, NSGPHY_MII_BMCR, 0); DELAY(1000); ktcr = PHY_READ(mii, NSGPHY_MII_1000CTL); diff --git a/sys/dev/mii/nsphy.c b/sys/dev/mii/nsphy.c index d270038898f..3aead79d332 100644 --- a/sys/dev/mii/nsphy.c +++ b/sys/dev/mii/nsphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nsphy.c,v 1.13 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: nsphy.c,v 1.14 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: nsphy.c,v 1.25 2000/02/02 23:34:57 thorpej Exp $ */ /*- @@ -104,6 +104,10 @@ int nsphy_service(struct mii_softc *, struct mii_data *, int); void nsphy_status(struct mii_softc *); void nsphy_reset(struct mii_softc *); +const struct mii_phy_funcs nsphy_funcs = { + nsphy_service, nsphy_status, nsphy_reset, +}; + int nsphymatch(parent, match, aux) struct device *parent; @@ -134,13 +138,12 @@ nsphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = nsphy_service; - sc->mii_status = nsphy_status; + sc->mii_funcs = &nsphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; sc->mii_anegticks = 5; - nsphy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/nsphyter.c b/sys/dev/mii/nsphyter.c index 753c891c6dd..dd833b296b6 100644 --- a/sys/dev/mii/nsphyter.c +++ b/sys/dev/mii/nsphyter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nsphyter.c,v 1.6 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: nsphyter.c,v 1.7 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: nsphyter.c,v 1.5 2000/02/02 23:34:57 thorpej Exp $ */ /*- @@ -103,6 +103,10 @@ struct cfdriver nsphyter_cd = { int nsphyter_service(struct mii_softc *, struct mii_data *, int); void nsphyter_status(struct mii_softc *); +const struct mii_phy_funcs nsphyter_funcs = { + nsphyter_service, nsphyter_status, mii_phy_reset, +}; + int nsphytermatch(parent, match, aux) struct device *parent; @@ -139,12 +143,11 @@ nsphyterattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = nsphyter_service; - sc->mii_status = nsphyter_status; + sc->mii_funcs = &nsphyter_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/qsphy.c b/sys/dev/mii/qsphy.c index 1a366265432..5afcfd6eb61 100644 --- a/sys/dev/mii/qsphy.c +++ b/sys/dev/mii/qsphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qsphy.c,v 1.9 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: qsphy.c,v 1.10 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: qsphy.c,v 1.19 2000/02/02 23:34:57 thorpej Exp $ */ /*- @@ -103,6 +103,10 @@ int qsphy_service(struct mii_softc *, struct mii_data *, int); void qsphy_reset(struct mii_softc *); void qsphy_status(struct mii_softc *); +const struct mii_phy_funcs qsphy_funcs = { + qsphy_service, qsphy_status, qsphy_reset, +}; + int qsphymatch(parent, match, aux) struct device *parent; @@ -132,12 +136,11 @@ qsphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = qsphy_service; - sc->mii_status = qsphy_status; + sc->mii_funcs = &qsphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; - qsphy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/rgephy.c b/sys/dev/mii/rgephy.c index e71413256da..c36b96112d9 100644 --- a/sys/dev/mii/rgephy.c +++ b/sys/dev/mii/rgephy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rgephy.c,v 1.2 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: rgephy.c,v 1.3 2004/09/26 00:59:58 brad Exp $ */ /* * Copyright (c) 2003 * Bill Paul <wpaul@windriver.com>. All rights reserved. @@ -85,6 +85,10 @@ void rgephy_loop(struct mii_softc *); void rgephy_load_dspcode(struct mii_softc *); int rgephy_mii_model; +const struct mii_phy_funcs rgephy_funcs = { + rgephy_service, rgephy_status, rgephy_reset, +}; + int rgephymatch(parent, match, aux) struct device *parent; @@ -115,16 +119,15 @@ rgephyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; + sc->mii_funcs = &rgephy_funcs; sc->mii_model = MII_MODEL(ma->mii_id2); sc->mii_rev = MII_REV(ma->mii_id2); - sc->mii_service = rgephy_service; - sc->mii_status = rgephy_status; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags | MIIF_NOISOLATE; sc->mii_ticks = 0; /* XXX */ sc->mii_anegticks = 5; - rgephy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; @@ -170,7 +173,7 @@ rgephy_service(sc, mii, cmd) if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; - rgephy_reset(sc); /* XXX hardware bug work-around */ + PHY_RESET(sc); /* XXX hardware bug work-around */ switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: @@ -340,7 +343,7 @@ rgephy_mii_phy_auto(mii) struct mii_softc *mii; { rgephy_loop(mii); - rgephy_reset(mii); + PHY_RESET(mii); PHY_WRITE(mii, RGEPHY_MII_ANAR, BMSR_MEDIA_TO_ANAR(mii->mii_capabilities) | ANAR_CSMA); diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c index f21ca0f5e4a..600bb9becd2 100644 --- a/sys/dev/mii/rlphy.c +++ b/sys/dev/mii/rlphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rlphy.c,v 1.10 2004/09/23 15:32:59 fgsch Exp $ */ +/* $OpenBSD: rlphy.c,v 1.11 2004/09/26 00:59:58 brad Exp $ */ /* * Copyright (c) 1998, 1999 Jason L. Wright (jason@thought.net) @@ -61,6 +61,10 @@ struct cfdriver rlphy_cd = { int rlphy_service(struct mii_softc *, struct mii_data *, int); void rlphy_reset(struct mii_softc *); +const struct mii_phy_funcs rlphy_funcs = { + rlphy_service, ukphy_status, rlphy_reset, +}; + int rlphymatch(parent, match, aux) struct device *parent; @@ -106,12 +110,11 @@ rlphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = rlphy_service; - sc->mii_status = ukphy_status; + sc->mii_funcs = &rlphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; - rlphy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/sqphy.c b/sys/dev/mii/sqphy.c index 396569c01cb..0a216bd4dbd 100644 --- a/sys/dev/mii/sqphy.c +++ b/sys/dev/mii/sqphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sqphy.c,v 1.9 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: sqphy.c,v 1.10 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: sqphy.c,v 1.17 2000/02/02 23:34:57 thorpej Exp $ */ /*- @@ -103,6 +103,10 @@ struct cfdriver sqphy_cd = { int sqphy_service(struct mii_softc *, struct mii_data *, int); void sqphy_status(struct mii_softc *); +const struct mii_phy_funcs sqphy_funcs = { + sqphy_service, sqphy_status, mii_phy_reset, +}; + int sqphymatch(parent, match, aux) struct device *parent; @@ -145,12 +149,11 @@ sqphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = sqphy_service; - sc->mii_status = sqphy_status; + sc->mii_funcs = &sqphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/tlphy.c b/sys/dev/mii/tlphy.c index b7318ac12e5..3dadb57e574 100644 --- a/sys/dev/mii/tlphy.c +++ b/sys/dev/mii/tlphy.c @@ -118,6 +118,10 @@ int tlphy_auto(struct tlphy_softc *, int); void tlphy_acomp(struct tlphy_softc *); void tlphy_status(struct mii_softc *); +const struct mii_phy_funcs tlphy_funcs = { + tlphy_service, tlphy_status, mii_phy_reset, +}; + int tlphymatch(parent, match, aux) struct device *parent; @@ -147,13 +151,12 @@ tlphyattach(parent, self, aux) sc->sc_mii.mii_inst = mii->mii_instance; sc->sc_mii.mii_phy = ma->mii_phyno; - sc->sc_mii.mii_service = tlphy_service; - sc->sc_mii.mii_status = tlphy_status; + sc->mii_funcs = &tlphy_funcs; sc->sc_mii.mii_pdata = mii; sc->sc_mii.mii_flags = mii->mii_flags; sc->sc_mii.mii_flags &= ~MIIF_NOISOLATE; - mii_phy_reset(&sc->sc_mii); + PHY_RESET(&sc->sc_mii); sc->sc_mii.mii_flags |= MIIF_NOISOLATE; /* diff --git a/sys/dev/mii/tqphy.c b/sys/dev/mii/tqphy.c index 6957e8a162e..502042e0954 100644 --- a/sys/dev/mii/tqphy.c +++ b/sys/dev/mii/tqphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tqphy.c,v 1.6 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: tqphy.c,v 1.7 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: tqphy.c,v 1.9 2000/02/02 23:34:57 thorpej Exp $ */ /* @@ -104,6 +104,10 @@ struct cfdriver tqphy_cd = { int tqphy_service(struct mii_softc *, struct mii_data *, int); void tqphy_status(struct mii_softc *); +const struct mii_phy_funcs tqphy_funcs = { + tqphy_service, tqphy_status, mii_phy_reset, +}; + int tqphymatch(parent, match, aux) struct device *parent; @@ -136,8 +140,7 @@ tqphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = tqphy_service; - sc->mii_status = tqphy_status; + sc->mii_funcs = &tqphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; @@ -146,7 +149,7 @@ tqphyattach(parent, self, aux) */ sc->mii_flags |= MIIF_NOLOOP; - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/txphy.c b/sys/dev/mii/txphy.c index ca8d0e1321a..368a26b540a 100644 --- a/sys/dev/mii/txphy.c +++ b/sys/dev/mii/txphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: txphy.c,v 1.6 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: txphy.c,v 1.7 2004/09/26 00:59:58 brad Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -58,6 +58,10 @@ struct cfdriver txphy_cd = { int txphy_service(struct mii_softc *, struct mii_data *, int); +const struct mii_phy_funcs txphy_funcs = { + txphy_service, ukphy_status, mii_phy_reset, +}; + int txphymatch(parent, match, aux) struct device *parent; @@ -86,12 +90,11 @@ txphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = txphy_service; - sc->mii_status = ukphy_status; + sc->mii_funcs = &txphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/ukphy.c b/sys/dev/mii/ukphy.c index 01302f7a534..6a8516aa3ae 100644 --- a/sys/dev/mii/ukphy.c +++ b/sys/dev/mii/ukphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukphy.c,v 1.11 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: ukphy.c,v 1.12 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: ukphy.c,v 1.9 2000/02/02 23:34:57 thorpej Exp $ */ /*- @@ -98,6 +98,10 @@ struct cfdriver ukphy_cd = { int ukphy_service(struct mii_softc *, struct mii_data *, int); +const struct mii_phy_funcs ukphy_funcs = { + ukphy_service, ukphy_status, mii_phy_reset, +}; + int ukphymatch(parent, match, aux) struct device *parent; @@ -127,8 +131,7 @@ ukphyattach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = ukphy_service; - sc->mii_status = ukphy_status; + sc->mii_funcs = &ukphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; @@ -137,7 +140,7 @@ ukphyattach(parent, self, aux) */ sc->mii_flags |= MIIF_NOLOOP; - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; diff --git a/sys/dev/mii/urlphy.c b/sys/dev/mii/urlphy.c index 5a4d1fca5ea..cf13faa3235 100644 --- a/sys/dev/mii/urlphy.c +++ b/sys/dev/mii/urlphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: urlphy.c,v 1.4 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: urlphy.c,v 1.5 2004/09/26 00:59:58 brad Exp $ */ /* $NetBSD: urlphy.c,v 1.1 2002/03/28 21:07:53 ichiro Exp $ */ /* * Copyright (c) 2001, 2002 @@ -76,6 +76,10 @@ struct cfdriver urlphy_cd = { int urlphy_service(struct mii_softc *, struct mii_data *, int); void urlphy_status(struct mii_softc *); +const struct mii_phy_funcs urlphy_funcs = { + urlphy_service, urlphy_status, mii_phy_reset, +}; + int urlphy_match(struct device *parent, void *match, void *aux) { @@ -108,8 +112,7 @@ urlphy_attach(struct device *parent, struct device *self, void *aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = urlphy_service; - sc->mii_status = urlphy_status; + sc->mii_funcs = &urlphy_funcs; sc->mii_pdata = mii; sc->mii_flags = mii->mii_flags; sc->mii_anegticks = 10; @@ -124,7 +127,7 @@ urlphy_attach(struct device *parent, struct device *self, void *aux) sc->mii_dev.dv_xname); return; } - mii_phy_reset(sc); + PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; if (sc->mii_capabilities & BMSR_MEDIAMASK) @@ -198,7 +201,7 @@ urlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) return (0); sc->mii_ticks = 0; - mii_phy_reset(sc); + PHY_RESET(sc); if (mii_phy_auto(sc, 0) == EJUSTRETURN) return (0); diff --git a/sys/dev/mii/xmphy.c b/sys/dev/mii/xmphy.c index 1cfd8563f2b..4949ae9fd77 100644 --- a/sys/dev/mii/xmphy.c +++ b/sys/dev/mii/xmphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xmphy.c,v 1.7 2004/09/20 06:05:27 brad Exp $ */ +/* $OpenBSD: xmphy.c,v 1.8 2004/09/26 00:59:58 brad Exp $ */ /* * Copyright (c) 2000 @@ -74,6 +74,10 @@ void xmphy_status(struct mii_softc *); int xmphy_mii_phy_auto(struct mii_softc *, int); extern void mii_phy_auto_timeout(void *); +const struct mii_phy_funcs xmphy_funcs = { + xmphy_service, xmphy_status, mii_phy_reset, +}; + int xmphy_probe(parent, match, aux) struct device *parent; void *match, *aux; @@ -100,8 +104,7 @@ xmphy_attach(parent, self, aux) sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; - sc->mii_service = xmphy_service; - sc->mii_status = xmphy_status; + sc->mii_funcs = &xmphy_funcs; sc->mii_pdata = mii; sc->mii_flags |= MIIF_NOISOLATE | mii->mii_flags; sc->mii_anegticks = 5; @@ -111,7 +114,7 @@ xmphy_attach(parent, self, aux) ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), BMCR_ISO); - mii_phy_reset(sc); + PHY_RESET(sc); ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, 0, sc->mii_inst), XMPHY_BMCR_FDX); @@ -169,7 +172,7 @@ xmphy_service(sc, mii, cmd) (void) xmphy_mii_phy_auto(sc, 1); break; case IFM_1000_SX: - mii_phy_reset(sc); + PHY_RESET(sc); if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { PHY_WRITE(sc, XMPHY_MII_ANAR, XMPHY_ANAR_FDX); PHY_WRITE(sc, XMPHY_MII_BMCR, XMPHY_BMCR_FDX); @@ -223,7 +226,7 @@ xmphy_service(sc, mii, cmd) if (reg & XMPHY_BMSR_LINK) break; - mii_phy_reset(sc); + PHY_RESET(sc); if (xmphy_mii_phy_auto(sc, 0) == EJUSTRETURN) return(0); break; |