RE: [net-next,PATCH v2] enetc: Increase eMDIO MDC rate to 2.5 MHz

From: Wei Fang

Date: Wed Sep 30 2026 - 20:46:01 EST


> > 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 ?

See below for details.

> >>> 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.
>
> 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