Skip to contentSkip to conversation

net: dsa: yt921x: Add support for Motorcomm YT921x

PATCH Superseded David Yang 2 participants 5 messages Oct 14, 2025 – Oct 16, 2025

Subsystems (5)

v13 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

David Yang

author maintainer
#0 lore raw

v13 cover net: dsa: yt921x: Add support for Motorcomm YT921x

Motorcomm YT921x is a series of ethernet switches developed by Shanghai Motorcomm Electronic Technology, including:

- YT9215S / YT9215RB / YT9215SC: 5 GbE phys
- YT9213NB / YT9214NB: 2 GbE phys
- YT9218N / YT9218MB: 8 GbE phys

and up to 2 serdes interfaces.

This patch adds basic support for a working DSA switch.

v12: https://lore.kernel.org/r/[email protected]
- do not introduce PHY_INTERFACE_MODE_REVSGMII for the moment
v11: https://lore.kernel.org/r/[email protected]
- make MIB_DESC cleaner
- use disable_delayed_work at teardown
v10: https://lore.kernel.org/r/[email protected]
- fix warnings related to PHY_INTERFACE_MODE_REVSGMII
v9: https://lore.kernel.org/r/[email protected]
- add PHY_INTERFACE_MODE_REVSGMII
- remove mdio_verify()
- remove uncessary fdb flush opeartions
- rework mib reading
- set port pvid by port_set_pvid()
v8: https://lore.kernel.org/r/[email protected]
- rework register polling
- rework mib reading
- other suggested code style changes
v7: https://lore.kernel.org/r/[email protected]
- simplify locking scheme
v6: https://lore.kernel.org/r/[email protected]
- handle unforwarded packets in tag driver
- move register and struct definitions to header file
- rework register abstraction and implement a driver lock
- implement *_stats and use a periodic work to fetch MIB
- remove EEPROM dump
- remove sysfs attr and other debug leftovers
- remove ds->user_mii_bus assignment
- run selftests and fix any errors found
v5: https://lore.kernel.org/r/[email protected]
- use enum for reg in dt binding
- fix phylink_mac_ops in the driver
- fix coding style
v4: https://lore.kernel.org/r/[email protected]
- remove switchid from dt binding
- remove hsr from tag driver
- use ratelimited log in tag driver
v3: https://lore.kernel.org/r/[email protected]
- fix words and warnings in dt binding
- remove unnecessary dev_warn_ratelimited and u64_from_u32
- remove lag and mst
- check for mdio results and fix a unlocked write in conduit_state_change
v2: https://lore.kernel.org/r/[email protected]
- fix words in dt binding
- add support for lag and mst
v1: https://lore.kernel.org/r/[email protected]
- fix coding style
- add dt binding
- add support for fdb, vlan and bridge

David Yang (3):
dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
net: dsa: tag_yt921x: add support for Motorcomm YT921x tags
net: dsa: yt921x: Add support for Motorcomm YT921x

 .../bindings/net/dsa/motorcomm,yt921x.yaml    |  167 +
 drivers/net/dsa/Kconfig                       |    7 +
 drivers/net/dsa/Makefile                      |    1 +
 drivers/net/dsa/yt921x.c                      | 2898 +++++++++++++++++
 drivers/net/dsa/yt921x.h                      |  504 +++
 include/net/dsa.h                             |    2 +
 include/uapi/linux/if_ether.h                 |    1 +
 net/dsa/Kconfig                               |    6 +
 net/dsa/Makefile                              |    1 +
 net/dsa/tag_yt921x.c                          |  141 +
 10 files changed, 3728 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
 create mode 100644 drivers/net/dsa/yt921x.c
 create mode 100644 drivers/net/dsa/yt921x.h
 create mode 100644 net/dsa/tag_yt921x.c
Signature · 1 line
2.51.0
author maintainer
#1 lore raw

PATCH v13 1/3 dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support

The Motorcomm YT921x series is a family of Ethernet switches with up to 8 internal GbE PHYs and up to 2 GMACs.

---
 .../bindings/net/dsa/motorcomm,yt921x.yaml    | 167 ++++++++++++++++++
 1 file changed, 167 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +167 -0
