devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 0/2] net: stmmac: dwc-qos: Add FSD EQoS support
       [not found] <CGME20250220044123epcas5p1eb9f906067a6e2585f9e4598653857fd@epcas5p1.samsung.com>
@ 2025-02-20  4:37 ` Swathi K S
       [not found]   ` <CGME20250220044128epcas5p1484d81bea4377bef4cbe7bc7b9f03713@epcas5p1.samsung.com>
       [not found]   ` <CGME20250220044132epcas5p305e4ed7ed1c84f9800299c2091ea0790@epcas5p3.samsung.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Swathi K S @ 2025-02-20  4:37 UTC (permalink / raw)
  To: krzk+dt, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	conor+dt, richardcochran, mcoquelin.stm32, alexandre.torgue
  Cc: rmk+kernel, swathi.ks, netdev, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, pankaj.dubey, ravi.patel,
	gost.dev

FSD platform has two instances of EQoS IP, one is in FSYS0 block and
another one is in PERIC block. This patch series add required DT binding
and platform driver specific changes for the same.

Changes since v1:
1. Updated dwc_eqos_setup_rxclock() function as per the review comments
given by Andrew.

Changes since v2:
1. Addressed all the review comments suggested by Krzysztof with respect to
DT binding file.
2. Added SOB Swathi.

Changes since v3:
1. Avoided using alias-id to configure the HW.
2. Modified the clock implementation.

Changes since v4:
1. Avoided switching between internal and external clocks for every open/
close.
2. Addressed the review comments on DT bindings

Changes since v5:
1. Addressed the review comment on correcting the intendation.
2. Corrected the compatible name in dt-binding file.
3. Listed and described the clocks in dt-binding.
4. Modified FSD probe as per the changes in the refactoring patch given
below: https://lore.kernel.org/netdev/20250207121849.55815-1-swathi.ks@samsung.com/

Changes since v6:
1. Addressed review comments by Krzysztof on dt-binding file regarding
clock-names property
2. Corrected indentation issue in dt-binding
3. Addressed Andrew's comment on listing phy-modes.

Here is the link to v6 patches for reference:
https://lore.kernel.org/netdev/20250213044624.37334-1-swathi.ks@samsung.com/

Swathi K S (2):
  dt-bindings: net: Add FSD EQoS device tree bindings
  net: stmmac: dwc-qos: Add FSD EQoS support

 .../devicetree/bindings/net/snps,dwmac.yaml   |   5 +-
 .../bindings/net/tesla,fsd-ethqos.yaml        | 115 ++++++++++++++++++
 .../stmicro/stmmac/dwmac-dwc-qos-eth.c        |  28 +++++
 3 files changed, 146 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/tesla,fsd-ethqos.yaml

-- 
2.17.1


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

* [PATCH v7 1/2] dt-bindings: net: Add FSD EQoS device tree bindings
       [not found]   ` <CGME20250220044128epcas5p1484d81bea4377bef4cbe7bc7b9f03713@epcas5p1.samsung.com>
