Thread View: linux.kernel.netdev
9 messages
9 total messages
Started by Selvamani Rajagopal via B4 Relay
Tue, 24 Nov 2026 22:09
[PATCH net-next v12 00/15] Support for onsemi's S2500 10BASE-T1S MAC-PHY
Author: Selvamani Rajagopal via B4 Relay
Date: Tue, 24 Nov 2026 22:09
Date: Tue, 24 Nov 2026 22:09
210 lines
21081 bytes
21081 bytes
This patch series brings support for onsemi's S2500, an
IEEE 802.3cg compliant 10BASE-T1S Ethernet transceiver with an
integrated Media Access Controller (MAC-PHY).
The driver works with the OA TC6 framework that is already
present, and supports hardware timestamping. The framework gets
hardware timestamp support, a quirk to map MDIO_MMD_VEND1 to a
vendor MMS, an API to set the TX credit threshold, an RX
cut-through quirk and handling of the frame drop (FD) bit. It
also moves to its own directory. A device tree binding is added
and the framework documentation is updated.
Through ethtool, the driver provides a register dump, MAC, PHY
and RMON statistics, timestamp statistics and self-test,
including PHY loopback.
As S2500 has an internal PHY, onsemi's PHY driver is extended to
support it. A new PHY core helper, genphy_loopback_no_speed(), is
added for its loopback and is also used by the dp83867 driver.
Changes to the current behavior:
- NCN26000: enhanced noise immunity (ENI) is now enabled and
disabled together with PLCA.
- OA TC6 framework users: frames flagged with FD are dropped,
received frames shorter than an Ethernet header are dropped,
and drivers selecting OA_TC6 now depend on PTP_1588_CLOCK_OPTIONAL
Signed-off-by: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
---
Changes in v12:
- Map MDIO_MMD_VEND1 to vendor MMS through a quirk parameter in oa_tc6_init
- Do not drop a TX frame when no timestamp capture register is free, send
it without a timestamp and count an error
- Fix races in timestamp configuration and in interface down handling
- Link to v11: https://lore.kernel.org/r/20261113-s2500-mac-phy-support-v11-0-7a186141952c@onsemi.com
Changes in v11:
- Create new patches to move vendor changes to its own patch
- Improve commit message to be more informative of the changes
- Add clarity to kernel documentation in oa-tc6-framework.rst
- Fix issues potential Oops issue in S2500 driver.
- Add logic to take care of frame drop bit from MAC-PHY
- Link to v10: https://lore.kernel.org/r/20261106-s2500-mac-phy-support-v10-0-31b5a69b85b7@onsemi.com
Changes in v10:
- Removed config_intr callback in S2500 PHY driver
- Removed writing status0/config0 from s2500 driver
- Implemented API to set tx credit threshold and
to enable RX cut-through mode
- Drop the frame when frame drop bit in footer is set
- Module name restored back to oa_tc6.ko from oa_tc6_mod.ko
- Link to v9: https://lore.kernel.org/r/20261009-s2500-mac-phy-support-v9-0-dcefe1d0bf0d@onsemi.com
Changes in v9:
- Renamed the new phy API from having "fixed_speed" to "no_speed"
- Fixed compilation issue due to having changes in the wrong patch
- Added the MAINTAINERS changes to where files were introduced.
- Fixed coding style issues reported.
- Moved the order of patches so that selftest changes goes after
s2500 support.
- Made Pier's email ID consistent across to be consistent across
the codebase.
- Link to v8: https://lore.kernel.org/r/20260928-s2500-mac-phy-support-v8-0-7e011aacc309@onsemi.com
Changes in v8:
- Modified to use newer MMD based read/write APIs
- clean up by removing unused definitions/initializations
- Better handling of timestamp capture events by using
bit fields so that we don't lose any event
- timestamp skb queue is protected with spinlock
- added reset-gpio in YAML file as support is recently added
- removed ioctl from OA TC6 framework as it is not needed.
- Link to v7: https://lore.kernel.org/all/20260708-s2500-mac-phy-support-v7-0-478c877aa1a9@onsemi.com
Changes in v7:
- Fixed compiler warning due to prototype mismatch
- Moved the order of patches to ensure dt-bindings comes first
before it is being used
- Added missing review tag
- Added missing MODULE_DEVICE_TABLE
- OA_TC6 framework enables 64 bit timestamping mode by default.
- Compiler related warnings fixed.
- Link to v6: https://lore.kernel.org/r/20260629-s2500-mac-phy-support-v6-0-18ce79500371@onsemi.com
Changes in v6:
- Changes to ensure onsemi code stay within 80 columns.
- Fixed the error of "not described in comments section"
in comments section.
- Fixed compiler warnings.
- Link to v5: https://patch.msgid.link/20260614-s2500-mac-phy-support-v5-0-89874b72f725@onsemi.com
Changes in v5:
- kernel doc related changes in oa_tc.c, onsemi driver files and
oa tc6 rst file
- Link to v4: https://lore.kernel.org/r/20260605-s2500-mac-phy-support-v4-0-de0fbc13c6d8@onsemi.com
Changes in v4:
- Added return value comment for genphy_read/write_phy_mmd functions
- Added genphy_loopback_fixed_speed helper function to be used in
set_loopback callbacks
- Updated networking documentation for OA TC6 framework to elaborate
on what is expected in the ptp_clock_info structure for registration.
- added spi-max-frequency in YAML file based on alert from sashiko-bot
- Removed model/version from the onsemi driver's private structure as
they were useful as "information-only" data.
- Replaced the non-standard selftest with Linux's standard selftest
and made it as a separate patch
- Changed bit manipulation, shift operations to use macros so that
it is clean and readable.
- added new read_register and write_register apis with _mms postfix
so that MMS (memory map selector) can be given as a parameter.
- Fixed the wrong condition check with NETIF_F_RXFCS to subtract
FCS size from the length of the frame.
- Link to v3: https://lore.kernel.org/r/CY8PR02MB92499C9080614FA3CEB8CD0483162@CY8PR02MB9249.namprd02.prod.outlook.com
Changes in v3:
- Moved OA TC6 framework to its own directory.
- Split changes to smaller patches based on feedback.
- Added PHY loopback support as a separate patch.
- New, read and write register APIs with extra parameter MMS
- Link to v2: https://lore.kernel.org/r/CY8PR02MB924920C8825C7AE5D22EFA4483382@CY8PR02MB9249.namprd02.prod.outlook.com
Changes in v2:
- API to add vendor specific MMS to mdio device map.
- Link to v1: https://lore.kernel.org/r/CY8PR02MB9249D083B637477C254F9B0583322@CY8PR02MB9249.namprd02.prod.outlook.com
To: Selva Rajagopal <selvamani.rajagopal@onsemi.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>
To: David S. Miller <davem@davemloft.net>
To: Eric Dumazet <edumazet@google.com>
To: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
To: Rob Herring <robh@kernel.org>
To: Krzysztof Kozlowski <krzk+dt@kernel.org>
To: Conor Dooley <conor+dt@kernel.org>
To: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>
To: Simon Horman <horms@kernel.org>
To: Jonathan Corbet <corbet@lwn.net>
To: Shuah Khan <skhan@linuxfoundation.org>
To: Randy Dunlap <rdunlap@infradead.org>
To: Richard Cochran <richardcochran@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
To: Heiner Kallweit <hkallweit1@gmail.com>
To: Russell King <linux@armlinux.org.uk>
To: Eric Dumazet <edumazet@kernel.org>
To: Piergiorgio Beruto <piergiorgio.beruto@gmail.com>
Cc: Selva Rajagopal <Selvamani.Rajagopal@onsemi.com>
Cc: netdev@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-doc@vger.kernel.org
---
Selvamani Rajagopal (15):
dt-bindings: net: add onsemi's S2500
Documentation: networking: Add timestamp related APIs to OA TC6 framework
net: ethernet: oa_tc6: Move oa_tc6.c to its own directory
net: ethernet: oa_tc6: Move constant definitions to header file
net: ethernet: microchip: lan865x: Depends on PTP_1588_CLOCK_OPTIONAL
net: ethernet: adi: adin1140: Depends on PTP_1588_CLOCK_OPTIONAL
net: ethernet: oa_tc6: Support for hardware timestamp
net: ethernet: oa_tc6: Drop frames if footer has FD bit set
net: ethernet: oa_tc6: Support for vendor specific MMS
net: ethernet: oa_tc6: APIs to customize CONFIG0 settings
net: phy: ncn26000: Enable enhanced noise immunity
net: phy: Add helper to modify only the PHY loopback bit
net: phy: ncn26000: Support for onsemi's S2500 internal phy
net: phy: dp83867: Use genphy_loopback_no_speed()
net: ethernet: onsemi: s2500: Add driver support for S2500
.../devicetree/bindings/net/onnn,s2500.yaml | 71 +++
Documentation/networking/oa-tc6-framework.rst | 113 ++++-
MAINTAINERS | 11 +-
drivers/net/ethernet/Kconfig | 13 +-
drivers/net/ethernet/Makefile | 3 +-
drivers/net/ethernet/adi/Kconfig | 1 +
drivers/net/ethernet/microchip/lan865x/Kconfig | 1 +
drivers/net/ethernet/oa_tc6/Kconfig | 16 +
drivers/net/ethernet/oa_tc6/Makefile | 7 +
.../ethernet/{oa_tc6.c => oa_tc6/oa_tc6_main.c} | 561 ++++++++++++++++-----
drivers/net/ethernet/oa_tc6/oa_tc6_ptp.c | 68 +++
drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h | 186 +++++++
drivers/net/ethernet/oa_tc6/oa_tc6_tstamp.c | 304 +++++++++++
drivers/net/ethernet/onsemi/Kconfig | 21 +
drivers/net/ethernet/onsemi/Makefile | 6 +
drivers/net/ethernet/onsemi/s2500/Kconfig | 20 +
drivers/net/ethernet/onsemi/s2500/Makefile | 6 +
drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c | 389 ++++++++++++++
drivers/net/ethernet/onsemi/s2500/s2500_hw_def.h | 165 ++++++
drivers/net/ethernet/onsemi/s2500/s2500_main.c | 496 ++++++++++++++++++
drivers/net/ethernet/onsemi/s2500/s2500_ptp.c | 156 ++++++
drivers/net/phy/Kconfig | 2 +-
drivers/net/phy/dp83867.c | 11 +-
drivers/net/phy/ncn26000.c | 68 ++-
drivers/net/phy/phy_device.c | 24 +
include/linux/oa_tc6.h | 33 ++
include/linux/phy.h | 2 +
27 files changed, 2602 insertions(+), 152 deletions(-)
---
base-commit: c2621b518b38ed38e280e008aa33e6c2d302f8cc
change-id: 20260601-s2500-mac-phy-support-4f3ae920fb73
Best regards,
--
Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
[PATCH net-next v12 03/15] net: ethernet: oa_tc6: Move oa_tc6.c to its own directory
Author: Selvamani Rajagopal via B4 Relay
Date: Tue, 24 Nov 2026 22:09
Date: Tue, 24 Nov 2026 22:09
149 lines
15913 bytes
15913 bytes
From: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
Move oa_tc6.c to its own directory, drivers/net/ethernet/oa_tc6.
File oa_tc6.c is renamed to oa_tc6_main.c to maintain the kernel
module's name as oa_tc6.
Having a separate oa_tc6 directory will facilitate adding more
files as subsequent patches will add files for hardware timestamping
and PTP support.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
---
changes in v12
- Changed the commit message to remove the term "patch series".
changes in v11
- Mentioned the renaming of oa_tc6.c in the commit message
changes in v10
- Kernel module restored to oa_tc6.ko from oa_tc6_mod.ko
changes in v9
- Changed MAINTAINERS to add "all files" under oa_tc6
- Added the missing "if COMPILE_TEST"
- Added Reviewed by tag
changes in v8
- No change
changes in v7
- No change
changes in v6
- No change
changes in v5
- No change
changes in v4
- Removed reference to onsemi in Kconfig files
changes in v3
- Moved oa_tc6.c to its own, oa_tc6 directory under ethernet.
- First patch
---
MAINTAINERS | 2 +-
drivers/net/ethernet/Kconfig | 12 +-----------
drivers/net/ethernet/Makefile | 2 +-
drivers/net/ethernet/oa_tc6/Kconfig | 15 +++++++++++++++
drivers/net/ethernet/oa_tc6/Makefile | 7 +++++++
drivers/net/ethernet/{oa_tc6.c => oa_tc6/oa_tc6_main.c} | 0
6 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 679b3b9565a1..ccc9dbf67731 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -21063,7 +21063,7 @@ M: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>
L: netdev@vger.kernel.org
S: Maintained
F: Documentation/networking/oa-tc6-framework.rst
-F: drivers/net/ethernet/oa_tc6.c
+F: drivers/net/ethernet/oa_tc6/*
F: include/linux/oa_tc6.h
OPEN FIRMWARE AND FLATTENED DEVICE TREE
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index c2b0161d0bec..5758e0fbbca5 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -135,6 +135,7 @@ source "drivers/net/ethernet/netronome/Kconfig"
source "drivers/net/ethernet/8390/Kconfig"
source "drivers/net/ethernet/nvidia/Kconfig"
source "drivers/net/ethernet/nxp/Kconfig"
+source "drivers/net/ethernet/oa_tc6/Kconfig"
source "drivers/net/ethernet/oki-semi/Kconfig"
config ETHOC
@@ -147,17 +148,6 @@ config ETHOC
help
Say Y here if you want to use the OpenCores 10/100 Mbps Ethernet MAC.
-config OA_TC6
- tristate "OPEN Alliance TC6 10BASE-T1x MAC-PHY support" if COMPILE_TEST
- depends on SPI
- select PHYLIB
- help
- This library implements OPEN Alliance TC6 10BASE-T1x MAC-PHY
- Serial Interface protocol for supporting 10BASE-T1x MAC-PHYs.
-
- To know the implementation details, refer documentation in
- <file:Documentation/networking/oa-tc6-framework.rst>.
-
source "drivers/net/ethernet/pasemi/Kconfig"
source "drivers/net/ethernet/pensando/Kconfig"
source "drivers/net/ethernet/qlogic/Kconfig"
diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile
index a306dae23bcb..e0e86c249e42 100644
--- a/drivers/net/ethernet/Makefile
+++ b/drivers/net/ethernet/Makefile
@@ -72,6 +72,7 @@ obj-$(CONFIG_NET_VENDOR_NETRONOME) += netronome/
obj-$(CONFIG_NET_VENDOR_NI) += ni/
obj-$(CONFIG_NET_VENDOR_NVIDIA) += nvidia/
obj-$(CONFIG_LPC_ENET) += nxp/
+obj-$(CONFIG_OA_TC6) += oa_tc6/
obj-$(CONFIG_NET_VENDOR_OKI) += oki-semi/
obj-$(CONFIG_ETHOC) += ethoc.o
obj-$(CONFIG_NET_VENDOR_PASEMI) += pasemi/
@@ -105,5 +106,4 @@ obj-$(CONFIG_NET_VENDOR_XILINX) += xilinx/
obj-$(CONFIG_NET_VENDOR_XIRCOM) += xircom/
obj-$(CONFIG_NET_VENDOR_SYNOPSYS) += synopsys/
obj-$(CONFIG_NET_VENDOR_PENSANDO) += pensando/
-obj-$(CONFIG_OA_TC6) += oa_tc6.o
obj-$(CONFIG_NET_VENDOR_ZTE) += zte/
diff --git a/drivers/net/ethernet/oa_tc6/Kconfig b/drivers/net/ethernet/oa_tc6/Kconfig
new file mode 100644
index 000000000000..ec2787eae4b1
--- /dev/null
+++ b/drivers/net/ethernet/oa_tc6/Kconfig
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# OA TC6 10BASE-T1x MAC-PHY configuration
+#
+
+config OA_TC6
+ tristate "OPEN Alliance TC6 10BASE-T1x MAC-PHY support" if COMPILE_TEST
+ depends on SPI
+ select PHYLIB
+ help
+ This library implements OPEN Alliance TC6 10BASE-T1x MAC-PHY
+ Serial Interface protocol for supporting 10BASE-T1x MAC-PHYs.
+
+ To know the implementation details, refer documentation in
+ <file:Documentation/networking/oa-tc6-framework.rst>.
diff --git a/drivers/net/ethernet/oa_tc6/Makefile b/drivers/net/ethernet/oa_tc6/Makefile
new file mode 100644
index 000000000000..c51621fae8be
--- /dev/null
+++ b/drivers/net/ethernet/oa_tc6/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for OA TC6 10BASE-T1x MAC-PHY
+#
+
+obj-$(CONFIG_OA_TC6) += oa_tc6.o
+oa_tc6-objs := oa_tc6_main.o
diff --git a/drivers/net/ethernet/oa_tc6.c b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
similarity index 100%
rename from drivers/net/ethernet/oa_tc6.c
rename to drivers/net/ethernet/oa_tc6/oa_tc6_main.c
--
2.43.0
[PATCH net-next v12 08/15] net: ethernet: oa_tc6: Drop frames if footer has FD bit set
Author: Selvamani Rajagopal via B4 Relay
Date: Tue, 24 Nov 2026 22:09
Date: Tue, 24 Nov 2026 22:09
100 lines
14819 bytes
14819 bytes
From: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
Drop a receive frame when the data footer of its last chunk has
the Frame Drop (FD) bit set, as required by the OPEN Alliance
specification. The dropped frame is counted in rx_errors.
Here is one scenario when FD bit will be set. With RX cut-through
enabled, the MAC-PHY can start forwarding a frame before it knows
the frame is bad, and uses FD to tell the host to discard it.
Signed-off-by: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
---
changes in v12
- Moved the OA_TC6_DATA_FOOTER_FRAME_DROP bit definition to this
patch as this is the patch where it is used.
- Dropped frames are counted in rx_errors.
changes in v11
- Act on FD bit on the footer in the received data chunk.
- New patch in v11
---
Documentation/networking/oa-tc6-framework.rst | 5 +++++
drivers/net/ethernet/oa_tc6/oa_tc6_main.c | 24 ++++++++++++++++++++++++
drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h | 1 +
3 files changed, 30 insertions(+)
diff --git a/Documentation/networking/oa-tc6-framework.rst b/Documentation/networking/oa-tc6-framework.rst
index 2df8455bf3ba..390529419133 100644
--- a/Documentation/networking/oa-tc6-framework.rst
+++ b/Documentation/networking/oa-tc6-framework.rst
@@ -324,6 +324,11 @@ FD (Bit 15) - Frame Drop. When set, this bit indicates that the MAC has
of a received Ethernet frame (EV = 1) and shall be zero at
all other times.
+ The framework accounts for frames it discards in response
+ to FD in ``rx_errors`` rather than ``rx_dropped``.
+ A partial frame already discarded during receive recovery
+ is not counted again when its FD footer arrives.
+
EV (Bit 14) - End Valid flag. The MAC-PHY sets this bit when the end of a
received Ethernet frame is present in this receive data
chunk payload.
diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
index 22aaecd814ec..c69ed576b41d 100644
--- a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
+++ b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
@@ -1173,6 +1173,7 @@ static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data,
footer);
bool start_valid = FIELD_GET(OA_TC6_DATA_FOOTER_START_VALID, footer);
bool end_valid = FIELD_GET(OA_TC6_DATA_FOOTER_END_VALID, footer);
+ bool frame_drop = FIELD_GET(OA_TC6_DATA_FOOTER_FRAME_DROP, footer);
u16 size;
/* Restart the new rx frame after receiving rx buffer overflow error */
@@ -1182,6 +1183,29 @@ static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data,
if (tc6->wait_until_start_valid)
return 0;
+ /* Drop the frame, if footer sets FD bit. Checking FD bit
+ * becomes important, when cut-through operation is enabled.
+ */
+ if (end_valid && frame_drop) {
+ /* Any buffered frame precedes this complete frame. */
+ if (start_valid && start_byte_offset < end_byte_offset) {
+ tc6->netdev->stats.rx_errors++;
+ oa_tc6_cleanup_ongoing_rx_skb(tc6);
+ return 0;
+ }
+
+ /* Recovery may have already discarded the buffered frame. */
+ if (tc6->rx_skb) {
+ tc6->netdev->stats.rx_errors++;
+ dev_kfree_skb_any(tc6->rx_skb);
+ tc6->rx_skb = NULL;
+ }
+
+ /* The chunk carries only the end of the dropped frame. */
+ if (!start_valid)
+ return 0;
+ }
+
/* Process the chunk with complete rx frame */
if (start_valid && end_valid && start_byte_offset < end_byte_offset) {
size = end_byte_offset + 1 - start_byte_offset;
diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h b/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h
index e93440447516..014b48e7e27d 100644
--- a/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h
+++ b/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h
@@ -50,6 +50,7 @@
#define OA_TC6_DATA_FOOTER_DATA_VALID BIT(21)
#define OA_TC6_DATA_FOOTER_START_VALID BIT(20)
#define OA_TC6_DATA_FOOTER_START_WORD_OFFSET GENMASK(19, 16)
+#define OA_TC6_DATA_FOOTER_FRAME_DROP BIT(15)
#define OA_TC6_DATA_FOOTER_END_VALID BIT(14)
#define OA_TC6_DATA_FOOTER_RTSA_VALID BIT(7)
#define OA_TC6_DATA_FOOTER_RTSP_VALID BIT(6)
--
2.43.0
[PATCH net-next v12 09/15] net: ethernet: oa_tc6: Support for vendor specific MMS
Author: Selvamani Rajagopal via B4 Relay
Date: Tue, 24 Nov 2026 22:09
Date: Tue, 24 Nov 2026 22:09
186 lines
16796 bytes
16796 bytes
From: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
Add vend1_mms to struct oa_tc6_quirks to let a vendor driver
map MDIO_MMD_VEND1 to one of the vendor specific MMS values,
10 to 15, in table 6 of the OPEN Alliance 10BASE-T1x MAC-PHY
Serial Interface specification.
The mapping must be known when oa_tc6_init() scans for the PHY,
which can access MMD VEND1.
A zero vend1_mms keeps the current behavior. A value outside 10 to 15
makes oa_tc6_init() fail with -EINVAL.
Signed-off-by: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
---
changes in v12
- Dropped Reviewed-by from Andrew Lunn as the code has changed.
- MMD VEND1 mapping is now part of the quirks, not an API.
changes in v11
- Accidentally patch got removed
changes in v10
- No change
changes in v9
- No change
changes in v8
- No change
changes in v7
- No change
changes in v6
- No change
changes in v5
- no change
changes in v4
- no change
changes in v3
- no change
changes in v2
- Moved the handling of vendor specific MMS mapping to separate patch
- new patch
---
Documentation/networking/oa-tc6-framework.rst | 12 +++++++++++-
drivers/net/ethernet/oa_tc6/oa_tc6_main.c | 22 ++++++++++++++++------
drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h | 6 +++++-
include/linux/oa_tc6.h | 1 +
4 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/Documentation/networking/oa-tc6-framework.rst b/Documentation/networking/oa-tc6-framework.rst
index 390529419133..558dc25038d3 100644
--- a/Documentation/networking/oa-tc6-framework.rst
+++ b/Documentation/networking/oa-tc6-framework.rst
@@ -469,7 +469,17 @@ The include/linux/oa_tc6.h defines the following functions:
struct net_device *netdev, \
struct oa_tc6_quirks *quirks)
-Initialize OA TC6 lib.
+Initialize the OA TC6 lib. Pass ``NULL`` for quirks if no device-specific
+settings are needed.
+
+The quirk_flags field supports:
+
+- OA_TC6_BROKEN_PHY: Leave MDIO bus registration and PHY connection to the
+ vendor driver instead of the framework.
+
+A zero value for vend1_mms means no Clause 45 ``MDIO_MMD_VEND1``
+mapping is requested; it does not select MMS 0. For any nonzero value
+outside the range 10 through 15, ``oa_tc6_init()`` fails with ``-EINVAL``.
.. c:function:: void oa_tc6_exit(struct oa_tc6 *tc6)
diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
index c69ed576b41d..228cc2a3dc2d 100644
--- a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
+++ b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
@@ -619,7 +619,7 @@ static int oa_tc6_mdiobus_write(struct mii_bus *bus, int addr, int regnum,
val);
}
-static int oa_tc6_get_phy_c45_mms(int devnum)
+static int oa_tc6_get_phy_c45_mms(struct oa_tc6 *tc6, int devnum)
{
switch (devnum) {
case MDIO_MMD_PCS:
@@ -632,6 +632,8 @@ static int oa_tc6_get_phy_c45_mms(int devnum)
return OA_TC6_PHY_C45_AUTO_NEG_MMS5;
case MDIO_MMD_POWER_UNIT:
return OA_TC6_PHY_C45_POWER_UNIT_MMS6;
+ case MDIO_MMD_VEND1:
+ return tc6->quirks.vend1_mms;
default:
return -EOPNOTSUPP;
}
@@ -645,7 +647,7 @@ int oa_tc6_mdiobus_read_c45(struct mii_bus *bus, int addr, int devnum,
int mms;
int ret;
- mms = oa_tc6_get_phy_c45_mms(devnum);
+ mms = oa_tc6_get_phy_c45_mms(tc6, devnum);
if (mms < 0)
return mms;
@@ -663,7 +665,7 @@ int oa_tc6_mdiobus_write_c45(struct mii_bus *bus, int addr, int devnum,
struct oa_tc6 *tc6 = bus->priv;
int mms;
- mms = oa_tc6_get_phy_c45_mms(devnum);
+ mms = oa_tc6_get_phy_c45_mms(tc6, devnum);
if (mms < 0)
return mms;
@@ -722,7 +724,7 @@ static int oa_tc6_phy_init(struct oa_tc6 *tc6)
{
int ret;
- if (tc6->quirk_flags & OA_TC6_BROKEN_PHY)
+ if (tc6->quirks.quirk_flags & OA_TC6_BROKEN_PHY)
return 0;
ret = oa_tc6_check_phy_reg_direct_access_capability(tc6);
@@ -761,7 +763,7 @@ static int oa_tc6_phy_init(struct oa_tc6 *tc6)
static void oa_tc6_phy_exit(struct oa_tc6 *tc6)
{
- if (tc6->quirk_flags & OA_TC6_BROKEN_PHY)
+ if (tc6->quirks.quirk_flags & OA_TC6_BROKEN_PHY)
return;
phy_disconnect(tc6->phydev);
@@ -1700,7 +1702,15 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev,
init_completion(&tc6->ts_cfg_done);
if (quirks)
- tc6->quirk_flags = quirks->quirk_flags;
+ tc6->quirks = *quirks;
+
+ if (!tc6->quirks.vend1_mms)
+ tc6->quirks.vend1_mms = -EOPNOTSUPP;
+ else if (tc6->quirks.vend1_mms < OA_TC6_VENDOR_MMS_MIN ||
+ tc6->quirks.vend1_mms > OA_TC6_VENDOR_MMS_MAX)
+ return ERR_PTR(dev_err_probe(&spi->dev, -EINVAL,
+ "Invalid VEND1 MMS: %d\n",
+ tc6->quirks.vend1_mms));
/* Set the SPI controller to pump at realtime priority */
tc6->spi->rt = true;
diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h b/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h
index 014b48e7e27d..cc7cda673f1b 100644
--- a/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h
+++ b/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h
@@ -32,6 +32,10 @@
#define OA_TC6_CTRL_HEADER_LENGTH GENMASK(7, 1)
#define OA_TC6_CTRL_HEADER_PARITY BIT(0)
+/* Vendor-specific MMS range from Table 6 of OA TC6 specification. */
+#define OA_TC6_VENDOR_MMS_MIN 10
+#define OA_TC6_VENDOR_MMS_MAX 15
+
/* Data header */
#define OA_TC6_DATA_HEADER_DATA_NOT_CTRL BIT(31)
#define OA_TC6_DATA_HEADER_DATA_VALID BIT(21)
@@ -131,7 +135,7 @@ struct oa_tc6 {
bool int_flag;
bool disable_traffic;
bool prot_ctrl;
- enum oa_tc6_quirk_flag quirk_flags;
+ struct oa_tc6_quirks quirks;
struct gpio_desc *reset_gpio;
struct list_head ttsc_skb_list;
struct ptp_clock *ptp_clock;
diff --git a/include/linux/oa_tc6.h b/include/linux/oa_tc6.h
index 32c25b5e2aa3..f34ed8218a7c 100644
--- a/include/linux/oa_tc6.h
+++ b/include/linux/oa_tc6.h
@@ -86,6 +86,7 @@ enum oa_tc6_quirk_flag {
struct oa_tc6_quirks {
enum oa_tc6_quirk_flag quirk_flags;
+ int vend1_mms;
};
struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev,
--
2.43.0
[PATCH net-next v12 11/15] net: phy: ncn26000: Enable enhanced noise immunity
Author: Selvamani Rajagopal via B4 Relay
Date: Tue, 24 Nov 2026 22:09
Date: Tue, 24 Nov 2026 22:09
87 lines
13008 bytes
13008 bytes
From: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
Intercept PLCA enable/disable requests in set_plca_cfg() and set or
clear the proprietary ENI bit accordingly. By setting the ENI bit,
noise immunity is improved and it is specifically meant for PLCA
enabled nodes.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
---
changes in v12
- No change
changes in v11
- Updated commit message to be more accurate
changes in v10
- No change
changes in v9
- Added Reviewed tag
changes in v8
- No change
changes in v7
- No change
changes in v6
- No change
changes in v5
- No changes
changes in v4
- No changes
changes in v3
- Moved as a separate patch
---
drivers/net/phy/ncn26000.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/ncn26000.c b/drivers/net/phy/ncn26000.c
index cabdd83c614f..888d74b83125 100644
--- a/drivers/net/phy/ncn26000.c
+++ b/drivers/net/phy/ncn26000.c
@@ -35,6 +35,9 @@
#define TO_TMR_DEFAULT 32
+#define NCN26000_REG_PHYCFG1 0x8001
+#define NCN26000_PHYCFG1_ENI BIT(7)
+
static int ncn26000_config_init(struct phy_device *phydev)
{
/* HW bug workaround: the default value of the PLCA TO_TIMER should be
@@ -100,6 +103,24 @@ static int ncn26000_read_status(struct phy_device *phydev)
return 0;
}
+/* Intercept PLCA enable/disable request to
+ * set the proprietary, ENI mode accordingly
+ */
+static int ncn26000_c45_plca_set_cfg(struct phy_device *phydev,
+ const struct phy_plca_cfg *plca_cfg)
+{
+ int ret = genphy_c45_plca_set_cfg(phydev, plca_cfg);
+ u16 eni_cfg = 0;
+
+ if (ret || plca_cfg->enabled < 0)
+ return ret;
+
+ eni_cfg = (plca_cfg->enabled) ? NCN26000_PHYCFG1_ENI : 0;
+ return phy_modify_mmd(phydev, MDIO_MMD_VEND2,
+ NCN26000_REG_PHYCFG1,
+ NCN26000_PHYCFG1_ENI, eni_cfg);
+}
+
static irqreturn_t ncn26000_handle_interrupt(struct phy_device *phydev)
{
int ret;
@@ -151,7 +172,7 @@ static struct phy_driver ncn26000_driver[] = {
.read_status = ncn26000_read_status,
.handle_interrupt = ncn26000_handle_interrupt,
.get_plca_cfg = genphy_c45_plca_get_cfg,
- .set_plca_cfg = genphy_c45_plca_set_cfg,
+ .set_plca_cfg = ncn26000_c45_plca_set_cfg,
.get_plca_status = genphy_c45_plca_get_status,
.soft_reset = genphy_soft_reset,
},
--
2.43.0
[PATCH net-next v12 12/15] net: phy: Add helper to modify only the PHY loopback bit
Author: Selvamani Rajagopal via B4 Relay
Date: Tue, 24 Nov 2026 22:10
Date: Tue, 24 Nov 2026 22:10
94 lines
13783 bytes
13783 bytes
From: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
Add a generic helper function, genphy_loopback_no_speed(), to modify
the loopback bit of the PHY only, without setting the speed. This will
help the PHY drivers, like 10BASE-T1S or any other PHYs that want to
handle the loopback bit only.
Signed-off-by: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
---
changes in v12
- No change
changes in v11
- Made the changes to phy core into a separate patch. Previously
changes were in a patch that also had vendor code changes.
- Documentation in the comments section is made accurate.
changes in v10
- No change
changes in v9
- replaced "fixed_speed" with "no_speed" for the API.
- Improved the comments to be specific about not setting the
speed.
changes in v8
- No code change. Changes were in two different patches.
Merged into one.
changes in v7
- No change
changes in v6
- No change
changes in v5
- No change
changes in v4
- Moved the onsemi implementation to a new, genphy API to
make it vendor agnostic.
changes in v3
- Added loopback functionality for onsemi's PHY driver
- First patch
---
drivers/net/phy/phy_device.c | 24 ++++++++++++++++++++++++
include/linux/phy.h | 2 ++
2 files changed, 26 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index b39e945cebd7..80d93bb43312 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2923,6 +2923,30 @@ int genphy_resume(struct phy_device *phydev)
}
EXPORT_SYMBOL(genphy_resume);
+/**
+ * genphy_loopback_no_speed - Enable or disable PHY loopback, speed unchanged
+ * @phydev: The phy_device struct
+ * @enable: Flag to enable or disable the PHY level loopback.
+ * @speed: Speed setting. Not supported: -EOPNOTSUPP is returned if it is
+ * non-zero when enabling loopback. Ignored when disabling.
+ *
+ * Description: Only BMCR_LOOPBACK is modified. It fails with -EOPNOTSUPP if
+ * @speed is non-zero when enabling loopback, or with the error from the
+ * BMCR access.
+ *
+ * Returns: 0 if successful, negative error code on failure.
+ */
+int genphy_loopback_no_speed(struct phy_device *phydev, bool enable,
+ int speed)
+{
+ if (enable && speed)
+ return -EOPNOTSUPP;
+
+ return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
+ enable ? BMCR_LOOPBACK : 0);
+}
+EXPORT_SYMBOL(genphy_loopback_no_speed);
+
int genphy_loopback(struct phy_device *phydev, bool enable, int speed)
{
if (enable) {
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f1b1ad1dd82f..38a60ad4f68e 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2318,6 +2318,8 @@ int genphy_read_status(struct phy_device *phydev);
int genphy_read_master_slave(struct phy_device *phydev);
int genphy_suspend(struct phy_device *phydev);
int genphy_resume(struct phy_device *phydev);
+int genphy_loopback_no_speed(struct phy_device *phydev, bool enable,
+ int speed);
int genphy_loopback(struct phy_device *phydev, bool enable, int speed);
int genphy_soft_reset(struct phy_device *phydev);
irqreturn_t genphy_handle_interrupt_no_ack(struct phy_device *phydev);
--
2.43.0
[PATCH net-next v12 14/15] net: phy: dp83867: Use genphy_loopback_no_speed()
Author: Selvamani Rajagopal via B4 Relay
Date: Tue, 24 Nov 2026 22:10
Date: Tue, 24 Nov 2026 22:10
50 lines
11979 bytes
11979 bytes
From: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
Replace dp83867_loopback() with genphy_loopback_no_speed(), which
does the same. No functional change.
Signed-off-by: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
---
changes in v12
- No change
changes in v11
- Moved the vendor changes into its own patch.
- New patch in v11.
---
drivers/net/phy/dp83867.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index b4b4931c6f8c..dc00484c6c7a 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -1057,15 +1057,6 @@ static void dp83867_link_change_notify(struct phy_device *phydev)
}
}
-static int dp83867_loopback(struct phy_device *phydev, bool enable, int speed)
-{
- if (enable && speed)
- return -EOPNOTSUPP;
-
- return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
- enable ? BMCR_LOOPBACK : 0);
-}
-
static int
dp83867_led_brightness_set(struct phy_device *phydev,
u8 index, enum led_brightness brightness)
@@ -1291,7 +1282,7 @@ static struct phy_driver dp83867_driver[] = {
.resume = dp83867_resume,
.link_change_notify = dp83867_link_change_notify,
- .set_loopback = dp83867_loopback,
+ .set_loopback = genphy_loopback_no_speed,
.led_brightness_set = dp83867_led_brightness_set,
.led_hw_is_supported = dp83867_led_hw_is_supported,
--
2.43.0
[PATCH net-next v12 15/15] net: ethernet: onsemi: s2500: Add driver support for S2500
Author: Selvamani Rajagopal via B4 Relay
Date: Tue, 24 Nov 2026 22:10
Date: Tue, 24 Nov 2026 22:10
1467 lines
55484 bytes
55484 bytes
From: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
Support for onsemi's S2500, 802.3cg compliant Ethernet
transceiver with integrated MAC-PHY. Works with
OPEN Alliance TC6 framework.
Hardware timestamp support is present in the driver. adjtime
functionality is implemented as a read-modify-write of the time
registers as the device has no add-delta register.
Driver has ethtool support for printing some device
registers, MAC, PHY and rmon stats and timestamp related
traffic counters.
The MAC address is taken from a device tree property if
present, otherwise from the device, otherwise a random
address is used.
Driver supports a maximum of three multicast filters. If
the system has more than 3 multicast addresses to support,
all multicast traffic is allowed.
Raise the transmit credit threshold from the default of 1
credit to 8, using the new oa_tc6_tx_credit_threshold_set()
helper, so that the MAC-PHY asserts the interrupt only when at
least 8 transmit credits are free.
Enable RX cut-through.
Enable the MAC's hardware FCS generation, so the host does
not have to append the FCS to transmitted frames.
Statistics read from the device are cached for 100 ms, so
repeated ethtool queries within that period return the
cached counters. The rx_otherhost_dropped link statistic
is refreshed every 3 seconds while the interface is up.
Support self-test. Also Add imply NET_SELFTESTS in Kconfig
so that users would be able to disable self-test and still
compile.
Signed-off-by: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
---
changes in v12
- Squashed self-test for S2500 into this patch as number of
patches nearing the maximum 15.
- Moved OA TC6 framework API changes to its own patch.
- Fixed RX filter and multicast handling.
- Added rx_otherhost_dropped statistic, refreshed periodically.
changes in v11
- fixed a potential "Oops" due to jumping to wrong label on error
while enabling RX cut-through feature
- Function that enables RX cut-through is made private
- Moved the frame drop feature to separate patch as it is not
related to S2500 driver support.
- MAINTAINERS file changed to include files under onsemi too.
changes in v10
- Removed the code that overwrites CONFIG0 after oa_tc6_init
is done.
- Removed the code that clears status0 register that would
interfere interrupt handling
- setting tx credit threshold to 8 credits
- New API documentation moved to this patch
changes in v9
- moved net_selftest entry in ethtool_ops to the correct patch
- Moved MAINTAINERS changes here for driver files.
- Fix the order of variable declaration to keep reverse Christmas
tree format.
changes in v8
- changes to use the new MMS read/write API in OA TC6 framework
- Updated to improve adjtime/adjfine implementation
- cleanup to remove unnecessary definitions/initializations
- Removed unnecessary ioctl callback
changes in v7
- Moved the update to MAINTAINERS to the patch that has DTS
as it comes first.
- Added space between {}. Added missing MODULE_DEVICE_TABLE
- Removed the duplicate vendor dependency check in Kconfig
changes in v6
- Changes to ensure line length stay within 80 columns
changes in v5
- integrated the onsemi's selftest support to onsemi's driver
as a single patch as number of patches exceeded the limit
- Fixed the formatting issue in Kconfig file
- Fixed commenting issue
changes in v4
- MAC/PHY Loopback implemented by onsemi replaced by Linux
standard net_selftest APIs
- onsemi defined MMS values are replaced by OA TC definitions.
- removed only model information as it has no practical use
- replaced all read/write APIs that use non-zero MMS to
use the new APIs that takes mms as one of its parameters.
- some bit manipulations are changed to use FIELD_GET macro
changes in v3
- split rmon stats and interface states separately.
- moved get_ts_info to OA TC6 framework as this isn't vendor
specific
- removed few static inline code
- moved ptp register code OA TC6 framework
changes in v2
- Removed the support for onsemi's NCN26010 which is legacy
MAC-PHY to keep only onsemi's S2500 MAC-PHY
- Renamed all the functions to start with S2500
changes in v1
- Added onsemi MAC-PHYs NCN26010 and S2500 support
---
MAINTAINERS | 1 +
drivers/net/ethernet/Kconfig | 1 +
drivers/net/ethernet/Makefile | 1 +
drivers/net/ethernet/onsemi/Kconfig | 21 +
drivers/net/ethernet/onsemi/Makefile | 6 +
drivers/net/ethernet/onsemi/s2500/Kconfig | 20 +
drivers/net/ethernet/onsemi/s2500/Makefile | 6 +
drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c | 389 +++++++++++++++++
drivers/net/ethernet/onsemi/s2500/s2500_hw_def.h | 165 +++++++
drivers/net/ethernet/onsemi/s2500/s2500_main.c | 496 ++++++++++++++++++++++
drivers/net/ethernet/onsemi/s2500/s2500_ptp.c | 156 +++++++
11 files changed, 1262 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 5020e938604a..e30e76acba5c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -21039,6 +21039,7 @@ M: Selvamani Rajagopal <selvamani.rajagopal@onsemi.com>
L: netdev@vger.kernel.org
S: Supported
F: Documentation/devicetree/bindings/net/onnn,s2500.yaml
+F: drivers/net/ethernet/onsemi/
OP-TEE DRIVER
M: Jens Wiklander <jenswi@kernel.org>
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index 5758e0fbbca5..c160bf991345 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -137,6 +137,7 @@ source "drivers/net/ethernet/nvidia/Kconfig"
source "drivers/net/ethernet/nxp/Kconfig"
source "drivers/net/ethernet/oa_tc6/Kconfig"
source "drivers/net/ethernet/oki-semi/Kconfig"
+source "drivers/net/ethernet/onsemi/Kconfig"
config ETHOC
tristate "OpenCores 10/100 Mbps Ethernet MAC support"
diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile
index e0e86c249e42..e4bad64bf95c 100644
--- a/drivers/net/ethernet/Makefile
+++ b/drivers/net/ethernet/Makefile
@@ -74,6 +74,7 @@ obj-$(CONFIG_NET_VENDOR_NVIDIA) += nvidia/
obj-$(CONFIG_LPC_ENET) += nxp/
obj-$(CONFIG_OA_TC6) += oa_tc6/
obj-$(CONFIG_NET_VENDOR_OKI) += oki-semi/
+obj-$(CONFIG_NET_VENDOR_ONSEMI) += onsemi/
obj-$(CONFIG_ETHOC) += ethoc.o
obj-$(CONFIG_NET_VENDOR_PASEMI) += pasemi/
obj-$(CONFIG_NET_VENDOR_QLOGIC) += qlogic/
diff --git a/drivers/net/ethernet/onsemi/Kconfig b/drivers/net/ethernet/onsemi/Kconfig
new file mode 100644
index 000000000000..afef0c9ebc72
--- /dev/null
+++ b/drivers/net/ethernet/onsemi/Kconfig
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# onsemi network device configuration
+#
+
+config NET_VENDOR_ONSEMI
+ bool "onsemi network devices"
+ default y
+ help
+ If you have a network card belonging to this class, say Y.
+
+ Note that the answer to this question doesn't directly affect the
+ kernel: saying N will just cause the configurator to skip all
+ the questions about onsemi ethernet devices. If you say Y, you
+ will be asked for your specific card in the following questions.
+
+if NET_VENDOR_ONSEMI
+
+source "drivers/net/ethernet/onsemi/s2500/Kconfig"
+
+endif # NET_VENDOR_ONSEMI
diff --git a/drivers/net/ethernet/onsemi/Makefile b/drivers/net/ethernet/onsemi/Makefile
new file mode 100644
index 000000000000..1091c55dcbe6
--- /dev/null
+++ b/drivers/net/ethernet/onsemi/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for the onsemi network device drivers.
+#
+
+obj-$(CONFIG_S2500_MACPHY) += s2500/
diff --git a/drivers/net/ethernet/onsemi/s2500/Kconfig b/drivers/net/ethernet/onsemi/s2500/Kconfig
new file mode 100644
index 000000000000..4bd28dc560e6
--- /dev/null
+++ b/drivers/net/ethernet/onsemi/s2500/Kconfig
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# onsemi S2500 Driver Support
+#
+
+config S2500_MACPHY
+ tristate "S2500 support"
+ depends on SPI
+ depends on PTP_1588_CLOCK_OPTIONAL
+ imply NET_SELFTESTS
+ select BITREVERSE
+ select NCN26000_PHY
+ select OA_TC6
+ help
+ Support for the onsemi S2500 MACPHY Ethernet chip.
+ It works under the framework that conforms to OPEN Alliance
+ 10BASE-T1x Serial Interface specification.
+
+ To compile this driver as a module, choose M here. The module will be
+ called s2500.
diff --git a/drivers/net/ethernet/onsemi/s2500/Makefile b/drivers/net/ethernet/onsemi/s2500/Makefile
new file mode 100644
index 000000000000..807eabaa7a3c
--- /dev/null
+++ b/drivers/net/ethernet/onsemi/s2500/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for the onsemi network device drivers.
+#
+obj-$(CONFIG_S2500_MACPHY) := s2500.o
+s2500-objs := s2500_main.o s2500_ethtool.o s2500_ptp.o
diff --git a/drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c b/drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c
new file mode 100644
index 000000000000..77d7d172efe0
--- /dev/null
+++ b/drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c
@@ -0,0 +1,389 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2026 Semiconductor Components Industries, LLC ("onsemi").
+ * onsemi's S2500 10BASE-T1S MAC-PHY driver
+ */
+
+#include <linux/ethtool.h>
+#include <net/selftests.h>
+#include <linux/phy.h>
+
+#include "s2500_hw_def.h"
+
+#define S2500_NUM_REGS 38
+#define S2500_REGDUMP_LEN (sizeof(u32) * (S2500_NUM_REGS * 2))
+
+#define S2500_NUM_RMON_STATS 12
+
+struct s2500_reg_map {
+ u16 reg;
+ u8 mms;
+};
+
+static const struct s2500_reg_map s2500_reg_map[S2500_NUM_REGS] = {
+ { S2500_REG_VS_ONIPVER, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_TWEAKS1, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_PLCAEXT, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_PMATUNE0, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_PMATUNE1, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_T1SWUPTUNE, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_HDD, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_DCQ_TOID, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_DCQ_SQI, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_DCQ_SQI_PLUS, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_HDD_TUNE1, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_HDD_TUNE2, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_HDD_TUNE3, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_WS_STATUS_0, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_WS_CTRL_0, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_WS_STATUS_1, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_WS_CTRL_1, OA_TC6_PHY_C45_VS_PLCA_MMS4 },
+ { S2500_REG_VS_MIIMIRQE, S2500_VS_MMS12 },
+ { S2500_REG_VS_MIIMIRQS, S2500_VS_MMS12 },
+ { S2500_REG_VS_DIOCFG0, S2500_VS_MMS12 },
+ { S2500_REG_VS_CHIPID, S2500_VS_MMS12 },
+ { S2500_REG_VS_TWEAKS2, S2500_VS_MMS12 },
+ { S2500_REG_VS_MACID0, S2500_VS_MMS12 },
+ { S2500_REG_VS_MACID1, S2500_VS_MMS12 },
+ { S2500_REG_VS_NVM_HEALTH, S2500_VS_MMS12 },
+ { S2500_REG_VS_PTP_SEC, S2500_VS_MMS12 },
+ { S2500_REG_VS_PTPNSEC, S2500_VS_MMS12 },
+ { S2500_REG_VS_PTP_SETSEC, S2500_VS_MMS12 },
+ { S2500_REG_VS_SETNSEC, S2500_VS_MMS12 },
+ { S2500_REG_VS_PTP_ADJ, S2500_VS_MMS12 },
+ { S2500_REG_VS_CMPCTL, S2500_VS_MMS12 },
+ { S2500_REG_VS_CMPSEC, S2500_VS_MMS12 },
+ { S2500_REG_VS_CMPNSEC, S2500_VS_MMS12 },
+ { S2500_REG_VS_CMPPER, S2500_VS_MMS12 },
+ { S2500_REG_VS_CAPCTL, S2500_VS_MMS12 },
+ { S2500_REG_VS_CAPSEC, S2500_VS_MMS12 },
+ { S2500_REG_VS_CAPNSEC, S2500_VS_MMS12 },
+ { S2500_REG_VS_BCNCNT, S2500_VS_MMS12 },
+};
+
+enum s2500_stat_idx {
+ S2500_MSTOCTETSTX_IDX = 0,
+ S2500_MSTFRAMESTXOK_IDX,
+ S2500_MSTBCASTTXOK_IDX,
+ S2500_MSTMCASTTXOK_IDX,
+ S2500_MSTFRAMESTX64_IDX,
+ S2500_MSTFRAMESTX65_IDX,
+ S2500_MSTFRAMESTX128_IDX,
+ S2500_MSTFRAMESTX256_IDX,
+ S2500_MSTFRAMESTX512_IDX,
+ S2500_MSTFRAMESTX1024_IDX,
+ S2500_MSTTXUNDERFLOW_IDX,
+ S2500_MSTSINGLECOL_IDX,
+ S2500_MSTMULTICOL_IDX,
+ S2500_MSTEXCESSCOL_IDX,
+ S2500_MSTDEFERREDTX_IDX,
+ S2500_MSTCRSERR_IDX,
+ S2500_MSTOCTETSRX_IDX,
+ S2500_MSTFRAMESRXOK_IDX,
+ S2500_MSTBCASTRXOK_IDX,
+ S2500_MSTMCASTRXOK_IDX,
+ S2500_MSTFRAMESRX64_IDX,
+ S2500_MSTFRAMESRX65_IDX,
+ S2500_MSTFRAMESRX128_IDX,
+ S2500_MSTFRAMESRX256_IDX,
+ S2500_MSTFRAMESRX512_IDX,
+ S2500_MSTFRAMESRX1024_IDX,
+ S2500_MSTRUNTSERR_IDX,
+ S2500_MSTRXTOOLONG_IDX,
+ S2500_MSTFCSERRS_IDX,
+ S2500_MSTSYMBOLERRS_IDX,
+ S2500_MSTALIGNERRS_IDX,
+ S2500_MSTRXOVERFLOW_IDX,
+ S2500_MSTRXDROPPED_IDX,
+};
+
+static const u8 s2500_rmon_stat_map[S2500_NUM_RMON_STATS] = {
+ S2500_MSTFRAMESTX64_IDX,
+ S2500_MSTFRAMESTX65_IDX,
+ S2500_MSTFRAMESTX128_IDX,
+ S2500_MSTFRAMESTX256_IDX,
+ S2500_MSTFRAMESTX512_IDX,
+ S2500_MSTFRAMESTX1024_IDX,
+ S2500_MSTFRAMESRX64_IDX,
+ S2500_MSTFRAMESRX65_IDX,
+ S2500_MSTFRAMESRX128_IDX,
+ S2500_MSTFRAMESRX256_IDX,
+ S2500_MSTFRAMESRX512_IDX,
+ S2500_MSTFRAMESRX1024_IDX,
+};
+
+static const struct ethtool_rmon_hist_range s2500_rmon_hist_ranges[] = {
+ { 64, 64 },
+ { 65, 127 },
+ { 128, 255 },
+ { 256, 511 },
+ { 512, 1023 },
+ { 1024, 1522 },
+ { },
+};
+
+static_assert(ARRAY_SIZE(s2500_rmon_stat_map) == S2500_NUM_RMON_STATS);
+
+#define STAT_REG_OFFSET(x) ((S2500_REG_MAC_ST##x) - \
+ S2500_REG_MAC_FIRST_STAT)
+
+/* Adds the registers just read to the counters. The hardware clears them on
+ * read, so each read returns only the delta since the previous read. Hence
+ * the values are accumulated. Called with stats_lock held.
+ */
+static void s2500_accumulate_stats(struct s2500_info *priv, const u32 *regs)
+{
+ u64 *data = priv->stats_data;
+ const u32 *rptr = regs;
+
+ lockdep_assert_held(&priv->stats_lock);
+
+ /* TX bytes is a 64-bit value that is stored in two regs.
+ * When lower 32 bits are read from OCTETS-L register,
+ * upper bits are sampled and stored in OCTETS-H register.
+ * Request to read multiple registers reads OCTETS-L first.
+ * This way, counter value is read in an atomic manner.
+ */
+ *(data++) += ((u64)*rptr) | (((u64)*(rptr + 1)) << 32);
+
+ /* Rest are 32-bit values until RX bytes register. */
+ for (rptr += 2; (rptr - regs) < STAT_REG_OFFSET(OCTETSRXL); ++rptr)
+ *(data++) += *rptr;
+
+ /* RX bytes is a 64-bit value that is stored in two regs.
+ * Like TX bytes counter, value is read atomically from
+ * registers.
+ */
+ *(data++) += ((u64)*rptr) | (((u64)*(rptr + 1)) << 32);
+
+ for (rptr += 2; (rptr - regs) < S2500_NUM_STAT_REGS; ++rptr)
+ *(data++) += *rptr;
+}
+
+/* Reads the statistics registers, unless that was done recently, and adds
+ * them to the counters. If @buf is not NULL it receives a copy of the
+ * counters, taken in the same locked section, so that the caller gets whole
+ * 64-bit values and a set that belongs together while the stats work keeps
+ * adding to them. The copy is made also when no register was read.
+ */
+void s2500_update_stats(struct s2500_info *priv, u64 *buf)
+{
+ u32 regs[S2500_NUM_STAT_REGS];
+ bool have_regs = false;
+ u32 addr;
+
+ if (!time_is_after_jiffies(priv->stats_last_update +
+ S2500_STATS_CACHE_PERIOD)) {
+ addr = FIELD_PREP(S2500_REG_MMS_MASK, OA_TC6_MAC_MMS1) |
+ S2500_REG_MAC_STOCTETSTXL;
+ have_regs = !oa_tc6_read_registers(priv->tc6, addr, regs,
+ S2500_NUM_STAT_REGS);
+ }
+
+ if (!have_regs && !buf)
+ return;
+
+ spin_lock_bh(&priv->stats_lock);
+ if (have_regs) {
+ priv->stats_last_update = jiffies;
+ s2500_accumulate_stats(priv, regs);
+ }
+ if (buf)
+ memcpy(buf, priv->stats_data, sizeof(priv->stats_data));
+ spin_unlock_bh(&priv->stats_lock);
+}
+
+/* Cannot sleep, so no register is read here: the stats work keeps the
+ * counters up to date. The standard counters the driver keeps in
+ * ndev->stats are reported as well, as the core clears @stats first.
+ */
+void s2500_get_stats64(struct net_device *ndev,
+ struct rtnl_link_stats64 *stats)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+
+ netdev_stats_to_stats64(stats, &ndev->stats);
+
+ spin_lock_bh(&priv->stats_lock);
+ stats->rx_otherhost_dropped =
+ priv->stats_data[S2500_MSTRXDROPPED_IDX];
+ spin_unlock_bh(&priv->stats_lock);
+}
+
+static void s2500_get_drvinfo(struct net_device *ndev,
+ struct ethtool_drvinfo *info)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+
+ strscpy(info->driver, DRV_NAME, sizeof(info->driver));
+ strscpy(info->bus_info, dev_name(&priv->spi->dev),
+ sizeof(info->bus_info));
+}
+
+static int s2500_get_sset_count(struct net_device *ndev, int sset)
+{
+ switch (sset) {
+ case ETH_SS_TEST:
+ if (!IS_ENABLED(CONFIG_NET_SELFTESTS))
+ return -EOPNOTSUPP;
+ return net_selftest_get_count();
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+static void s2500_get_strings(struct net_device *ndev, u32 stringset,
+ u8 *buf)
+{
+ switch (stringset) {
+ case ETH_SS_TEST:
+ net_selftest_get_strings(buf);
+ break;
+ }
+}
+
+static void s2500_get_eth_mac_stats(struct net_device *ndev,
+ struct ethtool_eth_mac_stats *mac_stats)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+ u64 st[S2500_NUM_STAT_VARS];
+
+ if (mac_stats->src != ETHTOOL_MAC_STATS_SRC_AGGREGATE)
+ return;
+
+ s2500_update_stats(priv, st);
+
+ mac_stats->OctetsTransmittedOK = st[S2500_MSTOCTETSTX_IDX];
+ mac_stats->FramesTransmittedOK = st[S2500_MSTFRAMESTXOK_IDX];
+ mac_stats->BroadcastFramesXmittedOK = st[S2500_MSTBCASTTXOK_IDX];
+ mac_stats->MulticastFramesXmittedOK = st[S2500_MSTMCASTTXOK_IDX];
+ mac_stats->SingleCollisionFrames = st[S2500_MSTSINGLECOL_IDX];
+ mac_stats->MultipleCollisionFrames = st[S2500_MSTMULTICOL_IDX];
+ mac_stats->FramesAbortedDueToXSColls = st[S2500_MSTEXCESSCOL_IDX];
+ mac_stats->FramesWithDeferredXmissions = st[S2500_MSTDEFERREDTX_IDX];
+ mac_stats->CarrierSenseErrors = st[S2500_MSTCRSERR_IDX];
+ mac_stats->FramesLostDueToIntMACXmitError =
+ st[S2500_MSTTXUNDERFLOW_IDX];
+ mac_stats->OctetsReceivedOK = st[S2500_MSTOCTETSRX_IDX];
+ mac_stats->FramesReceivedOK = st[S2500_MSTFRAMESRXOK_IDX];
+ mac_stats->BroadcastFramesReceivedOK = st[S2500_MSTBCASTRXOK_IDX];
+ mac_stats->MulticastFramesReceivedOK = st[S2500_MSTMCASTRXOK_IDX];
+ mac_stats->FrameTooLongErrors = st[S2500_MSTRXTOOLONG_IDX];
+ mac_stats->FrameCheckSequenceErrors = st[S2500_MSTFCSERRS_IDX];
+ mac_stats->AlignmentErrors = st[S2500_MSTALIGNERRS_IDX];
+ mac_stats->FramesLostDueToIntMACRcvError =
+ st[S2500_MSTRXOVERFLOW_IDX];
+}
+
+static void s2500_get_eth_phy_stats(struct net_device *ndev,
+ struct ethtool_eth_phy_stats *phy_stats)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+ u64 st[S2500_NUM_STAT_VARS];
+
+ if (phy_stats->src != ETHTOOL_MAC_STATS_SRC_AGGREGATE)
+ return;
+
+ s2500_update_stats(priv, st);
+ phy_stats->SymbolErrorDuringCarrier = st[S2500_MSTSYMBOLERRS_IDX];
+}
+
+static void s2500_rmon_stats(struct net_device *ndev,
+ struct ethtool_rmon_stats *rmon_stats,
+ const struct ethtool_rmon_hist_range **ranges)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+ u64 st[S2500_NUM_STAT_VARS];
+ u8 offset;
+ int i;
+
+ if (rmon_stats->src != ETHTOOL_MAC_STATS_SRC_AGGREGATE)
+ return;
+
+ s2500_update_stats(priv, st);
+
+ rmon_stats->undersize_pkts = st[S2500_MSTRUNTSERR_IDX];
+ rmon_stats->oversize_pkts = st[S2500_MSTRXTOOLONG_IDX];
+
+ for (i = 0; i < 6; i++) {
+ offset = s2500_rmon_stat_map[i];
+ rmon_stats->hist_tx[i] = st[offset];
+ }
+
+ for (i = 0; i < 6; i++) {
+ offset = s2500_rmon_stat_map[i + 6];
+ rmon_stats->hist[i] = st[offset];
+ }
+
+ *ranges = s2500_rmon_hist_ranges;
+}
+
+static int s2500_get_ts_info(struct net_device *ndev,
+ struct kernel_ethtool_ts_info *ts_info)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+
+ return oa_tc6_get_ts_info(priv->tc6, ts_info);
+}
+
+static int s2500_get_regs_len(struct net_device *dev)
+{
+ return S2500_REGDUMP_LEN;
+}
+
+static void s2500_get_regs(struct net_device *ndev,
+ struct ethtool_regs *regs, void *p)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+ __be32 *pbuff = p;
+ int ret = 0;
+ u32 val;
+ u16 reg;
+ u8 mms;
+ int i;
+
+ regs->version = 0;
+ memset(p, 0, S2500_REGDUMP_LEN);
+
+ if (!netif_running(ndev))
+ return;
+
+ for (i = 0; i < S2500_NUM_REGS; i++) {
+ val = 0;
+ reg = s2500_reg_map[i].reg;
+ mms = s2500_reg_map[i].mms;
+ ret = oa_tc6_read_register_mms(priv->tc6, mms, reg,
+ &val);
+
+ /* Write a pattern to indicate failure */
+ if (ret)
+ val = 0xDEADC0DE;
+ *pbuff++ = cpu_to_be32(((u32)mms << 16) | reg);
+ *pbuff++ = cpu_to_be32(val);
+ }
+}
+
+static void s2500_get_ts_stats(struct net_device *ndev,
+ struct ethtool_ts_stats *ts_stats)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+
+ oa_tc6_get_ts_stats(priv->tc6, ts_stats);
+}
+
+const struct ethtool_ops s2500_ethtool_ops = {
+ .get_drvinfo = s2500_get_drvinfo,
+ .get_link = ethtool_op_get_link,
+ .get_link_ksettings = phy_ethtool_get_link_ksettings,
+ .set_link_ksettings = phy_ethtool_set_link_ksettings,
+ .get_ts_stats = s2500_get_ts_stats,
+ .get_sset_count = s2500_get_sset_count,
+ .get_strings = s2500_get_strings,
+ .get_eth_mac_stats = s2500_get_eth_mac_stats,
+ .get_eth_phy_stats = s2500_get_eth_phy_stats,
+ .get_rmon_stats = s2500_rmon_stats,
+ .get_ts_info = s2500_get_ts_info,
+ .get_regs_len = s2500_get_regs_len,
+ .get_regs = s2500_get_regs,
+ .self_test = net_selftest,
+};
diff --git a/drivers/net/ethernet/onsemi/s2500/s2500_hw_def.h b/drivers/net/ethernet/onsemi/s2500/s2500_hw_def.h
new file mode 100644
index 000000000000..1d80bec76824
--- /dev/null
+++ b/drivers/net/ethernet/onsemi/s2500/s2500_hw_def.h
@@ -0,0 +1,165 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright 2026 Semiconductor Components Industries, LLC ("onsemi").
+ * onsemi's S2500 10BASE-T1S MAC-PHY driver
+ */
+
+#ifndef S2500_HW_DEF_H
+#define S2500_HW_DEF_H
+
+#include <linux/bitfield.h>
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/spi/spi.h>
+#include <linux/ptp_clock_kernel.h>
+#include <linux/mutex.h>
+#include <linux/spinlock.h>
+#include <linux/workqueue.h>
+#include <linux/ktime.h>
+#include <linux/errno.h>
+#include <linux/oa_tc6.h>
+
+#define DRV_NAME "s2500"
+
+#define S2500_N_MCAST_FILTERS 3
+
+/* Vendor specific memory map selector (MMS 10..15 are vendor defined) */
+#define S2500_VS_MMS12 12
+
+#define S2500_REG_MMS_MASK GENMASK(19, 16)
+
+/* SPI OID and model register */
+#define S2500_REG_PHYID 0x1
+
+#define S2500_PHYID_OUI_SHIFT 10
+#define S2500_PHYID_OUI_MASK GENMASK(31, S2500_PHYID_OUI_SHIFT)
+#define S2500_PHYID_OUI_MASK0 GENMASK(21, 16)
+#define S2500_PHYID_OUI_MASK1 GENMASK(15, 8)
+#define S2500_PHYID_OUI_MASK2 GENMASK(7, 0)
+
+#define S2500_REG_MAC_CTRL 0x0
+
+#define S2500_MAC_CTRL_MCSF BIT(18)
+#define S2500_MAC_CTRL_ADRF BIT(16)
+#define S2500_MAC_CTRL_FCSA BIT(8)
+#define S2500_MAC_CTRL_TXEN BIT(1)
+#define S2500_MAC_CTRL_RXEN BIT(0)
+
+/* MAC address filter registers */
+#define S2500_REG_MAC_ADDRFILTL(n) (16 + 2 * (n))
+#define S2500_REG_MAC_ADDRFILTH(n) (17 + 2 * (n))
+#define S2500_REG_MAC_ADDRMASKL(n) (32 + 2 * (n))
+#define S2500_REG_MAC_ADDRMASKH(n) (33 + 2 * (n))
+
+#define S2500_MAC_ADDRFILT_ENABLE BIT(31)
+
+/* Individual/group bit, the LSB of the first address byte (1 = multicast) */
+#define S2500_ADDR_IG_BIT BIT(8)
+
+/* MAC statistic registers */
+#define S2500_REG_MAC_STOCTETSTXL 48
+#define S2500_REG_MAC_STOCTETSRXL 65
+#define S2500_REG_MAC_STRXDROPPED 82
+
+/* First/last statistic register for sequential access */
+#define S2500_REG_MAC_FIRST_STAT S2500_REG_MAC_STOCTETSTXL
+#define S2500_REG_MAC_LAST_STAT S2500_REG_MAC_STRXDROPPED
+
+#define S2500_NUM_STAT_REGS \
+ (S2500_REG_MAC_LAST_STAT - S2500_REG_MAC_FIRST_STAT + 1)
+#define S2500_NUM_STAT_VARS (S2500_NUM_STAT_REGS - 2)
+#define S2500_STATS_CACHE_PERIOD msecs_to_jiffies(100)
+#define S2500_STATS_WORK_PERIOD msecs_to_jiffies(3000)
+
+/* Vendor specific MMS4 registers */
+#define S2500_REG_VS_ONIPVER 0x8000
+#define S2500_REG_VS_TWEAKS1 0x8001
+#define S2500_REG_VS_PLCAEXT 0x8002
+#define S2500_REG_VS_PMATUNE0 0x8003
+#define S2500_REG_VS_PMATUNE1 0x8004
+#define S2500_REG_VS_T1SWUPTUNE 0x8007
+#define S2500_REG_VS_HDD 0xCC01
+#define S2500_REG_VS_DCQ_TOID 0xCC02
+#define S2500_REG_VS_DCQ_SQI 0xCC03
+#define S2500_REG_VS_DCQ_SQI_PLUS 0xCC04
+#define S2500_REG_VS_HDD_TUNE1 0xCD00
+#define S2500_REG_VS_HDD_TUNE2 0xCD01
+#define S2500_REG_VS_HDD_TUNE3 0xCD02
+#define S2500_REG_VS_WS_STATUS_0 0xD000
+#define S2500_REG_VS_WS_CTRL_0 0xD001
+#define S2500_REG_VS_WS_STATUS_1 0xD100
+#define S2500_REG_VS_WS_CTRL_1 0xD101
+
+/* MIIM IRQ enable register */
+#define S2500_REG_VS_MIIMIRQE 0x10
+
+/* MIIM IRQ status register */
+#define S2500_REG_VS_MIIMIRQS 0x11
+
+/* Digital I/O config register */
+#define S2500_REG_VS_DIOCFG0 0x12
+
+#define S2500_REG_VS_CHIPID 0x1000
+#define S2500_REG_VS_TWEAKS2 0x1001
+
+/* Permanent MAC address register */
+#define S2500_REG_VS_MACID0 0x1002
+#define S2500_VS_MACID0_BYTE4_MASK GENMASK(15, 8)
+#define S2500_VS_MACID0_BYTE5_MASK GENMASK(7, 0)
+
+#define S2500_REG_VS_MACID1 0x1003
+#define S2500_VS_MACID1_BYTE3_MASK GENMASK(7, 0)
+#define S2500_REG_VS_NVM_HEALTH 0x1005
+
+/* Frequency adjust magnitude, 1 LSB = 0.000125 ppm = 1/8 ppb */
+#define S2500_PTP_ADJ_MAX GENMASK(27, 0)
+#define S2500_PTP_ADJ_BASE 8000000000ULL
+#define S2500_PTP_MAX_ADJ_PPB (S2500_PTP_ADJ_MAX / 8)
+
+/* PTP registers */
+#define S2500_REG_VS_PTP_SEC 0x1010
+#define S2500_REG_VS_PTPNSEC 0x1011
+#define S2500_REG_VS_PTP_SETSEC 0x1012
+#define S2500_REG_VS_SETNSEC 0x1013
+#define S2500_REG_VS_PTP_ADJ 0x1014
+#define S2500_REG_VS_CMPCTL 0x1015
+#define S2500_REG_VS_CMPSEC 0x1016
+#define S2500_REG_VS_CMPNSEC 0x1017
+#define S2500_REG_VS_CMPPER 0x1018
+#define S2500_REG_VS_CAPCTL 0x1019
+#define S2500_REG_VS_CAPSEC 0x101A
+#define S2500_REG_VS_CAPNSEC 0x101B
+#define S2500_REG_VS_BCNCNT 0x101C
+
+/* prototypes / forward declarations */
+extern const struct ethtool_ops s2500_ethtool_ops;
+
+struct s2500_info {
+ struct device *dev;
+ struct net_device *ndev;
+
+ /* To have atomic operation for PTP time registers */
+ struct mutex ptp_adj_lock;
+
+ struct spi_device *spi;
+
+ /* statistic counters variables */
+ u64 stats_data[S2500_NUM_STAT_VARS];
+ unsigned long stats_last_update;
+
+ /* Protects stats_data and stats_last_update. */
+ spinlock_t stats_lock;
+ struct delayed_work stats_work;
+
+ /* PTP related variables */
+ struct ptp_clock_info ptp_clock_info;
+ struct oa_tc6 *tc6;
+};
+
+int s2500_ptp_register(struct s2500_info *priv);
+
+void s2500_update_stats(struct s2500_info *priv, u64 *buf);
+void s2500_get_stats64(struct net_device *ndev,
+ struct rtnl_link_stats64 *stats);
+
+#endif /* S2500_HW_DEF_H */
diff --git a/drivers/net/ethernet/onsemi/s2500/s2500_main.c b/drivers/net/ethernet/onsemi/s2500/s2500_main.c
new file mode 100644
index 000000000000..55dbf3ba032d
--- /dev/null
+++ b/drivers/net/ethernet/onsemi/s2500/s2500_main.c
@@ -0,0 +1,496 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2026 Semiconductor Components Industries, LLC ("onsemi").
+ * onsemi's S2500 10BASE-T1S MAC-PHY driver
+ */
+
+#include <linux/etherdevice.h>
+#include <linux/if_ether.h>
+#include <linux/module.h>
+#include <linux/bitrev.h>
+#include <linux/phy.h>
+
+#include "s2500_hw_def.h"
+
+/* Initializes the net device MAC address by reading the UID stored
+ * into the device internal non-volatile memory.
+ */
+static int s2500_read_mac_from_nvmem(struct s2500_info *priv)
+{
+ u8 mms = S2500_VS_MMS12;
+ u8 addr[ETH_ALEN];
+ u32 mac1 = 0;
+ u32 mac0 = 0;
+ u32 val;
+ int ret;
+
+ ret = oa_tc6_read_register_mms(priv->tc6, mms,
+ S2500_REG_VS_MACID1, &mac1);
+ if (ret)
+ return ret;
+
+ ret = oa_tc6_read_register_mms(priv->tc6, mms,
+ S2500_REG_VS_MACID0, &mac0);
+ if (ret)
+ return ret;
+
+ /* Pre-production parts may have 0 */
+ if (mac0 == 0 && mac1 == 0)
+ return -ENXIO;
+
+ ret = oa_tc6_read_register(priv->tc6, S2500_REG_PHYID, &val);
+ if (ret)
+ return ret;
+
+ val = (val & S2500_PHYID_OUI_MASK) >> S2500_PHYID_OUI_SHIFT;
+
+ /* Mapping for bits from PHY ID register to OUI as given below.
+ * - PHY-ID[10:17] provides OUI[16:23]
+ * - PHY-ID[18:25] provides OUI[8:15]
+ * - PHY-ID[26:31] provides OUI[2:7]
+ *
+ * Hardware presents OUI such a way that this requires not just
+ * byte level swap, bit level swap is needed as well.
+ */
+ addr[0] = bitrev8(FIELD_GET(S2500_PHYID_OUI_MASK0, val));
+ addr[1] = bitrev8(FIELD_GET(S2500_PHYID_OUI_MASK1, val));
+ addr[2] = bitrev8(FIELD_GET(S2500_PHYID_OUI_MASK2, val));
+
+ addr[3] = FIELD_GET(S2500_VS_MACID1_BYTE3_MASK, mac1);
+ addr[4] = FIELD_GET(S2500_VS_MACID0_BYTE4_MASK, mac0);
+ addr[5] = FIELD_GET(S2500_VS_MACID0_BYTE5_MASK, mac0);
+
+ __dev_addr_set(priv->ndev, addr, ETH_ALEN);
+ priv->ndev->addr_assign_type = NET_ADDR_PERM;
+ return 0;
+}
+
+/* Writes MAC address to macphy registers */
+static int s2500_write_filter(struct s2500_info *priv, int slot,
+ const u8 *mac)
+{
+ u8 mms = OA_TC6_MAC_MMS1;
+ u32 val;
+ int ret;
+
+ ret = oa_tc6_write_register_mms(priv->tc6, mms,
+ S2500_REG_MAC_ADDRMASKL(slot),
+ 0xffffffff);
+ if (ret)
+ return ret;
+
+ ret = oa_tc6_write_register_mms(priv->tc6, mms,
+ S2500_REG_MAC_ADDRMASKH(slot),
+ 0xffff);
+ if (ret)
+ return ret;
+
+ val = get_unaligned_be32(&mac[2]);
+
+ ret = oa_tc6_write_register_mms(priv->tc6, mms,
+ S2500_REG_MAC_ADDRFILTL(slot), val);
+ if (ret)
+ return ret;
+
+ val = S2500_MAC_ADDRFILT_ENABLE | get_unaligned_be16(mac);
+
+ return oa_tc6_write_register_mms(priv->tc6, mms,
+ S2500_REG_MAC_ADDRFILTH(slot), val);
+}
+
+static int s2500_set_mac_filter(struct net_device *ndev, const u8 *mac)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+ int ret;
+
+ /* Disable slot 0 before programming its address. */
+ ret = oa_tc6_write_register_mms(priv->tc6, OA_TC6_MAC_MMS1,
+ S2500_REG_MAC_ADDRFILTH(0), 0);
+ if (ret)
+ return ret;
+
+ return s2500_write_filter(priv, 0, mac);
+}
+
+static int s2500_mac_ctrl_modify_bits(struct s2500_info *priv,
+ u32 in_bits, bool clr)
+{
+ u32 reg = S2500_REG_MAC_CTRL;
+ u8 mms = OA_TC6_MAC_MMS1;
+ u32 rval = 0;
+ u32 wval = 0;
+ int ret;
+
+ ret = oa_tc6_read_register_mms(priv->tc6, mms, reg, &rval);
+ if (ret)
+ return ret;
+
+ if (clr)
+ wval = rval & ~in_bits;
+ else
+ wval = rval | in_bits;
+ if (rval != wval)
+ ret = oa_tc6_write_register_mms(priv->tc6, mms,
+ reg, wval);
+ return ret;
+}
+
+static int s2500_init(struct s2500_info *priv)
+{
+ u32 val;
+ int ret;
+
+ /* Configure MAC-PHY's behavior */
+ ret = oa_tc6_tx_credit_threshold_set(priv->tc6,
+ OA_TC6_CONFIG0_TXCTHRESH_8);
+ if (ret)
+ return ret;
+
+ /* Program the source MAC address into the device */
+ ret = s2500_set_mac_filter(priv->ndev, priv->ndev->dev_addr);
+ if (ret)
+ return ret;
+
+ val = S2500_MAC_CTRL_ADRF | S2500_MAC_CTRL_FCSA;
+
+ return s2500_mac_ctrl_modify_bits(priv, val, false);
+}
+
+static void s2500_shutdown(struct s2500_info *priv)
+{
+ u32 val = S2500_MAC_CTRL_TXEN | S2500_MAC_CTRL_RXEN;
+ struct net_device *ndev = priv->ndev;
+
+ netif_stop_queue(ndev);
+ phy_stop(ndev->phydev);
+
+ s2500_mac_ctrl_modify_bits(priv, val, true);
+}
+
+static int s2500_set_promiscuous_mode(struct s2500_info *priv,
+ unsigned int rx_flags)
+{
+ u32 val = S2500_MAC_CTRL_ADRF;
+ bool clr = false;
+
+ if (rx_flags & IFF_PROMISC)
+ clr = true;
+ return s2500_mac_ctrl_modify_bits(priv, val, clr);
+}
+
+static int s2500_clear_mcast_filters(struct s2500_info *priv)
+{
+ int i, ret;
+
+ for (i = 1; i <= S2500_N_MCAST_FILTERS; i++) {
+ ret = oa_tc6_write_register_mms(priv->tc6, OA_TC6_MAC_MMS1,
+ S2500_REG_MAC_ADDRFILTH(i), 0);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int s2500_set_multicast_mode(struct s2500_info *priv,
+ unsigned int rx_flags,
+ struct netdev_hw_addr_list *mc)
+{
+ struct netdev_hw_addr *ha;
+ u8 mms = OA_TC6_MAC_MMS1;
+ int i, ret = 0;
+ int mc_count;
+ u16 addr;
+ u32 val;
+
+ mc_count = netdev_hw_addr_list_count(mc);
+
+ if ((rx_flags & (IFF_PROMISC | IFF_ALLMULTI)) ||
+ mc_count > S2500_N_MCAST_FILTERS) {
+ /* Disable multicast filter */
+ ret = s2500_mac_ctrl_modify_bits(priv,
+ S2500_MAC_CTRL_MCSF,
+ true);
+ if (ret)
+ return ret;
+
+ /* Accept all multicasts */
+ addr = S2500_REG_MAC_ADDRMASKL(1);
+ ret = oa_tc6_write_register_mms(priv->tc6, mms,
+ addr, 0);
+ if (ret)
+ return ret;
+
+ addr = S2500_REG_MAC_ADDRMASKH(1);
+ ret = oa_tc6_write_register_mms(priv->tc6, mms,
+ addr, S2500_ADDR_IG_BIT);
+ if (ret)
+ return ret;
+
+ addr = S2500_REG_MAC_ADDRFILTL(1);
+ ret = oa_tc6_write_register_mms(priv->tc6, mms,
+ addr, 0);
+ if (ret)
+ return ret;
+
+ val = S2500_MAC_ADDRFILT_ENABLE | S2500_ADDR_IG_BIT;
+ addr = S2500_REG_MAC_ADDRFILTH(1);
+ ret = oa_tc6_write_register_mms(priv->tc6, mms,
+ addr, val);
+ } else if (mc_count == 0) {
+ /* Enable multicast filter */
+ ret = s2500_mac_ctrl_modify_bits(priv,
+ S2500_MAC_CTRL_MCSF,
+ false);
+ if (ret)
+ return ret;
+
+ /* Disable filters */
+ ret = s2500_clear_mcast_filters(priv);
+ } else {
+ /* Disable multicast filter */
+ ret = s2500_mac_ctrl_modify_bits(priv,
+ S2500_MAC_CTRL_MCSF,
+ true);
+ if (ret)
+ return ret;
+
+ /* Disable filters */
+ ret = s2500_clear_mcast_filters(priv);
+ if (ret)
+ return ret;
+
+ /* Slot 0 holds the unicast MAC, multicast starts at 1 */
+ i = 1;
+ netdev_hw_addr_list_for_each(ha, mc) {
+ ret = s2500_write_filter(priv, i++, ha->addr);
+ if (ret)
+ return ret;
+ }
+ }
+ return ret;
+}
+
+static int s2500_set_rx_mode(struct net_device *ndev,
+ struct netdev_hw_addr_list *uc,
+ struct netdev_hw_addr_list *mc)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+ int ret;
+
+ ret = s2500_set_promiscuous_mode(priv, ndev->flags);
+ if (ret)
+ return ret;
+
+ return s2500_set_multicast_mode(priv, ndev->flags, mc);
+}
+
+static int s2500_set_mac_address(struct net_device *ndev, void *p)
+{
+ struct sockaddr *addr = p;
+ int ret;
+
+ ret = eth_prepare_mac_addr_change(ndev, p);
+ if (ret)
+ return ret;
+
+ ret = s2500_set_mac_filter(ndev, addr->sa_data);
+ if (ret)
+ return ret;
+
+ eth_commit_mac_addr_change(ndev, p);
+ return 0;
+}
+
+static netdev_tx_t s2500_start_xmit(struct sk_buff *skb,
+ struct net_device *ndev)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+
+ return oa_tc6_start_xmit(priv->tc6, skb);
+}
+
+static void s2500_stats_work(struct work_struct *work)
+{
+ struct s2500_info *priv = container_of(to_delayed_work(work),
+ struct s2500_info, stats_work);
+
+ s2500_update_stats(priv, NULL);
+ schedule_delayed_work(&priv->stats_work, S2500_STATS_WORK_PERIOD);
+}
+
+static int s2500_open(struct net_device *ndev)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+ u32 val;
+ int ret;
+
+ phy_start(priv->ndev->phydev);
+
+ val = S2500_MAC_CTRL_TXEN | S2500_MAC_CTRL_RXEN;
+ ret = s2500_mac_ctrl_modify_bits(priv, val, false);
+ if (!ret) {
+ netif_start_queue(priv->ndev);
+ schedule_delayed_work(&priv->stats_work,
+ S2500_STATS_WORK_PERIOD);
+ } else {
+ phy_stop(priv->ndev->phydev);
+ }
+ return ret;
+}
+
+static int s2500_stop(struct net_device *ndev)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+
+ cancel_delayed_work_sync(&priv->stats_work);
+ s2500_shutdown(priv);
+ return 0;
+}
+
+static int s2500_hwtstamp_get(struct net_device *ndev,
+ struct kernel_hwtstamp_config *k_cfg)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+
+ oa_tc6_hwtstamp_get(priv->tc6, k_cfg);
+ return 0;
+}
+
+static int s2500_hwtstamp_set(struct net_device *ndev,
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
+{
+ struct s2500_info *priv = netdev_priv(ndev);
+
+ return oa_tc6_hwtstamp_set(priv->tc6, cfg);
+}
+
+static const struct net_device_ops s2500_netdev_ops = {
+ .ndo_open = s2500_open,
+ .ndo_stop = s2500_stop,
+ .ndo_start_xmit = s2500_start_xmit,
+ .ndo_set_mac_address = s2500_set_mac_address,
+ .ndo_set_rx_mode_async = s2500_set_rx_mode,
+ .ndo_get_stats64 = s2500_get_stats64,
+ .ndo_eth_ioctl = phy_do_ioctl_running,
+ .ndo_hwtstamp_get = s2500_hwtstamp_get,
+ .ndo_hwtstamp_set = s2500_hwtstamp_set,
+};
+
+static int s2500_probe(struct spi_device *spi)
+{
+ struct oa_tc6_quirks tc6_quirks = {
+ .quirk_flags = OA_TC6_CONFIG_RX_CUT_THROUGH,
+ .vend1_mms = S2500_VS_MMS12,
+ };
+ struct device *dev = &spi->dev;
+ struct net_device *ndev;
+ struct s2500_info *priv;
+ int ret;
+
+ if (!spi->irq)
+ return dev_err_probe(dev, -ENODEV, "Missing interrupt\n");
+
+ ndev = devm_alloc_etherdev(dev, sizeof(struct s2500_info));
+ if (!ndev)
+ return -ENOMEM;
+
+ priv = netdev_priv(ndev);
+ priv->ndev = ndev;
+ priv->spi = spi;
+ priv->dev = dev;
+
+ SET_NETDEV_DEV(ndev, dev);
+
+ mutex_init(&priv->ptp_adj_lock);
+ spin_lock_init(&priv->stats_lock);
+ INIT_DELAYED_WORK(&priv->stats_work, s2500_stats_work);
+ ndev->irq = spi->irq;
+
+ /* Ensures that the first read is not from the cache. */
+ priv->stats_last_update = jiffies - S2500_STATS_CACHE_PERIOD;
+
+ spi_set_drvdata(spi, priv);
+
+ ndev->netdev_ops = &s2500_netdev_ops;
+ ndev->ethtool_ops = &s2500_ethtool_ops;
+ ndev->if_port = IF_PORT_10BASET;
+ ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
+
+ priv->tc6 = oa_tc6_init(spi, ndev, &tc6_quirks);
+ if (IS_ERR(priv->tc6))
+ return dev_err_probe(dev, PTR_ERR(priv->tc6),
+ "OA TC6 init failed\n");
+
+ ret = device_get_ethdev_address(priv->dev, ndev);
+ if (ret)
+ ret = s2500_read_mac_from_nvmem(priv);
+
+ if (ret) {
+ eth_hw_addr_random(ndev);
+ dev_warn(&spi->dev, "Using random MAC address %pM\n",
+ ndev->dev_addr);
+ }
+
+ ret = s2500_init(priv);
+ if (ret) {
+ dev_err_probe(dev, ret, "Failed to initialize device\n");
+ goto err_tc6_exit;
+ }
+
+ /* Configure PTP as S2500 supports it */
+ ret = s2500_ptp_register(priv);
+ if (ret)
+ goto err_tc6_exit;
+
+ ret = register_netdev(ndev);
+ if (ret) {
+ dev_err_probe(dev, ret, "Failed to register netdev\n");
+ oa_tc6_ptp_unregister(priv->tc6);
+ goto err_tc6_exit;
+ }
+
+ return 0;
+
+err_tc6_exit:
+ oa_tc6_exit(priv->tc6);
+ return ret;
+}
+
+static void s2500_remove(struct spi_device *spi)
+{
+ struct s2500_info *priv = spi_get_drvdata(spi);
+
+ unregister_netdev(priv->ndev);
+ oa_tc6_ptp_unregister(priv->tc6);
+ oa_tc6_exit(priv->tc6);
+}
+
+static const struct of_device_id s2500_of_match[] = {
+ { .compatible = "onnn,s2500" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, s2500_of_match);
+
+static const struct spi_device_id s2500_ids[] = {
+ { "s2500" },
+ { }
+};
+MODULE_DEVICE_TABLE(spi, s2500_ids);
+
+static struct spi_driver s2500_driver = {
+ .driver = {
+ .name = DRV_NAME,
+ .of_match_table = s2500_of_match,
+ },
+ .probe = s2500_probe,
+ .remove = s2500_remove,
+ .id_table = s2500_ids,
+};
+module_spi_driver(s2500_driver);
+
+MODULE_AUTHOR("Selvamani Rajagopal <selvamani.rajagopal@onsemi.com>");
+MODULE_AUTHOR("Piergiorgio Beruto");
+MODULE_DESCRIPTION("onsemi MACPHY ethernet driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/onsemi/s2500/s2500_ptp.c b/drivers/net/ethernet/onsemi/s2500/s2500_ptp.c
new file mode 100644
index 000000000000..595067a97ae5
--- /dev/null
+++ b/drivers/net/ethernet/onsemi/s2500/s2500_ptp.c
@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2026 Semiconductor Components Industries, LLC ("onsemi").
+ * onsemi's S2500 10BASE-T1S MAC-PHY driver
+ */
+
+#include "s2500_hw_def.h"
+
+static int s2500_ptp_get_time64(struct ptp_clock_info *ptp,
+ struct timespec64 *ts,
+ struct ptp_system_timestamp *ptp_sts)
+{
+ struct s2500_info *priv = container_of(ptp, struct s2500_info,
+ ptp_clock_info);
+ u32 data[2];
+ u32 addr;
+ int ret;
+
+ ptp_read_system_prets(ptp_sts);
+ addr = FIELD_PREP(S2500_REG_MMS_MASK, S2500_VS_MMS12) |
+ S2500_REG_VS_PTP_SEC;
+ ret = oa_tc6_read_registers(priv->tc6, addr, &data[0], 2);
+ ptp_read_system_postts(ptp_sts);
+
+ if (!ret) {
+ ts->tv_sec = data[0];
+ ts->tv_nsec = data[1];
+ }
+
+ return ret;
+}
+
+static int s2500_ptp_write_time(struct s2500_info *priv,
+ const struct timespec64 *ts)
+{
+ u32 data[2];
+ u32 addr;
+
+ lockdep_assert_held(&priv->ptp_adj_lock);
+
+ if (ts->tv_sec >= (1ULL << 32))
+ return -ERANGE;
+
+ data[0] = (u32)ts->tv_sec;
+ /* bit 31 = execute set command */
+ data[1] = ts->tv_nsec | BIT(31);
+ addr = FIELD_PREP(S2500_REG_MMS_MASK, S2500_VS_MMS12) |
+ S2500_REG_VS_PTP_SETSEC;
+
+ return oa_tc6_write_registers(priv->tc6, addr, &data[0], 2);
+}
+
+static int s2500_ptp_set_time64(struct ptp_clock_info *ptp,
+ const struct timespec64 *ts)
+{
+ struct s2500_info *priv = container_of(ptp, struct s2500_info,
+ ptp_clock_info);
+ int ret;
+
+ mutex_lock(&priv->ptp_adj_lock);
+ ret = s2500_ptp_write_time(priv, ts);
+ mutex_unlock(&priv->ptp_adj_lock);
+
+ return ret;
+}
+
+static int s2500_ptp_set_freq(struct s2500_info *priv, long scaled_ppm)
+{
+ u32 sign_bit = 0;
+ u64 adj;
+ u32 val;
+
+ if (diff_by_scaled_ppm(S2500_PTP_ADJ_BASE, scaled_ppm, &adj))
+ sign_bit = 1U << 31;
+
+ /* check overflow */
+ if (adj > S2500_PTP_ADJ_MAX)
+ return -ERANGE;
+
+ val = (u32)adj | sign_bit;
+ return oa_tc6_write_register_mms(priv->tc6, S2500_VS_MMS12,
+ S2500_REG_VS_PTP_ADJ, val);
+}
+
+static int s2500_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
+{
+ struct s2500_info *priv = container_of(ptp, struct s2500_info,
+ ptp_clock_info);
+
+ return s2500_ptp_set_freq(priv, scaled_ppm);
+}
+
+static int s2500_ptp_step_time(struct s2500_info *priv, s64 delta)
+{
+ struct timespec64 target, now, delta_ts;
+ ktime_t start;
+ s64 elapsed;
+ int ret;
+
+ start = ktime_get_raw();
+ ret = s2500_ptp_get_time64(&priv->ptp_clock_info, &now, NULL);
+ if (ret)
+ return ret;
+ if (delta >= 0) {
+ delta_ts = ns_to_timespec64(delta);
+ target = timespec64_add(now, delta_ts);
+ } else {
+ delta_ts = ns_to_timespec64(-delta);
+ target = timespec64_sub(now, delta_ts);
+ }
+
+ /* Adjust the time to take the SPI transaction time into
+ * account.
+ */
+ elapsed = ktime_to_ns(ktime_sub(ktime_get_raw(), start));
+ timespec64_add_ns(&target, elapsed);
+
+ /* The subtraction above can take the target below the epoch */
+ if (target.tv_sec < 0)
+ return -ERANGE;
+ return s2500_ptp_write_time(priv, &target);
+}
+
+static int s2500_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
+{
+ struct s2500_info *priv = container_of(ptp, struct s2500_info,
+ ptp_clock_info);
+ int ret;
+
+ /* Nothing to do */
+ if (delta == 0)
+ return 0;
+
+ /* The device has no add-delta register, so the offset is applied as
+ * a read-modify-write of the time registers.
+ */
+ mutex_lock(&priv->ptp_adj_lock);
+ ret = s2500_ptp_step_time(priv, delta);
+ mutex_unlock(&priv->ptp_adj_lock);
+
+ return ret;
+}
+
+int s2500_ptp_register(struct s2500_info *priv)
+{
+ struct ptp_clock_info *info = &priv->ptp_clock_info;
+
+ info->max_adj = S2500_PTP_MAX_ADJ_PPB;
+ info->owner = THIS_MODULE;
+ info->adjfine = s2500_ptp_adjfine;
+ info->gettimex64 = s2500_ptp_get_time64;
+ info->settime64 = s2500_ptp_set_time64;
+ info->adjtime = s2500_ptp_adjtime;
+
+ return oa_tc6_ptp_register(priv->tc6, info);
+}
--
2.43.0
Re: [PATCH net-next v12 15/15] net: ethernet: onsemi: s2500: Add driver support for S2500
Author: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 00:36
Date: Sun, 29 Nov 2026 00:36
212 lines
15662 bytes
15662 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] s2500_update_stats() decides whether its 100 ms cache is stale
with `!time_is_after_jiffies(priv->stats_last_update +…
- [Medium] s2500_set_mac_filter() first writes
`S2500_REG_MAC_ADDRFILTH(0) = 0`, which disables the unicast filter…
- [Low] The commit message says `imply NET_SELFTESTS` was added in
drivers/net/ethernet/onsemi/s2500/Kconfig "so that users would be able…
- [Low] In s2500_update_stats(), priv->stats_last_update is read with a
plain load before spin_lock_bh(&priv->stats_lock) is taken, at the…
--
net: ethernet: onsemi: s2500: Add driver support for S2500
This commit adds a new SPI driver for the onsemi S2500 10BASE-T1S MAC-PHY,
built on the OPEN Alliance TC6 framework. It provides a PTP clock, ethtool
MAC/PHY/RMON statistics with a 100 ms cache, register dumps, three
multicast filter slots, and self-test support.
> diff --git a/drivers/net/ethernet/onsemi/s2500/Kconfig b/drivers/net/ethernet/onsemi/s2500/Kconfig
> new file mode 100644
> index 0000000000000..4bd28dc560e64
> --- /dev/null
> +++ b/drivers/net/ethernet/onsemi/s2500/Kconfig
> @@ -0,0 +1,20 @@
[ ... ]
> +config S2500_MACPHY
> + tristate "S2500 support"
> + depends on SPI
> + depends on PTP_1588_CLOCK_OPTIONAL
> + imply NET_SELFTESTS
[Severity: Low]
The commit message says:
Support self-test. Also Add imply NET_SELFTESTS in Kconfig
so that users would be able to disable self-test and still
compile.
Is that accurate? In net/Kconfig, NET_SELFTESTS has no prompt:
config NET_SELFTESTS
def_tristate PHYLIB
depends on PHYLIB && INET
S2500_MACPHY selects OA_TC6, and OA_TC6 selects PHYLIB. So whenever INET
is enabled, NET_SELFTESTS follows PHYLIB whether or not this imply is
there. A user can't switch it off.
The driver does build with NET_SELFTESTS=n, because include/net/selftests.h
provides stubs and s2500_get_sset_count() checks IS_ENABLED(). That
configuration only happens with INET=n, though.
Could the imply line be dropped, or the commit message reworded?
> + select BITREVERSE
> + select NCN26000_PHY
> + select OA_TC6
[ ... ]
> diff --git a/drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c b/drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c
> new file mode 100644
> index 0000000000000..77d7d172efe0d
> --- /dev/null
> +++ b/drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c
> @@ -0,0 +1,389 @@
[ ... ]
> +void s2500_update_stats(struct s2500_info *priv, u64 *buf)
> +{
> + u32 regs[S2500_NUM_STAT_REGS];
> + bool have_regs = false;
> + u32 addr;
> +
> + if (!time_is_after_jiffies(priv->stats_last_update +
> + S2500_STATS_CACHE_PERIOD)) {
[Severity: Medium]
What happens if nothing calls s2500_update_stats() for more than LONG_MAX
jiffies?
stats_last_update is only refreshed after a successful register read.
While the interface is down, s2500_stop() has cancelled s2500_stats_work,
and only s2500_open() schedules it again. In that state ethtool stats
queries are the only callers.
On a 32-bit kernel with HZ=1000, about 24.8 days without a query is
enough for the signed difference in time_is_after_jiffies() to flip.
The stale timestamp then looks like it is in the future, and every later
call skips the hardware read. That includes the 3 s stats work once the
interface is back up. A skipped read never updates stats_last_update, so
this lasts for another 2^31 jiffies.
During that time rx_otherhost_dropped and the eth-mac, eth-phy and RMON
counters stay frozen. The 32-bit clear-on-read hardware counters can also
wrap in that window, so counts are lost.
Would a 64-bit timestamp checked with time_after64() avoid this? Resetting
stats_last_update in s2500_open() is another option.
> + addr = FIELD_PREP(S2500_REG_MMS_MASK, OA_TC6_MAC_MMS1) |
> + S2500_REG_MAC_STOCTETSTXL;
> + have_regs = !oa_tc6_read_registers(priv->tc6, addr, regs,
> + S2500_NUM_STAT_REGS);
> + }
> +
> + if (!have_regs && !buf)
> + return;
> +
> + spin_lock_bh(&priv->stats_lock);
> + if (have_regs) {
> + priv->stats_last_update = jiffies;
[Severity: Low]
stats_last_update is written here under stats_lock, and struct
s2500_info says the lock protects it:
/* Protects stats_data and stats_last_update. */
spinlock_t stats_lock;
The freshness check above reads it without the lock, though. Can
s2500_stats_work and an ethtool stats callback (s2500_get_eth_mac_stats(),
s2500_get_eth_phy_stats() or s2500_rmon_stats()) both see a stale
timestamp? If so, both would issue the clear-on-read register burst.
The totals still come out right. However, the caller whose read returns
an almost empty delta may copy stats_data before the other caller has
added the delta it already took from the hardware. That caller would
get a snapshot that is briefly too low. KCSAN would also report this
race.
Could the check move under the lock? Another way would be to serialize
the read and the accumulate with a mutex.
> + s2500_accumulate_stats(priv, regs);
> + }
[ ... ]
> diff --git a/drivers/net/ethernet/onsemi/s2500/s2500_main.c b/drivers/net/ethernet/onsemi/s2500/s2500_main.c
> new file mode 100644
> index 0000000000000..55dbf3ba032d9
> --- /dev/null
> +++ b/drivers/net/ethernet/onsemi/s2500/s2500_main.c
> @@ -0,0 +1,496 @@
[ ... ]
> +static int s2500_set_mac_filter(struct net_device *ndev, const u8 *mac)
> +{
> + struct s2500_info *priv = netdev_priv(ndev);
> + int ret;
> +
> + /* Disable slot 0 before programming its address. */
> + ret = oa_tc6_write_register_mms(priv->tc6, OA_TC6_MAC_MMS1,
> + S2500_REG_MAC_ADDRFILTH(0), 0);
> + if (ret)
> + return ret;
> +
> + return s2500_write_filter(priv, 0, mac);
> +}
[Severity: Medium]
What state is slot 0 left in if one of the four control writes in
s2500_write_filter() fails?
At that point the slot has already been disabled here. s2500_write_filter()
returns early, before the final ADDRFILTH write that sets
S2500_MAC_ADDRFILT_ENABLE. oa_tc6_perform_ctrl() can return SPI transfer
errors, or -EPROTO from the echo check.
s2500_set_mac_address() then bails out before committing the new address:
ret = s2500_set_mac_filter(ndev, addr->sa_data);
if (ret)
return ret;
eth_commit_mac_addr_change(ndev, p);
So dev_addr keeps the old address, but the hardware has no enabled unicast
filter. S2500_MAC_CTRL_ADRF is only cleared for IFF_PROMISC, so it stays
set. Would the MAC then drop every unicast frame sent to the host?
Nothing appears to restore slot 0 later:
- s2500_init() only runs at probe.
- s2500_open() only sets TXEN/RXEN.
- s2500_set_multicast_mode() and s2500_clear_mcast_filters() only touch
slots 1..S2500_N_MCAST_FILTERS.
Should the previous filter be restored on failure? Alternatively, the
writes could be ordered so that a failure can't leave slot 0 disabled.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124-s2500-mac-phy-support-v12-0-3575855d99f9%40onsemi.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads