]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: phy: bcm54811: PHY initialization
authorKamil Horák - 2N <kamilh@axis.com>
Tue, 8 Jul 2025 09:01:40 +0000 (11:01 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 10 Jul 2025 02:32:31 +0000 (19:32 -0700)
Reset the bit 12 in PHY's LRE Control register upon initialization.
According to the datasheet, this bit must be written to zero after
every device reset.

Signed-off-by: Kamil Horák - 2N <kamilh@axis.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20250708090140.61355-5-kamilh@axis.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/broadcom.c

index 8547983bd72f4cd7ab01e404750558302fd5a47e..a60e58ef90c4e1277d3f2633563a829d06a6c7dc 100644 (file)
@@ -667,7 +667,7 @@ static int bcm5481x_read_abilities(struct phy_device *phydev)
 {
        struct device_node *np = phydev->mdio.dev.of_node;
        struct bcm54xx_phy_priv *priv = phydev->priv;
-       int i, val, err;
+       int i, val, err, aneg;
 
        for (i = 0; i < ARRAY_SIZE(bcm54811_linkmodes); i++)
                linkmode_clear_bit(bcm54811_linkmodes[i], phydev->supported);
@@ -688,9 +688,19 @@ static int bcm5481x_read_abilities(struct phy_device *phydev)
                if (val < 0)
                        return val;
 
+               /* BCM54811 is not capable of LDS but the corresponding bit
+                * in LRESR is set to 1 and marked "Ignore" in the datasheet.
+                * So we must read the bcm54811 as unable to auto-negotiate
+                * in BroadR-Reach mode.
+                */
+               if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
+                       aneg = 0;
+               else
+                       aneg = val & LRESR_LDSABILITY;
+
                linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
                                 phydev->supported,
-                                val & LRESR_LDSABILITY);
+                                aneg);
                linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT1_Full_BIT,
                                 phydev->supported,
                                 val & LRESR_100_1PAIR);
@@ -747,8 +757,15 @@ static int bcm54811_config_aneg(struct phy_device *phydev)
 
        /* Aneg firstly. */
        if (priv->brr_mode) {
-               /* BCM54811 is only capable of autonegotiation in IEEE mode */
-               phydev->autoneg = 0;
+               /* BCM54811 is only capable of autonegotiation in IEEE mode.
+                * In BroadR-Reach mode, disable the Long Distance Signaling,
+                * the BRR mode autoneg as supported in other Broadcom PHYs.
+                * This bit is marked as "Reserved" and "Default 1, must be
+                *  written to 0 after every device reset" in the datasheet.
+                */
+               ret = phy_modify(phydev, MII_BCM54XX_LRECR, LRECR_LDSEN, 0);
+               if (ret < 0)
+                       return ret;
                ret = bcm_config_lre_aneg(phydev, false);
        } else {
                ret = genphy_config_aneg(phydev);