linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/6] net: stmmac: add renesas,rzn1-gmac support
@ 2023-01-16 10:39 Clément Léger
  2023-01-16 10:39 ` [PATCH net-next 1/6] net: stmmac: add support to use a generic phylink_pcs as PCS Clément Léger
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Clément Léger @ 2023-01-16 10:39 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Russell King,
	Wong Vee Khee, Clément Léger, Kurt Kanzenbach,
	Revanth Kumar Uppala, Tan Tee Min
  Cc: Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

The rzn1-gmac instance is connected to a PCS (MIIC). In order to use
this pcs, add support in the sttmac driver to set a generic phylink pcs
device instead of the xpcs only. Moreover, it adds support to provide
a phylink pcs device from the stmmac platform data and use it with the
driver. It also adds the bindings and the new rzn1-gmac driver that
retrieve this pcs from the device-tree.

Clément Léger (6):
  net: stmmac: add support to use a generic phylink_pcs as PCS
  net: stmmac: add support to provide pcs from platform data
  net: stmmac: start phylink before setting up hardware
  dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support
  net: stmmac: add support for RZ/N1 GMAC
  ARM: dts: r9a06g032: describe GMAC1

 .../bindings/net/renesas,rzn1-gmac.yaml       |  71 +++++++++++
 arch/arm/boot/dts/r9a06g032.dtsi              |  18 +++
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  11 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 drivers/net/ethernet/stmicro/stmmac/common.h  |   2 +
 .../net/ethernet/stmicro/stmmac/dwmac-rzn1.c  | 113 ++++++++++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |  15 ++-
 .../net/ethernet/stmicro/stmmac/stmmac_mdio.c |   1 +
 include/linux/stmmac.h                        |   1 +
 9 files changed, 228 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c

-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH net-next 1/6] net: stmmac: add support to use a generic phylink_pcs as PCS
  2023-01-16 10:39 [PATCH net-next 0/6] net: stmmac: add renesas,rzn1-gmac support Clément Léger
@ 2023-01-16 10:39 ` Clément Léger
  2023-01-16 10:39 ` [PATCH net-next 2/6] net: stmmac: add support to provide pcs from platform data Clément Léger
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Clément Léger @ 2023-01-16 10:39 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Russell King,
	Wong Vee Khee, Clément Léger, Kurt Kanzenbach,
	Revanth Kumar Uppala, Tan Tee Min
  Cc: Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

Currently, the PCS is set based on the presence of the xpcs field. In
order to allow supporting other PCS, add a phylink_pcs pcs field to struct
mac_device_info which is used in stmmac_mac_select_pcs() to select the
correct PCS.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/common.h      | 2 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +----
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 1 +
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 6b5d96bced47..79fd67e8ab90 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -15,6 +15,7 @@
 #include <linux/netdevice.h>
 #include <linux/stmmac.h>
 #include <linux/phy.h>
+#include <linux/phylink.h>
 #include <linux/pcs/pcs-xpcs.h>
 #include <linux/module.h>
 #if IS_ENABLED(CONFIG_VLAN_8021Q)
@@ -518,6 +519,7 @@ struct mac_device_info {
 	const struct stmmac_tc_ops *tc;
 	const struct stmmac_mmc_ops *mmc;
 	struct dw_xpcs *xpcs;
+	struct phylink_pcs *phylink_pcs;
 	struct mii_regs mii;	/* MII register Addresses */
 	struct mac_link link;
 	void __iomem *pcsr;     /* vpointer to device CSRs */
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c6951c976f5d..19459ef15a35 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -937,10 +937,7 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,
 {
 	struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
 
-	if (!priv->hw->xpcs)
-		return NULL;
-
-	return &priv->hw->xpcs->pcs;
+	return priv->hw->phylink_pcs;
 }
 
 static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index 5f177ea80725..3e875d4664c0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -413,6 +413,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus)
 		}
 
 		priv->hw->xpcs = xpcs;
+		priv->hw->phylink_pcs = &xpcs->pcs;
 		break;
 	}
 
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH net-next 2/6] net: stmmac: add support to provide pcs from platform data
  2023-01-16 10:39 [PATCH net-next 0/6] net: stmmac: add renesas,rzn1-gmac support Clément Léger
  2023-01-16 10:39 ` [PATCH net-next 1/6] net: stmmac: add support to use a generic phylink_pcs as PCS Clément Léger
@ 2023-01-16 10:39 ` Clément Léger
  2023-01-16 10:39 ` [PATCH net-next 3/6] net: stmmac: start phylink before setting up hardware Clément Léger
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Clément Léger @ 2023-01-16 10:39 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Russell King,
	Wong Vee Khee, Clément Léger, Kurt Kanzenbach,
	Revanth Kumar Uppala, Tan Tee Min
  Cc: Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

Add a pcs field in platform_data to allow providing platform data. This is
gonig to be used by the renesas,rzn1-gmac compatible driver which can make
use of a PCS.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++
 include/linux/stmmac.h                            | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 19459ef15a35..f2247b8cf0a3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -7287,6 +7287,9 @@ int stmmac_dvr_probe(struct device *device,
 			goto error_xpcs_setup;
 	}
 
+	if (priv->plat->pcs)
+		priv->hw->phylink_pcs = priv->plat->pcs;
+
 	ret = stmmac_phy_setup(priv);
 	if (ret) {
 		netdev_err(ndev, "failed to setup phy (%d)\n", ret);
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 83ca2e8eb6b5..af09d5e0ca4b 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -272,5 +272,6 @@ struct plat_stmmacenet_data {
 	bool use_phy_wol;
 	bool sph_disable;
 	bool serdes_up_after_phy_linkup;
+	struct phylink_pcs *pcs;
 };
 #endif
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH net-next 3/6] net: stmmac: start phylink before setting up hardware
  2023-01-16 10:39 [PATCH net-next 0/6] net: stmmac: add renesas,rzn1-gmac support Clément Léger
  2023-01-16 10:39 ` [PATCH net-next 1/6] net: stmmac: add support to use a generic phylink_pcs as PCS Clément Léger
  2023-01-16 10:39 ` [PATCH net-next 2/6] net: stmmac: add support to provide pcs from platform data Clément Léger
@ 2023-01-16 10:39 ` Clément Léger
  2023-01-16 10:53   ` Russell King (Oracle)
  2023-01-16 10:39 ` [PATCH net-next 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support Clément Léger
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Clément Léger @ 2023-01-16 10:39 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Russell King,
	Wong Vee Khee, Clément Léger, Kurt Kanzenbach,
	Revanth Kumar Uppala, Tan Tee Min
  Cc: Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

The stmmac on the Renesas RZ/N1 platform is connected to the PCS which
must be configured to provide a correct RGMII RX clock to the stmmac IP.
Without the RX clock, the driver will fail to initialize the hardware
(more specifically, the driver will report it fails to reset DMA). In
order to fix that, start phylink mecanism before setting up hardware.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f2247b8cf0a3..88c941003855 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3818,6 +3818,12 @@ static int __stmmac_open(struct net_device *dev,
 		}
 	}
 
+	/* We need to setup the phy & PCS before accessing the stmmac registers
+	 * because in some cases (RZ/N1), if the stmmac IP is not clocked by the
+	 * PCS, hardware init will fail because it lacks a RGMII RX clock.
+	 */
+	phylink_start(priv->phylink);
+
 	ret = stmmac_hw_setup(dev, true);
 	if (ret < 0) {
 		netdev_err(priv->dev, "%s: Hw setup failed\n", __func__);
@@ -3826,7 +3832,6 @@ static int __stmmac_open(struct net_device *dev,
 
 	stmmac_init_coalesce(priv);
 
-	phylink_start(priv->phylink);
 	/* We may have called phylink_speed_down before */
 	phylink_speed_up(priv->phylink);
 
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH net-next 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support
  2023-01-16 10:39 [PATCH net-next 0/6] net: stmmac: add renesas,rzn1-gmac support Clément Léger
                   ` (2 preceding siblings ...)
  2023-01-16 10:39 ` [PATCH net-next 3/6] net: stmmac: start phylink before setting up hardware Clément Léger
@ 2023-01-16 10:39 ` Clément Léger
  2023-01-16 12:27   ` Geert Uytterhoeven
                     ` (2 more replies)
  2023-01-16 10:39 ` [PATCH net-next 5/6] net: stmmac: add support for RZ/N1 GMAC Clément Léger
  2023-01-16 10:39 ` [PATCH net-next 6/6] ARM: dts: r9a06g032: describe GMAC1 Clément Léger
  5 siblings, 3 replies; 14+ messages in thread
From: Clément Léger @ 2023-01-16 10:39 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Russell King,
	Wong Vee Khee, Clément Léger, Kurt Kanzenbach,
	Revanth Kumar Uppala, Tan Tee Min
  Cc: Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

Add "renesas,rzn1-gmac" binding documention which is compatible which
"snps,dwmac" compatible driver but uses a custom PCS to communicate
with the phy.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 .../bindings/net/renesas,rzn1-gmac.yaml       | 71 +++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml

