2024-01-03 11:57:28 +00:00
|
|
|
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
|
2024-08-19 16:30:59 +00:00
|
|
|
@@ -82,6 +82,10 @@
|
2024-06-24 17:22:51 +00:00
|
|
|
|
|
|
|
#define RTL822X_VND2_PHYSR 0xa434
|
2024-01-03 11:57:28 +00:00
|
|
|
|
|
|
|
+#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)
|
|
|
|
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1102,6 +1106,25 @@ static int rtl8221b_vn_cg_c45_match_phy_
|
2024-06-24 17:22:51 +00:00
|
|
|
return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, true);
|
2024-01-03 11:57:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+static int rtl822x_probe(struct phy_device *phydev)
|
|
|
|
+{
|
|
|
|
+ struct device *dev = &phydev->mdio.dev;
|
|
|
|
+ int val;
|
|
|
|
+
|
2024-06-24 17:22:51 +00:00
|
|
|
+ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL8221B_PHYCR1);
|
2024-01-03 11:57:28 +00:00
|
|
|
+ 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);
|
|
|
|
+
|
2024-06-24 17:22:51 +00:00
|
|
|
+ phy_write_mmd(phydev, MDIO_MMD_VEND1, RTL8221B_PHYCR1, val);
|
2024-01-03 11:57:28 +00:00
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static int rtlgen_resume(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
int ret = genphy_resume(phydev);
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1377,6 +1400,7 @@ static struct phy_driver realtek_drvs[]
|
2024-06-24 17:22:51 +00:00
|
|
|
}, {
|
|
|
|
PHY_ID_MATCH_EXACT(0x001cc838),
|
2024-01-03 11:57:28 +00:00
|
|
|
.name = "RTL8226-CG 2.5Gbps PHY",
|
2024-06-24 17:22:51 +00:00
|
|
|
+ .probe = rtl822x_probe,
|
|
|
|
.soft_reset = genphy_soft_reset,
|
2024-01-03 11:57:28 +00:00
|
|
|
.get_features = rtl822x_get_features,
|
|
|
|
.config_aneg = rtl822x_config_aneg,
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1388,6 +1412,7 @@ static struct phy_driver realtek_drvs[]
|
2024-06-24 17:22:51 +00:00
|
|
|
}, {
|
|
|
|
PHY_ID_MATCH_EXACT(0x001cc848),
|
2024-01-03 11:57:28 +00:00
|
|
|
.name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY",
|
2024-06-24 17:22:51 +00:00
|
|
|
+ .probe = rtl822x_probe,
|
|
|
|
.soft_reset = genphy_soft_reset,
|
2024-01-03 11:57:28 +00:00
|
|
|
.get_features = rtl822x_get_features,
|
|
|
|
.config_aneg = rtl822x_config_aneg,
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1401,6 +1426,7 @@ static struct phy_driver realtek_drvs[]
|
2024-06-24 17:22:51 +00:00
|
|
|
}, {
|
|
|
|
.match_phy_device = rtl8221b_vb_cg_c22_match_phy_device,
|
|
|
|
.name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)",
|
2024-01-03 11:57:28 +00:00
|
|
|
+ .probe = rtl822x_probe,
|
2024-06-24 17:22:51 +00:00
|
|
|
.soft_reset = genphy_soft_reset,
|
2024-01-03 11:57:28 +00:00
|
|
|
.get_features = rtl822x_get_features,
|
|
|
|
.config_aneg = rtl822x_config_aneg,
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1414,6 +1440,7 @@ static struct phy_driver realtek_drvs[]
|
2024-06-24 17:22:51 +00:00
|
|
|
}, {
|
|
|
|
.match_phy_device = rtl8221b_vb_cg_c45_match_phy_device,
|
|
|
|
.name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)",
|
|
|
|
+ .probe = rtl822x_probe,
|
|
|
|
.soft_reset = genphy_soft_reset,
|
|
|
|
.config_init = rtl822xb_config_init,
|
|
|
|
.get_rate_matching = rtl822xb_get_rate_matching,
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1425,6 +1452,7 @@ static struct phy_driver realtek_drvs[]
|
2024-06-24 17:22:51 +00:00
|
|
|
}, {
|
|
|
|
.match_phy_device = rtl8221b_vn_cg_c22_match_phy_device,
|
|
|
|
.name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)",
|
2024-01-03 11:57:28 +00:00
|
|
|
+ .probe = rtl822x_probe,
|
2024-06-24 17:22:51 +00:00
|
|
|
.soft_reset = genphy_soft_reset,
|
2024-01-03 11:57:28 +00:00
|
|
|
.get_features = rtl822x_get_features,
|
|
|
|
.config_aneg = rtl822x_config_aneg,
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1438,6 +1466,7 @@ static struct phy_driver realtek_drvs[]
|
2024-06-24 17:22:51 +00:00
|
|
|
}, {
|
|
|
|
.match_phy_device = rtl8221b_vn_cg_c45_match_phy_device,
|
|
|
|
.name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)",
|
2024-01-03 11:57:28 +00:00
|
|
|
+ .probe = rtl822x_probe,
|
2024-06-24 17:22:51 +00:00
|
|
|
.soft_reset = genphy_soft_reset,
|
|
|
|
.config_init = rtl822xb_config_init,
|
|
|
|
.get_rate_matching = rtl822xb_get_rate_matching,
|