Skip to content

Commit 0713e55

Browse files
oleremkuba-moo
authored andcommitted
net: phy: smsc: Force predictable MDI-X state on LAN87xx
Override the hardware strap configuration for MDI-X mode to ensure a predictable initial state for the driver. The initial mode of the LAN87xx PHY is determined by the AUTOMDIX_EN strap pin, but the driver has no documented way to read its latched status. This unpredictability means the driver cannot know if the PHY has initialized with Auto-MDIX enabled or disabled, preventing it from providing a reliable interface to the user. This patch introduces a `config_init` hook that forces the PHY into a known state by explicitly enabling Auto-MDIX. Fixes: 05b35e7 ("smsc95xx: add phylib support") Signed-off-by: Oleksij Rempel <[email protected]> Cc: Andre Edich <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a141af8 commit 0713e55

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

drivers/net/phy/smsc.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,33 @@ int lan87xx_read_status(struct phy_device *phydev)
262262
}
263263
EXPORT_SYMBOL_GPL(lan87xx_read_status);
264264

265+
static int lan87xx_phy_config_init(struct phy_device *phydev)
266+
{
267+
int rc;
268+
269+
/* The LAN87xx PHY's initial MDI-X mode is determined by the AUTOMDIX_EN
270+
* hardware strap, but the driver cannot read the strap's status. This
271+
* creates an unpredictable initial state.
272+
*
273+
* To ensure consistent and reliable behavior across all boards,
274+
* override the strap configuration on initialization and force the PHY
275+
* into a known state with Auto-MDIX enabled, which is the expected
276+
* default for modern hardware.
277+
*/
278+
rc = phy_modify(phydev, SPECIAL_CTRL_STS,
279+
SPECIAL_CTRL_STS_OVRRD_AMDIX_ |
280+
SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
281+
SPECIAL_CTRL_STS_AMDIX_STATE_,
282+
SPECIAL_CTRL_STS_OVRRD_AMDIX_ |
283+
SPECIAL_CTRL_STS_AMDIX_ENABLE_);
284+
if (rc < 0)
285+
return rc;
286+
287+
phydev->mdix_ctrl = ETH_TP_MDI_AUTO;
288+
289+
return smsc_phy_config_init(phydev);
290+
}
291+
265292
static int lan874x_phy_config_init(struct phy_device *phydev)
266293
{
267294
u16 val;
@@ -696,7 +723,7 @@ static struct phy_driver smsc_phy_driver[] = {
696723

697724
/* basic functions */
698725
.read_status = lan87xx_read_status,
699-
.config_init = smsc_phy_config_init,
726+
.config_init = lan87xx_phy_config_init,
700727
.soft_reset = smsc_phy_reset,
701728
.config_aneg = lan87xx_config_aneg,
702729

0 commit comments

Comments
 (0)