diff --git a/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml b/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
new file mode 100644
index 000000000000..effb9a312832
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/renesas,rzn1-gmac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Renesas GMAC1 Device Tree Bindings
+
+maintainers:
+  - Clément Léger <clement.leger@bootlin.com>
+
+select:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - renesas,r9a06g032-gmac
+          - renesas,rzn1-gmac
+  required:
+    - compatible
+
+allOf:
+  - $ref: "snps,dwmac.yaml#"
+
+properties:
+  compatible:
+    additionalItems: true
+    maxItems: 3
+    items:
+      - enum:
+          - renesas,r9a06g032-gmac
+          - renesas,rzn1-gmac
+    contains:
+      enum:
+        - snps,dwmac
+
+  pcs-handle:
+    description:
+      phandle pointing to a PCS sub-node compatible with
+      renesas,rzn1-miic.yaml#
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+required:
+  - compatible
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/r9a06g032-sysctrl.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    ethernet@44000000 {
+      compatible = "renesas,rzn1-gmac";
+      reg = <0x44000000 0x2000>;
+      interrupt-parent = <&gic>;
+      interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
+             <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>,
+             <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
+      interrupt-names = "macirq", "eth_wake_irq", "eth_lpi";
+      clock-names = "stmmaceth";
+      clocks = <&sysctrl R9A06G032_HCLK_GMAC0>;
+      snps,multicast-filter-bins = <256>;
+      snps,perfect-filter-entries = <128>;
+      tx-fifo-depth = <2048>;
+      rx-fifo-depth = <4096>;
+      pcs-handle = <&mii_conv1>;
+      phy-mode = "mii";
+    };
+
+...
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH net-next 5/6] net: stmmac: add support for RZ/N1 GMAC
  2023-01-16 10:39 [PATCH net-next 0/6] net: stmmac: add renesas,rzn1-gmac support Clément Léger
                   ` (3 preceding siblings ...)
  2023-01-16 10:39 ` [PATCH net-next 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support Clément Léger
@ 2023-01-16 10:39 ` Clément Léger
  2023-01-16 10:39 ` [PATCH net-next 6/6] ARM: dts: r9a06g032: describe GMAC1 Clément Léger
  5 siblings, 0 replies; 14+ messages in thread
From: Clément Léger @ 2023-01-16 10:39 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Russell King,
	Wong Vee Khee, Clément Léger, Kurt Kanzenbach,
	Revanth Kumar Uppala, Tan Tee Min
  Cc: Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

Add support for Renesas RZ/N1 GMAC. This support uses a custom PCS (MIIC)
which is handle by parsing the pcs-handle device tree property.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  11 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../net/ethernet/stmicro/stmmac/dwmac-rzn1.c  | 113 ++++++++++++++++++
 3 files changed, 125 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c

diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index f77511fe4e87..be5429b7e192 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -153,6 +153,17 @@ config DWMAC_ROCKCHIP
 	  This selects the Rockchip RK3288 SoC glue layer support for
 	  the stmmac device driver.
 
+config DWMAC_RZN1
+	tristate "Renesas RZ/N1 dwmac support"
+	default ARCH_RZN1
+	depends on OF && (ARCH_RZN1 || COMPILE_TEST)
+	select PCS_RZN1_MIIC
+	help
+	  Support for Ethernet controller on Renesas RZ/N1 SoC family.
+
+	  This selects the Renesas RZ/N1 SoC glue layer support for
+	  the stmmac device driver.
+
 config DWMAC_SOCFPGA
 	tristate "SOCFPGA dwmac support"
 	default ARCH_INTEL_SOCFPGA
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 057e4bab5c08..53a0f74c1cb5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o dwmac-meson8b.o
 obj-$(CONFIG_DWMAC_OXNAS)	+= dwmac-oxnas.o
 obj-$(CONFIG_DWMAC_QCOM_ETHQOS)	+= dwmac-qcom-ethqos.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
+obj-$(CONFIG_DWMAC_RZN1)	+= dwmac-rzn1.o
 obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-altr-socfpga.o
 obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
 obj-$(CONFIG_DWMAC_STM32)	+= dwmac-stm32.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c
new file mode 100644
index 000000000000..427b239e9772
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 Schneider-Electric
+ *
+ * Clément Léger <clement.leger@bootlin.com>
+ */
+
+#include <linux/of.h>
+#include <linux/pcs-rzn1-miic.h>
+#include <linux/phylink.h>
+#include <linux/platform_device.h>
+
+#include "stmmac_platform.h"
+#include "stmmac.h"
+
+struct rzn1_dwmac {
+	struct phylink_pcs *pcs;
+};
+
+static int rzn1_dt_parse(struct device *dev, struct rzn1_dwmac *dwmac)
+{
+	struct device_node *np = dev->of_node;
+	struct device_node *pcs_node;
+	struct phylink_pcs *pcs;
+
+	pcs_node = of_parse_phandle(np, "pcs-handle", 0);
+	if (!pcs_node)
+		return 0;
+
+	pcs = miic_create(dev, pcs_node);
+	if (IS_ERR(pcs))
+		return PTR_ERR(pcs);
+
+	dwmac->pcs = pcs;
+
+	return 0;
+}
+
+static int rzn1_dwmac_probe(struct platform_device *pdev)
+{
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
+	struct device *dev = &pdev->dev;
+	struct rzn1_dwmac *dwmac;
+	int ret;
+
+	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (ret)
+		return ret;
+
+	plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
+	if (IS_ERR(plat_dat))
+		return PTR_ERR(plat_dat);
+
+	dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
+	if (!dwmac) {
+		ret = -ENOMEM;
+		goto err_remove_config_dt;
+	}
+
+	ret = rzn1_dt_parse(dev, dwmac);
+	if (ret)
+		goto err_remove_config_dt;
+
+	plat_dat->bsp_priv = dwmac;
+	plat_dat->pcs = dwmac->pcs;
+
+	ret = stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
+	if (ret)
+		goto err_free_pcs;
+
+	return 0;
+
+err_free_pcs:
+	if (dwmac->pcs)
+		miic_destroy(dwmac->pcs);
+
+err_remove_config_dt:
+	stmmac_remove_config_dt(pdev, plat_dat);
+
+	return ret;
+}
+
+static int rzn1_dwmac_remove(struct platform_device *pdev)
+{
+	struct rzn1_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
+	int ret = stmmac_dvr_remove(&pdev->dev);
+
+	if (dwmac->pcs)
+		miic_destroy(dwmac->pcs);
+
+	return ret;
+}
+
+static const struct of_device_id rzn1_dwmac_match[] = {
+	{ .compatible = "renesas,rzn1-gmac" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, rzn1_dwmac_match);
+
+static struct platform_driver rzn1_dwmac_driver = {
+	.probe  = rzn1_dwmac_probe,
+	.remove = rzn1_dwmac_remove,
+	.driver = {
+		.name           = "rzn1-dwmac",
+		.of_match_table = rzn1_dwmac_match,
+	},
+};
+module_platform_driver(rzn1_dwmac_driver);
+
+MODULE_AUTHOR("Clément Léger <clement.leger@bootlin.com>");
+MODULE_DESCRIPTION("Renesas RZN1 DWMAC specific glue layer");
+MODULE_LICENSE("GPL");
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH net-next 6/6] ARM: dts: r9a06g032: describe GMAC1
  2023-01-16 10:39 [PATCH net-next 0/6] net: stmmac: add renesas,rzn1-gmac support Clément Léger
                   ` (4 preceding siblings ...)
  2023-01-16 10:39 ` [PATCH net-next 5/6] net: stmmac: add support for RZ/N1 GMAC Clément Léger
@ 2023-01-16 10:39 ` Clément Léger
  5 siblings, 0 replies; 14+ messages in thread
From: Clément Léger @ 2023-01-16 10:39 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Russell King,
	Wong Vee Khee, Clément Léger, Kurt Kanzenbach,
	Revanth Kumar Uppala, Tan Tee Min
  Cc: Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

RZ/N1 SoC includes two MAC named GMACx that are compatible with the
"snps,dwmac" driver. GMAC1 is connected directly to the MII converter
port 1. Since this MII converter is represented using a PCS driver, it
uses the renesas specific compatible driver which uses this PCS.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 arch/arm/boot/dts/r9a06g032.dtsi | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm/boot/dts/r9a06g032.dtsi b/arch/arm/boot/dts/r9a06g032.dtsi
index 41e19c0986ce..ba32e4429b01 100644
--- a/arch/arm/boot/dts/r9a06g032.dtsi
+++ b/arch/arm/boot/dts/r9a06g032.dtsi
@@ -304,6 +304,24 @@ dma1: dma-controller@40105000 {
 			data-width = <8>;
 		};
 
+		gmac1: ethernet@44000000 {
+			compatible = "renesas,r9a06g032-gmac", "renesas,rzn1-gmac", "snps,dwmac";
+			reg = <0x44000000 0x2000>;
+			interrupt-parent = <&gic>;
+			interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "macirq", "eth_wake_irq", "eth_lpi";
+			clock-names = "stmmaceth";
+			clocks = <&sysctrl R9A06G032_HCLK_GMAC0>;
+			snps,multicast-filter-bins = <256>;
+			snps,perfect-filter-entries = <128>;
+			tx-fifo-depth = <2048>;
+			rx-fifo-depth = <4096>;
+			pcs-handle = <&mii_conv1>;
+			status = "disabled";
+		};
+
 		gmac2: ethernet@44002000 {
 			compatible = "renesas,r9a06g032-gmac", "renesas,rzn1-gmac", "snps,dwmac";
 			reg = <0x44002000 0x2000>;
-- 
2.39.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH net-next 3/6] net: stmmac: start phylink before setting up hardware
  2023-01-16 10:39 ` [PATCH net-next 3/6] net: stmmac: start phylink before setting up hardware Clément Léger
@ 2023-01-16 10:53   ` Russell King (Oracle)
  2023-02-07 14:41     ` Clément Léger
  0 siblings, 1 reply; 14+ messages in thread
From: Russell King (Oracle) @ 2023-01-16 10:53 UTC (permalink / raw)
  To: Clément Léger
  Cc: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Wong Vee Khee,
	Kurt Kanzenbach, Revanth Kumar Uppala, Tan Tee Min,
	Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

On Mon, Jan 16, 2023 at 11:39:23AM +0100, Clément Léger wrote:
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index f2247b8cf0a3..88c941003855 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3818,6 +3818,12 @@ static int __stmmac_open(struct net_device *dev,
>  		}
>  	}
>  
> +	/* We need to setup the phy & PCS before accessing the stmmac registers
> +	 * because in some cases (RZ/N1), if the stmmac IP is not clocked by the
> +	 * PCS, hardware init will fail because it lacks a RGMII RX clock.
> +	 */
> +	phylink_start(priv->phylink);

