mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 15:02:32 +00:00
6d33afd2b6
The previous attempt to replace an open coded paged read in the RealTek
Ethernet PHY driver was too naive and resulted in breaking the r8169
PCIe Ethernet driver which also makes use of the RealTek Ethernet PHY
driver.
Fix this by instead of using the (not yet populated) paged operations
rather use rtl821x_write_page and protect the whole paged read operation
using the MDIO bus mutex.
Fixes: 998b973157
("kernel: net: phy: realtek: improve RealTek 2.5G PHY driver")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
101 lines
3.5 KiB
Diff
101 lines
3.5 KiB
Diff
From 9155098547fb1172d4fa536f3f6bc9d42f59d08c Mon Sep 17 00:00:00 2001
|
|
From: Daniel Golle <daniel@makrotopia.org>
|
|
Date: Sat, 22 Apr 2023 03:26:01 +0100
|
|
Subject: [PATCH] net: phy: realtek: setup ALDPS on RTL822x
|
|
|
|
Setup Link Down Power Saving Mode according the DTS property
|
|
just like for RTL821x 1GE PHYs.
|
|
|
|
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
---
|
|
drivers/net/phy/realtek.c | 11 +++++++++++
|
|
1 file changed, 11 insertions(+)
|
|
|
|
--- a/drivers/net/phy/realtek.c
|
|
+++ b/drivers/net/phy/realtek.c
|
|
@@ -62,6 +62,10 @@
|
|
#define RTL8221B_SERDES_OPTION_MODE_2500BASEX 2
|
|
#define RTL8221B_SERDES_OPTION_MODE_HISGMII 3
|
|
|
|
+#define RTL8221B_PHYCR1 0xa430
|
|
+#define RTL8221B_PHYCR1_ALDPS_EN BIT(2)
|
|
+#define RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN BIT(12)
|
|
+
|
|
#define RTL8366RB_POWER_SAVE 0x15
|
|
#define RTL8366RB_POWER_SAVE_ON BIT(12)
|
|
|
|
@@ -740,6 +744,25 @@ static int rtl8226_match_phy_device(stru
|
|
rtlgen_supports_2_5gbps(phydev);
|
|
}
|
|
|
|
+static int rtl822x_probe(struct phy_device *phydev)
|
|
+{
|
|
+ struct device *dev = &phydev->mdio.dev;
|
|
+ int val;
|
|
+
|
|
+ val = phy_read_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, RTL8221B_PHYCR1);
|
|
+ if (val < 0)
|
|
+ return val;
|
|
+
|
|
+ if (of_property_read_bool(dev->of_node, "realtek,aldps-enable"))
|
|
+ val |= RTL8221B_PHYCR1_ALDPS_EN | RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN;
|
|
+ else
|
|
+ val &= ~(RTL8221B_PHYCR1_ALDPS_EN | RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN);
|
|
+
|
|
+ phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, RTL8221B_PHYCR1, val);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static int rtlgen_resume(struct phy_device *phydev)
|
|
{
|
|
int ret = genphy_resume(phydev);
|
|
@@ -1013,6 +1036,7 @@ static struct phy_driver realtek_drvs[]
|
|
.match_phy_device = rtl8226_match_phy_device,
|
|
.get_features = rtl822x_get_features,
|
|
.config_aneg = rtl822x_config_aneg,
|
|
+ .probe = rtl822x_probe,
|
|
.read_status = rtl822x_read_status,
|
|
.suspend = genphy_suspend,
|
|
.resume = rtlgen_resume,
|
|
@@ -1026,6 +1050,7 @@ static struct phy_driver realtek_drvs[]
|
|
.name = "RTL8226B_RTL8221B 2.5Gbps PHY",
|
|
.get_features = rtl822x_get_features,
|
|
.config_aneg = rtl822x_config_aneg,
|
|
+ .probe = rtl822x_probe,
|
|
.read_status = rtl822x_read_status,
|
|
.suspend = genphy_suspend,
|
|
.resume = rtlgen_resume,
|
|
@@ -1039,6 +1064,7 @@ static struct phy_driver realtek_drvs[]
|
|
.name = "RTL8226-CG 2.5Gbps PHY",
|
|
.get_features = rtl822x_get_features,
|
|
.config_aneg = rtl822x_config_aneg,
|
|
+ .probe = rtl822x_probe,
|
|
.read_status = rtl822x_read_status,
|
|
.suspend = genphy_suspend,
|
|
.resume = rtlgen_resume,
|
|
@@ -1050,6 +1076,7 @@ static struct phy_driver realtek_drvs[]
|
|
.name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY",
|
|
.get_features = rtl822x_get_features,
|
|
.config_aneg = rtl822x_config_aneg,
|
|
+ .probe = rtl822x_probe,
|
|
.read_status = rtl822x_read_status,
|
|
.suspend = genphy_suspend,
|
|
.resume = rtlgen_resume,
|
|
@@ -1062,6 +1089,7 @@ static struct phy_driver realtek_drvs[]
|
|
.get_features = rtl822x_get_features,
|
|
.config_init = rtl8221b_config_init,
|
|
.config_aneg = rtl822x_config_aneg,
|
|
+ .probe = rtl822x_probe,
|
|
.read_status = rtl822x_read_status,
|
|
.suspend = genphy_suspend,
|
|
.resume = rtlgen_resume,
|
|
@@ -1074,6 +1102,7 @@ static struct phy_driver realtek_drvs[]
|
|
.get_features = rtl822x_get_features,
|
|
.config_aneg = rtl822x_config_aneg,
|
|
.config_init = rtl8221b_config_init,
|
|
+ .probe = rtl822x_probe,
|
|
.read_status = rtl822x_read_status,
|
|
.suspend = genphy_suspend,
|
|
.resume = rtlgen_resume,
|