linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM
@ 2021-07-28 11:51 Joakim Zhang
  2021-07-28 11:51 ` [PATCH V2 net-next 1/7] dt-bindings: net: fsl,fec: update compatible items Joakim Zhang
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Joakim Zhang @ 2021-07-28 11:51 UTC (permalink / raw)
  To: davem, kuba, robh+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, netdev, devicetree, linux-kernel

This patch set adds supports for i.MX8MQ and i.MX8QM, both of them extend new features.

ChangeLogs:
V1->V2:
	* rebase on schema binding, and update dts compatible string.
	* use generic ethernet controller property for MAC internal RGMII clock delay
	  rx-internal-delay-ps and tx-internal-delay-ps

Fugang Duan (3):
  net: fec: add imx8mq and imx8qm new versions support
  net: fec: add eee mode tx lpi support
  net: fec: add MAC internal delayed clock feature support

Joakim Zhang (4):
  dt-bindings: net: fsl,fec: update compatible items
  dt-bindings: net: fsl,fec: add RGMII internal clock delay
  arm64: dts: imx8m: add "fsl,imx8mq-fec" compatible string for FEC
  arm64: dts: imx8qxp: add "fsl,imx8qm-fec" compatible string for FEC

 .../devicetree/bindings/net/fsl,fec.yaml      |  27 ++++
 arch/arm64/boot/dts/freescale/imx8mm.dtsi     |   2 +-
 arch/arm64/boot/dts/freescale/imx8mn.dtsi     |   2 +-
 .../boot/dts/freescale/imx8qxp-ss-conn.dtsi   |   4 +-
 drivers/net/ethernet/freescale/fec.h          |  25 +++
 drivers/net/ethernet/freescale/fec_main.c     | 146 ++++++++++++++++++
 6 files changed, 202 insertions(+), 4 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V2 net-next 1/7] dt-bindings: net: fsl,fec: update compatible items
  2021-07-28 11:51 [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM Joakim Zhang
@ 2021-07-28 11:51 ` Joakim Zhang
  2021-07-28 11:51 ` [PATCH V2 net-next 2/7] dt-bindings: net: fsl,fec: add RGMII internal clock delay Joakim Zhang
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Joakim Zhang @ 2021-07-28 11:51 UTC (permalink / raw)
  To: davem, kuba, robh+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, netdev, devicetree, linux-kernel

Add more compatible items for i.MX8/8M platforms.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 .../devicetree/bindings/net/fsl,fec.yaml       | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/fsl,fec.yaml b/Documentation/devicetree/bindings/net/fsl,fec.yaml
index dbcbec95fc9e..b14e0e7c1e42 100644
--- a/Documentation/devicetree/bindings/net/fsl,fec.yaml
+++ b/Documentation/devicetree/bindings/net/fsl,fec.yaml
@@ -40,6 +40,24 @@ properties:
           - enum:
               - fsl,imx7d-fec
           - const: fsl,imx6sx-fec
+      - items:
+          - const: fsl,imx8mq-fec
+          - const: fsl,imx6sx-fec
+      - items:
+          - enum:
+              - fsl,imx8mm-fec
+              - fsl,imx8mn-fec
+              - fsl,imx8mp-fec
+          - const: fsl,imx8mq-fec
+          - const: fsl,imx6sx-fec
+      - items:
+          - const: fsl,imx8qm-fec
+          - const: fsl,imx6sx-fec
+      - items:
+          - enum:
+              - fsl,imx8qxp-fec
+          - const: fsl,imx8qm-fec
+          - const: fsl,imx6sx-fec
 
   reg:
     maxItems: 1
-- 
2.17.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V2 net-next 2/7] dt-bindings: net: fsl,fec: add RGMII internal clock delay
  2021-07-28 11:51 [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM Joakim Zhang
  2021-07-28 11:51 ` [PATCH V2 net-next 1/7] dt-bindings: net: fsl,fec: update compatible items Joakim Zhang