So what happens if you end up with the mac_link_up method being called
at this point in the driver, before the hardware has been setup ?

If you use a fixed-link, that's a real possibility.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH net-next 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support
  2023-01-16 10:39 ` [PATCH net-next 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support Clément Léger
@ 2023-01-16 12:27   ` Geert Uytterhoeven
  2023-01-16 16:36   ` Rob Herring
  2023-01-22 14:19   ` Krzysztof Kozlowski
  2 siblings, 0 replies; 14+ messages in thread
From: Geert Uytterhoeven @ 2023-01-16 12:27 UTC (permalink / raw)
  To: Clément Léger
  Cc: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Russell King,
	Wong Vee Khee, Kurt Kanzenbach, Revanth Kumar Uppala,
	Tan Tee Min, Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

Hi Clément,

Thanks for your patch!

On Mon, Jan 16, 2023 at 11:37 AM Clément Léger
<clement.leger@bootlin.com> wrote:
> Add "renesas,rzn1-gmac" binding documention which is compatible which

documentation

> "snps,dwmac" compatible driver but uses a custom PCS to communicate
> with the phy.
>
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> ---
>  .../bindings/net/renesas,rzn1-gmac.yaml       | 71 +++++++++++++++++++
>  1 file changed, 71 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
>
> diff --git a/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml b/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
> new file mode 100644
> index 000000000000..effb9a312832
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
> @@ -0,0 +1,71 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/renesas,rzn1-gmac.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Renesas GMAC1 Device Tree Bindings
> +
> +maintainers:
> +  - Clément Léger <clement.leger@bootlin.com>
> +
> +select:
> +  properties:
> +    compatible:
> +      contains:
> +        enum:
> +          - renesas,r9a06g032-gmac
> +          - renesas,rzn1-gmac
> +  required:
> +    - compatible
> +
> +allOf:
> +  - $ref: "snps,dwmac.yaml#"
> +
> +properties:
> +  compatible:
> +    additionalItems: true
> +    maxItems: 3
> +    items:
> +      - enum:
> +          - renesas,r9a06g032-gmac
> +          - renesas,rzn1-gmac
> +    contains:
> +      enum:
> +        - snps,dwmac

