Netdev List
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Marek Vasut <marex@nabladev.com>
Cc: Wei Fang <wei.fang@nxp.com>, Clark Wang <xiaoning.wang@nxp.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	"David S. Miller" <davem@davemloft.net>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"imx@lists.linux.dev" <imx@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [net-next,PATCH v2] enetc: Increase eMDIO MDC rate to 2.5 MHz
Date: Tue, 13 Oct 2026 18:25:59 +0300	[thread overview]
Message-ID: <20261013152559.cnh2i7i36hak6z3t@skbuf> (raw)
In-Reply-To: <af3d4fd1-9659-4d91-997f-6bb09ae06ba5@nabladev.com>

On Wed, Sep 30, 2026 at 06:19:04AM +0200, Marek Vasut wrote:
> 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.

  parent reply	other threads:[~2026-10-13 15:26 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 18:05 [net-next,PATCH v2] enetc: Increase eMDIO MDC rate to 2.5 MHz Marek Vasut
2026-09-25 18:43 ` netdev-bot+sashiko
2026-09-30  2:10 ` patchwork-bot+netdevbpf
2026-09-30  2:21   ` Marek Vasut
2026-09-30 20:51     ` Jakub Kicinski
2026-09-30  3:40 ` Wei Fang
2026-09-30  4:19   ` Marek Vasut
2026-09-30  6:12     ` Wei Fang
2026-09-30 13:11       ` Andrew Lunn
2026-10-01  0:04         ` Wei Fang
2026-09-30 13:27       ` Marek Vasut
2026-10-01  0:45         ` Wei Fang
2026-10-01  1:34           ` Marek Vasut
2026-10-01 10:57             ` Wei Fang
2026-10-01 13:53               ` Andrew Lunn
2026-10-01 22:43                 ` Marek Vasut
2026-10-08  3:08                   ` Wei Fang
2026-10-01 22:51             ` Jakub Kicinski
2026-10-01 23:11               ` Marek Vasut
2026-10-01 22:00         ` Marek Vasut
2026-10-08  2:34           ` Wei Fang
2026-10-12 17:05             ` Marek Vasut
2026-10-13  2:17               ` Wei Fang
2026-10-15 21:20                 ` Marek Vasut
2026-10-13 15:25     ` Vladimir Oltean [this message]
2026-10-16 19:09       ` Marek Vasut

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=20261013152559.cnh2i7i36hak6z3t@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=imx@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marex@nabladev.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    /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