[PATCH net-next v2 1/5] net: stmmac: Add common internal RGMII delay handling
From: Jia Wang
Date: Mon Sep 07 2026 - 03:48:15 EST
Some DWMAC integrations add fixed RGMII clock delays internally.
Glue drivers need to account for these delays before passing the
interface mode to the PHY.
Add TX and RX delay capability flags to the common platform data.
Apply phy_fix_phy_mode_for_mac_delays() in stmmac_pltfr_probe() when
either capability is present.
This lets glue drivers describe the MAC capabilities without
duplicating the interface-mode validation and conversion.
Signed-off-by: Jia Wang <wangjia@xxxxxxxxxxxxx>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 11 +++++++++++
include/linux/stmmac.h | 2 ++
2 files changed, 13 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 6128ed1bd521..93b9af203a18 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -16,6 +16,7 @@
#include <linux/of.h>
#include <linux/of_net.h>
#include <linux/of_mdio.h>
+#include <linux/phy.h>
#include "stmmac.h"
#include "stmmac_platform.h"
@@ -847,6 +848,16 @@ int stmmac_pltfr_probe(struct platform_device *pdev,
struct plat_stmmacenet_data *plat,
struct stmmac_resources *res)
{
+ if (plat->has_internal_tx_delay || plat->has_internal_rx_delay) {
+ plat->phy_interface =
+ phy_fix_phy_mode_for_mac_delays(plat->phy_interface,
+ plat->has_internal_tx_delay,
+ plat->has_internal_rx_delay);
+ if (plat->phy_interface == PHY_INTERFACE_MODE_NA)
+ return dev_err_probe(&pdev->dev, -EINVAL,
+ "unsupported phy interface mode\n");
+ }
+
if (!plat->suspend && plat->exit)
plat->suspend = stmmac_plat_suspend;
if (!plat->resume && plat->init)
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 4430b967abde..00be2df63d22 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -242,6 +242,8 @@ struct plat_stmmacenet_data {
* that phylink uses.
*/
phy_interface_t phy_interface;
+ bool has_internal_tx_delay;
+ bool has_internal_rx_delay;
struct stmmac_mdio_bus_data *mdio_bus_data;
struct device_node *phy_node;
struct device_node *mdio_node;
--
2.34.1