Adding TP-Link Deco X55 Pro Support

Hello OpenWRT gurus!

I've been working on getting the TP-Link Deco X55 Pro working the past few weeks. I've had a bit of success with booting a initramfs custom build from the latest OpenWRT code on github and getting one of the two 2.5Gbe ports to work.

Per the FCC internal pictures and the boot log /running system info, the device has a Mediatek MT7981 SOC with 512MB RAM and two RTL8221b PHY chips for the two RJ-45 ethernet ports it has. For wireless it uses the MediaTek MT7976DAN chip which appears to work OK for both 2.4Mhz and 5Mhz radios on the custom build.

I soldered in a pin header to the UART and have it connected to an FTDI-USB adapter where I can connect at 115200bps. I can interrupt u-boot and execute commands to interrogate the system and also load and boot kernels using kermit over the serial port (since the network HW doesn't appear to be supported by the u-boot version that is used)

The opensource files provided by TP-Link has a DTS file in it, which I was able to confirm is the one used by the stock firmware. Between the version of OpenWRT used in the stock firmware (12.09-rc1) and the current OpenWRT, it seems there have been a lot of code changes around the realtek drivers in the kernel so I'm not sure what the appropriate settings should be. I've looked at the configuration code, existing issues, and forum posts for similar devices and for issues with the RTL8211B phy but haven't found anything that gets the second port to work.

One change I made in the DTS was to remove the following configuration for the gmacs in the eth node. Neither wired ports would come up with this set. After removing it, the LAN port eth1 comes up and appears to work ok.

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

Currently the eth section of the DTS file looks like this

&eth {

		status = "okay";

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

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

        mdio: mdio-bus {
                #address-cells = <1>;
                #size-cells = <0>;
		
		phy5: phy@5 {
			compatible = "ethernet-phy-ieee802.3-c45";
			reg = <0x5>;
			interrupt-parent = <&pio>;
			reset-gpios = <&pio 14 GPIO_ACTIVE_LOW>;
			reset-assert-us = <100000>;
			reset-deassert-us = <100000>;
			phy-mode = "2500base-x";
			partner_gmac = <1>;
		};
		
		phy6: phy@6 {
			compatible = "ethernet-phy-ieee802.3-c45";
			reg = <0x6>;
			interrupt-parent = <&pio>;
			reset-gpios = <&pio 39 GPIO_ACTIVE_LOW>;
			reset-assert-us = <100000>;
 			reset-deassert-us = <100000>;
			phy-mode = "2500base-x";
			partner_gmac = <0>;
		};
	};
};

After booting the custom build, the WAN port eth0 does not want to work no matter what I try
ethtool -S eth0 yeilds the following output, indicating that the interface isn't able to recieve any packets

NIC statistics:
tx_bytes: 3490
tx_packets: 29
tx_skip: 0
tx_collisions: 0
rx_bytes: 0
rx_packets: 0
rx_overflow: 0
rx_fcs_errors: 151
rx_short_errors: 902
rx_long_errors: 0
rx_checksum_errors: 0
rx_flow_control_packets: 0
rx_xdp_redirect: 0
rx_xdp_pass: 0
rx_xdp_drop: 0
rx_xdp_tx: 0
rx_xdp_tx_errors: 0
tx_xdp_xmit: 0
tx_xdp_xmit_errors: 0

The MT7981 mtk_soc_eth and the realtek driver seems to detect the hardware correctly and do not throw any errors on boot. Both ports show as link up in logs and link lights on the switch they are plugged into with both correctly negiotiating 1Gbs speed.

[    8.511821] mtk_soc_eth 15100000.ethernet eth0: PHY [mdio-bus:06] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[    8.526060] mtk_soc_eth 15100000.ethernet eth0: configuring for phy/2500base-x link mode
[   12.693041] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
[   18.725949] mtk_soc_eth 15100000.ethernet eth0: Link is Down
[   18.882037] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:05] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[   18.896119] mtk_soc_eth 15100000.ethernet eth1: configuring for phy/2500base-x link mode
[   18.943650] mtk_soc_eth 15100000.ethernet eth1: entered allmulticast mode
[   18.950574] mtk_soc_eth 15100000.ethernet eth1: entered promiscuous mode
[   19.191686] mtk_soc_eth 15100000.ethernet eth0: PHY [mdio-bus:06] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[   19.201878] mtk_soc_eth 15100000.ethernet eth0: configuring for phy/sgmii link mode
[   22.372672] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
[   23.093021] mtk_soc_eth 15100000.ethernet eth1: Link is Up - 1Gbps/Full - flow control off

