net: enetc: add i.MX952 NETC v4.6 support
Subsystems (7)
v2 cover net: enetc: add i.MX952 NETC v4.6 support
From: Clark Wang <[email protected]>
This series adds Ethernet support for the NXP i.MX952, whose NETC is revision 4.6. Its NETC integration differs from i.MX95 and i.MX94 in the following ways:
- there are two standalone ENETCs and no switch: ENETC 0 on PCIe bus 0 (RMII/RGMII) and ENETC 1 on PCIe bus 1 (RMII/RGMII/SGMII), plus a single IEEE 1588 timer;
- the NETC system clock is 133 MHz instead of 333 MHz;
- the reset value of the ENETC 0 Tx byte credit registers is too small for jumbo frames.
The DTS patch set will be sent separately after this series is applied.
---
V2 changes:
- Add preparation patch 2 to factor out the common NETCMIX link ID lookup, 'phy-mode' to MII protocol conversion, and i.MX95-style MII protocol register setup into shared helpers, reducing duplication across i.MX95, i.MX94, and i.MX952.
- Add preparation patch 3 to share ENETC port MDIO PHY address configuration in IERB across i.MX95, i.MX94, and i.MX952.
- Rebase patch 4 due to the code base has been changed.
- Add preparation patch 5 to look up a VF's 'ptp-timer' phandle from
its PF device node via pci_physfn(), so ENETC 1's VF on i.MX952 can locate the shared PTP timer on PCIe bus 0.
- Rebase patch 6 due to the code base has been changed.
- Adjust the order of NETC_TMR_SYSCLK_133M definitions in patch 7.
V1 link: https://lore.kernel.org/all/[email protected]/
---
Clark Wang (7):
dt-bindings: net: netc-blk-ctrl: add compatible string for i.MX952
platforms
net: enetc: netc-blk-ctrl: factor out common link MII protocol helpers
net: enetc: netc-blk-ctrl: share ENETC port MDIO PHY address config
net: enetc: add i.MX952 NETC blocks control support
net: enetc: look up VF ptp-timer from its PF device node
net: enetc: add i.MX952 ENETC support
ptp: netc: use 133MHz as the default reference clock rate for i.MX952
.../bindings/net/nxp,netc-blk-ctrl.yaml | 1 + drivers/net/ethernet/freescale/enetc/enetc.c | 23 ++ .../ethernet/freescale/enetc/enetc_ethtool.c | 4 +- .../net/ethernet/freescale/enetc/enetc_hw.h | 2 + .../ethernet/freescale/enetc/netc_blk_ctrl.c | 336 ++++++++++-------- drivers/ptp/ptp_netc.c | 7 +- 6 files changed, 224 insertions(+), 149 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/7 dt-bindings: net: netc-blk-ctrl: add compatible string for i.MX952 platforms
From: Clark Wang <[email protected]>
Add the compatible string "nxp,imx952-netc-blk-ctrl" for i.MX952 platforms.
--- Documentation/devicetree/bindings/net/nxp,netc-blk-ctrl.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/nxp,netc-blk-ctrl.yaml +1 -0
@@ -23,6 +23,7 @@ properties: enum: - nxp,imx94-netc-blk-ctrl - nxp,imx95-netc-blk-ctrl + - nxp,imx952-netc-blk-ctrl reg: maxItems: 3
Signature · 1 line
2.43.0
PATCH v2 2/7 net: enetc: netc-blk-ctrl: factor out common link MII protocol helpers
In reply to [email protected]From: Clark Wang <[email protected]>
This prepares for adding i.MX952 NETC blocks control support without duplicating the NETCMIX link configuration loop.
Refactor the NETCMIX link MII protocol configuration so that common logic can be reused across platforms:
- Introduce struct netc_link and add a per-platform table to struct netc_devinfo mapping PCIe bus/devfn to NETC link IDs.
- Add netc_of_get_link_id() to replace platform-specific bus/devfn to link ID switches in both i.MX95 and i.MX94.
- Add netc_of_get_link_mii_protocol() to share the 'phy-mode' to MII protocol parsing between imx94_link_config() and the IMX95-style NETCMIX configuration path.
- Factor out imx95_netcmix_get_mii_prot() from imx95_netcmix_init().
--- .../ethernet/freescale/enetc/netc_blk_ctrl.c | 150 +++++++++++------- 1 file changed, 93 insertions(+), 57 deletions(-)
drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c +93 -57
@@ -32,12 +32,11 @@#define IO_VAR (port, var) (((var) & 0xf) << ((port) << 2))#define IMX95_CFG_LINK_MII_PROT 0x4 -#define CFG_LINK_MII_PORT_0 GENMASK(3, 0) -#define CFG_LINK_MII_PORT_1 GENMASK(7, 4)#define MII_PROT_MII 0x0#define MII_PROT_RMII 0x1#define MII_PROT_RGMII 0x2#define MII_PROT_SERIAL 0x3 +#define MII_PROT_MASK (port) (GENMASK(3, 0) << ((port) << 2))#define MII_PROT (port, prot) (((prot) & 0xf) << ((port) << 2))#define IMX95_CFG_LINK_PCS_PROT (a) (0x8 + (a) * 4)
@@ -78,6 +77,9 @@#define IMX95_ENETC0_BUS_DEVFN 0x0#define IMX95_ENETC1_BUS_DEVFN 0x40#define IMX95_ENETC2_BUS_DEVFN 0x80 +#define IMX95_ENETC0_LINK 0 +#define IMX95_ENETC1_LINK 1 +#define IMX95_ENETC2_LINK 2#define IMX94_ENETC0_BUS_DEVFN 0x100#define IMX94_ENETC1_BUS_DEVFN 0x140
@@ -95,8 +97,15 @@/* Flags for different platforms */ #define NETC_HAS_NETCMIX BIT(0) +struct netc_link { +u32 bus_devfn; +u8 link_id; +}; +struct netc_devinfo {u32 flags; +const struct netc_link *links; +unsigned int num_links;int (*netcmix_init)(struct platform_device *pdev);int (*ierb_init)(struct platform_device *pdev); };
@@ -156,18 +165,44 @@ static int netc_get_link_mii_protocol(phy_interface_t interface) } } -static int imx95_netcmix_init (struct platform_device *pdev) +static int netc_of_get_link_mii_protocol (struct device_node *np) { -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 of MII protocol */ - val =MII_PROT (0 ,MII_PROT_RGMII ) |MII_PROT (1 ,MII_PROT_RGMII ) | -MII_PROT (2 ,MII_PROT_SERIAL ); +/* 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 -ENODEV ; + +return netc_get_link_mii_protocol (interface); +} + +static int netc_of_get_link_id (struct netc_blk_ctrl *priv, +struct device_node *np) +{ +const struct netc_devinfo *devinfo = priv->devinfo; +unsigned int i; +int bus_devfn; + + bus_devfn =netc_of_pci_get_bus_devfn (np); +if (bus_devfn <0 ) +return bus_devfn; + +for (i =0 ; i < devinfo->num_links; i++) { +if (devinfo->links[i].bus_devfn == bus_devfn) +return devinfo->links[i].link_id; + } + +return -EINVAL ; +} + +static int imx95_netcmix_get_mii_prot (struct netc_blk_ctrl *priv,u32 *val, +u32 fixed_links_mask) +{ +struct device_node *np = priv->pdev->dev.of_node; +int link_id, mii_proto; +u32 reg = *val;/* Update the link MII protocol through parsing phy-mode */ for_each_available_child_of_node_scoped (np, child) {
@@ -175,36 +210,43 @@ static int imx95_netcmix_init(struct platform_device *pdev)if (!of_device_is_compatible (gchild,"pci1131,e101" ))continue ; - bus_devfn =netc_of_pci_get_bus_devfn (gchild); -if (bus_devfn <0 ) -return -EINVAL ; + link_id =netc_of_get_link_id (priv, gchild); +if (link_id <0 ) +return link_id; -if (bus_devfn ==IMX95_ENETC2_BUS_DEVFN ) +if (fixed_links_mask &BIT (link_id))continue ; - err =of_get_phy_mode (gchild, &interface); -if (err) + mii_proto =netc_of_get_link_mii_protocol (gchild); +if (mii_proto == -ENODEV )continue ; - - mii_proto =netc_get_link_mii_protocol (interface);if (mii_proto <0 ) -return -EINVAL ; +return mii_proto; -switch (bus_devfn) { -case IMX95_ENETC0_BUS_DEVFN : - val =u32_replace_bits (val, mii_proto, -CFG_LINK_MII_PORT_0 ); -break ; -case IMX95_ENETC1_BUS_DEVFN : - val =u32_replace_bits (val, mii_proto, -CFG_LINK_MII_PORT_1 ); -break ; -default : -return -EINVAL ; - } + reg &= ~MII_PROT_MASK (link_id); + reg |=MII_PROT (link_id, mii_proto); } } + *val = reg; + +return 0 ; +} + +static int imx95_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 ) | +MII_PROT (2 ,MII_PROT_SERIAL ); + + err =imx95_netcmix_get_mii_prot (priv, &val,BIT (IMX95_ENETC2_LINK )); +if (err) +return err; +/* Configure Link I/O variant */ netc_reg_write (priv->netcmix,IMX95_CFG_LINK_IO_VAR ,IO_VAR (2 ,IO_VAR_16FF_16G_SERDES ));
@@ -216,37 +258,15 @@ 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)) + mii_proto =netc_of_get_link_mii_protocol (np); +if (mii_proto == -ENODEV )return 0 ; - - mii_proto =netc_get_link_mii_protocol (interface);if (mii_proto <0 )return mii_proto;
@@ -264,7 +284,7 @@ static int imx94_enetc_link_config(struct netc_blk_ctrl *priv,struct device_node *np, bool *enetc0_en) { - int link_id = imx94_enetc_get_link_id(np); + int link_id = netc_of_get_link_id(priv, np);if (link_id <0 )return link_id;
@@ -870,14 +890,30 @@ static int netc_prb_check_error(struct netc_blk_ctrl *priv)return 0 ; } +static const struct netc_link imx95_links[] = { + {IMX95_ENETC0_BUS_DEVFN ,IMX95_ENETC0_LINK }, + {IMX95_ENETC1_BUS_DEVFN ,IMX95_ENETC1_LINK }, + {IMX95_ENETC2_BUS_DEVFN ,IMX95_ENETC2_LINK }, +}; + +static const struct netc_link imx94_links[] = { + {IMX94_ENETC0_BUS_DEVFN ,IMX94_ENETC0_LINK }, + {IMX94_ENETC1_BUS_DEVFN ,IMX94_ENETC1_LINK }, + {IMX94_ENETC2_BUS_DEVFN ,IMX94_ENETC2_LINK }, +}; +static const struct netc_devinfo imx95_devinfo = { .flags =NETC_HAS_NETCMIX , + .links = imx95_links, + .num_links =ARRAY_SIZE (imx95_links), .netcmix_init = imx95_netcmix_init, .ierb_init = imx95_ierb_init, };static const struct netc_devinfo imx94_devinfo = { .flags =NETC_HAS_NETCMIX , + .links = imx94_links, + .num_links =ARRAY_SIZE (imx94_links), .netcmix_init = imx94_netcmix_init, .ierb_init = imx94_ierb_init, };
Signature · 1 line
2.43.0
Wei Fang
maintainerRE: [PATCH net-next V2 2/7] net: enetc: netc-blk-ctrl: factor out common link MII protocol helpers
drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c line 82
Quoted 8 lines
#define
IMX95_CFG_LINK_PCS_PROT(a)(0x8+ (a) * 4)drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c +3
-0@@ -78,6 +77,9 @@#define IMX95_ENETC0_BUS_DEVFN 0x0#define IMX95_ENETC1_BUS_DEVFN 0x40#define IMX95_ENETC2_BUS_DEVFN 0x80 +#define IMX95_ENETC0_LINK 0 +#define IMX95_ENETC1_LINK 1 +#define IMX95_ENETC2_LINK 2
It can be simplified as follows:
#define IMX95_ENETC_LINK(a) (a)
Also, IMX94_ENETC0/1/2_LINK can be refined as follows:
#define IMX94_ENETC_LINK(a) (3 + (a))
drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c line 103
Quoted 11 lines
drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c +4
-0#define IMX94_ENETC0_BUS_DEVFN 0x100#define IMX94_ENETC1_BUS_DEVFN 0x140@@ -95,8 +97,15 @@/* Flags for different platforms */ #define NETC_HAS_NETCMIX BIT(0) +struct netc_link { +u32 bus_devfn; +u8 link_id; +};
This only applies to ENETC links. Would it be more appropriate to name it netc_enetc_link?
PATCH v2 3/7 net: enetc: netc-blk-ctrl: share ENETC port MDIO PHY address config
In reply to [email protected]From: Clark Wang <[email protected]>
Both i.MX95 and i.MX94 duplicate the same logic to parse an ENETC node's port MDIO PHY address, validate it against the central EMDIO PHY mask, and program IERB_LBCR[MDIO_PHYAD_PRTAD] using a platform-specific bus/devfn switch.
Factor out netc_enetc_mdio_phyaddr_config() using netc_of_get_link_id() to map an ENETC node to its link ID, and add netc_ierb_enetc_mdio_phyaddr_config() to walk ENETC nodes for platforms that only need ENETC port MDIO PHY address setup in IERB.
This prepares for i.MX952 support, which also needs port MDIO PHY address configuration in IERB.
--- .../ethernet/freescale/enetc/netc_blk_ctrl.c | 131 ++++++------------ 1 file changed, 42 insertions(+), 89 deletions(-)
drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c +42 -89
@@ -482,13 +482,47 @@ static int netc_get_emdio_phy_mask(struct device_node *np, u32 *phy_mask)return 0 ; } -static int imx95_enetc_mdio_phyaddr_config (struct platform_device *pdev) +static int netc_enetc_mdio_phyaddr_config (struct netc_blk_ctrl *priv, +struct device_node *np, +u32 phy_mask) +{ +struct device *dev = &priv->pdev->dev; +int link_id, addr; + + link_id =netc_of_get_link_id (priv, np); +if (link_id <0 ) { +dev_err (dev,"Failed to get link ID\n" ); +return link_id; + } + + addr =netc_get_phy_addr (np); +if (addr <0 ) { +if (addr == -ENODEV ) +return 0 ; + +dev_err (dev,"Failed to get PHY address\n" ); +return addr; + } + +if (phy_mask &BIT (addr)) { +dev_err (dev, +"Find same PHY address in EMDIO and ENETC node\n" ); +return -EINVAL ; + } + +netc_reg_write (priv->ierb,IERB_LBCR (link_id), +LBCR_MDIO_PHYAD_PRTAD (addr)); + +return 0 ; +} + +static int netc_ierb_enetc_mdio_phyaddr_config (struct platform_device *pdev) {struct netc_blk_ctrl *priv =platform_get_drvdata (pdev);struct device_node *np = pdev->dev.of_node;struct device *dev = &pdev->dev; -int bus_devfn, addr, err;u32 phy_mask =0 ; +int err; err =netc_get_emdio_phy_mask (np, &phy_mask);if (err) {
@@ -505,43 +539,10 @@ static int imx95_enetc_mdio_phyaddr_config(struct platform_device *pdev)if (!of_device_is_compatible (gchild,"pci1131,e101" ))continue ; - bus_devfn =netc_of_pci_get_bus_devfn (gchild); -if (bus_devfn <0 ) { -dev_err (dev,"Failed to get BDF number\n" ); -return bus_devfn; - } - - addr =netc_get_phy_addr (gchild); -if (addr <0 ) { -if (addr == -ENODEV ) -continue ; - -dev_err (dev,"Failed to get PHY address\n" ); -return addr; - } - -if (phy_mask &BIT (addr)) { -dev_err (dev, -"Find same PHY address in EMDIO and ENETC node\n" ); -return -EINVAL ; - } - -switch (bus_devfn) { -case IMX95_ENETC0_BUS_DEVFN : -netc_reg_write (priv->ierb,IERB_LBCR (0 ), -LBCR_MDIO_PHYAD_PRTAD (addr)); -break ; -case IMX95_ENETC1_BUS_DEVFN : -netc_reg_write (priv->ierb,IERB_LBCR (1 ), -LBCR_MDIO_PHYAD_PRTAD (addr)); -break ; -case IMX95_ENETC2_BUS_DEVFN : -netc_reg_write (priv->ierb,IERB_LBCR (2 ), -LBCR_MDIO_PHYAD_PRTAD (addr)); -break ; -default : -break ; - } + err =netc_enetc_mdio_phyaddr_config (priv, gchild, + phy_mask); +if (err) +return err; } }
@@ -575,7 +576,7 @@ static int imx95_ierb_init(struct platform_device *pdev)/* NETC TIMER */ netc_reg_write (priv->ierb,IERB_T0FAUXR ,7 ); -return imx95_enetc_mdio_phyaddr_config (pdev); +return netc_ierb_enetc_mdio_phyaddr_config (pdev); }static int imx94_get_enetc_id (struct device_node *np)
@@ -650,54 +651,6 @@ static int imx94_enetc_update_tid(struct netc_blk_ctrl *priv,return 0 ; } -static int imx94_enetc_mdio_phyaddr_config (struct netc_blk_ctrl *priv, -struct device_node *np, -u32 phy_mask) -{ -struct device *dev = &priv->pdev->dev; -int bus_devfn, addr; - - bus_devfn =netc_of_pci_get_bus_devfn (np); -if (bus_devfn <0 ) { -dev_err (dev,"Failed to get BDF number\n" ); -return bus_devfn; - } - - addr =netc_get_phy_addr (np); -if (addr <0 ) { -if (addr == -ENODEV ) -return 0 ; - -dev_err (dev,"Failed to get PHY address\n" ); -return addr; - } - -if (phy_mask &BIT (addr)) { -dev_err (dev, -"Find same PHY address in EMDIO and ENETC node\n" ); -return -EINVAL ; - } - -switch (bus_devfn) { -case IMX94_ENETC0_BUS_DEVFN : -netc_reg_write (priv->ierb,IERB_LBCR (IMX94_ENETC0_LINK ), -LBCR_MDIO_PHYAD_PRTAD (addr)); -break ; -case IMX94_ENETC1_BUS_DEVFN : -netc_reg_write (priv->ierb,IERB_LBCR (IMX94_ENETC1_LINK ), -LBCR_MDIO_PHYAD_PRTAD (addr)); -break ; -case IMX94_ENETC2_BUS_DEVFN : -netc_reg_write (priv->ierb,IERB_LBCR (IMX94_ENETC2_LINK ), -LBCR_MDIO_PHYAD_PRTAD (addr)); -break ; -default : -break ; - } - -return 0 ; -} -static int imx94_ierb_enetc_init (struct netc_blk_ctrl *priv,struct device_node *np,u32 phy_mask)
@@ -708,7 +661,7 @@ static int imx94_ierb_enetc_init(struct netc_blk_ctrl *priv,if (err)return err; -return imx94_enetc_mdio_phyaddr_config (priv, np, phy_mask); +return netc_enetc_mdio_phyaddr_config (priv, np, phy_mask); } static int imx94_switch_mdio_phyaddr_config(struct netc_blk_ctrl *priv,
Signature · 1 line
2.43.0
PATCH v2 4/7 net: enetc: add i.MX952 NETC blocks control support
In reply to [email protected]From: Clark Wang <[email protected]>
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.
--- .../ethernet/freescale/enetc/netc_blk_ctrl.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/net/ethernet/freescale/enetc/netc_blk_ctrl.c +53 -0
@@ -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);
Signature · 1 line
2.43.0
PATCH v2 5/7 net: enetc: look up VF ptp-timer from its PF device node
In reply to [email protected]From: Clark Wang <[email protected]>
ENETC VFs do not have their own DT nodes, so enetc_get_phc_index() currently skips the 'ptp-timer' phandle lookup for VFs and always falls back to enetc_get_phc_index_by_pdev(), which only searches the VF's own PCI domain and bus.
On platforms where a PF with VFs uses a shared PTP timer on a different PCI domain/bus via the 'ptp-timer' property (such as ENETC 1 on i.MX952), this causes the VF to fail to find the PHC and fall back to software TX timestamping.
Use pci_physfn() to obtain the PF's device_node so VFs inherit the 'ptp-timer' phandle configured on their PF before falling back to the PCI bus lookup.
--- drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +2 -1
@@ -1168,7 +1168,8 @@ static int enetc_get_phc_index_by_pdev(struct enetc_si *si)static int enetc_get_phc_index (struct enetc_si *si) { -struct device_node *np = si->pdev->dev.of_node; +struct pci_dev *pdev =pci_physfn (si->pdev); +struct device_node *np = pdev->dev.of_node;struct device_node *timer_np;int phc_index;
Signature · 1 line
2.43.0
PATCH v2 6/7 net: enetc: add i.MX952 ENETC support
In reply to [email protected]From: Clark Wang <[email protected]>
The driver gets the driver data of ENETC based on the IP revision, so the ENETC PF and VF fail to probe on i.MX952 because its revision(v4.6) is not present in enetc_info.
Add the v4.6 entries to enetc_info.
Unlike i.MX95 and i.MX94, the NETC system clock of i.MX952 is 133MHz rather than 333MHz. So add the new PF and VF driver data with ENETC_CLK_133M for ENETC v4.6.
In addition, similar to i.MX94, the PTP timer is function 1 of device 0 on the PCIe bus of ENETC 0, so update enetc_get_phc_index_by_pdev() to support getting the PHC index for ENETC v4.6. ENETC 1 resides on a separate PCIe bus and uses the 'ptp-timer' DT property to reference the shared timer (which its VF also inherits via pci_physfn()).
--- drivers/net/ethernet/freescale/enetc/enetc.c | 23 +++++++++++++++++++ .../ethernet/freescale/enetc/enetc_ethtool.c | 1 + .../net/ethernet/freescale/enetc/enetc_hw.h | 2 ++ 3 files changed, 26 insertions(+)
drivers/net/ethernet/freescale/enetc/enetc.c +23 -0
@@ -3820,6 +3820,14 @@ static const struct enetc_drvdata enetc4_pf_data = { .eth_ops = &enetc4_pf_ethtool_ops, }; +static const struct enetc_drvdata enetc4_6_pf_data = { + .sysclk_freq =ENETC_CLK_133M , + .tx_csum = true, + .max_frags =ENETC4_MAX_SKB_FRAGS , + .pmac_offset =ENETC4_PMAC_OFFSET , + .eth_ops = &enetc4_pf_ethtool_ops, +}; +static const struct enetc_drvdata enetc4_ppm_data = { .sysclk_freq =ENETC_CLK_333M , .tx_csum = true,
@@ -3854,6 +3862,13 @@ static const struct enetc_drvdata enetc4_s32n79_vf_data = { .eth_ops = &enetc_vf_ethtool_ops, }; +static const struct enetc_drvdata enetc4_6_vf_data = { + .sysclk_freq =ENETC_CLK_133M , + .tx_csum = true, + .max_frags =ENETC4_MAX_SKB_FRAGS , + .eth_ops = &enetc_vf_ethtool_ops, +}; +static const struct enetc_platform_info enetc_info[] = { { .revision =ENETC_REV_1_0 , .dev_id =ENETC_DEV_ID_PF ,
@@ -3896,6 +3911,14 @@ static const struct enetc_platform_info enetc_info[] = { .dev_id = NXP_ENETC_VF_DEV_ID, .data = &enetc4_s32n79_vf_data, }, + { .revision = ENETC_REV_4_6, + .dev_id = NXP_ENETC_PF_DEV_ID, + .data = &enetc4_6_pf_data, + }, + { .revision = ENETC_REV_4_6, + .dev_id = NXP_ENETC_VF_DEV_ID, + .data = &enetc4_6_vf_data, + }, };int enetc_get_driver_data (struct enetc_si *si)
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +1 -0
@@ -1149,6 +1149,7 @@ static int enetc_get_phc_index_by_pdev(struct enetc_si *si) devfn =PCI_DEVFN (24 ,0 );break ;case ENETC_REV_4_3 : +case ENETC_REV_4_6 : devfn =PCI_DEVFN (0 ,1 );break ;default :
drivers/net/ethernet/freescale/enetc/enetc_hw.h +2 -0
@@ -415,6 +415,7 @@ enum enetc_bdr_type {TX, RX};#define ENETC_REV_4_1 0X0401#define ENETC_REV_4_3 0x0403#define ENETC_REV_4_4 0x0404 +#define ENETC_REV_4_6 0x0406#define ENETC_G_EIPBRR1 0x0bfc#define ENETC_G_EPFBLPR (n) (0xd00 + 4 * (n))
@@ -1049,6 +1050,7 @@ struct enetc_cbd {u8 status_flags; }; +#define ENETC_CLK_133M 133000000ULL#define ENETC_CLK_333M 333000000ULL#define ENETC_CLK_400M 400000000ULL#define ENETC_CLK_500M 500000000ULL
Signature · 1 line
2.43.0
PATCH v2 7/7 ptp: netc: use 133MHz as the default reference clock rate for i.MX952
In reply to [email protected]From: Clark Wang <[email protected]>
If the 'clocks' property is not present in the DT node, the NETC system clock is selected as the reference clock of the NETC Timer, and the driver assumes that its rate is 333MHz. However, the NETC system clock of i.MX952 (NETC v4.6) is 133MHz. Therefore, use 133MHz as the default reference clock rate for i.MX952.
--- drivers/ptp/ptp_netc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/ptp/ptp_netc.c +6 -1
@@ -72,6 +72,7 @@#define NETC_GLOBAL_IPBRR0 0xbf8#define IPBRR0_IP_REV GENMASK(15, 0)#define NETC_REV_4_1 0x0401 +#define NETC_REV_4_6 0x0406#define NETC_TMR_FIPER_NUM 3#define NETC_TMR_INVALID_CHANNEL NETC_TMR_FIPER_NUM
@@ -87,6 +88,7 @@#define NETC_TMR_SYSTEM_CLK 1/* enet_clk_root/2, from CCM */ #define NETC_TMR_EXT_OSC 2/* tmr_1588_clk, from IO pins */ +#define NETC_TMR_SYSCLK_133M 133333333U#define NETC_TMR_SYSCLK_333M 333333333Uenum netc_pp_type {
@@ -858,7 +860,10 @@ static int netc_timer_get_reference_clk_source(struct netc_timer *priv)/* Select NETC system clock as the reference clock by default */ priv->clk_select =NETC_TMR_SYSTEM_CLK ; - priv->clk_freq =NETC_TMR_SYSCLK_333M ; +if (priv->revision ==NETC_REV_4_6 ) + priv->clk_freq =NETC_TMR_SYSCLK_133M ; +else + priv->clk_freq =NETC_TMR_SYSCLK_333M ;/* Update the clock source of the reference clock if the clock * is specified in DT node.
Signature · 1 line
2.43.0