[PATCH v3 4/8] net: stmmac: dwmac-meson8b: apply the RGMII delays the T7 way
Andrew Lunn
andrew at lunn.ch
Mon Oct 12 05:30:49 PDT 2026
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> @@ -82,6 +82,7 @@ struct meson8b_dwmac_data {
> int (*set_phy_mode)(struct meson8b_dwmac *dwmac);
> bool has_prg_eth1_rgmii_rx_delay;
> bool has_pipeline_clk;
> + bool mac_applies_dt_delays;
Please can you invert this and call it broken delays.
We should make it clear that new devices should not set this, because
it wrong, broken.
> +static int meson_dwmac_init_dt_delays(struct meson8b_dwmac *dwmac,
> + struct plat_stmmacenet_data *plat_dat)
> +{
> + struct device_node *np = dwmac->dev->of_node;
> + u32 tx_delay_ps = 0, rx_delay_ps = 0;
> + phy_interface_t phy_mode;
> + bool mac_tx, mac_rx;
> +
> + mac_tx = !of_property_read_u32(np, "tx-internal-delay-ps", &tx_delay_ps);
> + mac_rx = !of_property_read_u32(np, "rx-internal-delay-ps", &rx_delay_ps);
> +
> + /* one step is a quarter of the RGMII clock period, 2ns at 1Gbit/s */
> + if (tx_delay_ps > 6000 || tx_delay_ps % 2000)
> + return dev_err_probe(dwmac->dev, -EINVAL,
> + "The RGMII TX delay must be 0, 2000, 4000 or 6000ps\n");
tx-internal-delay is not listed in amlogic,meson-dwmac.yaml. Please
could you add it, and list the valid values.
Do you have access to the datasheet? Could you check these numbers are
correct, because they are larger than typical. 4ns, and 6ns makes no
sense, the RGMII standard only calls for 2ns.
> +
> + /* the RX delay line moves in 200ps steps and reaches 3000ps */
> + if (rx_delay_ps > 3000 || rx_delay_ps % 200)
> + return dev_err_probe(dwmac->dev, -EINVAL,
> + "The RGMII RX delay range is 0..3000ps in 200ps steps\n");
Please could you listing these values in the binding.
Also, mark that amlogic,tx-delay-ns & amlogic,rx-delay-ns are not
valid for this compatible.
> +
> + phy_mode = phy_fix_phy_mode_for_mac_delays(dwmac->phy_mode, mac_tx,
> + mac_rx);
This is not correct. This function assumes mac_tx and mac_rx are
Boolean values, the MAC is applying the full 2ns delay. However, if
rx-internal-delay-ps is only providing 200ps, that is not true.
I would prefer you keep to the usual way of doing things. Allow the
MAC to apply small tuning delays, but have the PHY do the 2ns. So
don't make any modification to phy-mode.
> static int meson8b_init_rgmii_delays(struct meson8b_dwmac *dwmac)
> {
> u32 tx_dly_config, rx_adj_config, cfg_rxclk_dly, delay_config;
> @@ -411,32 +455,34 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
> dwmac->dev = &pdev->dev;
> dwmac->phy_mode = plat_dat->phy_interface;
>
> - /* use 2ns as fallback since this value was previously hardcoded */
> - if (of_property_read_u32(pdev->dev.of_node, "amlogic,tx-delay-ns",
> - &dwmac->tx_delay_ns))
> - dwmac->tx_delay_ns = 2;
> -
> - /* RX delay defaults to 0ps since this is what many boards use */
> - if (of_property_read_u32(pdev->dev.of_node, "rx-internal-delay-ps",
> - &dwmac->rx_delay_ps)) {
> - if (!of_property_read_u32(pdev->dev.of_node,
> - "amlogic,rx-delay-ns",
> - &dwmac->rx_delay_ps))
> - /* convert ns to ps */
> - dwmac->rx_delay_ps *= 1000;
> - }
> -
> - if (dwmac->data->has_prg_eth1_rgmii_rx_delay) {
> - if (dwmac->rx_delay_ps > 3000 || dwmac->rx_delay_ps % 200) {
> - dev_err(dwmac->dev,
> - "The RGMII RX delay range is 0..3000ps in 200ps steps");
> - return -EINVAL;
> + if (!dwmac->data->mac_applies_dt_delays) {
I suggest you do this at a higher level. Either call this function if
_broken_delay is set, or the other one.
Andrew
More information about the linux-amlogic
mailing list