@ 2021-07-28 11:51 ` Joakim Zhang
  2021-07-28 14:08   ` Andrew Lunn
  2021-07-28 11:51 ` [PATCH V2 net-next 3/7] net: fec: add imx8mq and imx8qm new versions support Joakim Zhang
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Joakim Zhang @ 2021-07-28 11:51 UTC (permalink / raw)
  To: davem, kuba, robh+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, netdev, devicetree, linux-kernel

Add RGMII internal clock delay for FEC controller.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 Documentation/devicetree/bindings/net/fsl,fec.yaml | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/fsl,fec.yaml b/Documentation/devicetree/bindings/net/fsl,fec.yaml
index b14e0e7c1e42..eca41443fcce 100644
--- a/Documentation/devicetree/bindings/net/fsl,fec.yaml
+++ b/Documentation/devicetree/bindings/net/fsl,fec.yaml
@@ -96,6 +96,8 @@ properties:
       SOC internal PLL.
       The "enet_out"(option), output clock for external device, like supply clock
       for PHY. The clock is required if PHY clock source from SOC.
+      The "enet_2x_txclk"(option), for RGMII sampling clock which fixed at 250Mhz.
+      The clock is required if SoC RGMII enable clock delay.
 
   clock-names:
     minItems: 2
@@ -107,6 +109,7 @@ properties:
         - ptp
         - enet_clk_ref
         - enet_out
+        - enet_2x_txclk
 
   phy-mode: true
 
@@ -118,6 +121,12 @@ properties:
 
   mac-address: true
 
+  tx-internal-delay-ps:
+    enum: [0, 2000]
+
+  rx-internal-delay-ps:
+    enum: [0, 2000]
+
   phy-supply:
     description:
       Regulator that powers the Ethernet PHY.
-- 
2.17.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V2 net-next 3/7] net: fec: add imx8mq and imx8qm new versions support
  2021-07-28 11:51 [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM Joakim Zhang
  2021-07-28 11:51 ` [PATCH V2 net-next 1/7] dt-bindings: net: fsl,fec: update compatible items Joakim Zhang
  2021-07-28 11:51 ` [PATCH V2 net-next 2/7] dt-bindings: net: fsl,fec: add RGMII internal clock delay Joakim Zhang
@ 2021-07-28 11:51 ` Joakim Zhang
  2021-07-28 11:52 ` [PATCH V2 net-next 4/7] net: fec: add eee mode tx lpi support Joakim Zhang
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Joakim Zhang @ 2021-07-28 11:51 UTC (permalink / raw)
  To: davem, kuba, robh+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, netdev, devicetree, linux-kernel

From: Fugang Duan <fugang.duan@nxp.com>

The ENET of imx8mq and imx8qm are basically the same as imx6sx,
but they have new features support based on imx6sx, like:
- imx8mq: supports IEEE 802.3az EEE standard.
- imx8qm: supports RGMII mode delayed clock.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 drivers/net/ethernet/freescale/fec.h      | 13 ++++++++++
 drivers/net/ethernet/freescale/fec_main.c | 30 +++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 2e002e4b4b4a..c1f93aa79d63 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -472,6 +472,19 @@ struct bufdesc_ex {
  */
 #define FEC_QUIRK_HAS_MULTI_QUEUES	(1 << 19)
 
+/* i.MX8MQ ENET IP version add new feature to support IEEE 802.3az EEE
+ * standard. For the transmission, MAC supply two user registers to set
+ * Sleep (TS) and Wake (TW) time.
+ */
+#define FEC_QUIRK_HAS_EEE		(1 << 20)
+
+/* i.MX8QM ENET IP version add new feture to generate delayed TXC/RXC
+ * as an alternative option to make sure it works well with various PHYs.
+ * For the implementation of delayed clock, ENET takes synchronized 250MHz
+ * clocks to generate 2ns delay.
+ */
+#define FEC_QUIRK_DELAYED_CLKS_SUPPORT	(1 << 21)
+
 struct bufdesc_prop {
 	int qid;
 	/* Address of Rx and Tx buffers */
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index e361be85f26f..d9ba9d6f7af7 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -135,6 +135,26 @@ static const struct fec_devinfo fec_imx6ul_info = {
 		  FEC_QUIRK_HAS_COALESCE | FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
+static const struct fec_devinfo fec_imx8mq_info = {
+	.quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
+		  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
+		  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_HAS_AVB |
+		  FEC_QUIRK_ERR007885 | FEC_QUIRK_BUG_CAPTURE |
+		  FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE |
+		  FEC_QUIRK_CLEAR_SETUP_MII | FEC_QUIRK_HAS_MULTI_QUEUES |
+		  FEC_QUIRK_HAS_EEE,
+};
+
+static const struct fec_devinfo fec_imx8qm_info = {
+	.quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
+		  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
+		  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_HAS_AVB |
+		  FEC_QUIRK_ERR007885 | FEC_QUIRK_BUG_CAPTURE |
+		  FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE |
+		  FEC_QUIRK_CLEAR_SETUP_MII | FEC_QUIRK_HAS_MULTI_QUEUES |
+		  FEC_QUIRK_DELAYED_CLKS_SUPPORT,
+};
+
 static struct platform_device_id fec_devtype[] = {
 	{
 		/* keep it for coldfire */
@@ -161,6 +181,12 @@ static struct platform_device_id fec_devtype[] = {
 	}, {
 		.name = "imx6ul-fec",
 		.driver_data = (kernel_ulong_t)&fec_imx6ul_info,
+	}, {
+		.name = "imx8mq-fec",
+		.driver_data = (kernel_ulong_t)&fec_imx8mq_info,
+	}, {
+		.name = "imx8qm-fec",
+		.driver_data = (kernel_ulong_t)&fec_imx8qm_info,
 	}, {
 		/* sentinel */
 	}
@@ -175,6 +201,8 @@ enum imx_fec_type {
 	MVF600_FEC,
 	IMX6SX_FEC,
 	IMX6UL_FEC,
+	IMX8MQ_FEC,
+	IMX8QM_FEC,
 };
 
 static const struct of_device_id fec_dt_ids[] = {
@@ -185,6 +213,8 @@ static const struct of_device_id fec_dt_ids[] = {
 	{ .compatible = "fsl,mvf600-fec", .data = &fec_devtype[MVF600_FEC], },
 	{ .compatible = "fsl,imx6sx-fec", .data = &fec_devtype[IMX6SX_FEC], },
 	{ .compatible = "fsl,imx6ul-fec", .data = &fec_devtype[IMX6UL_FEC], },
+	{ .compatible = "fsl,imx8mq-fec", .data = &fec_devtype[IMX8MQ_FEC], },
+	{ .compatible = "fsl,imx8qm-fec", .data = &fec_devtype[IMX8QM_FEC], },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, fec_dt_ids);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V2 net-next 4/7] net: fec: add eee mode tx lpi support
  2021-07-28 11:51 [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM Joakim Zhang
                   ` (2 preceding siblings ...)
  2021-07-28 11:51 ` [PATCH V2 net-next 3/7] net: fec: add imx8mq and imx8qm new versions support Joakim Zhang
@ 2021-07-28 11:52 ` Joakim Zhang
  2021-07-28 11:52 ` [PATCH V2 net-next 5/7] net: fec: add MAC internal delayed clock feature support Joakim Zhang
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Joakim Zhang @ 2021-07-28 11:52 UTC (permalink / raw)
  To: davem, kuba, robh+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, netdev, devicetree, linux-kernel

From: Fugang Duan <fugang.duan@nxp.com>

The i.MX8MQ ENET version support IEEE802.3az eee mode, add
eee mode tx lpi enable to support ethtool interface.

usage:
1. set sleep and wake timer to 5ms:
ethtool --set-eee eth0 eee on tx-lpi on tx-timer 5000
2. check the eee mode:
~# ethtool --show-eee eth0
EEE Settings for eth0:
        EEE status: enabled - active
        Tx LPI: 5000 (us)
        Supported EEE link modes:  100baseT/Full
                                   1000baseT/Full
        Advertised EEE link modes:  100baseT/Full
                                    1000baseT/Full
        Link partner advertised EEE link modes:  100baseT/Full

Note: For realtime case and IEEE1588 ptp case, it should disable
EEE mode.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 drivers/net/ethernet/freescale/fec.h      |  6 ++
 drivers/net/ethernet/freescale/fec_main.c | 89 +++++++++++++++++++++++
 2 files changed, 95 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index c1f93aa79d63..0a741bc440e4 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -77,6 +77,8 @@
 #define FEC_R_DES_ACTIVE_2	0x1e8 /* Rx descriptor active for ring 2 */
 #define FEC_X_DES_ACTIVE_2	0x1ec /* Tx descriptor active for ring 2 */
 #define FEC_QOS_SCHEME		0x1f0 /* Set multi queues Qos scheme */
+#define FEC_LPI_SLEEP		0x1f4 /* Set IEEE802.3az LPI Sleep Ts time */
+#define FEC_LPI_WAKE		0x1f8 /* Set IEEE802.3az LPI Wake Tw time */
 #define FEC_MIIGSK_CFGR		0x300 /* MIIGSK Configuration reg */
 #define FEC_MIIGSK_ENR		0x308 /* MIIGSK Enable reg */
 
@@ -602,6 +604,10 @@ struct fec_enet_private {
 	unsigned int tx_time_itr;
 	unsigned int itr_clk_rate;
 
+	/* tx lpi eee mode */
+	struct ethtool_eee eee;
+	unsigned int clk_ref_rate;
+
 	u32 rx_copybreak;
 
 	/* ptp clock period in ns*/
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index d9ba9d6f7af7..f13a9da180a2 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2722,6 +2722,92 @@ static int fec_enet_set_tunable(struct net_device *netdev,
 	return ret;
 }
 
+/* LPI Sleep Ts count base on tx clk (clk_ref).
+ * The lpi sleep cnt value = X us / (cycle_ns).
+ */
+static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us)
+{
+	struct fec_enet_private *fep = netdev_priv(ndev);
+
+	return us * (fep->clk_ref_rate / 1000) / 1000;
+}
+
+static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable)
+{
+	struct fec_enet_private *fep = netdev_priv(ndev);
+	struct ethtool_eee *p = &fep->eee;
+	unsigned int sleep_cycle, wake_cycle;
+	int ret = 0;
+
+	if (enable) {
+		ret = phy_init_eee(ndev->phydev, 0);
+		if (ret)
+			return ret;
+
+		sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer);
+		wake_cycle = sleep_cycle;
+	} else {
+		sleep_cycle = 0;
+		wake_cycle = 0;
+	}
+
+	p->tx_lpi_enabled = enable;
+	p->eee_enabled = enable;
+	p->eee_active = enable;
+
+	writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP);
+	writel(wake_cycle, fep->hwp + FEC_LPI_WAKE);
+
+	return 0;
+}
+
+static int
+fec_enet_get_eee(struct net_device *ndev, struct ethtool_eee *edata)
+{
+	struct fec_enet_private *fep = netdev_priv(ndev);
+	struct ethtool_eee *p = &fep->eee;
+
+	if (!(fep->quirks & FEC_QUIRK_HAS_EEE))
+		return -EOPNOTSUPP;
+
+	if (!netif_running(ndev))
+		return -ENETDOWN;
+
+	edata->eee_enabled = p->eee_enabled;
+	edata->eee_active = p->eee_active;
+	edata->tx_lpi_timer = p->tx_lpi_timer;
+	edata->tx_lpi_enabled = p->tx_lpi_enabled;
+
+	return phy_ethtool_get_eee(ndev->phydev, edata);
+}
+
+static int
+fec_enet_set_eee(struct net_device *ndev, struct ethtool_eee *edata)
+{
+	struct fec_enet_private *fep = netdev_priv(ndev);
+	struct ethtool_eee *p = &fep->eee;
+	int ret = 0;
+
+	if (!(fep->quirks & FEC_QUIRK_HAS_EEE))
+		return -EOPNOTSUPP;
+
+	if (!netif_running(ndev))
+		return -ENETDOWN;
+
+	p->tx_lpi_timer = edata->tx_lpi_timer;
+
+	if (!edata->eee_enabled || !edata->tx_lpi_enabled ||
+	    !edata->tx_lpi_timer)
+		ret = fec_enet_eee_mode_set(ndev, false);
+	else
+		ret = fec_enet_eee_mode_set(ndev, true);
+
+	if (ret)
+		return ret;
+
+	return phy_ethtool_set_eee(ndev->phydev, edata);
+}
+
 static void
 fec_enet_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
 {
@@ -2782,6 +2868,8 @@ static const struct ethtool_ops fec_enet_ethtool_ops = {
 	.set_tunable		= fec_enet_set_tunable,
 	.get_wol		= fec_enet_get_wol,
 	.set_wol		= fec_enet_set_wol,
+	.get_eee		= fec_enet_get_eee,
+	.set_eee		= fec_enet_set_eee,
 	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
 	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
 	.self_test		= net_selftest,
@@ -3722,6 +3810,7 @@ fec_probe(struct platform_device *pdev)
 	fep->clk_ref = devm_clk_get(&pdev->dev, "enet_clk_ref");
 	if (IS_ERR(fep->clk_ref))
 		fep->clk_ref = NULL;
+	fep->clk_ref_rate = clk_get_rate(fep->clk_ref);
 
 	fep->bufdesc_ex = fep->quirks & FEC_QUIRK_HAS_BUFDESC_EX;
 	fep->clk_ptp = devm_clk_get(&pdev->dev, "ptp");
-- 
2.17.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V2 net-next 5/7] net: fec: add MAC internal delayed clock feature support
  2021-07-28 11:51 [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM Joakim Zhang
                   ` (3 preceding siblings ...)
  2021-07-28 11:52 ` [PATCH V2 net-next 4/7] net: fec: add eee mode tx lpi support Joakim Zhang
@ 2021-07-28 11:52 ` Joakim Zhang
  2021-07-28 14:10   ` Andrew Lunn
  2021-07-28 11:52 ` [PATCH V2 net-next 6/7] arm64: dts: imx8m: add "fsl,imx8mq-fec" compatible string for FEC Joakim Zhang
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Joakim Zhang @ 2021-07-28 11:52 UTC (permalink / raw)
  To: davem, kuba, robh+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, netdev, devicetree, linux-kernel

From: Fugang Duan <fugang.duan@nxp.com>

i.MX8QM ENET IP version support timing specification that MAC
integrate clock delay in RGMII mode, the delayed TXC/RXC as an
alternative option to work well with various PHYs.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 drivers/net/ethernet/freescale/fec.h      |  6 +++++
 drivers/net/ethernet/freescale/fec_main.c | 27 +++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 0a741bc440e4..ae3259164395 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -381,6 +381,9 @@ struct bufdesc_ex {
 #define FEC_DEFAULT_IMASK (FEC_ENET_TXF | FEC_ENET_RXF)
 #define FEC_RX_DISABLED_IMASK (FEC_DEFAULT_IMASK & (~FEC_ENET_RXF))
 
+#define FEC_ENET_TXC_DLY	((uint)0x00010000)
+#define FEC_ENET_RXC_DLY	((uint)0x00020000)
+
 /* ENET interrupt coalescing macro define */
 #define FEC_ITR_CLK_SEL		(0x1 << 30)
 #define FEC_ITR_EN		(0x1 << 31)
@@ -543,6 +546,7 @@ struct fec_enet_private {
 	struct clk *clk_ref;
 	struct clk *clk_enet_out;
 	struct clk *clk_ptp;
+	struct clk *clk_2x_txclk;
 
 	bool ptp_clk_on;
 	struct mutex ptp_clk_mutex;
@@ -565,6 +569,8 @@ struct fec_enet_private {
 	uint	phy_speed;
 	phy_interface_t	phy_interface;
 	struct device_node *phy_node;
+	bool	rgmii_txc_dly;
+	bool	rgmii_rxc_dly;
 	int	link;
 	int	full_duplex;
 	int	speed;
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index f13a9da180a2..40ea318d7396 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1137,6 +1137,13 @@ fec_restart(struct net_device *ndev)
 	if (fep->bufdesc_ex)
 		ecntl |= (1 << 4);
 
+	if (fep->quirks & FEC_QUIRK_DELAYED_CLKS_SUPPORT &&
+	    fep->rgmii_txc_dly)
+		ecntl |= FEC_ENET_TXC_DLY;
+	if (fep->quirks & FEC_QUIRK_DELAYED_CLKS_SUPPORT &&
+	    fep->rgmii_rxc_dly)
+		ecntl |= FEC_ENET_RXC_DLY;
+
 #ifndef CONFIG_M5272
 	/* Enable the MIB statistic event counters */
 	writel(0 << 31, fep->hwp + FEC_MIB_CTRLSTAT);
@@ -2000,6 +2007,10 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
 		if (ret)
 			goto failed_clk_ref;
 
+		ret = clk_prepare_enable(fep->clk_2x_txclk);
+		if (ret)
+			goto failed_clk_2x_txclk;
+
 		fec_enet_phy_reset_after_clk_enable(ndev);
 	} else {
 		clk_disable_unprepare(fep->clk_enet_out);
@@ -2010,10 +2021,14 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
 			mutex_unlock(&fep->ptp_clk_mutex);
 		}
 		clk_disable_unprepare(fep->clk_ref);
+		clk_disable_unprepare(fep->clk_2x_txclk);
 	}
 
 	return 0;
 
+failed_clk_2x_txclk:
+	if (fep->clk_ref)
+		clk_disable_unprepare(fep->clk_ref);
 failed_clk_ref:
 	if (fep->clk_ptp) {
 		mutex_lock(&fep->ptp_clk_mutex);
@@ -3704,6 +3719,7 @@ fec_probe(struct platform_device *pdev)
 	char irq_name[8];
 	int irq_cnt;
 	struct fec_devinfo *dev_info;
+	u32 rgmii_delay;
 
 	fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs);
 
@@ -3761,6 +3777,12 @@ fec_probe(struct platform_device *pdev)
 	if (ret)
 		goto failed_stop_mode;
 
+	/* For rgmii internal delay, valid values are 0ps and 2000ps */
+	if (of_property_read_u32(np, "tx-internal-delay-ps", &rgmii_delay))
+		fep->rgmii_txc_dly = true;
+	if (of_property_read_u32(np, "rx-internal-delay-ps", &rgmii_delay))
+		fep->rgmii_rxc_dly = true;
+
 	phy_node = of_parse_phandle(np, "phy-handle", 0);
 	if (!phy_node && of_phy_is_fixed_link(np)) {
 		ret = of_phy_register_fixed_link(np);
@@ -3812,6 +3834,11 @@ fec_probe(struct platform_device *pdev)
 		fep->clk_ref = NULL;
 	fep->clk_ref_rate = clk_get_rate(fep->clk_ref);
 
+	/* clk_2x_txclk is optional, depends on board */
+	fep->clk_2x_txclk = devm_clk_get(&pdev->dev, "enet_2x_txclk");
+	if (IS_ERR(fep->clk_2x_txclk))
+		fep->clk_2x_txclk = NULL;
+
 	fep->bufdesc_ex = fep->quirks & FEC_QUIRK_HAS_BUFDESC_EX;
 	fep->clk_ptp = devm_clk_get(&pdev->dev, "ptp");
 	if (IS_ERR(fep->clk_ptp)) {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V2 net-next 6/7] arm64: dts: imx8m: add "fsl,imx8mq-fec" compatible string for FEC
  2021-07-28 11:51 [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM Joakim Zhang
                   ` (4 preceding siblings ...)
  2021-07-28 11:52 ` [PATCH V2 net-next 5/7] net: fec: add MAC internal delayed clock feature support Joakim Zhang
@ 2021-07-28 11:52 ` Joakim Zhang
  2021-07-28 11:52 ` [PATCH V2 net-next 7/7] arm64: dts: imx8qxp: add "fsl,imx8qm-fec" " Joakim Zhang
  2021-07-28 12:50 ` [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM patchwork-bot+netdevbpf
  7 siblings, 0 replies; 13+ messages in thread
From: Joakim Zhang @ 2021-07-28 11:52 UTC (permalink / raw)
  To: davem, kuba, robh+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, netdev, devicetree, linux-kernel

Add "fsl,imx8mq-fec" compatible string for FEC to support new feature
(IEEE 802.3az EEE standard).

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 arch/arm64/boot/dts/freescale/imx8mm.dtsi | 2 +-
 arch/arm64/boot/dts/freescale/imx8mn.dtsi | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mm.dtsi b/arch/arm64/boot/dts/freescale/imx8mm.dtsi
index e7648c3b8390..1608a48495b6 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm.dtsi
@@ -920,7 +920,7 @@
 			};
 
 			fec1: ethernet@30be0000 {
-				compatible = "fsl,imx8mm-fec", "fsl,imx6sx-fec";
+				compatible = "fsl,imx8mm-fec", "fsl,imx8mq-fec", "fsl,imx6sx-fec";
 				reg = <0x30be0000 0x10000>;
 				interrupts = <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
 					     <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>,
diff --git a/arch/arm64/boot/dts/freescale/imx8mn.dtsi b/arch/arm64/boot/dts/freescale/imx8mn.dtsi
index d4231e061403..e6de293865b0 100644
--- a/arch/arm64/boot/dts/freescale/imx8mn.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mn.dtsi
@@ -923,7 +923,7 @@
 			};
 
 			fec1: ethernet@30be0000 {
-				compatible = "fsl,imx8mn-fec", "fsl,imx6sx-fec";
+				compatible = "fsl,imx8mn-fec", "fsl,imx8mq-fec", "fsl,imx6sx-fec";
 				reg = <0x30be0000 0x10000>;
 				interrupts = <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
 					     <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V2 net-next 7/7] arm64: dts: imx8qxp: add "fsl,imx8qm-fec" compatible string for FEC
  2021-07-28 11:51 [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM Joakim Zhang
                   ` (5 preceding siblings ...)
  2021-07-28 11:52 ` [PATCH V2 net-next 6/7] arm64: dts: imx8m: add "fsl,imx8mq-fec" compatible string for FEC Joakim Zhang
@ 2021-07-28 11:52 ` Joakim Zhang
  2021-07-28 12:50 ` [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM patchwork-bot+netdevbpf
  7 siblings, 0 replies; 13+ messages in thread
From: Joakim Zhang @ 2021-07-28 11:52 UTC (permalink / raw)
  To: davem, kuba, robh+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, netdev, devicetree, linux-kernel

Add "fsl,imx8qm-fec" compatible string for FEC to support new feature
(RGMII delayed clock).

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 arch/arm64/boot/dts/freescale/imx8qxp-ss-conn.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8qxp-ss-conn.dtsi b/arch/arm64/boot/dts/freescale/imx8qxp-ss-conn.dtsi
index f5f58959f65c..46da21af3702 100644
--- a/arch/arm64/boot/dts/freescale/imx8qxp-ss-conn.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8qxp-ss-conn.dtsi
@@ -17,9 +17,9 @@
 };
 
 &fec1 {
-	compatible = "fsl,imx8qxp-fec", "fsl,imx6sx-fec";
+	compatible = "fsl,imx8qxp-fec", "fsl,imx8qm-fec", "fsl,imx6sx-fec";
 };
 
 &fec2 {
-	compatible = "fsl,imx8qxp-fec", "fsl,imx6sx-fec";
+	compatible = "fsl,imx8qxp-fec", "fsl,imx8qm-fec", "fsl,imx6sx-fec";
 };
-- 
2.17.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM
  2021-07-28 11:51 [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM Joakim Zhang
                   ` (6 preceding siblings ...)
  2021-07-28 11:52 ` [PATCH V2 net-next 7/7] arm64: dts: imx8qxp: add "fsl,imx8qm-fec" " Joakim Zhang
@ 2021-07-28 12:50 ` patchwork-bot+netdevbpf
  7 siblings, 0 replies; 13+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-28 12:50 UTC (permalink / raw)
  To: Joakim Zhang
  Cc: davem, kuba, robh+dt, shawnguo, s.hauer, kernel, festevam,
	linux-imx, netdev, devicetree, linux-kernel

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Wed, 28 Jul 2021 19:51:56 +0800 you wrote:
> This patch set adds supports for i.MX8MQ and i.MX8QM, both of them extend new features.
> 
> ChangeLogs:
> V1->V2:
> 	* rebase on schema binding, and update dts compatible string.
> 	* use generic ethernet controller property for MAC internal RGMII clock delay
> 	  rx-internal-delay-ps and tx-internal-delay-ps
> 
> [...]

Here is the summary with links:
  - [V2,net-next,1/7] dt-bindings: net: fsl,fec: update compatible items
    https://git.kernel.org/netdev/net-next/c/5d886947039d
  - [V2,net-next,2/7] dt-bindings: net: fsl,fec: add RGMII internal clock delay
    https://git.kernel.org/netdev/net-next/c/df11b8073e19
  - [V2,net-next,3/7] net: fec: add imx8mq and imx8qm new versions support
    https://git.kernel.org/netdev/net-next/c/947240ebcc63
  - [V2,net-next,4/7] net: fec: add eee mode tx lpi support
    https://git.kernel.org/netdev/net-next/c/b82f8c3f1409
  - [V2,net-next,5/7] net: fec: add MAC internal delayed clock feature support
    https://git.kernel.org/netdev/net-next/c/fc539459e900
  - [V2,net-next,6/7] arm64: dts: imx8m: add "fsl,imx8mq-fec" compatible string for FEC
    https://git.kernel.org/netdev/net-next/c/a758dee8ac50
  - [V2,net-next,7/7] arm64: dts: imx8qxp: add "fsl,imx8qm-fec" compatible string for FEC
    https://git.kernel.org/netdev/net-next/c/987e1b96d056

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V2 net-next 2/7] dt-bindings: net: fsl,fec: add RGMII internal clock delay
  2021-07-28 11:51 ` [PATCH V2 net-next 2/7] dt-bindings: net: fsl,fec: add RGMII internal clock delay Joakim Zhang
@ 2021-07-28 14:08   ` Andrew Lunn
  2021-07-29  2:30     ` Joakim Zhang
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2021-07-28 14:08 UTC (permalink / raw)
  To: Joakim Zhang
  Cc: davem, kuba, robh+dt, shawnguo, s.hauer, kernel, festevam,
	linux-imx, netdev, devicetree, linux-kernel

On Wed, Jul 28, 2021 at 07:51:58PM +0800, Joakim Zhang wrote:

> +      The "enet_2x_txclk"(option), for RGMII sampling clock which fixed at 250Mhz.
> +      The clock is required if SoC RGMII enable clock delay.

Hi Joakim

So you only need the clock if you are using RGMII delays? For RGMII
without delays, the clock is not needed?

You might want to add a check in the C code that the clock is provided
when needed.

     Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V2 net-next 5/7] net: fec: add MAC internal delayed clock feature support
  2021-07-28 11:52 ` [PATCH V2 net-next 5/7] net: fec: add MAC internal delayed clock feature support Joakim Zhang
@ 2021-07-28 14:10   ` Andrew Lunn
  2021-07-29  2:32     ` Joakim Zhang
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2021-07-28 14:10 UTC (permalink / raw)
  To: Joakim Zhang
  Cc: davem, kuba, robh+dt, shawnguo, s.hauer, kernel, festevam,
	linux-imx, netdev, devicetree, linux-kernel

> +	/* For rgmii internal delay, valid values are 0ps and 2000ps */
> +	if (of_property_read_u32(np, "tx-internal-delay-ps", &rgmii_delay))
> +		fep->rgmii_txc_dly = true;
> +	if (of_property_read_u32(np, "rx-internal-delay-ps", &rgmii_delay))
> +		fep->rgmii_rxc_dly = true;

I don't see any validation of the only supported values are 0ps and
2000ps.

	Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH V2 net-next 2/7] dt-bindings: net: fsl,fec: add RGMII internal clock delay
  2021-07-28 14:08   ` Andrew Lunn
@ 2021-07-29  2:30     ` Joakim Zhang
  0 siblings, 0 replies; 13+ messages in thread
From: Joakim Zhang @ 2021-07-29  2:30 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: davem, kuba, robh+dt, shawnguo, s.hauer, kernel, festevam,
	dl-linux-imx, netdev, devicetree, linux-kernel


> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: 2021年7月28日 22:08
> To: Joakim Zhang <qiangqing.zhang@nxp.com>
> Cc: davem@davemloft.net; kuba@kernel.org; robh+dt@kernel.org;
> shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
> festevam@gmail.com; dl-linux-imx <linux-imx@nxp.com>;
> netdev@vger.kernel.org; devicetree@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Subject: Re: [PATCH V2 net-next 2/7] dt-bindings: net: fsl,fec: add RGMII
> internal clock delay
> 
> On Wed, Jul 28, 2021 at 07:51:58PM +0800, Joakim Zhang wrote:
> 
> > +      The "enet_2x_txclk"(option), for RGMII sampling clock which fixed at
> 250Mhz.
> > +      The clock is required if SoC RGMII enable clock delay.
> 
> Hi Joakim
> 
> So you only need the clock if you are using RGMII delays? For RGMII without
> delays, the clock is not needed?
> 
> You might want to add a check in the C code that the clock is provided when
> needed.

Hi Andrew,

Yes, we only need this clock for RGMII delays, the clock is not needed for RGMII without delays.

Had better add below check to avoid enabling needless clock. 
	if (fep->rgmii_txc_dly || fep->rgmii_rxc_dly)

Best Regards,
Joakim Zhang
>      Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH V2 net-next 5/7] net: fec: add MAC internal delayed clock feature support
  2021-07-28 14:10   ` Andrew Lunn
@ 2021-07-29  2:32     ` Joakim Zhang
  0 siblings, 0 replies; 13+ messages in thread
From: Joakim Zhang @ 2021-07-29  2:32 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: davem, kuba, robh+dt, shawnguo, s.hauer, kernel, festevam,
	dl-linux-imx, netdev, devicetree, linux-kernel


> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: 2021年7月28日 22:11
> To: Joakim Zhang <qiangqing.zhang@nxp.com>
> Cc: davem@davemloft.net; kuba@kernel.org; robh+dt@kernel.org;
> shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
> festevam@gmail.com; dl-linux-imx <linux-imx@nxp.com>;
> netdev@vger.kernel.org; devicetree@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Subject: Re: [PATCH V2 net-next 5/7] net: fec: add MAC internal delayed clock
> feature support
> 
> > +	/* For rgmii internal delay, valid values are 0ps and 2000ps */
> > +	if (of_property_read_u32(np, "tx-internal-delay-ps", &rgmii_delay))
> > +		fep->rgmii_txc_dly = true;
> > +	if (of_property_read_u32(np, "rx-internal-delay-ps", &rgmii_delay))
> > +		fep->rgmii_rxc_dly = true;
> 
> I don't see any validation of the only supported values are 0ps and 2000ps.

Hi Andrew,

I also take this into account, since I have limited the value to 0 and 2000 in fec dt-bindings.
It will report error when run dtbs_check if value is not invalid. Another reason is that actually
the value is not program to hardware, we only enable RGMII delay or not. If need, I think we
can only add a dev_warn() here, instead of stop the probe process?

