devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044
@ 2025-03-05  6:39 Inochi Amaoto
  2025-03-05  6:39 ` [PATCH net-next v6 1/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac Inochi Amaoto
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Inochi Amaoto @ 2025-03-05  6:39 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Chen Wang, Inochi Amaoto, Maxime Coquelin, Alexandre Torgue,
	Richard Cochran, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Romain Gantois, Hariprasad Kelam, Jisheng Zhang,
	Clément Léger, Jan Petrous (OSS), Simon Horman,
	Furong Xu, Lothar Rubusch, Joe Hattori, Bartosz Golaszewski,
	Giuseppe Cavallaro, Jose Abreu
  Cc: netdev, devicetree, linux-kernel, sophgo, linux-stm32,
	linux-arm-kernel, linux-riscv, Yixun Lan, Longbin Li

The ethernet controller of SG2044 is Synopsys DesignWare IP with
custom clock. Add glue layer for it.

Changed from v5:
- https://lore.kernel.org/netdev/20250216123953.1252523-1-inochiama@gmail.com/
1. apply Andrew's tag for patch 2,3
3. patch 1: add dma-noncoherent property.
2. patch 2,3: separate original patch into 2 part
4. patch 4: adopt new stmmac_set_clk_tx_rate helper function

Changed from v4:
- https://lore.kernel.org/netdev/20250209013054.816580-1-inochiama@gmail.com/
1. apply Romain's tag
2. patch 3: use device variable to replace &pdev->dev.
3. patch 3: remove unused include.
4. patch 3: make error message more useful.

Changed from v3:
- https://lore.kernel.org/netdev/20241223005843.483805-1-inochiama@gmail.com/
1. rebase for 6.14.rc1
2. remove the dependency requirement as it was already merged
   into master.

Changed from RFC:
- https://lore.kernel.org/netdev/20241101014327.513732-1-inochiama@gmail.com/
1. patch 1: apply Krzysztof' tag

Changed from v2:
- https://lore.kernel.org/netdev/20241025011000.244350-1-inochiama@gmail.com/
1. patch 1: merge the first and the second bindings patch to show the all
            compatible change.
2. patch 2: use of_device_compatible_match helper function to perform check.
2. patch 3: remove unused include and sort the left.
3. patch 3: fix wrong variable usage in sophgo_dwmac_fix_mac_speed
4. patch 3: drop unused variable in the patch.

Changed from v1:
- https://lore.kernel.org/netdev/20241021103617.653386-1-inochiama@gmail.com/
1. patch 2: remove sophgo,syscon as this mac delay is resolved.
2. patch 2: apply all the properties unconditionally.
3. patch 4: remove sophgo,syscon code as this mac delay is resolved.
4. patch 4: use the helper function to compute rgmii clock.
5. patch 4: use remove instead of remove_new for the platform driver.

Inochi Amaoto (4):
  dt-bindings: net: Add support for Sophgo SG2044 dwmac
  net: stmmac: platform: Group GMAC4 compatible check
  net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string
  net: stmmac: Add glue layer for Sophgo SG2044 SoC

 .../devicetree/bindings/net/snps,dwmac.yaml   |   4 +
 .../bindings/net/sophgo,sg2044-dwmac.yaml     | 126 ++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  11 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../ethernet/stmicro/stmmac/dwmac-sophgo.c    |  75 +++++++++++
 .../ethernet/stmicro/stmmac/stmmac_platform.c |  17 ++-
 6 files changed, 229 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c

--
2.48.1


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

* [PATCH net-next v6 1/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac
  2025-03-05  6:39 [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044 Inochi Amaoto
@ 2025-03-05  6:39 ` Inochi Amaoto
  2025-03-05  6:45   ` Inochi Amaoto
  2025-03-05  6:39 ` [PATCH net-next v6 2/4] net: stmmac: platform: Group GMAC4 compatible check Inochi Amaoto
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Inochi Amaoto @ 2025-03-05  6:39 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Chen Wang, Inochi Amaoto, Maxime Coquelin, Alexandre Torgue,
	Richard Cochran, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Romain Gantois, Hariprasad Kelam, Jisheng Zhang,
	Clément Léger, Jan Petrous (OSS), Simon Horman,
	Furong Xu, Lothar Rubusch, Joe Hattori, Bartosz Golaszewski,
	Giuseppe Cavallaro, Jose Abreu
  Cc: netdev, devicetree, linux-kernel, sophgo, linux-stm32,
	linux-arm-kernel, linux-riscv, Yixun Lan, Longbin Li,
	Krzysztof Kozlowski

