Skip to content

Commit bac7b22

Browse files
committed
sys-kernel/coreos-sources: backport RTL8125D PHY ID
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
1 parent 445ed20 commit bac7b22

File tree

3 files changed

+171
-0
lines changed

3 files changed

+171
-0
lines changed

sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/coreos-sources-6.12.34.ebuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ UNIPATCH_LIST="
4444
${PATCH_DIR}/z0007-arm64-add-kernel-config-option-to-lock-down-when.patch \
4545
${PATCH_DIR}/z0008-tools-hv-fix-cross-compilation-for-ARM64.patch \
4646
${PATCH_DIR}/z0009-f75d1fbe7809bc5ed134204b920fd9e2fc5db1df.patch \
47+
${PATCH_DIR}/z0010-f87a17ed3b51fba4dfdd8f8b643b5423a85fc551.patch \
48+
${PATCH_DIR}/z0011-8989bad541133c43550bff2b80edbe37b8fb9659.patch \
4749
"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
From f87a17ed3b51fba4dfdd8f8b643b5423a85fc551 Mon Sep 17 00:00:00 2001
2+
From: Heiner Kallweit <hkallweit1@gmail.com>
3+
Date: Tue, 15 Oct 2024 07:47:14 +0200
4+
Subject: [PATCH] net: phy: realtek: merge the drivers for internal NBase-T
5+
PHY's
6+
7+
The Realtek RTL8125/RTL8126 NBase-T MAC/PHY chips have internal PHY's
8+
which are register-compatible, at least for the registers we use here.
9+
So let's use just one PHY driver to support all of them.
10+
These internal PHY's exist also as external C45 PHY's, but on the
11+
internal PHY's no access to MMD registers is possible. This can be
12+
used to differentiate between the internal and external version.
13+
14+
As a side effect the drivers for two now external-only drivers don't
15+
require read_mmd/write_mmd hooks any longer.
16+
17+
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
18+
Link: https://patch.msgid.link/c57081a6-811f-4571-ab35-34f4ca6de9af@gmail.com
19+
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
20+
---
21+
drivers/net/phy/realtek.c | 53 +++++++++++++++++++++++++++++++--------
22+
1 file changed, 43 insertions(+), 10 deletions(-)
23+
24+
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
25+
index 905038b1bb6414..66646212053173 100644
26+
--- a/drivers/net/phy/realtek.c
27+
+++ b/drivers/net/phy/realtek.c
28+
@@ -95,6 +95,7 @@
29+
30+
#define RTL_GENERIC_PHYID 0x001cc800
31+
#define RTL_8211FVD_PHYID 0x001cc878
32+
+#define RTL_8221B 0x001cc840
33+
#define RTL_8221B_VB_CG 0x001cc849
34+
#define RTL_8221B_VN_CG 0x001cc84a
35+
#define RTL_8251B 0x001cc862
36+
@@ -1077,6 +1078,23 @@ static bool rtlgen_supports_2_5gbps(struct phy_device *phydev)
37+
return val >= 0 && val & MDIO_PMA_SPEED_2_5G;
38+
}
39+
40+
+/* On internal PHY's MMD reads over C22 always return 0.
41+
+ * Check a MMD register which is known to be non-zero.
42+
+ */
43+
+static bool rtlgen_supports_mmd(struct phy_device *phydev)
44+
+{
45+
+ int val;
46+
+
47+
+ phy_lock_mdio_bus(phydev);
48+
+ __phy_write(phydev, MII_MMD_CTRL, MDIO_MMD_PCS);
49+
+ __phy_write(phydev, MII_MMD_DATA, MDIO_PCS_EEE_ABLE);
50+
+ __phy_write(phydev, MII_MMD_CTRL, MDIO_MMD_PCS | MII_MMD_CTRL_NOINCR);
51+
+ val = __phy_read(phydev, MII_MMD_DATA);
52+
+ phy_unlock_mdio_bus(phydev);
53+
+
54+
+ return val > 0;
55+
+}
56+
+
57+
static int rtlgen_match_phy_device(struct phy_device *phydev)
58+
{
59+
return phydev->phy_id == RTL_GENERIC_PHYID &&
60+
@@ -1086,7 +1104,8 @@ static int rtlgen_match_phy_device(struct phy_device *phydev)
61+
static int rtl8226_match_phy_device(struct phy_device *phydev)
62+
{
63+
return phydev->phy_id == RTL_GENERIC_PHYID &&
64+
- rtlgen_supports_2_5gbps(phydev);
65+
+ rtlgen_supports_2_5gbps(phydev) &&
66+
+ rtlgen_supports_mmd(phydev);
67+
}
68+
69+
static int rtlgen_is_c45_match(struct phy_device *phydev, unsigned int id,
70+
@@ -1098,6 +1117,11 @@ static int rtlgen_is_c45_match(struct phy_device *phydev, unsigned int id,
71+
return !is_c45 && (id == phydev->phy_id);
72+
}
73+
74+
+static int rtl8221b_match_phy_device(struct phy_device *phydev)
75+
+{
76+
+ return phydev->phy_id == RTL_8221B && rtlgen_supports_mmd(phydev);
77+
+}
78+
+
79+
static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev)
80+
{
81+
return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false);
82+
@@ -1118,9 +1142,21 @@ static int rtl8221b_vn_cg_c45_match_phy_device(struct phy_device *phydev)
83+
return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, true);
84+
}
85+
86+
-static int rtl8251b_c22_match_phy_device(struct phy_device *phydev)
87+
+static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev)
88+
{
89+
- return rtlgen_is_c45_match(phydev, RTL_8251B, false);
90+
+ if (phydev->is_c45)
91+
+ return false;
92+
+
93+
+ switch (phydev->phy_id) {
94+
+ case RTL_GENERIC_PHYID:
95+
+ case RTL_8221B:
96+
+ case RTL_8251B:
97+
+ break;
98+
+ default:
99+
+ return false;
100+
+ }
101+
+
102+
+ return rtlgen_supports_2_5gbps(phydev) && !rtlgen_supports_mmd(phydev);
103+
}
104+
105+
static int rtl8251b_c45_match_phy_device(struct phy_device *phydev)
106+
@@ -1382,10 +1418,8 @@ static struct phy_driver realtek_drvs[] = {
107+
.resume = rtlgen_resume,
108+
.read_page = rtl821x_read_page,
109+
.write_page = rtl821x_write_page,
110+
- .read_mmd = rtl822x_read_mmd,
111+
- .write_mmd = rtl822x_write_mmd,
112+
}, {
113+
- PHY_ID_MATCH_EXACT(0x001cc840),
114+
+ .match_phy_device = rtl8221b_match_phy_device,
115+
.name = "RTL8226B_RTL8221B 2.5Gbps PHY",
116+
.get_features = rtl822x_get_features,
117+
.config_aneg = rtl822x_config_aneg,
118+
@@ -1396,8 +1430,6 @@ static struct phy_driver realtek_drvs[] = {
119+
.resume = rtlgen_resume,
120+
.read_page = rtl821x_read_page,
121+
.write_page = rtl821x_write_page,
122+
- .read_mmd = rtl822x_read_mmd,
123+
- .write_mmd = rtl822x_write_mmd,
124+
}, {
125+
PHY_ID_MATCH_EXACT(0x001cc838),
126+
.name = "RTL8226-CG 2.5Gbps PHY",
127+
@@ -1475,8 +1507,9 @@ static struct phy_driver realtek_drvs[] = {
128+
.read_page = rtl821x_read_page,
129+
.write_page = rtl821x_write_page,
130+
}, {
131+
- .match_phy_device = rtl8251b_c22_match_phy_device,
132+
- .name = "RTL8126A-internal 5Gbps PHY",
133+
+ .match_phy_device = rtl_internal_nbaset_match_phy_device,
134+
+ .name = "Realtek Internal NBASE-T PHY",
135+
+ .flags = PHY_IS_INTERNAL,
136+
.get_features = rtl822x_get_features,
137+
.config_aneg = rtl822x_config_aneg,
138+
.read_status = rtl822x_read_status,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 8989bad541133c43550bff2b80edbe37b8fb9659 Mon Sep 17 00:00:00 2001
2+
From: Heiner Kallweit <hkallweit1@gmail.com>
3+
Date: Thu, 17 Oct 2024 18:01:13 +0200
4+
Subject: [PATCH] net: phy: realtek: add RTL8125D-internal PHY
5+
6+
The first boards show up with Realtek's RTL8125D. This MAC/PHY chip
7+
comes with an integrated 2.5Gbps PHY with ID 0x001cc841. It's not
8+
clear yet whether there's an external version of this PHY and how
9+
Realtek calls it, therefore use the numeric id for now.
10+
11+
Link: https://lore.kernel.org/netdev/2ada65e1-5dfa-456c-9334-2bc51272e9da@gmail.com/T/
12+
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
13+
Message-ID: <7d2924de-053b-44d2-a479-870dc3878170@gmail.com>
14+
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
15+
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
16+
---
17+
drivers/net/phy/realtek.c | 1 +
18+
1 file changed, 1 insertion(+)
19+
20+
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
21+
index 66646212053173..f65d7f1f348e73 100644
22+
--- a/drivers/net/phy/realtek.c
23+
+++ b/drivers/net/phy/realtek.c
24+
@@ -1151,6 +1151,7 @@ static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev)
25+
case RTL_GENERIC_PHYID:
26+
case RTL_8221B:
27+
case RTL_8251B:
28+
+ case 0x001cc841:
29+
break;
30+
default:
31+
return false;

0 commit comments

Comments
 (0)