Skip to contentSkip to conversation

net: dsa: yt921x: Add support for Motorcomm YT921x

PATCH Superseded David Yang 4 participants 10 messages Aug 16, 2025

Subsystems (5)

v3 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

David Yang

author maintainer
#0 lore raw

v3 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.

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    |  166 +
 drivers/net/dsa/Kconfig                       |    7 +
 drivers/net/dsa/Makefile                      |    1 +
 drivers/net/dsa/yt921x.c                      | 3960 +++++++++++++++++
 include/net/dsa.h                             |    2 +
 net/dsa/Kconfig                               |    6 +
 net/dsa/Makefile                              |    1 +
 net/dsa/tag_yt921x.c                          |  126 +
 8 files changed, 4269 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
 create mode 100644 drivers/net/dsa/yt921x.c
 create mode 100644 net/dsa/tag_yt921x.c
Signature · 1 line
2.47.2
author maintainer
#1 lore raw

PATCH v3 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    | 166 ++++++++++++++++++
 1 file changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +166 -0
new file mode 100644
index 000000000000..d93fa24e0943
@@ -0,0 +1,166 @@
+# 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:
+    maxItems: 1
+
+  reset-gpios:
+    maxItems: 1
+
+  motorcomm,switch-id:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      When managed via MDIO, a hard-configured switch ID to form MDIO reg addrs,
+      to distinguish between multiple devices beside phyaddr.
+    enum: [0, 1, 2, 3]
+    default: 0
+    maxItems: 1
+
+  mdio:
+    $ref: /schemas/net/mdio.yaml#
+    unevaluatedProperties: false
+    description: |
+      Internal MDIO bus for the internal GbE PHYs. PHYs 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.
+
+allOf:
+  - $ref: dsa.yaml#/$defs/ethernet-ports
+
+required:
+  - compatible
+  - reg
+
+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>;
+            motorcomm,switch-id = <0>;
+            reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
+
+            mdio {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                sw_phy0: phy@0 {
+                    reg = <0x0>;
+                };
+            };
+
+            mdio-external {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                phy1: phy@b {
+                    reg = <0xb>;
+                };
+            };
+
+            ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                /* phy-handle is optional for internal PHYs */
+                port@0 {
+                    reg = <0>;
+                    label = "lan1";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy0>;
+                };
+
+                port@1 {
+                    reg = <1>;
+                    label = "lan2";
+                    phy-mode = "internal";
+                };
+
+                port@2 {
+                    reg = <2>;
+                    label = "lan3";
+                    phy-mode = "internal";
+                };
+
+                port@3 {
+                    reg = <3>;
+                    label = "lan4";
+                    phy-mode = "internal";
+                };
+
+                port@4 {
+                    reg = <4>;
+                    label = "lan5";
+                    phy-mode = "internal";
+                };
+
+                /* CPU port */
+                port@8 {
+                    reg = <8>;
+                    phy-mode = "sgmii";
+                    ethernet = <&eth0>;
+
+                    fixed-link {
+                        speed = <1000>;
+                        full-duplex;
+                        pause;
+                        asym-pause;
+                    };
+                };
+
+                /* if external phy is connected to a MAC */
+                port@9 {
+                    reg = <9>;
+                    label = "wan";
+                    phy-mode = "rgmii";
+                    phy-handle = <&phy1>;
+
+                    fixed-link {
+                        speed = <1000>;
+                        full-duplex;
+                        pause;
+                    };
+                };
+            };
+        };
+    };
Signature · 1 line
2.47.2
#2 lore raw