The GMAC IP on SG2044 is almost a standard Synopsys DesignWare
MAC (version 5.30a) with some extra clock.

Add necessary compatible string for this device.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 .../devicetree/bindings/net/snps,dwmac.yaml   |   4 +
 .../bindings/net/sophgo,sg2044-dwmac.yaml     | 126 ++++++++++++++++++
 2 files changed, 130 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml

diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
index 91e75eb3f329..02ab6a9aded2 100644
--- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
@@ -32,6 +32,7 @@ select:
           - snps,dwmac-4.20a
           - snps,dwmac-5.10a
           - snps,dwmac-5.20
+          - snps,dwmac-5.30a
           - snps,dwxgmac
           - snps,dwxgmac-2.10
 
@@ -98,8 +99,10 @@ properties:
         - snps,dwmac-4.20a
         - snps,dwmac-5.10a
         - snps,dwmac-5.20
+        - snps,dwmac-5.30a
         - snps,dwxgmac
         - snps,dwxgmac-2.10
+        - sophgo,sg2044-dwmac
         - starfive,jh7100-dwmac
         - starfive,jh7110-dwmac
         - thead,th1520-gmac
@@ -631,6 +634,7 @@ allOf:
                 - snps,dwmac-4.20a
                 - snps,dwmac-5.10a
                 - snps,dwmac-5.20
+                - snps,dwmac-5.30a
                 - snps,dwxgmac
                 - snps,dwxgmac-2.10
                 - st,spear600-gmac
diff --git a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
new file mode 100644
index 000000000000..4dd2dc9c678b
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
@@ -0,0 +1,126 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/sophgo,sg2044-dwmac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sophgo SG2044 DWMAC glue layer
+
+maintainers:
+  - Inochi Amaoto <inochiama@gmail.com>
+
+select:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - sophgo,sg2044-dwmac
+  required:
+    - compatible
+
+properties:
+  compatible:
+    items:
+      - const: sophgo,sg2044-dwmac
+      - const: snps,dwmac-5.30a
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: GMAC main clock
+      - description: PTP clock
+      - description: TX clock
+
+  clock-names:
+    items:
+      - const: stmmaceth
+      - const: ptp_ref
+      - const: tx
+
+  dma-noncoherent: true
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-names:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    const: stmmaceth
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - interrupts
+  - interrupt-names
+  - resets
+  - reset-names
+
+allOf:
+  - $ref: snps,dwmac.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    ethernet@30006000 {
+      compatible = "sophgo,sg2044-dwmac", "snps,dwmac-5.30a";
+      reg = <0x30006000 0x4000>;
+      clocks = <&clk 151>, <&clk 152>, <&clk 154>;
+      clock-names = "stmmaceth", "ptp_ref", "tx";
+      interrupt-parent = <&intc>;
+      interrupts = <296 IRQ_TYPE_LEVEL_HIGH>;
+      interrupt-names = "macirq";
+      resets = <&rst 30>;
+      reset-names = "stmmaceth";
+      snps,multicast-filter-bins = <0>;
+      snps,perfect-filter-entries = <1>;
+      snps,aal;
+      snps,tso;
+      snps,txpbl = <32>;
+      snps,rxpbl = <32>;
+      snps,mtl-rx-config = <&gmac0_mtl_rx_setup>;
+      snps,mtl-tx-config = <&gmac0_mtl_tx_setup>;
+      snps,axi-config = <&gmac0_stmmac_axi_setup>;
+      status = "disabled";
+
+      gmac0_mtl_rx_setup: rx-queues-config {
+        snps,rx-queues-to-use = <8>;
+        snps,rx-sched-wsp;
+        queue0 {};
+        queue1 {};
+        queue2 {};
+        queue3 {};
+        queue4 {};
+        queue5 {};
+        queue6 {};
+        queue7 {};
+      };
+
+      gmac0_mtl_tx_setup: tx-queues-config {
+        snps,tx-queues-to-use = <8>;
+        queue0 {};
+        queue1 {};
+        queue2 {};
+        queue3 {};
+        queue4 {};
+        queue5 {};
+        queue6 {};
+        queue7 {};
+      };
+
+      gmac0_stmmac_axi_setup: stmmac-axi-config {
+        snps,blen = <16 8 4 0 0 0 0>;
+        snps,wr_osr_lmt = <1>;
+        snps,rd_osr_lmt = <2>;
+      };
+    };
-- 
2.48.1


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

