[PATCH net-next V2 4/7] net: enetc: add i.MX952 NETC blocks control support
From: xiaoning . wang
Date: Fri Nov 27 2026 - 04:50:19 EST
From: Clark Wang <xiaoning.wang@xxxxxxx>
The NETC of i.MX952(v4.6) has two standalone ENETCs.
- ENETC 0 is on PCIe bus 0 and supports RMII and RGMII.
- ENETC 1 is on PCIe bus 1 and supports RMII, RGMII and SGMII.
Add the netc_devinfo for i.MX952 to do the following pre-boot
initialization.
1. Set the MII protocol of the links in NETCMIX according to the
'phy-mode' property of the ENETC nodes. RGMII is used by default.
The PCS configuration required by SGMII will be added separately.
2. The reset value of the ENETC 0 transmit byte credit registers
(E0TXHPTBCR and E0TXLPTBCR) is 0x5dc, which is only suitable for a
maximum frame size of 1536 bytes. When jumbo frames are used, the
byte credits are exhausted too early, so HTA has to wait for the
credits to be returned, which reduces the transmit throughput. So
set them to 0xc35, the same as the reset value of the ENETC 1
registers.
3. Configure the external PHY address in IERB LaBCR[MDIO_PHYAD_PRTAD]
for port MDIO usage.
Signed-off-by: Clark Wang <xiaoning.wang@xxxxxxx>
---
.../ethernet/freescale/enetc/netc_blk_ctrl.c | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
index 491340061b19..78a420416a1f 100644
--- a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
+++ b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
@@ -66,6 +66,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)
@@ -91,6 +93,12 @@
#define IMX94_ENETC1_LINK 4
#define IMX94_ENETC2_LINK 5
+#define IMX952_ENETC0_BUS_DEVFN 0x0
+#define IMX952_ENETC1_BUS_DEVFN 0x100
+#define IMX952_ENETC0_LINK 0
+#define IMX952_ENETC1_LINK 1
+#define IMX952_TX_BYTE_CREDIT 0xc35
+
#define NETC_ENETC_ID(a) (a)
#define NETC_TIMER_ID(a) (a)
@@ -388,6 +396,24 @@ 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);
+ u32 val;
+ int err;
+
+ /* Default setting of MII protocol */
+ val = MII_PROT(0, MII_PROT_RGMII) | MII_PROT(1, MII_PROT_RGMII);
+
+ err = imx95_netcmix_get_mii_prot(priv, &val, 0);
+ if (err)
+ return err;
+
+ 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);
@@ -756,6 +782,19 @@ 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);
+
+ /* The reset value of ENETC 0 Tx byte credits is too small for
+ * jumbo frames, so use the same value as ENETC 1.
+ */
+ netc_reg_write(priv->ierb, IERB_ETXHPTBCR(0), IMX952_TX_BYTE_CREDIT);
+ netc_reg_write(priv->ierb, IERB_ETXLPTBCR(0), IMX952_TX_BYTE_CREDIT);
+
+ return netc_ierb_enetc_mdio_phyaddr_config(pdev);
+}
+
static int netc_ierb_init(struct platform_device *pdev)
{
struct netc_blk_ctrl *priv = platform_get_drvdata(pdev);
@@ -855,6 +894,11 @@ static const struct netc_link imx94_links[] = {
{ IMX94_ENETC2_BUS_DEVFN, IMX94_ENETC2_LINK },
};
+static const struct netc_link imx952_links[] = {
+ { IMX952_ENETC0_BUS_DEVFN, IMX952_ENETC0_LINK },
+ { IMX952_ENETC1_BUS_DEVFN, IMX952_ENETC1_LINK },
+};
+
static const struct netc_devinfo imx95_devinfo = {
.flags = NETC_HAS_NETCMIX,
.links = imx95_links,
@@ -871,9 +915,18 @@ static const struct netc_devinfo imx94_devinfo = {
.ierb_init = imx94_ierb_init,
};
+static const struct netc_devinfo imx952_devinfo = {
+ .flags = NETC_HAS_NETCMIX,
+ .links = imx952_links,
+ .num_links = ARRAY_SIZE(imx952_links),
+ .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,imx94-netc-blk-ctrl", .data = &imx94_devinfo },
+ { .compatible = "nxp,imx952-netc-blk-ctrl", .data = &imx952_devinfo },
{},
};
MODULE_DEVICE_TABLE(of, netc_blk_ctrl_match);
--
2.43.0