Skip to contentSkip to conversation

riscv: sophgo: Add ethernet support for SG2044

PATCH Superseded Inochi Amaoto 2 participants 5 messages Dec 23, 2024

Subsystems (7)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Inochi Amaoto

author maintainer
#0 lore raw

v3 cover riscv: sophgo: Add ethernet support for SG2044

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

Since v2, these patch depends on that following patch that provides helper function to compute rgmii clock, As for now, this patch is merged in net/for-next
https://lore.kernel.org/netdev/173380743727.355055.17303486442146316315.git-patchwork-notify@kernel.org/

Changed from RFC:
- https://lore.kernel.org/netdev/[email protected]/
1. patch 1: apply Krzysztof' tag

Changed from v2:
- https://lore.kernel.org/netdev/[email protected]/
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/[email protected]/
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 (3):
dt-bindings: net: Add support for Sophgo SG2044 dwmac
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     | 124 ++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  11 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../ethernet/stmicro/stmmac/dwmac-sophgo.c    | 105 +++++++++++++++
 .../ethernet/stmicro/stmmac/stmmac_platform.c |  17 ++-
 6 files changed, 257 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.47.1

author maintainer
#1 lore raw

PATCH v3 1/3 dt-bindings: net: Add support for Sophgo SG2044 dwmac

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.

---
 .../devicetree/bindings/net/snps,dwmac.yaml   |   4 +
 .../bindings/net/sophgo,sg2044-dwmac.yaml     | 124 ++++++++++++++++++
 2 files changed, 128 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
Documentation/devicetree/bindings/net/snps,dwmac.yaml +4 -0
index eb1f3ae41ab9..cd112ef6b3bf 100644
@@ -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
 
@@ -97,8 +98,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
@@ -630,6 +633,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
Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
2.47.1
author maintainer
#2 lore raw

PATCH v3 2/3 net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string

In reply to Inochi Amaoto

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

---
 .../ethernet/stmicro/stmmac/stmmac_platform.c   | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +12 -5
index 3ac32444e492..6ce3e538ce0a 100644
@@ -421,6 +421,17 @@ static void stmmac_remove_config_dt(struct platform_device *pdev,
 	of_node_put(plat->mdio_node);
 }
 
+/* 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",
+	"snps,dwmac-5.30a",
+	NULL
+};
+
 /**
  * stmmac_probe_config_dt - parse device-tree driver parameters
  * @pdev: platform_device structure
@@ -552,11 +563,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;
Signature · 1 line
2.47.1
author maintainer
#3 lore raw

PATCH v3 3/3 net: stmmac: Add glue layer for Sophgo SG2044 SoC

In reply to Inochi Amaoto

Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  11 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../ethernet/stmicro/stmmac/dwmac-sophgo.c    | 105 ++++++++++++++++++
 3 files changed, 117 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
drivers/net/ethernet/stmicro/stmmac/Kconfig +11 -0
index 6658536a4e17..23085d27ace6 100644
@@ -169,6 +169,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)
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
index 2389fd261344..36f21c86568d 100644
@@ -23,6 +23,7 @@ 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_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
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
2.47.1
maintainer
#4 lore raw
In reply to Inochi Amaoto
Quoted 7 lines · On Mon, 23 Dec 2024 08:58:36 +0800 Inochi Amaoto wrote:

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

Since v2, these patch depends on that following patch that provides helper function to compute rgmii clock, As for now, this patch is merged in net/for-next
https://lore.kernel.org/netdev/173380743727.355055.17303486442146316315.git-patchwork-notify@kernel.org/

## Form letter - winter break

Networking development is suspended for winter holidays, until Jan 2nd. We are currently accepting bug fixes only, see the announcements at:

https://lore.kernel.org/[email protected]
https://lore.kernel.org/[email protected]

RFC patches sent for review only are welcome at any time.

Signature · 2 lines
pw-bot: defer
pv-bot: closed