Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Nov 2010 11:12:30 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r214910 - in stable/7/sys: arm/xscale/ixp425 dev/ae dev/age dev/alc dev/ale dev/bfe dev/bge dev/bm dev/cas dev/dc dev/fxp dev/gem dev/hme dev/jme dev/mii dev/msk dev/pcn dev/re dev/sk d...
Message-ID:  <201011071112.oA7BCUYl040102@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Sun Nov  7 11:12:30 2010
New Revision: 214910
URL: http://svn.freebsd.org/changeset/base/214910

Log:
  MFC: r213893, r213908, r214566, r214605, r214846
  
  Convert the PHY drivers to honor the mii_flags passed down and convert
  the NIC drivers as well as the PHY drivers to take advantage of the
  mii_attach() introduced in r213878 (MFC'ed to stable/8 in r214685) to
  get rid of certain hacks. For the most part these were:
  - Artificially limiting miibus_{read,write}reg methods to certain PHY
    addresses; we now let mii_attach() only probe the PHY at the desired
    address(es) instead.
  - PHY drivers setting MIIF_* flags based on the NIC driver they hang
    off from, partly even based on grabbing and using the softc of the
    parent; we now pass these flags down from the NIC to the PHY drivers
    via mii_attach(). This got us rid of all such hacks except those of
    brgphy() in combination with bce(4) and bge(4), which is way beyond
    what can be expressed with simple flags.
  
  While at it, I took the opportunity to change the NIC drivers to pass
  up the error returned by mii_attach() (previously by mii_phy_probe())
  and unify the error message used in this case where and as appropriate
  as mii_attach() actually can fail for a number of reasons, not just
  because of no PHY(s) being present at the expected address(es).
  
  Reviewed by:	jhb, yongari

Modified:
  stable/7/sys/arm/xscale/ixp425/if_npe.c
  stable/7/sys/dev/ae/if_ae.c
  stable/7/sys/dev/ae/if_aevar.h
  stable/7/sys/dev/age/if_age.c
  stable/7/sys/dev/alc/if_alc.c
  stable/7/sys/dev/ale/if_ale.c
  stable/7/sys/dev/bfe/if_bfe.c
  stable/7/sys/dev/bge/if_bge.c
  stable/7/sys/dev/bge/if_bgereg.h
  stable/7/sys/dev/bm/if_bm.c
  stable/7/sys/dev/cas/if_cas.c
  stable/7/sys/dev/cas/if_casvar.h
  stable/7/sys/dev/dc/if_dc.c
  stable/7/sys/dev/dc/pnphy.c
  stable/7/sys/dev/fxp/if_fxp.c
  stable/7/sys/dev/gem/if_gem.c
  stable/7/sys/dev/gem/if_gemvar.h
  stable/7/sys/dev/hme/if_hme.c
  stable/7/sys/dev/jme/if_jme.c
  stable/7/sys/dev/mii/acphy.c
  stable/7/sys/dev/mii/amphy.c
  stable/7/sys/dev/mii/atphy.c
  stable/7/sys/dev/mii/bmtphy.c
  stable/7/sys/dev/mii/brgphy.c
  stable/7/sys/dev/mii/ciphy.c
  stable/7/sys/dev/mii/e1000phy.c
  stable/7/sys/dev/mii/exphy.c
  stable/7/sys/dev/mii/gentbi.c
  stable/7/sys/dev/mii/icsphy.c
  stable/7/sys/dev/mii/inphy.c
  stable/7/sys/dev/mii/ip1000phy.c
  stable/7/sys/dev/mii/jmphy.c
  stable/7/sys/dev/mii/lxtphy.c
  stable/7/sys/dev/mii/mlphy.c
  stable/7/sys/dev/mii/nsgphy.c
  stable/7/sys/dev/mii/nsphy.c
  stable/7/sys/dev/mii/nsphyter.c
  stable/7/sys/dev/mii/pnaphy.c
  stable/7/sys/dev/mii/qsphy.c
  stable/7/sys/dev/mii/rgephy.c
  stable/7/sys/dev/mii/rlphy.c
  stable/7/sys/dev/mii/rlswitch.c
  stable/7/sys/dev/mii/ruephy.c
  stable/7/sys/dev/mii/tdkphy.c
  stable/7/sys/dev/mii/tlphy.c
  stable/7/sys/dev/mii/truephy.c
  stable/7/sys/dev/mii/ukphy.c
  stable/7/sys/dev/mii/xmphy.c
  stable/7/sys/dev/msk/if_msk.c
  stable/7/sys/dev/pcn/if_pcn.c
  stable/7/sys/dev/re/if_re.c
  stable/7/sys/dev/sk/if_sk.c
  stable/7/sys/dev/ste/if_ste.c
  stable/7/sys/dev/stge/if_stge.c
  stable/7/sys/dev/vge/if_vge.c
  stable/7/sys/dev/vr/if_vr.c
  stable/7/sys/dev/vr/if_vrreg.h
  stable/7/sys/pci/if_rl.c
  stable/7/sys/pci/if_xl.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/arm/xscale/ixp425/if_npe.c
==============================================================================
--- stable/7/sys/arm/xscale/ixp425/if_npe.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/arm/xscale/ixp425/if_npe.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -318,11 +318,13 @@ npe_attach(device_t dev)
 
 	npe_getmac(sc, eaddr);
 
-	/* NB: must be setup prior to invoking mii code */
 	sc->sc_ifp = ifp = if_alloc(IFT_ETHER);
-	if (mii_phy_probe(dev, &sc->sc_mii, npe_ifmedia_update, npe_ifmedia_status)) {
-		device_printf(dev, "Cannot find my PHY.\n");
-		error = ENXIO;
+	error = mii_attach(dev, &sc->sc_mii, ifp, npe_ifmedia_update,
+	    npe_ifmedia_status, BMSR_DEFCAPMASK, sc->sc_phy, MII_OFFSET_ANY,
+	    0);
+	if (error != 0) {
+		device_printf(dev, "attaching PHYs failed\n");
+		return error;
 		goto out;
 	}
 
@@ -1596,8 +1598,6 @@ npe_miibus_readreg(device_t dev, int phy
 	struct npe_softc *sc = device_get_softc(dev);
 	uint32_t v;
 
-	if (phy != sc->sc_phy)		/* XXX no auto-detect */
-		return 0xffff;
 	v = (phy << NPE_MII_ADDR_SHL) | (reg << NPE_MII_REG_SHL)
 	  | NPE_MII_GO;
 	npe_mii_mdio_write(sc, NPE_MAC_MDIO_CMD, v);
@@ -1615,8 +1615,6 @@ npe_miibus_writereg(device_t dev, int ph
 	struct npe_softc *sc = device_get_softc(dev);
 	uint32_t v;
 
-	if (phy != sc->sc_phy)		/* XXX */
-		return;
 	v = (phy << NPE_MII_ADDR_SHL) | (reg << NPE_MII_REG_SHL)
 	  | data | NPE_MII_WRITE
 	  | NPE_MII_GO;

Modified: stable/7/sys/dev/ae/if_ae.c
==============================================================================
--- stable/7/sys/dev/ae/if_ae.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/ae/if_ae.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -360,9 +360,6 @@ ae_attach(device_t dev)
 	if (error != 0)
 		goto fail;
 
-	/* Set default PHY address. */
-	sc->phyaddr = AE_PHYADDR_DEFAULT;
-
 	ifp = sc->ifp = if_alloc(IFT_ETHER);
 	if (ifp == NULL) {
 		device_printf(dev, "could not allocate ifnet structure.\n");
@@ -390,10 +387,11 @@ ae_attach(device_t dev)
 	/*
 	 * Configure and attach MII bus.
 	 */
-	error = mii_phy_probe(dev, &sc->miibus, ae_mediachange,
-	    ae_mediastatus);
+	error = mii_attach(dev, &sc->miibus, ifp, ae_mediachange,
+	    ae_mediastatus, BMSR_DEFCAPMASK, AE_PHYADDR_DEFAULT,
+	    MII_OFFSET_ANY, 0);
 	if (error != 0) {
-		device_printf(dev, "no PHY found.\n");
+		device_printf(dev, "attaching PHYs failed\n");
 		goto fail;
 	}
 
@@ -813,9 +811,6 @@ ae_miibus_readreg(device_t dev, int phy,
 	 * Locking is done in upper layers.
 	 */
 
-	if (phy != sc->phyaddr)
-		return (0);
-
 	val = ((reg << AE_MDIO_REGADDR_SHIFT) & AE_MDIO_REGADDR_MASK) |
 	    AE_MDIO_START | AE_MDIO_READ | AE_MDIO_SUP_PREAMBLE |
 	    ((AE_MDIO_CLK_25_4 << AE_MDIO_CLK_SHIFT) & AE_MDIO_CLK_MASK);
@@ -851,9 +846,6 @@ ae_miibus_writereg(device_t dev, int phy
 	 * Locking is done in upper layers.
 	 */
 
-	if (phy != sc->phyaddr)
-		return (0);
-
 	aereg = ((reg << AE_MDIO_REGADDR_SHIFT) & AE_MDIO_REGADDR_MASK) |
 	    AE_MDIO_START | AE_MDIO_SUP_PREAMBLE |
 	    ((AE_MDIO_CLK_25_4 << AE_MDIO_CLK_SHIFT) & AE_MDIO_CLK_MASK) |

Modified: stable/7/sys/dev/ae/if_aevar.h
==============================================================================
--- stable/7/sys/dev/ae/if_aevar.h	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/ae/if_aevar.h	Sun Nov  7 11:12:30 2010	(r214910)
@@ -111,7 +111,6 @@ typedef struct ae_softc	{
 
 	struct mtx		mtx;
 
-	int			phyaddr;
 	uint8_t			eaddr[ETHER_ADDR_LEN];
 	uint8_t			flags;
 	int			if_flags;

Modified: stable/7/sys/dev/age/if_age.c
==============================================================================
--- stable/7/sys/dev/age/if_age.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/age/if_age.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -210,8 +210,6 @@ age_miibus_readreg(device_t dev, int phy
 	int i;
 
 	sc = device_get_softc(dev);
-	if (phy != sc->age_phyaddr)
-		return (0);
 
 	CSR_WRITE_4(sc, AGE_MDIO, MDIO_OP_EXECUTE | MDIO_OP_READ |
 	    MDIO_SUP_PREAMBLE | MDIO_CLK_25_4 | MDIO_REG_ADDR(reg));
@@ -241,8 +239,6 @@ age_miibus_writereg(device_t dev, int ph
 	int i;
 
 	sc = device_get_softc(dev);
-	if (phy != sc->age_phyaddr)
-		return (0);
 
 	CSR_WRITE_4(sc, AGE_MDIO, MDIO_OP_EXECUTE | MDIO_OP_WRITE |
 	    (val & MDIO_DATA_MASK) << MDIO_DATA_SHIFT |
@@ -621,9 +617,11 @@ age_attach(device_t dev)
 	ifp->if_capenable = ifp->if_capabilities;
 
 	/* Set up MII bus. */
-	if ((error = mii_phy_probe(dev, &sc->age_miibus, age_mediachange,
-	    age_mediastatus)) != 0) {
-		device_printf(dev, "no PHY found!\n");
+	error = mii_attach(dev, &sc->age_miibus, ifp, age_mediachange,
+	    age_mediastatus, BMSR_DEFCAPMASK, sc->age_phyaddr, MII_OFFSET_ANY,
+	    0);
+	if (error != 0) {
+		device_printf(dev, "attaching PHYs failed\n");
 		goto fail;
 	}
 

Modified: stable/7/sys/dev/alc/if_alc.c
==============================================================================
--- stable/7/sys/dev/alc/if_alc.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/alc/if_alc.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -235,9 +235,6 @@ alc_miibus_readreg(device_t dev, int phy
 
 	sc = device_get_softc(dev);
 
-	if (phy != sc->alc_phyaddr)
-		return (0);
-
 	/*
 	 * For AR8132 fast ethernet controller, do not report 1000baseT
 	 * capability to mii(4). Even though AR8132 uses the same
@@ -274,9 +271,6 @@ alc_miibus_writereg(device_t dev, int ph
 
 	sc = device_get_softc(dev);
 
-	if (phy != sc->alc_phyaddr)
-		return (0);
-
 	CSR_WRITE_4(sc, ALC_MDIO, MDIO_OP_EXECUTE | MDIO_OP_WRITE |
 	    (val & MDIO_DATA_MASK) << MDIO_DATA_SHIFT |
 	    MDIO_SUP_PREAMBLE | MDIO_CLK_25_4 | MDIO_REG_ADDR(reg));
@@ -978,9 +972,11 @@ alc_attach(device_t dev)
 	ifp->if_capenable = ifp->if_capabilities;
 
 	/* Set up MII bus. */
-	if ((error = mii_phy_probe(dev, &sc->alc_miibus, alc_mediachange,
-	    alc_mediastatus)) != 0) {
-		device_printf(dev, "no PHY found!\n");
+	error = mii_attach(dev, &sc->alc_miibus, ifp, alc_mediachange,
+	    alc_mediastatus, BMSR_DEFCAPMASK, sc->alc_phyaddr, MII_OFFSET_ANY,
+	    0);
+	if (error != 0) {
+		device_printf(dev, "attaching PHYs failed\n");
 		goto fail;
 	}
 

Modified: stable/7/sys/dev/ale/if_ale.c
==============================================================================
--- stable/7/sys/dev/ale/if_ale.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/ale/if_ale.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -208,9 +208,6 @@ ale_miibus_readreg(device_t dev, int phy
 
 	sc = device_get_softc(dev);
 
-	if (phy != sc->ale_phyaddr)
-		return (0);
-
 	CSR_WRITE_4(sc, ALE_MDIO, MDIO_OP_EXECUTE | MDIO_OP_READ |
 	    MDIO_SUP_PREAMBLE | MDIO_CLK_25_4 | MDIO_REG_ADDR(reg));
 	for (i = ALE_PHY_TIMEOUT; i > 0; i--) {
@@ -237,9 +234,6 @@ ale_miibus_writereg(device_t dev, int ph
 
 	sc = device_get_softc(dev);
 
-	if (phy != sc->ale_phyaddr)
-		return (0);
-
 	CSR_WRITE_4(sc, ALE_MDIO, MDIO_OP_EXECUTE | MDIO_OP_WRITE |
 	    (val & MDIO_DATA_MASK) << MDIO_DATA_SHIFT |
 	    MDIO_SUP_PREAMBLE | MDIO_CLK_25_4 | MDIO_REG_ADDR(reg));
@@ -605,9 +599,11 @@ ale_attach(device_t dev)
 	ifp->if_capenable = ifp->if_capabilities;
 
 	/* Set up MII bus. */
-	if ((error = mii_phy_probe(dev, &sc->ale_miibus, ale_mediachange,
-	    ale_mediastatus)) != 0) {
-		device_printf(dev, "no PHY found!\n");
+	error = mii_attach(dev, &sc->ale_miibus, ifp, ale_mediachange,
+	    ale_mediastatus, BMSR_DEFCAPMASK, sc->ale_phyaddr, MII_OFFSET_ANY,
+	    0);
+	if (error != 0) {
+		device_printf(dev, "attaching PHYs failed\n");
 		goto fail;
 	}
 

Modified: stable/7/sys/dev/bfe/if_bfe.c
==============================================================================
--- stable/7/sys/dev/bfe/if_bfe.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/bfe/if_bfe.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -498,10 +498,11 @@ bfe_attach(device_t dev)
 	bfe_chip_reset(sc);
 	BFE_UNLOCK(sc);
 
-	if (mii_phy_probe(dev, &sc->bfe_miibus,
-				bfe_ifmedia_upd, bfe_ifmedia_sts)) {
-		device_printf(dev, "MII without any PHY!\n");
-		error = ENXIO;
+	error = mii_attach(dev, &sc->bfe_miibus, ifp, bfe_ifmedia_upd,
+	    bfe_ifmedia_sts, BMSR_DEFCAPMASK, sc->bfe_phyaddr, MII_OFFSET_ANY,
+	    0);
+	if (error != 0) {
+		device_printf(dev, "attaching PHYs failed\n");
 		goto fail;
 	}
 
@@ -624,8 +625,6 @@ bfe_miibus_readreg(device_t dev, int phy
 	u_int32_t ret;
 
 	sc = device_get_softc(dev);
-	if (phy != sc->bfe_phyaddr)
-		return (0);
 	bfe_readphy(sc, reg, &ret);
 
 	return (ret);
@@ -637,8 +636,6 @@ bfe_miibus_writereg(device_t dev, int ph
 	struct bfe_softc *sc;
 
 	sc = device_get_softc(dev);
-	if (phy != sc->bfe_phyaddr)
-		return (0);
 	bfe_writephy(sc, reg, val);
 
 	return (0);

Modified: stable/7/sys/dev/bge/if_bge.c
==============================================================================
--- stable/7/sys/dev/bge/if_bge.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/bge/if_bge.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -782,10 +782,6 @@ bge_miibus_readreg(device_t dev, int phy
 
 	sc = device_get_softc(dev);
 
-	/* Prevent the probe from finding incorrect devices. */
-	if (phy != sc->bge_phy_addr)
-		return (0);
-
 	/* Clear the autopoll bit if set, otherwise may trigger PCI errors. */
 	if ((sc->bge_mi_mode & BGE_MIMODE_AUTOPOLL) != 0) {
 		CSR_WRITE_4(sc, BGE_MI_MODE,
@@ -2572,7 +2568,7 @@ bge_attach(device_t dev)
 	struct bge_softc *sc;
 	uint32_t hwcfg = 0, misccfg;
 	u_char eaddr[ETHER_ADDR_LEN];
-	int error, msicount, reg, rid, trys;
+	int error, msicount, phy_addr, reg, rid, trys;
 
 	sc = device_get_softc(dev);
 	sc->bge_dev = dev;
@@ -2605,7 +2601,7 @@ bge_attach(device_t dev)
 	sc->bge_chiprev = BGE_CHIPREV(sc->bge_chipid);
 
 	/* Set default PHY address. */
-	sc->bge_phy_addr = 1;
+	phy_addr = 1;
 
 	/*
 	 * Don't enable Ethernet@WireSpeed for the 5700, 5906, or the
@@ -2972,17 +2968,17 @@ bge_attach(device_t dev)
 again:
 		bge_asf_driver_up(sc);
 
-		if (mii_phy_probe(dev, &sc->bge_miibus,
-		    bge_ifmedia_upd, bge_ifmedia_sts)) {
+		error = (mii_attach(dev, &sc->bge_miibus, ifp,
+		    bge_ifmedia_upd, bge_ifmedia_sts, BMSR_DEFCAPMASK,
+		    phy_addr, MII_OFFSET_ANY, 0));
+		if (error != 0) {
 			if (trys++ < 4) {
 				device_printf(sc->bge_dev, "Try again\n");
 				bge_miibus_writereg(sc->bge_dev, 1, MII_BMCR,
 				    BMCR_RESET);
 				goto again;
 			}
-
-			device_printf(sc->bge_dev, "MII without any PHY!\n");
-			error = ENXIO;
+			device_printf(sc->bge_dev, "attaching PHYs failed\n");
 			goto fail;
 		}
 

Modified: stable/7/sys/dev/bge/if_bgereg.h
==============================================================================
--- stable/7/sys/dev/bge/if_bgereg.h	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/bge/if_bgereg.h	Sun Nov  7 11:12:30 2010	(r214910)
@@ -2762,7 +2762,6 @@ struct bge_softc {
 	uint32_t		bge_tx_buf_ratio;
 	uint32_t		bge_mi_mode;
 	int			bge_if_flags;
-	int			bge_phy_addr;
 	int			bge_txcnt;
 	int			bge_link;	/* link state */
 	int			bge_link_evt;	/* pending link event */

Modified: stable/7/sys/dev/bm/if_bm.c
==============================================================================
--- stable/7/sys/dev/bm/if_bm.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/bm/if_bm.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -594,11 +594,19 @@ bm_attach(device_t dev)
 	/* reset the adapter  */
 	bm_chip_setup(sc);
 
-	/* setup MII */
-	error = mii_phy_probe(dev, &sc->sc_miibus, bm_ifmedia_upd,
-	    bm_ifmedia_sts);
-	if (error != 0)
-		device_printf(dev,"PHY probe failed: %d\n", error);
+	/*
+	 * Setup MII
+	 * On Apple BMAC controllers, we end up in a weird state of
+	 * partially-completed autonegotiation on boot.  So we force
+	 * autonegotation to try again.
+	 */
+	error = mii_attach(dev, &sc->sc_miibus, ifp, bm_ifmedia_upd,
+	    bm_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY,
+	    MIIF_FORCEANEG);
+	if (error != 0) {
+		device_printf(dev, "attaching PHYs failed\n");
+		return (error);
+	}
 
 	sc->sc_mii = device_get_softc(sc->sc_miibus);
 

Modified: stable/7/sys/dev/cas/if_cas.c
==============================================================================
--- stable/7/sys/dev/cas/if_cas.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/cas/if_cas.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -344,13 +344,9 @@ cas_attach(struct cas_softc *sc)
 				    BUS_SPACE_BARRIER_READ |
 				    BUS_SPACE_BARRIER_WRITE);
 			}
-			switch (sc->sc_variant) {
-			default:
-				sc->sc_phyad = -1;
-				break;
-			}
-			error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus,
-			    cas_mediachange, cas_mediastatus);
+			error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp,
+			    cas_mediachange, cas_mediastatus, BMSR_DEFCAPMASK,
+			    MII_PHY_ANY, MII_OFFSET_ANY, 0);
 		}
 		/*
 		 * Fall back on an internal PHY if no external PHY was found.
@@ -368,13 +364,9 @@ cas_attach(struct cas_softc *sc)
 				    BUS_SPACE_BARRIER_READ |
 				    BUS_SPACE_BARRIER_WRITE);
 			}
-			switch (sc->sc_variant) {
-			default:
-				sc->sc_phyad = -1;
-				break;
-			}
-			error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus,
-			    cas_mediachange, cas_mediastatus);
+			error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp,
+			    cas_mediachange, cas_mediastatus, BMSR_DEFCAPMASK,
+			    MII_PHY_ANY, MII_OFFSET_ANY, 0);
 		}
 	} else {
 		/*
@@ -394,12 +386,12 @@ cas_attach(struct cas_softc *sc)
 		CAS_WRITE_4(sc, CAS_PCS_CONF, CAS_PCS_CONF_EN);
 		CAS_BARRIER(sc, CAS_PCS_CONF, 4,
 		    BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
-		sc->sc_phyad = CAS_PHYAD_EXTERNAL;
-		error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus,
-		    cas_mediachange, cas_mediastatus);
+		error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp,
+		    cas_mediachange, cas_mediastatus, BMSR_DEFCAPMASK,
+		    CAS_PHYAD_EXTERNAL, MII_OFFSET_ANY, 0);
 	}
 	if (error != 0) {
-		device_printf(sc->sc_dev, "PHY probe failed: %d\n", error);
+		device_printf(sc->sc_dev, "attaching PHYs failed\n");
 		goto fail_rxmap;
 	}
 	sc->sc_mii = device_get_softc(sc->sc_miibus);
@@ -2172,9 +2164,6 @@ cas_mii_readreg(device_t dev, int phy, i
 #endif
 
 	sc = device_get_softc(dev);
-	if (sc->sc_phyad != -1 && phy != sc->sc_phyad)
-		return (0);
-
 	if ((sc->sc_flags & CAS_SERDES) != 0) {
 		switch (reg) {
 		case MII_BMCR:
@@ -2233,9 +2222,6 @@ cas_mii_writereg(device_t dev, int phy, 
 #endif
 
 	sc = device_get_softc(dev);
-	if (sc->sc_phyad != -1 && phy != sc->sc_phyad)
-		return (0);
-
 	if ((sc->sc_flags & CAS_SERDES) != 0) {
 		switch (reg) {
 		case MII_BMSR:
@@ -2318,8 +2304,7 @@ cas_mii_statchg(device_t dev)
 
 #ifdef CAS_DEBUG
 	if ((ifp->if_flags & IFF_DEBUG) != 0)
-		device_printf(sc->sc_dev, "%s: status change: PHY = %d\n",
-		    __func__, sc->sc_phyad);
+		device_printf(sc->sc_dev, "%s: status changen", __func__);
 #endif
 
 	if ((sc->sc_mii->mii_media_status & IFM_ACTIVE) != 0 &&

Modified: stable/7/sys/dev/cas/if_casvar.h
==============================================================================
--- stable/7/sys/dev/cas/if_casvar.h	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/cas/if_casvar.h	Sun Nov  7 11:12:30 2010	(r214910)
@@ -154,8 +154,6 @@ struct cas_softc {
 	bus_dma_tag_t	sc_cdmatag;	/* control data bus DMA tag */
 	bus_dmamap_t	sc_dmamap;	/* bus DMA handle */
 
-	u_int		sc_phyad;	/* PHY to use or -1 for any */
-
 	u_int		sc_variant;
 #define	CAS_UNKNOWN	0		/* don't know */
 #define	CAS_CAS		1		/* Sun Cassini */

Modified: stable/7/sys/dev/dc/if_dc.c
==============================================================================
--- stable/7/sys/dev/dc/if_dc.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/dc/if_dc.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -779,26 +779,6 @@ dc_miibus_readreg(device_t dev, int phy,
 	sc = device_get_softc(dev);
 	bzero(&frame, sizeof(frame));
 
-	/*
-	 * Note: both the AL981 and AN983 have internal PHYs,
-	 * however the AL981 provides direct access to the PHY
-	 * registers while the AN983 uses a serial MII interface.
-	 * The AN983's MII interface is also buggy in that you
-	 * can read from any MII address (0 to 31), but only address 1
-	 * behaves normally. To deal with both cases, we pretend
-	 * that the PHY is at MII address 1.
-	 */
-	if (DC_IS_ADMTEK(sc) && phy != DC_ADMTEK_PHYADDR)
-		return (0);
-
-	/*
-	 * Note: the ukphy probes of the RS7112 report a PHY at
-	 * MII address 0 (possibly HomePNA?) and 1 (ethernet)
-	 * so we only respond to correct one.
-	 */
-	if (DC_IS_CONEXANT(sc) && phy != DC_CONEXANT_PHYADDR)
-		return (0);
-
 	if (sc->dc_pmode != DC_PMODE_MII) {
 		if (phy == (MII_NPHY - 1)) {
 			switch (reg) {
@@ -901,12 +881,6 @@ dc_miibus_writereg(device_t dev, int phy
 	sc = device_get_softc(dev);
 	bzero(&frame, sizeof(frame));
 
-	if (DC_IS_ADMTEK(sc) && phy != DC_ADMTEK_PHYADDR)
-		return (0);
-
-	if (DC_IS_CONEXANT(sc) && phy != DC_CONEXANT_PHYADDR)
-		return (0);
-
 	if (DC_IS_PNIC(sc)) {
 		CSR_WRITE_4(sc, DC_PN_MII, DC_PN_MIIOPCODE_WRITE |
 		    (phy << 23) | (reg << 10) | data);
@@ -1815,14 +1789,12 @@ dc_dma_map_addr(void *arg, bus_dma_segme
 static int
 dc_attach(device_t dev)
 {
-	int tmp = 0;
 	uint32_t eaddr[(ETHER_ADDR_LEN+3)/4];
 	u_int32_t command;
 	struct dc_softc *sc;
 	struct ifnet *ifp;
 	u_int32_t reg, revision;
-	int error = 0, rid, mac_offset;
-	int i;
+	int error, i, mac_offset, phy, rid, tmp;
 	u_int8_t *mac;
 
 	sc = device_get_softc(dev);
@@ -2203,6 +2175,7 @@ dc_attach(device_t dev)
 	 * old selection (SIA only or SIA/SYM) and attach the dcphy
 	 * driver instead.
 	 */
+	tmp = 0;
 	if (DC_IS_INTEL(sc)) {
 		dc_apply_fixup(sc, IFM_AUTO);
 		tmp = sc->dc_pmode;
@@ -2211,7 +2184,7 @@ dc_attach(device_t dev)
 
 	/*
 	 * Setup General Purpose port mode and data so the tulip can talk
-	 * to the MII.  This needs to be done before mii_phy_probe so that
+	 * to the MII.  This needs to be done before mii_attach so that
 	 * we can actually see them.
 	 */
 	if (DC_IS_XIRCOM(sc)) {
@@ -2223,16 +2196,37 @@ dc_attach(device_t dev)
 		DELAY(10);
 	}
 
-	error = mii_phy_probe(dev, &sc->dc_miibus,
-	    dc_ifmedia_upd, dc_ifmedia_sts);
+	phy = MII_PHY_ANY;
+	/*
+	 * Note: both the AL981 and AN983 have internal PHYs, however the
+	 * AL981 provides direct access to the PHY registers while the AN983
+	 * uses a serial MII interface. The AN983's MII interface is also
+	 * buggy in that you can read from any MII address (0 to 31), but
+	 * only address 1 behaves normally. To deal with both cases, we
+	 * pretend that the PHY is at MII address 1.
+	 */
+	if (DC_IS_ADMTEK(sc))
+		phy = DC_ADMTEK_PHYADDR;
+
+	/*
+	 * Note: the ukphy probes of the RS7112 report a PHY at MII address
+	 * 0 (possibly HomePNA?) and 1 (ethernet) so we only respond to the
+	 * correct one.
+	 */
+	if (DC_IS_CONEXANT(sc))
+		phy = DC_CONEXANT_PHYADDR;
+
+	error = mii_attach(dev, &sc->dc_miibus, ifp, dc_ifmedia_upd,
+	    dc_ifmedia_sts, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
 
 	if (error && DC_IS_INTEL(sc)) {
 		sc->dc_pmode = tmp;
 		if (sc->dc_pmode != DC_PMODE_SIA)
 			sc->dc_pmode = DC_PMODE_SYM;
 		sc->dc_flags |= DC_21143_NWAY;
-		mii_phy_probe(dev, &sc->dc_miibus,
-		    dc_ifmedia_upd, dc_ifmedia_sts);
+		mii_attach(dev, &sc->dc_miibus, ifp, dc_ifmedia_upd,
+		    dc_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
+		    MII_OFFSET_ANY, 0);
 		/*
 		 * For non-MII cards, we need to have the 21143
 		 * drive the LEDs. Except there are some systems
@@ -2247,7 +2241,7 @@ dc_attach(device_t dev)
 	}
 
 	if (error) {
-		device_printf(dev, "MII without any PHY!\n");
+		device_printf(dev, "attaching PHYs failed\n");
 		goto fail;
 	}
 

Modified: stable/7/sys/dev/dc/pnphy.c
==============================================================================
--- stable/7/sys/dev/dc/pnphy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/dc/pnphy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -132,6 +132,7 @@ pnphy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = pnphy_service;
@@ -169,8 +170,6 @@ pnphy_service(struct mii_softc *sc, stru
 		if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
 			break;
 
-		sc->mii_flags = 0;
-
 		switch (IFM_SUBTYPE(ife->ifm_media)) {
 		case IFM_AUTO:
 			/* NWAY is busted on this chip */

Modified: stable/7/sys/dev/fxp/if_fxp.c
==============================================================================
--- stable/7/sys/dev/fxp/if_fxp.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/fxp/if_fxp.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -805,10 +805,14 @@ fxp_attach(device_t dev)
 		ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL);
 		ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_MANUAL);
 	} else {
-		if (mii_phy_probe(dev, &sc->miibus, fxp_ifmedia_upd,
-		    fxp_ifmedia_sts)) {
-	                device_printf(dev, "MII without any PHY!\n");
-			error = ENXIO;
+		/*
+		 * i82557 wedge when isolating all of their PHYs.
+		 */
+		error = mii_attach(dev, &sc->miibus, ifp, fxp_ifmedia_upd,
+		    fxp_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
+		    MII_OFFSET_ANY, MIIF_NOISOLATE);
+		if (error != 0) {
+	                device_printf(dev, "attaching PHYs failed\n");
 			goto fail;
 		}
 	}

Modified: stable/7/sys/dev/gem/if_gem.c
==============================================================================
--- stable/7/sys/dev/gem/if_gem.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/gem/if_gem.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -149,7 +149,7 @@ gem_attach(struct gem_softc *sc)
 {
 	struct gem_txsoft *txs;
 	struct ifnet *ifp;
-	int error, i;
+	int error, i, phy;
 	uint32_t v;
 
 	if (bootverbose)
@@ -294,14 +294,15 @@ gem_attach(struct gem_softc *sc)
 		    BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
 		switch (sc->sc_variant) {
 		case GEM_SUN_ERI:
-			sc->sc_phyad = GEM_PHYAD_EXTERNAL;
+			phy = GEM_PHYAD_EXTERNAL;
 			break;
 		default:
-			sc->sc_phyad = -1;
+			phy = MII_PHY_ANY;
 			break;
 		}
-		error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus,
-		    gem_mediachange, gem_mediastatus);
+		error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp,
+		    gem_mediachange, gem_mediastatus, BMSR_DEFCAPMASK, phy,
+		    MII_OFFSET_ANY, 0);
 	}
 
 	/*
@@ -318,17 +319,18 @@ gem_attach(struct gem_softc *sc)
 		switch (sc->sc_variant) {
 		case GEM_SUN_ERI:
 		case GEM_APPLE_K2_GMAC:
-			sc->sc_phyad = GEM_PHYAD_INTERNAL;
+			phy = GEM_PHYAD_INTERNAL;
 			break;
 		case GEM_APPLE_GMAC:
-			sc->sc_phyad = GEM_PHYAD_EXTERNAL;
+			phy = GEM_PHYAD_EXTERNAL;
 			break;
 		default:
-			sc->sc_phyad = -1;
+			phy = MII_PHY_ANY;
 			break;
 		}
-		error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus,
-		    gem_mediachange, gem_mediastatus);
+		error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp,
+		    gem_mediachange, gem_mediastatus, BMSR_DEFCAPMASK, phy,
+		    MII_OFFSET_ANY, 0);
 	}
 
 	/*
@@ -348,12 +350,12 @@ gem_attach(struct gem_softc *sc)
 		GEM_BANK1_BARRIER(sc, GEM_MII_CONFIG, 4,
 		    BUS_SPACE_BARRIER_WRITE);
 		sc->sc_flags |= GEM_SERDES;
-		sc->sc_phyad = GEM_PHYAD_EXTERNAL;
-		error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus,
-		    gem_mediachange, gem_mediastatus);
+		error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp,
+		    gem_mediachange, gem_mediastatus, BMSR_DEFCAPMASK,
+		    GEM_PHYAD_EXTERNAL, MII_OFFSET_ANY, 0);
 	}
 	if (error != 0) {
-		device_printf(sc->sc_dev, "PHY probe failed: %d\n", error);
+		device_printf(sc->sc_dev, "attaching PHYs failed\n");
 		goto fail_rxd;
 	}
 	sc->sc_mii = device_get_softc(sc->sc_miibus);
@@ -1848,9 +1850,6 @@ gem_mii_readreg(device_t dev, int phy, i
 #endif
 
 	sc = device_get_softc(dev);
-	if (sc->sc_phyad != -1 && phy != sc->sc_phyad)
-		return (0);
-
 	if ((sc->sc_flags & GEM_SERDES) != 0) {
 		switch (reg) {
 		case MII_BMCR:
@@ -1909,9 +1908,6 @@ gem_mii_writereg(device_t dev, int phy, 
 #endif
 
 	sc = device_get_softc(dev);
-	if (sc->sc_phyad != -1 && phy != sc->sc_phyad)
-		return (0);
-
 	if ((sc->sc_flags & GEM_SERDES) != 0) {
 		switch (reg) {
 		case MII_BMSR:
@@ -1992,8 +1988,7 @@ gem_mii_statchg(device_t dev)
 
 #ifdef GEM_DEBUG
 	if ((sc->sc_ifp->if_flags & IFF_DEBUG) != 0)
-		device_printf(sc->sc_dev, "%s: status change: PHY = %d\n",
-		    __func__, sc->sc_phyad);
+		device_printf(sc->sc_dev, "%s: status change\n", __func__);
 #endif
 
 	if ((sc->sc_mii->mii_media_status & IFM_ACTIVE) != 0 &&

Modified: stable/7/sys/dev/gem/if_gemvar.h
==============================================================================
--- stable/7/sys/dev/gem/if_gemvar.h	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/gem/if_gemvar.h	Sun Nov  7 11:12:30 2010	(r214910)
@@ -126,8 +126,6 @@ struct gem_softc {
 	bus_dma_tag_t	sc_cdmatag;	/* control data bus DMA tag */
 	bus_dmamap_t	sc_dmamap;	/* bus DMA handle */
 
-	int		sc_phyad;	/* PHY to use or -1 for any */
-
 	u_int		sc_variant;
 #define	GEM_UNKNOWN		0	/* don't know */
 #define	GEM_SUN_GEM		1	/* Sun GEM */

Modified: stable/7/sys/dev/hme/if_hme.c
==============================================================================
--- stable/7/sys/dev/hme/if_hme.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/hme/if_hme.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -315,9 +315,20 @@ hme_config(struct hme_softc *sc)
 
 	hme_mifinit(sc);
 
-	if ((error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus, hme_mediachange,
-	    hme_mediastatus)) != 0) {
-		device_printf(sc->sc_dev, "phy probe failed: %d\n", error);
+	/*
+	 * DP83840A used with HME chips don't advertise their media
+	 * capabilities themselves properly so force writing the ANAR
+	 * according to the BMSR in mii_phy_setmedia().
+ 	 */
+	error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp, hme_mediachange,
+	    hme_mediastatus, BMSR_DEFCAPMASK, HME_PHYAD_EXTERNAL,
+	    MII_OFFSET_ANY, MIIF_FORCEANEG);
+	i = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp, hme_mediachange,
+	    hme_mediastatus, BMSR_DEFCAPMASK, HME_PHYAD_INTERNAL,
+	    MII_OFFSET_ANY, MIIF_FORCEANEG);
+	if (error != 0 && i != 0) {
+		error = ENXIO;
+		device_printf(sc->sc_dev, "attaching PHYs failed\n");
 		goto fail_rxdesc;
 	}
 	sc->sc_mii = device_get_softc(sc->sc_miibus);
@@ -1404,10 +1415,6 @@ hme_mii_readreg(device_t dev, int phy, i
 	int n;
 	u_int32_t v;
 
-	/* We can at most have two PHYs. */
-	if (phy != HME_PHYAD_EXTERNAL && phy != HME_PHYAD_INTERNAL)
-		return (0);
-
 	sc = device_get_softc(dev);
 	/* Select the desired PHY in the MIF configuration register */
 	v = HME_MIF_READ_4(sc, HME_MIFI_CFG);
@@ -1445,10 +1452,6 @@ hme_mii_writereg(device_t dev, int phy, 
 	int n;
 	u_int32_t v;
 
-	/* We can at most have two PHYs. */
-	if (phy != HME_PHYAD_EXTERNAL && phy != HME_PHYAD_INTERNAL)
-		return (0);
-
 	sc = device_get_softc(dev);
 	/* Select the desired PHY in the MIF configuration register */
 	v = HME_MIF_READ_4(sc, HME_MIFI_CFG);

Modified: stable/7/sys/dev/jme/if_jme.c
==============================================================================
--- stable/7/sys/dev/jme/if_jme.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/jme/if_jme.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -224,13 +224,8 @@ jme_miibus_readreg(device_t dev, int phy
 	sc = device_get_softc(dev);
 
 	/* For FPGA version, PHY address 0 should be ignored. */
-	if ((sc->jme_flags & JME_FLAG_FPGA) != 0) {
-		if (phy == 0)
-			return (0);
-	} else {
-		if (sc->jme_phyaddr != phy)
-			return (0);
-	}
+	if ((sc->jme_flags & JME_FLAG_FPGA) != 0 && phy == 0)
+		return (0);
 
 	CSR_WRITE_4(sc, JME_SMI, SMI_OP_READ | SMI_OP_EXECUTE |
 	    SMI_PHY_ADDR(phy) | SMI_REG_ADDR(reg));
@@ -260,13 +255,8 @@ jme_miibus_writereg(device_t dev, int ph
 	sc = device_get_softc(dev);
 
 	/* For FPGA version, PHY address 0 should be ignored. */
-	if ((sc->jme_flags & JME_FLAG_FPGA) != 0) {
-		if (phy == 0)
-			return (0);
-	} else {
-		if (sc->jme_phyaddr != phy)
-			return (0);
-	}
+	if ((sc->jme_flags & JME_FLAG_FPGA) != 0 && phy == 0)
+		return (0);
 
 	CSR_WRITE_4(sc, JME_SMI, SMI_OP_WRITE | SMI_OP_EXECUTE |
 	    ((val << SMI_DATA_SHIFT) & SMI_DATA_MASK) |
@@ -751,9 +741,11 @@ jme_attach(device_t dev)
 	ifp->if_capenable = ifp->if_capabilities;
 
 	/* Set up MII bus. */
-	if ((error = mii_phy_probe(dev, &sc->jme_miibus, jme_mediachange,
-	    jme_mediastatus)) != 0) {
-		device_printf(dev, "no PHY found!\n");
+	error = mii_attach(dev, &sc->jme_miibus, ifp, jme_mediachange,
+	    jme_mediastatus, BMSR_DEFCAPMASK, sc->jme_phyaddr, MII_OFFSET_ANY,
+	    0);
+	if (error != 0) {
+		device_printf(dev, "attaching PHYs failed\n");
 		goto fail;
 	}
 

Modified: stable/7/sys/dev/mii/acphy.c
==============================================================================
--- stable/7/sys/dev/mii/acphy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/acphy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -132,6 +132,7 @@ acphy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = acphy_service;

Modified: stable/7/sys/dev/mii/amphy.c
==============================================================================
--- stable/7/sys/dev/mii/amphy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/amphy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -109,6 +109,7 @@ amphy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = amphy_service;

Modified: stable/7/sys/dev/mii/atphy.c
==============================================================================
--- stable/7/sys/dev/mii/atphy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/atphy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -113,6 +113,7 @@ atphy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = atphy_service;

Modified: stable/7/sys/dev/mii/bmtphy.c
==============================================================================
--- stable/7/sys/dev/mii/bmtphy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/bmtphy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -147,6 +147,7 @@ bmtphy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = bmtphy_service;

Modified: stable/7/sys/dev/mii/brgphy.c
==============================================================================
--- stable/7/sys/dev/mii/brgphy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/brgphy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -191,6 +191,7 @@ brgphy_attach(device_t dev)
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
 	/* Initialize mii_softc structure */
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = brgphy_service;

Modified: stable/7/sys/dev/mii/ciphy.c
==============================================================================
--- stable/7/sys/dev/mii/ciphy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/ciphy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -57,9 +57,7 @@ __FBSDID("$FreeBSD$");
 #include "miibus_if.h"
 
 #include <machine/bus.h>
-/*
-#include <dev/vge/if_vgereg.h>
-*/
+
 static int ciphy_probe(device_t);
 static int ciphy_attach(device_t);
 
@@ -118,6 +116,7 @@ ciphy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = ciphy_service;

Modified: stable/7/sys/dev/mii/e1000phy.c
==============================================================================
--- stable/7/sys/dev/mii/e1000phy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/e1000phy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -59,9 +59,6 @@ __FBSDID("$FreeBSD$");
 #include "miidevs.h"
 
 #include <dev/mii/e1000phyreg.h>
-/* XXX */
-#include <machine/bus.h>
-#include <dev/msk/if_mskreg.h>
 
 #include "miibus_if.h"
 
@@ -71,7 +68,6 @@ static int	e1000phy_attach(device_t);
 struct e1000phy_softc {
 	struct mii_softc mii_sc;
 	int mii_model;
-	struct msk_mii_data *mmd;
 };
 
 static device_method_t e1000phy_methods[] = {
@@ -144,6 +140,7 @@ e1000phy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = e1000phy_service;
@@ -151,14 +148,9 @@ e1000phy_attach(device_t dev)
 
 	esc->mii_model = MII_MODEL(ma->mii_id2);
 	ifp = sc->mii_pdata->mii_ifp;
-	if (strcmp(ifp->if_dname, "msk") == 0) {
-		/* XXX */
-		esc->mmd = device_get_ivars(
-		    device_get_parent(device_get_parent(dev)));
-		if (esc->mmd != NULL &&
-		    (esc->mmd->mii_flags & MIIF_HAVEFIBER) != 0)
-			sc->mii_flags |= MIIF_HAVEFIBER;
-	}
+	if (strcmp(ifp->if_dname, "msk") == 0 &&
+	    (sc->mii_flags & MIIF_MACPRIV0) != 0)
+		sc->mii_flags |= MIIF_PHYPRIV0;
 
 	switch (esc->mii_model) {
 	case MII_MODEL_MARVELL_E1011:
@@ -214,7 +206,7 @@ e1000phy_reset(struct mii_softc *sc)
 			reg &= ~E1000_SCR_MODE_MASK;
 			reg |= E1000_SCR_MODE_1000BX;
 			PHY_WRITE(sc, E1000_SCR, reg);
-			if (esc->mmd != NULL && esc->mmd->pmd == 'P') {
+			if ((sc->mii_flags & MIIF_MACPRIV0) != 0) {
 				/* Set SIGDET polarity low for SFP module. */
 				PHY_WRITE(sc, E1000_EADR, 1);
 				reg = PHY_READ(sc, E1000_SCR);

Modified: stable/7/sys/dev/mii/exphy.c
==============================================================================
--- stable/7/sys/dev/mii/exphy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/exphy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -138,6 +138,7 @@ exphy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = exphy_service;

Modified: stable/7/sys/dev/mii/gentbi.c
==============================================================================
--- stable/7/sys/dev/mii/gentbi.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/gentbi.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -166,6 +166,7 @@ gentbi_attach(device_t dev)
 		    MII_OUI(ma->mii_id1, ma->mii_id2),
 		    MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = gentbi_service;

Modified: stable/7/sys/dev/mii/icsphy.c
==============================================================================
--- stable/7/sys/dev/mii/icsphy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/icsphy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -141,6 +141,7 @@ icsphy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = icsphy_service;

Modified: stable/7/sys/dev/mii/inphy.c
==============================================================================
--- stable/7/sys/dev/mii/inphy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/inphy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -107,6 +107,7 @@ inphy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = inphy_service;

Modified: stable/7/sys/dev/mii/ip1000phy.c
==============================================================================
--- stable/7/sys/dev/mii/ip1000phy.c	Sun Nov  7 11:12:29 2010	(r214909)
+++ stable/7/sys/dev/mii/ip1000phy.c	Sun Nov  7 11:12:30 2010	(r214910)
@@ -114,6 +114,7 @@ ip1000phy_attach(device_t dev)
 	mii = ma->mii_data;
 	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
+	sc->mii_flags = miibus_get_flags(dev);
 	sc->mii_inst = mii->mii_instance++;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_service = ip1000phy_service;
@@ -123,6 +124,10 @@ ip1000phy_attach(device_t dev)
 
 	isc->model = MII_MODEL(ma->mii_id2);
 	isc->revision = MII_REV(ma->mii_id2);
+	if (isc->model == MII_MODEL_ICPLUS_IP1000A &&
+	     strcmp(mii->mii_ifp->if_dname, "stge") == 0 &&
+	     (sc->mii_flags & MIIF_MACPRIV0) != 0)
+		sc->mii_flags |= MIIF_PHYPRIV0;
 
 	sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
 	if (sc->mii_capabilities & BMSR_EXTSTAT)
@@ -412,12 +417,8 @@ ip1000phy_load_dspcode(struct mii_softc 
 static void
 ip1000phy_reset(struct mii_softc *sc)
 {
-	struct ip1000phy_softc *isc;
-	struct stge_softc *stge_sc;
-	struct mii_data *mii;
 	uint32_t reg;
 
-	isc = (struct ip1000phy_softc *)sc;
 	mii_phy_reset(sc);
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201011071112.oA7BCUYl040102>