Skip to content

Commit b1129e6

Browse files
committed
net: phy: dp83867: retrigger SGMII AN when link change
Author: Tan Tee Min <tee.min.tan@linux.intel.com> There is a limitation in TI DP83867 PHY device where SGMII AN is only triggered once after the device is booted up. Even after the PHY TPI is down and up again, SGMII AN is not triggered and hence no new in-band message from PHY to MAC side SGMII. This could cause an issue during power up, when PHY is up prior to MAC. At this condition, once MAC side SGMII is up, MAC side SGMII wouldn`t receive new in-band message from TI PHY with correct link status, speed and duplex info. As suggested by TI, implemented a SW solution here to retrigger SGMII Auto-Neg whenever there is a link change. v2: Add Fixes tag in commit message. Fixes: 2a10154 ("net: phy: dp83867: Add TI dp83867 phy") Cc: <stable@vger.kernel.org> # 5.4.x Signed-off-by: Sit, Michael Wei Hong <michael.wei.hong.sit@intel.com> Reviewed-by: Voon Weifeng <weifeng.voon@intel.com> Signed-off-by: Tan Tee Min <tee.min.tan@linux.intel.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20220526090347.128742-1-tee.min.tan@linux.intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit c76acfb) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100606 Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
1 parent 6dc70ea commit b1129e6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/net/phy/dp83867.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
#define DP83867_DOWNSHIFT_2_COUNT 2
138138
#define DP83867_DOWNSHIFT_4_COUNT 4
139139
#define DP83867_DOWNSHIFT_8_COUNT 8
140+
#define DP83867_SGMII_AUTONEG_EN BIT(7)
140141

141142
/* CFG3 bits */
142143
#define DP83867_CFG3_INT_OE BIT(7)
@@ -836,6 +837,32 @@ static int dp83867_phy_reset(struct phy_device *phydev)
836837
DP83867_PHYCR_FORCE_LINK_GOOD, 0);
837838
}
838839

840+
static void dp83867_link_change_notify(struct phy_device *phydev)
841+
{
842+
/* There is a limitation in DP83867 PHY device where SGMII AN is
843+
* only triggered once after the device is booted up. Even after the
844+
* PHY TPI is down and up again, SGMII AN is not triggered and
845+
* hence no new in-band message from PHY to MAC side SGMII.
846+
* This could cause an issue during power up, when PHY is up prior
847+
* to MAC. At this condition, once MAC side SGMII is up, MAC side
848+
* SGMII wouldn`t receive new in-band message from TI PHY with
849+
* correct link status, speed and duplex info.
850+
* Thus, implemented a SW solution here to retrigger SGMII Auto-Neg
851+
* whenever there is a link change.
852+
*/
853+
if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
854+
int val = 0;
855+
856+
val = phy_clear_bits(phydev, DP83867_CFG2,
857+
DP83867_SGMII_AUTONEG_EN);
858+
if (val < 0)
859+
return;
860+
861+
phy_set_bits(phydev, DP83867_CFG2,
862+
DP83867_SGMII_AUTONEG_EN);
863+
}
864+
}
865+
839866
static struct phy_driver dp83867_driver[] = {
840867
{
841868
.phy_id = DP83867_PHY_ID,
@@ -860,6 +887,8 @@ static struct phy_driver dp83867_driver[] = {
860887

861888
.suspend = genphy_suspend,
862889
.resume = genphy_resume,
890+
891+
.link_change_notify = dp83867_link_change_notify,
863892
},
864893
};
865894
module_phy_driver(dp83867_driver);

0 commit comments

Comments
 (0)