Re: [net-next v3 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support

Quoted 9 lines · David Yang

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    | 166 ++++++++++++++++++
 1 file changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml: properties:motorcomm,switch-id: 'enum' should not be valid under {'enum': ['const', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'minimum', 'maximum', 'multipleOf', 'pattern']}
hint: Scalar and array keywords cannot be mixed
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml: properties:motorcomm,switch-id:maxItems: False schema does not allow 1
hint: Scalar properties should not have array keywords
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#3 lore raw

Re: [net-next v3 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support

In reply to David Yang
Quoted 6 lines · David Yang

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    | 166 ++++++++++++++++++

Previous version was not tested. This is not tested, either.

You must test your code BEFORE you send it, not after.

Best regards,
Krzysztof

maintainer
#4 lore raw

Re: [net-next v3 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support

In reply to David Yang

Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 41

Quoted 8 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +8 -0
+  motorcomm,switch-id:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      When managed via MDIO, a hard-configured switch ID to form MDIO reg addrs,
+      to distinguish between multiple devices beside phyaddr.
+    enum: [0, 1, 2, 3]
+    default: 0
+    maxItems: 1

So how is this different to reg? Why cannot it be derived from reg? Please give us all the details of what this actually does. Or point us to a chapter in the datasheet.

Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 162

Quoted 12 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +12 -0
+                /* if external phy is connected to a MAC */
+                port@9 {
+                    reg = <9>;
+                    label = "wan";
+                    phy-mode = "rgmii";
+                    phy-handle = <&phy1>;
+
+                    fixed-link {
+                        speed = <1000>;
+                        full-duplex;
+                        pause;
+                    };

If there is an external PHY, why have a fixed link?

Andrew

---
pw-bot: cr

author maintainer
#5 lore raw

PATCH v3 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 +
 net/dsa/Kconfig      |   6 +++
 net/dsa/Makefile     |   1 +
 net/dsa/tag_yt921x.c | 126 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 135 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;
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 +126 -0

126 lines not on this page · raw message

Signature · 1 line
2.47.2
maintainer
#6 lore raw

Re: [net-next v3 2/3] net: dsa: tag_yt921x: add support for Motorcomm YT921x tags

Quoted 16 lines
net/dsa/tag_yt921x.c new file +16 -0
+static struct sk_buff *
+yt921x_tag_rcv(struct sk_buff *skb, struct net_device *netdev)
+{
+	unsigned int port;
+	__be16 *tag;
+	u16 rx;
+
+	if (unlikely(!pskb_may_pull(skb, YT921X_TAG_LEN)))
+		return NULL;
+
+	tag = (__be16 *)skb->data;
+
+	/* Locate which port this is coming from */
+	rx = ntohs(tag[1]);
+	if (unlikely((rx & YT921X_TAG_PORT_EN) == 0)) {
+		netdev_err(netdev, "Unexpected rx tag 0x%04x\n", rx);

net/dsa/tag_yt921x.c line 102

Quoted 10 lines
net/dsa/tag_yt921x.c new file +10 -0
+		return NULL;
+	}
+
+	port = FIELD_GET(YT921X_TAG_RX_PORT_M, rx);
+	skb->dev = dsa_conduit_find_user(netdev, 0, port);
+	if (unlikely(!skb->dev)) {
+		dev_warn_ratelimited(&netdev->dev,
+				     "Cannot locate rx port %u\n", port);
+		return NULL;
+	}

Why do you rate limit the second, but not the first?

Andrew

author maintainer
#7 lore raw

PATCH v3 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 | 3960 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 3968 insertions(+)
 create mode 100644 drivers/net/dsa/yt921x.c
drivers/net/dsa/Kconfig +7 -0
index ec759f8cb0e2..1b789daab34c 100644
@@ -152,4 +152,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 cb9a97340e58..dc81769fa92b 100644
@@ -17,6 +17,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				+= microchip/
drivers/net/dsa/yt921x.c new file +3960 -0

2,982 lines not on this page · raw message

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

Signature · 1 line
2.47.2

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

maintainer
#9 lore raw
In reply to David Yang
Quoted 7 lines · 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

Quoted 7 lines

and up to 2 serdes interfaces.

This patch adds basic support for a working DSA switch.

v2: https://lore.kernel.org/r/[email protected]
- fix words in dt binding
- add support for lag and mst

Please don't add new features between revisions. Reviewers spend time reviewing the code. They assume just the issues raised will be address, and the rest of the code remains unchanged. It then means they just need to check the issues raised have been addressed. By adding new features, they back to the beginning, having to review all the code again, because you potentially added new issues.

LAG and MST should of been implemented as patches on top of the basic driver. They can then be reviewed as small increments.

Please put yourself in our position. How would you review this code? That would make it easy for you to review it?

Andrew