Commit 94acaeb5 authored by Marco Hartmann's avatar Marco Hartmann Committed by David S. Miller

Add genphy_c45_config_aneg() function to phy-c45.c

Commit 34786005 ("net: phy: prevent PHYs w/o Clause 22 regs from calling
genphy_config_aneg") introduced a check that aborts phy_config_aneg()
if the phy is a C45 phy.
This causes phy_state_machine() to call phy_error() so that the phy
ends up in PHY_HALTED state.

Instead of returning -EOPNOTSUPP, call genphy_c45_config_aneg()
(analogous to the C22 case) so that the state machine can run
correctly.

genphy_c45_config_aneg() closely resembles mv3310_config_aneg()
in drivers/net/phy/marvell10g.c, excluding vendor specific
configurations for 1000BaseT.

Fixes: 22b56e82 ("net: phy: replace genphy_10g_driver with genphy_c45_driver")
Signed-off-by: default avatarMarco Hartmann <marco.hartmann@nxp.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 981471bd
...@@ -523,6 +523,32 @@ int genphy_c45_read_status(struct phy_device *phydev) ...@@ -523,6 +523,32 @@ int genphy_c45_read_status(struct phy_device *phydev)
} }
EXPORT_SYMBOL_GPL(genphy_c45_read_status); EXPORT_SYMBOL_GPL(genphy_c45_read_status);
/**
* genphy_c45_config_aneg - restart auto-negotiation or forced setup
* @phydev: target phy_device struct
*
* Description: If auto-negotiation is enabled, we configure the
* advertising, and then restart auto-negotiation. If it is not
* enabled, then we force a configuration.
*/
int genphy_c45_config_aneg(struct phy_device *phydev)
{
bool changed = false;
int ret;
if (phydev->autoneg == AUTONEG_DISABLE)
return genphy_c45_pma_setup_forced(phydev);
ret = genphy_c45_an_config_aneg(phydev);
if (ret < 0)
return ret;
if (ret > 0)
changed = true;
return genphy_c45_check_and_restart_aneg(phydev, changed);
}
EXPORT_SYMBOL_GPL(genphy_c45_config_aneg);
/* The gen10g_* functions are the old Clause 45 stub */ /* The gen10g_* functions are the old Clause 45 stub */
int gen10g_config_aneg(struct phy_device *phydev) int gen10g_config_aneg(struct phy_device *phydev)
......
...@@ -507,7 +507,7 @@ static int phy_config_aneg(struct phy_device *phydev) ...@@ -507,7 +507,7 @@ static int phy_config_aneg(struct phy_device *phydev)
* allowed to call genphy_config_aneg() * allowed to call genphy_config_aneg()
*/ */
if (phydev->is_c45 && !(phydev->c45_ids.devices_in_package & BIT(0))) if (phydev->is_c45 && !(phydev->c45_ids.devices_in_package & BIT(0)))
return -EOPNOTSUPP; return genphy_c45_config_aneg(phydev);
return genphy_config_aneg(phydev); return genphy_config_aneg(phydev);
} }
......
...@@ -1107,6 +1107,7 @@ int genphy_c45_an_disable_aneg(struct phy_device *phydev); ...@@ -1107,6 +1107,7 @@ int genphy_c45_an_disable_aneg(struct phy_device *phydev);
int genphy_c45_read_mdix(struct phy_device *phydev); int genphy_c45_read_mdix(struct phy_device *phydev);
int genphy_c45_pma_read_abilities(struct phy_device *phydev); int genphy_c45_pma_read_abilities(struct phy_device *phydev);
int genphy_c45_read_status(struct phy_device *phydev); int genphy_c45_read_status(struct phy_device *phydev);
int genphy_c45_config_aneg(struct phy_device *phydev);
/* The gen10g_* functions are the old Clause 45 stub */ /* The gen10g_* functions are the old Clause 45 stub */
int gen10g_config_aneg(struct phy_device *phydev); int gen10g_config_aneg(struct phy_device *phydev);
......
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