kernel: ar8216: add get_features method
authorDavid Bauer <mail@david-bauer.net>
Wed, 2 Jun 2021 17:34:01 +0000 (19:34 +0200)
committerDavid Bauer <mail@david-bauer.net>
Wed, 2 Jun 2021 22:00:46 +0000 (00:00 +0200)
Modifying PHY capabilities in the probe function broke with upstream
commit 92ed2eb7f4b7 ("net: phy: probe the PHY before determining the
supported features").

AR8316 switches only support 10/100 Mbit/s link modes because of this
change.

Provide a get_features method for the PHY driver, so Gigabit link mode
will be advertised to link partners again.

Signed-off-by: David Bauer <mail@david-bauer.net>
target/linux/generic/files/drivers/net/phy/ar8216.c

index ef0fc549492d1e3c22513f2017793c1ebd3b8817..dbcb1c41c414029f91c5673d0af1105832eea0d8 100644 (file)
@@ -2552,6 +2552,18 @@ ar8xxx_phy_config_aneg(struct phy_device *phydev)
        return genphy_config_aneg(phydev);
 }
 
+static int
+ar8xxx_get_features(struct phy_device *phydev)
+{
+       struct ar8xxx_priv *priv = phydev->priv;
+
+       linkmode_copy(phydev->supported, PHY_BASIC_FEATURES);
+       if (ar8xxx_has_gige(priv))
+               linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, phydev->supported);
+
+       return 0;
+}
+
 static const u32 ar8xxx_phy_ids[] = {
        0x004dd033,
        0x004dd034, /* AR8327 */
@@ -2649,29 +2661,14 @@ ar8xxx_phy_probe(struct phy_device *phydev)
 found:
        priv->use_count++;
 
-       if (phydev->mdio.addr == 0) {
-               linkmode_zero(phydev->supported);
-               if (ar8xxx_has_gige(priv))
-                       linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, phydev->supported);
-               else
-                       linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported);
-               linkmode_copy(phydev->advertising, phydev->supported);
+       if (phydev->mdio.addr == 0 && priv->chip->config_at_probe) {
+               priv->phy = phydev;
 
-               if (priv->chip->config_at_probe) {
-                       priv->phy = phydev;
-
-                       ret = ar8xxx_start(priv);
-                       if (ret)
-                               goto err_unregister_switch;
-               }
-       } else {
-               if (ar8xxx_has_gige(priv)) {
-                       linkmode_zero(phydev->supported);
-                       linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, phydev->supported);
-                       linkmode_copy(phydev->advertising, phydev->supported);
-               }
-               if (priv->chip->phy_rgmii_set)
-                       priv->chip->phy_rgmii_set(priv, phydev);
+               ret = ar8xxx_start(priv);
+               if (ret)
+                       goto err_unregister_switch;
+       } else if (priv->chip->phy_rgmii_set) {
+               priv->chip->phy_rgmii_set(priv, phydev);
        }
 
        phydev->priv = priv;
@@ -2746,7 +2743,6 @@ static struct phy_driver ar8xxx_phy_driver[] = {
                .phy_id         = 0x004d0000,
                .name           = "Atheros AR8216/AR8236/AR8316",
                .phy_id_mask    = 0xffff0000,
-               .features       = PHY_BASIC_FEATURES,
                .probe          = ar8xxx_phy_probe,
                .remove         = ar8xxx_phy_remove,
                .detach         = ar8xxx_phy_detach,
@@ -2754,6 +2750,7 @@ static struct phy_driver ar8xxx_phy_driver[] = {
                .config_aneg    = ar8xxx_phy_config_aneg,
                .read_status    = ar8xxx_phy_read_status,
                .soft_reset     = ar8xxx_phy_soft_reset,
+               .get_features   = ar8xxx_get_features,
        }
 };