[RTL930x] RTL8221B PHY registered but no traffic or link

I'm porting the XGS1210-12 rev. B1, and the plain gigabit and SFP+ ports seem to work as expected. The 2.5G PHYs are RTL8221B though (unlike the A1 which had 8226 PHYs), and I'm not seeing any link activity.

Defining the PHYs as follows in the DTS seems to work, they're getting recognised:

[    3.160761] rtl83xx-switch switch@1b000000 lan9 (uninitialized): PHY [mdio-bus:18] driver [REALTEK RTL8221B] (irq=POLL)
[    3.174018] rtl83xx-switch switch@1b000000 lan10 (uninitialized): PHY [mdio-bus:19] driver [REALTEK RTL8221B] (irq=POLL)

DTS:

                 * External 10/100M/1G/2.5G Realtek RTL8221B PHYs (ID 001c:c849).                                                                                         
                  * Properly recognised as RTL8221B, but no link established.
                  */
                 phy24: ethernet-phy@24 {
                         reg = <24>;
                         compatible = "ethernet-phy-id001c.c849";
                         rtl9300,smi-address = <1 8>;
                         sds = <6>;
                 };
 
                 phy25: ethernet-phy@25 {
                         reg = <25>;
                         compatible = "ethernet-phy-id001c.c849";
                         rtl9300,smi-address = <2 9>;
                         sds = <7>;
                 };

Setting the compatible to C45 (or C22) instead of the ID breaks things:

[    0.992743] mdio_bus mdio-bus: MDIO device at address 24 is missing.
[    0.999842] mdio_bus mdio-bus: MDIO device at address 25 is missing.
[    3.161197] rtl83xx-switch switch@1b000000 lan9 (uninitialized): no phy at 24
[    3.169222] rtl83xx-switch switch@1b000000 lan9 (uninitialized): failed to connect to PHY: -ENODEV
[    3.179235] rtl83xx-switch switch@1b000000 lan9 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 24
[    3.191437] rtl83xx-switch switch@1b000000 lan10 (uninitialized): no phy at 25
[    3.199562] rtl83xx-switch switch@1b000000 lan10 (uninitialized): failed to connect to PHY: -ENODEV
[    3.209679] rtl83xx-switch switch@1b000000 lan10 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 25

Specifically for the realtek target, there's commit caaac9ab3b which added RTL8221B support, which seemed to copy a lot of rtl8226_ calls (the RTL8226 being an older 2.5G PHY). I do not see the RTL8221B already being used by any device yet in the realtek target though?

When looking at commit 28b3a5e6b5 however, which adds RTL8221B support for under generic/ (and which suggests the (early) RTL8211B is a bit quirky), I see rtl8221b_ and rtl821x_ calls being used. It also points out the PHY can't be identified with the regular C45 clause, which probably explains what I'm seeing in dmesg.

So I'm wondering if the realtek target specific code needs to be amended to use the rtl8221b_ and rtl821x_ calls? Anything else I can check to find out why I'm not seeing any link changes when a cable gets plugged in?

@daniel Can I pick your brain here? Thanks.

So for historic reasons and for covering undocumented hardware quirks the realtek PHY driver for the realtek switch targets is not the same as for all other targets. I started to unify the drivers by ridding them from calls into realtek-soc-specific functions a while ago, but more has to be done to merge the realtek-target-specific phy driver with the mainline one.

So the 2nd commit you were referencing ("generic: net: phy: realtek: detect early version of RTL8221B") doesn't affect the realtek target at all, but was meant to support RTL8221B on other (mediatek) boards.

You could try a similar work-around on rtl83xx-phy.c driver in the RealTek target.

1 Like