On some but not all devices using the RTL8221B 2.5GBit/s PHY the SerDes
setup sequence may hang under some circumstances (eg. <2500M link
partner present during boot).
RTL8221B-VB-CG 2.5Gbps PHY (C45) mdio-bus:01: rtl822xb_config_init failed: -110
Work-around the issue by performing a hardware reset and subsequent
retry of the SerDes setup, which seems to always succeed.
Doing this requires moving ALDPS setup to config_init (which is anyway
the better place for that) as it otherwise doesn't survive the reset.
Also disable listening on MDIO address 0 which may be used by other PHYs
despite being spec'ed as "broadcast address", as bus activity on address
0 may otherwise confuse the RealTek PHY for good reasons.
Tested-by: Luis Mita <luis@luismita.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
(cherry picked from commit c87a767801)
Link: https://github.com/openwrt/openwrt/pull/17790
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
		
	
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
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>
 | 
						|
[forward-port by @namiltd]
 | 
						|
Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
 | 
						|
--- a/drivers/net/phy/realtek/realtek_main.c
 | 
						|
+++ b/drivers/net/phy/realtek/realtek_main.c
 | 
						|
@@ -1166,10 +1166,32 @@ static int rtl8226_match_phy_device(stru
 | 
						|
 static int rtlgen_is_c45_match(struct phy_device *phydev, unsigned int id,
 | 
						|
 			       bool is_c45)
 | 
						|
 {
 | 
						|
-	if (phydev->is_c45)
 | 
						|
-		return is_c45 && (id == phydev->c45_ids.device_ids[1]);
 | 
						|
-	else
 | 
						|
+	if (phydev->is_c45) {
 | 
						|
+		u32 rid;
 | 
						|
+
 | 
						|
+		if (!is_c45)
 | 
						|
+			return 0;
 | 
						|
+
 | 
						|
+		rid = phydev->c45_ids.device_ids[1];
 | 
						|
+		if ((rid == 0xffffffff) && phydev->mdio.bus->read_c45) {
 | 
						|
+			int val;
 | 
						|
+
 | 
						|
+			val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID1);
 | 
						|
+			if (val < 0)
 | 
						|
+				return 0;
 | 
						|
+
 | 
						|
+			rid = val << 16;
 | 
						|
+			val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID2);
 | 
						|
+			if (val < 0)
 | 
						|
+				return 0;
 | 
						|
+
 | 
						|
+			rid |= val;
 | 
						|
+		}
 | 
						|
+
 | 
						|
+		return (id == rid);
 | 
						|
+	} else {
 | 
						|
 		return !is_c45 && (id == phydev->phy_id);
 | 
						|
+	}
 | 
						|
 }
 | 
						|
 
 | 
						|
 static int rtl8221b_match_phy_device(struct phy_device *phydev)
 |