Why not just

    items:
      - enum:
          - renesas,r9a06g032-gmac
          - renesas,rzn1-gmac
          - snps,dwmac

?

> +examples:
> +  - |
> +    #include <dt-bindings/clock/r9a06g032-sysctrl.h>
> +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> +
> +    ethernet@44000000 {
> +      compatible = "renesas,rzn1-gmac";

Documentation/devicetree/bindings/net/renesas,rzn1-gmac.example.dtb:
ethernet@44000000: compatible: ['renesas,rzn1-gmac'] does not contain
items matching the given schema

> +      reg = <0x44000000 0x2000>;
> +      interrupt-parent = <&gic>;
> +      interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
> +             <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>,
> +             <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
> +      interrupt-names = "macirq", "eth_wake_irq", "eth_lpi";
> +      clock-names = "stmmaceth";
> +      clocks = <&sysctrl R9A06G032_HCLK_GMAC0>;
> +      snps,multicast-filter-bins = <256>;
> +      snps,perfect-filter-entries = <128>;
> +      tx-fifo-depth = <2048>;
> +      rx-fifo-depth = <4096>;
> +      pcs-handle = <&mii_conv1>;
> +      phy-mode = "mii";
> +    };
> +
> +...

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH net-next 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support
  2023-01-16 10:39 ` [PATCH net-next 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support Clément Léger
  2023-01-16 12:27   ` Geert Uytterhoeven
