Re: [PATCH] arm64: dts: rockchip: use MAC TX delay for ROCK 4D
From: Sebastian Reichel <hidden>
Date: 2025-07-25 05:24:30
Also in:
linux-devicetree, linux-rockchip, lkml
Hi, On Thu, Jul 24, 2025 at 05:51:16PM +0200, Andrew Lunn wrote:
quoted
&gmac0 { clock_in_out = "output"; phy-handle = <&rgmii_phy0>; - phy-mode = "rgmii-id"; + phy-mode = "rgmii-rxid"; pinctrl-names = "default"; pinctrl-0 = <ð0m0_miim ð0m0_tx_bus2@@ -246,6 +246,8 @@ ð0m0_rgmii_clk ð0m0_rgmii_bus ðm0_clk0_25m_out>; status = "okay"; + tx_delay = <0x20>; + rx_delay = <0x00>;What does 0x20 mean? Is it less than 2ns, or greater than 2ns?
Unfortunately I don't know. This part is not documented in the TRM I have access to. Also my scope is not good enough for measuring delays in the pico-second range. Previous measurements for RK3588 (RK3576 uses most of its IP and probably shared most of its quirks) suggested, that mapping this to the standard properties may not easily be possible: https://lore.kernel.org/all/bb3486c6-93df-4453-acc6-deba3c8f7f0e@lunn.ch/ (local)
Have you tried "rgmii-id" and small values for tx_delay? If the hardware needs 2.1ns, for example, the MAC could add 0.1ns and the PHY adds the default 2ns. That would allow you to conform to the DT binding.
The MAC code (drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c) looks
like this, so "rgmii-id" results in no MAC delays being applied:
case PHY_INTERFACE_MODE_RGMII:
bsp_priv->ops->set_to_rgmii(bsp_priv, bsp_priv->tx_delay,
bsp_priv->rx_delay);
break;
case PHY_INTERFACE_MODE_RGMII_ID:
bsp_priv->ops->set_to_rgmii(bsp_priv, 0, 0);
break;
case PHY_INTERFACE_MODE_RGMII_RXID:
bsp_priv->ops->set_to_rgmii(bsp_priv, bsp_priv->tx_delay, 0);
break;
case PHY_INTERFACE_MODE_RGMII_TXID:
bsp_priv->ops->set_to_rgmii(bsp_priv, 0, bsp_priv->rx_delay);
break;
...
Also the default values (if properties are missing in DT) are
rx_delay=0x10 and tx_delay=0x30, so changing this logic risks
breaking some boards :(
What PHY is this? Have you looked it you can control the delays the PHY adds? If you actually need a delay of 1.9ns, maybe the PHY can be configured to do this? That would also allow you to conform to the DT binding.
The Rock 4D uses a RTL8211F. As far as I can see that just offers one delay control knob. Greetings, -- Sebastian
Attachments
- signature.asc [application/pgp-signature] 833 bytes