Commit 84383b5e authored by Raju Lakkaraju's avatar Raju Lakkaraju Committed by Jakub Kicinski

net: phy: micrel: Fix the KSZ9131 MDI-X status issue

The MDIX status is not accurately reflecting the current state after the link
partner has manually altered its MDIX configuration while operating in forced
mode.

Access information about Auto mdix completion and pair selection from the
KSZ9131's Auto/MDI/MDI-X status register

Fixes: b64e6a87 ("net: phy: micrel: Add PHY Auto/MDI/MDI-X set driver for KSZ9131")
Signed-off-by: default avatarRaju Lakkaraju <Raju.Lakkaraju@microchip.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20240725071125.13960-1-Raju.Lakkaraju@microchip.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0aa3ca95
...@@ -1389,6 +1389,8 @@ static int ksz9131_config_init(struct phy_device *phydev) ...@@ -1389,6 +1389,8 @@ static int ksz9131_config_init(struct phy_device *phydev)
const struct device *dev_walker; const struct device *dev_walker;
int ret; int ret;
phydev->mdix_ctrl = ETH_TP_MDI_AUTO;
dev_walker = &phydev->mdio.dev; dev_walker = &phydev->mdio.dev;
do { do {
of_node = dev_walker->of_node; of_node = dev_walker->of_node;
...@@ -1438,28 +1440,30 @@ static int ksz9131_config_init(struct phy_device *phydev) ...@@ -1438,28 +1440,30 @@ static int ksz9131_config_init(struct phy_device *phydev)
#define MII_KSZ9131_AUTO_MDIX 0x1C #define MII_KSZ9131_AUTO_MDIX 0x1C
#define MII_KSZ9131_AUTO_MDI_SET BIT(7) #define MII_KSZ9131_AUTO_MDI_SET BIT(7)
#define MII_KSZ9131_AUTO_MDIX_SWAP_OFF BIT(6) #define MII_KSZ9131_AUTO_MDIX_SWAP_OFF BIT(6)
#define MII_KSZ9131_DIG_AXAN_STS 0x14
#define MII_KSZ9131_DIG_AXAN_STS_LINK_DET BIT(14)
#define MII_KSZ9131_DIG_AXAN_STS_A_SELECT BIT(12)
static int ksz9131_mdix_update(struct phy_device *phydev) static int ksz9131_mdix_update(struct phy_device *phydev)
{ {
int ret; int ret;
ret = phy_read(phydev, MII_KSZ9131_AUTO_MDIX); if (phydev->mdix_ctrl != ETH_TP_MDI_AUTO) {
if (ret < 0) phydev->mdix = phydev->mdix_ctrl;
return ret;
if (ret & MII_KSZ9131_AUTO_MDIX_SWAP_OFF) {
if (ret & MII_KSZ9131_AUTO_MDI_SET)
phydev->mdix_ctrl = ETH_TP_MDI;
else
phydev->mdix_ctrl = ETH_TP_MDI_X;
} else { } else {
phydev->mdix_ctrl = ETH_TP_MDI_AUTO; ret = phy_read(phydev, MII_KSZ9131_DIG_AXAN_STS);
} if (ret < 0)
return ret;
if (ret & MII_KSZ9131_AUTO_MDI_SET) if (ret & MII_KSZ9131_DIG_AXAN_STS_LINK_DET) {
phydev->mdix = ETH_TP_MDI; if (ret & MII_KSZ9131_DIG_AXAN_STS_A_SELECT)
else phydev->mdix = ETH_TP_MDI;
phydev->mdix = ETH_TP_MDI_X; else
phydev->mdix = ETH_TP_MDI_X;
} else {
phydev->mdix = ETH_TP_MDI_INVALID;
}
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment