Author: marius
Date: Fri Oct 15 14:52:11 2010
New Revision: 213893
URL: http://svn.freebsd.org/changeset/base/213893

Log:
  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 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:
  head/sys/arm/econa/if_ece.c
  head/sys/arm/xscale/ixp425/if_npe.c
  head/sys/dev/ae/if_ae.c
  head/sys/dev/ae/if_aevar.h
  head/sys/dev/age/if_age.c
  head/sys/dev/alc/if_alc.c
  head/sys/dev/ale/if_ale.c
  head/sys/dev/bfe/if_bfe.c
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h
  head/sys/dev/bm/if_bm.c
  head/sys/dev/cas/if_cas.c
  head/sys/dev/cas/if_casvar.h
  head/sys/dev/dc/if_dc.c
  head/sys/dev/dc/pnphy.c
  head/sys/dev/fxp/if_fxp.c
  head/sys/dev/gem/if_gem.c
  head/sys/dev/gem/if_gemvar.h
  head/sys/dev/hme/if_hme.c
  head/sys/dev/jme/if_jme.c
  head/sys/dev/mge/if_mge.c
  head/sys/dev/mge/if_mgevar.h
  head/sys/dev/mii/acphy.c
  head/sys/dev/mii/amphy.c
  head/sys/dev/mii/atphy.c
  head/sys/dev/mii/axphy.c
  head/sys/dev/mii/bmtphy.c
  head/sys/dev/mii/brgphy.c
  head/sys/dev/mii/ciphy.c
  head/sys/dev/mii/e1000phy.c
  head/sys/dev/mii/exphy.c
  head/sys/dev/mii/gentbi.c
  head/sys/dev/mii/icsphy.c
  head/sys/dev/mii/inphy.c
  head/sys/dev/mii/ip1000phy.c
  head/sys/dev/mii/jmphy.c
  head/sys/dev/mii/lxtphy.c
  head/sys/dev/mii/mlphy.c
  head/sys/dev/mii/nsgphy.c
  head/sys/dev/mii/nsphy.c
  head/sys/dev/mii/nsphyter.c
  head/sys/dev/mii/pnaphy.c
  head/sys/dev/mii/qsphy.c
  head/sys/dev/mii/rgephy.c
  head/sys/dev/mii/rlphy.c
  head/sys/dev/mii/rlswitch.c
  head/sys/dev/mii/ruephy.c
  head/sys/dev/mii/smcphy.c
  head/sys/dev/mii/tdkphy.c
  head/sys/dev/mii/tlphy.c
  head/sys/dev/mii/truephy.c
  head/sys/dev/mii/ukphy.c
  head/sys/dev/mii/xmphy.c
  head/sys/dev/msk/if_msk.c
  head/sys/dev/pcn/if_pcn.c
  head/sys/dev/re/if_re.c
  head/sys/dev/sk/if_sk.c
  head/sys/dev/ste/if_ste.c
  head/sys/dev/stge/if_stge.c
  head/sys/dev/tsec/if_tsec.c
  head/sys/dev/vge/if_vge.c
  head/sys/dev/vr/if_vr.c
  head/sys/dev/vr/if_vrreg.h
  head/sys/dev/xl/if_xl.c
  head/sys/mips/cavium/octe/octe.c
  head/sys/mips/rmi/dev/nlge/if_nlge.c
  head/sys/pci/if_rl.c

Modified: head/sys/arm/econa/if_ece.c
==============================================================================
--- head/sys/arm/econa/if_ece.c Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/arm/econa/if_ece.c Fri Oct 15 14:52:11 2010        (r213893)
@@ -353,10 +353,11 @@ ece_attach(device_t dev)
        }
        ece_set_mac(sc, eaddr);
        sc->ifp = ifp = if_alloc(IFT_ETHER);
