| From: |
| Vivian Wang <wangruikang-AT-iscas.ac.cn> |
| To: |
| Andrew Lunn <andrew+netdev-AT-lunn.ch>, Jakub Kicinski <kuba-AT-kernel.org>, Rob Herring <robh-AT-kernel.org>, Krzysztof Kozlowski <krzk+dt-AT-kernel.org>, Conor Dooley <conor+dt-AT-kernel.org>, Yixun Lan <dlan-AT-gentoo.org>, Vivian Wang <wangruikang-AT-iscas.ac.cn>, "David S. Miller" <davem-AT-davemloft.net>, Eric Dumazet <edumazet-AT-google.com>, Paolo Abeni <pabeni-AT-redhat.com>, Philipp Zabel <p.zabel-AT-pengutronix.de>, Paul Walmsley <paul.walmsley-AT-sifive.com>, Palmer Dabbelt <palmer-AT-dabbelt.com>, Albert Ou <aou-AT-eecs.berkeley.edu>, Alexandre Ghiti <alex-AT-ghiti.fr> |
| Subject: |
| [PATCH net-next v11 0/5] Add Ethernet MAC support for SpacemiT K1 |
| Date: |
| Fri, 12 Sep 2025 02:13:52 +0800 |
| Message-ID: |
| <20250912-net-k1-emac-v11-0-aa3e84f8043b@iscas.ac.cn> |
| Cc: |
| Vivian Wang <uwu-AT-dram.page>, Vadim Fedorenko <vadim.fedorenko-AT-linux.dev>, Junhui Liu <junhui.liu-AT-pigmoral.tech>, Simon Horman <horms-AT-kernel.org>, Maxime Chevallier <maxime.chevallier-AT-bootlin.com>, netdev-AT-vger.kernel.org, devicetree-AT-vger.kernel.org, linux-riscv-AT-lists.infradead.org, spacemit-AT-lists.linux.dev, linux-kernel-AT-vger.kernel.org, Conor Dooley <conor.dooley-AT-microchip.com>, Troy Mitchell <troy.mitchell-AT-linux.spacemit.com>, Hendrik Hamerlinck <hendrik.hamerlinck-AT-hammernet.be> |
| Archive-link: |
| Article |
SpacemiT K1 has two gigabit Ethernet MACs with RGMII and RMII support.
Add devicetree bindings, driver, and DTS for it.
Tested primarily on BananaPi BPI-F3. Basic TX/RX functionality also
tested on Milk-V Jupiter.
I would like to note that even though some bit field names superficially
resemble that of DesignWare MAC, all other differences point to it in
fact being a custom design.
Based on SpacemiT drivers [1]. These patches are also available at:
https://github.com/dramforever/linux/tree/k1/ethernet/v11
[1]: https://github.com/spacemit-com/linux-k1x
---
Changes in v11:
- Use NETDEV_PCPU_STAT_DSTATS for tx_dropped
- Use DECLARE_FLEX_ARRAY for emac_hw_{tx,rx}_stats instead of cast
- More bitfields stuff to simplify code:
- Define EMAC_MAX_DELAY_UNIT with FIELD_MAX
- Use FIELD_{PREP,GET} in emac_mii_{read,write}()
- Use FIELD_MODIFY in emac_set_{tx,rx}_fc()
- Minor changes:
- Use lower_32_bits and such instead of casts and shifts
- Extract emac_ether_addr_hash() helper
- In emac_mdio_init(), 0xffffffff -> ~0
- Minor comment changes
- Link to v10: https://lore.kernel.org/r/20250908-net-k1-emac-v10-0-90d8...
Changes in v10:
- Use FIELD_GET and FIELD_PREP, remove some unused constants
- Remove redundant software statistics
- In particular, rx_dropped should have been and is already tracked in
rx_errors.
- Track tx_dropped with a percpu field
- Minor changes
- Simplified int emac_rx_frame_status() -> bool emac_rx_frame_good()
- Link to v9: https://lore.kernel.org/r/20250905-net-k1-emac-v9-0-f1649...
Changes in v9:
- Refactor to use phy_interface_mode_is_rgmii
- Minor changes
- Use netdev_err in more places
- Print phy-mode by name on unsupported phy-mode
- Link to v8: https://lore.kernel.org/r/20250828-net-k1-emac-v8-0-e9075...
Changes in v8:
- Use devres to do of_phy_deregister_fixed_link on probe failure or
remove
- Simplified control flow in a few places with early return or continue
- Minor changes
- Removed some unneeded parens in emac_configure_{tx,rx}
- Link to v7: https://lore.kernel.org/r/20250826-net-k1-emac-v7-0-5bc15...
Changes in v7:
- Removed scoped_guard usage
- Renamed error handling path labels after destinations
- Fix skb free error handling path in emac_start_xmit and emac_tx_mem_map
- Cancel tx_timeout_task to prevent schedule_work lifetime problems
- Minor changes:
- Remove unnecessary timer_delete_sync in emac_down
- Use dev_err_ratelimited in a few more places
- Cosmetic fixes in error messages
- Link to v6: https://lore.kernel.org/r/20250820-net-k1-emac-v6-0-c1e28...
Changes in v6:
- Implement pause frame support
- Minor changes:
- Convert comment for emac_stats_update() into assert_spin_locked()
- Cosmetic fixes for some comments and whitespace
- emac_set_mac_addr() is now refactored
- Link to v5: https://lore.kernel.org/r/20250812-net-k1-emac-v5-0-dd17c...
Changes in v5:
- Rebased on v6.17-rc1, add back DTS now that they apply cleanly
- Use standard statistics interface, handle 32-bit statistics overflow
- Minor changes:
- Fix clock resource handling in emac_resume
- Ratelimit the message in emac_rx_frame_status
- Add ndo_validate_addr = eth_validate_addr
- Remove unnecessary parens in emac_set_mac_addr
- Change some functions that never fail to return void instead of int
- Minor rewording
- Link to v4: https://lore.kernel.org/r/20250703-net-k1-emac-v4-0-686d0...
Changes in v4:
- Resource handling on probe and remove: timer_delete_sync and
of_phy_deregister_fixed_link
- Drop DTS changes and dependencies (will send through SpacemiT tree)
- Minor changes:
- Remove redundant phy_stop() and setting of ndev->phydev
- Fix error checking for emac_open in emac_resume
- Fix one missed dev_err -> dev_err_probe
- Fix type of emac_start_xmit
- Fix one missed reverse xmas tree formatting
- Rename some functions for consistency between emac_* and ndo_*
- Link to v3: https://lore.kernel.org/r/20250702-net-k1-emac-v3-0-882dc...
Changes in v3:
- Refactored and simplified emac_tx_mem_map
- Addressed other minor v2 review comments
- Removed what was patch 3 in v2, depend on DMA buses instead
- DT nodes in alphabetical order where appropriate
- Link to v2: https://lore.kernel.org/r/20250618-net-k1-emac-v2-0-94f5f...
Changes in v2:
- dts: Put eth0 and eth1 nodes under a bus with dma-ranges
- dts: Added Milk-V Jupiter
- Fix typo in emac_init_hw() that broke the driver (Oops!)
- Reformatted line lengths to under 80
- Addressed other v1 review comments
- Link to v1: https://lore.kernel.org/r/20250613-net-k1-emac-v1-0-cc6f9...
---
Vivian Wang (5):
dt-bindings: net: Add support for SpacemiT K1
net: spacemit: Add K1 Ethernet MAC
riscv: dts: spacemit: Add Ethernet support for K1
riscv: dts: spacemit: Add Ethernet support for BPI-F3
riscv: dts: spacemit: Add Ethernet support for Jupiter
.../devicetree/bindings/net/spacemit,k1-emac.yaml | 81 +
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 46 +
arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts | 46 +
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 48 +
arch/riscv/boot/dts/spacemit/k1.dtsi | 22 +
drivers/net/ethernet/Kconfig | 1 +
drivers/net/ethernet/Makefile | 1 +
drivers/net/ethernet/spacemit/Kconfig | 29 +
drivers/net/ethernet/spacemit/Makefile | 6 +
drivers/net/ethernet/spacemit/k1_emac.c | 2161 ++++++++++++++++++++
drivers/net/ethernet/spacemit/k1_emac.h | 416 ++++
11 files changed, 2857 insertions(+)
---
base-commit: 062b3e4a1f880f104a8d4b90b767788786aa7b78
change-id: 20250606-net-k1-emac-3e181508ea64
Best regards,
--
Vivian "dramforever" Wang