* [PATCH net-next v6 2/4] net: stmmac: platform: Group GMAC4 compatible check
  2025-03-05  6:39 [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044 Inochi Amaoto
  2025-03-05  6:39 ` [PATCH net-next v6 1/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac Inochi Amaoto
@ 2025-03-05  6:39 ` Inochi Amaoto
  2025-03-05  6:39 ` [PATCH net-next v6 3/4] net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string Inochi Amaoto
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Inochi Amaoto @ 2025-03-05  6:39 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Chen Wang, Inochi Amaoto, Maxime Coquelin, Alexandre Torgue,
	Richard Cochran, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Romain Gantois, Hariprasad Kelam, Jisheng Zhang,
	Clément Léger, Jan Petrous (OSS), Simon Horman,
	Furong Xu, Lothar Rubusch, Joe Hattori, Bartosz Golaszewski,
	Giuseppe Cavallaro, Jose Abreu
  Cc: netdev, devicetree, linux-kernel, sophgo, linux-stm32,
	linux-arm-kernel, linux-riscv, Yixun Lan, Longbin Li, Andrew Lunn

Use of_device_compatible_match to group existing compatible
check of GMAC4 device.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Romain Gantois <romain.gantois@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 .../ethernet/stmicro/stmmac/stmmac_platform.c    | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index d0e61aa1a495..4a3fe44b780d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -405,6 +405,16 @@ static int stmmac_of_get_mac_mode(struct device_node *np)
 	return -ENODEV;
 }
 
+/* Compatible string array for all gmac4 devices */
+static const char * const stmmac_gmac4_compats[] = {
+	"snps,dwmac-4.00",
+	"snps,dwmac-4.10a",
+	"snps,dwmac-4.20a",
+	"snps,dwmac-5.10a",
+	"snps,dwmac-5.20",
+	NULL
+};
+
 /**
  * stmmac_probe_config_dt - parse device-tree driver parameters
  * @pdev: platform_device structure
@@ -538,11 +548,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
 		plat->pmt = 1;
 	}
 
-	if (of_device_is_compatible(np, "snps,dwmac-4.00") ||
-	    of_device_is_compatible(np, "snps,dwmac-4.10a") ||
-	    of_device_is_compatible(np, "snps,dwmac-4.20a") ||
-	    of_device_is_compatible(np, "snps,dwmac-5.10a") ||
-	    of_device_is_compatible(np, "snps,dwmac-5.20")) {
+	if (of_device_compatible_match(np, stmmac_gmac4_compats)) {
 		plat->has_gmac4 = 1;
 		plat->has_gmac = 0;
 		plat->pmt = 1;
-- 
2.48.1


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

* [PATCH net-next v6 3/4] net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string
  2025-03-05  6:39 [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044 Inochi Amaoto
  2025-03-05  6:39 ` [PATCH net-next v6 1/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac Inochi Amaoto
  2025-03-05  6:39 ` [PATCH net-next v6 2/4] net: stmmac: platform: Group GMAC4 compatible check Inochi Amaoto
@ 2025-03-05  6:39 ` Inochi Amaoto
  2025-03-05  6:39 ` [PATCH net-next v6 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC Inochi Amaoto
  2025-03-07  0:59 ` [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044 Jakub Kicinski
  4 siblings, 0 replies; 9+ messages in thread
From: Inochi Amaoto @ 2025-03-05  6:39 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Chen Wang, Inochi Amaoto, Maxime Coquelin, Alexandre Torgue,
	Richard Cochran, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Romain Gantois, Hariprasad Kelam, Jisheng Zhang,
	Clément Léger, Jan Petrous (OSS), Simon Horman,
	Furong Xu, Lothar Rubusch, Joe Hattori, Bartosz Golaszewski,
	Giuseppe Cavallaro, Jose Abreu
  Cc: netdev, devicetree, linux-kernel, sophgo, linux-stm32,
	linux-arm-kernel, linux-riscv, Yixun Lan, Longbin Li, Andrew Lunn

Add "snps,dwmac-5.30a" compatible string for 5.30a version that can avoid
to define some platform data in the glue layer.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Romain Gantois <romain.gantois@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 4a3fe44b780d..8dc3bd6946c6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -412,6 +412,7 @@ static const char * const stmmac_gmac4_compats[] = {
 	"snps,dwmac-4.20a",
 	"snps,dwmac-5.10a",
 	"snps,dwmac-5.20",
+	"snps,dwmac-5.30a",
 	NULL
 };
 
-- 
2.48.1


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

* [PATCH net-next v6 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC
  2025-03-05  6:39 [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044 Inochi Amaoto
                   ` (2 preceding siblings ...)
  2025-03-05  6:39 ` [PATCH net-next v6 3/4] net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string Inochi Amaoto
@ 2025-03-05  6:39 ` Inochi Amaoto
  2025-03-07  0:59 ` [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044 Jakub Kicinski
  4 siblings, 0 replies; 9+ messages in thread
From: Inochi Amaoto @ 2025-03-05  6:39 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Chen Wang, Inochi Amaoto, Maxime Coquelin, Alexandre Torgue,
	Richard Cochran, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Romain Gantois, Hariprasad Kelam, Jisheng Zhang,
	Clément Léger, Jan Petrous (OSS), Simon Horman,
	Furong Xu, Lothar Rubusch, Joe Hattori, Bartosz Golaszewski,
	Giuseppe Cavallaro, Jose Abreu
  Cc: netdev, devicetree, linux-kernel, sophgo, linux-stm32,
	linux-arm-kernel, linux-riscv, Yixun Lan, Longbin Li

Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/Kconfig   | 11 +++
 drivers/net/ethernet/stmicro/stmmac/Makefile  |  1 +
 .../ethernet/stmicro/stmmac/dwmac-sophgo.c    | 75 +++++++++++++++++++
 3 files changed, 87 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c

diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 4cc85a36a1ab..b6ff51e1ebce 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -181,6 +181,17 @@ config DWMAC_SOCFPGA
 	  for the stmmac device driver. This driver is used for
 	  arria5 and cyclone5 FPGA SoCs.
 
+config DWMAC_SOPHGO
+	tristate "Sophgo dwmac support"
+	depends on OF && (ARCH_SOPHGO || COMPILE_TEST)
+	default m if ARCH_SOPHGO
+	help
+	  Support for ethernet controllers on Sophgo RISC-V SoCs
+
+	  This selects the Sophgo SoC specific glue layer support
+	  for the stmmac device driver. This driver is used for the
+	  ethernet controllers on various Sophgo SoCs.
+
 config DWMAC_STARFIVE
 	tristate "StarFive dwmac support"
 	depends on OF && (ARCH_STARFIVE || COMPILE_TEST)
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index b26f0e79c2b3..594883fb4164 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
 obj-$(CONFIG_DWMAC_RZN1)	+= dwmac-rzn1.o
 obj-$(CONFIG_DWMAC_S32)		+= dwmac-s32.o
 obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-altr-socfpga.o
+obj-$(CONFIG_DWMAC_SOPHGO)	+= dwmac-sophgo.o
 obj-$(CONFIG_DWMAC_STARFIVE)	+= dwmac-starfive.o
 obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
 obj-$(CONFIG_DWMAC_STM32)	+= dwmac-stm32.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
new file mode 100644
index 000000000000..3303784cbbf8
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Sophgo DWMAC platform driver
+ *
+ * Copyright (C) 2024 Inochi Amaoto <inochiama@gmail.com>
+ */
+
+#include <linux/clk.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+
+#include "stmmac_platform.h"
+
+static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
+				    struct plat_stmmacenet_data *plat_dat,
+				    struct stmmac_resources *stmmac_res)
+{
+	plat_dat->clk_tx_i = devm_clk_get_enabled(&pdev->dev, "tx");
+	if (IS_ERR(plat_dat->clk_tx_i))
+		return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat->clk_tx_i),
+				     "failed to get tx clock\n");
+
+	plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE;
+	plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
+	plat_dat->multicast_filter_bins = 0;
+	plat_dat->unicast_filter_entries = 1;
+
+	return 0;
+}
+
+static int sophgo_dwmac_probe(struct platform_device *pdev)
+{
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
+	struct device *dev = &pdev->dev;
+	int ret;
+
+	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "failed to get platform resources\n");
+
+	plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
+	if (IS_ERR(plat_dat))
+		return dev_err_probe(dev, PTR_ERR(plat_dat),
+				     "failed to parse DT parameters\n");
+
+	ret = sophgo_sg2044_dwmac_init(pdev, plat_dat, &stmmac_res);
+	if (ret)
+		return ret;
+
+	return stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
+}
+
+static const struct of_device_id sophgo_dwmac_match[] = {
+	{ .compatible = "sophgo,sg2044-dwmac" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, sophgo_dwmac_match);
+
+static struct platform_driver sophgo_dwmac_driver = {
+	.probe  = sophgo_dwmac_probe,
+	.remove = stmmac_pltfr_remove,
+	.driver = {
+		.name = "sophgo-dwmac",
+		.pm = &stmmac_pltfr_pm_ops,
+		.of_match_table = sophgo_dwmac_match,
+	},
+};
+module_platform_driver(sophgo_dwmac_driver);
+
+MODULE_AUTHOR("Inochi Amaoto <inochiama@gmail.com>");
+MODULE_DESCRIPTION("Sophgo DWMAC platform driver");
+MODULE_LICENSE("GPL");
-- 
2.48.1


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

* Re: [PATCH net-next v6 1/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac
  2025-03-05  6:39 ` [PATCH net-next v6 1/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac Inochi Amaoto
@ 2025-03-05  6:45   ` Inochi Amaoto
  0 siblings, 0 replies; 9+ messages in thread
From: Inochi Amaoto @ 2025-03-05  6:45 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Conor Dooley, Chen Wang, Inochi Amaoto,
	Maxime Coquelin, Alexandre Torgue, Richard Cochran, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Romain Gantois, Hariprasad Kelam,
	Jisheng Zhang, Clément Léger, Jan Petrous (OSS),
	Simon Horman, Furong Xu, Lothar Rubusch, Joe Hattori,
	Bartosz Golaszewski, Giuseppe Cavallaro, Jose Abreu, netdev,
	devicetree, linux-kernel, sophgo, linux-stm32, linux-arm-kernel,
	linux-riscv, Yixun Lan, Longbin Li, Krzysztof Kozlowski

On Wed, Mar 05, 2025 at 02:39:13PM +0800, Inochi Amaoto wrote:
> The GMAC IP on SG2044 is almost a standard Synopsys DesignWare
> MAC (version 5.30a) with some extra clock.
> 
> Add necessary compatible string for this device.
> 
> Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  .../devicetree/bindings/net/snps,dwmac.yaml   |   4 +
>  .../bindings/net/sophgo,sg2044-dwmac.yaml     | 126 ++++++++++++++++++
>  2 files changed, 130 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> 
> diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> index 91e75eb3f329..02ab6a9aded2 100644
> --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> @@ -32,6 +32,7 @@ select:
>            - snps,dwmac-4.20a
>            - snps,dwmac-5.10a
>            - snps,dwmac-5.20
> +          - snps,dwmac-5.30a
>            - snps,dwxgmac
>            - snps,dwxgmac-2.10
>  
> @@ -98,8 +99,10 @@ properties:
>          - snps,dwmac-4.20a
>          - snps,dwmac-5.10a
>          - snps,dwmac-5.20
> +        - snps,dwmac-5.30a
>          - snps,dwxgmac
>          - snps,dwxgmac-2.10
> +        - sophgo,sg2044-dwmac
>          - starfive,jh7100-dwmac
>          - starfive,jh7110-dwmac
>          - thead,th1520-gmac
> @@ -631,6 +634,7 @@ allOf:
>                  - snps,dwmac-4.20a
>                  - snps,dwmac-5.10a
>                  - snps,dwmac-5.20
> +                - snps,dwmac-5.30a
>                  - snps,dwxgmac
>                  - snps,dwxgmac-2.10
>                  - st,spear600-gmac
> diff --git a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> new file mode 100644
> index 000000000000..4dd2dc9c678b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> @@ -0,0 +1,126 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/sophgo,sg2044-dwmac.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Sophgo SG2044 DWMAC glue layer
> +
> +maintainers:
> +  - Inochi Amaoto <inochiama@gmail.com>
> +
> +select:
> +  properties:
> +    compatible:
> +      contains:
> +        enum:
> +          - sophgo,sg2044-dwmac
> +  required:
> +    - compatible
> +
> +properties:
> +  compatible:
> +    items:
> +      - const: sophgo,sg2044-dwmac
> +      - const: snps,dwmac-5.30a
> +
> +  reg:
> +    maxItems: 1
> +
> +  clocks:
> +    items:
> +      - description: GMAC main clock
> +      - description: PTP clock
> +      - description: TX clock
> +
> +  clock-names:
> +    items:
> +      - const: stmmaceth
> +      - const: ptp_ref
> +      - const: tx
> +
> +  dma-noncoherent: true

Hi, Krzysztof,

I add this property due to the discussion on PCIe binding of SG2044, it
can be found on link [1]. As a similar change (at link [2]) was acked by
Conor. I preserve your tag on this binding. If you have any further
requirement, please let me know. I will appreciate it.

[1] https://lore.kernel.org/all/20250221013758.370936-2-inochiama@gmail.com/
[2] https://lore.kernel.org/all/20250303065649.937233-1-inochiama@gmail.com/

Regards,
Inochi

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

* Re: [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044
  2025-03-05  6:39 [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044 Inochi Amaoto
                   ` (3 preceding siblings ...)
  2025-03-05  6:39 ` [PATCH net-next v6 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC Inochi Amaoto
@ 2025-03-07  0:59 ` Jakub Kicinski
  2025-03-07  1:12   ` Inochi Amaoto
  4 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2025-03-07  0:59 UTC (permalink / raw)
  To: Inochi Amaoto
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
	Maxime Coquelin, Alexandre Torgue, Richard Cochran, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Romain Gantois, Hariprasad Kelam,
	Jisheng Zhang, Clément Léger, Jan Petrous (OSS),
	Simon Horman, Furong Xu, Lothar Rubusch, Joe Hattori,
	Bartosz Golaszewski, Giuseppe Cavallaro, Jose Abreu, netdev,
	devicetree, linux-kernel, sophgo, linux-stm32, linux-arm-kernel,
	linux-riscv, Yixun Lan, Longbin Li

On Wed,  5 Mar 2025 14:39:12 +0800 Inochi Amaoto wrote:
> The ethernet controller of SG2044 is Synopsys DesignWare IP with
> custom clock. Add glue layer for it.

Looks like we have a conflict on the binding, could you rebase
against latest net-next/main and repost?
-- 
pw-bot: cr

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

* Re: [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044
  2025-03-07  0:59 ` [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044 Jakub Kicinski
@ 2025-03-07  1:12   ` Inochi Amaoto
  2025-03-07  1:20     ` Inochi Amaoto
  0 siblings, 1 reply; 9+ messages in thread
From: Inochi Amaoto @ 2025-03-07  1:12 UTC (permalink / raw)
  To: Jakub Kicinski, Inochi Amaoto
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
	Maxime Coquelin, Alexandre Torgue, Richard Cochran, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Romain Gantois, Hariprasad Kelam,
	Jisheng Zhang, Clément Léger, Jan Petrous (OSS),
	Simon Horman, Furong Xu, Lothar Rubusch, Joe Hattori,
	Bartosz Golaszewski, Giuseppe Cavallaro, Jose Abreu, netdev,
	devicetree, linux-kernel, sophgo, linux-stm32, linux-arm-kernel,
	linux-riscv, Yixun Lan, Longbin Li

On Thu, Mar 06, 2025 at 04:59:31PM -0800, Jakub Kicinski wrote:
> On Wed,  5 Mar 2025 14:39:12 +0800 Inochi Amaoto wrote:
> > The ethernet controller of SG2044 is Synopsys DesignWare IP with
> > custom clock. Add glue layer for it.
> 
> Looks like we have a conflict on the binding, could you rebase
> against latest net-next/main and repost?
> -- 
> pw-bot: cr

Yeah, I see a auto merge when cherry-pick here. I will send a
new version for it.

Regards,
Inochi

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

* Re: [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044
  2025-03-07  1:12   ` Inochi Amaoto
@ 2025-03-07  1:20     ` Inochi Amaoto
  0 siblings, 0 replies; 9+ messages in thread
From: Inochi Amaoto @ 2025-03-07  1:20 UTC (permalink / raw)
  To: Jakub Kicinski, Inochi Amaoto
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
	Maxime Coquelin, Alexandre Torgue, Richard Cochran, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Romain Gantois, Hariprasad Kelam,
	Jisheng Zhang, Clément Léger, Jan Petrous (OSS),
	Simon Horman, Furong Xu, Lothar Rubusch, Joe Hattori,
	Bartosz Golaszewski, Giuseppe Cavallaro, Jose Abreu, netdev,
	devicetree, linux-kernel, sophgo, linux-stm32, linux-arm-kernel,
	linux-riscv, Yixun Lan, Longbin Li

On Fri, Mar 07, 2025 at 09:12:33AM +0800, Inochi Amaoto wrote:
> On Thu, Mar 06, 2025 at 04:59:31PM -0800, Jakub Kicinski wrote:
> > On Wed,  5 Mar 2025 14:39:12 +0800 Inochi Amaoto wrote:
> > > The ethernet controller of SG2044 is Synopsys DesignWare IP with
> > > custom clock. Add glue layer for it.
> > 
> > Looks like we have a conflict on the binding, could you rebase
> > against latest net-next/main and repost?
> > -- 
> > pw-bot: cr
> 
> Yeah, I see a auto merge when cherry-pick here. I will send a
> new version for it.
> 

Here is the new version:
https://lore.kernel.org/netdev/20250307011623.440792-1-inochiama@gmail.com/

Regards,
Inochi

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

end of thread, other threads:[~2025-03-07  1:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05  6:39 [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044 Inochi Amaoto
2025-03-05  6:39 ` [PATCH net-next v6 1/4] dt-bindings: net: Add support for Sophgo SG2044 dwmac Inochi Amaoto
2025-03-05  6:45   ` Inochi Amaoto
2025-03-05  6:39 ` [PATCH net-next v6 2/4] net: stmmac: platform: Group GMAC4 compatible check Inochi Amaoto
2025-03-05  6:39 ` [PATCH net-next v6 3/4] net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string Inochi Amaoto
2025-03-05  6:39 ` [PATCH net-next v6 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC Inochi Amaoto
2025-03-07  0:59 ` [PATCH net-next v6 0/4] riscv: sophgo: Add ethernet support for SG2044 Jakub Kicinski
2025-03-07  1:12   ` Inochi Amaoto
2025-03-07  1:20     ` Inochi Amaoto

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