-       if (mii_phy_probe(dev, &sc->miibus, ece_ifmedia_upd,
-                   ece_ifmedia_sts)) {
-               device_printf(dev, "Cannot find my PHY.\n");
-               err = ENXIO;
+       /* Only one PHY at address 0 in this device. */
+       err = mii_attach(dev, &sc->miibus, ifp, ece_ifmedia_upd,
+           ece_ifmedia_sts, BMSR_DEFCAPMASK, 0, MII_OFFSET_ANY, 0);
+       if (err != 0) {
+               device_printf(dev, "attaching PHYs failed\n");
                goto out;
        }
        ifp->if_softc = sc;
@@ -1904,9 +1905,6 @@ static int
 ece_miibus_readreg(device_t dev, int phy, int reg)
 {
        struct ece_softc *sc;
-       /* Only one phy in this device. */
-       if (phy>0)
-               return (0);
        sc = device_get_softc(dev);
        return (phy_read(sc, phy, reg));
 }

Modified: head/sys/arm/xscale/ixp425/if_npe.c
==============================================================================
--- head/sys/arm/xscale/ixp425/if_npe.c Fri Oct 15 14:34:34 2010        
(r213892)
+++ head/sys/arm/xscale/ixp425/if_npe.c Fri Oct 15 14:52:11 2010        
(r213893)
@@ -137,7 +137,6 @@ struct npe_softc {
        int             rx_freeqid;     /* rx free buffers qid */
        int             tx_qid;         /* tx qid */
        int             tx_doneqid;     /* tx completed qid */
-       int             sc_phy;         /* PHY id */
        struct ifmib_iso_8802_3 mibdata;
        bus_dma_tag_t   sc_stats_tag;   /* bus dma tag for stats block */
        struct npestats *sc_stats;
@@ -668,7 +667,7 @@ static int
 npe_activate(device_t dev)
 {
        struct npe_softc *sc = device_get_softc(dev);
-       int error, i, macbase, miibase;
+       int error, i, macbase, miibase, phy;
 
        /*
         * Setup NEP ID, MAC, and MII bindings.  We allow override
@@ -693,8 +692,8 @@ npe_activate(device_t dev)
        }
 
        /* PHY */
-       if (!override_unit(dev, "phy", &sc->sc_phy, 0, MII_NPHY-1))
-               sc->sc_phy = npeconfig[sc->sc_npeid].phy;
+       if (!override_unit(dev, "phy", &phy, 0, MII_NPHY - 1))
+               phy = npeconfig[sc->sc_npeid].phy;
        if (!override_addr(dev, "mii", &miibase))
                miibase = npeconfig[sc->sc_npeid].miibase;
        device_printf(sc->sc_dev, "MII at 0x%x\n", miibase);
@@ -721,10 +720,12 @@ npe_activate(device_t dev)
                return error;
        }
 
-       /* probe for PHY */
-       if (mii_phy_probe(dev, &sc->sc_mii, npe_ifmedia_update, 
npe_ifmedia_status)) {
-               device_printf(dev, "cannot find PHY %d.\n", sc->sc_phy);
-               return ENXIO;
+       /* attach PHY */
+       error = mii_attach(dev, &sc->sc_mii, sc->sc_ifp, npe_ifmedia_update,
+           npe_ifmedia_status, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
+       if (error != 0) {
+               device_printf(dev, "attaching PHYs failed\n");
+               return error;
        }
 
        error = npe_dma_setup(sc, &sc->txdma, "tx", npe_txbuf, NPE_MAXSEG);
@@ -1700,8 +1701,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);
        if (npe_mii_mdio_wait(sc))
@@ -1717,8 +1716,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 (0);
        v = (phy << NPE_MII_ADDR_SHL) | (reg << NPE_MII_REG_SHL)
          | data | NPE_MII_WRITE
          | NPE_MII_GO;

Modified: head/sys/dev/ae/if_ae.c
==============================================================================
--- head/sys/dev/ae/if_ae.c     Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/ae/if_ae.c     Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/ae/if_aevar.h
==============================================================================
--- head/sys/dev/ae/if_aevar.h  Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/ae/if_aevar.h  Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/age/if_age.c
==============================================================================
--- head/sys/dev/age/if_age.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/age/if_age.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/alc/if_alc.c
==============================================================================
--- head/sys/dev/alc/if_alc.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/alc/if_alc.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/ale/if_ale.c
==============================================================================
--- head/sys/dev/ale/if_ale.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/ale/if_ale.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/bfe/if_bfe.c
==============================================================================
--- head/sys/dev/bfe/if_bfe.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/bfe/if_bfe.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -505,10 +505,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;
        }
 
@@ -631,8 +632,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);
@@ -644,8 +643,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: head/sys/dev/bge/if_bge.c
==============================================================================
--- head/sys/dev/bge/if_bge.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/bge/if_bge.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -781,10 +781,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,
@@ -2563,7 +2559,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;
@@ -2596,7 +2592,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 ether...@wirespeed for the 5700, 5906, or the
@@ -2961,17 +2957,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: head/sys/dev/bge/if_bgereg.h
==============================================================================
--- head/sys/dev/bge/if_bgereg.h        Fri Oct 15 14:34:34 2010        
(r213892)
+++ head/sys/dev/bge/if_bgereg.h        Fri Oct 15 14:52:11 2010        
(r213893)
@@ -2757,7 +2757,6 @@ struct bge_softc {
        uint32_t                bge_tx_max_coal_bds;
        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: head/sys/dev/bm/if_bm.c
==============================================================================
--- head/sys/dev/bm/if_bm.c     Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/bm/if_bm.c     Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/cas/if_cas.c
==============================================================================
--- head/sys/dev/cas/if_cas.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/cas/if_cas.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/cas/if_casvar.h
==============================================================================
--- head/sys/dev/cas/if_casvar.h        Fri Oct 15 14:34:34 2010        
(r213892)
+++ head/sys/dev/cas/if_casvar.h        Fri Oct 15 14:52:11 2010        
(r213893)
@@ -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: head/sys/dev/dc/if_dc.c
==============================================================================
--- head/sys/dev/dc/if_dc.c     Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/dc/if_dc.c     Fri Oct 15 14:52:11 2010        (r213893)
@@ -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);
@@ -2217,6 +2189,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;
@@ -2225,7 +2198,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)) {
@@ -2237,16 +2210,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
@@ -2261,7 +2255,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: head/sys/dev/dc/pnphy.c
==============================================================================
--- head/sys/dev/dc/pnphy.c     Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/dc/pnphy.c     Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/fxp/if_fxp.c
==============================================================================
--- head/sys/dev/fxp/if_fxp.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/fxp/if_fxp.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -804,10 +804,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: head/sys/dev/gem/if_gem.c
==============================================================================
--- head/sys/dev/gem/if_gem.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/gem/if_gem.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/gem/if_gemvar.h
==============================================================================
--- head/sys/dev/gem/if_gemvar.h        Fri Oct 15 14:34:34 2010        
(r213892)
+++ head/sys/dev/gem/if_gemvar.h        Fri Oct 15 14:52:11 2010        
(r213893)
@@ -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: head/sys/dev/hme/if_hme.c
==============================================================================
--- head/sys/dev/hme/if_hme.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/hme/if_hme.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/jme/if_jme.c
==============================================================================
--- head/sys/dev/jme/if_jme.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/jme/if_jme.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -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) |
@@ -743,9 +733,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: head/sys/dev/mge/if_mge.c
==============================================================================
--- head/sys/dev/mge/if_mge.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/mge/if_mge.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -629,7 +629,7 @@ mge_attach(device_t dev)
        struct mii_softc *miisc;
        struct ifnet *ifp;
        uint8_t hwaddr[ETHER_ADDR_LEN];