The output for the MDIO bus for the two phys does show some differences, but I'm not sure how to interpret them.

            eth0-gmac0    eth1-gmac1
            phy6	      phy5

phy:1 0x6	0xc000	      0xc000
phy:1 0x5	0x008b	      0x008b
phy:1 0x2	0x001c	      0x001c
phy:1 0x3	0xc849	      0xc849
phy:3 0x2	0x001c	      0x001c
phy:3 0x3	0xc849	      0xc849
phy:7 0x2	0x001c	      0x001c
phy:7 0x3	0xc849        0xc849
phy:30 0x8	0x5555	      0x4b3c
phy:30 0x2	0x0000	      0x5555
phy:30 0x3	0x0000	      0xd555
phy:31 0x8	0x8000	      0x8000
phy:31 0x2	0x001c	      0x001c
phy:31 0x3	0xc849	      0xc849
phy:30 0xa662 0x0000	  0xa8c0
phy:30 0xa4d2 0x0608	  0x5555
phy:30 0xa4d4 0x0008	  0xffff
phy:7 0x1	0x002d	      0x002d
phy:1 0x8	0x8200	      0x8200
phy:1 0xb	0x41a0	      0x41a0
phy:1 0x15	0x0001	      0x0001
phy:3 0x14	0x0006	      0x0006
phy:3 0x15	0x0001	      0x0001
phy:7 0x3c	0x0006	      0x0006
phy:7 0xe3	0x0000	      0x0000

Any suggestions or tips to get over this hurdle would be appreciated.

The RTL8221B is a little tricky out of the box in that it wants to change its serdes rate based upon the ethernet line rate. So at 1000Mbps it wants to use SGMII, and then at 2500Mbps it wants to use either HiSGMII or 2500base-X.

For our Realtek MAC usage we've got it set to sgmii and inband autonegotiation.

However this will depend quite a bit on the MAC / serdes handling, and how the MT7981 driver handles things.
In saying that... the devicetree properties that I've pointed you to are worth a try for you...

As an aside... are there any LEDs controlled by the RTL8221B PHYs on this device?

Thanks for the suggestion Bevan. I was able to try out those different settings and they did not change the behavior. I've tried several more variations in the DTS too but no luck.

I even booted back into the stock firmware and confirmed that the port is still working there.

There are no LEDs on the ethernet ports for this device. There is only a single overall LED indicating the different phases of booting for the stock firmware.

Are there any other ideas out there?

Can you provide boot logs of the PHY / switch bring up sections for the different devicetree attempts?
Perhaps there's something glaring in them...

Here are some logs from a few custom build attempts with different DTS changes. Nothing jumping out at me with the exception of the last attempt where I swapped the gmacs. Still trying to wrap my head around the internal routing and relationships between the gmacs and external phys as to how that is working.

original settings from first post - eth1-lan works

[    2.723146] mtk_soc_eth 15100000.ethernet: generated random MAC address 20:08:02:00:00:00
[    2.731335] mtk_soc_eth 15100000.ethernet: generated random MAC address 20:08:02:00:00:00
[    3.296969] mtk_soc_eth 15100000.ethernet eth0: mediatek frame engine at 0xffffffc081380000, irq 76
[    3.306918] mtk_soc_eth 15100000.ethernet eth1: mediatek frame engine at 0xffffffc081380000, irq 76
[    9.211964] mtk_soc_eth 15100000.ethernet eth0: PHY [mdio-bus:06] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[    9.226186] mtk_soc_eth 15100000.ethernet eth0: configuring for phy/2500base-x link mode
[   13.413300] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
[   24.941781] mtk_soc_eth 15100000.ethernet eth0: Link is Down
[   25.112012] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:05] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[   25.126626] mtk_soc_eth 15100000.ethernet eth1: configuring for phy/2500base-x link mode
[   25.164480] br-lan: port 1(eth1) entered blocking state
[   25.169721] br-lan: port 1(eth1) entered disabled state
[   25.175044] mtk_soc_eth 15100000.ethernet eth1: entered allmulticast mode
[   25.182077] mtk_soc_eth 15100000.ethernet eth1: entered promiscuous mode
[   25.431999] mtk_soc_eth 15100000.ethernet eth0: PHY [mdio-bus:06] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[   25.442188] mtk_soc_eth 15100000.ethernet eth0: configuring for phy/sgmii link mode


