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 4/6] net: enetc: add ptp timer binding support for i.MX94
Date: Thu, 23 Oct 2025 11:35:38 -0400 [thread overview]
Message-ID: <aPpLSv1jhP19S8k/@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20251023065416.30404-5-wei.fang@nxp.com>
On Thu, Oct 23, 2025 at 02:54:14PM +0800, Wei Fang wrote:
> From: Clark Wang <xiaoning.wang@nxp.com>
>
> The i.MX94 has three PTP timers, and all standalone ENETCs can select
> one of them to bind to as their PHC. The 'ptp-timer' property is used
> to represent the PTP device of the Ethernet controller. So users can
> add 'ptp-timer' to the ENETC node to specify the PTP timer. The driver
> parses this property to bind the two hardware devices.
>
> If the "ptp-timer" property is not present, the first timer of the PCIe
> bus where the ENETC is located is used as the default bound PTP timer.
>
> Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
> .../ethernet/freescale/enetc/netc_blk_ctrl.c | 100 ++++++++++++++++++
> 1 file changed, 100 insertions(+)
>
> diff --git a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
> index 5978ea096e80..d7aee3c934d3 100644
> --- a/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
> +++ b/drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c
> @@ -66,6 +66,7 @@
> /* NETC integrated endpoint register block register */
> #define IERB_EMDIOFAUXR 0x344
> #define IERB_T0FAUXR 0x444
> +#define IERB_ETBCR(a) (0x300c + 0x100 * (a))
> #define IERB_EFAUXR(a) (0x3044 + 0x100 * (a))
> #define IERB_VFAUXR(a) (0x4004 + 0x40 * (a))
> #define FAUXR_LDID GENMASK(3, 0)
> @@ -78,10 +79,16 @@
> #define IMX94_ENETC0_BUS_DEVFN 0x100
> #define IMX94_ENETC1_BUS_DEVFN 0x140
> #define IMX94_ENETC2_BUS_DEVFN 0x180
> +#define IMX94_TIMER0_BUS_DEVFN 0x1
> +#define IMX94_TIMER1_BUS_DEVFN 0x101
> +#define IMX94_TIMER2_BUS_DEVFN 0x181
> #define IMX94_ENETC0_LINK 3
> #define IMX94_ENETC1_LINK 4
> #define IMX94_ENETC2_LINK 5
>
> +#define NETC_ENETC_ID(a) (a)
> +#define NETC_TIMER_ID(a) (a)
> +
> /* Flags for different platforms */
> #define NETC_HAS_NETCMIX BIT(0)
>
> @@ -345,6 +352,98 @@ static int imx95_ierb_init(struct platform_device *pdev)
> return 0;
> }
>
> +static int imx94_get_enetc_id(struct device_node *np)
> +{
> + int bus_devfn = netc_of_pci_get_bus_devfn(np);
> +
> + /* Parse ENETC offset */
> + switch (bus_devfn) {
> + case IMX94_ENETC0_BUS_DEVFN:
> + return NETC_ENETC_ID(0);
> + case IMX94_ENETC1_BUS_DEVFN:
> + return NETC_ENETC_ID(1);
> + case IMX94_ENETC2_BUS_DEVFN:
> + return NETC_ENETC_ID(2);
> + default:
> + return -EINVAL;
> + }
> +}
> +
> +static int imx94_get_timer_id(struct device_node *np)
> +{
> + int bus_devfn = netc_of_pci_get_bus_devfn(np);
> +
> + /* Parse NETC PTP timer ID, the timer0 is on bus 0,
> + * the timer 1 and timer2 is on bus 1.
> + */
> + switch (bus_devfn) {
> + case IMX94_TIMER0_BUS_DEVFN:
> + return NETC_TIMER_ID(0);
> + case IMX94_TIMER1_BUS_DEVFN:
> + return NETC_TIMER_ID(1);
> + case IMX94_TIMER2_BUS_DEVFN:
> + return NETC_TIMER_ID(2);
> + default:
> + return -EINVAL;
> + }
> +}
> +
> +static int imx94_enetc_update_tid(struct netc_blk_ctrl *priv,
> + struct device_node *np)
> +{
> + struct device *dev = &priv->pdev->dev;
> + struct device_node *timer_np;
> + int eid, tid;
> +
> + eid = imx94_get_enetc_id(np);
> + if (eid < 0) {
> + dev_err(dev, "Failed to get ENETC ID\n");
> + return eid;
> + }
> +
> + timer_np = of_parse_phandle(np, "ptp-timer", 0);
struct device_node *timer_np __free(device_node) = of_parse_phandle(np, "ptp-timer", 0);
Frank
> + if (!timer_np) {
> + /* If 'ptp-timer' is not present, the timer1 is the default
> + * timer of all standalone ENETCs, which is on the same PCIe
> + * bus as these ENETCs.
> + */
> + tid = NETC_TIMER_ID(1);
> + goto end;
> + }
> +
> + tid = imx94_get_timer_id(timer_np);
> + of_node_put(timer_np);
> + if (tid < 0) {
> + dev_err(dev, "Failed to get NETC Timer ID\n");
> + return tid;
> + }
> +
> +end:
> + netc_reg_write(priv->ierb, IERB_ETBCR(eid), tid);
> +
> + return 0;
> +}
> +
> +static int imx94_ierb_init(struct platform_device *pdev)
> +{
> + struct netc_blk_ctrl *priv = platform_get_drvdata(pdev);
> + struct device_node *np = pdev->dev.of_node;
> + 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_update_tid(priv, gchild);
> + if (err)
> + return err;
> + }
> + }
> +
> + return 0;
> +}
> +
> static int netc_ierb_init(struct platform_device *pdev)
> {
> struct netc_blk_ctrl *priv = platform_get_drvdata(pdev);
> @@ -441,6 +540,7 @@ static const struct netc_devinfo imx95_devinfo = {
> static const struct netc_devinfo imx94_devinfo = {
> .flags = NETC_HAS_NETCMIX,
> .netcmix_init = imx94_netcmix_init,
> + .ierb_init = imx94_ierb_init,
> };
>
> static const struct of_device_id netc_blk_ctrl_match[] = {
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-10-23 15:35 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
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 [this message]
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=aPpLSv1jhP19S8k/@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