net: dsa: mt7628 embedded switch initial support
Subsystems (6)
cover net: dsa: mt7628 embedded switch initial support
Hello,
This patch series adds initial support for the MediaTek MT7628 Embedded Switch.
The driver implements the basic functionality required to operate the switch using DSA. The hardware provides five internal Fast Ethernet user ports and one Gigabit port connected internally to the CPU MAC.
Bridge offloading is not yet supported.
Tested on an MT7628NN-based board.
Changes since RFC v3:
- remove labels from DT binding
- set ds->user_mii_bus if mdio node does not exist
Thanks,
Joris
Joris Vaisvila (4):
dt-bindings: net: dsa: add MT7628 ESW
net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet
PHYs
net: dsa: initial MT7628 tagging driver
net: dsa: initial support for MT7628 embedded switch
.../bindings/net/dsa/mediatek,mt7628-esw.yaml | 101 +++ drivers/net/dsa/Kconfig | 7 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/mt7628.c | 637 ++++++++++++++++++ drivers/net/phy/mediatek/Kconfig | 10 +- drivers/net/phy/mediatek/Makefile | 1 + drivers/net/phy/mediatek/mtk-fe-soc.c | 50 ++ include/net/dsa.h | 2 + net/dsa/Kconfig | 6 + net/dsa/Makefile | 1 + net/dsa/tag_mt7628.c | 92 +++ 11 files changed, 907 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml create mode 100644 drivers/net/dsa/mt7628.c create mode 100644 drivers/net/phy/mediatek/mtk-fe-soc.c create mode 100644 net/dsa/tag_mt7628.c
Signature · 1 line
2.53.0
PATCH 1/4 dt-bindings: net: dsa: add MT7628 ESW
Add bindings for MT7628 SoC's Embedded Switch.
--- .../bindings/net/dsa/mediatek,mt7628-esw.yaml | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml
Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml new file +101 -0
@@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/mediatek,mt7628-esw.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek MT7628 Embedded Ethernet Switch + +maintainers: + - Joris Vaisvila <[email protected]> + +description: + The MT7628 SoC's built-in Ethernet Switch is a five port switch with + integrated 10/100 PHYs. The switch registers are directly mapped in the SoC's + memory. The switch has an internally connected 1G CPU port and 5 user ports + connected to the built-in Fast Ethernet PHYs. + +unevaluatedProperties: false + +allOf: + - $ref: dsa.yaml#/$defs/ethernet-ports + +properties: + compatible: + const: mediatek,mt7628-esw + + reg: + maxItems: 1 + description: MMIO address of the switch + + resets: + items: + - description: Phandle of system reset controller with ESW reset index + - description: Phandle of system reset controller with EPHY reset index + + reset-names: + items: + - const: esw + - const: ephy + + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + +required: + - compatible + - reg + - resets + - reset-names + +examples: + - | + switch0: switch@10110000 { + reg = <0x10110000 0x8000>; + + resets = <&sysc 23>, <&sysc 24>; + reset-names = "esw", "ephy"; + + compatible = "mediatek,mt7628-esw"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + phy-mode = "internal"; + }; + + port@1 { + reg = <1>; + phy-mode = "internal"; + }; + + port@2 { + reg = <2>; + phy-mode = "internal"; + }; + + port@3 { + reg = <3>; + phy-mode = "internal"; + }; + + port@4 { + reg = <4>; + phy-mode = "internal"; + }; + + port@6 { + reg = <6>; + ethernet = <ðernet>; + phy-mode = "rgmii"; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + };
Signature · 1 line
2.53.0
Re: [PATCH net-next 1/4] dt-bindings: net: dsa: add MT7628 ESW
Quoted 20 lines · Joris Vaisvila
Add bindings for MT7628 SoC's Embedded Switch.
[...]Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml new file +12
-0@@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/mediatek,mt7628-esw.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek MT7628 Embedded Ethernet Switch + +maintainers: + - Joris Vaisvila <[email protected]> + +description:
Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml
Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml new file +9
-0+ The MT7628 SoC's built-in Ethernet Switch is a five port switch with + integrated 10/100 PHYs. The switch registers are directly mapped in the SoC's + memory. The switch has an internally connected 1G CPU port and 5 user ports + connected to the built-in Fast Ethernet PHYs. + + port@6 { + reg = <6>; + ethernet = <ðernet>; + phy-mode = "rgmii";
Is this actually RGMII internally? Or some unknown internal way to wire the switch CPU port to the CPU MAC? In this case, "internal" should be used here as well.
Re: [PATCH net-next 1/4] dt-bindings: net: dsa: add MT7628 ESW
Hi Daniel, thanks for the feedback
Quoted 9 lines · Daniel Golle
Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml line 93
Quoted 5 lines
[...]
Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml new file +4
-0+ port@6 { + reg = <6>; + ethernet = <ðernet>; + phy-mode = "rgmii";Is this actually RGMII internally? Or some unknown internal way to wire the switch CPU port to the CPU MAC? In this case, "internal" should be used here as well.
I don't know how to find this out for sure.
In the MT7628 doc (https://vonger.cn/upload/MT7628_Full.pdf) port 6 is refered to as RGMII port 1 (RGMII port 0 being the non-existent port 5), but there are no clock registers to be seen.
In RT3050 docs there are RGMII clock registers for port 5, but nothing for port 6, so maybe the CPU port is really using some mystery internal connection and only uses "RGMII" as a way to say it's a Gigabit port?
On the hardware I'm testing on, it works fine with the port set to "internal" or "rgmii". Would it make more sense to set "internal" then?
Thanks,
Joris
Re: [PATCH net-next 1/4] dt-bindings: net: dsa: add MT7628 ESW
Quoted 22 lines · Joris Vaisvila
Hi Daniel, thanks for the feedback
Quoted 9 lines · Daniel Golle
Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml line 93
Quoted 5 lines
[...]
Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml new file +4
-0+ port@6 { + reg = <6>; + ethernet = <ðernet>; + phy-mode = "rgmii";Is this actually RGMII internally? Or some unknown internal way to wire the switch CPU port to the CPU MAC? In this case, "internal" should be used here as well.
I don't know how to find this out for sure.
In the MT7628 doc (https://vonger.cn/upload/MT7628_Full.pdf) port 6 is refered to as RGMII port 1 (RGMII port 0 being the non-existent port 5), but there are no clock registers to be seen.
In RT3050 docs there are RGMII clock registers for port 5, but nothing for port 6, so maybe the CPU port is really using some mystery internal connection and only uses "RGMII" as a way to say it's a Gigabit port?
Quoted 2 lines
On the hardware I'm testing on, it works fine with the port set to "internal" or "rgmii". Would it make more sense to set "internal" then?
"internal" then. It's a single-die SoC, the switch sharing the same memory space, clocking domain, ... with all the rest of the SoC makes it very unlikely that RGMII would be used as an on-die connection type. (unlike eg. MT7621 or MT7623A which are using multiple dies in the same package, and actually RGMII or TRGMII to connect the MDIO-managed switch part to the main SoC, see "MCM" / "multi-chip module" in the mt7530 driver...)
Re: [PATCH net-next 1/4] dt-bindings: net: dsa: add MT7628 ESW
Quoted 11 lines · Daniel Golle
Quoted 3 lines
[...]
On the hardware I'm testing on, it works fine with the port set to "internal" or "rgmii". Would it make more sense to set "internal" then?"internal" then. It's a single-die SoC, the switch sharing the same memory space, clocking domain, ... with all the rest of the SoC makes it very unlikely that RGMII would be used as an on-die connection type. (unlike eg. MT7621 or MT7623A which are using multiple dies in the same package, and actually RGMII or TRGMII to connect the MDIO-managed switch part to the main SoC, see "MCM" / "multi-chip module" in the mt7530 driver...)
Makes sense, will change CPU port to internal in v2.
Thanks,
Joris
PATCH 2/4 net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet PHYs
In reply to Joris VaisvilaThe Fast Ethernet PHYs present in the MT7628 SoCs require an undocumented bit to be set before they can establish 100mbps links.
This commit adds the Kconfig option MEDIATEK_FE_SOC_PHY and the corresponding driver mtk-fe-soc.c.
--- drivers/net/phy/mediatek/Kconfig | 10 +++++- drivers/net/phy/mediatek/Makefile | 1 + drivers/net/phy/mediatek/mtk-fe-soc.c | 50 +++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 drivers/net/phy/mediatek/mtk-fe-soc.c
drivers/net/phy/mediatek/Kconfig +9 -1
@@ -21,8 +21,16 @@ config MEDIATEK_GE_PHY common operations with MediaTek SoC built-in Gigabit Ethernet PHYs. +config MEDIATEK_FE_SOC_PHY + tristate "MediaTek SoC Fast Ethernet PHYs" + help + Support for MediaTek MT7628 built-in Fast Ethernet PHYs. + This driver only sets an initialization bit required for the PHY + to establish 100 Mbps links. All other PHY operations are handled + by the kernel's generic PHY code. + config MEDIATEK_GE_SOC_PHY - tristate "MediaTek SoC Ethernet PHYs" + tristate "MediaTek SoC Gigabit Ethernet PHYs" depends on ARM64 || COMPILE_TEST depends on ARCH_AIROHA || (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || \ COMPILE_TEST
drivers/net/phy/mediatek/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_MEDIATEK_2P5GE_PHY) += mtk-2p5ge.o +obj-$(CONFIG_MEDIATEK_FE_SOC_PHY) += mtk-fe-soc.o obj-$(CONFIG_MEDIATEK_GE_PHY) += mtk-ge.o obj-$(CONFIG_MEDIATEK_GE_SOC_PHY) += mtk-ge-soc.o obj-$(CONFIG_MTK_NET_PHYLIB) += mtk-phy-lib.o
drivers/net/phy/mediatek/mtk-fe-soc.c new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH net-next 2/4] net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet PHYs
Quoted 7 lines · Joris Vaisvila
The Fast Ethernet PHYs present in the MT7628 SoCs require an undocumented bit to be set before they can establish 100mbps links.
This commit adds the
KconfigoptionMEDIATEK_FE_SOC_PHYand the corresponding drivermtk-fe-soc.c.Signed-off-by Joris Vaisvila <[email protected]>
Andrew
PATCH 3/4 net: dsa: initial MT7628 tagging driver
In reply to Joris VaisvilaAdd support for the MT7628 embedded switch's tag.
The MT7628 tag is merged with the VLAN TPID field when a VLAN is appended by the switch hardware. It is not installed if the VLAN tag is already there on ingress. Due to this hardware quirk the tag cannot be trusted for port 0 if we don't know that the VLAN was added by the hardware. As a workaround for this the switch is configured to always append the port PVID tag even if the incoming packet is already tagged. The tagging driver can then trust that the tag is always accurate and the whole VLAN tag can be removed on ingress as it's only metadata for the tagger.
On egress the MT7628 tag allows precise TX, but the correct VLAN tag from tag_8021q is still appended or the switch will not forward the packet.
--- include/net/dsa.h | 2 + net/dsa/Kconfig | 6 +++ net/dsa/Makefile | 1 + net/dsa/tag_mt7628.c | 92 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 net/dsa/tag_mt7628.c
include/net/dsa.h +2 -0
@@ -58,6 +58,7 @@ struct tc_action;#define DSA_TAG_PROTO_YT921X_VALUE 30#define DSA_TAG_PROTO_MXL_GSW1XX_VALUE 31#define DSA_TAG_PROTO_MXL862_VALUE 32 +#define DSA_TAG_PROTO_MT7628_VALUE 33enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,
@@ -93,6 +94,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_YT921X =DSA_TAG_PROTO_YT921X_VALUE ,DSA_TAG_PROTO_MXL_GSW1XX =DSA_TAG_PROTO_MXL_GSW1XX_VALUE ,DSA_TAG_PROTO_MXL862 =DSA_TAG_PROTO_MXL862_VALUE , + DSA_TAG_PROTO_MT7628 = DSA_TAG_PROTO_MT7628_VALUE, };struct dsa_switch ;
net/dsa/Kconfig +6 -0
@@ -211,4 +211,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_MT7628 + tristate "Tag driver for the MT7628 embedded switch" + help + Say Y or M if you want to enable support for tagging frames for the + switch embedded in the MT7628 SoC. + endif
net/dsa/Makefile +1 -0
@@ -42,6 +42,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_MT7628) += tag_mt7628.o # for tracing framework to find trace.h CFLAGS_trace.o := -I$(src)
net/dsa/tag_mt7628.c new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH net-next 3/4] net: dsa: initial MT7628 tagging driver
net/dsa/tag_mt7628.c line 30
Quoted 10 lines · Joris Vaisvila
Add support for the MT7628 embedded switch's tag.
[...]+++
b/net/dsa/tag_mt7628.c
[...]net/dsa/tag_mt7628.c new file +5
-0+ +#define MT7628_TAG_NAME "mt7628" + +#define MT7628_TAG_TX_PORT_BIT_MASK GENMASK(5, 0) +#define MT7628_TAG_RX_PORT_MASK GENMASK(2, 0)
'MASK' vs. 'BIT_MASK'... Maybe just
#define MT7628_TAG_TX_PORT GENMASK(5, 0)
#define MT7628_TAG_RX_PORT GENMASK(2, 0)
Quoted 27 lines
net/dsa/tag_mt7628.c new file +27
-0+#define MT7628_TAG_LEN 4 + +static struct sk_buff *mt7628_tag_xmit (struct sk_buff *skb, +struct net_device *dev) +{ +struct dsa_port *dp; +u16 xmit_vlan; +__be16 *tag; + + dp =dsa_user_to_port (dev); + xmit_vlan =dsa_tag_8021q_standalone_vid (dp); + +skb_push (skb,MT7628_TAG_LEN ); +dsa_alloc_etype_header (skb,MT7628_TAG_LEN ); + + tag =dsa_etype_header_pos_tx (skb); + + tag[0 ] =htons (ETH_P_8021Q | +FIELD_PREP (MT7628_TAG_TX_PORT_BIT_MASK , +dsa_xmit_port_mask (skb, dev))); + tag[1 ] =htons (xmit_vlan); + +return skb; +} + +static struct sk_buff *mt7628_tag_rcv (struct sk_buff *skb, +struct net_device *dev)
net/dsa/tag_mt7628.c line 67
Quoted 10 lines
net/dsa/tag_mt7628.c new file +10
-0+{ +int src_port; +__be16 *phdr; +u16 tpid; + +if (unlikely (!pskb_may_pull (skb,MT7628_TAG_LEN ))) +return NULL ; + + phdr =dsa_etype_header_pos_rx (skb); + tpid =ntohs (*phdr);
Why not directly
src_port = FIELD_GET(MT7628_TAG_RX_PORT, ntohs(*phdr));
tpid isn't used for anything else (at this point).
Or even getting rid of both stack variables:
skb->dev = dsa_conduit_find_user(dev, 0, FIELD_GET(MT7628_TAG_RX_PORT, ntohs(*phdr)));
(though the compiler probably treats both forms equally or almost equally)
net/dsa/tag_mt7628.c line 71
Quoted 4 lines
net/dsa/tag_mt7628.c new file +4
-0+skb_pull_rcsum (skb,MT7628_TAG_LEN ); +dsa_strip_etype_header (skb,MT7628_TAG_LEN ); + + src_port = tpid &MT7628_TAG_RX_PORT_MASK ;
As you are using FIELD_PREP above for something which also could as well just be an & operation, I would say you should then also use FIELD_GET here, just to maintain an consistent style. And potentially move up to get rid of the stack variables, see above.
Quoted 7 lines
net/dsa/tag_mt7628.c new file +7
-0+ + skb->dev =dsa_conduit_find_user (dev,0 , src_port); +if (!skb->dev) +return NULL ; +dsa_default_offload_fwd_mark (skb); +return skb; +}
PATCH 4/4 net: dsa: initial support for MT7628 embedded switch
In reply to Joris VaisvilaAdd support for the MT7628 embedded switch.
The switch has 5 built-in 100Mbps user ports (ports 0-4) and one 1Gbps port that is internally attached to the SoCs CPU MAC and serves as the CPU port.
The switch hardware has a very limited 16 entry VLAN table. Configuring VLANs is the only way to control switch forwarding. Currently 6 entries are used by tag_8021q to isolate the ports. Double tag feature is enabled to force the switch to append the VLAN tag even if the incoming packet is already tagged, this simulates VLAN-unaware functionality and simplifies the tagger implementation.
--- drivers/net/dsa/Kconfig | 7 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/mt7628.c | 637 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 645 insertions(+) create mode 100644 drivers/net/dsa/mt7628.c
drivers/net/dsa/Kconfig +7 -0
@@ -70,6 +70,13 @@ config NET_DSA_MV88E6060 This enables support for the Marvell 88E6060 ethernet switch chip. +config NET_DSA_MT7628 + tristate "MT7628 Embedded ethernet switch support" + select NET_DSA_TAG_MT7628 + select MEDIATEK_FE_SOC_PHY + help + This enables support for the switch in the MT7628 SoC. + source "drivers/net/dsa/microchip/Kconfig" source "drivers/net/dsa/mv88e6xxx/Kconfig"
drivers/net/dsa/Makefile +1 -0
@@ -15,6 +15,7 @@ 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-$(CONFIG_NET_DSA_MT7628) += mt7628.o obj-y += b53/ obj-y += hirschmann/ obj-y += lantiq/
drivers/net/dsa/mt7628.c new file +637 -0
637 lines not on this page · raw message
Signature · 1 line
2.53.0
Andrew Lunn
maintainerRe: [PATCH net-next 4/4] net: dsa: initial support for MT7628 embedded switch
drivers/net/dsa/Kconfig config NET_DSA_MV88E6060 · line 74
Quoted 10 lines
drivers/net/dsa/Kconfig +2
-0@@ -70,6 +70,13 @@ config NET_DSA_MV88E6060 This enables support for the Marvell 88E6060 ethernet switch chip. +config NET_DSA_MT7628 + tristate "MT7628 Embedded ethernet switch support"
Please could you make this fit the pattern other devices have.
MediaTek MT7628 Embedded ethernet switch support
would be better. And please put it before MT7530. The sorting in drivers/net/dsa/Kconfig is not great, but we should not make it worse.
drivers/net/dsa/Makefile obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx-core.o · line 18
Quoted 9 lines
drivers/net/dsa/Makefile +1
-0@@ -15,6 +15,7 @@ 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-$(CONFIG_NET_DSA_MT7628) += mt7628.o
This is also sorted, so should be inserted earlier.
Quoted 17 lines
drivers/net/dsa/Makefile +17
-0+static int mt7628_mii_read(struct mii_bus *bus, int port, int regnum) +{ + struct mt7628_esw *esw = bus->priv; + int ret; + u32 val; + + ret = regmap_read_poll_timeout(esw->regmap, MT7628_ESW_REG_PCR1, val, + !(val & MT7628_ESW_PCR1_RD_DONE), 10, + 5000); + if (ret) + goto out; + + ret = regmap_write(esw->regmap, MT7628_ESW_REG_PCR0, + FIELD_PREP(MT7628_ESW_PCR0_CPU_PHY_REG, + regnum) | + FIELD_PREP(MT7628_ESW_PCR0_CPU_PHY_ADDR, + port) | MT7628_ESW_PCR0_RD_PHY_CMD);
drivers/net/dsa/Makefile obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx-core.o
Quoted 10 lines
drivers/net/dsa/Makefile +10
-0+ if (ret) + goto out; + + ret = regmap_read_poll_timeout(esw->regmap, MT7628_ESW_REG_PCR1, val, + (val & MT7628_ESW_PCR1_RD_DONE), 10, + 5000); +out: + if (ret) { + dev_err(&bus->dev, "read failed. MDIO timeout?\n"); + return -ETIMEDOUT;
Return the error code regmap_read_poll_timeout() or regmap_write() returned.
Quoted 18 lines
drivers/net/dsa/Makefile +18
-0+static int mt7628_mii_write(struct mii_bus *bus, int port, int regnum, u16 dat) +{ + struct mt7628_esw *esw = bus->priv; + u32 val; + int ret; + + ret = regmap_read_poll_timeout(esw->regmap, MT7628_ESW_REG_PCR1, val, + !(val & MT7628_ESW_PCR1_WT_DONE), 10, + 5000); + if (ret) + goto out; + + ret = regmap_write(esw->regmap, MT7628_ESW_REG_PCR0, + FIELD_PREP(MT7628_ESW_PCR0_WT_NWAY_DATA, dat) | + FIELD_PREP(MT7628_ESW_PCR0_CPU_PHY_REG, + regnum) | + FIELD_PREP(MT7628_ESW_PCR0_CPU_PHY_ADDR, + port) | MT7628_ESW_PCR0_WT_PHY_CMD);
drivers/net/dsa/Makefile
Quoted 10 lines
drivers/net/dsa/Makefile +10
-0+ if (ret) + goto out; + + ret = regmap_read_poll_timeout(esw->regmap, MT7628_ESW_REG_PCR1, val, + (val & MT7628_ESW_PCR1_WT_DONE), 10, + 5000); +out: + if (ret) { + dev_err(&bus->dev, "write failed. MDIO timeout?\n"); + return -ETIMEDOUT;
Same here. And in general, always return the error code, if there is one, don't make one up.
drivers/net/dsa/Makefile
Quoted 10 lines
drivers/net/dsa/Makefile +10
-0+static int mt7628_setup_internal_mdio(struct dsa_switch *ds) +{ + struct mt7628_esw *esw = ds->priv; + struct device_node *mdio; + struct mii_bus *bus; + int ret = 0; + + mdio = of_get_child_by_name(ds->dev->of_node, "mdio"); + if (mdio && !of_device_is_available(mdio)) + goto out_put_node;
of_get_available_child_by_name() ?
Andrew
Re: [PATCH net-next 4/4] net: dsa: initial support for MT7628 embedded switch
Thanks for the review, will fix all of these in v2.