Skip to contentSkip to conversation

riscv: spacemit: Add ethernet support for K3

PATCH Superseded Inochi Amaoto 1 participant 4 messages Mar 3

Subsystems (8)

v6 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Inochi Amaoto

author maintainer
#0 lore raw

v6 cover riscv: spacemit: Add ethernet support for K3

Add initial support for ethernet controller of the Spacemit K3 SoC. This ethernet controller is almost a standard Synopsys DesignWare MAC (version 5.40a). This controller require a syscon device to configure some basic features, like interface type and internal delay.

Change from v5:
- https://lore.kernel.org/netdev/[email protected]
patch 3:
1. fix error from checkpatch

Change from v4:
- https://lore.kernel.org/netdev/[email protected]
patch 1:
1 Apply Rob's tag.
2 Adjust clock description according to Russell's suggestion. patch 3:
1. Add set_phy_intf_sel() and get_interfaces() hook, suggested by Russell.

Change from v3:
- https://lore.kernel.org/netdev/[email protected]
patch 1:
1. fix the uncorrect compatible string postion
patch 3:
1. add "CTRL_" prefix to all ctrl register definition
2. only use delay config 0 to calculate delay code.
3. fix typo in the comment

Change from v2:
- https://lore.kernel.org/netdev/[email protected]
patch 1:
1. remove not needed compatible for select
2. drop empty line in "spacemit,apmu" properties
3. add spacemit,apmu properties to required.
patch 3:
1. remove misused phy_fix_phy_mode_for_mac_delays.
2. use local tx clock instead of the clk_tx_i in the dwmac.

Change from v1:
- https://lore.kernel.org/netdev/[email protected]
patch 1:
1. remove phy clock
patch 3:
1. improve comment and include something special about Spacmit K3 dwmac
2. reorder the included file
3. fix wrong delay macro used in spacemit_dwmac_set_delay.
4. add check for maximum supported delay.
5. use DIV_ROUND_CLOSEST to calculate best delay configuration.
6. use assign for the ctrl register initial value.
7. fix input when calling of_property_read_u32().

Inochi Amaoto (3):
dt-bindings: net: Add support for Spacemit K3 dwmac
net: stmmac: platform: Add snps,dwmac-5.40a IP compatible string
net: stmmac: Add glue layer for Spacemit K3 SoC

 .../devicetree/bindings/net/snps,dwmac.yaml   |   2 +
 .../bindings/net/spacemit,k3-dwmac.yaml       | 103 ++++++++
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  12 +
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../ethernet/stmicro/stmmac/dwmac-spacemit.c  | 228 ++++++++++++++++++
 .../ethernet/stmicro/stmmac/stmmac_platform.c |   1 +
 6 files changed, 347 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/spacemit,k3-dwmac.yaml
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-spacemit.c

--
2.53.0

author maintainer
#1 lore raw

PATCH v6 1/3 dt-bindings: net: Add support for Spacemit K3 dwmac

The GMAC IP on Spacemit K3 is almost a standard Synopsys DesignWare MAC (version 5.40a) with some extra clock.

Add necessary compatible string for this device.

---
 .../devicetree/bindings/net/snps,dwmac.yaml   |   2 +
 .../bindings/net/spacemit,k3-dwmac.yaml       | 103 ++++++++++++++++++
 2 files changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/spacemit,k3-dwmac.yaml
Documentation/devicetree/bindings/net/snps,dwmac.yaml +2 -0
index 38bc34dc4f09..98ebb6276bc6 100644
@@ -109,6 +109,7 @@ properties:
         - snps,dwmac-5.10a
         - snps,dwmac-5.20
         - snps,dwmac-5.30a
+        - snps,dwmac-5.40a
         - snps,dwxgmac
         - snps,dwxgmac-2.10
         - sophgo,sg2042-dwmac
@@ -656,6 +657,7 @@ allOf:
                 - snps,dwmac-5.10a
                 - snps,dwmac-5.20
                 - snps,dwmac-5.30a
+                - snps,dwmac-5.40a
                 - snps,dwxgmac
                 - snps,dwxgmac-2.10
                 - st,spear600-gmac
Documentation/devicetree/bindings/net/spacemit,k3-dwmac.yaml new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#2 lore raw

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

In reply to Inochi Amaoto

Add compatible string for 5.40a version that can avoid to define some platform data in the glue layer.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -0
index 5c9fd91a1db9..02303a808fb5 100644
@@ -396,6 +396,7 @@ static const char * const stmmac_gmac4_compats[] = {
 	"snps,dwmac-5.10a",
 	"snps,dwmac-5.20",
 	"snps,dwmac-5.30a",
+	"snps,dwmac-5.40a",
 	NULL
 };
 
Signature · 1 line
2.53.0
author maintainer
#3 lore raw

PATCH v6 3/3 net: stmmac: Add glue layer for Spacemit K3 SoC

In reply to Inochi Amaoto

The ethernet controller on Spacemit K3 SoC is Synopsys DesignWare MAC (version 5.40a), with the following special points:
1. The rate of the tx clock line is auto changed when the mac speed rate is changed, and no need for changing the input tx clock.
2. This controller require a extra syscon device to configure the interface type, enable wake up interrupt and delay configuration if needed.

Add Spacemit dwmac driver support on the Spacemit K3 SoC.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  12 +
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../ethernet/stmicro/stmmac/dwmac-spacemit.c  | 228 ++++++++++++++++++
 3 files changed, 241 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-spacemit.c
drivers/net/ethernet/stmicro/stmmac/Kconfig +12 -0
index 07088d03dbab..d3a6ab7383fc 100644
@@ -216,6 +216,18 @@ config DWMAC_SOPHGO
 	  for the stmmac device driver. This driver is used for the
 	  ethernet controllers on various Sophgo SoCs.
 
+config DWMAC_SPACEMIT
+	tristate "Spacemit dwmac support"
+	depends on OF && (ARCH_SPACEMIT || COMPILE_TEST)
+	select MFD_SYSCON
+	default m if ARCH_SPACEMIT
+	help
+	  Support for ethernet controllers on Spacemit RISC-V SoCs
+
+	  This selects the Spacemit platform specific glue layer support
+	  for the stmmac device driver. This driver is used for the
+	  Spacemit K3 ethernet controllers.
+
 config DWMAC_STARFIVE
 	tristate "StarFive dwmac support"
 	depends on OF && (ARCH_STARFIVE || COMPILE_TEST)
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
index c9263987ef8d..945c5354eced 100644
@@ -27,6 +27,7 @@ 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_SPACEMIT)	+= dwmac-spacemit.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-spacemit.c new file +228 -0

228 lines not on this page · raw message

Signature · 1 line
2.53.0