Subject: Re: [PATCH v3 08/13] net: phy: add qca8081 config_aneg

From: Andrew Lunn <[email-masked]>
Date: Mon, 18 Oct 2021 23:37:52 +0200

On Mon, Oct 18, 2021 at 11:33:28AM +0800, Luo Jie wrote:
> Reuse at803x phy driver config_aneg excepting
> adding 2500M auto-negotiation.
> 
> Signed-off-by: Luo Jie <[email-masked]>
> ---
>  drivers/net/phy/at803x.c | 26 +++++++++++++++++++++++++-
>  1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index 0c22ef735230..c124d3fe40fb 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -1084,7 +1084,30 @@ static int at803x_config_aneg(struct phy_device *phydev)
>  			return ret;
>  	}
>  
> -	return genphy_config_aneg(phydev);
> +	/* Do not restart auto-negotiation by setting ret to 0 defautly,
> +	 * when calling __genphy_config_aneg later.
> +	 */
> +	ret = 0;
> +
> +	if (phydev->drv->phy_id == QCA8081_PHY_ID) {
> +		int phy_ctrl = 0;
> +
> +		/* The reg MII_BMCR also needs to be configured for force mode, the
> +		 * genphy_config_aneg is also needed.
> +		 */
> +		if (phydev->autoneg == AUTONEG_DISABLE)
> +			genphy_c45_pma_setup_forced(phydev);
> +
> +		if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising))
> +			phy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G;
> +
> +		ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
> +				MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl);

Does the PHY also have MDIO_MMD_AN, MDIO_AN_ADVERTISE ? I'm wondering
if you can use genphy_c45_an_config_aneg()

   Andrew