b50e133a670182c1aebd10d4160b43f99d318b89
[openwrt/staging/wigyori.git] /
1 From a6ad589c1d118f9d5b1bc4c6888d42919f830340 Mon Sep 17 00:00:00 2001
2 From: Heiner Kallweit <hkallweit1@gmail.com>
3 Date: Mon, 7 Oct 2024 11:57:41 +0200
4 Subject: [PATCH] net: phy: realtek: Fix MMD access on RTL8126A-integrated PHY
5
6 All MMD reads return 0 for the RTL8126A-integrated PHY. Therefore phylib
7 assumes it doesn't support EEE, what results in higher power consumption,
8 and a significantly higher chip temperature in my case.
9 To fix this split out the PHY driver for the RTL8126A-integrated PHY
10 and set the read_mmd/write_mmd callbacks to read from vendor-specific
11 registers.
12
13 Fixes: 5befa3728b85 ("net: phy: realtek: add support for RTL8126A-integrated 5Gbps PHY")
14 Cc: stable@vger.kernel.org
15 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 ---
18 drivers/net/phy/realtek.c | 24 +++++++++++++++++++++++-
19 1 file changed, 23 insertions(+), 1 deletion(-)
20
21 --- a/drivers/net/phy/realtek.c
22 +++ b/drivers/net/phy/realtek.c
23 @@ -1081,6 +1081,16 @@ static int rtl8221b_vn_cg_c45_match_phy_
24 return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, true);
25 }
26
27 +static int rtl8251b_c22_match_phy_device(struct phy_device *phydev)
28 +{
29 + return rtlgen_is_c45_match(phydev, RTL_8251B, false);
30 +}
31 +
32 +static int rtl8251b_c45_match_phy_device(struct phy_device *phydev)
33 +{
34 + return rtlgen_is_c45_match(phydev, RTL_8251B, true);
35 +}
36 +
37 static int rtlgen_resume(struct phy_device *phydev)
38 {
39 int ret = genphy_resume(phydev);
40 @@ -1418,7 +1428,7 @@ static struct phy_driver realtek_drvs[]
41 .suspend = genphy_c45_pma_suspend,
42 .resume = rtlgen_c45_resume,
43 }, {
44 - PHY_ID_MATCH_EXACT(0x001cc862),
45 + .match_phy_device = rtl8251b_c45_match_phy_device,
46 .name = "RTL8251B 5Gbps PHY",
47 .get_features = rtl822x_get_features,
48 .config_aneg = rtl822x_config_aneg,
49 @@ -1428,6 +1438,18 @@ static struct phy_driver realtek_drvs[]
50 .read_page = rtl821x_read_page,
51 .write_page = rtl821x_write_page,
52 }, {
53 + .match_phy_device = rtl8251b_c22_match_phy_device,
54 + .name = "RTL8126A-internal 5Gbps PHY",
55 + .get_features = rtl822x_get_features,
56 + .config_aneg = rtl822x_config_aneg,
57 + .read_status = rtl822x_read_status,
58 + .suspend = genphy_suspend,
59 + .resume = rtlgen_resume,
60 + .read_page = rtl821x_read_page,
61 + .write_page = rtl821x_write_page,
62 + .read_mmd = rtl822x_read_mmd,
63 + .write_mmd = rtl822x_write_mmd,
64 + }, {
65 PHY_ID_MATCH_EXACT(0x001ccad0),
66 .name = "RTL8224 2.5Gbps PHY",
67 .get_features = rtl822x_c45_get_features,