@ 2023-01-16 16:36   ` Rob Herring
  2023-01-22 14:19   ` Krzysztof Kozlowski
  2 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2023-01-16 16:36 UTC (permalink / raw)
  To: Clément Léger
  Cc: Russell King, linux-renesas-soc, David S. Miller,
	Miquèl Raynal, Wong Vee Khee, Mohammad Athari Bin Ismail,
	Tan Tee Min, Rob Herring, Herve Codina, linux-arm-kernel, ,
	Thomas Petazzoni, Sergey Shtylyov, Geert Uytterhoeven,
	Jimmy Lalande, Alexandre Torgue, Krzysztof Kozlowski,
	linux-kernel, netdev, Magnus Damm, Giuseppe Cavallaro,
	Jose Abreu, Jon Hunter, Milan Stevanovic, Eric Dumazet,
	devicetree, Paolo Abeni, linux-stm32, Jakub Kicinski,
	Maxime Coquelin, ,
	Pascal Eberhard, Kurt Kanzenbach, Revanth Kumar Uppala


On Mon, 16 Jan 2023 11:39:24 +0100, Clément Léger wrote:
> Add "renesas,rzn1-gmac" binding documention which is compatible which
> "snps,dwmac" compatible driver but uses a custom PCS to communicate
> with the phy.
> 
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> ---
>  .../bindings/net/renesas,rzn1-gmac.yaml       | 71 +++++++++++++++++++
>  1 file changed, 71 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.example.dtb: ethernet@44000000: compatible: ['renesas,rzn1-gmac'] does not contain items matching the given schema
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20230116103926.276869-5-clement.leger@bootlin.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH net-next 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support
  2023-01-16 10:39 ` [PATCH net-next 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support Clément Léger
  2023-01-16 12:27   ` Geert Uytterhoeven
  2023-01-16 16:36   ` Rob Herring
@ 2023-01-22 14:19   ` Krzysztof Kozlowski
  2 siblings, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2023-01-22 14:19 UTC (permalink / raw)
  To: Clément Léger, Sergey Shtylyov, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring,
	Krzysztof Kozlowski, Geert Uytterhoeven, Magnus Damm,
	Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Russell King, Wong Vee Khee, Kurt Kanzenbach,
	Revanth Kumar Uppala, Tan Tee Min
  Cc: Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

On 16/01/2023 11:39, Clément Léger wrote:
> Add "renesas,rzn1-gmac" binding documention which is compatible which
> "snps,dwmac" compatible driver but uses a custom PCS to communicate
> with the phy.
> 
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> ---
>  .../bindings/net/renesas,rzn1-gmac.yaml       | 71 +++++++++++++++++++
>  1 file changed, 71 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
> 
> diff --git a/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml b/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
> new file mode 100644
> index 000000000000..effb9a312832
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml
> @@ -0,0 +1,71 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/renesas,rzn1-gmac.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Renesas GMAC1 Device Tree Bindings

Drop Device Tree Bindings.

> +
> +maintainers:
> +  - Clément Léger <clement.leger@bootlin.com>
> +
> +select:
> +  properties:
> +    compatible:
> +      contains:
> +        enum:
> +          - renesas,r9a06g032-gmac
> +          - renesas,rzn1-gmac
> +  required:
> +    - compatible
> +
> +allOf:
> +  - $ref: "snps,dwmac.yaml#"

Drop quotes.

> +
> +properties:
> +  compatible:
> +    additionalItems: true

No. Drop.

> +    maxItems: 3

No.

> +    items:
> +      - enum:
> +          - renesas,r9a06g032-gmac
> +          - renesas,rzn1-gmac
> +    contains:
> +      enum:
> +        - snps,dwmac

