Skip to content

Commit

Permalink
net: phy: hook up clause 45 autonegotiation restart
Browse files Browse the repository at this point in the history
genphy_restart_aneg() can only restart autonegotiation on clause 22
PHYs.  Add a phy_restart_aneg() function which selects between the
clause 22 and clause 45 restart functionality depending on the PHY
type and whether the Clause 45 PHY supports the Clause 22 register set.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Russell King authored and David S. Miller committed Jun 7, 2017
1 parent 41408ad commit 002ba70
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 21 additions & 2 deletions drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@ static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
return 0;
}

/**
* phy_restart_aneg - restart auto-negotiation
* @phydev: target phy_device struct
*
* Restart the autonegotiation on @phydev. Returns >= 0 on success or
* negative errno on error.
*/
int phy_restart_aneg(struct phy_device *phydev)
{
int ret;

if (phydev->is_c45 && !(phydev->c45_ids.devices_in_package & BIT(0)))
ret = genphy_c45_restart_aneg(phydev);
else
ret = genphy_restart_aneg(phydev);

return ret;
}
EXPORT_SYMBOL_GPL(phy_restart_aneg);

/**
* phy_aneg_done - return auto-negotiation status
Expand Down Expand Up @@ -1397,7 +1416,7 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
/* Restart autonegotiation so the new modes get sent to the
* link partner.
*/
ret = genphy_restart_aneg(phydev);
ret = phy_restart_aneg(phydev);
if (ret < 0)
return ret;
}
Expand Down Expand Up @@ -1456,6 +1475,6 @@ int phy_ethtool_nway_reset(struct net_device *ndev)
if (!phydev->drv)
return -EIO;

return genphy_restart_aneg(phydev);
return phy_restart_aneg(phydev);
}
EXPORT_SYMBOL(phy_ethtool_nway_reset);
1 change: 1 addition & 0 deletions include/linux/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ int phy_start_aneg(struct phy_device *phydev);
int phy_aneg_done(struct phy_device *phydev);

int phy_stop_interrupts(struct phy_device *phydev);
int phy_restart_aneg(struct phy_device *phydev);

static inline int phy_read_status(struct phy_device *phydev)
{
Expand Down

0 comments on commit 002ba70

Please sign in to comment.