new file mode 100644
index 000000000000..33a6552e46fc
@@ -0,0 +1,167 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/dsa/motorcomm,yt921x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Motorcomm YT921x Ethernet switch family
+
+maintainers:
+  - David Yang <[email protected]>
+
+description: |
+  The Motorcomm YT921x series is a family of Ethernet switches with up to 8
+  internal GbE PHYs and up to 2 GMACs, including:
+
+    - YT9215S / YT9215RB / YT9215SC: 5 GbE PHYs (Port 0-4) + 2 GMACs (Port 8-9)
+    - YT9213NB: 2 GbE PHYs (Port 1/3) + 1 GMAC (Port 9)
+    - YT9214NB: 2 GbE PHYs (Port 1/3) + 2 GMACs (Port 8-9)
+    - YT9218N: 8 GbE PHYs (Port 0-7)
+    - YT9218MB: 8 GbE PHYs (Port 0-7) + 2 GMACs (Port 8-9)
+
+  Any port can be used as the CPU port.
+
+properties:
+  compatible:
+    const: motorcomm,yt9215
+
+  reg:
+    enum: [0x0, 0x1d]
+
+  reset-gpios:
+    maxItems: 1
+
+  mdio:
+    $ref: /schemas/net/mdio.yaml#
+    unevaluatedProperties: false
+    description:
+      Internal MDIO bus for the internal GbE PHYs. PHY 0-7 are used for Port
+      0-7 respectively.
+
+  mdio-external:
+    $ref: /schemas/net/mdio.yaml#
+    unevaluatedProperties: false
+    description:
+      External MDIO bus to access external components. External PHYs for GMACs
+      (Port 8-9) are expected to be connected to the external MDIO bus in
+      vendor's reference design, but that is not a hard limitation from the
+      chip.
+
+required:
+  - compatible
+  - reg
+
+allOf:
+  - $ref: dsa.yaml#/$defs/ethernet-ports
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        switch@1d {
+            compatible = "motorcomm,yt9215";
+            /* default 0x1d, alternate 0x0 */
+            reg = <0x1d>;
+            reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
+
+            mdio {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                sw_phy0: phy@0 {
+                    reg = <0x0>;
+                };
+
+                sw_phy1: phy@1 {
+                    reg = <0x1>;
+                };
+
+                sw_phy2: phy@2 {
+                    reg = <0x2>;
+                };
+
+                sw_phy3: phy@3 {
+                    reg = <0x3>;
+                };
+
+                sw_phy4: phy@4 {
+                    reg = <0x4>;
+                };
+            };
+
+            mdio-external {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                phy1: phy@b {
+                    reg = <0xb>;
+                };
+            };
+
+            ethernet-ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                ethernet-port@0 {
+                    reg = <0>;
+                    label = "lan1";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy0>;
+                };
+
+                ethernet-port@1 {
+                    reg = <1>;
+                    label = "lan2";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy1>;
+                };
+
+                ethernet-port@2 {
+                    reg = <2>;
+                    label = "lan3";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy2>;
+                };
+
+                ethernet-port@3 {
+                    reg = <3>;
+                    label = "lan4";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy3>;
+                };
+
+                ethernet-port@4 {
+                    reg = <4>;
+                    label = "lan5";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy4>;
+                };
+
+                /* CPU port */
+                ethernet-port@8 {
+                    reg = <8>;
+                    phy-mode = "2500base-x";
+                    ethernet = <&eth0>;
+
+                    fixed-link {
+                        speed = <2500>;
+                        full-duplex;
+                    };
+                };
+
+                /* if external phy is connected to a MAC */
+                ethernet-port@9 {
+                    reg = <9>;
+                    label = "wan";
+                    phy-mode = "rgmii-id";
+                    phy-handle = <&phy1>;
+                };
+            };
+        };
+    };
Signature · 1 line
2.51.0
author maintainer
#2 lore raw

PATCH v13 2/3 net: dsa: tag_yt921x: add support for Motorcomm YT921x tags

In reply to David Yang

