Skip to content

Commit

Permalink
net: phy: micrel: Fix the KSZ9131 MDI-X status issue
Browse files Browse the repository at this point in the history
Access information about Auto mdix completion and pair selection from the
KSZ9131's Auto/MDI/MDI-X status register

Fixes: b64e6a8 ("net: phy: micrel: Add PHY Auto/MDI/MDI-X set driver for KSZ9131")
Signed-off-by: Raju Lakkaraju <[email protected]>
Signed-off-by: NipaLocal <nipa@local>
  • Loading branch information
lakkarajun authored and NipaLocal committed Jul 16, 2024
1 parent 77ae5e5 commit e992e00
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions drivers/net/phy/micrel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,9 @@ static int ksz9131_config_init(struct phy_device *phydev)
#define MII_KSZ9131_AUTO_MDIX 0x1C
#define MII_KSZ9131_AUTO_MDI_SET BIT(7)
#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)
{
Expand All @@ -1452,14 +1455,24 @@ static int ksz9131_mdix_update(struct phy_device *phydev)
phydev->mdix_ctrl = ETH_TP_MDI;
else
phydev->mdix_ctrl = ETH_TP_MDI_X;

phydev->mdix = phydev->mdix_ctrl;
} else {
ret = phy_read(phydev, MII_KSZ9131_DIG_AXAN_STS);
if (ret < 0)
return ret;

phydev->mdix_ctrl = ETH_TP_MDI_AUTO;
}

if (ret & MII_KSZ9131_AUTO_MDI_SET)
phydev->mdix = ETH_TP_MDI;
else
phydev->mdix = ETH_TP_MDI_X;
if (ret & MII_KSZ9131_DIG_AXAN_STS_LINK_DET) {
if (ret & MII_KSZ9131_DIG_AXAN_STS_A_SELECT)
phydev->mdix = ETH_TP_MDI;
else
phydev->mdix = ETH_TP_MDI_X;
} else {
phydev->mdix = ETH_TP_MDI_INVALID;
}
}

return 0;
}
Expand Down

0 comments on commit e992e00

Please sign in to comment.