bge(4)s traditionally only have a phy at address 1, which is enforced
by the mii_read backend by failing reads at any other address.

why not just tell mii up front that the phy is at address 1?

why not avoid a conditional in an io path?

also, this is necessary to support recent chips which have phys at
different locations. 5717s through 5720s (and maybe chips in the
future) have phys at addresses relative to the pci function number
and whether theyre serdes capable. to support them we'll have to
be able to support phys at locations other than 1.

tested on this:

bge0 at pci3 dev 4 function 0 "Broadcom BCM5714" rev 0xa3, BCM5715 A3 (0x9003): 
ivec 0x795, address 00:14:4f:a9:34:90
brgphy0 at bge0 phy 1: BCM5714 10/100/1000baseT/SX PHY, rev. 0

so at least one old thing still works. ok?


Index: if_bge.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_bge.c,v
retrieving revision 1.311
diff -u -p -r1.311 if_bge.c
--- if_bge.c    4 Jul 2012 13:24:41 -0000       1.311
+++ if_bge.c    13 Sep 2012 01:16:19 -0000
@@ -586,18 +586,6 @@ bge_miibus_readreg(struct device *dev, i
        u_int32_t val, autopoll;
        int i;
 
-       /*
-        * Broadcom's own driver always assumes the internal
-        * PHY is at GMII address 1. On some chips, the PHY responds
-        * to accesses at all addresses, which could cause us to
-        * bogusly attach the PHY 32 times at probe type. Always
-        * restricting the lookup to address 1 is simpler than
-        * trying to figure out which chips revisions should be
-        * special-cased.
-        */
-       if (phy != 1)
-               return (0);
-
        /* Reading with autopolling on may trigger PCI errors */
        autopoll = CSR_READ_4(sc, BGE_MI_MODE);
        if (autopoll & BGE_MIMODE_AUTOPOLL) {
@@ -2253,8 +2241,8 @@ bge_attach(struct device *parent, struct
                if (sc->bge_flags & BGE_PHY_FIBER_MII)
                        mii_flags |= MIIF_HAVEFIBER;
                mii_attach(&sc->bge_dev, &sc->bge_mii, 0xffffffff,
-                          MII_PHY_ANY, MII_OFFSET_ANY, mii_flags);
-               
+                   1, MII_OFFSET_ANY, mii_flags);
+
                if (LIST_FIRST(&sc->bge_mii.mii_phys) == NULL) {
                        printf("%s: no PHY found!\n", sc->bge_dev.dv_xname);
                        ifmedia_add(&sc->bge_mii.mii_media,

Reply via email to