@ 2025-02-20  4:37     ` Swathi K S
  2025-02-20  8:21       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 8+ messages in thread
From: Swathi K S @ 2025-02-20  4:37 UTC (permalink / raw)
  To: krzk+dt, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	conor+dt, richardcochran, mcoquelin.stm32, alexandre.torgue
  Cc: rmk+kernel, swathi.ks, netdev, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, pankaj.dubey, ravi.patel,
	gost.dev

Add FSD Ethernet compatible in Synopsys dt-bindings document. Add FSD
Ethernet YAML schema to enable the DT validation.

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Signed-off-by: Ravi Patel <ravi.patel@samsung.com>
Signed-off-by: Swathi K S <swathi.ks@samsung.com>
---
 .../devicetree/bindings/net/snps,dwmac.yaml   |   5 +-
 .../bindings/net/tesla,fsd-ethqos.yaml        | 115 ++++++++++++++++++
 2 files changed, 118 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/tesla,fsd-ethqos.yaml

diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
index 91e75eb3f329..c7004eaa8eae 100644
--- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
@@ -102,6 +102,7 @@ properties:
         - snps,dwxgmac-2.10
         - starfive,jh7100-dwmac
         - starfive,jh7110-dwmac
+        - tesla,fsd-ethqos
         - thead,th1520-gmac
 
   reg:
@@ -126,7 +127,7 @@ properties:
 
   clocks:
     minItems: 1
-    maxItems: 8
+    maxItems: 10
     additionalItems: true
     items:
       - description: GMAC main clock
@@ -138,7 +139,7 @@ properties:
 
   clock-names:
     minItems: 1
-    maxItems: 8
+    maxItems: 10
     additionalItems: true
     contains:
       enum:
diff --git a/Documentation/devicetree/bindings/net/tesla,fsd-ethqos.yaml b/Documentation/devicetree/bindings/net/tesla,fsd-ethqos.yaml
new file mode 100644
index 000000000000..538432158436
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/tesla,fsd-ethqos.yaml
@@ -0,0 +1,115 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/tesla,fsd-ethqos.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: FSD Ethernet Quality of Service
+
+maintainers:
+  - Swathi K S <swathi.ks@samsung.com>
+
+description:
+  Tesla ethernet devices based on dwmmac support Gigabit ethernet.
+
+allOf:
+  - $ref: snps,dwmac.yaml#
+
+properties:
+  compatible:
+    const: tesla,fsd-ethqos
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-names:
+    items:
+      - const: macirq
+
+  clocks:
+    minItems: 5
+    items:
+      - description: PTP clock
+      - description: Master bus clock
+      - description: Slave bus clock
+      - description: MAC TX clock
+      - description: MAC RX clock
+      - description: Master2 bus clock
+      - description: Slave2 bus clock
+      - description: RX MUX clock
+      - description: PHY RX clock
+      - description: PERIC RGMII clock
+
+  clock-names:
+    minItems: 5
+    items:
+      - const: ptp_ref
+      - const: master_bus
+      - const: slave_bus
+      - const: tx
+      - const: rx
+      - const: master2_bus
+      - const: slave2_bus
+      - const: eqos_rxclk_mux
+      - const: eqos_phyrxclk
+      - const: dout_peric_rgmii_clk
+
+  iommus:
+    maxItems: 1
+
+  phy-mode:
+    enum:
+      - rgmii
+      - rgmii-id
+      - rgmii-rxid
+      - rgmii-txid
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - iommus
+  - phy-mode
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/fsd-clk.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+        ethernet1: ethernet@14300000 {
+            compatible = "tesla,fsd-ethqos";
+            reg = <0x0 0x14300000 0x0 0x10000>;
+            interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
+            interrupt-names = "macirq";
+            clocks = <&clock_peric PERIC_EQOS_TOP_IPCLKPORT_CLK_PTP_REF_I>,
+                     <&clock_peric PERIC_EQOS_TOP_IPCLKPORT_ACLK_I>,
+                     <&clock_peric PERIC_EQOS_TOP_IPCLKPORT_HCLK_I>,
+                     <&clock_peric PERIC_EQOS_TOP_IPCLKPORT_RGMII_CLK_I>,
+                     <&clock_peric PERIC_EQOS_TOP_IPCLKPORT_CLK_RX_I>,
+                     <&clock_peric PERIC_BUS_D_PERIC_IPCLKPORT_EQOSCLK>,
+                     <&clock_peric PERIC_BUS_P_PERIC_IPCLKPORT_EQOSCLK>,
+                     <&clock_peric PERIC_EQOS_PHYRXCLK_MUX>,
+                     <&clock_peric PERIC_EQOS_PHYRXCLK>,
+                     <&clock_peric PERIC_DOUT_RGMII_CLK>;
+            clock-names = "ptp_ref", "master_bus", "slave_bus","tx",
+                          "rx", "master2_bus", "slave2_bus", "eqos_rxclk_mux",
+                          "eqos_phyrxclk","dout_peric_rgmii_clk";
+            pinctrl-names = "default";
+            pinctrl-0 = <&eth1_tx_clk>, <&eth1_tx_data>, <&eth1_tx_ctrl>,
+                        <&eth1_phy_intr>, <&eth1_rx_clk>, <&eth1_rx_data>,
+                        <&eth1_rx_ctrl>, <&eth1_mdio>;
+            iommus = <&smmu_peric 0x0 0x1>;
+            phy-mode = "rgmii-id";
+        };
+    };
+
+...
-- 
2.17.1


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

* [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS support
       [not found]   ` <CGME20250220044132epcas5p305e4ed7ed1c84f9800299c2091ea0790@epcas5p3.samsung.com>
@ 2025-02-20  4:37     ` Swathi K S
  2025-02-20 12:39       ` Russell King (Oracle)
  0 siblings, 1 reply; 8+ messages in thread
From: Swathi K S @ 2025-02-20  4:37 UTC (permalink / raw)
  To: krzk+dt, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	conor+dt, richardcochran, mcoquelin.stm32, alexandre.torgue
  Cc: rmk+kernel, swathi.ks, netdev, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, pankaj.dubey, ravi.patel,
	gost.dev

The FSD SoC contains two instance of the Synopsys DWC ethernet QOS IP core.
The binding that it uses is slightly different from existing ones because
of the integration (clocks, resets).

Signed-off-by: Swathi K S <swathi.ks@samsung.com>
---
 .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 1fadb8ba1d2f..22a263664f0a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -307,6 +307,29 @@ static void tegra_eqos_remove(struct platform_device *pdev)
 	gpiod_set_value(eqos->reset, 1);
 }
 