Add support for Motorcomm YT921x tags, which includes a proper configurable ethertype field (default to 0x9988).

---
 include/net/dsa.h             |   2 +
 include/uapi/linux/if_ether.h |   1 +
 net/dsa/Kconfig               |   6 ++
 net/dsa/Makefile              |   1 +
 net/dsa/tag_yt921x.c          | 141 ++++++++++++++++++++++++++++++++++
 5 files changed, 151 insertions(+)
 create mode 100644 net/dsa/tag_yt921x.c
include/net/dsa.h +2 -0
index d73ea0880066..67762fdaf3c7 100644
@@ -55,6 +55,7 @@ struct tc_action;
 #define DSA_TAG_PROTO_LAN937X_VALUE		27
 #define DSA_TAG_PROTO_VSC73XX_8021Q_VALUE	28
 #define DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE	29
+#define DSA_TAG_PROTO_YT921X_VALUE		30
 
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE		= DSA_TAG_PROTO_NONE_VALUE,
@@ -87,6 +88,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_RZN1_A5PSW	= DSA_TAG_PROTO_RZN1_A5PSW_VALUE,
 	DSA_TAG_PROTO_LAN937X		= DSA_TAG_PROTO_LAN937X_VALUE,
 	DSA_TAG_PROTO_VSC73XX_8021Q	= DSA_TAG_PROTO_VSC73XX_8021Q_VALUE,
+	DSA_TAG_PROTO_YT921X		= DSA_TAG_PROTO_YT921X_VALUE,
 };
 
 struct dsa_switch;
include/uapi/linux/if_ether.h +1 -0
index 69e0457eb200..cfd200c87e5e 100644
@@ -114,6 +114,7 @@
 #define ETH_P_QINQ1	0x9100		/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_QINQ2	0x9200		/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_QINQ3	0x9300		/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
+#define ETH_P_YT921X	0x9988		/* Motorcomm YT921x DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_EDSA	0xDADA		/* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_DSA_8021Q	0xDADB		/* Fake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_DSA_A5PSW	0xE001		/* A5PSW Tag Value [ NOT AN OFFICIALLY REGISTERED ID ] */
net/dsa/Kconfig +6 -0
index 869cbe57162f..6b94028b1fcc 100644
@@ -190,4 +190,10 @@ config NET_DSA_TAG_XRS700X
 	  Say Y or M if you want to enable support for tagging frames for
 	  Arrow SpeedChips XRS700x switches that use a single byte tag trailer.
 
+config NET_DSA_TAG_YT921X
+	tristate "Tag driver for Motorcomm YT921x switches"
+	help
+	  Say Y or M if you want to enable support for tagging frames for
+	  Motorcomm YT921x switches.
+
 endif
net/dsa/Makefile +1 -0
index 555c07cfeb71..4b011a1d5c87 100644
@@ -39,6 +39,7 @@ obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o
 obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
 obj-$(CONFIG_NET_DSA_TAG_VSC73XX_8021Q) += tag_vsc73xx_8021q.o
 obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o
+obj-$(CONFIG_NET_DSA_TAG_YT921X) += tag_yt921x.o
 
 # for tracing framework to find trace.h
 CFLAGS_trace.o := -I$(src)
net/dsa/tag_yt921x.c new file +141 -0

141 lines not on this page · raw message

Signature · 1 line
2.51.0
author maintainer
#3 lore raw

PATCH v13 3/3 net: dsa: yt921x: Add support for Motorcomm YT921x

In reply to David Yang

Motorcomm YT921x is a series of ethernet switches developed by Shanghai Motorcomm Electronic Technology, including:

- YT9215S / YT9215RB / YT9215SC: 5 GbE PHYs
- YT9213NB / YT9214NB: 2 GbE PHYs
- YT9218N / YT9218MB: 8 GbE PHYs

and up to 2 GMACs.

Driver verified on a stock wireless router with IPQ5018 + YT9215S.

