net-next: dsa: add Mediatek MT7530 support
Subsystems (7)
v4 cover net-next: dsa: add Mediatek MT7530 support
From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on Mediatek router platforms such as MT7623A or MT7623N which includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports, The port from 0 to 4 are the user ports connecting with the remote devices while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet GMAC.
The patch series integrated Mediatek MT7530 into DSA support which includes the most of the essential callbacks such as tag insertion for port distinguishing, port control, bridge offloading, STP setup and ethtool operations to allow DSA to model each user port into independently standalone netdevice as the other DSA driver had done.
Changes since v1:
- rebased into 4.11-rc1
- refined binding document including below five items
- changed the type of mediatek,mcm into bool
- used reset controller binding for MCM reset and removed "mediatek,ethsys" property from binding
- reused CPU port's ethernet Phandle instead of creating new one and removed "mediatek,ethernet" property from binding
- aligned naming for GPIO reset with dsa/marvell.txt
- added phy-mode as required property child nodes within ports container
- handled gpio reset with devm_gpiod_* API
- refined comment words
- removed condition for CDM setting since the setup looks both fine for all cases
- allowed of_find_net_device_by_node() working with pointing the device node into real netdev instance
- fixed Kbuild warnings
Changes since v2:
- reuse readx_poll_timeout() to poll
- add proper macro instead of hard coding
- treat inconsistent cpu port as warning
- remove the usage for regmap-debugfs
- show error message when invalid id is found
- put the logic for the setup of trgmii into adjut_link()
- refine and reuse logic between port_[disable,enable], and default port setup
- correct typo
Changes since v3:
- used struct as the parameter for readx_poll_timeout() and kill extra lpriv defined
- moved around function to get out of an additional declaration
- fixed kbuild errors caused by missing proper include in the latest tree
Sean Wang (5):
dt-bindings: net: dsa: add Mediatek MT7530 binding
net-next: dsa: add Mediatek tag RX/TX handler
net-next: ethernet: mediatek: add CDM able to recognize the tag for
DSA
net-next: ethernet: mediatek: add device_node of GMAC pointing into
the netdev instance
net-next: dsa: add dsa support for Mediatek MT7530 switch
.../devicetree/bindings/net/dsa/mt7530.txt | 92 ++ drivers/net/dsa/Kconfig | 8 + drivers/net/dsa/Makefile | 2 +- drivers/net/dsa/mt7530.c | 1125 ++++++++++++++++++++ drivers/net/dsa/mt7530.h | 402 +++++++ drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 + include/net/dsa.h | 1 + net/dsa/Kconfig | 2 + net/dsa/Makefile | 1 + net/dsa/dsa.c | 3 + net/dsa/dsa_priv.h | 3 + net/dsa/tag_mtk.c | 118 ++ 13 files changed, 1768 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/net/dsa/mt7530.txt create mode 100644 drivers/net/dsa/mt7530.c create mode 100644 drivers/net/dsa/mt7530.h create mode 100644 net/dsa/tag_mtk.c
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 1/5 dt-bindings: net: dsa: add Mediatek MT7530 binding
From: Sean Wang <[email protected]>
Add device-tree binding for Mediatek MT7530 switch.
--- .../devicetree/bindings/net/dsa/mt7530.txt | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/mt7530.txt
Documentation/devicetree/bindings/net/dsa/mt7530.txt new file +92 -0
@@ -0,0 +1,92 @@ +Mediatek MT7530 Ethernet switch +================================ + +Required properties: + +- compatible: Must be compatible = "mediatek,mt7530"; +- #address-cells: Must be 1. +- #size-cells: Must be 0. +- mediatek,mcm: Boolean; if defined, indicates that either MT7530 is the part + on multi-chip module belong to MT7623A has or the remotely standalone + chip as the function MT7623N reference board provided for. +- core-supply: Phandle to the regulator node necessary for the core power. +- io-supply: Phandle to the regulator node necessary for the I/O power. + See Documentation/devicetree/bindings/regulator/mt6323-regulator.txt + for details for the regulator setup on these boards. + +If the property mediatek,mcm isn't defined, following property is required + +- reset-gpios: Should be a gpio specifier for a reset line. + +Else, following properties are required + +- resets : Phandle pointing to the system reset controller with + line index for the ethsys. +- reset-names : Should be set to "mcm". + +Required properties for the child nodes within ports container: + +- reg: Port address described must be 6 for CPU port and from 0 to 5 for + user ports. +- phy-mode: String, must be either "trgmii" or "rgmii" for port labeled + "cpu". + +See Documentation/devicetree/bindings/dsa/dsa.txt for a list of additional +required, optional properties and how the integrated switch subnodes must +be specified. + +Example: + + &mdio0 { + switch@0 { + compatible = "mediatek,mt7530"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + core-supply = <&mt6323_vpa_reg>; + io-supply = <&mt6323_vemc3v3_reg>; + reset-gpios = <&pio 33 0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + port@0 { + reg = <0>; + label = "lan0"; + }; + + port@1 { + reg = <1>; + label = "lan1"; + }; + + port@2 { + reg = <2>; + label = "lan2"; + }; + + port@3 { + reg = <3>; + label = "lan3"; + }; + + port@4 { + reg = <4>; + label = "wan"; + }; + + port@6 { + reg = <6>; + label = "cpu"; + ethernet = <&gmac0>; + phy-mode = "trgmii"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; + };
Signature · 1 line
1.9.1
PATCH v4 2/5 net-next: dsa: add Mediatek tag RX/TX handler
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Add the support for the 4-bytes tag for DSA port distinguishing inserted allowing receiving and transmitting the packet via the particular port. The tag is being added after the source MAC address in the ethernet header.
--- include/net/dsa.h | 1 + net/dsa/Kconfig | 2 + net/dsa/Makefile | 1 + net/dsa/dsa.c | 3 ++ net/dsa/dsa_priv.h | 3 ++ net/dsa/tag_mtk.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 128 insertions(+) create mode 100644 net/dsa/tag_mtk.c
include/net/dsa.h +1 -0
@@ -31,6 +31,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_EDSA ,DSA_TAG_PROTO_BRCM ,DSA_TAG_PROTO_QCA , +DSA_TAG_PROTO_MTK , DSA_TAG_LAST, /* MUST BE LAST */ };
net/dsa/Kconfig +2 -0
@@ -31,4 +31,6 @@ config NET_DSA_TAG_TRAILER config NET_DSA_TAG_QCA bool +config NET_DSA_TAG_MTK + bool endif
net/dsa/Makefile +1 -0
@@ -8,3 +8,4 @@ dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o dsa_core-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o dsa_core-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o +dsa_core-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o
net/dsa/dsa.c +3 -0
@@ -53,6 +53,9 @@ static struct sk_buff *dsa_slave_notag_xmit(struct sk_buff *skb, #ifdef CONFIG_NET_DSA_TAG_QCA [DSA_TAG_PROTO_QCA ] = &qca_netdev_ops, #endif +#ifdef CONFIG_NET_DSA_TAG_MTK + [DSA_TAG_PROTO_MTK] = &mtk_netdev_ops, +#endif [DSA_TAG_PROTO_NONE] = &none_ops, };
net/dsa/dsa_priv.h +3 -0
@@ -85,4 +85,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,/* tag_qca.c */ extern const struct dsa_device_ops qca_netdev_ops; +/* tag_mtk.c */ +extern const struct dsa_device_ops mtk_netdev_ops; +#endif
net/dsa/tag_mtk.c new file +118 -0
118 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v4 3/5 net-next: ethernet: mediatek: add CDM able to recognize the tag for DSA
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
The patch adds the setup for allowing CDM can recognize these packets with carrying port-distinguishing tag. Otherwise, these tagging packets will be handled incorrectly by CDM. The setup is also working out for general untag packets as well.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++++ drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++++ 2 files changed, 10 insertions(+)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +6 -0
@@ -1846,6 +1846,12 @@ static int mtk_hw_init(struct mtk_eth *eth)/* GE2, Force 1000M/FD, FC ON */ mtk_w32 (eth,MAC_MCR_FIXED_LINK ,MTK_MAC_MCR (1 )); +/* Indicates CDM to parse the MTK special tag from CPU +* which also is working out for untag packets. +*/ + val =mtk_r32 (eth,MTK_CDMQ_IG_CTRL ); +mtk_w32 (eth, val |MTK_CDMQ_STAG_EN ,MTK_CDMQ_IG_CTRL ); +/* Enable RX VLan Offloading */ mtk_w32 (eth,1 ,MTK_CDMP_EG_CTRL );
drivers/net/ethernet/mediatek/mtk_eth_soc.h +4 -0
@@ -70,6 +70,10 @@/* Frame Engine Interrupt Grouping Register */ #define MTK_FE_INT_GRP 0x20 +/* CDMP Ingress Control Register */ +#define MTK_CDMQ_IG_CTRL 0x1400 +#define MTK_CDMQ_STAG_EN BIT(0) +/* CDMP Exgress Control Register */ #define MTK_CDMP_EG_CTRL 0x404
Signature · 1 line
1.9.1
PATCH v4 4/5 net-next: ethernet: mediatek: add device_node of GMAC pointing into the netdev instance
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
the patch adds the setup of the corresponding device node of GMAC into the netdev instance which could allow other modules such as DSA to find the instance through the node in dt-bindings using of_find_net_device_by_node() call.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +2 -0
@@ -2323,6 +2323,8 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) eth->netdev[id]->ethtool_ops = &mtk_ethtool_ops; eth->netdev[id]->irq = eth->irq[0 ]; + eth->netdev[id]->dev.of_node = np; +return 0 ; free_netdev:
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 5/5 net-next: dsa: add dsa support for Mediatek MT7530 switch
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on Mediatek router platforms such as MT7623A or MT7623N platform which includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports, The port from 0 to 4 are the user ports connecting with the remote devices while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet GMAC.
For port 6, it can communicate with the CPU via Mediatek Ethernet GMAC through either the TRGMII or RGMII which could be controlled by phy-mode in the dt-bindings to specify which mode is preferred to use. And for port 5, only RGMII can be specified. However, currently, only port 6 is being supported in this DSA driver.
The driver is made with the reference to qca8k and other existing DSA driver. The most of the essential callbacks of the DSA are already support in the driver, including tag insert for user port distinguishing, port control, bridge offloading, STP setup and ethtool operation to allow DSA to model each user port into a standalone netdevice as the other DSA driver had done.
--- drivers/net/dsa/Kconfig | 8 + drivers/net/dsa/Makefile | 2 +- drivers/net/dsa/mt7530.c | 1125 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/dsa/mt7530.h | 402 +++++++++++++++++ 4 files changed, 1536 insertions(+), 1 deletion(-) create mode 100644 drivers/net/dsa/mt7530.c create mode 100644 drivers/net/dsa/mt7530.h
drivers/net/dsa/Kconfig +8 -0
@@ -34,4 +34,12 @@ config NET_DSA_QCA8K This enables support for the Qualcomm Atheros QCA8K Ethernet switch chips. +config NET_DSA_MT7530 + tristate "Mediatek MT7530 Ethernet switch support" + depends on NET_DSA + select NET_DSA_TAG_MTK + ---help--- + This enables support for the Mediatek MT7530 Ethernet switch + chip. + endmenu
drivers/net/dsa/Makefile +1 -1
@@ -2,6 +2,6 @@ obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o obj-$(CONFIG_NET_DSA_BCM_SF2) += bcm-sf2.o bcm-sf2-objs := bcm_sf2.o bcm_sf2_cfp.o obj-$(CONFIG_NET_DSA_QCA8K) += qca8k.o - +obj-$(CONFIG_NET_DSA_MT7530) += mt7530.o obj-y += b53/ obj-y += mv88e6xxx/
drivers/net/dsa/mt7530.c new file +1125 -0
1,125 lines not on this page · raw message
drivers/net/dsa/mt7530.h new file +402 -0
402 lines not on this page · raw message
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next v4 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch
Quoted 22 lines · On Fri, Apr 07, 2017 at 04:45:09PM +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on Mediatek router platforms such as MT7623A or MT7623N platform which includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports, The port from 0 to 4 are the user ports connecting with the remote devices while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet GMAC.
For port 6, it can communicate with the CPU via Mediatek Ethernet GMAC through either the TRGMII or RGMII which could be controlled by phy-mode in the dt-bindings to specify which mode is preferred to use. And for port 5, only RGMII can be specified. However, currently, only port 6 is being supported in this DSA driver.
The driver is made with the reference to qca8k and other existing DSA driver. The most of the essential callbacks of the DSA are already support in the driver, including tag insert for user port distinguishing, port control, bridge offloading, STP setup and ethtool operation to allow DSA to model each user port into a standalone netdevice as the other DSA driver had done.
Quoted 2 lines
Signed-off-by Sean Wang <[email protected]>Signed-off-by Landen Chao <[email protected]>
Hi Sean
This is looking good now. Thanks
Andrew
Re: [PATCH net-next v4 1/5] dt-bindings: net: dsa: add Mediatek MT7530 binding
In reply to [email protected]Quoted 7 lines · On Fri, Apr 07, 2017 at 04:45:05PM +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Add device-tree binding for Mediatek MT7530 switch.
Signed-off-by Sean Wang <[email protected]>Acked-by Rob Herring <[email protected]>
Andrew
Re: [PATCH net-next v4 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch
In reply to [email protected]Quoted 22 lines · On 04/07/2017 01:45 AM, [email protected] wrote:
From: Sean Wang <[email protected]>
MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on Mediatek router platforms such as MT7623A or MT7623N platform which includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports, The port from 0 to 4 are the user ports connecting with the remote devices while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet GMAC.
For port 6, it can communicate with the CPU via Mediatek Ethernet GMAC through either the TRGMII or RGMII which could be controlled by phy-mode in the dt-bindings to specify which mode is preferred to use. And for port 5, only RGMII can be specified. However, currently, only port 6 is being supported in this DSA driver.
The driver is made with the reference to qca8k and other existing DSA driver. The most of the essential callbacks of the DSA are already support in the driver, including tag insert for user port distinguishing, port control, bridge offloading, STP setup and ethtool operation to allow DSA to model each user port into a standalone netdevice as the other DSA driver had done.
Quoted 2 lines
Signed-off-by Sean Wang <[email protected]>Signed-off-by Landen Chao <[email protected]>
Signature · 1 line
Florian
Re: [PATCH net-next v4 1/5] dt-bindings: net: dsa: add Mediatek MT7530 binding
In reply to [email protected]Quoted 7 lines · On 04/07/2017 01:45 AM, sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected] wrote:
From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Add device-tree binding for Mediatek MT7530 switch.
Signature · 5 lines
Florian -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
maintainerFrom: <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Date: Fri, 7 Apr 2017 16:45:04 +0800
Quoted 7 lines
MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on Mediatek router platforms such as MT7623A or MT7623N which includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports, The port from 0 to 4 are the user ports connecting with the remote devices while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet GMAC.
Quoted 5 lines
The patch series integrated Mediatek MT7530 into DSA support which includes the most of the essential callbacks such as tag insertion for port distinguishing, port control, bridge offloading, STP setup and ethtool operations to allow DSA to model each user port into independently standalone netdevice as the other DSA driver had done.
Series applied, thanks Sean.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html