Best Regards,
Joakim Zhang
> 	Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-07-29  2:32 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-28 11:51 [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM Joakim Zhang
2021-07-28 11:51 ` [PATCH V2 net-next 1/7] dt-bindings: net: fsl,fec: update compatible items Joakim Zhang
2021-07-28 11:51 ` [PATCH V2 net-next 2/7] dt-bindings: net: fsl,fec: add RGMII internal clock delay Joakim Zhang
2021-07-28 14:08   ` Andrew Lunn
2021-07-29  2:30     ` Joakim Zhang
2021-07-28 11:51 ` [PATCH V2 net-next 3/7] net: fec: add imx8mq and imx8qm new versions support Joakim Zhang
2021-07-28 11:52 ` [PATCH V2 net-next 4/7] net: fec: add eee mode tx lpi support Joakim Zhang
2021-07-28 11:52 ` [PATCH V2 net-next 5/7] net: fec: add MAC internal delayed clock feature support Joakim Zhang
2021-07-28 14:10   ` Andrew Lunn
2021-07-29  2:32     ` Joakim Zhang
2021-07-28 11:52 ` [PATCH V2 net-next 6/7] arm64: dts: imx8m: add "fsl,imx8mq-fec" compatible string for FEC Joakim Zhang
2021-07-28 11:52 ` [PATCH V2 net-next 7/7] arm64: dts: imx8qxp: add "fsl,imx8qm-fec" " Joakim Zhang
2021-07-28 12:50 ` [PATCH V2 net-next 0/7] net: fec: add support for i.MX8MQ and i.MX8QM patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).