diff mbox series

[net-next] net: phy: realtek: add helper RTL822X_VND2_C22_REG

Message ID 6344277b-c5c7-449b-ac89-d5425306ca76@gmail.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: phy: realtek: add helper RTL822X_VND2_C22_REG | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
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: 0 this patch: 0
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, 27 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-15--03-00 (tests: 891)

Commit Message

Heiner Kallweit Feb. 14, 2025, 8:31 p.m. UTC
C22 register space is mapped to 0xa400 in MMD VEND2 register space.
Add a helper to access mapped C22 registers.

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

Comments

Andrew Lunn Feb. 16, 2025, 4:10 p.m. UTC | #1
On Fri, Feb 14, 2025 at 09:31:14PM +0100, Heiner Kallweit wrote:
> C22 register space is mapped to 0xa400 in MMD VEND2 register space.
> Add a helper to access mapped C22 registers.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Jakub Kicinski Feb. 18, 2025, 12:44 a.m. UTC | #2
On Fri, 14 Feb 2025 21:31:14 +0100 Heiner Kallweit wrote:
> -#define RTL822X_VND2_GANLPAR				0xa414
> +#define	RTL822X_VND2_C22_REG(reg)		(0xa400 + 2 * (reg))

Just to double check - is the tab between define and RTL intentional?
Heiner Kallweit Feb. 18, 2025, 6:33 a.m. UTC | #3
On 18.02.2025 01:44, Jakub Kicinski wrote:
> On Fri, 14 Feb 2025 21:31:14 +0100 Heiner Kallweit wrote:
>> -#define RTL822X_VND2_GANLPAR				0xa414
>> +#define	RTL822X_VND2_C22_REG(reg)		(0xa400 + 2 * (reg))
> 
> Just to double check - is the tab between define and RTL intentional?

Yes. In the terminal a space or a tab after #define are the same,
not sure whether there's any preference from your side.
At least checkpatch doesn't complain.
Jakub Kicinski Feb. 18, 2025, 2:42 p.m. UTC | #4
On Tue, 18 Feb 2025 07:33:32 +0100 Heiner Kallweit wrote:
> On 18.02.2025 01:44, Jakub Kicinski wrote:
> > On Fri, 14 Feb 2025 21:31:14 +0100 Heiner Kallweit wrote:  
> >> -#define RTL822X_VND2_GANLPAR				0xa414
> >> +#define	RTL822X_VND2_C22_REG(reg)		(0xa400 + 2 * (reg))  
> > 
> > Just to double check - is the tab between define and RTL intentional?  
> 
> Yes. In the terminal a space or a tab after #define are the same,
> not sure whether there's any preference from your side.
> At least checkpatch doesn't complain.

Weak preference for following what the rest of the file does,
so space would be better. I'll change when applying.
diff mbox series

Patch

diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
index e137e9942..566261f42 100644
--- a/drivers/net/phy/realtek/realtek_main.c
+++ b/drivers/net/phy/realtek/realtek_main.c
@@ -79,9 +79,7 @@ 
 /* RTL822X_VND2_XXXXX registers are only accessible when phydev->is_c45
  * is set, they cannot be accessed by C45-over-C22.
  */
-#define RTL822X_VND2_GBCR				0xa412
-
-#define RTL822X_VND2_GANLPAR				0xa414
+#define	RTL822X_VND2_C22_REG(reg)		(0xa400 + 2 * (reg))
 
 #define RTL8366RB_POWER_SAVE			0x15
 #define RTL8366RB_POWER_SAVE_ON			BIT(12)
@@ -1026,7 +1024,8 @@  static int rtl822x_c45_config_aneg(struct phy_device *phydev)
 	val = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising);
 
 	/* Vendor register as C45 has no standardized support for 1000BaseT */
-	ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, RTL822X_VND2_GBCR,
+	ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2,
+				     RTL822X_VND2_C22_REG(MII_CTRL1000),
 				     ADVERTISE_1000FULL, val);
 	if (ret < 0)
 		return ret;
@@ -1043,7 +1042,7 @@  static int rtl822x_c45_read_status(struct phy_device *phydev)
 	/* Vendor register as C45 has no standardized support for 1000BaseT */
 	if (phydev->autoneg == AUTONEG_ENABLE && genphy_c45_aneg_done(phydev)) {
 		val = phy_read_mmd(phydev, MDIO_MMD_VEND2,
-				   RTL822X_VND2_GANLPAR);
+				   RTL822X_VND2_C22_REG(MII_STAT1000));
 		if (val < 0)
 			return val;
 	} else {