-       int i, error ;
+       int i, error, phy;
 
        sc = device_get_softc(dev);
        sc->dev = dev;
@@ -642,7 +642,7 @@ mge_attach(device_t dev)
        mge_ver_params(sc);
 
        /* Get phy address from fdt */
-       if (fdt_get_phyaddr(sc->node, &sc->phyaddr) != 0)
+       if (fdt_get_phyaddr(sc->node, &phy) != 0)
                return (ENXIO);
 
        /* Initialize mutexes */
@@ -706,10 +706,11 @@ mge_attach(device_t dev)
        ether_ifattach(ifp, hwaddr);
        callout_init(&sc->wd_callout, 0);
 
-       /* Probe PHY(s) */
-       error = mii_phy_probe(dev, &sc->miibus, mge_ifmedia_upd, 
mge_ifmedia_sts);
+       /* Attach PHY(s) */
+       error = mii_attach(dev, &sc->miibus, ifp, mge_ifmedia_upd,
+           mge_ifmedia_sts, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
        if (error) {
-               device_printf(dev, "MII failed to find PHY\n");
+               device_printf(dev, "attaching PHYs failed\n");
                mge_detach(dev);
                return (error);
        }
@@ -1293,9 +1294,6 @@ mge_miibus_readreg(device_t dev, int phy
 
        sc = device_get_softc(dev);
 
-       if (sc->phyaddr != phy)
-               return (0);
-
        MGE_WRITE(sc_mge0, MGE_REG_SMI, 0x1fffffff &
            (MGE_SMI_READ | (reg << 21) | (phy << 16)));
 
@@ -1317,9 +1315,6 @@ mge_miibus_writereg(device_t dev, int ph
 
        sc = device_get_softc(dev);
 
-       if (sc->phyaddr != phy)
-               return (0);
-
        MGE_WRITE(sc_mge0, MGE_REG_SMI, 0x1fffffff &
            (MGE_SMI_WRITE | (reg << 21) | (phy << 16) | (value & 0xffff)));
 

Modified: head/sys/dev/mge/if_mgevar.h
==============================================================================
--- head/sys/dev/mge/if_mgevar.h        Fri Oct 15 14:34:34 2010        
(r213892)
+++ head/sys/dev/mge/if_mgevar.h        Fri Oct 15 14:52:11 2010        
(r213893)
@@ -103,8 +103,6 @@ struct mge_softc {
        uint32_t        mge_tx_tok_cnt;
        uint16_t        mge_mtu;
        int             mge_ver;
-
-       int             phyaddr;
 };
 
 

Modified: head/sys/dev/mii/acphy.c
==============================================================================
--- head/sys/dev/mii/acphy.c    Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/mii/acphy.c    Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/mii/amphy.c
==============================================================================
--- head/sys/dev/mii/amphy.c    Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/mii/amphy.c    Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/mii/atphy.c
==============================================================================
--- head/sys/dev/mii/atphy.c    Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/mii/atphy.c    Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/mii/axphy.c
==============================================================================
--- head/sys/dev/mii/axphy.c    Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/mii/axphy.c    Fri Oct 15 14:52:11 2010        (r213893)
@@ -97,6 +97,7 @@ axphy_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 = axphy_service;

Modified: head/sys/dev/mii/bmtphy.c
==============================================================================
--- head/sys/dev/mii/bmtphy.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/mii/bmtphy.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/mii/brgphy.c
==============================================================================
--- head/sys/dev/mii/brgphy.c   Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/mii/brgphy.c   Fri Oct 15 14:52:11 2010        (r213893)
@@ -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: head/sys/dev/mii/ciphy.c
==============================================================================
--- head/sys/dev/mii/ciphy.c    Fri Oct 15 14:34:34 2010        (r213892)
+++ head/sys/dev/mii/ciphy.c    Fri Oct 15 14:52:11 2010        (r213893)
@@ -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);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to