aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2023-04-30 03:59:55 +0100
committerDaniel Golle <daniel@makrotopia.org>2023-04-30 17:27:00 +0100
commit28b3a5e6b5b17520d62745cac5cfa07e4793fe5c (patch)
tree66bf4dae2167c280c2b326ae409dd4c2122a068c /target/linux/generic
parent45f5115253362c82296eb212742381e90199b3ef (diff)
downloadupstream-28b3a5e6b5b17520d62745cac5cfa07e4793fe5c.tar.gz
upstream-28b3a5e6b5b17520d62745cac5cfa07e4793fe5c.tar.bz2
upstream-28b3a5e6b5b17520d62745cac5cfa07e4793fe5c.zip
generic: net: phy: realtek: detect early version of RTL8221B
Early versions (?) of the RTL8221B PHY cannot be identified in a regular Clause-45 bus scan as the PHY doesn't report the implemented MMDs correctly but returns 0 instead. Implement custom identify function using the PKGID instead of iterating over the implemented MMDs to work-around this problem. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'target/linux/generic')
-rw-r--r--target/linux/generic/pending-5.15/730-net-phy-realtek-detect-early-version-of-RTL8221B.patch63
1 files changed, 63 insertions, 0 deletions
diff --git a/target/linux/generic/pending-5.15/730-net-phy-realtek-detect-early-version-of-RTL8221B.patch b/target/linux/generic/pending-5.15/730-net-phy-realtek-detect-early-version-of-RTL8221B.patch
new file mode 100644
index 0000000000..6d414bfbad
--- /dev/null
+++ b/target/linux/generic/pending-5.15/730-net-phy-realtek-detect-early-version-of-RTL8221B.patch
@@ -0,0 +1,63 @@
+From 0de82310d2b32e78ff79d42c08b1122a6ede3778 Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel@makrotopia.org>
+Date: Sun, 30 Apr 2023 00:15:41 +0100
+Subject: [PATCH] net: phy: realtek: detect early version of RTL8221B
+
+Early versions (?) of the RTL8221B PHY cannot be identified in a regular
+Clause-45 bus scan as the PHY doesn't report the implemented MMDs
+correctly but returns 0 instead.
+Implement custom identify function using the PKGID instead of iterating
+over the implemented MMDs.
+
+Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+
+--- a/drivers/net/phy/realtek.c
++++ b/drivers/net/phy/realtek.c
+@@ -744,6 +744,38 @@ static int rtl8226_match_phy_device(stru
+ rtlgen_supports_2_5gbps(phydev);
+ }
+
++static int rtl8221b_vb_cg_match_phy_device(struct phy_device *phydev)
++{
++ int val;
++ u32 id;
++
++ if (phydev->mdio.bus->probe_capabilities >= MDIOBUS_C45) {
++ val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID1);
++ if (val < 0)
++ return 0;
++
++ id = val << 16;
++ val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID2);
++ if (val < 0)
++ return 0;
++
++ id |= val;
++ } else {
++ val = phy_read(phydev, MII_PHYSID1);
++ if (val < 0)
++ return 0;
++
++ id = val << 16;
++ val = phy_read(phydev, MII_PHYSID2);
++ if (val < 0)
++ return 0;
++
++ id |= val;
++ }
++
++ return (id == 0x001cc849);
++}
++
+ static int rtl822x_probe(struct phy_device *phydev)
+ {
+ struct device *dev = &phydev->mdio.dev;
+@@ -1084,7 +1116,7 @@ static struct phy_driver realtek_drvs[]
+ .write_page = rtl821x_write_page,
+ .soft_reset = genphy_soft_reset,
+ }, {
+- PHY_ID_MATCH_EXACT(0x001cc849),
++ .match_phy_device = rtl8221b_vb_cg_match_phy_device,
+ .name = "RTL8221B-VB-CG 2.5Gbps PHY",
+ .get_features = rtl822x_get_features,
+ .config_init = rtl8221b_config_init,