net: phy: marvell10g: add support for half duplex 100M and 10M
authorRussell King <rmk+kernel@armlinux.org.uk>
Fri, 29 Dec 2017 12:46:43 +0000 (12:46 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 2 Jan 2018 20:00:50 +0000 (15:00 -0500)
Add support for half-duplex 100M and 10M copper connections by parsing
the advertisment results rather than trying to decode the negotiated
speed from one of the PHYs "vendor" registers.  This allows us to
decode the duplex as well, which means we can support half-duplex mode
for the slower speeds.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/marvell10g.c

index fa7245a573e2cc94d5faeb3ed4c6b482662def69..8a0bd98fdec77400e729683a4aec6381a4c57051 100644 (file)
@@ -40,13 +40,6 @@ enum {
         */
        MV_AN_CTRL1000          = 0x8000, /* 1000base-T control register */
        MV_AN_STAT1000          = 0x8001, /* 1000base-T status register */
-
-       /* This register appears to reflect the copper status */
-       MV_AN_RESULT            = 0xa016,
-       MV_AN_RESULT_SPD_10     = BIT(12),
-       MV_AN_RESULT_SPD_100    = BIT(13),
-       MV_AN_RESULT_SPD_1000   = BIT(14),
-       MV_AN_RESULT_SPD_10000  = BIT(15),
 };
 
 static int mv3310_modify(struct phy_device *phydev, int devad, u16 reg,
@@ -160,12 +153,18 @@ static int mv3310_config_init(struct phy_device *phydev)
                if (val & MDIO_PMA_EXTABLE_1000BKX)
                        __set_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT,
                                  supported);
-               if (val & MDIO_PMA_EXTABLE_100BTX)
+               if (val & MDIO_PMA_EXTABLE_100BTX) {
                        __set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
                                  supported);
-               if (val & MDIO_PMA_EXTABLE_10BT)
+                       __set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT,
+                                 supported);
+               }
+               if (val & MDIO_PMA_EXTABLE_10BT) {
                        __set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
                                  supported);
+                       __set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT,
+                                 supported);
+               }
        }
 
        if (!ethtool_convert_link_mode_to_legacy_u32(&mask, supported))
@@ -325,22 +324,8 @@ static int mv3310_read_status(struct phy_device *phydev)
 
                phydev->lp_advertising |= mii_stat1000_to_ethtool_lpa_t(val);
 
-               if (phydev->autoneg == AUTONEG_ENABLE) {
-                       val = phy_read_mmd(phydev, MDIO_MMD_AN, MV_AN_RESULT);
-                       if (val < 0)
-                               return val;
-
-                       if (val & MV_AN_RESULT_SPD_10000)
-                               phydev->speed = SPEED_10000;
-                       else if (val & MV_AN_RESULT_SPD_1000)
-                               phydev->speed = SPEED_1000;
-                       else if (val & MV_AN_RESULT_SPD_100)
-                               phydev->speed = SPEED_100;
-                       else if (val & MV_AN_RESULT_SPD_10)
-                               phydev->speed = SPEED_10;
-
-                       phydev->duplex = DUPLEX_FULL;
-               }
+               if (phydev->autoneg == AUTONEG_ENABLE)
+                       phy_resolve_aneg_linkmode(phydev);
        }
 
        if (phydev->autoneg != AUTONEG_ENABLE) {
@@ -382,7 +367,9 @@ static struct phy_driver mv3310_drivers[] = {
                .phy_id_mask    = MARVELL_PHY_ID_MASK,
                .name           = "mv88x3310",
                .features       = SUPPORTED_10baseT_Full |
+                                 SUPPORTED_10baseT_Half |
                                  SUPPORTED_100baseT_Full |
+                                 SUPPORTED_100baseT_Half |
                                  SUPPORTED_1000baseT_Full |
                                  SUPPORTED_Autoneg |
                                  SUPPORTED_TP |