[PATCH net-next 2/4] net: enetc: netc_blk_ctrl: add i.MX952 support

From: Frieder Schrempf

Date: Wed Nov 18 2026 - 05:39:11 EST


From: Clark Wang <xiaoning.wang@xxxxxxx>

Add NETCMIX support for i.MX952 platform. i.MX952 has two ENETC
instances, each on its own PCIe bus: ENETC0 at bus 0 devfn 0 and ENETC1
at bus 1 devfn 0. Their link MII protocol is configured through the
same NETCMIX register as on i.MX95.

The i.MX952 RM describes E0TXHPTBCR and E0TXLPTBCR as the byte-credit
limits for the ENETC transmit datapath. Both ENETC0 transmit
byte-credit registers reset to 0x5dc, which matches the RM example for
a 1536-byte maximum frame size. That is too small once jumbo frames are
enabled when the NETCMIX root clock is 133 MHz: the credit counter is
exhausted too early, which reduces transmit throughput. Program them to
0xc35, the same as port 1, during IERB initialization.

Signed-off-by: Clark Wang <xiaoning.wang@xxxxxxx>
[fs: squashed NXP a9dd7adc7e44, 68415a57f31e]
Signed-off-by: Frieder Schrempf <frieder.schrempf@xxxxxxxxxx>
---
.../net/ethernet/freescale/enetc/netc_blk_ctrl.c | 73 ++++++++++++++++++++++
1 file changed, 73 insertions(+)

diff --git a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
index 658fab31e9ed7..6e3098a0a43ee 100644
--- a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
+++ b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
@@ -67,6 +67,8 @@
#define IERB_EMDIOFAUXR 0x344
#define IERB_T0FAUXR 0x444
#define IERB_ETBCR(a) (0x300c + 0x100 * (a))
+#define IERB_ETXHPTBCR(a) (0x3070 + 0x100 * (a))
+#define IERB_ETXLPTBCR(a) (0x3074 + 0x100 * (a))
#define IERB_LBCR(a) (0x1010 + 0x40 * (a))
#define LBCR_MDIO_PHYAD_PRTAD(addr) (((addr) & 0x1f) << 8)

@@ -89,6 +91,10 @@
#define IMX94_ENETC1_LINK 4
#define IMX94_ENETC2_LINK 5

+#define IMX952_ENETC0_BUS_DEVFN 0x0
+#define IMX952_ENETC1_BUS_DEVFN 0x100
+#define IMX952_BYTE_CREDIT 0xc35
+
#define NETC_ENETC_ID(a) (a)
#define NETC_TIMER_ID(a) (a)

@@ -368,6 +374,56 @@ static int imx94_netcmix_init(struct platform_device *pdev)
return 0;
}

+static int imx952_netcmix_init(struct platform_device *pdev)
+{
+ struct netc_blk_ctrl *priv = platform_get_drvdata(pdev);
+ struct device_node *np = pdev->dev.of_node;
+ phy_interface_t interface;
+ int bus_devfn, mii_proto;
+ u32 val;
+ int err;
+
+ /* Default setting */
+ val = MII_PROT(0, MII_PROT_RGMII) | MII_PROT(1, MII_PROT_RGMII);
+
+ /* Update the link MII protocol through parsing phy-mode */
+ for_each_child_of_node_scoped(np, child) {
+ for_each_child_of_node_scoped(child, gchild) {
+ if (!of_device_is_compatible(gchild, "pci1131,e101"))
+ continue;
+
+ bus_devfn = netc_of_pci_get_bus_devfn(gchild);
+ if (bus_devfn < 0)
+ return bus_devfn;
+
+ err = of_get_phy_mode(gchild, &interface);
+ if (err)
+ continue;
+
+ mii_proto = netc_get_link_mii_protocol(interface);
+ if (mii_proto < 0)
+ return mii_proto;
+
+ switch (bus_devfn) {
+ case IMX952_ENETC0_BUS_DEVFN:
+ val = u32_replace_bits(val, mii_proto,
+ CFG_LINK_MII_PORT_0);
+ break;
+ case IMX952_ENETC1_BUS_DEVFN:
+ val = u32_replace_bits(val, mii_proto,
+ CFG_LINK_MII_PORT_1);
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+ }
+
+ netc_reg_write(priv->netcmix, IMX95_CFG_LINK_MII_PROT, val);
+
+ return 0;
+}
+
static bool netc_ierb_is_locked(struct netc_blk_ctrl *priv)
{
return !!(netc_reg_read(priv->prb, PRB_NETCRR) & NETCRR_LOCK);
@@ -783,6 +839,16 @@ static int imx94_ierb_init(struct platform_device *pdev)
return 0;
}

+static int imx952_ierb_init(struct platform_device *pdev)
+{
+ struct netc_blk_ctrl *priv = platform_get_drvdata(pdev);
+
+ netc_reg_write(priv->ierb, IERB_ETXHPTBCR(0), IMX952_BYTE_CREDIT);
+ netc_reg_write(priv->ierb, IERB_ETXLPTBCR(0), IMX952_BYTE_CREDIT);
+
+ return 0;
+}
+
static int netc_ierb_init(struct platform_device *pdev)
{
struct netc_blk_ctrl *priv = platform_get_drvdata(pdev);
@@ -882,8 +948,15 @@ static const struct netc_devinfo imx94_devinfo = {
.ierb_init = imx94_ierb_init,
};

+static const struct netc_devinfo imx952_devinfo = {
+ .flags = NETC_HAS_NETCMIX,
+ .netcmix_init = imx952_netcmix_init,
+ .ierb_init = imx952_ierb_init,
+};
+
static const struct of_device_id netc_blk_ctrl_match[] = {
{ .compatible = "nxp,imx95-netc-blk-ctrl", .data = &imx95_devinfo },
+ { .compatible = "nxp,imx952-netc-blk-ctrl", .data = &imx952_devinfo },
{ .compatible = "nxp,imx94-netc-blk-ctrl", .data = &imx94_devinfo },
{},
};

--
2.56.0