net: dsa: motorcomm: add support yt922x driver
Subsystems (5)
v18 cover net: dsa: motorcomm: add support yt922x driver
changes in v18:
This series adds yt9224 driver support and includes several fixes and cleanups for the yt92xx driver.
Patch 1 updates the commit message, improves the chip lookup series failure logging to print the failure reason instead of a potentially stale chip id, aligns the data types of ageing_time_max/ageing_time_min with dsa_switch, and removes the YT92XX_MODE_YT922X definition (to be re-added when the yt922x driver is introduced).
Patch 2 updates the commit message and adds max_port check logic.
Patch 3 updates the commit message.
Patch 4 adds the yt9224 driver dts.
Patch 5 improves the format comments for the YT9224 tag.
Patch 6 improves the commit message, adds BX100 handling, and adds some code comments.
changes in v17:
1) Rebase.
changes in v16:
1) Add missing break in switch case to prevent fall-through in yt922x_port_config()
changes in v15:
1) Revert the use of GENMASK_U16() to replace GENMASK(), so as to facilitate adaptation to scenarios with more ports in the future.
2) Group functions with the same functionality together in mdio_bus.c.
3) Remove meaningless code comments.
4) Renaming parameters in yt922x_pcs_get_state().
5) Add neg_mode and advertising handle.
changes in v14:
1) Replace the goto-based skip_extmode_check path with an early conditional in yt921x_chip_detect().
changes in v13:
1) Fix a compilation error in patch1 only.
The change is limited to the yt92xx_register_switch function:
- Replace yt921x_priv with dsa_to_yt921x_priv
- Replace to_device with yt921x_priv_to_device
changes in v12:
1) Rebase the code.
2) Delete origin patch4 and patch5 about MIB init and remove operation.
3) Optimize error message logging.
4) Add documents about yt922x tag.
changes in v11:
1) Initialize ctrl variable inside yt922x_port_up().
2) Update maitainer for new file.
changes in v10:
1) Rebase the code.
changes in v9:
patch 1: 1) Add a dev_err() when chipid mismatch.
patch 3: 1) Using GENMASK_U* to replace GENMASK
changes in v8:
patch 1: 1) Add a lock operation to acquire the chip ID during the probe()
stage.
2) Remove meaningless changes.
patch 3: Modify the changelog description.
patch 6: 1) Remove sds_init() in this patch.
2) Code refactoring, including yt922x_sds_phyaddr_get() and yt921x_needs_extmode_check()
3) In yt921x_intif_ext_write() and yt921x_intif_ext_read(), add a boundary check for phyaddr. The reason is that the phyaddr of the top ext register is 9, so max_ports should be used for the check to include it.
4) In the yt922x driver, added initialization of yt921x_port for exporting priv.
changes in v7:
patch 1: Fix the series_lookup() redundancy issue.
Fix the dsa->priv initialization and the code style issue.
patch 6: Move psc definition to yt921x_port
Fix psc_get_state() and an_restart().
Use the existing yt921x driver interface for the duplicated logic for chip_reset().
Move the yt922x_cpu_port_set() to chip_setup_dsa() to align with yt921x function.
Kyle Switch (6):
net: dsa: motorcomm: initialize dsa_switch based on chipid
net: dsa: motorcomm: use max_ports in series for port bounds checking
net: dsa: motorcomm: use GENMASK_U32() for mbus phy_mask
dt-bindings: net: dsa: add Motorcomm YT9224
net: dsa: tag_yt922x: add support for Motorcomm YT922x tags
net: dsa: motorcomm: Add support for Motorcomm YT922x
.../bindings/net/dsa/motorcomm,yt9224.yaml | 142 +++++ MAINTAINERS | 5 +- drivers/net/dsa/motorcomm/Kconfig | 7 +- drivers/net/dsa/motorcomm/Makefile | 1 + drivers/net/dsa/motorcomm/chip.c | 586 +++++++++++++++++- drivers/net/dsa/motorcomm/chip.h | 103 +++ drivers/net/dsa/motorcomm/mdio_bus.c | 51 +- drivers/net/dsa/motorcomm/mdio_bus.h | 4 + drivers/net/dsa/motorcomm/pcs-922x.c | 300 +++++++++ drivers/net/dsa/motorcomm/pcs.h | 1 + include/net/dsa.h | 2 + net/dsa/Kconfig | 6 + net/dsa/Makefile | 1 + net/dsa/tag_yt922x.c | 133 ++++ 14 files changed, 1325 insertions(+), 17 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt9224.yaml create mode 100644 drivers/net/dsa/motorcomm/pcs-922x.c create mode 100644 net/dsa/tag_yt922x.c
Signature · 1 line
2.25.1
PATCH v18 1/6 net: dsa: motorcomm: initialize dsa_switch based on chipid
Replace the hardcoded dsa_switch configuration in yt921x_mdio_probe() with a data-driven lookup by the chip ID and Major. This is a preparation step for supporting additional chips in the YT92xx family.
Introduce struct yt92xx_series to describe per-chip properties (max_ports, num_lag_ids, ageing_time_min/max, dscp_prio_mapping_is_global, assisted_learning_on_cpu_port, switch_ops and mac_ops), and populate a yt92xx_series_table[] indexed by enum yt92xx_mode. yt92xx_register_switch() reads YT921X_CHIP_ID, extracts the major revision, looks up the matching series and fills in ds->ops, ds->phylink_mac_ops and the remaining dsa_switch fields from it.
The table currently contains a single YT921x entry covering the YT9215 and YT9218 majors, so behaviour is unchanged. Store the matched series in yt921x_priv for later use.
--- drivers/net/dsa/motorcomm/chip.c | 74 ++++++++++++++++++++++++++++---- drivers/net/dsa/motorcomm/chip.h | 19 ++++++++ 2 files changed, 85 insertions(+), 8 deletions(-)
drivers/net/dsa/motorcomm/chip.c +66 -8
@@ -2699,6 +2699,68 @@ static const struct dsa_switch_ops yt921x_dsa_switch_ops = { .setup = yt921x_dsa_setup, }; +static const struct yt92xx_series yt92xx_series_table[] = { + [YT92XX_MODE_YT921X ] = { + .name ="YT921x" , + .max_ports =YT921X_PORT_NUM , + .num_lag_ids =YT921X_LAG_NUM , + .ageing_time_min =1U *YT921X_AGEING_TIME_UNIT , + .ageing_time_max =U16_MAX *YT921X_AGEING_TIME_UNIT , + .dscp_prio_mapping_is_global = true, + .assisted_learning_on_cpu_port = true, + .switch_ops = &yt921x_dsa_switch_ops, + .mac_ops = &yt921x_phylink_mac_ops + }, +}; + +static const struct yt92xx_series *yt92xx_series_lookup (u32 major) +{ +if (major ==YT9215_MAJOR || major ==YT9218_MAJOR ) +return &yt92xx_series_table[YT92XX_MODE_YT921X ]; +else +return NULL ; +} + +static int yt92xx_register_switch (struct dsa_switch *ds) +{ +struct yt921x_priv *priv =dsa_to_yt921x_priv (ds); +struct device *dev =yt921x_priv_to_device (priv); +const struct yt92xx_series *series; +u32 chipid; +u32 major; +int res; + +mutex_lock (&priv->reg_lock); + res =yt921x_reg_read (priv,YT921X_CHIP_ID , &chipid); +mutex_unlock (&priv->reg_lock); +if (res) { +dev_err (dev,"Failed to read Chip ID with errcode: %d\n" , res); +return res; + } + + major =FIELD_GET (YT921X_CHIP_ID_MAJOR , chipid); + series =yt92xx_series_lookup (major); +if (!series) { +dev_err (dev,"Unknown Chip ID: 0x%x, or unknown Major: 0x%x\n" , + chipid, major); +return -ENODEV ; + } + priv->series = series; + + ds->assisted_learning_on_cpu_port = + priv->series->assisted_learning_on_cpu_port; + ds->dscp_prio_mapping_is_global = + priv->series->dscp_prio_mapping_is_global; + ds->ageing_time_min = priv->series->ageing_time_min; + ds->ageing_time_max = priv->series->ageing_time_max; + ds->num_lag_ids = priv->series->num_lag_ids; + ds->num_ports = priv->series->max_ports; + ds->ops = priv->series->switch_ops; + ds->phylink_mac_ops = priv->series->mac_ops; + +return 0 ; +} +static void yt921x_mdio_shutdown (struct mdio_device *mdiodev) {struct yt921x_priv *priv =mdiodev_get_drvdata (mdiodev);
@@ -2741,6 +2803,7 @@ static int yt921x_mdio_probe(struct mdio_device *mdiodev)struct yt921x_reg_mdio *mdio;struct yt921x_priv *priv;struct dsa_switch *ds; +int res; priv =devm_kzalloc_obj (dev, *priv);if (!priv)
@@ -2767,15 +2830,10 @@ static int yt921x_mdio_probe(struct mdio_device *mdiodev) ds = &priv->ds; ds->dev = dev; - ds->assisted_learning_on_cpu_port = true; - ds->dscp_prio_mapping_is_global = true; ds->priv = priv; - ds->ops = &yt921x_dsa_switch_ops; - ds->ageing_time_min =1 *5000 ; - ds->ageing_time_max =U16_MAX *5000 ; - ds->phylink_mac_ops = &yt921x_phylink_mac_ops; - ds->num_lag_ids =YT921X_LAG_NUM ; - ds->num_ports =YT921X_PORT_NUM ; + res =yt92xx_register_switch (ds); +if (res) +return res;mdiodev_set_drvdata (mdiodev, priv);
drivers/net/dsa/motorcomm/chip.h +19 -0
@@ -18,6 +18,7 @@#define YT921X_SMI_READ YT921X_SMI_RW#define YT921X_SWITCHID_NUM 4 +#define YT921X_AGEING_TIME_UNIT 5000U#define YT921X_RST 0x80000#define YT921X_RST_HW BIT(31)
@@ -503,9 +504,27 @@ static inline u16 yt921x_info_ports_mask(const struct yt921x_info *info)return info->internal_mask | info->xmii_mask | info->serdes_mask; } +enum yt92xx_mode { +YT92XX_MODE_YT921X , +YT92XX_MODE_MAX , +}; + +struct yt92xx_series { +const char *name; +unsigned int max_ports; +unsigned int num_lag_ids; +u32 ageing_time_min; +u32 ageing_time_max; +u32 dscp_prio_mapping_is_global; +u32 assisted_learning_on_cpu_port; +const struct dsa_switch_ops *switch_ops; +const struct phylink_mac_ops *mac_ops; +}; +struct yt921x_priv {struct dsa_switch ds; +const struct yt92xx_series *series;const struct yt921x_info *info;unsigned int meter_slot_ns;unsigned int port_shape_slot_ns;
Signature · 1 line
2.25.1
PATCH v18 2/6 net: dsa: motorcomm: use max_ports in series for port bounds checking
In reply to Kyle SwitchReplace the hardcoded YT921X_PORT_NUM macro with the per-series max_ports field in port validation and in the internal mii_bus phy_mask setup. This removes family-specific constants from the common code path and simplifies adding new switch families with different port counts.
Validate max_ports against the size of priv->ports (and the u32 width of phy_mask) before using it in GENMASK().
No functional change for existing YT921X devices, as their max_ports equals YT921X_PORT_NUM.
--- drivers/net/dsa/motorcomm/mdio_bus.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/dsa/motorcomm/mdio_bus.c +9 -3
@@ -113,7 +113,7 @@ static int yt921x_mbus_int_read(struct mii_bus *mbus, int port, int reg)u16 val;int res; -if (port >=YT921X_PORT_NUM ) +if (port >= priv->series->max_ports)return U16_MAX ;mutex_lock (&priv->reg_lock);
@@ -131,7 +131,7 @@ yt921x_mbus_int_write(struct mii_bus *mbus, int port, int reg, u16 data)struct yt921x_priv *priv = mbus->priv;int res; -if (port >=YT921X_PORT_NUM ) +if (port >= priv->series->max_ports)return -ENODEV ;mutex_lock (&priv->reg_lock);
@@ -155,6 +155,7 @@ int yt921x_mbus_int_init(struct yt921x_priv *priv, struct device_node *mnp) {struct device *dev =yt921x_priv_to_device (priv);struct mii_bus *mbus; +u32 max_ports;int res; mbus =mdiobus_alloc ();
@@ -167,7 +168,12 @@ int yt921x_mbus_int_init(struct yt921x_priv *priv, struct device_node *mnp) mbus->read = yt921x_mbus_int_read; mbus->write = yt921x_mbus_int_write; mbus->parent = dev; - mbus->phy_mask = (u32 )~GENMASK (YT921X_PORT_NUM -1 ,0 ); + max_ports = priv->series->max_ports; +if (max_ports ==0 || max_ports >ARRAY_SIZE (priv->ports)) { +dev_err (dev,"Invalid max_ports: %u\n" , max_ports); +return -EINVAL ; + } + mbus->phy_mask = (u32 )~GENMASK (max_ports -1 ,0 ); res =of_mdiobus_register (mbus, mnp);if (res) {
Signature · 1 line
2.25.1
PATCH v18 3/6 net: dsa: motorcomm: use GENMASK_U32() for mbus phy_mask
In reply to Kyle Switchmbus->phy_mask is a u32, but the mask was built with GENMASK(), which has type unsigned long, requiring an explicit (u32) cast to avoid a truncation warning.
Use GENMASK_U32() instead, which yields a u32 and makes the intended 32-bit width explicit. The cast can then be dropped. GENMASK_U32() also lets the compiler reject out-of-range masks at build time.
No functional change.
--- drivers/net/dsa/motorcomm/mdio_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/motorcomm/mdio_bus.c +1 -1
@@ -173,7 +173,7 @@ int yt921x_mbus_int_init(struct yt921x_priv *priv, struct device_node *mnp)dev_err (dev,"Invalid max_ports: %u\n" , max_ports);return -EINVAL ; } - mbus->phy_mask = (u32 )~GENMASK (max_ports -1 ,0 ); + mbus->phy_mask = ~GENMASK_U32 (max_ports -1 ,0 ); res =of_mdiobus_register (mbus, mnp);if (res) {
Signature · 1 line
2.25.1
PATCH v18 4/6 dt-bindings: net: dsa: add Motorcomm YT9224
In reply to Kyle SwitchAdd a device tree binding for the Motorcomm YT9224, a member of the YT922x Ethernet switch family. It has 4 internal GbE PHYs on ports 4-7 and 2 SerDes ports on ports 0 and 8. Any port can be used as the CPU port.
The YT9224 port layout differs from the YT921x family described by motorcomm,yt921x.yaml (internal PHYs on ports 0-7, SerDes on 8-9), so give it its own binding instead of extending the existing one. This also avoids the dt_binding_check failure caused by yt921x.yaml declaring compatible as a const for motorcomm,yt9215.
Also add the new binding file to the Motorcomm YT921x switch driver MAINTAINERS entry so that it is covered by get_maintainer.pl.
--- .../bindings/net/dsa/motorcomm,yt9224.yaml | 142 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 143 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt9224.yaml
Documentation/devicetree/bindings/net/dsa/motorcomm,yt9224.yaml new file +142 -0
@@ -0,0 +1,142 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/motorcomm,yt9224.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Motorcomm YT9224 Ethernet switch + +maintainers: + - Kyle Switch <[email protected]> + +description: | + The Motorcomm YT9224 is a member of the YT922x Ethernet switch family, + with 4 internal GbE PHYs (Port 4-7) and 2 SerDes ports (Port 0 and 8). + + Any port can be used as the CPU port. + +properties: + compatible: + const: motorcomm,yt9224 + + reg: + enum: [0x0, 0x1d] + + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: + Internal MDIO bus for the internal GbE PHYs. PHY 4-7 are used for + Port 4-7 respectively. + + mdio-external: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: + External MDIO bus to access external components. External PHYs for + the SerDes ports (Port 0 and 8) are expected to be connected to the + external MDIO bus, 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> + #include <dt-bindings/leds/common.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + switch@1d { + compatible = "motorcomm,yt9224"; + /* default 0x1d, alternate 0x0 */ + reg = <0x1d>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + sw_phy4: phy@4 { + reg = <0x4>; + }; + + sw_phy5: phy@5 { + reg = <0x5>; + }; + + sw_phy6: phy@6 { + reg = <0x6>; + }; + + sw_phy7: phy@7 { + reg = <0x7>; + }; + }; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + /* SerDes port 0 */ + ethernet-port@0 { + reg = <0>; + label = "wan"; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + }; + }; + + /* Internal PHY ports 4-7 */ + ethernet-port@4 { + reg = <4>; + label = "lan1"; + phy-mode = "internal"; + phy-handle = <&sw_phy4>; + }; + + ethernet-port@5 { + reg = <5>; + label = "lan2"; + phy-mode = "internal"; + phy-handle = <&sw_phy5>; + }; + + ethernet-port@6 { + reg = <6>; + label = "lan3"; + phy-mode = "internal"; + phy-handle = <&sw_phy6>; + }; + + ethernet-port@7 { + reg = <7>; + label = "lan4"; + phy-mode = "internal"; + phy-handle = <&sw_phy7>; + }; + + /* SerDes port 8, CPU port */ + ethernet-port@8 { + reg = <8>; + phy-mode = "usxgmii"; + ethernet = <ð0>; + + fixed-link { + speed = <5000>; + full-duplex; + }; + }; + }; + }; + };
MAINTAINERS +1 -0
@@ -18937,6 +18937,7 @@ M: David Yang <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml +F: Documentation/devicetree/bindings/net/dsa/motorcomm,yt9224.yaml F: Documentation/networking/devlink/yt921x.rst F: drivers/net/dsa/motorcomm/ F: net/dsa/tag_yt921x.c
Signature · 1 line
2.25.1
Re: [PATCH net-next v18 4/6] dt-bindings: net: dsa: add Motorcomm YT9224
Quoted 14 lines · Kyle Switch
Add a device tree binding for the Motorcomm YT9224, a member of the YT922x Ethernet switch family. It has 4 internal GbE PHYs on ports 4-7 and 2 SerDes ports on ports 0 and 8. Any port can be used as the CPU port.
The YT9224 port layout differs from the YT921x family described by motorcomm,yt921x.yaml (internal PHYs on ports 0-7, SerDes on 8-9), so give it its own binding instead of extending the existing one. This also avoids the
dt_binding_checkfailure caused byyt921x.yamldeclaring compatible as a const for motorcomm,yt9215.Also add the new binding file to the Motorcomm YT921x switch driver
MAINTAINERSentry so that it is covered by get_maintainer.pl.
Quoted 7 lines
Signed-off-by Kyle Switch <[email protected]>--- .../bindings/net/dsa/motorcomm,yt9224.yaml | 142 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 143 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt9224.yaml
PATCH v18 5/6 net: dsa: tag_yt922x: add support for Motorcomm YT922x tags
In reply to Kyle SwitchAdd DSA tag support for Motorcomm YT922x switches. YT922x uses the same ETH_P_YT921X EtherType and the same 8-byte tag length as YT921x, but the tag layout differs, so a separate tag driver is needed instead of extending tag_yt921x.c.
The new driver documents both the to-CPU and from-CPU tag layouts.
Update the co-maintainer for the Motorcomm DSA driver.
--- MAINTAINERS | 2 + include/net/dsa.h | 2 + net/dsa/Kconfig | 6 ++ net/dsa/Makefile | 1 + net/dsa/tag_yt922x.c | 133 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 144 insertions(+) create mode 100644 net/dsa/tag_yt922x.c
MAINTAINERS +2 -0
@@ -18934,6 +18934,7 @@ F: drivers/net/phy/motorcomm.c MOTORCOMM YT921X ETHERNET SWITCH DRIVER M: David Yang <[email protected]> +M: Kyle Switch <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
@@ -18941,6 +18942,7 @@ F: Documentation/devicetree/bindings/net/dsa/motorcomm,yt9224.yaml F: Documentation/networking/devlink/yt921x.rst F: drivers/net/dsa/motorcomm/ F: net/dsa/tag_yt921x.c +F: net/dsa/tag_yt922x.c MOXA SMARTIO/INDUSTIO SERIAL CARD M: Jiri Slaby <[email protected]>
include/net/dsa.h +2 -0
@@ -63,6 +63,7 @@ struct tc_action;#define DSA_TAG_PROTO_MT7628_VALUE 35#define DSA_TAG_PROTO_KS8995_VALUE 36#define DSA_TAG_PROTO_LAN9645X_VALUE 37 +#define DSA_TAG_PROTO_YT922X_VALUE 38enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,
@@ -103,6 +104,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_MT7628 =DSA_TAG_PROTO_MT7628_VALUE ,DSA_TAG_PROTO_KS8995 =DSA_TAG_PROTO_KS8995_VALUE ,DSA_TAG_PROTO_LAN9645X =DSA_TAG_PROTO_LAN9645X_VALUE , + DSA_TAG_PROTO_YT922X = DSA_TAG_PROTO_YT922X_VALUE, };struct dsa_switch ;
net/dsa/Kconfig +6 -0
@@ -244,4 +244,10 @@ config NET_DSA_TAG_YT921X Say Y or M if you want to enable support for tagging frames for Motorcomm YT921x switches. +config NET_DSA_TAG_YT922X + tristate "Tag driver for Motorcomm YT922x switches" + help + Say Y or M if you want to enable support for tagging frames for + Motorcomm YT922x switches. + endif
net/dsa/Makefile +1 -0
@@ -46,6 +46,7 @@ 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 +obj-$(CONFIG_NET_DSA_TAG_YT922X) += tag_yt922x.o # for tracing framework to find trace.h CFLAGS_trace.o := -I$(src)
net/dsa/tag_yt922x.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v18 6/6 net: dsa: motorcomm: Add support for Motorcomm YT922x
In reply to Kyle SwitchAdd support for the Motorcomm YT922x family of Ethernet switches, which includes the YT9224 and YT9228. This patch only adds support for the YT9224; YT9228 is not supported yet.
This adds basic support for a working DSA switch, including .port_setup, .setup, .phylink_get_caps and .get_tag_protocol. Alongside the YT9224-specific additions, this touches shared yt921x code, so the blast radius on the existing YT921x path is called out below.
New functionality:
- Add four dsa_switch_ops for the YT9224.
- Implement a full phylink_mac_ops set (mac_config, mac_link_up, mac_link_down, mac_select_pcs).
- Add a new PCS driver in pcs-922x.c supporting SGMII, 1000BASE-X, 2500BASE-X and USXGMII.
- Add two MDIO helpers, yt921x_intif_ext_read() and yt921x_intif_ext_write().
Shared code changes (also used by the YT921x path):
- Add YT921X_SPEED_5000 to the yt921x_speed enum and a SPEED_5000 case in ethtool_speed_to_yt921x().
- Add an early return for YT9224 in yt921x_chip_detect(), skipping the CHIP_MODE, EXTMODE.
--- MAINTAINERS | 2 +- drivers/net/dsa/motorcomm/Kconfig | 7 +- drivers/net/dsa/motorcomm/Makefile | 1 + drivers/net/dsa/motorcomm/chip.c | 512 ++++++++++++++++++++++++++- drivers/net/dsa/motorcomm/chip.h | 84 +++++ drivers/net/dsa/motorcomm/mdio_bus.c | 39 ++ drivers/net/dsa/motorcomm/mdio_bus.h | 4 + drivers/net/dsa/motorcomm/pcs-922x.c | 300 ++++++++++++++++ drivers/net/dsa/motorcomm/pcs.h | 1 + 9 files changed, 944 insertions(+), 6 deletions(-) create mode 100644 drivers/net/dsa/motorcomm/pcs-922x.c
MAINTAINERS +1 -1
@@ -18932,7 +18932,7 @@ S: Maintained F: Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml F: drivers/net/phy/motorcomm.c -MOTORCOMM YT921X ETHERNET SWITCH DRIVER +MOTORCOMM YT921X AND YT922X ETHERNET SWITCH DRIVER M: David Yang <[email protected]> M: Kyle Switch <[email protected]> L: [email protected]
drivers/net/dsa/motorcomm/Kconfig +4 -3
@@ -1,11 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-only config NET_DSA_YT921X - tristate "Motorcomm YT9215 ethernet switch chip support" + tristate "Motorcomm YT9215 and YT9224 ethernet switch chip support" select NET_DSA_TAG_YT921X + select NET_DSA_TAG_YT922X select NET_IEEE8021Q_HELPERS if DCB help - This enables support for the Motorcomm YT9215 ethernet switch - chip. + This enables support for the Motorcomm YT9215 and YT9224 + ethernet switch chip. config NET_DSA_YT921X_LEDS bool "LED support for Motorcomm YT9215"
drivers/net/dsa/motorcomm/Makefile +1 -0
@@ -5,6 +5,7 @@ yt921x-$(CONFIG_NET_DSA_YT921X_LEDS) += leds.o yt921x-objs += devlink.o yt921x-objs += mdio_bus.o yt921x-objs += mib.o +yt921x-objs += pcs-922x.o yt921x-objs += pcs-921x.o yt921x-objs += smi.o yt921x-objs += tc.o
drivers/net/dsa/motorcomm/chip.c +510 -2
563 lines not on this page · raw message
drivers/net/dsa/motorcomm/chip.h +84 -0
114 lines not on this page · raw message
drivers/net/dsa/motorcomm/mdio_bus.c +39 -0
@@ -107,6 +107,45 @@ yt921x_intif_modify_changed(struct yt921x_priv *priv, int port, int reg,return 1 ; } +/* intif extend register read/write api */ +int +yt921x_intif_ext_write (struct yt921x_priv *priv,int port,int reg,u16 val) +{ +int res; + +if (port >= priv->series->max_ports) +return -ENODEV ; + + res =yt921x_intif_write (priv, port,YT92XX_PAGE_SELECT , reg); +if (res) +return res; + + res =yt921x_intif_write (priv, port,YT92XX_PAGE , val); +if (res) +return res; + +return 0 ; +} + +int +yt921x_intif_ext_read (struct yt921x_priv *priv,int port,int reg,u16 *valp) +{ +int res; + +if (port >= priv->series->max_ports) +return -ENODEV ; + + res =yt921x_intif_write (priv, port,YT92XX_PAGE_SELECT , reg); +if (res) +return res; + + res =yt921x_intif_read (priv, port,YT92XX_PAGE , valp); +if (res) +return res; + +return 0 ; +} +static int yt921x_mbus_int_read (struct mii_bus *mbus,int port,int reg) {struct yt921x_priv *priv = mbus->priv;
drivers/net/dsa/motorcomm/mdio_bus.h +4 -0
@@ -35,6 +35,10 @@ struct yt921x_priv;int yt921x_intif_read (struct yt921x_priv *priv,int port,int reg,u16 *valp);int yt921x_intif_write (struct yt921x_priv *priv,int port,int reg,u16 val); +int yt921x_intif_ext_write (struct yt921x_priv *priv,int port,int reg, +u16 val); +int yt921x_intif_ext_read (struct yt921x_priv *priv,int port,int reg, +u16 *valp);int yt921x_intif_modify_changed (struct yt921x_priv *priv,int port,int reg,u16 mask,u16 val);
drivers/net/dsa/motorcomm/pcs-922x.c new file +300 -0
300 lines not on this page · raw message
drivers/net/dsa/motorcomm/pcs.h +1 -0
@@ -9,5 +9,6 @@#include <linux/phylink.h> extern const struct phylink_pcs_ops yt921x_phylink_pcs_ops; +extern const struct phylink_pcs_ops yt922x_phylink_pcs_ops;#endif
Signature · 1 line
2.25.1