public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Wei Fang <wei.fang@nxp.com>
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	claudiu.manoil@nxp.com, vladimir.oltean@nxp.com,
	xiaoning.wang@nxp.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, richardcochran@gmail.com, imx@lists.linux.dev,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v2 net-next 3/6] net: enetc: add preliminary i.MX94 NETC blocks control support
Date: Thu, 23 Oct 2025 11:32:06 -0400	[thread overview]
Message-ID: <aPpKdjWPhzHEDR3I@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20251023065416.30404-4-wei.fang@nxp.com>

On Thu, Oct 23, 2025 at 02:54:13PM +0800, Wei Fang wrote:
> NETC blocks control is used for warm reset and pre-boot initialization.
> Different versions of NETC blocks control are not exactly the same. We
> need to add corresponding netc_devinfo data for each version. The NETC
> version of i.MX94 is v4.3, which is different from i.MX95. Currently,
> the patch adds the following configurations for ENETCs.
>
> 1. Set the link's MII protocol.
> 2. ENETC 0 (MAC 3) and the switch port 2 (MAC 2) share the same parallel
> interface, but due to SoC constraint, they cannot be used simultaneously.
> Since the switch is not supported yet, so the interface is assigned to
> ENETC 0 by default.
>
> The switch configuration will be added separately in a subsequent patch.
>
> Signed-off-by: Wei Fang <wei.fang@nxp.com>

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> ---
>  .../ethernet/freescale/enetc/netc_blk_ctrl.c  | 104 ++++++++++++++++++
>  1 file changed, 104 insertions(+)
>
> diff --git a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
> index bcb8eefeb93c..5978ea096e80 100644
> --- a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
> +++ b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
> @@ -47,6 +47,13 @@
>  #define PCS_PROT_SFI			BIT(4)
>  #define PCS_PROT_10G_SXGMII		BIT(6)
>
> +#define IMX94_EXT_PIN_CONTROL		0x10
> +#define  MAC2_MAC3_SEL			BIT(1)
> +
> +#define IMX94_NETC_LINK_CFG(a)		(0x4c + (a) * 4)
> +#define  NETC_LINK_CFG_MII_PROT		GENMASK(3, 0)
> +#define  NETC_LINK_CFG_IO_VAR		GENMASK(19, 16)
> +
>  /* NETC privileged register block register */
>  #define PRB_NETCRR			0x100
>  #define  NETCRR_SR			BIT(0)
> @@ -68,6 +75,13 @@
>  #define IMX95_ENETC1_BUS_DEVFN		0x40
>  #define IMX95_ENETC2_BUS_DEVFN		0x80
>
> +#define IMX94_ENETC0_BUS_DEVFN		0x100
> +#define IMX94_ENETC1_BUS_DEVFN		0x140
> +#define IMX94_ENETC2_BUS_DEVFN		0x180
> +#define IMX94_ENETC0_LINK		3
> +#define IMX94_ENETC1_LINK		4
> +#define IMX94_ENETC2_LINK		5
> +
>  /* Flags for different platforms */
>  #define NETC_HAS_NETCMIX		BIT(0)
>
> @@ -192,6 +206,90 @@ static int imx95_netcmix_init(struct platform_device *pdev)
>  	return 0;
>  }
>
> +static int imx94_enetc_get_link_id(struct device_node *np)
> +{
> +	int bus_devfn = netc_of_pci_get_bus_devfn(np);
> +
> +	/* Parse ENETC link number */
> +	switch (bus_devfn) {
> +	case IMX94_ENETC0_BUS_DEVFN:
> +		return IMX94_ENETC0_LINK;
> +	case IMX94_ENETC1_BUS_DEVFN:
> +		return IMX94_ENETC1_LINK;
> +	case IMX94_ENETC2_BUS_DEVFN:
> +		return IMX94_ENETC2_LINK;
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
> +static int imx94_link_config(struct netc_blk_ctrl *priv,
> +			     struct device_node *np, int link_id)
> +{
> +	phy_interface_t interface;
> +	int mii_proto;
> +	u32 val;
> +
> +	/* The node may be disabled and does not have a 'phy-mode'
> +	 * or 'phy-connection-type' property.
> +	 */
> +	if (of_get_phy_mode(np, &interface))
> +		return 0;
> +
> +	mii_proto = netc_get_link_mii_protocol(interface);
> +	if (mii_proto < 0)
> +		return mii_proto;
> +
> +	val = mii_proto & NETC_LINK_CFG_MII_PROT;
> +	if (val == MII_PROT_SERIAL)
> +		val = u32_replace_bits(val, IO_VAR_16FF_16G_SERDES,
> +				       NETC_LINK_CFG_IO_VAR);
> +
> +	netc_reg_write(priv->netcmix, IMX94_NETC_LINK_CFG(link_id), val);
> +
> +	return 0;
> +}
> +
> +static int imx94_enetc_link_config(struct netc_blk_ctrl *priv,
> +				   struct device_node *np)
> +{
> +	int link_id = imx94_enetc_get_link_id(np);
> +
> +	if (link_id < 0)
> +		return link_id;
> +
> +	return imx94_link_config(priv, np, link_id);
> +}
> +
> +static int imx94_netcmix_init(struct platform_device *pdev)
> +{
> +	struct netc_blk_ctrl *priv = platform_get_drvdata(pdev);
> +	struct device_node *np = pdev->dev.of_node;
> +	u32 val;
> +	int err;
> +
> +	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;
> +
> +			err = imx94_enetc_link_config(priv, gchild);
> +			if (err)
> +				return err;
> +		}
> +	}
> +
> +	/* ENETC 0 and switch port 2 share the same parallel interface.
> +	 * Currently, the switch is not supported, so this interface is
> +	 * used by ENETC 0 by default.
> +	 */
> +	val = netc_reg_read(priv->netcmix, IMX94_EXT_PIN_CONTROL);
> +	val |= MAC2_MAC3_SEL;
> +	netc_reg_write(priv->netcmix, IMX94_EXT_PIN_CONTROL, val);
> +
> +	return 0;
> +}
> +
>  static bool netc_ierb_is_locked(struct netc_blk_ctrl *priv)
>  {
>  	return !!(netc_reg_read(priv->prb, PRB_NETCRR) & NETCRR_LOCK);
> @@ -340,8 +438,14 @@ static const struct netc_devinfo imx95_devinfo = {
>  	.ierb_init = imx95_ierb_init,
>  };
>
> +static const struct netc_devinfo imx94_devinfo = {
> +	.flags = NETC_HAS_NETCMIX,
> +	.netcmix_init = imx94_netcmix_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 },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, netc_blk_ctrl_match);
> --
> 2.34.1
>

  reply	other threads:[~2025-10-23 15:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23  6:54 [PATCH v2 net-next 0/6] net: enetc: Add i.MX94 ENETC support Wei Fang
2025-10-23  6:54 ` [PATCH v2 net-next 1/6] dt-bindings: net: netc-blk-ctrl: add compatible string for i.MX94 platforms Wei Fang
2025-10-23  6:54 ` [PATCH v2 net-next 2/6] dt-bindings: net: enetc: add compatible string for ENETC with pseduo MAC Wei Fang
2025-10-23  6:54 ` [PATCH v2 net-next 3/6] net: enetc: add preliminary i.MX94 NETC blocks control support Wei Fang
2025-10-23 15:32   ` Frank Li [this message]
2025-10-23  6:54 ` [PATCH v2 net-next 4/6] net: enetc: add ptp timer binding support for i.MX94 Wei Fang
2025-10-23 15:35   ` Frank Li
2025-10-23  6:54 ` [PATCH v2 net-next 5/6] net: enetc: add basic support for the ENETC with pseudo MAC " Wei Fang
2025-10-23  6:54 ` [PATCH v2 net-next 6/6] net: enetc: add standalone ENETC support " Wei Fang
2025-10-23 15:39   ` Frank Li

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=aPpKdjWPhzHEDR3I@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=imx@lists.linux.dev \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=robh@kernel.org \
    --cc=vladimir.oltean@nxp.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