Skip to content

Commit 0c49baf

Browse files
hkallweitkuba-moo
authored andcommitted
r8169: add helper rtl8125_phy_param
The integrated PHY's of RTL8125/8126 have an own mechanism to access PHY parameters, similar to what r8168g_phy_param does on earlier PHY versions. Add helper rtl8125_phy_param to simplify the code. Signed-off-by: Heiner Kallweit <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8c40d99 commit 0c49baf

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

drivers/net/ethernet/realtek/r8169_phy_config.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ static void r8168g_phy_param(struct phy_device *phydev, u16 parm,
5050
phy_restore_page(phydev, oldpage, 0);
5151
}
5252

53+
static void rtl8125_phy_param(struct phy_device *phydev, u16 parm,
54+
u16 mask, u16 val)
55+
{
56+
phy_lock_mdio_bus(phydev);
57+
__phy_write_mmd(phydev, MDIO_MMD_VEND2, 0xb87c, parm);
58+
__phy_modify_mmd(phydev, MDIO_MMD_VEND2, 0xb87e, mask, val);
59+
phy_unlock_mdio_bus(phydev);
60+
}
61+
5362
struct phy_reg {
5463
u16 reg;
5564
u16 val;
@@ -1004,12 +1013,8 @@ static void rtl8125a_2_hw_phy_config(struct rtl8169_private *tp,
10041013
phy_write_paged(phydev, 0xac5, 0x16, 0x01ff);
10051014
phy_modify_paged(phydev, 0xac8, 0x15, 0x00f0, 0x0030);
10061015

1007-
phy_write(phydev, 0x1f, 0x0b87);
1008-
phy_write(phydev, 0x16, 0x80a2);
1009-
phy_write(phydev, 0x17, 0x0153);
1010-
phy_write(phydev, 0x16, 0x809c);
1011-
phy_write(phydev, 0x17, 0x0153);
1012-
phy_write(phydev, 0x1f, 0x0000);
1016+
rtl8125_phy_param(phydev, 0x80a2, 0xffff, 0x0153);
1017+
rtl8125_phy_param(phydev, 0x809c, 0xffff, 0x0153);
10131018

10141019
phy_write(phydev, 0x1f, 0x0a43);
10151020
phy_write(phydev, 0x13, 0x81B3);
@@ -1061,14 +1066,9 @@ static void rtl8125b_hw_phy_config(struct rtl8169_private *tp,
10611066
phy_modify_paged(phydev, 0xac4, 0x13, 0x00f0, 0x0090);
10621067
phy_modify_paged(phydev, 0xad3, 0x10, 0x0003, 0x0001);
10631068

1064-
phy_write(phydev, 0x1f, 0x0b87);
1065-
phy_write(phydev, 0x16, 0x80f5);
1066-
phy_write(phydev, 0x17, 0x760e);
1067-
phy_write(phydev, 0x16, 0x8107);
1068-
phy_write(phydev, 0x17, 0x360e);
1069-
phy_write(phydev, 0x16, 0x8551);
1070-
phy_modify(phydev, 0x17, 0xff00, 0x0800);
1071-
phy_write(phydev, 0x1f, 0x0000);
1069+
rtl8125_phy_param(phydev, 0x80f5, 0xffff, 0x760e);
1070+
rtl8125_phy_param(phydev, 0x8107, 0xffff, 0x360e);
1071+
rtl8125_phy_param(phydev, 0x8551, 0xff00, 0x0800);
10721072

10731073
phy_modify_paged(phydev, 0xbf0, 0x10, 0xe000, 0xa000);
10741074
phy_modify_paged(phydev, 0xbf4, 0x13, 0x0f00, 0x0300);
@@ -1110,12 +1110,8 @@ static void rtl8125bp_hw_phy_config(struct rtl8169_private *tp,
11101110

11111111
r8168g_phy_param(phydev, 0x8010, 0x0800, 0x0000);
11121112

1113-
phy_write(phydev, 0x1f, 0x0b87);
1114-
phy_write(phydev, 0x16, 0x8088);
1115-
phy_modify(phydev, 0x17, 0xff00, 0x9000);
1116-
phy_write(phydev, 0x16, 0x808f);
1117-
phy_modify(phydev, 0x17, 0xff00, 0x9000);
1118-
phy_write(phydev, 0x1f, 0x0000);
1113+
rtl8125_phy_param(phydev, 0x8088, 0xff00, 0x9000);
1114+
rtl8125_phy_param(phydev, 0x808f, 0xff00, 0x9000);
11191115

11201116
r8168g_phy_param(phydev, 0x8174, 0x2000, 0x1800);
11211117

0 commit comments

Comments
 (0)