[openwrt/openwrt] realtek: adapt RTl931x "digital 2" serdes page calculation

LEDE Commits lede-commits at lists.infradead.org
Mon Sep 1 15:52:40 PDT 2025


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/6802cd7f151f9bb6e59ed060c481e88323e58d27

commit 6802cd7f151f9bb6e59ed060c481e88323e58d27
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Tue Aug 26 09:41:11 2025 -0400

    realtek: adapt RTl931x "digital 2" serdes page calculation
    
    The more we step down into the SerDes deeps the more confusing it
    gets. Nevertheless it is not to late to fix a wrong assumption.
    Until now it seemed as if the frontend/backend SerDes mapping is
    totally without intersection. This is not true.
    
    The backend SerDes mapping is also dependent on the mode. Especially
    the proprietary Realtek XSGMII mode stands out from all other
    mappings. So fix the descriptions and the calculation of the third
    page package (digital 2 aka XSGMII 2).
    
    As it was not yet used it had no impact.
    
    Fixes: a4cbb44c1b ("realtek: convert access to RTL931x analog serdes pages")
    Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
    Link: https://github.com/openwrt/openwrt/pull/19873
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../files-6.12/drivers/net/ethernet/rtl838x_eth.c  | 33 ++++++++++++++--------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c b/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c
index cebf95d8df..5ba7af7fd2 100644
--- a/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c
+++ b/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c
@@ -2362,26 +2362,33 @@ static int rtmdio_930x_read_mmd_phy(u32 port, u32 devnum, u32 regnum, u32 *val)
 /*
  * The RTL931x family has 14 "frontend" SerDes that are cascaded. All operations (e.g. reset) work
  * on this frontend view while their registers are distributed over a total of least 26 background
- * SerDes. Two types of SerDes exist:
+ * SerDes with 64 pages and 32 registers. Three types of SerDes exist:
  *
- * An "even" SerDes with numbers 0, 1, 2, 4, 6, 8, 10, 12 works on one background SerDes.
+ * - Serdes 0,1 are "simple" and work on one background serdes.
+ * - "Even" SerDes with numbers 2, 4, 6, 8, 10, 12 work on two background SerDes. One analog and
+ *   one digital.
+ * - "Odd" SerDes with numbers 3, 5, 7, 9, 11, 13 work on a total of 3 background SerDes (one analog
+ *   and two digital)
+ *
+ * This maps to:
  *
- * The "odd" SerDes with numbers 3, 5, 7, 9, 11 & 13 SerDes consist of a total of 3 background
- * SerDes (one analog and two XSGMII) each with its own page/register set. So it gives this
- * mapping:
-
  * Frontend SerDes  |  0  1  2  3  4  5  6  7  8  9 10 11 12 13
  * -----------------+------------------------------------------
  * Backend SerDes 1 |  0  1  2  3  6  7 10 11 14 15 18 19 22 23
  * Backend SerDes 2 |  0  1  2  4  6  8 10 12 14 16 18 20 22 24
- * Backend SerDes 3 |  0  1  2  5  6  9 10 13 14 17 18 21 22 25
+ * Backend SerDes 3 |  0  1  3  5  7  9 11 13 15 17 19 21 23 25
+ *
+ * Note: In Realtek proprietary XSGMII mode (10G pumped SGMII) the frontend SerDes works on the
+ * two digital SerDes while in all other modes it works on the analog and the first digital SerDes.
+ * Overlapping (e.g. backend SerDes 7 can be analog or digital 2) is avoided by the existing
+ * hardware designs.
  *
  * Align this for readability by simulating a total of 576 pages and mix them as follows.
  *
  * frontend page		"even" frontend SerDes		"odd" frontend SerDes
  * page 0x000-0x03f (analog):	page 0x000-0x03f back SDS	page 0x000-0x03f back SDS
- * page 0x100-0x13f (XSGMII1):	page 0x000-0x03f back SDS	page 0x000-0x03f back SDS+1
- * page 0x200-0x23f (XSGMII2):	page 0x000-0x03f back SDS	page 0x000-0x03f back SDS+2
+ * page 0x100-0x13f (digi 1):	page 0x000-0x03f back SDS	page 0x000-0x03f back SDS+1
+ * page 0x200-0x23f (digi 2):	page 0x000-0x03f back SDS+1	page 0x000-0x03f back SDS+2
  */ 
 
 static int rtmdio_931x_get_backing_sds(u32 sds, u32 page)
@@ -2392,8 +2399,12 @@ static int rtmdio_931x_get_backing_sds(u32 sds, u32 page)
 	if (page & 0xc0)
 		return -EINVAL; /* hole */
 
-	if ((sds & 1) && (sds != 1))
-		back += (page >> 8); /* distribute "odd" to 3 background SerDes */
+	if (sds >= 2) {
+		if (sds & 1)
+			back += (page >> 8); /* distribute "odd" to 3 background SerDes */
+		else
+			back += (page >> 9); /* distribute "even" to 2 background SerDes */
+	}
 
 	return back;
 }




More information about the lede-commits mailing list