riscv: spacemit: Add ethernet support for K3
Subsystems (8)
Inochi Amaoto
maintainerv10 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 v9:
- https://lore.kernel.org/netdev/[email protected]
patch 3:
1. fix misaligned brace.
Change from v8:
- https://lore.kernel.org/netdev/[email protected]
patch 2:
1. Apply Russell's tag.
patch 3:
1. reverse the order of the local variable to make it "reverse christmas tree" for function spacemit_dwmac_update_irq_config() and function spacemit_set_phy_intf_sel()
2. Apply Russell's tag
patch 4:
1. Add MAINTAINERS entry
Change from v7:
- https://lore.kernel.org/netdev/[email protected]
patch 3:
1. Remove unused parameter in spacemit_dwmac_fix_delay().
Change from v6:
- https://lore.kernel.org/netdev/[email protected]
patch 1:
1. Drop the extra blank line at the last
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 (4):
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
MAINTAINERS: add entry for SpacemiT DWMAC glue layer
.../devicetree/bindings/net/snps,dwmac.yaml | 2 + .../bindings/net/spacemit,k3-dwmac.yaml | 102 ++++++++ MAINTAINERS | 6 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 12 + drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + .../ethernet/stmicro/stmmac/dwmac-spacemit.c | 227 ++++++++++++++++++ .../ethernet/stmicro/stmmac/stmmac_platform.c | 1 + 7 files changed, 351 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
Inochi Amaoto
maintainerPATCH v10 1/4 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 | 102 ++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/spacemit,k3-dwmac.yaml
Documentation/devicetree/bindings/net/snps,dwmac.yaml +2 -0
@@ -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 +102 -0
102 lines not on this page · raw message
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerRe: [PATCH net-next v10 1/4] dt-bindings: net: Add support for Spacemit K3 dwmac
Quoted 4 lines · On Mon, 16 Mar 2026 09:00:37 +0800 Inochi Amaoto wrote:
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.
In the previous version the AI reviewer complained that we're not adding the new entry to the select at the top of the file. Other compatibles appear in 3 places in Documentation/devicetree/bindings/net/snps,dwmac.yaml
Also I asked whether we can drop the "default m"
Did you disagree with those comments or did you miss them? stmmac is a strange beast I don't really know what's going on in the binding, so just double checking this is intentional..
Inochi Amaoto
maintainerRe: [PATCH net-next v10 1/4] dt-bindings: net: Add support for Spacemit K3 dwmac
Quoted 4 lines · Jakub Kicinski
Quoted 3 lines · On Mon, 16 Mar 2026 09:00:37 +0800 Inochi Amaoto wrote:
The GMAC IP on Spacemit K3 is almost a standard Synopsys DesignWare MAC (version 5.40a) with some extra clock.
Quoted 9 lines
Quoted 1 line
Add necessary compatible string for this device.
In the previous version the AI reviewer complained that we're not adding the new entry to the select at the top of the file. Other compatibles appear in 3 places in
Documentation/devicetree/bindings/net/snps,dwmac.yamlAlso I asked whether we can drop the "default m"
For the Kconfig, I think it is better to keep the thing the same as others. And I guess this question may be related to some compromise that I do not know, and it is a hard thing for me to answer.
Quoted 3 lines
Did you disagree with those comments or did you miss them? stmmac is a strange beast I don't really know what's going on in the binding, so just double checking this is intentional..
Oh, I have forgot to reply to the binding.
Currently, I disagree to add something in the select, as a new binding is always required for a new device. Even if it is already supported in the existing kernel, the new device is required to add at least a new compatiable string for it.
Regards,
Inochi
Inochi Amaoto
maintainerPATCH v10 2/4 net: stmmac: platform: Add snps,dwmac-5.40a IP compatible string
In reply to Inochi AmaotoAdd 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
@@ -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
Inochi Amaoto
maintainerPATCH v10 3/4 net: stmmac: Add glue layer for Spacemit K3 SoC
In reply to Inochi AmaotoThe 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 | 227 ++++++++++++++++++ 3 files changed, 240 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-spacemit.c
drivers/net/ethernet/stmicro/stmmac/Kconfig +12 -0
@@ -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
@@ -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 +227 -0
227 lines not on this page · raw message
Signature · 1 line
2.53.0
Inochi Amaoto
maintainerPATCH v10 4/4 MAINTAINERS: add entry for SpacemiT DWMAC glue layer
In reply to Inochi AmaotoAdd a MAINTAINERS entry for the SpacemiT DWMAC glue layer driver and its DT binding.
--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -24834,6 +24834,12 @@ W: https://linuxtv.org Q: http://patchwork.linuxtv.org/project/linux-media/list/ F: drivers/media/dvb-frontends/sp2* +SPACEMIT DWMAC GLUE LAYER +M: Inochi Amaoto <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/net/spacemit,k3-dwmac.yaml +F: drivers/net/ethernet/stmicro/stmmac/dwmac-spacemit.c + SPACEMIT K1 I2C DRIVER M: Troy Mitchell <[email protected]> S: Maintained
Signature · 1 line
2.53.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Mon, 16 Mar 2026 09:00:36 +0800 you wrote:
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 v9:
- https://lore.kernel.org/netdev/[email protected]
patch 3:
1. fix misaligned brace.[...]
Here is the summary with links:
- [net-next,v10,1/4] dt-bindings: net: Add support for Spacemit K3 dwmac
https://git.kernel.org/netdev/net-next/c/bb30400a566c - [net-next,v10,2/4] net: stmmac: platform: Add snps,dwmac-5.40a IP compatible string https://git.kernel.org/netdev/net-next/c/d35aa97ea908 - [net-next,v10,3/4] net: stmmac: Add glue layer for Spacemit K3 SoC https://git.kernel.org/netdev/net-next/c/30f0ba420ed3 - [net-next,v10,4/4] MAINTAINERS: add entry for SpacemiT DWMAC glue layer https://git.kernel.org/netdev/net-next/c/25e7553a502b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html