609ae1a0280343f416ba45c0c16a7743fbbe4cd0
[openwrt/staging/wigyori.git] /
1 From c189dbd738243be6775bb6878366bf63e27bfd05 Mon Sep 17 00:00:00 2001
2 From: Eric Woudstra <ericwouds@gmail.com>
3 Date: Tue, 9 Apr 2024 09:30:12 +0200
4 Subject: [PATCH] net: phy: realtek: add get_rate_matching() for rtl822xb PHYs
5
6 Uses vendor register to determine if SerDes is setup in rate-matching mode.
7
8 Rate-matching only supported when SerDes is set to 2500base-x.
9
10 Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
12 ---
13 drivers/net/phy/realtek.c | 25 +++++++++++++++++++++++++
14 1 file changed, 25 insertions(+)
15
16 --- a/drivers/net/phy/realtek.c
17 +++ b/drivers/net/phy/realtek.c
18 @@ -726,6 +726,27 @@ static int rtl822xb_config_init(struct p
19 return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020);
20 }
21
22 +static int rtl822xb_get_rate_matching(struct phy_device *phydev,
23 + phy_interface_t iface)
24 +{
25 + int val;
26 +
27 + /* Only rate matching at 2500base-x */
28 + if (iface != PHY_INTERFACE_MODE_2500BASEX)
29 + return RATE_MATCH_NONE;
30 +
31 + val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_OPTION);
32 + if (val < 0)
33 + return val;
34 +
35 + if ((val & RTL822X_VND1_SERDES_OPTION_MODE_MASK) ==
36 + RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX)
37 + return RATE_MATCH_PAUSE;
38 +
39 + /* RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII */
40 + return RATE_MATCH_NONE;
41 +}
42 +
43 static int rtl822x_get_features(struct phy_device *phydev)
44 {
45 int val;
46 @@ -1091,6 +1112,7 @@ static struct phy_driver realtek_drvs[]
47 .get_features = rtl822x_get_features,
48 .config_aneg = rtl822x_config_aneg,
49 .config_init = rtl822xb_config_init,
50 + .get_rate_matching = rtl822xb_get_rate_matching,
51 .read_status = rtl822xb_read_status,
52 .suspend = genphy_suspend,
53 .resume = rtlgen_resume,
54 @@ -1114,6 +1136,7 @@ static struct phy_driver realtek_drvs[]
55 .get_features = rtl822x_get_features,
56 .config_aneg = rtl822x_config_aneg,
57 .config_init = rtl822xb_config_init,
58 + .get_rate_matching = rtl822xb_get_rate_matching,
59 .read_status = rtl822xb_read_status,
60 .suspend = genphy_suspend,
61 .resume = rtlgen_resume,
62 @@ -1125,6 +1148,7 @@ static struct phy_driver realtek_drvs[]
63 .get_features = rtl822x_get_features,
64 .config_aneg = rtl822x_config_aneg,
65 .config_init = rtl822xb_config_init,
66 + .get_rate_matching = rtl822xb_get_rate_matching,
67 .read_status = rtl822xb_read_status,
68 .suspend = genphy_suspend,
69 .resume = rtlgen_resume,
70 @@ -1136,6 +1160,7 @@ static struct phy_driver realtek_drvs[]
71 .get_features = rtl822x_get_features,
72 .config_aneg = rtl822x_config_aneg,
73 .config_init = rtl822xb_config_init,
74 + .get_rate_matching = rtl822xb_get_rate_matching,
75 .read_status = rtl822xb_read_status,
76 .suspend = genphy_suspend,
77 .resume = rtlgen_resume,