enetc: Increase eMDIO MDC rate to 2.5 MHz
PATCH v2 1/1 enetc: Increase eMDIO MDC rate to 2.5 MHz
The current eMDIO MDC rate is 558 kHz on i.MX95 B0. This is very low, but also very compatible. However, for example NXP TJA1120 PHY needs at minimum 1 MHz MDC clock and 558 kHz does not work with that PHY.
As a minimum change, increase the MDC clock to 2.5 MHz which matches the 802.3 specification. Also, even old PHYs like LAN8210Ai, KSZ8794, DP83822 support up to 2.5 MHz MDC clock frequency, and it covers the NXP TJA1120 as well. There is no known rationale for why the 558 kHz was picked when the eMDIO driver was added.
---
Cc: "David S. Miller" <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Clark Wang <[email protected]>
Cc: Claudiu Manoil <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Paolo Abeni <[email protected]>
Cc: Vladimir Oltean <[email protected]>
Cc: Wei Fang <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: Use 2.5 MHz per 802.3 spec, update commit message
--- drivers/net/ethernet/freescale/enetc/enetc_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/enetc/enetc_mdio.c +1 -1
@@ -24,7 +24,7 @@#define ENETC_EMDIO_CFG \ (MDIO_CFG_HOLD(2) | \ - MDIO_CFG_CLKDIV(258) | \ + MDIO_CFG_CLKDIV(66) | \ MDIO_CFG_NEG)#define MDIO_CTL_DEV_ADDR (x) ((x) & 0x1f)
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] enetc: hardcoded MDIO clock divider change overclocks MDC on faster platforms --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] enetc: hardcoded MDIO clock divider change overclocks MDC on faster platforms --
commit f8edf987f57daf3802702cc91c7af187a4c08ef1
Author: Marek Vasut <[email protected]>
enetc: Increase eMDIO MDC rate to 2.5 MHz
This commit lowers the global MDIO clock divider from 258 to 66 to increase the MDC rate to 2.5 MHz for the i.MX95 B0 platform.
drivers/net/ethernet/freescale/enetc/enetc_mdio.c line 27
Quoted 10 lines
drivers/net/ethernet/freescale/enetc/enetc_mdio.c +1
-1@@ -24,7 +24,7 @@#define ENETC_EMDIO_CFG \ (MDIO_CFG_HOLD(2) | \ - MDIO_CFG_CLKDIV(258) | \ + MDIO_CFG_CLKDIV(66) | \
^^^^^^^^^^^^^^^^^^^^
[Severity: High]
Does hardcoding this lower divider overclock the MDC frequency on platforms with a faster base clock?
The enetc_mdio.c driver is also used on other platforms like the LS1028A, which typically run the ENETC system clock at a much faster rate (e.g., 333 - 400 MHz).
Applying a divider of 66 on a 400 MHz clock yields an MDC frequency of ~6.06 MHz. This exceeds the IEEE 802.3 Clause 22 maximum MDC frequency of 2.5 MHz (400 ns minimum period).
Will this break MDIO communication with PHYs on these existing boards? Should the driver dynamically calculate the divider based on the platform's actual clock rate rather than hardcoding a value tailored only for the i.MX95?
Quoted 3 lines
drivers/net/ethernet/freescale/enetc/enetc_mdio.c +0
-0MDIO_CFG_NEG)#define MDIO_CTL_DEV_ADDR (x) ((x) & 0x1f)
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 (1) · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] The patch changes ENETC_EMDIO_CFG in drivers/net/ethernet/freescale/enetc/enetc_mdio.c from…
Pre-existing issues:
- [Medium] Documentation/devicetree/bindings/net/fsl,enetc-mdio.yaml covers pci1957,ee01 (LS1028A) and pci1131,ee00 (i.MX95/94).
--
enetc: Increase eMDIO MDC rate to 2.5 MHz
This commit changes the fixed eMDIO clock divider in ENETC_EMDIO_CFG from 258 to 66. The goal is to raise MDC from 558 kHz to 2.5 MHz on i.MX95 B0. The NXP TJA1120 PHY needs an MDC of at least 1 MHz, which is the reason for the change.
drivers/net/ethernet/freescale/enetc/enetc_mdio.c line 28
Quoted 11 lines
drivers/net/ethernet/freescale/enetc/enetc_mdio.c +1
-1@@ -24,7 +24,7 @@#define ENETC_EMDIO_CFG \ (MDIO_CFG_HOLD(2) | \ - MDIO_CFG_CLKDIV(258) | \ + MDIO_CFG_CLKDIV(66) | \ MDIO_CFG_NEG)
[Severity: Medium]
The commit message only describes i.MX95 B0. What MDC rate does this divider give on the other SoCs that use it?
ENETC_EMDIO_CFG is a compile-time constant and does not depend on the input clock. enetc_mdio_read_c22(), enetc_mdio_write_c22(), enetc_mdio_read_c45() and enetc_mdio_write_c45() write it to MDIO_CFG before every transaction:
mdio_cfg = ENETC_EMDIO_CFG;
...
enetc_mdio_wr(mdio_priv, ENETC_MDIO_CFG, mdio_cfg);These accessors are installed by:
- enetc_pci_mdio_probe(), for both the LS1028A EMDIO (1957:ee01) and
the i.MX95/i.MX94 netc_emdio (1131:ee00)
- enetc_mdio_probe() and enetc_imdio_create() in enetc_pf_common.c
- vsc9959_mdio_bus_alloc(), for the LS1028A Felix switch internal MDIO
- netc_port_create_emdio_bus(), for the NETC switch per-port EMDIO
The driver uses a different system clock for each of the two generations in enetc.c:
.sysclk_freq = ENETC_CLK_400M, /* enetc_pf_data */
.sysclk_freq = ENETC_CLK_333M, /* enetc4_pf_data */The sibling QorIQ driver, xgmac_mdio.c, puts its divider at the same bit position and uses MDC = f_in / (2 * div + 1). Under that formula the new divider gives f_in / 133.
If the LS1028A EMDIO is clocked at 400 MHz, would MDC be about 3.0 MHz? The old divider gave about 774 kHz. That new rate is above the 2.5 MHz 802.3 limit the commit message is aiming for. Even at 333 MHz, the result would be about 2.504 MHz, slightly over the limit.
The driver has no per-SoC divider and does not read the input clock rate. Boards such as LS1028A RDB/QDS, Kontron sl28 or TQ MBLS1028A would have no way to bring MDC back down.
Could the divider be derived from the actual input clock, or at least chosen per SoC?
[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch. The binding and the driver do not agree on how the MDC rate is set.
Documentation/devicetree/bindings/net/fsl,enetc-mdio.yaml covers both pci1957,ee01 and pci1131,ee00. It includes mdio.yaml, so the generic clock-frequency property passes schema validation:
clock-frequency:
description:
Desired MDIO bus clock frequency in Hz. Values greater than IEEE 802.3 defined 2.5MHz should only be used when all devices on the bus support the given clock speed.
enetc_pci_mdio_probe() never reads this property. It only calls:
err = of_mdiobus_register(bus, dev->of_node);
The divider therefore always comes from ENETC_EMDIO_CFG, and any clock-frequency value in the DT is silently ignored. By comparison, xgmac_mdio_set_mdc_freq() in xgmac_mdio.c and fec_main.c both honour this property.
This patch makes the fixed MDC about 3.9 times faster on every board. Should the driver honour clock-frequency, so that a board whose PHY or wiring can't handle the new rate can lower it through the DT?
That would also need the input clock rate. The netc_emdio and enetc_mdio_pf3 DT nodes don't provide it today.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260924180607.60932-1-marex%40nabladev.com
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Thu, 24 Sep 2026 20:05:19 +0200 you wrote:
The current eMDIO MDC rate is 558 kHz on i.MX95 B0. This is very low, but also very compatible. However, for example NXP TJA1120 PHY needs at minimum 1 MHz MDC clock and 558 kHz does not work with that PHY.
As a minimum change, increase the MDC clock to 2.5 MHz which matches the 802.3 specification. Also, even old PHYs like LAN8210Ai, KSZ8794, DP83822 support up to 2.5 MHz MDC clock frequency, and it covers the NXP TJA1120 as well. There is no known rationale for why the 558 kHz was picked when the eMDIO driver was added.
[...]
Here is the summary with links:
- [net-next,v2] enetc: Increase eMDIO MDC rate to 2.5 MHz
https://git.kernel.org/netdev/net-next/c/587acb86d646
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 16 lines · On 9/30/26 4:10 AM, [email protected] wrote:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Thu, 24 Sep 2026 20:05:19 +0200 you wrote:
The current eMDIO MDC rate is 558 kHz on i.MX95 B0. This is very low, but also very compatible. However, for example NXP TJA1120 PHY needs at minimum 1 MHz MDC clock and 558 kHz does not work with that PHY.
As a minimum change, increase the MDC clock to 2.5 MHz which matches the 802.3 specification. Also, even old PHYs like LAN8210Ai, KSZ8794, DP83822 support up to 2.5 MHz MDC clock frequency, and it covers the NXP TJA1120 as well. There is no known rationale for why the 558 kHz was picked when the eMDIO driver was added.
Quoted 5 lines
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,v2] enetc: Increase eMDIO MDC rate to 2.5 MHzhttps://git.kernel.org/netdev/net-next/c/587acb86d646
This should have likely been applied only after someone from NXP looked at it.
Jakub Kicinski
maintainerQuoted 17 lines · On Wed, 30 Sep 2026 04:21:19 +0200 Marek Vasut wrote:
Quoted 16 lines · On 9/30/26 4:10 AM, [email protected] wrote:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Thu, 24 Sep 2026 20:05:19 +0200 you wrote:
The current eMDIO MDC rate is 558 kHz on i.MX95 B0. This is very low, but also very compatible. However, for example NXP TJA1120 PHY needs at minimum 1 MHz MDC clock and 558 kHz does not work with that PHY.
As a minimum change, increase the MDC clock to 2.5 MHz which matches the 802.3 specification. Also, even old PHYs like LAN8210Ai, KSZ8794, DP83822 support up to 2.5 MHz MDC clock frequency, and it covers the NXP TJA1120 as well. There is no known rationale for why the 558 kHz was picked when the eMDIO driver was added.
Quoted 5 lines
Quoted 3 lines
Here is the summary with links:
- [net-next,v2] enetc: Increase eMDIO MDC rate to 2.5 MHzhttps://git.kernel.org/netdev/net-next/c/587acb86d646This should have likely been applied only after someone from NXP looked at it.
Maybe say that in the commit message next time.
Wei Fang
maintainerSorry, this email was missed because it did not match the filtering rules I set.
Hi Valdimir and Claudiu,
Please take a look at this patch, it may affect LS1028A and S32N7 platforms.
Quoted 1 line
The current eMDIO MDC rate is 558 kHz on i.MX95 B0. This is very low,
The system clock of i.MX95 NETC is 333MHz, AFAIU, the MDC rate should be 333/(2*258+1) = 644KHz. I'm confused that why you said the rate is 558KHz.
Quoted 2 lines
but also very compatible. However, for example NXP TJA1120 PHY needs at minimum 1 MHz MDC clock and 558 kHz does not work with that PHY.
We previously used the TJA1120-SDBR daughter card to connect to the ENETC interface (RGMII) of the i.MX95 19x19 EVK board. However, we did not encounter any issues with MDIO access. Furthermore, I did not see a minimum MDC frequency rate of 1MHz on the TJA1120 datasheet. I'm not sure if this is an errata of TJA1120.
Quoted 2 lines
As a minimum change, increase the MDC clock to 2.5 MHz which matches
The prerequisite is that NETC system clock is 333MHz, so that you can get a MDC clock rate of 2.5MHz (333/(2*66 + 1)). But unfortunately, not all NETC versions have a 333MHz system clock. For example, LS1028A is 400MHz, so the MDC rate will be 3MHz, which will be a problem.
Quoted 42 lines
the 802.3 specification. Also, even old PHYs like LAN8210Ai, KSZ8794, DP83822 support up to 2.5 MHz MDC clock frequency, and it covers the NXP TJA1120 as well. There is no known rationale for why the 558 kHz was picked when the eMDIO driver was added.
Signed-off-by Marek Vasut <[email protected]>---
Cc: "David S. Miller" <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Clark Wang <[email protected]>
Cc: Claudiu Manoil <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Paolo Abeni <[email protected]>
Cc: Vladimir Oltean <[email protected]>
Cc: Wei Fang <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: Use 2.5 MHz per 802.3 spec, update commit message--- drivers/net/ethernet/freescale/enetc/enetc_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/freescale/enetc/enetc_mdio.c +1
-2@@ -24,7 +24,7 @@#define ENETC_EMDIO_CFG \ (MDIO_CFG_HOLD(2) | \ - MDIO_CFG_CLKDIV(258) | \ + MDIO_CFG_CLKDIV(66) | \ MDIO_CFG_NEG)#define MDIO_CTL_DEV_ADDR (x) ((x) & 0x1f) --2.53.0
Quoted 1 line · Wei Fang
Sorry, this email was missed because it did not match the filtering rules I set.
No worries.
Quoted 8 lines
Hi Valdimir and Claudiu,
Please take a look at this patch, it may affect LS1028A and S32N7 platforms.
Quoted 1 line
The current eMDIO MDC rate is 558 kHz on i.MX95 B0. This is very low,
The system clock of i.MX95 NETC is 333MHz, AFAIU, the MDC rate should be 333/(2*258+1) = 644KHz. I'm confused that why you said the rate is 558KHz.
That is what I observe on a scope on local MX95 board (not the EVK).
Quoted 6 lines
Quoted 2 lines
but also very compatible. However, for example NXP TJA1120 PHY needs at minimum 1 MHz MDC clock and 558 kHz does not work with that PHY.
We previously used the TJA1120-SDBR daughter card to connect to the ENETC interface (RGMII) of the i.MX95 19x19 EVK board. However, we did not encounter any issues with MDIO access.
Most PHYs are fine with the low frequency.
Quoted 3 lines
Furthermore, I did not see a minimum MDC
frequency rate of 1MHz on the TJA1120 datasheet. I'm not sure if this is an errata of TJA1120.
The TJA1120 RM is not public, but look at its predecessor:
https://www.nxp.com/docs/en/data-sheet/TJA1101B.pdf
Page 46 bottom
Table 37. Dynamic characteristics...continued
Tclk(MDC) MDC ... clock period ... Min 400 ns
400ns ~= 2.5 MHz .
Quoted 6 lines
Quoted 1 line
As a minimum change, increase the MDC clock to 2.5 MHz which matches
The prerequisite is that NETC system clock is 333MHz, so that you can get a MDC clock rate of 2.5MHz (333/(2*66 + 1)). But unfortunately, not all NETC versions have a 333MHz system clock. For example, LS1028A is 400MHz, so the MDC rate will be 3MHz, which will be a problem.
Yes, this is my concern.
Are those clock which feed MDC clock available via clock framework on LS ? If so, we could calculate the divider based on those clock.
Wei Fang
maintainerQuoted 7 lines
Quoted 5 lines
Quoted 1 line
The current eMDIO MDC rate is 558 kHz on i.MX95 B0. This is very low,
The system clock of i.MX95 NETC is 333MHz, AFAIU, the MDC rate should be
333/(2*258+1) = 644KHz. I'm confused that why you said the rate is 558KHz.That is what I observe on a scope on local MX95 board (not the EVK).
Clark helped measure the MDC rate on the 95 EVK board this morning, and the result was 644KHz, which is consistent with the theoretical value. The scope's accuracy or other factors may be causing you to observe a rate of 558kHz. But anyway, the description of 558kHz is indeed confusing because it does not match the theoretical value.
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
but also very compatible. However, for example NXP TJA1120 PHY needs at minimum 1 MHz MDC clock and 558 kHz does not work with that PHY.
We previously used the TJA1120-SDBR daughter card to connect to the ENETC interface (RGMII) of the i.MX95 19x19 EVK board. However, we did not encounter any issues with MDIO access.
Most PHYs are fine with the low frequency.
Yes, but the example you gave is TJA1120, and we also connected to TJA1120 without this problem, so this is what puzzles me.
Quoted 14 lines
Quoted 3 lines
Furthermore, I did not see a minimum MDC frequency rate of 1MHz on the TJA1120 datasheet. I'm not sure if this is an errata of TJA1120.
The TJA1120 RM is not public, but look at its predecessor:
https://www.n/
xp.com%2Fdocs%2Fen%2Fdata-sheet%2FTJA1101B.pdf&data=05%7C02%7Cw ei.fang%40nxp.com%7C44f566383a0e4f1fbf4208df1ea9fcb7%7C686ea1d3bc 2b4c6fa92cd99c5c301635%7C0%7C0%7C639263387581887659%7CUnknow n%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAi OiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=e sOmbNzJ0qJ0z7CyZYHWCm5ihMjq%2BFT1AKfT6xT1RUc%3D&reserved=0
Quoted 5 lines
Page 46 bottom
Table 37. Dynamic characteristics...continued
Tclk(MDC) MDC ... clock period ... Min 400 ns400ns ~= 2.5 MHz .
Thanks, I find the similar context in TJA1120's datasheet. The max period is 1000ns, so the min rate is 1MHz. It's weird that we did not see any MDIO access issues with TJA1120. I saw a note about MDC timing: "Not measured in production, guaranteed by design." It's possible that the minimum of 1MHz is a theoretical value, and it may actually work even below 1MHz.
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
As a minimum change, increase the MDC clock to 2.5 MHz which matches
The prerequisite is that NETC system clock is 333MHz, so that you can get a MDC clock rate of 2.5MHz (333/(2*66 + 1)). But unfortunately, not all NETC versions have a 333MHz system clock. For example, LS1028A is 400MHz, so the MDC rate will be 3MHz, which will be a problem.
Yes, this is my concern.
Are those clock which feed MDC clock available via clock framework on LS ? If so, we could calculate the divider based on those clock.
No, we typically hardcode the clock frequency in the driver based on the NETC version. Another simple method is to set the divisor to 166 instead of 66, which will not cause any problems for using a 400MHz NETC.
Quoted 3 lines
No, we typically hardcode the clock frequency in the driver based on the NETC version. Another simple method is to set the divisor to 166 instead of 66, which will not cause any problems for using a 400MHz NETC.
There are use cases where you want the MDIO bus running at the 802.3 speed, or higher.
Some PHYs need firmware download because the OEM saved $0.02 by not putting on an EEPROM. I've seen boards take 10s of seconds to download the firmware on boot.
The Marvell PHYs allow you access to the raw TDR cable testing values, which is a lot of data. Getting it faster allows nicer and more responsive tools.
There might be an MDIO managed switch hanging off the MDIO bus, so again, lots of traffic.
So please look at setting the divisor correctly to achieve 2.5Mhz, and maybe consider implementing the device tree property:
clock-frequency:
description:
Desired MDIO bus clock frequency in Hz. Values greater than IEEE 802.3 defined 2.5MHz should only be used when all devices on the bus support the given clock speed.
so it can be overclocked.
Andrew
Wei Fang
maintainerQuoted 17 lines
Quoted 1 line
No, we typically hardcode the clock frequency in the driver based on the
NETC
Quoted 1 line
version. Another simple method is to set the divisor to 166 instead of 66,
which
Quoted 1 line
will not cause any problems for using a 400MHz NETC.
There are use cases where you want the MDIO bus running at the 802.3 speed, or higher.
Some PHYs need firmware download because the OEM saved $0.02 by not putting on an EEPROM. I've seen boards take 10s of seconds to download the firmware on boot.
The Marvell PHYs allow you access to the raw TDR cable testing values, which is a lot of data. Getting it faster allows nicer and more responsive tools.
Quoted 5 lines
There might be an MDIO managed switch hanging off the MDIO bus, so again, lots of traffic.
So please look at setting the divisor correctly to achieve 2.5Mhz, and maybe consider implementing the device tree property:
Yeah, you are right, using clock-frequency is more flexible. We should add lock-frequency support later, so that a suitable divisor can be calculated based on the current NETC system clock rate. Thanks.
Quoted 11 lines
clock-frequency:
description:
Desired MDIO bus clock frequency in Hz. Values greater than IEEE 802.3 defined 2.5MHz should only be used when all devices on the bus
support
the given clock speed.so it can be overclocked.
Andrew
Quoted 11 lines · Wei Fang
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
The current eMDIO MDC rate is 558 kHz on i.MX95 B0. This is very low,
The system clock of i.MX95 NETC is 333MHz, AFAIU, the MDC rate should be
333/(2*258+1) = 644KHz. I'm confused that why you said the rate is 558KHz.That is what I observe on a scope on local MX95 board (not the EVK).
Clark helped measure the MDC rate on the 95 EVK board this morning, and the result was 644KHz, which is consistent with the theoretical value. The scope's accuracy or other factors may be causing you to observe a rate of 558kHz.
That 644 kHz and 558 kHz differs too much to be an equipment miscalibration / misuse.
Quoted 3 lines
But
anyway, the description of 558kHz is indeed confusing because it does not match the theoretical value.
Do you know from which clock are the MDC clock derived from on MX95 ?
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
but also very compatible. However, for example NXP TJA1120 PHY needs at minimum 1 MHz MDC clock and 558 kHz does not work with that PHY.
We previously used the TJA1120-SDBR daughter card to connect to the ENETC interface (RGMII) of the i.MX95 19x19 EVK board. However, we did not encounter any issues with MDIO access.
Most PHYs are fine with the low frequency.
Yes, but the example you gave is TJA1120, and we also connected to TJA1120 without this problem, so this is what puzzles me.
[...]
Quoted 11 lines
Quoted 5 lines
Page 46 bottom
Table 37. Dynamic characteristics...continued
Tclk(MDC) MDC ... clock period ... Min 400 ns400ns ~= 2.5 MHz .
Thanks, I find the similar context in TJA1120's datasheet. The max period is 1000ns, so the min rate is 1MHz. It's weird that we did not see any MDIO access issues with TJA1120. I saw a note about MDC timing: "Not measured in production, guaranteed by design." It's possible that the minimum of 1MHz is a theoretical value, and it may actually work even below 1MHz.
I got a report it is problematic, hence this patch. But maybe this is also related to the 558 kHz MDC clock I measure locally vs. 644 kHz MDC clock on your end.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
As a minimum change, increase the MDC clock to 2.5 MHz which matches
The prerequisite is that NETC system clock is 333MHz, so that you can get a MDC clock rate of 2.5MHz (333/(2*66 + 1)). But unfortunately, not all NETC versions have a 333MHz system clock. For example, LS1028A is 400MHz, so the MDC rate will be 3MHz, which will be a problem.
Quoted 8 lines
Quoted 4 lines
Yes, this is my concern.
Are those clock which feed MDC clock available via clock framework on LS ? If so, we could calculate the divider based on those clock.
No, we typically hardcode the clock frequency in the driver based on the NETC version. Another simple method is to set the divisor to 166 instead of 66, which will not cause any problems for using a 400MHz NETC.
Hmmmm, are those clock available on MX95 ? Maybe we can do some sort of fallback -- assume 166 MHz clock on LS, and obtain the clock and clock rate via clock framework on MX95 ?
Wei Fang
maintainerQuoted 6 lines
Quoted 2 lines
But
anyway, the description of 558kHz is indeed confusing because it does notmatch
Quoted 1 line
the theoretical value.
Do you know from which clock are the MDC clock derived from on MX95 ?
See below for details.
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
The prerequisite is that NETC system clock is 333MHz, so that you can get a MDC clock rate of 2.5MHz (333/(2*66 + 1)). But unfortunately, not all NETC versions have a 333MHz system clock. For example, LS1028A is 400MHz, so the MDC rate will be 3MHz, which will be a problem.
Yes, this is my concern.
Are those clock which feed MDC clock available via clock framework on LS ?
If
Quoted 3 lines
Quoted 1 line
so, we could calculate the divider based on those clock.
No, we typically hardcode the clock frequency in the driver based on the
Quoted 8 lines
NETC
Quoted 1 line
version. Another simple method is to set the divisor to 166 instead of 66,
which
Quoted 1 line
will not cause any problems for using a 400MHz NETC.
Hmmmm, are those clock available on MX95 ? Maybe we can do some sort of fallback -- assume 166 MHz clock on LS, and obtain the clock and clock rate via clock framework on MX95 ?
The MDC clock is derived from the NETC system clock. For iMX platforms, the system clock is controlled by system manager (M33 core), Linux cannot configure it. Moreover, the actual situation is a bit complicated. For iMX95, the system clock source provided by the SoC to NETC is IMX95_CLK_ENET, which is 666MHz. There is a 1/2 divisor in NETCMIX, so the clock input to NETC is 333MHz. Therefore, to obtain the actual system clock from the clock framework, we need to add a fixed-factor clock to the DTS as the NETC's system clock. Some platforms do not have this divisor. So we do not add the system clock to the binding-doc of both emdio and enetc.
In addition, the NETC is also used on S32 platforms, that might be another story altogether.
Therefore, hardcoding the clock frequency according to the NETC revision in the driver is a simple and quick method, just like we did in the enetc driver.
https://elixir.bootlin.com/linux/v7.3-rc5/source/drivers/net/ethernet/freescale/enetc/enetc.c#L3770
On 10/1/26 2:45 AM, Wei Fang wrote:
Hello Wei,
Quoted 7 lines
Quoted 3 lines
Hmmmm, are those clock available on MX95 ? Maybe we can do some sort of fallback -- assume 166 MHz clock on LS, and obtain the clock and clock rate via clock framework on MX95 ?
The MDC clock is derived from the NETC system clock. For iMX platforms, the system clock is controlled by system manager (M33 core), Linux cannot configure it.
That is probably still fine, as long as the clock are available via SCMI and their clock frequency can be read (not written/set), we can use them.
Quoted 7 lines
Moreover, the actual situation is a bit complicated. For iMX95, the system clock source provided by the SoC to NETC is
IMX95_CLK_ENET, which is 666MHz. There is a 1/2 divisor in NETCMIX, so the clock input to NETC is 333MHz. Therefore, to obtain the actual system clock from the clock framework, we need to add a fixed-factor clock to the DTS as the NETC's system clock. Some platforms do not have this divisor. So we do not add the system clock to the binding-doc of both emdio and enetc.
This is something which can still be handled by a compatible string match.
Quoted 6 lines
In addition, the NETC is also used on S32 platforms, that might be another story altogether.
Therefore, hardcoding the clock frequency according to the NETC revision in the driver is a simple and quick method, just like we did in the enetc driver.
https://elixir.bootlin.com/linux/v7.3-rc5/source/drivers/net/ethernet/freescale/enetc/enetc.c#L3770
Let me try something better, give me a day or two.
Jakub, do you want a revert of this one, fix, or follow up patch ?
Wei Fang
maintainerQuoted 11 lines
Quoted 1 line
Quoted 1 line
Hmmmm, are those clock available on MX95 ? Maybe we can do some sort
of
Quoted 6 lines
Quoted 2 lines
fallback -- assume 166 MHz clock on LS, and obtain the clock and clock rate via clock framework on MX95 ?
The MDC clock is derived from the NETC system clock. For iMX platforms, the system clock is controlled by system manager (M33 core), Linux cannot configure it.
That is probably still fine, as long as the clock are available via SCMI and their clock frequency can be read (not written/set), we can use them.
Yes, SCMI can read the clock frequency. However, because some platforms have a divisor between the clock source and NETC, we also need special handling in DTS - for example, a fixed-factor-clock. In addition, some platforms do not expose a clock provider at all (e.g. LS1028A, and likely S32N7), so they would require adding a fixed-clock in DTS.
All of these extra DTS modifications exist solely to obtain the clock frequency - yet for a given NETC version, that frequency is effectively a constant. Whether we put it in a fixed-clock/fixed-factor-clock in DTS or in the driver, we are hard-coding the same constant; the only difference is where it lives.
For these reasons, I believe hard-coding the per-version frequency in the driver is the simpler and more efficient approach, rather than introducing this extra DTS complexity just to read a constant.
Quoted 32 lines
Quoted 3 lines
Moreover, the actual situation is a bit complicated. For iMX95, the system clock source provided by the SoC to NETC is
IMX95_CLK_ENET, whichis
Quoted 1 line
666MHz. There is a 1/2 divisor in NETCMIX, so the clock input to NETC is
333MHz.
Quoted 1 line
Therefore, to obtain the actual system clock from the clock framework, we
need
Quoted 1 line
to add a fixed-factor clock to the DTS as the NETC's system clock. Some
platforms
Quoted 1 line
do not have this divisor. So we do not add the system clock to the
binding-doc of
Quoted 1 line
both emdio and enetc.
This is something which can still be handled by a compatible string match.
Quoted 1 line
In addition, the NETC is also used on S32 platforms, that might be another
story
Quoted 5 lines
altogether.
Therefore, hardcoding the clock frequency according to the NETC revision in the driver is a simple and quick method, just like we did in the enetc driver.
https://elixir.bo/
otlin.com%2Flinux%2Fv7.3-rc5%2Fsource%2Fdrivers%2Fnet%2Fethernet%2Ffr eescale%2Fenetc%2Fenetc.c%23L3770&data=05%7C02%7Cwei.fang%40nxp.c om%7C5cf4fb9826954a20a0bf08df1f5c1ab2%7C686ea1d3bc2b4c6fa92cd99c 5c301635%7C0%7C0%7C639264152594829487%7CUnknown%7CTWFpbGZs b3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIk FOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=C8sTNGPtiqsUqz 1eXYif8deaG1R1e%2BEjcpzGHnkR16k%3D&reserved=0
Quoted 1 line
Let me try something better, give me a day or two.
Okay, but please consider Andrew's suggestion. Add clock-frequency support for greater flexibility in adapting to different situations, instead of fixing the MDC clock to 2.5MHz.
BTW, I'm currently OOO until next Thursday, so I won't be able to reply to emails during that time. Sorry.
Quoted 2 lines
Jakub, do you want a revert of this one, fix, or follow up patch ?
Quoted 3 lines
Okay, but please consider Andrew's suggestion. Add clock-frequency support for greater flexibility in adapting to different situations, instead of fixing the MDC clock to 2.5MHz.
I consider this nice to have. And to actually implement it, you need to know the base frequency in order to calculate the divider. So i suggest the first patches in the patchset set the clock to 2.5Mhz, then consider other DT requested frequencies.
Andrew
Quoted 8 lines · Andrew Lunn
Quoted 3 lines
Okay, but please consider Andrew's suggestion. Add clock-frequency support for greater flexibility in adapting to different situations, instead of fixing the MDC clock to 2.5MHz.
I consider this nice to have. And to actually implement it, you need to know the base frequency in order to calculate the divider. So i suggest the first patches in the patchset set the clock to 2.5Mhz, then consider other DT requested frequencies.
I sent this:
[net-next,PATCH] enetc: Set eMDIO MDC rate to 2.5 MHz only on i.MX95
This sets MX95 to 2.5 MHz and keeps other SoCs unaffected.
Wei, for the other SoCs, do we know which SoCs clocks the MDC (divider) from which clock ? And can we figure out the clock rates and dividers ?
For the MX95, I assume the clock that feed the MDC divider are "enet" clock at 666 MHz , divided by 66 and divided by 4 ? Where does the 4 come from ?
Thank you for your help !
Wei Fang
maintainerQuoted 8 lines
Quoted 4 lines
I consider this nice to have. And to actually implement it, you need to know the base frequency in order to calculate the divider. So i suggest the first patches in the patchset set the clock to 2.5Mhz, then consider other DT requested frequencies.
I sent this:
[net-next,PATCH] enetc: Set eMDIO MDC rate to 2.5 MHz only on i.MX95
Quoted 8 lines
This sets MX95 to 2.5 MHz and keeps other SoCs unaffected.
Wei, for the other SoCs, do we know which SoCs clocks the MDC (divider) from which clock ? And can we figure out the clock rates and dividers ?
For the MX95, I assume the clock that feed the MDC divider are "enet" clock at 666 MHz , divided by 66 and divided by 4 ? Where does the 4 come from ?
See the description of MDIO_CLK_DIV field in RM: Ratio is
(2*MDIO_CLK_DIV)+1.
And as I said before, the NETC system clock of i.MX95 is 333 MHz (a fixed 1/2 divisor inside the NETCMIX), so the MDC clock frequency is
333 / ((2 * 66) + 1) = 2.5 MHz
Jakub Kicinski
maintainerQuoted 1 line · On Thu, 1 Oct 2026 03:34:09 +0200 Marek Vasut wrote:
Jakub, do you want a revert of this one, fix, or follow up patch ?
FWIW the answer was follow up, thanks for sending it!
Quoted 4 lines · Jakub Kicinski
Quoted 1 line · On Thu, 1 Oct 2026 03:34:09 +0200 Marek Vasut wrote:
Jakub, do you want a revert of this one, fix, or follow up patch ?
FWIW the answer was follow up, thanks for sending it!
Of course, sorry for the mess this created.
I'll try to figure out some more flexible way of configuring the MDC clock together with Wei, basically what Andrew suggested, in another follow up patch. Hopefully there is a way to do that for all the SoCs which have this IP.
On 9/30/26 3:27 PM, Marek Vasut wrote:
Hello again,
Quoted 5 lines
Quoted 3 lines
Clark helped measure the MDC rate on the 95 EVK board this morning, and the result was 644KHz, which is consistent with the theoretical value. The scope's accuracy or other factors may be causing you to observe a rate of 558kHz.
That 644 kHz and 558 kHz differs too much to be an equipment miscalibration / misuse.
For the sake of completeness, the MX95 B0 I have on my desk now prints this in SM:
Quoted 1 line
$ clock.r
...
097: busnetcmix = on, 133333333Hz 098: enet = on, 666666666Hz 099: enetphytest200m = on, 24000000Hz 100: enetphytest500m = on, 24000000Hz 101: enetphytest667m = on, 24000000Hz 102: enetref = on, 250000000Hz 103: enettimer1 = on, 24000000Hz
And the cycle time of MDC is 1.8ms , which is some 550 kHz .
Wei Fang
maintainerQuoted 21 lines
Quoted 7 lines
Quoted 4 lines
Clark helped measure the MDC rate on the 95 EVK board this morning, and the result was 644KHz, which is consistent with the theoretical value. The scope's accuracy or other factors may be causing you to observe a rate of 558kHz.
That 644 kHz and 558 kHz differs too much to be an equipment miscalibration / misuse.
For the sake of completeness, the MX95 B0 I have on my desk now prints this in SM:
Quoted 1 line
$ clock.r...
097: busnetcmix = on, 133333333Hz 098: enet = on, 666666666Hz 099: enetphytest200m = on, 24000000Hz 100: enetphytest500m = on, 24000000Hz 101: enetphytest667m = on, 24000000Hz 102: enetref = on, 250000000Hz 103: enettimer1 = on, 24000000Hz
Quoted 1 line
And the cycle time of MDC is 1.8ms , which is some 550 kHz .
The enet clock is the source of NETC system clock, and there is a 1/2 divisor inside the NETCMIX, so the NETC system clock is 333 MHz. So the MDC clock should be 644 KHz, the frequency measured by Clark in the attachment is indeed 644kHz.
Quoted 21 lines · Wei Fang
Quoted 21 lines
Quoted 7 lines
Quoted 4 lines
Clark helped measure the MDC rate on the 95 EVK board this morning, and the result was 644KHz, which is consistent with the theoretical value. The scope's accuracy or other factors may be causing you to observe a rate of 558kHz.
That 644 kHz and 558 kHz differs too much to be an equipment miscalibration / misuse.
For the sake of completeness, the MX95 B0 I have on my desk now prints this in SM:
Quoted 1 line
$ clock.r...
097: busnetcmix = on, 133333333Hz 098: enet = on, 666666666Hz 099: enetphytest200m = on, 24000000Hz 100: enetphytest500m = on, 24000000Hz 101: enetphytest667m = on, 24000000Hz 102: enetref = on, 250000000Hz 103: enettimer1 = on, 24000000Hz
Quoted 6 lines
Quoted 1 line
And the cycle time of MDC is 1.8ms , which is some 550 kHz .
The enet clock is the source of NETC system clock, and there is a 1/2 divisor inside the NETCMIX, so the NETC system clock is 333 MHz. So the MDC clock should be 644 KHz, the frequency measured by Clark in the attachment is indeed 644kHz.
Is there maybe any other clock source that might feed the MDC clock on MX95 B0, that could explain the 558 kHz I observe ?
I apologize for my late reply, I am currently catching up on email.
Thank you for your help !
Wei Fang
maintainerQuoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 7 lines
Quoted 4 lines
Clark helped measure the MDC rate on the 95 EVK board this morning, and the result was 644KHz, which is consistent with the theoretical value. The scope's accuracy or other factors may be causing you to observe a rate of 558kHz.
That 644 kHz and 558 kHz differs too much to be an equipment miscalibration / misuse.
For the sake of completeness, the MX95 B0 I have on my desk now prints this in
SM:Quoted 1 line
$ clock.r...
097: busnetcmix = on, 133333333Hz 098: enet = on, 666666666Hz 099: enetphytest200m = on, 24000000Hz 100: enetphytest500m = on, 24000000Hz 101: enetphytest667m = on, 24000000Hz 102: enetref = on, 250000000Hz 103: enettimer1 = on, 24000000Hz
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
And the cycle time of MDC is 1.8ms , which is some 550 kHz .
The enet clock is the source of NETC system clock, and there is a 1/2 divisor inside the NETCMIX, so the NETC system clock is 333 MHz. So the MDC clock should be 644 KHz, the frequency measured by Clark in the attachment is indeed 644kHz.
Is there maybe any other clock source that might feed the MDC clock on MX95 B0, that could explain the 558 kHz I observe ?
I do not think so. If that's the case, then setting the divisor to 66 would not result in a MDC clock of 2.5 MHz.
Quoted 4 lines
I apologize for my late reply, I am currently catching up on email.
Thank you for your help !
Quoted 28 lines · Wei Fang
Quoted 28 lines
Quoted 28 lines
Quoted 22 lines
Quoted 7 lines
Quoted 4 lines
Clark helped measure the MDC rate on the 95 EVK board this morning, and the result was 644KHz, which is consistent with the theoretical value. The scope's accuracy or other factors may be causing you to observe a rate of 558kHz.
That 644 kHz and 558 kHz differs too much to be an equipment miscalibration / misuse.
For the sake of completeness, the MX95 B0 I have on my desk now prints this in
SM:Quoted 1 line
$ clock.r...
097: busnetcmix = on, 133333333Hz 098: enet = on, 666666666Hz 099: enetphytest200m = on, 24000000Hz 100: enetphytest500m = on, 24000000Hz 101: enetphytest667m = on, 24000000Hz 102: enetref = on, 250000000Hz 103: enettimer1 = on, 24000000HzQuoted 1 line
And the cycle time of MDC is 1.8ms , which is some 550 kHz .
The enet clock is the source of NETC system clock, and there is a 1/2 divisor inside the NETCMIX, so the NETC system clock is 333 MHz. So the MDC clock should be 644 KHz, the frequency measured by Clark in the attachment is indeed 644kHz.
Quoted 5 lines
Quoted 2 lines
Is there maybe any other clock source that might feed the MDC clock on MX95 B0, that could explain the 558 kHz I observe ?
I do not think so. If that's the case, then setting the divisor to 66 would not result in a MDC clock of 2.5 MHz.
Hmmm, I see.
(also, I apologize for the slow response, I am completely flooded by emails, I still need a few days to get back to this topic)
Vladimir Oltean
maintainerQuoted 2 lines · Marek Vasut
Are those clock which feed MDC clock available via clock framework on LS ? If so, we could calculate the divider based on those clock.
Yes.
On LS1028A, the ENETC clock selection is made by a mux called HWA_CGA_M4_CLK_SEL (Hardware Accelerator Block Cluster Group A Mux 4 Clock Select).
You can describe that in ls1028a.dtsi like this (note that in the RM, the mux numbering is one-based, while in the device tree it is 0-based, so 3 is actually "MUX 4"):
enetc_mdio_pf3: mdio@0,3 {
compatible = "pci1957,ee01", "fsl,enetc-mdio"; reg = <0x000300 0 0 0 0>;
+ clocks = <&clockgen QORIQ_CLK_HWACCEL 3>;
#address-cells = <1>;
#size-cells = <0>;
};
Upon clk_get_rate(), the qoriq clockgen driver will use the device tree definition to index the hwaccel[] array and find the ls1028a_hwa4 structure. This defines what values the HWA4CSR register can legally take, and what each means. It will read HWA4CSR[HWACLKSEL] as 0011 (meaning Cluster PLL2 divide-by-3). Then to calculate this clock rate, it knows it must read CGA_PLL2 and to divide by PLL_DIV3 (1200 / 3 = 400 MHz).
Note the ENETC PTP device already has this property defined (which is OK, all ENETC devices share the same clock).
Without a 'clocks' and/or 'clock-frequency' property, we have to figure out a default that works for everyone, or if that fails.
For example, with 400 MHz enet_clk on LS1028A, the original MDIO_CFG_CLKDIV value of 258 used to produce an MDC frequency of 400000000÷((258×2)+1)=773 KHz.
Your new MDIO_CFG_CLKDIV value of 66 produces 400000000÷((66)+1)=3 MHz, which is too high to be a default value. So from LS perspective, this patch needs to be reverted.
Generally it is assumed that low MDIO clock frequencies are not a problem. Otherwise, drivers/net/mdio/mdio-bitbang.c could never work. It seems TJA1120 is the odd one for requiring a maximum MDC clock period of 1000 ns.
Please use xgmac_mdio_set_mdc_freq() as model, since it exists to solve a very similar issue as you are trying to do.
Quoted 42 lines · Vladimir Oltean
Quoted 2 lines · Marek Vasut
Are those clock which feed MDC clock available via clock framework on LS ? If so, we could calculate the divider based on those clock.
Yes.
On LS1028A, the ENETC clock selection is made by a mux called
HWA_CGA_M4_CLK_SEL(Hardware Accelerator Block Cluster Group A Mux 4 Clock Select).You can describe that in
ls1028a.dtsilike this (note that in the RM, the mux numbering is one-based, while in the device tree it is 0-based, so 3 is actually "MUX 4"):enetc_mdio_pf3: mdio@0,3 { compatible = "pci1957,ee01", "fsl,enetc-mdio"; reg = <0x000300 0 0 0 0>;(quoted diff) +1
-0+ clocks = <&clockgen QORIQ_CLK_HWACCEL 3>; #address-cells = <1>; #size-cells = <0>; };Upon
clk_get_rate(), the qoriq clockgen driver will use the device tree definition to index the hwaccel[] array and find thels1028a_hwa4structure. This defines what values the HWA4CSR register can legally take, and what each means. It will read HWA4CSR[HWACLKSEL] as 0011 (meaning Cluster PLL2 divide-by-3). Then to calculate this clock rate, it knows it must readCGA_PLL2and to divide byPLL_DIV3(1200 / 3 = 400 MHz).Note the ENETC PTP device already has this property defined (which is OK, all ENETC devices share the same clock).
Without a 'clocks' and/or 'clock-frequency' property, we have to figure out a default that works for everyone, or if that fails.
For example, with 400 MHz
enet_clkon LS1028A, the originalMDIO_CFG_CLKDIVvalue of 258 used to produce an MDC frequency of 400000000÷((258×2)+1)=773 KHz.Your new
MDIO_CFG_CLKDIVvalue of 66 produces 400000000÷((66)+1)=3 MHz, which is too high to be a default value. So from LS perspective, this patch needs to be reverted.
Quoted 7 lines
Generally it is assumed that low MDIO clock frequencies are not a problem. Otherwise,
drivers/net/mdio/mdio-bitbang.ccould never work. It seems TJA1120 is the odd one for requiring a maximum MDC clock period of 1000 ns.Please use
xgmac_mdio_set_mdc_freq()as model, since it exists to solve a very similar issue as you are trying to do.
All right, let's revert the original broken patch (already posted) and lemme prepare something similar to xgmac_mdio_set_mdc_freq(). Thanks !