From patchwork Wed Dec 20 15:55:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13500303 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22A484777F for ; Wed, 20 Dec 2023 15:55:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pEK+O7c3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E6D0C433C8; Wed, 20 Dec 2023 15:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703087754; bh=uN2oOY2uytuDyvfPFC7ZMgbdRr3OXmf+hM/f9Zp1z70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pEK+O7c3IqEPGs+EapbwHmbTtm5s98EvlHC3AThMOQL4ISbIF454Igypnnql98IhD Y5Frg7YrR4l69aOipg0AB/wgz5K0C5kR9SJ0pJFI26vZ32WGBaoobMpcw+6D18SPQC L27f+F0rho1VCm9Tez/xZE/WnGwovQNnBDo6ma4TMB7KXoqafNYbo5apZeGxqFKlKz ukwxtuny+PHh/vbj2y4/UJDY7dOOFRyAT2L3PyaXSp+Ju3+aIsSyyIWEbBea0dt1Rn LHrTBi2F6Iw34iib1FYpSDE00+NpzyYW3w1XIaSD2tiiQVB8Gj6whMGVd59yp3cHKl /9nwp5t5i97Cw== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: netdev@vger.kernel.org, Andrew Lunn , "David S. Miller" , Jakub Kicinski , Paolo Abeni Cc: Russell King , Alexander Couzens , Daniel Golle , Heiner Kallweit , Willy Liu , Ioana Ciornei , =?utf-8?q?Marek_Moj=C3=ADk?= , =?utf-8?q?Maximili=C3=A1?= =?utf-8?q?n_Maliar?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH net-next 10/15] net: phy: realtek: use generic c45 AN config with 1000baseT vendor extension for rtl822x Date: Wed, 20 Dec 2023 16:55:13 +0100 Message-ID: <20231220155518.15692-11-kabel@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231220155518.15692-1-kabel@kernel.org> References: <20231220155518.15692-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Now that rtl822x PHYs .read_mmd() and .write_mmd() methods support accessing all MMD registers, use the generic clause 45 functions genphy_c45_an_config_aneg() and genphy_c45_pma_setup_forced() instead of the clause 22 for configuring autonegotiation for the rtl822x series. Because 802.3-2018 does not define MMD registers for configuring 1000baseT autonegotiation, use vendor specific MMD register for this, similar to how the marvell10g driver does it. Signed-off-by: Marek BehĂșn --- drivers/net/phy/realtek.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 0bb56d89157a..592de975248f 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -54,6 +54,8 @@ RTL8201F_ISR_LINK) #define RTL8201F_IER 0x13 +#define RTL8221_GBCR 0xa412 + #define RTL8366RB_POWER_SAVE 0x15 #define RTL8366RB_POWER_SAVE_ON BIT(12) @@ -650,23 +652,28 @@ static int rtl822x_probe(struct phy_device *phydev) static int rtl822x_config_aneg(struct phy_device *phydev) { - int ret = 0; + bool changed = false; + u16 val; + int ret; - if (phydev->autoneg == AUTONEG_ENABLE) { - u16 adv2500 = 0; + if (phydev->autoneg == AUTONEG_DISABLE) + return genphy_c45_pma_setup_forced(phydev); - if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, - phydev->advertising)) - adv2500 = MDIO_AN_10GBT_CTRL_ADV2_5G; + ret = genphy_c45_an_config_aneg(phydev); + if (ret < 0) + return ret; + if (ret > 0) + changed = true; - ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12, - MDIO_AN_10GBT_CTRL_ADV2_5G, - adv2500); - if (ret < 0) - return ret; - } + val = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); + ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, RTL8221_GBCR, + ADVERTISE_1000FULL, val); + if (ret < 0) + return ret; + if (ret > 0) + changed = true; - return __genphy_config_aneg(phydev, ret); + return genphy_c45_check_and_restart_aneg(phydev, changed); } static int rtl822x_read_status(struct phy_device *phydev)