diff mbox series

[v2,net-next,3/3] net: phy: realtek: switch from paged to MMD ops in rtl822x functions

Message ID 81416f95-0fac-4225-87b4-828e3738b8ed@gmail.com (mailing list archive)
State Accepted
Commit 02d3b306ac2f0b174753d1c5b9e4e5fb8ec5057e
Delegated to: Netdev Maintainers
Headers show
Series net: phy: realtek: improve MMD register access for internal PHY's | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 29 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-02-14--18-00 (tests: 889)

Commit Message

Heiner Kallweit Feb. 13, 2025, 7:19 p.m. UTC
The MDIO bus provided by r8169 for the internal PHY's now supports
c45 ops for the MDIO_MMD_VEND2 device. So we can switch to standard
MMD ops here.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/realtek/realtek_main.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Andrew Lunn Feb. 14, 2025, 3:46 p.m. UTC | #1
On Thu, Feb 13, 2025 at 08:19:14PM +0100, Heiner Kallweit wrote:
> The MDIO bus provided by r8169 for the internal PHY's now supports
> c45 ops for the MDIO_MMD_VEND2 device. So we can switch to standard
> MMD ops here.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>  {
>  	int val;
>  
> -	val = phy_read_paged(phydev, 0xa61, 0x13);
> +	val = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0xa616);

It is nice to see some magic numbers gone. Maybe as a followup add
#defines for these registers? Are they standard registers, just in odd
places? So you could base there name on the standard register name,
but with a vendor prefix?

Thanks
	Andrew
Heiner Kallweit Feb. 14, 2025, 5:48 p.m. UTC | #2
On 14.02.2025 16:46, Andrew Lunn wrote:
> On Thu, Feb 13, 2025 at 08:19:14PM +0100, Heiner Kallweit wrote:
>> The MDIO bus provided by r8169 for the internal PHY's now supports
>> c45 ops for the MDIO_MMD_VEND2 device. So we can switch to standard
>> MMD ops here.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>>  {
>>  	int val;
>>  
>> -	val = phy_read_paged(phydev, 0xa61, 0x13);
>> +	val = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0xa616);
> 
> It is nice to see some magic numbers gone. Maybe as a followup add
> #defines for these registers? Are they standard registers, just in odd
> places? So you could base there name on the standard register name,
> but with a vendor prefix?
> 

Most of the registers are standard registers which are shadowed in
VEND2 device. E.g. 0xa616 is 45.2.1.4 (PMA/PMD speed ability).
So yes, it would make sense to add defines based on the standard
register name.


> Thanks
> 	Andrew
> 
Heiner
diff mbox series

Patch

diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
index 2e2c5353c..34be1d752 100644
--- a/drivers/net/phy/realtek/realtek_main.c
+++ b/drivers/net/phy/realtek/realtek_main.c
@@ -901,7 +901,7 @@  static int rtl822x_get_features(struct phy_device *phydev)
 {
 	int val;
 
-	val = phy_read_paged(phydev, 0xa61, 0x13);
+	val = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0xa616);
 	if (val < 0)
 		return val;
 
@@ -922,10 +922,9 @@  static int rtl822x_config_aneg(struct phy_device *phydev)
 	if (phydev->autoneg == AUTONEG_ENABLE) {
 		u16 adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising);
 
-		ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12,
-					       MDIO_AN_10GBT_CTRL_ADV2_5G |
-					       MDIO_AN_10GBT_CTRL_ADV5G,
-					       adv);
+		ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, 0xa5d4,
+					     MDIO_AN_10GBT_CTRL_ADV2_5G |
+					     MDIO_AN_10GBT_CTRL_ADV5G, adv);
 		if (ret < 0)
 			return ret;
 	}
@@ -969,7 +968,7 @@  static int rtl822x_read_status(struct phy_device *phydev)
 	    !phydev->autoneg_complete)
 		return 0;
 
-	lpadv = phy_read_paged(phydev, 0xa5d, 0x13);
+	lpadv = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0xa5d6);
 	if (lpadv < 0)
 		return lpadv;