Skip to contentSkip to conversation

net: phy: realtek: add helper RTL822X_VND2_C22_REG

PATCH In review Heiner Kallweit 4 participants 6 messages Feb 14, 2025 – Feb 20, 2025

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 net: phy: realtek: add helper RTL822X_VND2_C22_REG

C22 register space is mapped to 0xa400 in MMD VEND2 register space. Add a helper to access mapped C22 registers.

---
 drivers/net/phy/realtek/realtek_main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/phy/realtek/realtek_main.c +4 -5
index e137e9942..566261f42 100644
@@ -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 {
Signature · 1 line
2.48.1
maintainer
#2 lore raw
In reply to Heiner Kallweit

drivers/net/phy/realtek/realtek_main.c line 82

Quoted 2 lines · On Fri, 14 Feb 2025 21:31:14 +0100 Heiner Kallweit wrote:
drivers/net/phy/realtek/realtek_main.c +1 -1
-#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?

author maintainer
#3 lore raw
Quoted 5 lines · Jakub Kicinski

drivers/net/phy/realtek/realtek_main.c line 82

Quoted 2 lines · On Fri, 14 Feb 2025 21:31:14 +0100 Heiner Kallweit wrote:
drivers/net/phy/realtek/realtek_main.c +1 -1
-#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.

maintainer
#4 lore raw
Quoted 10 lines · On Tue, 18 Feb 2025 07:33:32 +0100 Heiner Kallweit wrote:
Quoted 5 lines · Jakub Kicinski

drivers/net/phy/realtek/realtek_main.c line 82

Quoted 2 lines · On Fri, 14 Feb 2025 21:31:14 +0100 Heiner Kallweit wrote:
drivers/net/phy/realtek/realtek_main.c +1 -1
-#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.