No, please list possibilities

> +
> +  pcs-handle:
> +    description:
> +      phandle pointing to a PCS sub-node compatible with
> +      renesas,rzn1-miic.yaml#
> +    $ref: /schemas/types.yaml#/definitions/phandle
> +
> +required:
> +  - compatible
> +
> +unevaluatedProperties: false
> +

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH net-next 3/6] net: stmmac: start phylink before setting up hardware
  2023-01-16 10:53   ` Russell King (Oracle)
@ 2023-02-07 14:41     ` Clément Léger
  2023-02-10 11:03       ` Russell King (Oracle)
  0 siblings, 1 reply; 14+ messages in thread
From: Clément Léger @ 2023-02-07 14:41 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Wong Vee Khee,
	Kurt Kanzenbach, Revanth Kumar Uppala, Tan Tee Min,
	Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

Le Mon, 16 Jan 2023 10:53:49 +0000,
"Russell King (Oracle)" <linux@armlinux.org.uk> a écrit :

> On Mon, Jan 16, 2023 at 11:39:23AM +0100, Clément Léger wrote:
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > index f2247b8cf0a3..88c941003855 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > @@ -3818,6 +3818,12 @@ static int __stmmac_open(struct net_device *dev,
> >  		}
> >  	}
> >  
> > +	/* We need to setup the phy & PCS before accessing the stmmac registers
> > +	 * because in some cases (RZ/N1), if the stmmac IP is not clocked by the
> > +	 * PCS, hardware init will fail because it lacks a RGMII RX clock.
> > +	 */
> > +	phylink_start(priv->phylink);  
> 
> So what happens if you end up with the mac_link_up method being called
> at this point in the driver, before the hardware has been setup ?
> 
> If you use a fixed-link, that's a real possibility.

I actually have this setup. On the board, one GMAC is connected to a
DSA switch using a fixed-link and the other using the PCS such as added
by this series.

From what I see, indeed, the mac_link_up() function is called before
stmmac_hw_setup(). This does not seems to have any effect on my setup
(except making it working of course) but I agree this is clearly not
ideal.

What I could do is adding a function in the miic pcs driver that could
be called from my rzn1 stmmac probe function to actually configure the
PCS at probe time based on the detected "phy-mode". Does that seems
better to you ?

Thanks,

-- 
Clément Léger,
Embedded Linux and Kernel engineer at Bootlin
https://bootlin.com

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH net-next 3/6] net: stmmac: start phylink before setting up hardware
  2023-02-07 14:41     ` Clément Léger
@ 2023-02-10 11:03       ` Russell King (Oracle)
  2023-02-10 11:20         ` Clément Léger
  0 siblings, 1 reply; 14+ messages in thread
From: Russell King (Oracle) @ 2023-02-10 11:03 UTC (permalink / raw)
  To: Clément Léger, Clark Wang
  Cc: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Wong Vee Khee,
	Kurt Kanzenbach, Revanth Kumar Uppala, Tan Tee Min,
	Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

On Tue, Feb 07, 2023 at 03:41:35PM +0100, Clément Léger wrote:
> Le Mon, 16 Jan 2023 10:53:49 +0000,
> "Russell King (Oracle)" <linux@armlinux.org.uk> a écrit :
> 
> > On Mon, Jan 16, 2023 at 11:39:23AM +0100, Clément Léger wrote:
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > index f2247b8cf0a3..88c941003855 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > @@ -3818,6 +3818,12 @@ static int __stmmac_open(struct net_device *dev,
> > >  		}
> > >  	}
> > >  
> > > +	/* We need to setup the phy & PCS before accessing the stmmac registers
> > > +	 * because in some cases (RZ/N1), if the stmmac IP is not clocked by the
> > > +	 * PCS, hardware init will fail because it lacks a RGMII RX clock.
> > > +	 */
> > > +	phylink_start(priv->phylink);  
> > 
> > So what happens if you end up with the mac_link_up method being called
> > at this point in the driver, before the hardware has been setup ?
> > 
> > If you use a fixed-link, that's a real possibility.
> 
> I actually have this setup. On the board, one GMAC is connected to a
> DSA switch using a fixed-link and the other using the PCS such as added
> by this series.
> 
> From what I see, indeed, the mac_link_up() function is called before
> stmmac_hw_setup(). This does not seems to have any effect on my setup
> (except making it working of course) but I agree this is clearly not
> ideal.
> 
> What I could do is adding a function in the miic pcs driver that could
> be called from my rzn1 stmmac probe function to actually configure the
> PCS at probe time based on the detected "phy-mode". Does that seems
> better to you ?

