From nobody Wed Feb 11 03:42:01 2026 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (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 1385319A288; Fri, 9 Jan 2026 03:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767927797; cv=none; b=dGJV6zmBN/vBVlWX41By+qzexQlrY1Ips2yV7QfXAKlx3H7sRVPaM+StPBX7cR3n88GmiPxJ8uOYgY3oOGSOknWiQEQcrp6esrpbGXQJdYEO7U++698opO9PB5EbztrfCDTsYi7UFXJvqUCaawqt3XW38GDQmAmXbhBGUR2FVs0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767927797; c=relaxed/simple; bh=kO1mpmyAP2DRh5/wDZxZoieVtP2B/Fq/8rWBoXAej2A=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Kvz3/l+pU3c2Klw3YkoahlMXftEKNGdzDMOgv/+Gj6oyvxjsg3swzaXrYP8q2tOK2Nc/UO75ut9uWpqd8Tgzo+oJwi7EKzqtVZQmteoU7A2GkJIHYN2qR+IVNwZvDatdF9NEWKFRn8CPJOjCMowhVkCYfbWXGRskEF3HMzG9ZxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1ve2mN-000000005k0-0la4; Fri, 09 Jan 2026 03:03:11 +0000 Date: Fri, 9 Jan 2026 03:03:08 +0000 From: Daniel Golle To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Daniel Golle , Vladimir Oltean , Michael Klein , Aleksander Jan Bajkowski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/5] net: phy: realtek: support interrupt also for C22 variants Message-ID: <1b01a903484f441c0fc2e61f7277910b2fac7855.1767926665.git.daniel@makrotopia.org> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that access to MDIO_MMD_VEND2 works transparently also in Clause-22 mode, add interrupt support also for the C22 variants of the RTL8221B-VB-CG and RTL8221B-VM-CG. This results in the C22 and C45 driver instances now having all the same features implemented. Signed-off-by: Daniel Golle --- drivers/net/phy/realtek/realtek_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realt= ek/realtek_main.c index eb5b540ada0e5..7302b25b8908b 100644 --- a/drivers/net/phy/realtek/realtek_main.c +++ b/drivers/net/phy/realtek/realtek_main.c @@ -2275,6 +2275,8 @@ static struct phy_driver realtek_drvs[] =3D { }, { .match_phy_device =3D rtl8221b_vb_cg_c22_match_phy_device, .name =3D "RTL8221B-VB-CG 2.5Gbps PHY (C22)", + .config_intr =3D rtl8221b_config_intr, + .handle_interrupt =3D rtl8221b_handle_interrupt, .probe =3D rtl822x_probe, .get_features =3D rtl822x_get_features, .config_aneg =3D rtl822x_config_aneg, @@ -2307,6 +2309,8 @@ static struct phy_driver realtek_drvs[] =3D { }, { .match_phy_device =3D rtl8221b_vm_cg_c22_match_phy_device, .name =3D "RTL8221B-VM-CG 2.5Gbps PHY (C22)", + .config_intr =3D rtl8221b_config_intr, + .handle_interrupt =3D rtl8221b_handle_interrupt, .probe =3D rtl822x_probe, .get_features =3D rtl822x_get_features, .config_aneg =3D rtl822x_config_aneg, --=20 2.52.0 From nobody Wed Feb 11 03:42:01 2026 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (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 96EFD1E8329; Fri, 9 Jan 2026 03:03:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767927811; cv=none; b=ixSP+vwq2qcNJ9fQnRq1cgAK4MxsRhAONSjiKRB1lNSrbwCY+asg2lShIf8kCDlkV/f4CEQfZdiO71gQxiNxiKYYH1TmUuTIsUZF66awbxM/7PdaynTSMqBd1Ra9vE/2i/s/V6/md7CtfeAukUKxk+pVAV3vLJasg1o1/CZ2gQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767927811; c=relaxed/simple; bh=BFTSDRGmQm6Sxux2IEKd6bs1hUut7PYVzFZXa4mECW4=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nOqj/4UnV7p9s2mi26DQvr3VKAWkutpbw9WwJYreGGOMqRsFTG1E7zxrXdNJGz9s7ff/10s50s80JTFH8RA3VOYlLXmC29JlFh7Y5gX6Lsy5lBIRIYs+P5IRB3S5dSL5uNqrSniiKMZlMX8KeaTr44Np+e5awoDgFIobM7JvZiI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1ve2mb-000000005kQ-1vBF; Fri, 09 Jan 2026 03:03:25 +0000 Date: Fri, 9 Jan 2026 03:03:22 +0000 From: Daniel Golle To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Daniel Golle , Vladimir Oltean , Michael Klein , Aleksander Jan Bajkowski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/5] net: phy: realtek: simplify C22 reg access via MDIO_MMD_VEND2 Message-ID: <938aff8b65ea84eccdf1a2705684298ec33cc5b0.1767926665.git.daniel@makrotopia.org> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RealTek 2.5GE PHYs have all standard Clause-22 registers mapped also inside MDIO_MMD_VEND2 at offset 0xa400. This is used mainly in case the PHY is inside a copper SFP module which uses the RollBall MDIO-over-I2C method which *only* supports Clause-45. In order to support such modules, the PHY driver has previously been split into a C22-only and C45-only instances, creating quite a bit of redundancy and confusion. In preparation of reunifying the two driver instances, add support for translating MDIO_MMD_VEND2 registers 0xa400 to 0xa438 back to standard Clause-22 access in case the PHY is accessed on a Clause-22 bus. Signed-off-by: Daniel Golle --- drivers/net/phy/realtek/realtek_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realt= ek/realtek_main.c index 7302b25b8908b..886694ff995f6 100644 --- a/drivers/net/phy/realtek/realtek_main.c +++ b/drivers/net/phy/realtek/realtek_main.c @@ -143,6 +143,7 @@ =20 #define RTL822X_VND2_TO_PAGE(reg) ((reg) >> 4) #define RTL822X_VND2_TO_PAGE_REG(reg) (16 + (((reg) & GENMASK(3, 0)) >> 1= )) +#define RTL822X_VND2_TO_C22_REG(reg) (((reg) - 0xa400) / 2) #define RTL822X_VND2_C22_REG(reg) (0xa400 + 2 * (reg)) =20 #define RTL8221B_VND2_INER 0xa4d2 @@ -1264,6 +1265,11 @@ static int rtl822xb_read_mmd(struct phy_device *phyd= ev, int devnum, u16 reg) return mmd_phy_read(phydev->mdio.bus, phydev->mdio.addr, phydev->is_c45, devnum, reg); =20 + /* Simplify access to C22-registers addressed inside MDIO_MMD_VEND2 */ + if (reg >=3D RTL822X_VND2_C22_REG(0) && + reg <=3D RTL822X_VND2_C22_REG(30)) + return __phy_read(phydev, RTL822X_VND2_TO_C22_REG(reg)); + /* Use paged access for MDIO_MMD_VEND2 over Clause-22 */ page =3D RTL822X_VND2_TO_PAGE(reg); oldpage =3D __phy_read(phydev, RTL821x_PAGE_SELECT); @@ -1299,6 +1305,11 @@ static int rtl822xb_write_mmd(struct phy_device *phy= dev, int devnum, u16 reg, return mmd_phy_write(phydev->mdio.bus, phydev->mdio.addr, phydev->is_c45, devnum, reg, val); =20 + /* Simplify access to C22-registers addressed inside MDIO_MMD_VEND2 */ + if (reg >=3D RTL822X_VND2_C22_REG(0) && + reg <=3D RTL822X_VND2_C22_REG(30)) + return __phy_write(phydev, RTL822X_VND2_TO_C22_REG(reg), val); + /* Use paged access for MDIO_MMD_VEND2 over Clause-22 */ page =3D RTL822X_VND2_TO_PAGE(reg); oldpage =3D __phy_read(phydev, RTL821x_PAGE_SELECT); --=20 2.52.0 From nobody Wed Feb 11 03:42:01 2026 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (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 7659C318149; Fri, 9 Jan 2026 03:03:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767927822; cv=none; b=K721wNJueFwqTRQJtJ6jRxO5ZyRFyTxV2BcUfWwlX0CpKLr7E4Lhm+9N3iJLnHsnkuvK0gKmFyarh2txQ1bL5aHUaM8TBAP1SMn4iqktAvPjoiC3wB/oe2/Qpvo7gWbhbPSOlVPQqWsipTAx0onX02iV4BYlaQiU7oa1GNgKzNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767927822; c=relaxed/simple; bh=AgCN7syOW90clP7U8S/cgQlEmAQhvUDyxIvK7AStBss=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FU1OwFRQtM0bZ58OpqqIGR8auuEsPzJS9kLQa/hoEtI9NBvF/eBLe9MmqN1WUkq28eNpLer75uNBKBdhFsuML9+KCuLXY3elXfx0a8V8hxprUwlfEmkhGsVpaiKqRCTH0TX3eXxw8JCANkLavOkgOZqqaXxFAq/P1z6dCUjv1fA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1ve2mm-000000005l8-1FSA; Fri, 09 Jan 2026 03:03:36 +0000 Date: Fri, 9 Jan 2026 03:03:33 +0000 From: Daniel Golle To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Daniel Golle , Vladimir Oltean , Michael Klein , Aleksander Jan Bajkowski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/5] net: phy: realtek: reunify C22 and C45 drivers Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Reunify the split C22/C45 drivers for the RTL8221B-VB-CG 2.5Gbps and RTL8221B-VM-CG 2.5Gbps PHYs back into a single driver. This is possible now by using all the driver operations previously used by the C45 driver, as transparent access to all MMDs including MDIO_MMD_VEND2 is now possible also over Clause-22 MDIO. Signed-off-by: Daniel Golle --- drivers/net/phy/realtek/realtek_main.c | 72 ++++++-------------------- 1 file changed, 16 insertions(+), 56 deletions(-) diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realt= ek/realtek_main.c index 886694ff995f6..d07d60bc1ce34 100644 --- a/drivers/net/phy/realtek/realtek_main.c +++ b/drivers/net/phy/realtek/realtek_main.c @@ -1879,28 +1879,18 @@ static int rtl8221b_match_phy_device(struct phy_dev= ice *phydev, return phydev->phy_id =3D=3D RTL_8221B && rtlgen_supports_mmd(phydev); } =20 -static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev, - const struct phy_driver *phydrv) +static int rtl8221b_vb_cg_match_phy_device(struct phy_device *phydev, + const struct phy_driver *phydrv) { - return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false); + return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true) || + rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false); } =20 -static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device *phydev, - const struct phy_driver *phydrv) +static int rtl8221b_vm_cg_match_phy_device(struct phy_device *phydev, + const struct phy_driver *phydrv) { - return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true); -} - -static int rtl8221b_vm_cg_c22_match_phy_device(struct phy_device *phydev, - const struct phy_driver *phydrv) -{ - return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, false); -} - -static int rtl8221b_vm_cg_c45_match_phy_device(struct phy_device *phydev, - const struct phy_driver *phydrv) -{ - return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, true); + return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, true) || + rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, false); } =20 static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev, @@ -2284,27 +2274,8 @@ static struct phy_driver realtek_drvs[] =3D { .read_mmd =3D rtl822xb_read_mmd, .write_mmd =3D rtl822xb_write_mmd, }, { - .match_phy_device =3D rtl8221b_vb_cg_c22_match_phy_device, - .name =3D "RTL8221B-VB-CG 2.5Gbps PHY (C22)", - .config_intr =3D rtl8221b_config_intr, - .handle_interrupt =3D rtl8221b_handle_interrupt, - .probe =3D rtl822x_probe, - .get_features =3D rtl822x_get_features, - .config_aneg =3D rtl822x_config_aneg, - .config_init =3D rtl822xb_config_init, - .inband_caps =3D rtl822x_inband_caps, - .config_inband =3D rtl822x_config_inband, - .get_rate_matching =3D rtl822xb_get_rate_matching, - .read_status =3D rtl822xb_read_status, - .suspend =3D genphy_suspend, - .resume =3D rtlgen_resume, - .read_page =3D rtl821x_read_page, - .write_page =3D rtl821x_write_page, - .read_mmd =3D rtl822xb_read_mmd, - .write_mmd =3D rtl822xb_write_mmd, - }, { - .match_phy_device =3D rtl8221b_vb_cg_c45_match_phy_device, - .name =3D "RTL8221B-VB-CG 2.5Gbps PHY (C45)", + .match_phy_device =3D rtl8221b_vb_cg_match_phy_device, + .name =3D "RTL8221B-VB-CG 2.5Gbps PHY", .config_intr =3D rtl8221b_config_intr, .handle_interrupt =3D rtl8221b_handle_interrupt, .probe =3D rtl822x_probe, @@ -2317,28 +2288,13 @@ static struct phy_driver realtek_drvs[] =3D { .read_status =3D rtl822xb_c45_read_status, .suspend =3D genphy_c45_pma_suspend, .resume =3D rtlgen_c45_resume, - }, { - .match_phy_device =3D rtl8221b_vm_cg_c22_match_phy_device, - .name =3D "RTL8221B-VM-CG 2.5Gbps PHY (C22)", - .config_intr =3D rtl8221b_config_intr, - .handle_interrupt =3D rtl8221b_handle_interrupt, - .probe =3D rtl822x_probe, - .get_features =3D rtl822x_get_features, - .config_aneg =3D rtl822x_config_aneg, - .config_init =3D rtl822xb_config_init, - .inband_caps =3D rtl822x_inband_caps, - .config_inband =3D rtl822x_config_inband, - .get_rate_matching =3D rtl822xb_get_rate_matching, - .read_status =3D rtl822xb_read_status, - .suspend =3D genphy_suspend, - .resume =3D rtlgen_resume, .read_page =3D rtl821x_read_page, .write_page =3D rtl821x_write_page, .read_mmd =3D rtl822xb_read_mmd, .write_mmd =3D rtl822xb_write_mmd, }, { - .match_phy_device =3D rtl8221b_vm_cg_c45_match_phy_device, - .name =3D "RTL8221B-VM-CG 2.5Gbps PHY (C45)", + .match_phy_device =3D rtl8221b_vm_cg_match_phy_device, + .name =3D "RTL8221B-VM-CG 2.5Gbps PHY", .config_intr =3D rtl8221b_config_intr, .handle_interrupt =3D rtl8221b_handle_interrupt, .probe =3D rtl822x_probe, @@ -2351,6 +2307,10 @@ static struct phy_driver realtek_drvs[] =3D { .read_status =3D rtl822xb_c45_read_status, .suspend =3D genphy_c45_pma_suspend, .resume =3D rtlgen_c45_resume, + .read_page =3D rtl821x_read_page, + .write_page =3D rtl821x_write_page, + .read_mmd =3D rtl822xb_read_mmd, + .write_mmd =3D rtl822xb_write_mmd, }, { .match_phy_device =3D rtl8251b_c45_match_phy_device, .name =3D "RTL8251B 5Gbps PHY", --=20 2.52.0 From nobody Wed Feb 11 03:42:01 2026 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (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 037A11E8329; Fri, 9 Jan 2026 03:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767927833; cv=none; b=aSiqvi13h8ZHDcL+p0PqgNEdVFVNuNtnbCxhRZbZcUkhDkpPX3fz5uuP/SKudZ9WHZX1DxSYO7R4vOvl0tiV5xnRvCHjv8cuhwOFfWwckxEg6RxHUluTTp3SNwy1LKWOgcmKzQTMJ5ulfkPC63T6dj3TlUp3Y3tQECOQyUNsi7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767927833; c=relaxed/simple; bh=fFQh76+m+BUPRidLALObSIy1ryFNPjOKKoEZgbiNkTg=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jN8h8Ac/0hqGnJ0Z0nEf217b7ujh6uBvS7h8doESo5exnyB2RLdLNmwgKg3prjHTPU4YL3frgKH7ShMTsIIPGuvll4WUWaJC52ZycGbpiwab5G6WCu9d1T7hkKNUKGdseSBwRqDX+5f0dliEnKy9dr9BGFyiKv2yKyizHpZC/d8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1ve2mw-000000005lV-3bcD; Fri, 09 Jan 2026 03:03:46 +0000 Date: Fri, 9 Jan 2026 03:03:44 +0000 From: Daniel Golle To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Daniel Golle , Vladimir Oltean , Michael Klein , Aleksander Jan Bajkowski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/5] net: phy: realtek: demystify PHYSR register location Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Turns out that register address RTL_VND2_PHYSR (0xa434) maps to Clause-22 register MII_RESV2. Use that to get rid of yet another magic number, and rename access macros accordingly. Signed-off-by: Daniel Golle --- drivers/net/phy/realtek/realtek_main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realt= ek/realtek_main.c index d07d60bc1ce34..5712372c71f91 100644 --- a/drivers/net/phy/realtek/realtek_main.c +++ b/drivers/net/phy/realtek/realtek_main.c @@ -178,12 +178,12 @@ #define RTL9000A_GINMR 0x14 #define RTL9000A_GINMR_LINK_STATUS BIT(4) =20 -#define RTL_VND2_PHYSR 0xa434 -#define RTL_VND2_PHYSR_DUPLEX BIT(3) -#define RTL_VND2_PHYSR_SPEEDL GENMASK(5, 4) -#define RTL_VND2_PHYSR_SPEEDH GENMASK(10, 9) -#define RTL_VND2_PHYSR_MASTER BIT(11) -#define RTL_VND2_PHYSR_SPEED_MASK (RTL_VND2_PHYSR_SPEEDL | RTL_VND2_PHYSR= _SPEEDH) +#define RTL_PHYSR MII_RESV2 +#define RTL_PHYSR_DUPLEX BIT(3) +#define RTL_PHYSR_SPEEDL GENMASK(5, 4) +#define RTL_PHYSR_SPEEDH GENMASK(10, 9) +#define RTL_PHYSR_MASTER BIT(11) +#define RTL_PHYSR_SPEED_MASK (RTL_PHYSR_SPEEDL | RTL_PHYSR_SPEEDH) =20 #define RTL_MDIO_PCS_EEE_ABLE 0xa5c4 #define RTL_MDIO_AN_EEE_ADV 0xa5d0 @@ -1102,12 +1102,12 @@ static void rtlgen_decode_physr(struct phy_device *= phydev, int val) * 0: Half Duplex * 1: Full Duplex */ - if (val & RTL_VND2_PHYSR_DUPLEX) + if (val & RTL_PHYSR_DUPLEX) phydev->duplex =3D DUPLEX_FULL; else phydev->duplex =3D DUPLEX_HALF; =20 - switch (val & RTL_VND2_PHYSR_SPEED_MASK) { + switch (val & RTL_PHYSR_SPEED_MASK) { case 0x0000: phydev->speed =3D SPEED_10; break; @@ -1135,7 +1135,7 @@ static void rtlgen_decode_physr(struct phy_device *ph= ydev, int val) * 1: Master Mode */ if (phydev->speed >=3D 1000) { - if (val & RTL_VND2_PHYSR_MASTER) + if (val & RTL_PHYSR_MASTER) phydev->master_slave_state =3D MASTER_SLAVE_STATE_MASTER; else phydev->master_slave_state =3D MASTER_SLAVE_STATE_SLAVE; @@ -1155,8 +1155,7 @@ static int rtlgen_read_status(struct phy_device *phyd= ev) if (!phydev->link) return 0; =20 - val =3D phy_read_paged(phydev, RTL822X_VND2_TO_PAGE(RTL_VND2_PHYSR), - RTL822X_VND2_TO_PAGE_REG(RTL_VND2_PHYSR)); + val =3D phy_read(phydev, RTL_PHYSR); if (val < 0) return val; =20 @@ -1622,7 +1621,8 @@ static int rtl822x_c45_read_status(struct phy_device = *phydev) } =20 /* Read actual speed from vendor register. */ - val =3D phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL_VND2_PHYSR); + val =3D phy_read_mmd(phydev, MDIO_MMD_VEND2, + RTL822X_VND2_C22_REG(RTL_PHYSR)); if (val < 0) return val; =20 --=20 2.52.0 From nobody Wed Feb 11 03:42:01 2026 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (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 19BAC3064A0; Fri, 9 Jan 2026 03:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767927844; cv=none; b=pIPku4eX3BHT9GFZrG7FhKYh+anqWELkcTDRmxiOJvMxtE3k7xcqW1mTz1xiqIv9N9tXqF1TIi3Ka2R49DyucnzWop57XK6E06CW0eZp44IQS0yWUqXnysdrsdB9LYuhihp5FoH0yd73V9UUvQDP68gH24UWGtA38GYzZ+HbNe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767927844; c=relaxed/simple; bh=WzlgF0HbsNG48TpSAMxJTbYiUuyvClyfGICfhRLJfQQ=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m7FK0eIK7jUN3lsMU8seMK1dOmydv3LW5yf4JD/XBSf3Bn8OquDAT4OHZPRKW9VlG265CzMuaxkpq1w6uyOBQilnecob/zJ2whKYYjDrwq7kLJCRziuCiwdmvn2OjrE8AweCXa3stPcdqo41wS77JlbeqjgUsmHMlhFzt/u1QwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1ve2n8-000000005m1-2Aqa; Fri, 09 Jan 2026 03:03:58 +0000 Date: Fri, 9 Jan 2026 03:03:55 +0000 From: Daniel Golle To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Daniel Golle , Vladimir Oltean , Michael Klein , Aleksander Jan Bajkowski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/5] net: phy: realtek: simplify bogus paged operations Message-ID: <37d675ff02e38807edbd3940a3818478d0dd28ee.1767926665.git.daniel@makrotopia.org> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Only registers 0x10~0x17 are affected by the value in the page selection register 0x1f. Hence there is no point in using paged operations when accessing any other registers. Simplify the driver by using the normal phy_read and phy_write operations for registers which are anyway not affected by paging. Signed-off-by: Daniel Golle --- drivers/net/phy/realtek/realtek_main.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realt= ek/realtek_main.c index 5712372c71f91..e3687e4216052 100644 --- a/drivers/net/phy/realtek/realtek_main.c +++ b/drivers/net/phy/realtek/realtek_main.c @@ -67,7 +67,6 @@ #define RTL8211E_DELAY_MASK GENMASK(13, 11) =20 /* RTL8211F PHY configuration */ -#define RTL8211F_PHYCR_PAGE 0xa43 #define RTL8211F_PHYCR1 0x18 #define RTL8211F_ALDPS_PLL_OFF BIT(1) #define RTL8211F_ALDPS_ENABLE BIT(2) @@ -77,7 +76,6 @@ #define RTL8211F_CLKOUT_EN BIT(0) #define RTL8211F_PHYCR2_PHY_EEE_ENABLE BIT(5) =20 -#define RTL8211F_INSR_PAGE 0xa43 #define RTL8211F_INSR 0x1d =20 /* RTL8211F LED configuration */ @@ -332,7 +330,7 @@ static int rtl8211f_ack_interrupt(struct phy_device *ph= ydev) { int err; =20 - err =3D phy_read_paged(phydev, RTL8211F_INSR_PAGE, RTL8211F_INSR); + err =3D phy_read(phydev, RTL8211F_INSR); =20 return (err < 0) ? err : 0; } @@ -478,7 +476,7 @@ static irqreturn_t rtl8211f_handle_interrupt(struct phy= _device *phydev) { int irq_status; =20 - irq_status =3D phy_read_paged(phydev, RTL8211F_INSR_PAGE, RTL8211F_INSR); + irq_status =3D phy_read(phydev, RTL8211F_INSR); if (irq_status < 0) { phy_error(phydev); return IRQ_NONE; @@ -669,8 +667,8 @@ static int rtl8211f_config_clk_out(struct phy_device *p= hydev) RTL8211FVD_CLKOUT_REG, RTL8211FVD_CLKOUT_EN, 0); else - ret =3D phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, - RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, 0); + ret =3D phy_modify(phydev, RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, + 0); if (ret) return ret; =20 @@ -695,15 +693,14 @@ static int rtl8211f_config_aldps(struct phy_device *p= hydev) if (!priv->enable_aldps) return 0; =20 - return phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR1, - mask, mask); + return phy_modify(phydev, RTL8211F_PHYCR1, mask, mask); } =20 static int rtl8211f_config_phy_eee(struct phy_device *phydev) { /* Disable PHY-mode EEE so LPI is passed to the MAC */ - return phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR2, - RTL8211F_PHYCR2_PHY_EEE_ENABLE, 0); + return phy_modify(phydev, RTL8211F_PHYCR2, + RTL8211F_PHYCR2_PHY_EEE_ENABLE, 0); } =20 static int rtl8211f_config_init(struct phy_device *phydev) @@ -769,7 +766,7 @@ static int rtl8211f_suspend(struct phy_device *phydev) goto err; =20 /* Read the INSR to clear any pending interrupt */ - phy_read_paged(phydev, RTL8211F_INSR_PAGE, RTL8211F_INSR); + phy_read(phydev, RTL8211F_INSR); =20 /* Reset the WoL to ensure that an event is picked up. * Unless we do this, even if we receive another packet, --=20 2.52.0