From: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Richard Cochran <richardcochran@gmail.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Biao Huang <biao.huang@mediatek.com>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Eric Dumazet <edumazet@kernel.org>,
Eric Dumazet <edumazet@kernel.org>
Cc: kernel@collabora.com, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
Subject: [PATCH net-next v3 5/9] net: stmmac: mediatek: add RX/TX delay stage divider in platform data
Date: Fri, 16 Oct 2026 12:31:09 +0200 [thread overview]
Message-ID: <20261016-dwmac-mediatek-mt8189-v3-5-25daf2bbcf35@collabora.com> (raw)
In-Reply-To: <20261016-dwmac-mediatek-mt8189-v3-0-25daf2bbcf35@collabora.com>
In preparation of newer SoC support, that have like MT8189 SoC
different RX and TX internal delay stage steps than MT8188/MT8195, add
the RX and TX delay stage divider values in the variant platform data
and replace the hardcoded value uses in mt2712_set_delay and
mt8195_set_delay.
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
---
.../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 46 ++++++++++++++++++----
1 file changed, 38 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
index 596411d4a5b2..cb5bda53edb9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -108,6 +108,10 @@ struct mediatek_dwmac_variant {
u32 rx_delay_max;
u32 tx_delay_max;
+ u16 rx_rmii_delay_stage_div;
+ u16 tx_rmii_delay_stage_div;
+ u16 rx_rgmii_delay_stage_div;
+ u16 tx_rgmii_delay_stage_div;
u8 dma_bit_mask;
};
@@ -146,14 +150,22 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat)
u32 fine_val = 0;
if (phy_interface_mode_is_rgmii(plat->phy_mode)) {
- rx_delay_stage_div = MT2712_RGMII_DLY_RXC_STAGE_DIV;
- tx_delay_stage_div = MT2712_RGMII_DLY_TXC_STAGE_DIV;
+ rx_delay_stage_div = plat->variant->rx_rgmii_delay_stage_div;
+ tx_delay_stage_div = plat->variant->tx_rgmii_delay_stage_div;
} else {
- rx_delay_stage_div = MT2712_RMII_DLY_RXC_STAGE_DIV;
- tx_delay_stage_div = MT2712_RMII_DLY_TXC_STAGE_DIV;
+ rx_delay_stage_div = plat->variant->rx_rmii_delay_stage_div;
+ tx_delay_stage_div = plat->variant->tx_rmii_delay_stage_div;
}
- rx_delay_stage_val = mac_delay->rx_delay / rx_delay_stage_div;
- tx_delay_stage_val = mac_delay->tx_delay / tx_delay_stage_div;
+
+ if (rx_delay_stage_div)
+ rx_delay_stage_val = mac_delay->rx_delay / rx_delay_stage_div;
+ else
+ rx_delay_stage_val = 0;
+
+ if (tx_delay_stage_div)
+ tx_delay_stage_val = mac_delay->tx_delay / tx_delay_stage_div;
+ else
+ tx_delay_stage_val = 0;
switch (plat->phy_mode) {
case PHY_INTERFACE_MODE_MII:
@@ -258,6 +270,10 @@ static const struct mediatek_dwmac_variant mt2712_gmac_variant = {
.num_clks = ARRAY_SIZE(mt2712_dwmac_clk_l),
.rx_delay_max = MT2712_RGMII_DLY_RXC_MAX,
.tx_delay_max = MT2712_RGMII_DLY_TXC_MAX,
+ .rx_rmii_delay_stage_div = MT2712_RMII_DLY_RXC_STAGE_DIV,
+ .tx_rmii_delay_stage_div = MT2712_RMII_DLY_TXC_STAGE_DIV,
+ .rx_rgmii_delay_stage_div = MT2712_RGMII_DLY_RXC_STAGE_DIV,
+ .tx_rgmii_delay_stage_div = MT2712_RMII_DLY_TXC_STAGE_DIV,
.dma_bit_mask = 33,
};
@@ -283,13 +299,25 @@ static int mt8195_set_interface(struct mediatek_dwmac_plat_data *plat,
static int mt8195_set_delay(struct mediatek_dwmac_plat_data *plat)
{
+ u16 rx_delay_stage_div = plat->variant->rx_rgmii_delay_stage_div;
+ u16 tx_delay_stage_div = plat->variant->tx_rgmii_delay_stage_div;
struct mac_delay_struct *mac_delay = &plat->mac_delay;
- u32 rx_delay_stage_val = mac_delay->rx_delay / MT8195_DLY_RXC_STAGE_DIV;
- u32 tx_delay_stage_val = mac_delay->tx_delay / MT8195_DLY_TXC_STAGE_DIV;
+ u32 rx_delay_stage_val;
+ u32 tx_delay_stage_val;
u32 gtxc_delay_val = 0;
u32 rmii_delay_val = 0;
u32 delay_val = 0;
+ if (rx_delay_stage_div)
+ rx_delay_stage_val = mac_delay->rx_delay / rx_delay_stage_div;
+ else
+ rx_delay_stage_val = 0;
+
+ if (tx_delay_stage_div)
+ tx_delay_stage_val = mac_delay->tx_delay / tx_delay_stage_div;
+ else
+ tx_delay_stage_val = 0;
+
switch (plat->phy_mode) {
case PHY_INTERFACE_MODE_MII:
delay_val |= FIELD_PREP(MT8195_DLY_TXC_ENABLE,
@@ -398,6 +426,8 @@ static const struct mediatek_dwmac_variant mt8195_gmac_variant = {
.num_clks = ARRAY_SIZE(mt8195_dwmac_clk_l),
.rx_delay_max = MT8195_DLY_RXC_MAX,
.tx_delay_max = MT8195_DLY_TXC_MAX,
+ .rx_rgmii_delay_stage_div = MT8195_DLY_RXC_STAGE_DIV,
+ .tx_rgmii_delay_stage_div = MT8195_DLY_TXC_STAGE_DIV,
.dma_bit_mask = 35,
};
--
2.56.0
next prev parent reply other threads:[~2026-10-16 10:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 10:31 [PATCH net-next v3 0/9] net/stmmac: Add Mediatek MT8189 support Louis-Alexis Eyraud
2026-10-16 10:31 ` [PATCH net-next v3 1/9] dt-bindings: net: mediatek-dwmac: fix unit in rx/tx delay property description Louis-Alexis Eyraud
2026-10-16 15:33 ` Andrew Lunn
2026-10-16 10:31 ` [PATCH net-next v3 2/9] dt-bindings: net: mediatek-dwmac: add support for MT8189 SoC Louis-Alexis Eyraud
2026-10-16 15:40 ` Andrew Lunn
2026-10-16 10:31 ` [PATCH net-next v3 3/9] net: stmmac: mediatek: simplify TX/RX delay handling in mt8195_set_delay Louis-Alexis Eyraud
2026-10-16 10:31 ` [PATCH net-next v3 4/9] net: stmmac: mediatek: simplify TX/RX delay handling in mt2712_set_delay Louis-Alexis Eyraud
2026-10-16 10:31 ` Louis-Alexis Eyraud [this message]
2026-10-16 11:37 ` [PATCH net-next v3 5/9] net: stmmac: mediatek: add RX/TX delay stage divider in platform data Maxime Chevallier
2026-10-16 10:31 ` [PATCH net-next v3 6/9] net: stmmac: mediatek: add PERI_ETH_CTRLx register offset " Louis-Alexis Eyraud
2026-10-16 10:31 ` [PATCH net-next v3 7/9] net: stmmac: mediatek: use TX clock phase shift in RGMII mode with 1Gbps speed Louis-Alexis Eyraud
2026-10-16 11:41 ` Maxime Chevallier
2026-10-16 15:48 ` Andrew Lunn
2026-10-16 10:31 ` [PATCH net-next v3 8/9] net: stmmac: mediatek: add support for TX clock output enable feature Louis-Alexis Eyraud
2026-10-16 10:31 ` [PATCH net-next v3 9/9] net: stmmac: mediatek: add support for MT8189 SoC Louis-Alexis Eyraud
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261016-dwmac-mediatek-mt8189-v3-5-25daf2bbcf35@collabora.com \
--to=louisalexis.eyraud@collabora.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=biao.huang@mediatek.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=kernel@collabora.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=matthias.bgg@gmail.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®