+static int fsd_eqos_probe(struct platform_device *pdev,
+			  struct plat_stmmacenet_data *data,
+			  struct stmmac_resources *res)
+{
+	struct clk *clk_rx1 = NULL;
+	struct clk *clk_rx2 = NULL;
+
+	for (int i = 0; i < data->num_clks; i++) {
+		if (strcmp(data->clks[i].id, "slave_bus") == 0)
+			data->stmmac_clk = data->clks[i].clk;
+		else if (strcmp(data->clks[i].id, "eqos_rxclk_mux") == 0)
+			clk_rx1 = data->clks[i].clk;
+		else if (strcmp(data->clks[i].id, "eqos_phyrxclk") == 0)
+			clk_rx2 = data->clks[i].clk;
+	}
+
+	/* Eth0 RX clock doesn't support MUX */
+	if (clk_rx1)
+		clk_set_parent(clk_rx1, clk_rx2);
+
+	return 0;
+}
+
 struct dwc_eth_dwmac_data {
 	int (*probe)(struct platform_device *pdev,
 		     struct plat_stmmacenet_data *data,
@@ -323,6 +346,10 @@ static const struct dwc_eth_dwmac_data tegra_eqos_data = {
 	.remove = tegra_eqos_remove,
 };
 
+static const struct dwc_eth_dwmac_data fsd_eqos_data = {
+	.probe = fsd_eqos_probe,
+};
+
 static int dwc_eth_dwmac_probe(struct platform_device *pdev)
 {
 	const struct dwc_eth_dwmac_data *data;
@@ -401,6 +428,7 @@ static void dwc_eth_dwmac_remove(struct platform_device *pdev)
 static const struct of_device_id dwc_eth_dwmac_match[] = {
 	{ .compatible = "snps,dwc-qos-ethernet-4.10", .data = &dwc_qos_data },
 	{ .compatible = "nvidia,tegra186-eqos", .data = &tegra_eqos_data },
+	{ .compatible = "tesla,fsd-ethqos", .data = &fsd_eqos_data },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, dwc_eth_dwmac_match);
-- 
2.17.1


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

* Re: [PATCH v7 1/2] dt-bindings: net: Add FSD EQoS device tree bindings
  2025-02-20  4:37     ` [PATCH v7 1/2] dt-bindings: net: Add FSD EQoS device tree bindings Swathi K S
@ 2025-02-20  8:21       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2025-02-20  8:21 UTC (permalink / raw)
  To: Swathi K S, krzk+dt, andrew+netdev, davem, edumazet, kuba, pabeni,
	robh, conor+dt, richardcochran, mcoquelin.stm32, alexandre.torgue
  Cc: rmk+kernel, netdev, devicetree, linux-stm32, linux-arm-kernel,
	linux-kernel, pankaj.dubey, ravi.patel, gost.dev

On 20/02/2025 05:37, Swathi K S wrote:
> Add FSD Ethernet compatible in Synopsys dt-bindings document. Add FSD
> Ethernet YAML schema to enable the DT validation.
> 
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> Signed-off-by: Ravi Patel <ravi.patel@samsung.com>
> Signed-off-by: Swathi K S <swathi.ks@samsung.com>
> ---

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof

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

* Re: [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS support
  2025-02-20  4:37     ` [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS support Swathi K S
@ 2025-02-20 12:39       ` Russell King (Oracle)
  2025-02-21 10:34         ` Swathi K S
  0 siblings, 1 reply; 8+ messages in thread
From: Russell King (Oracle) @ 2025-02-20 12:39 UTC (permalink / raw)
  To: Swathi K S
  Cc: krzk+dt, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	conor+dt, richardcochran, mcoquelin.stm32, alexandre.torgue,
	netdev, devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
	pankaj.dubey, ravi.patel, gost.dev

On Thu, Feb 20, 2025 at 10:07:12AM +0530, Swathi K S wrote:
> +static int fsd_eqos_probe(struct platform_device *pdev,
> +			  struct plat_stmmacenet_data *data,
> +			  struct stmmac_resources *res)
> +{
> +	struct clk *clk_rx1 = NULL;
> +	struct clk *clk_rx2 = NULL;
> +
> +	for (int i = 0; i < data->num_clks; i++) {
> +		if (strcmp(data->clks[i].id, "slave_bus") == 0)
> +			data->stmmac_clk = data->clks[i].clk;
> +		else if (strcmp(data->clks[i].id, "eqos_rxclk_mux") == 0)
> +			clk_rx1 = data->clks[i].clk;
> +		else if (strcmp(data->clks[i].id, "eqos_phyrxclk") == 0)
> +			clk_rx2 = data->clks[i].clk;
> +	}
> +
> +	/* Eth0 RX clock doesn't support MUX */
> +	if (clk_rx1)
> +		clk_set_parent(clk_rx1, clk_rx2);

Isn't there support in DT for automatically setting the clock tree?
See
https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/clock/clock.yaml#L24

Also, I think a cleanup like the below (sorry, it's on top of other
patches I'm working on at the moment but could be rebased) would
make sense.

With both of these, this should mean that your changes amount to:

1. making data->probe optional
2. providing a dwc_eth_dwmac_data structure that has .stmmac_clk_name
   filled in
3. adding your compatible to the match data with a pointer to the
   above structure.

In other words, support for your device becomes just a matter of adding
data structures rather than a chunk of extra code.

Thanks.

8<====
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Subject: [PATCH net-next] net: stmmac: clean up clock initialisation

Clean up the clock initialisation by providing a helper to find a
named clock in the bulk clocks, and provide the name of the stmmac
clock in match data so we can locate the stmmac clock in generic
code.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 32 +++++++++++--------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 581c0b40db57..8e343ab7a7e2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -34,6 +34,16 @@ struct tegra_eqos {
 	struct gpio_desc *reset;
 };
 
+static struct clk *dwc_eth_find_clk(struct plat_stmmacenet_data *plat_dat,
+				    const char *name)
+{
+	for (int i = 0; i < plat_dat->num_clks; i++)
+		if (strcmp(plat_dat->clks[i].id, name) == 0)
+			return plat_dat->clks[i].clk;
+
+	return 0;
+}
+
 static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
 				   struct plat_stmmacenet_data *plat_dat)
 {
@@ -120,12 +130,7 @@ static int dwc_qos_probe(struct platform_device *pdev,
 			 struct plat_stmmacenet_data *plat_dat,
 			 struct stmmac_resources *stmmac_res)
 {
-	for (int i = 0; i < plat_dat->num_clks; i++) {
-		if (strcmp(plat_dat->clks[i].id, "apb_pclk") == 0)
-			plat_dat->stmmac_clk = plat_dat->clks[i].clk;
-		else if (strcmp(plat_dat->clks[i].id, "phy_ref_clk") == 0)
-			plat_dat->pclk = plat_dat->clks[i].clk;
-	}
+	plat_dat->pclk = dwc_eth_find_clk(plat_dat, "phy_ref_clk");
 
 	return 0;
 }
@@ -230,18 +235,12 @@ static int tegra_eqos_probe(struct platform_device *pdev,
 
 	eqos->dev = &pdev->dev;
 	eqos->regs = res->addr;
+	eqos->clk_slave = data->stmmac_clk;
 
 	if (!is_of_node(dev->fwnode))
 		goto bypass_clk_reset_gpio;
 
-	for (int i = 0; i < data->num_clks; i++) {
-		if (strcmp(data->clks[i].id, "slave_bus") == 0) {
-			eqos->clk_slave = data->clks[i].clk;
-			data->stmmac_clk = eqos->clk_slave;
-		} else if (strcmp(data->clks[i].id, "tx") == 0) {
-			data->clk_tx_i = data->clks[i].clk;
-		}
-	}
+	data->clk_tx_i = dwc_eth_find_clk(data, "tx");
 
 	eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(eqos->reset)) {
@@ -306,15 +305,18 @@ struct dwc_eth_dwmac_data {
 		     struct plat_stmmacenet_data *data,
 		     struct stmmac_resources *res);
 	void (*remove)(struct platform_device *pdev);
+	const char *stmmac_clk_name;
 };
 
 static const struct dwc_eth_dwmac_data dwc_qos_data = {
 	.probe = dwc_qos_probe,
+	.stmmac_clk_name = "apb_pclk",
 };
 
 static const struct dwc_eth_dwmac_data tegra_eqos_data = {
 	.probe = tegra_eqos_probe,
 	.remove = tegra_eqos_remove,
+	.stmmac_clk_name = "slave_bus",
 };
 
 static int dwc_eth_dwmac_probe(struct platform_device *pdev)
@@ -354,6 +356,8 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret, "Failed to enable clocks\n");
 
+	data->stmmac_clk = dwc_eth_find_clk(plat_dat, data->stmmac_clk_name);
+
 	ret = data->probe(pdev, plat_dat, &stmmac_res);
 	if (ret < 0) {
 		dev_err_probe(&pdev->dev, ret, "failed to probe subdriver\n");
-- 
2.30.2


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

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

* RE: [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS support
  2025-02-20 12:39       ` Russell King (Oracle)
@ 2025-02-21 10:34         ` Swathi K S
  2025-02-21 11:49           ` Russell King (Oracle)
  0 siblings, 1 reply; 8+ messages in thread
From: Swathi K S @ 2025-02-21 10:34 UTC (permalink / raw)
  To: 'Russell King (Oracle)'
  Cc: krzk+dt, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	conor+dt, richardcochran, mcoquelin.stm32, alexandre.torgue,
	netdev, devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
	pankaj.dubey, ravi.patel, gost.dev



> -----Original Message-----
> From: Russell King (Oracle) <linux@armlinux.org.uk>
> Sent: 20 February 2025 18:10
> To: Swathi K S <swathi.ks@samsung.com>
> Cc: krzk+dt@kernel.org; andrew+netdev@lunn.ch; davem@davemloft.net;
> edumazet@google.com; kuba@kernel.org; pabeni@redhat.com;
> robh@kernel.org; conor+dt@kernel.org; richardcochran@gmail.com;
> mcoquelin.stm32@gmail.com; alexandre.torgue@foss.st.com;
> netdev@vger.kernel.org; devicetree@vger.kernel.org; linux-stm32@st-md-
> mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; pankaj.dubey@samsung.com;
> ravi.patel@samsung.com; gost.dev@samsung.com
> Subject: Re: [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS support
> 
> On Thu, Feb 20, 2025 at 10:07:12AM +0530, Swathi K S wrote:
> > +static int fsd_eqos_probe(struct platform_device *pdev,
> > +			  struct plat_stmmacenet_data *data,
> > +			  struct stmmac_resources *res)
> > +{
> > +	struct clk *clk_rx1 = NULL;
> > +	struct clk *clk_rx2 = NULL;
> > +
> > +	for (int i = 0; i < data->num_clks; i++) {
> > +		if (strcmp(data->clks[i].id, "slave_bus") == 0)
> > +			data->stmmac_clk = data->clks[i].clk;
> > +		else if (strcmp(data->clks[i].id, "eqos_rxclk_mux") == 0)
> > +			clk_rx1 = data->clks[i].clk;
> > +		else if (strcmp(data->clks[i].id, "eqos_phyrxclk") == 0)
> > +			clk_rx2 = data->clks[i].clk;
> > +	}
> > +
> > +	/* Eth0 RX clock doesn't support MUX */
> > +	if (clk_rx1)
> > +		clk_set_parent(clk_rx1, clk_rx2);
> 
> Isn't there support in DT for automatically setting the clock tree?
> See
> https://protect2.fireeye.com/v1/url?k=f0089f78-90ea0225-f0091437-
> 000babd9f1ba-cf835b8b94ccd94a&q=1&e=4ae794ec-f443-4d77-aee4-
> 449f53a3a1a4&u=https%3A%2F%2Fgithub.com%2Fdevicetree-org%2Fdt-
> schema%2Fblob%2Fmain%2Fdtschema%2Fschemas%2Fclock%2Fclock.yaml
> %23L24
> 
> Also, I think a cleanup like the below (sorry, it's on top of other
patches I'm
> working on at the moment but could be rebased) would make sense.
> 
> With both of these, this should mean that your changes amount to:
> 
> 1. making data->probe optional
> 2. providing a dwc_eth_dwmac_data structure that has .stmmac_clk_name
>    filled in
> 3. adding your compatible to the match data with a pointer to the
>    above structure.

Hi Russell, 
Thanks for your input.
Will implement this in v8.
But I could not find your patch 'net: stmmac: clean up clock initialisation'
in mailing list
Could you point me to that?
Or do you want me to integrate the below changes into my patch series and
post?

Please let me know

- Swathi

> 
> In other words, support for your device becomes just a matter of adding
data
> structures rather than a chunk of extra code.
> 
> Thanks.
> 
> 8<====
> From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
> Subject: [PATCH net-next] net: stmmac: clean up clock initialisation
> 
> Clean up the clock initialisation by providing a helper to find a named
clock in
> the bulk clocks, and provide the name of the stmmac clock in match data so
> we can locate the stmmac clock in generic code.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 32 +++++++++++--------
>  1 file changed, 18 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> index 581c0b40db57..8e343ab7a7e2 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> @@ -34,6 +34,16 @@ struct tegra_eqos {
>  	struct gpio_desc *reset;
>  };
> 
> +static struct clk *dwc_eth_find_clk(struct plat_stmmacenet_data
*plat_dat,
> +				    const char *name)
> +{
> +	for (int i = 0; i < plat_dat->num_clks; i++)
> +		if (strcmp(plat_dat->clks[i].id, name) == 0)
> +			return plat_dat->clks[i].clk;
> +
> +	return 0;
> +}
> +
>  static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
>  				   struct plat_stmmacenet_data *plat_dat)  {
> @@ -120,12 +130,7 @@ static int dwc_qos_probe(struct platform_device
> *pdev,
>  			 struct plat_stmmacenet_data *plat_dat,
>  			 struct stmmac_resources *stmmac_res)  {
> -	for (int i = 0; i < plat_dat->num_clks; i++) {
> -		if (strcmp(plat_dat->clks[i].id, "apb_pclk") == 0)
> -			plat_dat->stmmac_clk = plat_dat->clks[i].clk;
> -		else if (strcmp(plat_dat->clks[i].id, "phy_ref_clk") == 0)
> -			plat_dat->pclk = plat_dat->clks[i].clk;
> -	}
> +	plat_dat->pclk = dwc_eth_find_clk(plat_dat, "phy_ref_clk");
> 
>  	return 0;
>  }
> @@ -230,18 +235,12 @@ static int tegra_eqos_probe(struct platform_device
> *pdev,
> 
>  	eqos->dev = &pdev->dev;
>  	eqos->regs = res->addr;
> +	eqos->clk_slave = data->stmmac_clk;
> 
>  	if (!is_of_node(dev->fwnode))
>  		goto bypass_clk_reset_gpio;
> 
> -	for (int i = 0; i < data->num_clks; i++) {
> -		if (strcmp(data->clks[i].id, "slave_bus") == 0) {
> -			eqos->clk_slave = data->clks[i].clk;
> -			data->stmmac_clk = eqos->clk_slave;
> -		} else if (strcmp(data->clks[i].id, "tx") == 0) {
> -			data->clk_tx_i = data->clks[i].clk;
> -		}
> -	}
> +	data->clk_tx_i = dwc_eth_find_clk(data, "tx");
> 
>  	eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset",
> GPIOD_OUT_HIGH);
>  	if (IS_ERR(eqos->reset)) {
> @@ -306,15 +305,18 @@ struct dwc_eth_dwmac_data {
>  		     struct plat_stmmacenet_data *data,
>  		     struct stmmac_resources *res);
>  	void (*remove)(struct platform_device *pdev);
> +	const char *stmmac_clk_name;
>  };
> 
>  static const struct dwc_eth_dwmac_data dwc_qos_data = {
>  	.probe = dwc_qos_probe,
> +	.stmmac_clk_name = "apb_pclk",
>  };
> 
>  static const struct dwc_eth_dwmac_data tegra_eqos_data = {
>  	.probe = tegra_eqos_probe,
>  	.remove = tegra_eqos_remove,
> +	.stmmac_clk_name = "slave_bus",
>  };
> 
>  static int dwc_eth_dwmac_probe(struct platform_device *pdev) @@ -354,6
> +356,8 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
>  	if (ret)
>  		return dev_err_probe(&pdev->dev, ret, "Failed to enable
> clocks\n");
> 
> +	data->stmmac_clk = dwc_eth_find_clk(plat_dat, data-
> >stmmac_clk_name);
> +
>  	ret = data->probe(pdev, plat_dat, &stmmac_res);
>  	if (ret < 0) {
>  		dev_err_probe(&pdev->dev, ret, "failed to probe
> subdriver\n");
> --
> 2.30.2
> 
> 
> --
> RMK's Patch system: https://protect2.fireeye.com/v1/url?k=bd23955d-
> ddc10800-bd221e12-000babd9f1ba-890d84739eaced1c&q=1&e=4ae794ec-
> f443-4d77-aee4-
> 449f53a3a1a4&u=https%3A%2F%2Fwww.armlinux.org.uk%2Fdeveloper%2F
> patches%2F
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!


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

* Re: [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS support
  2025-02-21 10:34         ` Swathi K S
@ 2025-02-21 11:49           ` Russell King (Oracle)
  2025-02-21 12:56             ` Swathi K S
  0 siblings, 1 reply; 8+ messages in thread
From: Russell King (Oracle) @ 2025-02-21 11:49 UTC (permalink / raw)
  To: Swathi K S
  Cc: krzk+dt, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	conor+dt, richardcochran, mcoquelin.stm32, alexandre.torgue,
	netdev, devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
	pankaj.dubey, ravi.patel, gost.dev

On Fri, Feb 21, 2025 at 04:04:25PM +0530, Swathi K S wrote:
> 
> 
> > -----Original Message-----
> > From: Russell King (Oracle) <linux@armlinux.org.uk>
> > Sent: 20 February 2025 18:10
> > To: Swathi K S <swathi.ks@samsung.com>
> > Cc: krzk+dt@kernel.org; andrew+netdev@lunn.ch; davem@davemloft.net;
> > edumazet@google.com; kuba@kernel.org; pabeni@redhat.com;
> > robh@kernel.org; conor+dt@kernel.org; richardcochran@gmail.com;
> > mcoquelin.stm32@gmail.com; alexandre.torgue@foss.st.com;
> > netdev@vger.kernel.org; devicetree@vger.kernel.org; linux-stm32@st-md-
> > mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-
> > kernel@vger.kernel.org; pankaj.dubey@samsung.com;
> > ravi.patel@samsung.com; gost.dev@samsung.com
> > Subject: Re: [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS support
> > 
> > On Thu, Feb 20, 2025 at 10:07:12AM +0530, Swathi K S wrote:
> > > +static int fsd_eqos_probe(struct platform_device *pdev,
> > > +			  struct plat_stmmacenet_data *data,
> > > +			  struct stmmac_resources *res)
> > > +{
> > > +	struct clk *clk_rx1 = NULL;
> > > +	struct clk *clk_rx2 = NULL;
> > > +
> > > +	for (int i = 0; i < data->num_clks; i++) {
> > > +		if (strcmp(data->clks[i].id, "slave_bus") == 0)
> > > +			data->stmmac_clk = data->clks[i].clk;
> > > +		else if (strcmp(data->clks[i].id, "eqos_rxclk_mux") == 0)
> > > +			clk_rx1 = data->clks[i].clk;
> > > +		else if (strcmp(data->clks[i].id, "eqos_phyrxclk") == 0)
> > > +			clk_rx2 = data->clks[i].clk;
> > > +	}
> > > +
> > > +	/* Eth0 RX clock doesn't support MUX */
> > > +	if (clk_rx1)
> > > +		clk_set_parent(clk_rx1, clk_rx2);
> > 
> > Isn't there support in DT for automatically setting the clock tree?
> > See
> > https://protect2.fireeye.com/v1/url?k=f0089f78-90ea0225-f0091437-
> > 000babd9f1ba-cf835b8b94ccd94a&q=1&e=4ae794ec-f443-4d77-aee4-
> > 449f53a3a1a4&u=https%3A%2F%2Fgithub.com%2Fdevicetree-org%2Fdt-
> > schema%2Fblob%2Fmain%2Fdtschema%2Fschemas%2Fclock%2Fclock.yaml
> > %23L24
> > 
> > Also, I think a cleanup like the below (sorry, it's on top of other
> patches I'm
> > working on at the moment but could be rebased) would make sense.
> > 
> > With both of these, this should mean that your changes amount to:
> > 
> > 1. making data->probe optional
> > 2. providing a dwc_eth_dwmac_data structure that has .stmmac_clk_name
> >    filled in
> > 3. adding your compatible to the match data with a pointer to the
> >    above structure.
> 
> Hi Russell, 
> Thanks for your input.
> Will implement this in v8.
> But I could not find your patch 'net: stmmac: clean up clock initialisation'
> in mailing list
> Could you point me to that?
> Or do you want me to integrate the below changes into my patch series and
> post?
> 
> Please let me know

Please have patience - I'm a volunteer here, and I included the patch in
the email for you. You're not the only one whom I'm addressing issues in
the stmmac driver for. Since Sunday, I have a total of 16 new stmmac
patches plus been debugging a regression someone has reported.

Coincidentally, I just sent out the patch as a stand-alone patch, it
should be quicker to get it into net-next rather than trying to get all
the other patches I'd *already* had queued up in first.

https://lore.kernel.org/r/E1tlRMP-004Vt5-W1@rmk-PC.armlinux.org.uk

However, I'm expecting someone to say that dwc_eth_find_clk() should be
moved into the stmmac platform code, and the other platforms need to be
converted to use it... so it may be some time before we're at a stage
where you can proceed.

Please be patient.

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

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

* RE: [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS support
  2025-02-21 11:49           ` Russell King (Oracle)
@ 2025-02-21 12:56             ` Swathi K S
  0 siblings, 0 replies; 8+ messages in thread
From: Swathi K S @ 2025-02-21 12:56 UTC (permalink / raw)
  To: 'Russell King (Oracle)'
  Cc: krzk+dt, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
	conor+dt, richardcochran, mcoquelin.stm32, alexandre.torgue,
	netdev, devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
	pankaj.dubey, ravi.patel, gost.dev



> -----Original Message-----
> From: Russell King (Oracle) <linux@armlinux.org.uk>
> Sent: 21 February 2025 17:20
> To: Swathi K S <swathi.ks@samsung.com>
> Cc: krzk+dt@kernel.org; andrew+netdev@lunn.ch; davem@davemloft.net;
> edumazet@google.com; kuba@kernel.org; pabeni@redhat.com;
> robh@kernel.org; conor+dt@kernel.org; richardcochran@gmail.com;
> mcoquelin.stm32@gmail.com; alexandre.torgue@foss.st.com;
> netdev@vger.kernel.org; devicetree@vger.kernel.org; linux-stm32@st-md-
> mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; pankaj.dubey@samsung.com;
> ravi.patel@samsung.com; gost.dev@samsung.com
> Subject: Re: [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS support
> 
> On Fri, Feb 21, 2025 at 04:04:25PM +0530, Swathi K S wrote:
> >
> >
> > > -----Original Message-----
> > > From: Russell King (Oracle) <linux@armlinux.org.uk>
> > > Sent: 20 February 2025 18:10
> > > To: Swathi K S <swathi.ks@samsung.com>
> > > Cc: krzk+dt@kernel.org; andrew+netdev@lunn.ch;
> davem@davemloft.net;
> > > edumazet@google.com; kuba@kernel.org; pabeni@redhat.com;
> > > robh@kernel.org; conor+dt@kernel.org; richardcochran@gmail.com;
> > > mcoquelin.stm32@gmail.com; alexandre.torgue@foss.st.com;
> > > netdev@vger.kernel.org; devicetree@vger.kernel.org;
> > > linux-stm32@st-md- mailman.stormreply.com;
> > > linux-arm-kernel@lists.infradead.org; linux- kernel@vger.kernel.org;
> > > pankaj.dubey@samsung.com; ravi.patel@samsung.com;
> > > gost.dev@samsung.com
> > > Subject: Re: [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS
> > > support
> > >
> > > On Thu, Feb 20, 2025 at 10:07:12AM +0530, Swathi K S wrote:
> > > > +static int fsd_eqos_probe(struct platform_device *pdev,
> > > > +			  struct plat_stmmacenet_data *data,
> > > > +			  struct stmmac_resources *res) {
> > > > +	struct clk *clk_rx1 = NULL;
> > > > +	struct clk *clk_rx2 = NULL;
> > > > +
> > > > +	for (int i = 0; i < data->num_clks; i++) {
> > > > +		if (strcmp(data->clks[i].id, "slave_bus") == 0)
> > > > +			data->stmmac_clk = data->clks[i].clk;
> > > > +		else if (strcmp(data->clks[i].id, "eqos_rxclk_mux")
== 0)
> > > > +			clk_rx1 = data->clks[i].clk;
> > > > +		else if (strcmp(data->clks[i].id, "eqos_phyrxclk")
== 0)
> > > > +			clk_rx2 = data->clks[i].clk;
> > > > +	}
> > > > +
> > > > +	/* Eth0 RX clock doesn't support MUX */
> > > > +	if (clk_rx1)
> > > > +		clk_set_parent(clk_rx1, clk_rx2);
> > >
> > > Isn't there support in DT for automatically setting the clock tree?
> > > See
> > > https://protect2.fireeye.com/v1/url?k=f0089f78-90ea0225-f0091437-
> > > 000babd9f1ba-cf835b8b94ccd94a&q=1&e=4ae794ec-f443-4d77-aee4-
> > > 449f53a3a1a4&u=https%3A%2F%2Fgithub.com%2Fdevicetree-org%2Fdt-
> > >
> schema%2Fblob%2Fmain%2Fdtschema%2Fschemas%2Fclock%2Fclock.yaml
> > > %23L24
> > >
> > > Also, I think a cleanup like the below (sorry, it's on top of other
> > patches I'm
> > > working on at the moment but could be rebased) would make sense.
> > >
> > > With both of these, this should mean that your changes amount to:
> > >
> > > 1. making data->probe optional
> > > 2. providing a dwc_eth_dwmac_data structure that has
> .stmmac_clk_name
> > >    filled in
> > > 3. adding your compatible to the match data with a pointer to the
> > >    above structure.
> >
> > Hi Russell,
> > Thanks for your input.
> > Will implement this in v8.
> > But I could not find your patch 'net: stmmac: clean up clock
initialisation'
> > in mailing list
> > Could you point me to that?
> > Or do you want me to integrate the below changes into my patch series
> > and post?
> >
> > Please let me know
> 
> Please have patience - I'm a volunteer here, and I included the patch in
the
> email for you. You're not the only one whom I'm addressing issues in the
> stmmac driver for. Since Sunday, I have a total of 16 new stmmac patches
> plus been debugging a regression someone has reported.

I understand your concern and thanks for improving the code.

> 
> Coincidentally, I just sent out the patch as a stand-alone patch, it
should be
> quicker to get it into net-next rather than trying to get all the other
patches
> I'd *already* had queued up in first.
> 
> https://lore.kernel.org/r/E1tlRMP-004Vt5-W1@rmk-PC.armlinux.org.uk

Will test your patch on FSD platform.

- Swathi

> 
> However, I'm expecting someone to say that dwc_eth_find_clk() should be
> moved into the stmmac platform code, and the other platforms need to be
> converted to use it... so it may be some time before we're at a stage
where
> you can proceed.
> 
> Please be patient.
> 
> --
> RMK's Patch system: https://protect2.fireeye.com/v1/url?k=9539722c-
> f442d8a5-9538f963-74fe48600034-5bc44de329219ee1&q=1&e=0bc950e5-
> 2fde-481e-bce0-
> 534d0f94352b&u=https%3A%2F%2Fwww.armlinux.org.uk%2Fdeveloper%2F
> patches%2F
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!


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

end of thread, other threads:[~2025-02-22 10:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20250220044123epcas5p1eb9f906067a6e2585f9e4598653857fd@epcas5p1.samsung.com>
2025-02-20  4:37 ` [PATCH v7 0/2] net: stmmac: dwc-qos: Add FSD EQoS support Swathi K S
     [not found]   ` <CGME20250220044128epcas5p1484d81bea4377bef4cbe7bc7b9f03713@epcas5p1.samsung.com>
2025-02-20  4:37     ` [PATCH v7 1/2] dt-bindings: net: Add FSD EQoS device tree bindings Swathi K S
2025-02-20  8:21       ` Krzysztof Kozlowski
     [not found]   ` <CGME20250220044132epcas5p305e4ed7ed1c84f9800299c2091ea0790@epcas5p3.samsung.com>
2025-02-20  4:37     ` [PATCH v7 2/2] net: stmmac: dwc-qos: Add FSD EQoS support Swathi K S
2025-02-20 12:39       ` Russell King (Oracle)
2025-02-21 10:34         ` Swathi K S
2025-02-21 11:49           ` Russell King (Oracle)
2025-02-21 12:56             ` Swathi K S

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