managed inband - niether ports worked

[    2.713185] mtk_soc_eth 15100000.ethernet: generated random MAC address 20:08:02:00:00:00
[    2.721375] mtk_soc_eth 15100000.ethernet: generated random MAC address 20:08:02:00:00:00
[    3.687007] mtk_soc_eth 15100000.ethernet eth0: mediatek frame engine at 0xffffffc081500000, irq 76
[    3.696941] mtk_soc_eth 15100000.ethernet eth1: mediatek frame engine at 0xffffffc081500000, irq 76
[    9.579949] mtk_soc_eth 15100000.ethernet eth0: configuring for inband/2500base-x link mode
[   10.611949] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control off
[   22.522224] mtk_soc_eth 15100000.ethernet eth0: Link is Down
[   22.547859] mtk_soc_eth 15100000.ethernet eth1: configuring for inband/2500base-x link mode
[   22.560470] mtk_soc_eth 15100000.ethernet eth1: Link is Up - 2.5Gbps/Full - flow control off
[   22.575103] br-lan: port 1(eth1) entered blocking state
[   22.580349] br-lan: port 1(eth1) entered disabled state
[   22.585699] mtk_soc_eth 15100000.ethernet eth1: entered allmulticast mode
[   22.592747] mtk_soc_eth 15100000.ethernet eth1: entered promiscuous mode
[   22.602806] br-lan: port 1(eth1) entered blocking state
[   22.608057] br-lan: port 1(eth1) entered forwarding state
[   22.627497] mtk_soc_eth 15100000.ethernet eth0: configuring for inband/2500base-x link mode
[   22.646630] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control off


gmac reg/index swap (gmac0=reg1, gmac1=reg0) eth1-lan still works using other physical port

[    2.723183] mtk_soc_eth 15100000.ethernet: generated random MAC address 20:08:02:00:00:00
[    2.731372] mtk_soc_eth 15100000.ethernet: generated random MAC address 20:08:02:00:00:00
[    3.697009] mtk_soc_eth 15100000.ethernet eth0: mediatek frame engine at 0xffffffc081500000, irq 76
[    3.706942] mtk_soc_eth 15100000.ethernet eth1: mediatek frame engine at 0xffffffc081500000, irq 76
[    9.611986] mtk_soc_eth 15100000.ethernet eth0: PHY [mdio-bus:05] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[    9.626364] mtk_soc_eth 15100000.ethernet eth0: configuring for phy/2500base-x link mode
[   13.813332] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
[   20.718293] mtk_soc_eth 15100000.ethernet eth0: Link is Down
[   20.972033] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:06] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[   20.986356] mtk_soc_eth 15100000.ethernet eth1: configuring for phy/2500base-x link mode
[   21.024434] br-lan: port 1(eth1) entered blocking state
[   21.029675] br-lan: port 1(eth1) entered disabled state
[   21.035023] mtk_soc_eth 15100000.ethernet eth1: entered allmulticast mode
[   21.042098] mtk_soc_eth 15100000.ethernet eth1: entered promiscuous mode
[   21.292072] mtk_soc_eth 15100000.ethernet eth0: PHY [mdio-bus:05] driver [RTL8221B-VB-CG 2.5Gbps PHY] (irq=POLL)
[   21.302299] mtk_soc_eth 15100000.ethernet eth0: configuring for phy/sgmii link mode
[   24.452989] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
[   25.173326] mtk_soc_eth 15100000.ethernet eth1: Link is Up - 1Gbps/Full - flow control off
[   25.173357] br-lan: port 1(eth1) entered blocking state
[   25.186816] br-lan: port 1(eth1) entered forwarding state

Per the datasheet, the MT7981b SOC has two GMACs. All the OpenWRT supported devices I can find seem to use one GMAC with an external phy and the other GMAC with the available internal gigabit ethernet PHY. The TP-Link x55 Pro seems to be special in that it uses two external phys (RTL8221b). Since GMAC2 can work with either internal or external phys, I'm curious if I explicitly disable the internal gphy somehow if it will make a difference with any initialization or communication.