I think Clark Wang is also working on addressing a very similar problem
with stmmac. Please can you check out his work first, he's adding a new
function to phylink to bring the PHY up early in the resume path.

I would like you both to work together to address what seems to be the
same issue.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH net-next 3/6] net: stmmac: start phylink before setting up hardware
  2023-02-10 11:03       ` Russell King (Oracle)
@ 2023-02-10 11:20         ` Clément Léger
  0 siblings, 0 replies; 14+ messages in thread
From: Clément Léger @ 2023-02-10 11:20 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Clark Wang, Sergey Shtylyov, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Geert Uytterhoeven, Magnus Damm, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, Maxime Coquelin, Wong Vee Khee,
	Kurt Kanzenbach, Revanth Kumar Uppala, Tan Tee Min,
	Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard,
	Mohammad Athari Bin Ismail, Jon Hunter, netdev,
	linux-renesas-soc, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

Le Fri, 10 Feb 2023 11:03:34 +0000,
"Russell King (Oracle)" <linux@armlinux.org.uk> a écrit :

> On Tue, Feb 07, 2023 at 03:41:35PM +0100, Clément Léger wrote:
> > Le Mon, 16 Jan 2023 10:53:49 +0000,
> > "Russell King (Oracle)" <linux@armlinux.org.uk> a écrit :
> >   
> > > On Mon, Jan 16, 2023 at 11:39:23AM +0100, Clément Léger wrote:  
> > > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > > index f2247b8cf0a3..88c941003855 100644
> > > > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > > @@ -3818,6 +3818,12 @@ static int __stmmac_open(struct net_device *dev,
> > > >  		}
> > > >  	}
> > > >  
> > > > +	/* We need to setup the phy & PCS before accessing the stmmac registers
> > > > +	 * because in some cases (RZ/N1), if the stmmac IP is not clocked by the
> > > > +	 * PCS, hardware init will fail because it lacks a RGMII RX clock.
> > > > +	 */
> > > > +	phylink_start(priv->phylink);    
> > > 
> > > So what happens if you end up with the mac_link_up method being called
> > > at this point in the driver, before the hardware has been setup ?
> > > 
> > > If you use a fixed-link, that's a real possibility.  
> > 
> > I actually have this setup. On the board, one GMAC is connected to a
> > DSA switch using a fixed-link and the other using the PCS such as added
> > by this series.
> > 
> > From what I see, indeed, the mac_link_up() function is called before
> > stmmac_hw_setup(). This does not seems to have any effect on my setup
> > (except making it working of course) but I agree this is clearly not
> > ideal.
> > 
> > What I could do is adding a function in the miic pcs driver that could
> > be called from my rzn1 stmmac probe function to actually configure the
> > PCS at probe time based on the detected "phy-mode". Does that seems
> > better to you ?  
> 
> I think Clark Wang is also working on addressing a very similar problem
> with stmmac. Please can you check out his work first, he's adding a new
> function to phylink to bring the PHY up early in the resume path.
> 
> I would like you both to work together to address what seems to be the
> same issue.
> 

Acked

-- 
Clément Léger,
Embedded Linux and Kernel engineer at Bootlin
https://bootlin.com

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-02-10 11:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-16 10:39 [PATCH net-next 0/6] net: stmmac: add renesas,rzn1-gmac support Clément Léger
2023-01-16 10:39 ` [PATCH net-next 1/6] net: stmmac: add support to use a generic phylink_pcs as PCS Clément Léger
2023-01-16 10:39 ` [PATCH net-next 2/6] net: stmmac: add support to provide pcs from platform data Clément Léger
2023-01-16 10:39 ` [PATCH net-next 3/6] net: stmmac: start phylink before setting up hardware Clément Léger
2023-01-16 10:53   ` Russell King (Oracle)
2023-02-07 14:41     ` Clément Léger
2023-02-10 11:03       ` Russell King (Oracle)
2023-02-10 11:20         ` Clément Léger
2023-01-16 10:39 ` [PATCH net-next 4/6] dt-bindings: net: renesas,rzn1-gmac: Document RZ/N1 GMAC support Clément Léger
2023-01-16 12:27   ` Geert Uytterhoeven
2023-01-16 16:36   ` Rob Herring
2023-01-22 14:19   ` Krzysztof Kozlowski
2023-01-16 10:39 ` [PATCH net-next 5/6] net: stmmac: add support for RZ/N1 GMAC Clément Léger
2023-01-16 10:39 ` [PATCH net-next 6/6] ARM: dts: r9a06g032: describe GMAC1 Clément Léger

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).