net: add SpacemiT K1 EMAC support
Subsystems (2)
cover net: add SpacemiT K1 EMAC support
This series adds support for the Ethernet MACs integrated in the SpacemiT K1 SoC, which includes adding a k1_emac driver with MDIO and PHYLIB support for RGMII and RMII operation, enabling it in the k1 defconfig, and adding MAINTAINERS coverage on new directory.
The k1_emac driver in series draws upon Vivian Wang's work [1]. To make it simple and working, driver which using small ring-buffers operates primarily on polling and only implements basic functions.
Tested on both Banana Pi F3 Ethernet ports with RTL8211F PHYs at 1000 Mbps full duplex, and tested command: dhcp, ping, tftp, etc.
[1]: https://lore.kernel.org/all/[email protected]/
---
Zixian Zeng (3):
net: k1: add Ethernet MAC driver
configs: k1: enable Ethernet support
MAINTAINERS: spacemit: add K1 Ethernet driver
board/spacemit/k1/MAINTAINERS | 1 + configs/spacemit_k1_defconfig | 6 + drivers/net/Kconfig | 1 + drivers/net/Makefile | 1 + drivers/net/spacemit/Kconfig | 15 + drivers/net/spacemit/Makefile | 3 + drivers/net/spacemit/k1_emac.c | 952 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 979 insertions(+)
---
base-commit: a000f2af240eaa996cec92f8d44bad96fdf3f898
change-id: 20260926-b4-k1-emac-fa5f2b146f38
Best regards,
Signature · 1 line
Zixian Zeng <[email protected]>
PATCH 1/3 net: k1: add Ethernet MAC driver
Add Ethernet MAC driver support for the SpacemiT K1 SoC. The driver supports RGMII and RMII interfaces, synchronous transmission, and exposes the integrated MDIO controller through the MDIO uclass.
The register definitions, descriptor layout, MDIO protocol, RGMII delay line handling and hardware initialisation sequences are derived from the mainline Linux commit bfec6d7f2001 (net: spacemit: Add K1 Ethernet MAC).
--- drivers/net/Kconfig | 1 + drivers/net/Makefile | 1 + drivers/net/spacemit/Kconfig | 15 + drivers/net/spacemit/Makefile | 3 + drivers/net/spacemit/k1_emac.c | 952 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 972 insertions(+)
drivers/net/Kconfig +1 -0
@@ -1123,6 +1123,7 @@ config MDIO_MUX_MESON_GXL source "drivers/net/phy/Kconfig" source "drivers/net/pfe_eth/Kconfig" source "drivers/net/fsl-mc/Kconfig" +source "drivers/net/spacemit/Kconfig" endif # NETDEVICES
drivers/net/Makefile +1 -0
@@ -105,6 +105,7 @@ obj-$(CONFIG_SJA1105) += sja1105.o obj-$(CONFIG_SMC911X) += smc911x.o obj-$(CONFIG_SNI_AVE) += sni_ave.o obj-$(CONFIG_SNI_NETSEC) += sni_netsec.o +obj-$(CONFIG_SPACEMIT_K1_EMAC) += spacemit/ obj-$(CONFIG_SUN4I_EMAC) += sunxi_emac.o obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o obj-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o
drivers/net/spacemit/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0+ + +config SPACEMIT_K1_EMAC + bool "SpacemiT K1 Ethernet MAC support" + depends on TARGET_SPACEMIT_K1 + select DM_DMA + select DM_ETH_PHY + select DM_MDIO + select PHYLIB + select PHY_GIGE + help + Enable support for the Ethernet MAC integrated in the SpacemiT K1. + The controller supports 10/100/1000 Mbps links through RGMII and + 10/100 Mbps links through RMII. Its internal MDIO controller is + exposed through the driver-model MDIO uclass.
drivers/net/spacemit/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_SPACEMIT_K1_EMAC) += k1_emac.o
drivers/net/spacemit/k1_emac.c new file +952 -0
952 lines not on this page · raw message
Signature · 1 line
2.56.0
PATCH 2/3 configs: k1: enable Ethernet support
In reply to Zixian ZengEnable the K1 Ethernet MAC, Realtek PHY driver, and network commands.
--- configs/spacemit_k1_defconfig | 6 ++++++ 1 file changed, 6 insertions(+)
configs/spacemit_k1_defconfig +6 -0
@@ -44,6 +44,7 @@ CONFIG_SPL_I2C=y CONFIG_SPL_DM_RESET=y CONFIG_SPL_POWER=y CONFIG_HUSH_PARSER=y +CONFIG_ID_EEPROM=y CONFIG_CMD_TLV_EEPROM=y CONFIG_SPL_CMD_TLV_EEPROM=y CONFIG_OF_UPSTREAM=y
@@ -115,6 +116,11 @@ CONFIG_PHY=y CONFIG_PHY_SPACEMIT_K1_PCIE=y CONFIG_CMD_FAT=y CONFIG_CMD_EXT4=y +CONFIG_CMD_DHCP=y +CONFIG_CMD_MII=y +CONFIG_CMD_PING=y +CONFIG_SPACEMIT_K1_EMAC=y +CONFIG_PHY_REALTEK=y CONFIG_SPL_SPI=y CONFIG_SPL_DM_SPI=y CONFIG_SPL_DM_SPI_FLASH=y
Signature · 1 line
2.56.0
PATCH 3/3 MAINTAINERS: spacemit: add K1 Ethernet driver
In reply to Zixian ZengAdd the SpacemiT K1 Ethernet driver to the maintained files.
--- board/spacemit/k1/MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
board/spacemit/k1/MAINTAINERS +1 -0
@@ -10,6 +10,7 @@ F: doc/board/spacemit/ F: drivers/gpio/spacemit_gpio.c F: drivers/i2c/k1_i2c.c F: drivers/mmc/spacemit_sdhci.c +F: drivers/net/spacemit/ F: drivers/pci/pcie_dw_spacemit.c F: drivers/pinctrl/spacemit/ F: drivers/power/pmic/pmic_spacemit_p1.c
Signature · 1 line
2.56.0
Yixun Lan
maintainerRe: [PATCH 3/3] MAINTAINERS: spacemit: add K1 Ethernet driver
Hi Zixian,
Quoted 12 lines · Zixian Zeng
Add the SpacemiT K1 Ethernet driver to the maintained files.
Signed-off-by Zixian Zeng <[email protected]>--- board/spacemit/k1/MAINTAINERS | 1 + 1 file changed, 1 insertion(+)board/spacemit/k1/MAINTAINERS +0
-0
board/spacemit/k1/MAINTAINERS F: doc/board/spacemit/ · line 13
Quoted 4 lines
board/spacemit/k1/MAINTAINERS +1
-0@@ -10,6 +10,7 @@ F: doc/board/spacemit/ F: drivers/gpio/spacemit_gpio.c F: drivers/i2c/k1_i2c.c F: drivers/mmc/spacemit_sdhci.c +F: drivers/net/spacemit/
Let's not bother adding it explicitly, since the top MAINTAINERS already cover the keyword 'spacemit'[1], so should fallback it well
But, don't treat this as a hard policy, if there is file that k1 specific and want to highlight it, then please add as you prefer..
[1] bdc04bcabfd8 ("MAINTAINERS: add new SpacemiT custodians")
Quoted 7 lines
board/spacemit/k1/MAINTAINERS +0
-0F: drivers/pci/pcie_dw_spacemit.c F: drivers/pinctrl/spacemit/ F: drivers/power/pmic/pmic_spacemit_p1.cSignature · 2 lines
-- 2.56.0
Signature · 1 line
Yixun Lan (dlan)