Commit f4069cd7 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

net: phy: prepare phylib to deal with PHY's extending Clause 22

The integrated PHY in 2.5Gbps chip RTL8125 is the first (known to me)
PHY that uses standard Clause 22 for all modes up to 1Gbps and adds
2.5Gbps control using vendor-specific registers. To use phylib for
the standard part little extensions are needed:
- Move most of genphy_config_aneg to a new function
  __genphy_config_aneg that takes a parameter whether restarting
  auto-negotiation is needed (depending on whether content of
  vendor-specific advertisement register changed).
- Don't clear phydev->lp_advertising in genphy_read_status so that
  we can set non-C22 mode flags before.

Basically both changes mimic the behavior of the equivalent Clause 45
functions.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3eef8689
...@@ -1671,18 +1671,20 @@ int genphy_restart_aneg(struct phy_device *phydev) ...@@ -1671,18 +1671,20 @@ int genphy_restart_aneg(struct phy_device *phydev)
EXPORT_SYMBOL(genphy_restart_aneg); EXPORT_SYMBOL(genphy_restart_aneg);
/** /**
* genphy_config_aneg - restart auto-negotiation or write BMCR * __genphy_config_aneg - restart auto-negotiation or write BMCR
* @phydev: target phy_device struct * @phydev: target phy_device struct
* @changed: whether autoneg is requested
* *
* Description: If auto-negotiation is enabled, we configure the * Description: If auto-negotiation is enabled, we configure the
* advertising, and then restart auto-negotiation. If it is not * advertising, and then restart auto-negotiation. If it is not
* enabled, then we write the BMCR. * enabled, then we write the BMCR.
*/ */
int genphy_config_aneg(struct phy_device *phydev) int __genphy_config_aneg(struct phy_device *phydev, bool changed)
{ {
int err, changed; int err;
changed = genphy_config_eee_advert(phydev); if (genphy_config_eee_advert(phydev))
changed = true;
if (AUTONEG_ENABLE != phydev->autoneg) if (AUTONEG_ENABLE != phydev->autoneg)
return genphy_setup_forced(phydev); return genphy_setup_forced(phydev);
...@@ -1690,10 +1692,10 @@ int genphy_config_aneg(struct phy_device *phydev) ...@@ -1690,10 +1692,10 @@ int genphy_config_aneg(struct phy_device *phydev)
err = genphy_config_advert(phydev); err = genphy_config_advert(phydev);
if (err < 0) /* error */ if (err < 0) /* error */
return err; return err;
else if (err)
changed = true;
changed |= err; if (!changed) {
if (changed == 0) {
/* Advertisement hasn't changed, but maybe aneg was never on to /* Advertisement hasn't changed, but maybe aneg was never on to
* begin with? Or maybe phy was isolated? * begin with? Or maybe phy was isolated?
*/ */
...@@ -1703,18 +1705,15 @@ int genphy_config_aneg(struct phy_device *phydev) ...@@ -1703,18 +1705,15 @@ int genphy_config_aneg(struct phy_device *phydev)
return ctl; return ctl;
if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE)) if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE))
changed = 1; /* do restart aneg */ changed = true; /* do restart aneg */
} }
/* Only restart aneg if we are advertising something different /* Only restart aneg if we are advertising something different
* than we were before. * than we were before.
*/ */
if (changed > 0) return changed ? genphy_restart_aneg(phydev) : 0;
return genphy_restart_aneg(phydev);
return 0;
} }
EXPORT_SYMBOL(genphy_config_aneg); EXPORT_SYMBOL(__genphy_config_aneg);
/** /**
* genphy_aneg_done - return auto-negotiation status * genphy_aneg_done - return auto-negotiation status
...@@ -1801,8 +1800,6 @@ int genphy_read_status(struct phy_device *phydev) ...@@ -1801,8 +1800,6 @@ int genphy_read_status(struct phy_device *phydev)
phydev->pause = 0; phydev->pause = 0;
phydev->asym_pause = 0; phydev->asym_pause = 0;
linkmode_zero(phydev->lp_advertising);
if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) { if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) {
if (phydev->is_gigabit_capable) { if (phydev->is_gigabit_capable) {
lpagb = phy_read(phydev, MII_STAT1000); lpagb = phy_read(phydev, MII_STAT1000);
......
...@@ -1069,7 +1069,7 @@ int genphy_read_abilities(struct phy_device *phydev); ...@@ -1069,7 +1069,7 @@ int genphy_read_abilities(struct phy_device *phydev);
int genphy_setup_forced(struct phy_device *phydev); int genphy_setup_forced(struct phy_device *phydev);
int genphy_restart_aneg(struct phy_device *phydev); int genphy_restart_aneg(struct phy_device *phydev);
int genphy_config_eee_advert(struct phy_device *phydev); int genphy_config_eee_advert(struct phy_device *phydev);
int genphy_config_aneg(struct phy_device *phydev); int __genphy_config_aneg(struct phy_device *phydev, bool changed);
int genphy_aneg_done(struct phy_device *phydev); int genphy_aneg_done(struct phy_device *phydev);
int genphy_update_link(struct phy_device *phydev); int genphy_update_link(struct phy_device *phydev);
int genphy_read_status(struct phy_device *phydev); int genphy_read_status(struct phy_device *phydev);
...@@ -1077,6 +1077,12 @@ int genphy_suspend(struct phy_device *phydev); ...@@ -1077,6 +1077,12 @@ int genphy_suspend(struct phy_device *phydev);
int genphy_resume(struct phy_device *phydev); int genphy_resume(struct phy_device *phydev);
int genphy_loopback(struct phy_device *phydev, bool enable); int genphy_loopback(struct phy_device *phydev, bool enable);
int genphy_soft_reset(struct phy_device *phydev); int genphy_soft_reset(struct phy_device *phydev);
static inline int genphy_config_aneg(struct phy_device *phydev)
{
return __genphy_config_aneg(phydev, false);
}
static inline int genphy_no_soft_reset(struct phy_device *phydev) static inline int genphy_no_soft_reset(struct phy_device *phydev)
{ {
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