net: phy: read MMD ID from all present MMDs
authorRussell King <rmk+kernel@armlinux.org.uk>
Thu, 18 Jun 2020 13:46:13 +0000 (14:46 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 20 Jun 2020 03:17:15 +0000 (20:17 -0700)
Expand the device_ids[] array to allow all MMD IDs to be read rather
than just the first 8 MMDs, but only read the ID if the MDIO_STAT2
register reports that a device really is present here for these new
devices to maintain compatibility with our current behaviour.  Note
that only a limited number of devices have MDIO_STAT2.

88X3310 PHY vendor MMDs do are marked as present in the
devices_in_package, but do not contain IEE 802.3 compatible register
sets in their lower space.  This avoids reading incorrect values as MMD
identifiers.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy_device.c
include/linux/phy.h

index c1f81c4d0bb3450d860d3ed149fd7715e650bace..29ef4456ac253160f24458515b4f28656bf52024 100644 (file)
@@ -774,6 +774,19 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
                if (!(devs_in_pkg & (1 << i)))
                        continue;
 
+               if (i == MDIO_MMD_VEND1 || i == MDIO_MMD_VEND2) {
+                       /* Probe the "Device Present" bits for the vendor MMDs
+                        * to ignore these if they do not contain IEEE 802.3
+                        * registers.
+                        */
+                       ret = phy_c45_probe_present(bus, addr, i);
+                       if (ret < 0)
+                               return ret;
+
+                       if (!ret)
+                               continue;
+               }
+
                phy_reg = mdiobus_c45_read(bus, addr, i, MII_PHYSID1);
                if (phy_reg < 0)
                        return -EIO;
index 19d9e040ad84bc9ac6936e69bdabd63bedc549be..9248dd2ce4ca7fdca3c52ac82dc60854298a7dee 100644 (file)
@@ -399,7 +399,7 @@ enum phy_state {
 struct phy_c45_device_ids {
        u32 devices_in_package;
        u32 mmds_present;
-       u32 device_ids[8];
+       u32 device_ids[MDIO_MMD_NUM];
 };
 
 struct macsec_context;