Commit fd8ca894 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'net-phy-improve-generic-clause-45-aneg-configuration'



Heiner Kallweit says:

====================
net: phy: improve generic clause 45 aneg configuration

Improve generic clause 45 aneg configuration.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a41070aa 6b4cb6cb
Loading
Loading
Loading
Loading
+1 −14
Original line number Diff line number Diff line
@@ -288,20 +288,7 @@ static int mv3310_config_aneg(struct phy_device *phydev)
	if (ret > 0)
		changed = true;

	if (!changed) {
		/* Configure and restart aneg if it wasn't set before */
		ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_CTRL1);
		if (ret < 0)
			return ret;

		if (!(ret & MDIO_AN_CTRL1_ENABLE))
			changed = 1;
	}

	if (changed)
		ret = genphy_c45_restart_aneg(phydev);

	return ret;
	return genphy_c45_check_and_restart_aneg(phydev, changed);
}

static int mv3310_aneg_done(struct phy_device *phydev)
+33 −1
Original line number Diff line number Diff line
@@ -89,12 +89,14 @@ EXPORT_SYMBOL_GPL(genphy_c45_pma_setup_forced);
 */
int genphy_c45_an_config_aneg(struct phy_device *phydev)
{
	int changed = 0, ret;
	int changed, ret;
	u32 adv;

	linkmode_and(phydev->advertising, phydev->advertising,
		     phydev->supported);

	changed = genphy_config_eee_advert(phydev);

	adv = linkmode_adv_to_mii_adv_t(phydev->advertising);

	ret = phy_modify_mmd(phydev, MDIO_MMD_AN, MDIO_AN_ADVERTISE,
@@ -154,6 +156,36 @@ int genphy_c45_restart_aneg(struct phy_device *phydev)
}
EXPORT_SYMBOL_GPL(genphy_c45_restart_aneg);

/**
 * genphy_c45_check_and_restart_aneg - Enable and restart auto-negotiation
 * @phydev: target phy_device struct
 * @restart: whether aneg restart is requested
 *
 * This assumes that the auto-negotiation MMD is present.
 *
 * Check, and restart auto-negotiation if needed.
 */
int genphy_c45_check_and_restart_aneg(struct phy_device *phydev, bool restart)
{
	int ret = 0;

	if (!restart) {
		/* Configure and restart aneg if it wasn't set before */
		ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_CTRL1);
		if (ret < 0)
			return ret;

		if (!(ret & MDIO_AN_CTRL1_ENABLE))
			restart = true;
	}

	if (restart)
		ret = genphy_c45_restart_aneg(phydev);

	return ret;
}
EXPORT_SYMBOL_GPL(genphy_c45_check_and_restart_aneg);

/**
 * genphy_c45_aneg_done - return auto-negotiation complete status
 * @phydev: target phy_device struct
+2 −1
Original line number Diff line number Diff line
@@ -1575,7 +1575,7 @@ static int genphy_config_advert(struct phy_device *phydev)
 *   efficent ethernet modes. Returns 0 if the PHY's advertisement hasn't
 *   changed, and 1 if it has changed.
 */
static int genphy_config_eee_advert(struct phy_device *phydev)
int genphy_config_eee_advert(struct phy_device *phydev)
{
	int err;

@@ -1588,6 +1588,7 @@ static int genphy_config_eee_advert(struct phy_device *phydev)
	/* If the call failed, we assume that EEE is not supported */
	return err < 0 ? 0 : err;
}
EXPORT_SYMBOL(genphy_config_eee_advert);

/**
 * genphy_setup_forced - configures/forces speed/duplex from @phydev
+2 −0
Original line number Diff line number Diff line
@@ -1077,6 +1077,7 @@ void phy_attached_info(struct phy_device *phydev);
int genphy_config_init(struct phy_device *phydev);
int genphy_setup_forced(struct phy_device *phydev);
int genphy_restart_aneg(struct phy_device *phydev);
int genphy_config_eee_advert(struct phy_device *phydev);
int genphy_config_aneg(struct phy_device *phydev);
int genphy_aneg_done(struct phy_device *phydev);
int genphy_update_link(struct phy_device *phydev);
@@ -1096,6 +1097,7 @@ int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,

/* Clause 45 PHY */
int genphy_c45_restart_aneg(struct phy_device *phydev);
int genphy_c45_check_and_restart_aneg(struct phy_device *phydev, bool restart);
int genphy_c45_aneg_done(struct phy_device *phydev);
int genphy_c45_read_link(struct phy_device *phydev);
int genphy_c45_read_lpa(struct phy_device *phydev);