MTK830 + RTL8221B-VB-CG 2.5G question

IDK, sorry. I tried to consult Realtek FAE, but they said I should have NDA signed before getting the document.

Also this device will need proper support for interface-mode switching PHYs and also adapting in-band autonegotiation setting. I'm currently working on getting all this supported in upstream Linux and would appreciate review and testing. Once it's all upstream, we can backport to Linux 5.15 for OpenWrt.

work-in-progress tree is here:

(one of the) upstream submission(s) is here:
https://lore.kernel.org/linux-arm-kernel/cover.1675984550.git.daniel@makrotopia.org/

I also encountered this Phy on a Netgear WAX220. This device has a single ethernet port, but the Phy shows up as 0x00 and 0x06 for some reason.

Anyways, I'm struggling with the reset and getting the link. Apparently GPIO 5 and 6 somehow influence the reset. GPIO 6 makes both addresses disappear completely from the MDIO, GPIO 5 needs to be high in order to get a link. If I specify GPIO 6 as reset GPIO the Phy no longer gets a connection to my 1Gbit/s Ethernet card, the link simply stays down but the Phy shows up on the MDIO.

Any idea what might be going on and why I have 2 phy adresses showing up on the MDIO?

I think this may be the historical bug of realtek phy. On some router with mt7621 + rtl8211x, the realtek phy will preempt the phyad 0 of the mdio-bus, causing the port 0 of the mt7530 to fail to work. We don't need to pay attention to this on mediatek, it's not on the same mdio-bus as mt7531. So the actual address should be 0x6.

1 Like

Thanks! Any idea why it doesn't get a link if I reset it properly? What I am trying right now is this:

&eth {
        status = "okay";

        gmac0: mac@1 {
                compatible = "mediatek,eth-mac";
                reg = <1>;
                phy-handle = <&rtl8221b_phy>;
                phy-mode = "2500base-x";
        };

        mdio: mdio-bus {
                #address-cells = <1>;
                #size-cells = <0>;
        };
};

&mdio {
        #address-cells = <1>;
        #size-cells = <0>;
        rtl8221b_phy: ethernet-phy@6 {
                phy-mode = "2500base-x";
                compatible = "ethernet-phy-id001c.c849";
                reg = <6>;
                reset-gpios = <&pio 6 GPIO_ACTIVE_LOW>;
                interrupt-controller;
                #interrupt-cells = <1>;
                interrupt-parent = <&pio>;
                interrupts = <46 IRQ_TYPE_LEVEL_HIGH>;
                reset-assert-us = <100000>;
                reset-deassert-us = <100000>;
        };
};

Edit: If I set the eth to sgmii and remove the phy-mode from the phy it gets a link again but no traffic going through.

Afaik many RealTek PHYs do that, address 0 is used as broadcast ("to all RealTek PHYs in the system") while in your case address 6 is the individual PHY.
There is also way to program the PHY so it won't answer to address 0 at all, but I currently to find the part in the documentation mentioning that.

1 Like

Don't worry, it's not important. It was just weird seeing that. This unit has only the realtek on the MDIO bus, so it shouldn't matter at all. I only need to figure out how to make it forward data now....

@Amadeus I just tried your patch to see if it helps with this device aswell but that didn't help: No link if phy-mode = "2500base-x"; is specified, if phy-mode = "sgmii"; is specified there is a link but no traffic flowing.

For some reason when specifying

                fixed-link {
                        speed = <2500>;
                        full-duplex;
                        pause;
                }; 

for the gmac and remove the reset declaration from the phy it starts to work, even though I have the AP connected to a 1Gbit/s NIC. I am not seeing anything on any other MDIO address, so I assume there isn't a switch installed in this device? But what is doing the conversion between 1Gbit/s and 2.5 Gbit/s? The phy? And by resetting it I disable that feature?

You can disassemble the machine or use mdio-tools to confirm whether the switch exists. If you use fixed-link, the interface will be up by default, regardless of the actual situation.

I did disassemble it but didn't find any switch. It's a single ethernet port only, so a switch doesn't make sense. mdio-tools only shows 0 and 6, if 0 is the broadcast there's only the phy.

The fixed-link is the only way I can make it work: If I use sgmii I get a link but no traffic, if I use 2500base-x I get no link at all. I was hoping that maybe you have a clue why that could be the case.