---
 drivers/net/dsa/Kconfig  |    7 +
 drivers/net/dsa/Makefile |    1 +
 drivers/net/dsa/yt921x.c | 2898 ++++++++++++++++++++++++++++++++++++++
 drivers/net/dsa/yt921x.h |  504 +++++++
 4 files changed, 3410 insertions(+)
 create mode 100644 drivers/net/dsa/yt921x.c
 create mode 100644 drivers/net/dsa/yt921x.h
drivers/net/dsa/Kconfig +7 -0
index 4d9af691b989..7eb301fd987d 100644
@@ -154,4 +154,11 @@ config NET_DSA_VITESSE_VSC73XX_PLATFORM
 	  This enables support for the Vitesse VSC7385, VSC7388, VSC7395
 	  and VSC7398 SparX integrated ethernet switches, connected over
 	  a CPU-attached address bus and work in memory-mapped I/O mode.
+
+config NET_DSA_YT921X
+	tristate "Motorcomm YT9215 ethernet switch chip support"
+	select NET_DSA_TAG_YT921X
+	help
+	  This enables support for the Motorcomm YT9215 ethernet switch
+	  chip.
 endmenu
drivers/net/dsa/Makefile +1 -0
index 0f8ff4a1a313..16de4ba3fa38 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_NET_DSA_SMSC_LAN9303_MDIO) += lan9303_mdio.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx-core.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_PLATFORM) += vitesse-vsc73xx-platform.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_SPI) += vitesse-vsc73xx-spi.o
+obj-$(CONFIG_NET_DSA_YT921X) += yt921x.o
 obj-y				+= b53/
 obj-y				+= hirschmann/
 obj-y				+= lantiq/
drivers/net/dsa/yt921x.c new file +2898 -0

2,898 lines not on this page · raw message

drivers/net/dsa/yt921x.h new file +504 -0

84 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.51.0

Part of the diff is not shown here. View the raw message.

maintainer
#4 lore raw
Quoted 7 lines · On Tue, 14 Oct 2025 11:35:47 +0800 David Yang wrote:

Motorcomm YT921x is a series of ethernet switches developed by Shanghai Motorcomm Electronic Technology, including:

 drivers/net/dsa/Kconfig  |    7 +
 drivers/net/dsa/Makefile |    1 +
 drivers/net/dsa/yt921x.c | 2898 ++++++++++++++++++++++++++++++++++++++
 drivers/net/dsa/yt921x.h |  504 +++++++

We need a MAINTAINERS entry covering the new driver. See also:
https://docs.kernel.org/next/maintainer/feature-and-driver-maintainers.html
And:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#supported-status-for-drivers

drivers/net/dsa/yt921x.c line 723

Quoted 12 lines
drivers/net/dsa/yt921x.c new file +12 -0
+
+	pp->rx_frames = mib->rx_64byte + mib->rx_65_127byte +
+			mib->rx_128_255byte + mib->rx_256_511byte +
+			mib->rx_512_1023byte + mib->rx_1024_1518byte +
+			mib->rx_jumbo;
+	pp->tx_frames = mib->tx_64byte + mib->tx_65_127byte +
+			mib->tx_128_255byte + mib->tx_256_511byte +
+			mib->tx_512_1023byte + mib->tx_1024_1518byte +
+			mib->tx_jumbo;
+
+	/* Flush all writes */
+	smp_wmb();

Barriers don't flush anything, they order visibility of writes. You don't have a matching smp_rmb() AFAICT so this looks unnecessary.

drivers/net/dsa/yt921x.c line 1077

Quoted 3 lines
drivers/net/dsa/yt921x.c new file +3 -0
+	/* other mirror tasks & different dst port -> conflict */
+	if ((val & ~srcs & (YT921X_MIRROR_EGR_PORTS_M |
+			    YT921X_MIRROR_IGR_PORTS_M)) != 0 &&

nit: you can delete the != 0

drivers/net/dsa/yt921x.c line 1081

Quoted 4 lines
drivers/net/dsa/yt921x.c new file +4 -0
+	    (val & YT921X_MIRROR_PORT_M) != dst) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "Sniffer port is already configured, "
+				   "delete existing rules & retry");

please don't wrap strings, it's okay to go over 80 chars Makes it easier to find them by grepping if they are not broken up

Signature · 1 line
pw-bot: cr