net-next: dsa: mt7530: add support for MT7531
Subsystems (6)
cover net-next: dsa: mt7530: add support for MT7531
This patch series adds support for MT7531.
MT7531 is the next generation of MT7530 which could be found on Mediatek router platforms such as MT7622 or MT7629.
It is also a 7-ports switch with 5 giga embedded phys, 2 cpu ports, and the same MAC logic of MT7530. Cpu port 6 only supports HSGMII interface. Cpu port 5 supports either RGMII or HSGMII in different HW SKU. Due to support for HSGMII interface, pll, and pad setting are different from MT7530.
Landen Chao (6):
net: dsa: mt7530: Refine message in Kconfig
net: dsa: mt7530: Extend device data ready for adding a new hardware
dt-bindings: net: dsa: add new MT7531 binding to support MT7531
net: dsa: mt7530: Add the support of MT7531 switch
arm64: dts: mt7622: add mt7531 dsa to mt7622-rfb1 board
arm64: dts: mt7622: add mt7531 dsa to bananapi-bpi-r64 board
.../devicetree/bindings/net/dsa/mt7530.txt | 77 +- .../dts/mediatek/mt7622-bananapi-bpi-r64.dts | 50 + arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts | 63 +- drivers/net/dsa/Kconfig | 6 +- drivers/net/dsa/mt7530.c | 874 ++++++++++++++++-- drivers/net/dsa/mt7530.h | 173 +++- 6 files changed, 1168 insertions(+), 75 deletions(-)
Signature · 1 line
2.17.1
PATCH 3/6 dt-bindings: net: dsa: add new MT7531 binding to support MT7531
Add devicetree binding to support the compatible mt7531 switch as used in the MediaTek MT7531 switch.
--- .../devicetree/bindings/net/dsa/mt7530.txt | 77 ++++++++++++++++++- 1 file changed, 74 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/dsa/mt7530.txt +74 -3
@@ -5,6 +5,7 @@ Required properties: - compatible: may be compatible = "mediatek,mt7530" or compatible = "mediatek,mt7621" + or compatible = "mediatek,mt7531" - #address-cells: Must be 1. - #size-cells: Must be 0. - mediatek,mcm: Boolean; if defined, indicates that either MT7530 is the part
@@ -32,10 +33,13 @@ 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". +- phy-mode: String, the follow value would be acceptable for port labeled "cpu" + If compatible mediatek,mt7530 or mediatek,mt7621 is set, + must be either "trgmii" or "rgmii" + If compatible mediatek,mt7531 is set, + must be either "sgmii", "1000base-x" or "2500base-x" -Port 5 of the switch is muxed between: +Port 5 of mt7530 and mt7621 switch is muxed between: 1. GMAC5: GMAC5 can interface with another external MAC or PHY. 2. PHY of port 0 or port 4: PHY interfaces with an external MAC like 2nd GMAC of the SOC. Used in many setups where port 0/4 becomes the WAN port.
@@ -308,3 +312,70 @@ Example 3: MT7621: Port 5 is connected to external PHY: Port 5 -> external PHY. }; }; }; + +Example 4: + +ð { + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <1000>; + full-duplex; + pause; + }; + }; + + &mdio0 { + switch@0 { + compatible = "mediatek,mt7531"; + reg = <0>; + reset-gpios = <&pio 54 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 = "2500base-x"; + + fixed-link { + speed = <1000>; + full-duplex; + pause; + }; + }; + }; + }; + };
Signature · 5 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 1/6 net: dsa: mt7530: Refine message in Kconfig
In reply to Landen ChaoRefine message in Kconfig with fixing typo and an explicit MT7621 support.
--- drivers/net/dsa/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/dsa/Kconfig +3 -3
@@ -33,12 +33,12 @@ config NET_DSA_LANTIQ_GSWIP the xrx200 / VR9 SoC. config NET_DSA_MT7530 - tristate "Mediatek MT7530 Ethernet switch support" + tristate "MediaTek MT7530 and MT7621 Ethernet switch support" depends on NET_DSA select NET_DSA_TAG_MTK ---help--- - This enables support for the Mediatek MT7530 Ethernet switch - chip. + This enables support for the MediaTek MT7530 and MT7621 Ethernet + switch chip. config NET_DSA_MV88E6060 tristate "Marvell 88E6060 ethernet switch chip support"
Signature · 1 line
2.17.1
PATCH 5/6 arm64: dts: mt7622: add mt7531 dsa to mt7622-rfb1 board
In reply to Landen ChaoAdd mt7531 dsa to mt7622-rfb1 board for 5 giga Ethernet ports support. mt7622 only supports 1 sgmii interface, so either gmac0 or gmac1 can be configured as sgmii interface. In this patch, change to connet mt7622 gmac0 and mt7531 port6 through sgmii interface.
--- arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts | 63 ++++++++++++++++++-- 1 file changed, 57 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts +57 -6
@@ -105,20 +105,71 @@ pinctrl-0 = <ð_pins>; status = "okay"; - gmac1: mac@1 { + gmac0: mac@0 { compatible = "mediatek,eth-mac"; - reg = <1>; - phy-handle = <&phy5>; + reg = <0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; }; mdio-bus { #address-cells = <1>; #size-cells = <0>; - phy5: ethernet-phy@5 { - reg = <5>; - phy-mode = "sgmii"; + switch@0 { + compatible = "mediatek,mt7531"; + reg = <0>; + reset-gpios = <&pio 54 0>; + + ports { + #address-cells = <1>; + #size-cells = <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 = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; }; + }; };
Signature · 5 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 2/6 net: dsa: mt7530: Extend device data ready for adding a new hardware
In reply to Landen ChaoAdd a structure holding required operations for each device such as device initialization, PHY port read or write, a checker whether PHY interface is supported on a certain port, MAC port setup for either bus pad or a specific PHY interface.
The patch is done for ready adding a new hardware MT7531.
--- drivers/net/dsa/mt7530.c | 231 +++++++++++++++++++++++++++++---------- drivers/net/dsa/mt7530.h | 29 ++++- 2 files changed, 203 insertions(+), 57 deletions(-)
drivers/net/dsa/mt7530.c +175 -56
@@ -425,7 +425,7 @@ mt7530_fdb_write(struct mt7530_priv *priv, u16 vid, }static int -mt7530_pad_clk_setup (struct dsa_switch *ds,int mode) +mt7530_pad_clk_setup (struct dsa_switch *ds,phy_interface_t mode) {struct mt7530_priv *priv = ds->priv;u32 ncpo1, ssc_delta, trgint, i, xtal;
@@ -1380,13 +1380,111 @@ mt7530_setup(struct dsa_switch *ds)return 0 ; } -static void mt7530_phylink_mac_config (struct dsa_switch *ds,int port, +static bool mt7530_phy_supported (struct dsa_switch *ds,int port, +const struct phylink_link_state *state) +{ +struct mt7530_priv *priv = ds->priv; + +switch (port) { +case 0 :/* Internal phy */ +case 1 : +case 2 : +case 3 : +case 4 : +if (state->interface !=PHY_INTERFACE_MODE_GMII ) + goto unsupported; +break ; +case 5 :/* 2nd cpu port with phy of port 0 or 4 / external phy */ +if (!phy_interface_mode_is_rgmii (state->interface) && + state->interface !=PHY_INTERFACE_MODE_MII && + state->interface !=PHY_INTERFACE_MODE_GMII ) + goto unsupported; +break ; +case 6 :/* 1st cpu port */ +if (state->interface !=PHY_INTERFACE_MODE_RGMII && + state->interface !=PHY_INTERFACE_MODE_TRGMII ) + goto unsupported; +break ; +default : +dev_err (priv->dev,"%s: unsupported port: %i\n" , __func__, + port); + goto unsupported; + } + +return true; + +unsupported: +return false; +} + +static bool mt753x_phy_supported (struct dsa_switch *ds,int port, +const struct phylink_link_state *state) +{ +struct mt7530_priv *priv = ds->priv; + +return priv->info->phy_supported (ds, port, state); +} + +static int +mt7530_pad_setup (struct dsa_switch *ds,const struct phylink_link_state *state) +{ +struct mt7530_priv *priv = ds->priv; + +/* Setup TX circuit incluing relevant PAD and driving */ +mt7530_pad_clk_setup (ds, state->interface); + +if (priv->id ==ID_MT7530 ) { +/* Setup RX circuit, relevant PAD and driving on the +* host which must be placed after the setup on the +* device side is all finished. +*/ +mt7623_pad_clk_setup (ds); + } + +return 0 ; +} + +static int +mt753x_pad_setup (struct dsa_switch *ds,const struct phylink_link_state *state) +{ +struct mt7530_priv *priv = ds->priv; + +return priv->info->pad_setup (ds, state); +} + +static int +mt7530_mac_setup (struct dsa_switch *ds,int port,unsigned int mode, +const struct phylink_link_state *state) +{ +struct mt7530_priv *priv = ds->priv; + +/* Only need to setup port5. */ +if (port !=5 ) +return 0 ; + +mt7530_setup_port5 (priv->ds, state->interface); + +return 0 ; +} + +static int mt753x_mac_setup (struct dsa_switch *ds,int port,unsigned int mode, +const struct phylink_link_state *state) +{ +struct mt7530_priv *priv = ds->priv; + +return priv->info->mac_setup (ds, port, mode, state); +} + +static void mt753x_phylink_mac_config (struct dsa_switch *ds,int port,unsigned int mode,const struct phylink_link_state *state) {struct mt7530_priv *priv = ds->priv;u32 mcr_cur, mcr_new; +if (!mt753x_phy_supported (ds, port, state)) +return ; +switch (port) {case 0 :/* Internal phy */ case 1 :
@@ -1399,35 +1497,24 @@ static void mt7530_phylink_mac_config(struct dsa_switch *ds, int port,case 5 :/* 2nd cpu port with phy of port 0 or 4 / external phy */ if (priv->p5_interface == state->interface)break ; -if (!phy_interface_mode_is_rgmii (state->interface) && - state->interface !=PHY_INTERFACE_MODE_MII && - state->interface !=PHY_INTERFACE_MODE_GMII ) -return ; -mt7530_setup_port5 (ds, state->interface); +if (mt753x_mac_setup (ds, port, mode, state) <0 ) + goto unsupported; +break ;case 6 :/* 1st cpu port */ if (priv->p6_interface == state->interface)break ; -if (state->interface !=PHY_INTERFACE_MODE_RGMII && - state->interface !=PHY_INTERFACE_MODE_TRGMII ) -return ; - -/* Setup TX circuit incluing relevant PAD and driving */ -mt7530_pad_clk_setup (ds, state->interface); +mt753x_pad_setup (ds, state); -if (priv->id ==ID_MT7530 ) { -/* Setup RX circuit, relevant PAD and driving on the -* host which must be placed after the setup on the -* device side is all finished. -*/ -mt7623_pad_clk_setup (ds); - } +if (mt753x_mac_setup (ds, port, mode, state) <0 ) + goto unsupported; priv->p6_interface = state->interface;break ;default : +unsupported:dev_err (ds->dev,"%s: unsupported port: %i\n" , __func__, port);return ; }
@@ -1488,38 +1575,14 @@ static void mt7530_phylink_mac_link_up(struct dsa_switch *ds, int port,mt7530_port_set_status (priv, port,1 ); } -static void mt7530_phylink_validate (struct dsa_switch *ds,int port, +static void mt753x_phylink_validate (struct dsa_switch *ds,int port,unsigned long *supported,struct phylink_link_state *state) {__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , }; -switch (port) { -case 0 :/* Internal phy */ -case 1 : -case 2 : -case 3 : -case 4 : -if (state->interface !=PHY_INTERFACE_MODE_NA && - state->interface !=PHY_INTERFACE_MODE_GMII ) - goto unsupported; -break ; -case 5 :/* 2nd cpu port with phy of port 0 or 4 / external phy */ -if (state->interface !=PHY_INTERFACE_MODE_NA && - !phy_interface_mode_is_rgmii (state->interface) && - state->interface !=PHY_INTERFACE_MODE_MII && - state->interface !=PHY_INTERFACE_MODE_GMII ) - goto unsupported; -break ; -case 6 :/* 1st cpu port */ -if (state->interface !=PHY_INTERFACE_MODE_NA && - state->interface !=PHY_INTERFACE_MODE_RGMII && - state->interface !=PHY_INTERFACE_MODE_TRGMII ) - goto unsupported; -break ; -default : -dev_err (ds->dev,"%s: unsupported port: %i\n" , __func__, port); -unsupported: +if (state->interface !=PHY_INTERFACE_MODE_NA && + !mt753x_phy_supported (ds, port, state)) {linkmode_zero (supported);return ; }
@@ -1590,12 +1653,36 @@ mt7530_phylink_mac_link_state(struct dsa_switch *ds, int port,return 1 ; } +static int +mt753x_setup (struct dsa_switch *ds) +{ +struct mt7530_priv *priv = ds->priv; + +return priv->info->setup (ds); +} + +static int +mt753x_phy_read (struct dsa_switch *ds,int port,int regnum) +{ +struct mt7530_priv *priv = ds->priv; + +return priv->info->phy_read (ds, port, regnum); +} + +static int +mt753x_phy_write (struct dsa_switch *ds,int port,int regnum,u16 val) +{ +struct mt7530_priv *priv = ds->priv; + +return priv->info->phy_write (ds, port, regnum, val); +} +static const struct dsa_switch_ops mt7530_switch_ops = { .get_tag_protocol = mtk_get_tag_protocol, - .setup = mt7530_setup, + .setup = mt753x_setup, .get_strings = mt7530_get_strings, - .phy_read = mt7530_phy_read, - .phy_write = mt7530_phy_write, + .phy_read = mt753x_phy_read, + .phy_write = mt753x_phy_write, .get_ethtool_stats = mt7530_get_ethtool_stats, .get_sset_count = mt7530_get_sset_count, .port_enable = mt7530_port_enable,
@@ -1610,16 +1697,37 @@ static const struct dsa_switch_ops mt7530_switch_ops = { .port_vlan_prepare = mt7530_port_vlan_prepare, .port_vlan_add = mt7530_port_vlan_add, .port_vlan_del = mt7530_port_vlan_del, - .phylink_validate = mt7530_phylink_validate, + .phylink_validate = mt753x_phylink_validate, .phylink_mac_link_state = mt7530_phylink_mac_link_state, - .phylink_mac_config = mt7530_phylink_mac_config, + .phylink_mac_config = mt753x_phylink_mac_config, .phylink_mac_link_down = mt7530_phylink_mac_link_down, .phylink_mac_link_up = mt7530_phylink_mac_link_up, }; +static const struct mt753x_info mt753x_table[] = { + [ID_MT7621 ] = { + .id =ID_MT7621 , + .setup = mt7530_setup, + .phy_read = mt7530_phy_read, + .phy_write = mt7530_phy_write, + .phy_supported = mt7530_phy_supported, + .pad_setup = mt7530_pad_setup, + .mac_setup = mt7530_mac_setup, + }, + [ID_MT7530 ] = { + .id =ID_MT7530 , + .setup = mt7530_setup, + .phy_read = mt7530_phy_read, + .phy_write = mt7530_phy_write, + .phy_supported = mt7530_phy_supported, + .pad_setup = mt7530_pad_setup, + .mac_setup = mt7530_mac_setup, + }, +}; +static const struct of_device_id mt7530_of_match[] = { - { .compatible ="mediatek,mt7621" , .data = (void *)ID_MT7621 , }, - { .compatible ="mediatek,mt7530" , .data = (void *)ID_MT7530 , }, + { .compatible ="mediatek,mt7621" , .data = &mt753x_table[ID_MT7621 ], }, + { .compatible ="mediatek,mt7530" , .data = &mt753x_table[ID_MT7530 ], }, {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, mt7530_of_match);
@@ -1660,8 +1768,19 @@ mt7530_probe(struct mdio_device *mdiodev)/* Get the hardware identifier from the devicetree node. * We will need it for some of the clock and regulator setup. */ - priv->id = (unsigned int )(unsigned long ) -of_device_get_match_data (&mdiodev->dev); + priv->info =of_device_get_match_data (&mdiodev->dev); +if (!priv->info) +return -EINVAL ; + +/* Sanity check if these required device operstaions are filled +* properly. +*/ +if (!priv->info->setup || !priv->info->phy_read || + !priv->info->phy_write || !priv->info->phy_supported || + !priv->info->pad_setup || !priv->info->mac_setup) +return -EINVAL ; + + priv->id = priv->info->id;if (priv->id ==ID_MT7530 ) { priv->core_pwr =devm_regulator_get (&mdiodev->dev,"core" );
drivers/net/dsa/mt7530.h +28 -1
@@ -11,7 +11,7 @@#define MT7530_NUM_FDB_RECORDS 2048#define MT7530_ALL_MEMBERS 0xff -enum { +enum mt753x_id {ID_MT7530 =0 ,ID_MT7621 =1 , };
@@ -428,6 +428,32 @@ static const char *p5_intf_modes(unsigned int p5_interface) } } +/* struct mt753x_info - This is the main data structure for holding the specific +* part for each supported device +* @setup: Holding the handler to a device initialization +* @phy_read: Holding the way reading PHY port +* @phy_write: Holding the way writing PHY port +* @phy_supported: Check if the PHY type is being supported on a certain +* port +* @pad_setup: Holding the way setting up the bus pad for a certain MAC +* port +* @mac_setup: Holding the way setting up the PHY attribute for a +* certain MAC port +*/ +struct mt753x_info { +enum mt753x_id id; + +int (*setup)(struct dsa_switch *ds); +int (*phy_read)(struct dsa_switch *ds,int port,int regnum); +int (*phy_write)(struct dsa_switch *ds,int port,int regnum,u16 val); +bool (*phy_supported)(struct dsa_switch *ds,int port, +const struct phylink_link_state *state); +int (*pad_setup)(struct dsa_switch *ds, +const struct phylink_link_state *state); +int (*mac_setup)(struct dsa_switch *ds,int port,unsigned int mode, +const struct phylink_link_state *state); +}; +/* struct mt7530_priv - This is the main data structure for holding the state * of the driver * @dev: The device pointer
@@ -455,6 +481,7 @@ struct mt7530_priv {struct regulator *core_pwr;struct regulator *io_pwr;struct gpio_desc *reset; +const struct mt753x_info *info;unsigned int id;bool mcm;phy_interface_t p6_interface;
Signature · 5 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 6/6 arm64: dts: mt7622: add mt7531 dsa to bananapi-bpi-r64 board
In reply to Landen ChaoAdd mt7531 dsa to bananapi-bpi-r64 board for 5 giga Ethernet ports support.
--- .../dts/mediatek/mt7622-bananapi-bpi-r64.dts | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+)
arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +50 -0
@@ -143,6 +143,56 @@ mdio: mdio-bus { #address-cells = <1>; #size-cells = <0>; + + switch@0 { + compatible = "mediatek,mt7531"; + reg = <0>; + reset-gpios = <&pio 54 0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "wan"; + }; + + port@1 { + reg = <1>; + label = "lan0"; + }; + + port@2 { + reg = <2>; + label = "lan1"; + }; + + port@3 { + reg = <3>; + label = "lan2"; + }; + + port@4 { + reg = <4>; + label = "lan3"; + }; + + port@6 { + reg = <6>; + label = "cpu"; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; + }; + }; };
Signature · 5 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 4/6 net: dsa: mt7530: Add the support of MT7531 switch
In reply to Landen ChaoAdd new support for MT7531:
MT7531 is the next generation of MT7530. It is also a 7-ports switch with 5 giga embedded phys, 2 cpu ports, and the same MAC logic of MT7530. Cpu port 6 only supports HSGMII interface. Cpu port 5 supports either RGMII or HSGMII in different HW sku. Due to HSGMII interface support, pll, and pad setting are different from MT7530. This patch adds different initial setting of MT7531.
--- drivers/net/dsa/Kconfig | 6 +- drivers/net/dsa/mt7530.c | 643 ++++++++++++++++++++++++++++++++++++++- drivers/net/dsa/mt7530.h | 144 +++++++++ 3 files changed, 784 insertions(+), 9 deletions(-)
drivers/net/dsa/Kconfig +3 -3
@@ -33,12 +33,12 @@ config NET_DSA_LANTIQ_GSWIP the xrx200 / VR9 SoC. config NET_DSA_MT7530 - tristate "MediaTek MT7530 and MT7621 Ethernet switch support" + tristate "MediaTek MT753x and MT7621 Ethernet switch support" depends on NET_DSA select NET_DSA_TAG_MTK ---help--- - This enables support for the MediaTek MT7530 and MT7621 Ethernet - switch chip. + This enables support for the MediaTek MT7530, MT7531 and MT7621 + Ethernet switch chip. config NET_DSA_MV88E6060 tristate "Marvell 88E6060 ethernet switch chip support"
drivers/net/dsa/mt7530.c +637 -6
749 lines not on this page · raw message
drivers/net/dsa/mt7530.h +144 -0
206 lines not on this page · raw message
Signature · 1 line
2.17.1
Hi
thank you for the DSA-driver, works so far, but a bit to improve:
i got some retransmitts on RX (TX looks good)...i guess a clk/pll problem
Iperf3-Client (BPI-R64,192.168.0.19):
root@bpi-r64:~# iperf3 -c 192.168.0.21 Connecting to host 192.168.0.21, port 5201 [ 5] local 192.168.0.19 port 56412 connected to 192.168.0.21 port 5201 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 114 MBytes 957 Mbits/sec 0 1003 KBytes [ 5] 1.00-2.00 sec 113 MBytes 944 Mbits/sec 0 1.08 MBytes [ 5] 2.00-3.00 sec 112 MBytes 941 Mbits/sec 0 1.08 MBytes [ 5] 3.00-4.00 sec 112 MBytes 941 Mbits/sec 0 1.08 MBytes [ 5] 4.00-5.00 sec 112 MBytes 942 Mbits/sec 0 1.08 MBytes [ 5] 5.00-6.00 sec 112 MBytes 944 Mbits/sec 0 1.21 MBytes [ 5] 6.00-7.00 sec 112 MBytes 944 Mbits/sec 0 1.27 MBytes [ 5] 7.00-8.00 sec 112 MBytes 943 Mbits/sec 0 1.27 MBytes [ 5] 8.00-9.00 sec 111 MBytes 934 Mbits/sec 0 1.27 MBytes [ 5] 9.00-10.00 sec 112 MBytes 944 Mbits/sec 0 1.27 MBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.00 sec 1.10 GBytes 943 Mbits/sec 0 sender [ 5] 0.00-10.00 sec 1.10 GBytes 941 Mbits/sec receiver
iperf Done.
root@bpi-r64:~# iperf3 -c 192.168.0.21 -R Connecting to host 192.168.0.21, port 5201 Reverse mode, remote host 192.168.0.21 is sending [ 5] local 192.168.0.19 port 56420 connected to 192.168.0.21 port 5201 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 112 MBytes 941 Mbits/sec [ 5] 1.00-2.00 sec 112 MBytes 941 Mbits/sec [ 5] 2.00-3.00 sec 111 MBytes 933 Mbits/sec [ 5] 3.00-4.00 sec 112 MBytes 941 Mbits/sec [ 5] 4.00-5.00 sec 112 MBytes 937 Mbits/sec [ 5] 5.00-6.00 sec 112 MBytes 941 Mbits/sec [ 5] 6.00-7.00 sec 111 MBytes 933 Mbits/sec [ 5] 7.00-8.00 sec 112 MBytes 939 Mbits/sec [ 5] 8.00-9.00 sec 112 MBytes 936 Mbits/sec [ 5] 9.00-10.00 sec 112 MBytes 941 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.00 sec 1.10 GBytes 942 Mbits/sec 605 sender [ 5] 0.00-10.00 sec 1.09 GBytes 939 Mbits/sec receiver
iperf Done.
Iperf3-Server (my Laptop,192.168.0.21, reverse mode only):
Accepted connection from 192.168.0.19, port 56418
[ 5] local 192.168.0.21 port 5201 connected to 192.168.0.19 port 56420
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 5] 0.00-1.00 sec 115 MBytes 965 Mbits/sec 0 772 KBytes [ 5] 1.00-2.00 sec 112 MBytes 944 Mbits/sec 0 772 KBytes [ 5] 2.00-3.00 sec 111 MBytes 933 Mbits/sec 157 643 KBytes [ 5] 3.00-4.00 sec 112 MBytes 944 Mbits/sec 0 755 KBytes [ 5] 4.00-5.00 sec 111 MBytes 933 Mbits/sec 141 625 KBytes [ 5] 5.00-6.00 sec 112 MBytes 944 Mbits/sec 0 740 KBytes [ 5] 6.00-7.00 sec 111 MBytes 933 Mbits/sec 307 438 KBytes [ 5] 7.00-8.00 sec 111 MBytes 933 Mbits/sec 0 585 KBytes [ 5] 8.00-9.00 sec 112 MBytes 944 Mbits/sec 0 700 KBytes [ 5] 9.00-10.00 sec 112 MBytes 944 Mbits/sec 0 803 KBytes [ 5] 10.00-10.00 sec 0.00 Bytes 0.00 bits/sec 0 803 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bandwidth Retr [ 5] 0.00-10.00 sec 1.10 GBytes 942 Mbits/sec 605 sender [ 5] 0.00-10.00 sec 0.00 Bytes 0.00 bits/sec receiver
regards Frank
[1] https://github.com/frank-w/BPI-R2-4.14/tree/5.5-r64-netnext
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Andrew Lunn
maintainerRe: [PATCH net-next 3/6] dt-bindings: net: dsa: add new MT7531 binding to support MT7531
In reply to Landen ChaoQuoted 4 lines
Documentation/devicetree/bindings/net/dsa/mt7530.txt +4
-0+Example 4: + +ð { + gmac0: mac@0 {
Documentation/devicetree/bindings/net/dsa/mt7530.txt Example 3: MT7621: Port 5 is connected to external PHY: Port 5 -> external PHY. · line 329
Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/mt7530.txt +10
-0+ compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <1000>; + full-duplex; + pause; + }; + };
2500Base-X, but fixed link speed 1000?
Documentation/devicetree/bindings/net/dsa/mt7530.txt Example 3: MT7621: Port 5 is connected to external PHY: Port 5 -> external PHY. · line 377
Quoted 11 lines
Documentation/devicetree/bindings/net/dsa/mt7530.txt +11
-0+ port@6 { + reg = <6>; + label = "cpu"; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <1000>; + full-duplex; + pause; + };
Same here!
Andrew
Andrew Lunn
maintainerRe: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Landen ChaoQuoted 6 lines · Landen Chao
Add new support for MT7531:
MT7531 is the next generation of MT7530. It is also a 7-ports switch with 5 giga embedded phys, 2 cpu ports, and the same MAC logic of MT7530. Cpu port 6 only supports HSGMII interface. Cpu port 5 supports either RGMII or HSGMII in different HW sku.
Hi Landen
Looking at the code, you seem to treat HSGMII as 2500Base-X. Is this correct? Or is it SGMII over clocked to 2.5Gbps?
Andrew
Andrew Lunn
maintainerRe: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Landen ChaoQuoted 12 lines
drivers/net/dsa/mt7530.c +12
-0+static int +mt7531_ind_mmd_phy_read (struct mt7530_priv *priv,int port,int devad, +int regnum) +{ +struct mii_bus *bus = priv->bus; +struct mt7530_dummy_poll p; +u32 reg, val; +int ret; + +INIT_MT7530_DUMMY_POLL (&p, priv,MT7531_PHY_IAC ); + +mutex_lock_nested (&bus->mdio_lock,MDIO_MUTEX_NESTED );
drivers/net/dsa/mt7530.c mt7530_clear(struct mt7530_priv *priv, u32 reg, u32 val) · line 368
Quoted 10 lines
drivers/net/dsa/mt7530.c +10
-0+ + ret =readx_poll_timeout (_mt7530_unlocked_read, &p, val, + !(val &PHY_ACS_ST ),20 ,100000 ); +if (ret <0 ) { +dev_err (priv->dev,"poll timeout\n" ); + goto out; + } + + reg =MDIO_CL45_ADDR |MDIO_PHY_ADDR (port) |MDIO_DEV_ADDR (devad) | + regnum;
It might be better to call this mt7531_ind_c45_phy_read()
Quoted 11 lines
drivers/net/dsa/mt7530.c +11
-0+static int +mt7531_ind_phy_read (struct dsa_switch *ds,int port,int regnum) +{ +struct mt7530_priv *priv = ds->priv; +struct mii_bus *bus = priv->bus; +struct mt7530_dummy_poll p; +int ret; +u32 val; + +INIT_MT7530_DUMMY_POLL (&p, priv,MT7531_PHY_IAC ); +
drivers/net/dsa/mt7530.c static int mt7530_phy_write(struct dsa_switch *ds, int port, int regnum, · line 714
Quoted 10 lines
drivers/net/dsa/mt7530.c +10
-0+mutex_lock_nested (&bus->mdio_lock,MDIO_MUTEX_NESTED ); + + ret =readx_poll_timeout (_mt7530_unlocked_read, &p, val, + !(val &PHY_ACS_ST ),20 ,100000 ); +if (ret <0 ) { +dev_err (priv->dev,"poll timeout\n" ); + goto out; + } + + val =MDIO_CL22_READ |MDIO_PHY_ADDR (port) |MDIO_REG_ADDR (regnum);
This is then mt7531_ind_c22_phy_read().
And then you can add a wrapper around this to provide
mt7531_phy_read() which can do both C22 and C45.
drivers/net/dsa/mt7530.c static const struct mt753x_info mt753x_table[] = { · line 2349
Quoted 4 lines
drivers/net/dsa/mt7530.c +4
-0+ [ID_MT7531] = { + .id = ID_MT7531, + .setup = mt7531_setup, + .phy_read = mt7531_ind_phy_read,
and use it here.
Andrew
Andrew Lunn
maintainerRe: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Landen ChaoQuoted 4 lines
drivers/net/dsa/mt7530.c +4
-0+static int mt7531_setup (struct dsa_switch *ds) +{ +/* Enable PHY power, since phy_device has not yet been created +* provided for phy_[read,write]_mmd_indirect is called, we provide
drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1617
Quoted 10 lines
drivers/net/dsa/mt7530.c +10
-0+* our own mt7531_ind_mmd_phy_[read,write] to complete this +* function. +*/ + val =mt7531_ind_mmd_phy_read (priv,0 ,PHY_DEV1F , +MT7531_PHY_DEV1F_REG_403 ); + val |=MT7531_PHY_EN_BYPASS_MODE ; + val &= ~MT7531_PHY_POWER_OFF ; +mt7531_ind_mmd_phy_write (priv,0 ,PHY_DEV1F , +MT7531_PHY_DEV1F_REG_403 , val); +
Is this power to all the PHYs? Or just one?
Andrew
Andrew Lunn
maintainerRe: [PATCH net-next 5/6] arm64: dts: mt7622: add mt7531 dsa to mt7622-rfb1 board
In reply to Landen Chaoarch/arm64/boot/dts/mediatek/mt7622-rfb1.dts line 168
Quoted 11 lines
arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts +11
-0+ port@6 { + reg = <6>; + label = "cpu"; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + };
This fixed-link should not be needed. The DSA driver is supposed to configure the CPU port to its fastest speed by default. 2500 is the fastest speed a 2500Base-X link can do...
Andrew
Vladimir Oltean
maintainerRe: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Andrew LunnHi Landen, Andrew,
Quoted 9 lines · Andrew Lunn
Quoted 6 lines · Landen Chao
Add new support for MT7531:
MT7531 is the next generation of MT7530. It is also a 7-ports switch with 5 giga embedded phys, 2 cpu ports, and the same MAC logic of MT7530. Cpu port 6 only supports HSGMII interface. Cpu port 5 supports either RGMII or HSGMII in different HW sku.
Quoted 6 lines
Hi Landen
Looking at the code, you seem to treat HSGMII as 2500Base-X. Is this correct? Or is it SGMII over clocked to 2.5Gbps?
Andrew
I think the better question is: what is being understood by HSGMII? What does the AN base page look like? Do you support AN with the 2500 baud speed? Do you support AN with lower speeds? Do you support lower speeds at all? What PHYs do you interoperate with in this mode? If you don't support AN, then what's so SGMII about it? And for that matter, if you don't support AN, what's so 2500Base-X (802.3z) about it? I see you unconditionally force the speed and disable AN in this mode. Do you have any reference for what SerDes protocol your hardware implements in this mode?
Thanks,
-Vladimir
Re: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Andrew LunnQuoted 8 lines · On Tue, 10 Dec 2019 17:35:57 +0100 Andrew Lunn <[email protected]> wrote:
Quoted 6 lines · Landen Chao
Add new support for MT7531:
MT7531 is the next generation of MT7530. It is also a 7-ports switch with 5 giga embedded phys, 2 cpu ports, and the same MAC logic of MT7530. Cpu port 6 only supports HSGMII interface. Cpu port 5 supports either RGMII or HSGMII in different HW sku.
Quoted 6 lines
Hi Landen
Looking at the code, you seem to treat HSGMII as 2500Base-X. Is this correct? Or is it SGMII over clocked to 2.5Gbps?
Andrew
How would that work? Would 10 and 100 be overclocked to 25 and 250?
Andrew Lunn
maintainerRe: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
Quoted 11 lines · Marek Behun
Quoted 8 lines · On Tue, 10 Dec 2019 17:35:57 +0100 Andrew Lunn <[email protected]> wrote:
Quoted 6 lines · Landen Chao
Add new support for MT7531:
MT7531 is the next generation of MT7530. It is also a 7-ports switch with 5 giga embedded phys, 2 cpu ports, and the same MAC logic of MT7530. Cpu port 6 only supports HSGMII interface. Cpu port 5 supports either RGMII or HSGMII in different HW sku.
Quoted 8 lines
Quoted 6 lines
Hi Landen
Looking at the code, you seem to treat HSGMII as 2500Base-X. Is this correct? Or is it SGMII over clocked to 2.5Gbps?
Andrew
How would that work? Would 10 and 100 be overclocked to 25 and 250?
No. SGMII clocked up to 2.5G does not support any of the lower speeds. And inband signalling does not make much sense, the control word is all wrong.
Andrew
Re: [PATCH net-next 3/6] dt-bindings: net: dsa: add new MT7531 binding to support MT7531
In reply to Andrew LunnHi Andrew,
Quoted 8 lines · Andrew Lunn
Quoted 8 lines
Documentation/devicetree/bindings/net/dsa/mt7530.txt +8
-0+Example 4: + +ð { + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; +
Quoted 8 lines
Documentation/devicetree/bindings/net/dsa/mt7530.txt Example 3: MT7621: Port 5 is connected to external PHY: Port 5 -> external PHY. · line 329
Quoted 6 lines
Documentation/devicetree/bindings/net/dsa/mt7530.txt +6
-0+ fixed-link { + speed = <1000>; + full-duplex; + pause; + }; + };2500Base-X, but fixed link speed 1000?
fixed-link speed should be 2500. I will update it.
Quoted 14 lines
Documentation/devicetree/bindings/net/dsa/mt7530.txt Example 3: MT7621: Port 5 is connected to external PHY: Port 5 -> external PHY. · line 377
Quoted 12 lines
Documentation/devicetree/bindings/net/dsa/mt7530.txt +11
-0+ port@6 { + reg = <6>; + label = "cpu"; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <1000>; + full-duplex; + pause; + };Same here!
I will update it or remove fixed-link block as the discussion in dts thread.
Quoted 2 lines
Andrew
regards Landen
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Andrew LunnHi Andrew,
Quoted 8 lines · Andrew Lunn
Quoted 6 lines · Landen Chao
Add new support for MT7531:
MT7531 is the next generation of MT7530. It is also a 7-ports switch with 5 giga embedded phys, 2 cpu ports, and the same MAC logic of MT7530. Cpu port 6 only supports HSGMII interface. Cpu port 5 supports either RGMII or HSGMII in different HW sku.
Quoted 4 lines
Hi Landen
Looking at the code, you seem to treat HSGMII as 2500Base-X. Is this correct? Or is it SGMII over clocked to 2.5Gbps?
After re-read MT7622 tread[0] again, and according to the configurable part of this IP, it is closer to 2500Base-X definition:
``PHY_INTERFACE_MODE_2500BASEX``
This defines a variant of 1000BASE-X which is clocked 2.5 times
faster, than the 802.3 standard giving a fixed bit rate of 3.125Gbaud.
If HSGMII means SGMII over clocked to 2.5Gbps, the introduction needs to be changed to "support SGMII/1000Base-X/2500Base-x".
[0]:
https://patchwork.kernel.org/patch/11057527/
Quoted 2 lines
Andrew
Regards Landen
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Andrew LunnQuoted 8 lines · Andrew Lunn
Quoted 8 lines
drivers/net/dsa/mt7530.c +8
-0+static int mt7531_setup (struct dsa_switch *ds) +{ +/* Enable PHY power, since phy_device has not yet been created +* provided for phy_[read,write]_mmd_indirect is called, we provide +* our own mt7531_ind_mmd_phy_[read,write] to complete this +* function. +*/ + val = mt7531_ind_mmd_phy_read(priv, 0, PHY_DEV1F,
Quoted 8 lines
drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1617
Quoted 6 lines
drivers/net/dsa/mt7530.c +6
-0+ MT7531_PHY_DEV1F_REG_403); + val |=MT7531_PHY_EN_BYPASS_MODE ; + val &= ~MT7531_PHY_POWER_OFF ; +mt7531_ind_mmd_phy_write (priv,0 ,PHY_DEV1F , +MT7531_PHY_DEV1F_REG_403 , val); +Is this power to all the PHYs? Or just one?
This is an internal circuit that controls the power to all PHYs before Generic MII registers are available.
Landen
Quoted 2 lines
Andrew
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Andrew LunnQuoted 49 lines · Andrew Lunn
Quoted 12 lines
drivers/net/dsa/mt7530.c +12
-0+static int +mt7531_ind_mmd_phy_read (struct mt7530_priv *priv,int port,int devad, +int regnum) +{ +struct mii_bus *bus = priv->bus; +struct mt7530_dummy_poll p; +u32 reg, val; +int ret; + +INIT_MT7530_DUMMY_POLL (&p, priv,MT7531_PHY_IAC ); + +mutex_lock_nested (&bus->mdio_lock,MDIO_MUTEX_NESTED );drivers/net/dsa/mt7530.c mt7530_clear(struct mt7530_priv *priv, u32 reg, u32 val) · line 368
Quoted 10 lines
drivers/net/dsa/mt7530.c +10
-0+ + ret =readx_poll_timeout (_mt7530_unlocked_read, &p, val, + !(val &PHY_ACS_ST ),20 ,100000 ); +if (ret <0 ) { +dev_err (priv->dev,"poll timeout\n" ); + goto out; + } + + reg =MDIO_CL45_ADDR |MDIO_PHY_ADDR (port) |MDIO_DEV_ADDR (devad) | + regnum;It might be better to call this
mt7531_ind_c45_phy_read()Quoted 11 lines
drivers/net/dsa/mt7530.c +11
-0+static int +mt7531_ind_phy_read (struct dsa_switch *ds,int port,int regnum) +{ +struct mt7530_priv *priv = ds->priv; +struct mii_bus *bus = priv->bus; +struct mt7530_dummy_poll p; +int ret; +u32 val; + +INIT_MT7530_DUMMY_POLL (&p, priv,MT7531_PHY_IAC ); +drivers/net/dsa/mt7530.c static int mt7530_phy_write(struct dsa_switch *ds, int port, int regnum, · line 714
Quoted 10 lines
drivers/net/dsa/mt7530.c +10
-0+mutex_lock_nested (&bus->mdio_lock,MDIO_MUTEX_NESTED ); + + ret =readx_poll_timeout (_mt7530_unlocked_read, &p, val, + !(val &PHY_ACS_ST ),20 ,100000 ); +if (ret <0 ) { +dev_err (priv->dev,"poll timeout\n" ); + goto out; + } + + val =MDIO_CL22_READ |MDIO_PHY_ADDR (port) |MDIO_REG_ADDR (regnum);This is then
mt7531_ind_c22_phy_read().
Quoted 3 lines
And then you can add a wrapper around this to provide
mt7531_phy_read()which can do both C22 and C45.
I'll update the code base on above suggestion.
Quoted 7 lines
drivers/net/dsa/mt7530.c static const struct mt753x_info mt753x_table[] = { · line 2349
Quoted 5 lines
drivers/net/dsa/mt7530.c +4
-0+ [ID_MT7531] = { + .id = ID_MT7531, + .setup = mt7531_setup, + .phy_read = mt7531_ind_phy_read,and use it here.
Do you also hint at using the same number of parameters for mt7531_ind_c22_phy_read() and mt7531_ind_c45_phy_read()?
Landen
Quoted 2 lines
Andrew
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH net-next 5/6] arm64: dts: mt7622: add mt7531 dsa to mt7622-rfb1 board
In reply to Andrew LunnQuoted 7 lines · Andrew Lunn
Quoted 7 lines
arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts +7
-0+ port@6 { + reg = <6>; + label = "cpu"; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link {
Quoted 8 lines
arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts line 117
Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts +4
-0+ speed = <2500>; + full-duplex; + pause; + };This fixed-link should not be needed. The DSA driver is supposed to configure the CPU port to its fastest speed by default. 2500 is the fastest speed a 2500Base-X link can do...
I'll add the cpu port logic to use the fastest speed by default. It also needs to modify the mt753x_phylink_mac_config() logic.
Landen
Quoted 2 lines
Andrew
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Andrew Lunn
maintainerRe: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Landen ChaoQuoted 2 lines
Do you also hint at using the same number of parameters for
mt7531_ind_c22_phy_read()andmt7531_ind_c45_phy_read()?
That is up to you. It just seems like your MDIO bus can do both C22 and C45. And somebody might connect an external C45 PHY, so you might as well support it.
Andrew
Re: [PATCH net-next 1/6] net: dsa: mt7530: Refine message in Kconfig
In reply to Landen ChaoQuoted 4 lines · Landen Chao
Refine message in
Kconfigwith fixing typo and an explicit MT7621 support.Signed-off-by Landen Chao <[email protected]>Signed-off-by Sean Wang <[email protected]>
Signature · 1 line
Florian
Re: [PATCH net-next 2/6] net: dsa: mt7530: Extend device data ready for adding a new hardware
In reply to Landen ChaoQuoted 10 lines · Landen Chao
Add a structure holding required operations for each device such as device initialization, PHY port read or write, a checker whether PHY interface is supported on a certain port, MAC port setup for either bus pad or a specific PHY interface.
The patch is done for ready adding a new hardware MT7531.
Signed-off-by Landen Chao <[email protected]>Signed-off-by Sean Wang <[email protected]>---
[snip]
drivers/net/dsa/mt7530.c mt7530_fdb_write(struct mt7530_priv *priv, u16 vid, · line 428
Quoted 10 lines
drivers/net/dsa/mt7530.c +1
-1@@ -425,7 +425,7 @@ mt7530_fdb_write(struct mt7530_priv *priv, u16 vid, }static int -mt7530_pad_clk_setup (struct dsa_switch *ds,int mode) +mt7530_pad_clk_setup (struct dsa_switch *ds,phy_interface_t mode)
Here you pass a phy_interface_t argument but not in mt7632_pad_clk_setup().
Quoted 4 lines
drivers/net/dsa/mt7530.c +4
-0+static int +mt7530_pad_setup (struct dsa_switch *ds,const struct phylink_link_state *state) +{ +struct mt7530_priv *priv = ds->priv;
drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1441
Quoted 10 lines
drivers/net/dsa/mt7530.c +10
-0+ +/* Setup TX circuit incluing relevant PAD and driving */ +mt7530_pad_clk_setup (ds, state->interface); + +if (priv->id ==ID_MT7530 ) { +/* Setup RX circuit, relevant PAD and driving on the +* host which must be placed after the setup on the +* device side is all finished. +*/ +mt7623_pad_clk_setup (ds);
Would not it make sense to pass it down here as well for consistency?
[snip]
drivers/net/dsa/mt7530.c mt7530_probe(struct mdio_device *mdiodev) · line 1776
Quoted 12 lines
drivers/net/dsa/mt7530.c +6
-2@@ -1660,8 +1768,19 @@ mt7530_probe(struct mdio_device *mdiodev)/* Get the hardware identifier from the devicetree node. * We will need it for some of the clock and regulator setup. */ - priv->id = (unsigned int )(unsigned long ) -of_device_get_match_data (&mdiodev->dev); + priv->info =of_device_get_match_data (&mdiodev->dev); +if (!priv->info) +return -EINVAL ; + +/* Sanity check if these required device operstaions are filled +* properly.
Typo: operations.
Other than that, this looks okay to me.
Signature · 1 line
Florian
Re: [PATCH net-next 3/6] dt-bindings: net: dsa: add new MT7531 binding to support MT7531
In reply to Landen ChaoQuoted 5 lines · Landen Chao
Add devicetree binding to support the compatible mt7531 switch as used in the MediaTek MT7531 switch.
Signed-off-by Sean Wang <[email protected]>Signed-off-by Landen Chao <[email protected]>
With the comments from Andrew fixed, this looks good to me.
Signature · 1 line
Florian
Re: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Landen ChaoQuoted 12 lines · Landen Chao
Add new support for MT7531:
MT7531 is the next generation of MT7530. It is also a 7-ports switch with 5 giga embedded phys, 2 cpu ports, and the same MAC logic of MT7530. Cpu port 6 only supports HSGMII interface. Cpu port 5 supports either RGMII or HSGMII in different HW sku. Due to HSGMII interface support, pll, and pad setting are different from MT7530. This patch adds different initial setting of MT7531.
Signed-off-by Landen Chao <[email protected]>Signed-off-by Sean Wang <[email protected]>---
[snip]
drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1616
Quoted 11 lines
drivers/net/dsa/mt7530.c +11
-0+/* Enable PHY power, since phy_device has not yet been created +* provided for phy_[read,write]_mmd_indirect is called, we provide +* our own mt7531_ind_mmd_phy_[read,write] to complete this +* function. +*/ + val =mt7531_ind_mmd_phy_read (priv,0 ,PHY_DEV1F , +MT7531_PHY_DEV1F_REG_403 ); + val |=MT7531_PHY_EN_BYPASS_MODE ; + val &= ~MT7531_PHY_POWER_OFF ; +mt7531_ind_mmd_phy_write (priv,0 ,PHY_DEV1F , +MT7531_PHY_DEV1F_REG_403 , val);
You are doing this for port 0 only, is that because this broadcasts to all internal PHYs as well, or is it enough to somehow do it just for port 0? It sounds like you might want to make this operation a bit more scoped, if you have an external PHY that also responds to broadcast MDIO writes this could possibly cause some unattended effects, no?
[snip]
Quoted 6 lines
drivers/net/dsa/mt7530.c +6
-0+static int mt7531_rgmii_setup (struct mt7530_priv *priv,u32 port) +{ +u32 val; + +if (port !=5 ) { + dev_err(priv->dev, "RGMII mode is not available for port %d\n",
drivers/net/dsa/mt7530.c mt7530_mac_setup(struct dsa_switch *ds, int port, unsigned int mode, · line 1924
Quoted 10 lines
drivers/net/dsa/mt7530.c +10
-0+ port); +return -EINVAL ; + } + + val =mt7530_read (priv,MT7531_CLKGEN_CTRL ); + val |=GP_CLK_EN ; + val &= ~GP_MODE_MASK ; + val |=GP_MODE (MT7531_GP_MODE_RGMII ); + val |=TXCLK_NO_REVERSE ; + val |=RXCLK_NO_DELAY ;
You actually need to look at the port's phy_interface_t value to determine whether the delays should be set/clear in either RX or TX directions.
[snip]
drivers/net/dsa/mt7530.c static void mt753x_phylink_mac_config(struct dsa_switch *ds, int port, · line 2106
Quoted 3 lines
drivers/net/dsa/mt7530.c +2
-1-if (phylink_autoneg_inband (mode)) { +if (phylink_autoneg_inband (mode) && + state->interface !=PHY_INTERFACE_MODE_SGMII ) {
So you don't support in-band auto-negotiation for 1000BaseX either?
[snip]
Quoted 4 lines
drivers/net/dsa/mt7530.c +0
-0@@ -1590,9 +2197,20 @@ static void mt753x_phylink_validate(struct dsa_switch *ds, int port,phylink_set_port_modes (mask);phylink_set (mask, Autoneg);
drivers/net/dsa/mt7530.c static void mt753x_phylink_validate(struct dsa_switch *ds, int port, · line 2207
Quoted 10 lines
drivers/net/dsa/mt7530.c +7
-2-if (state->interface ==PHY_INTERFACE_MODE_TRGMII ) { +switch (state->interface) { +case PHY_INTERFACE_MODE_TRGMII : phylink_set(mask, 1000baseT_Full); - }else { +break ; +case PHY_INTERFACE_MODE_1000BASEX : +case PHY_INTERFACE_MODE_2500BASEX : + phylink_set(mask, 1000baseX_Full); + phylink_set(mask, 2500baseX_Full);
Did you intend this to be:
case PHY_INTERFACE_MODE_2500BASEX: phylink_set(mask, 2500baseX_Full); /* fall through */ case PHY_INTERFACE_MODE_1000BASEX: phylink_set(mask, 1000baseX_Full); break;
?
[snip]
drivers/net/dsa/mt7530.h enum mt7530_vlan_port_attr { · line 297
Quoted 13 lines
drivers/net/dsa/mt7530.h +13
-0+/* Register for PHY Indirect Access Control */ +#define MT7531_PHY_IAC 0x701C +#define PHY_ACS_ST BIT(31) +#define MDIO_REG_ADDR_MASK (0x1f << 25) +#define MDIO_PHY_ADDR_MASK (0x1f << 20) +#define MDIO_CMD_MASK (0x3 << 18) +#define MDIO_ST_MASK (0x3 << 16) +#define MDIO_RW_DATA_MASK (0xffff) +#define MDIO_REG_ADDR (x) (((x) & 0x1f) << 25) +#define MDIO_DEV_ADDR (x) (((x) & 0x1f) << 25) +#define MDIO_PHY_ADDR (x) (((x) & 0x1f) << 20) +#define MDIO_CMD (x) (((x) & 0x3) << 18) +#define MDIO_ST (x) (((x) & 0x3) << 16)
I would suggest names that are more scoped because these could easily collide with existing of future definitions from include/linux/mdio.h.
Quoted 14 lines
drivers/net/dsa/mt7530.h +14
-0+ +enum mt7531_phy_iac_cmd { +MT7531_MDIO_ADDR =0 , +MT7531_MDIO_WRITE =1 , +MT7531_MDIO_READ =2 , +MT7531_MDIO_READ_CL45 =3 , +}; + +/* MDIO_ST: MDIO start field */ +enum mt7531_mdio_st { +MT7531_MDIO_ST_CL45 =0 , +MT7531_MDIO_ST_CL22 =1 , +}; +
drivers/net/dsa/mt7530.h enum mt7530_vlan_port_attr { · line 321
Quoted 10 lines
drivers/net/dsa/mt7530.h +10
-0+#define MDIO_CL22_READ (MDIO_ST(MT7531_MDIO_ST_CL22) | \ + MDIO_CMD(MT7531_MDIO_READ)) +#define MDIO_CL22_WRITE (MDIO_ST(MT7531_MDIO_ST_CL22) | \ + MDIO_CMD(MT7531_MDIO_WRITE)) +#define MDIO_CL45_ADDR (MDIO_ST(MT7531_MDIO_ST_CL45) | \ + MDIO_CMD(MT7531_MDIO_ADDR)) +#define MDIO_CL45_READ (MDIO_ST(MT7531_MDIO_ST_CL45) | \ + MDIO_CMD(MT7531_MDIO_READ)) +#define MDIO_CL45_WRITE (MDIO_ST(MT7531_MDIO_ST_CL45) | \ + MDIO_CMD(MT7531_MDIO_WRITE))
Likewise.
Signature · 1 line
Florian
Re: [PATCH net-next 2/6] net: dsa: mt7530: Extend device data ready for adding a new hardware
In reply to Florian FainelliQuoted 27 lines · Florian Fainelli
Quoted 10 lines · Landen Chao
Add a structure holding required operations for each device such as device initialization, PHY port read or write, a checker whether PHY interface is supported on a certain port, MAC port setup for either bus pad or a specific PHY interface.
The patch is done for ready adding a new hardware MT7531.
Signed-off-by Landen Chao <[email protected]>Signed-off-by Sean Wang <[email protected]>---
[snip]
drivers/net/dsa/mt7530.c mt7530_fdb_write(struct mt7530_priv *priv, u16 vid, · line 428
Quoted 10 lines
drivers/net/dsa/mt7530.c +1
-1@@ -425,7 +425,7 @@ mt7530_fdb_write(struct mt7530_priv *priv, u16 vid, }static int -mt7530_pad_clk_setup (struct dsa_switch *ds,int mode) +mt7530_pad_clk_setup (struct dsa_switch *ds,phy_interface_t mode)Here you pass a
phy_interface_targument but not inmt7632_pad_clk_setup().
Quoted 16 lines
Quoted 4 lines
drivers/net/dsa/mt7530.c +4
-0+static int +mt7530_pad_setup (struct dsa_switch *ds,const struct phylink_link_state *state) +{ +struct mt7530_priv *priv = ds->priv;drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1441
Quoted 10 lines
drivers/net/dsa/mt7530.c +10
-0+ +/* Setup TX circuit incluing relevant PAD and driving */ +mt7530_pad_clk_setup (ds, state->interface); + +if (priv->id ==ID_MT7530 ) { +/* Setup RX circuit, relevant PAD and driving on the +* host which must be placed after the setup on the +* device side is all finished. +*/ +mt7623_pad_clk_setup (ds);Would not it make sense to pass it down here as well for consistency?
mt7623_pad_clk() contains the setting for PHY_INTERFACE_MODE_TRGMII. It is really better to pass phy_interface_t for error handling.
Quoted 17 lines
[snip]
drivers/net/dsa/mt7530.c mt7530_probe(struct mdio_device *mdiodev) · line 1776
Quoted 12 lines
drivers/net/dsa/mt7530.c +6
-2@@ -1660,8 +1768,19 @@ mt7530_probe(struct mdio_device *mdiodev)/* Get the hardware identifier from the devicetree node. * We will need it for some of the clock and regulator setup. */ - priv->id = (unsigned int )(unsigned long ) -of_device_get_match_data (&mdiodev->dev); + priv->info =of_device_get_match_data (&mdiodev->dev); +if (!priv->info) +return -EINVAL ; + +/* Sanity check if these required device operstaions are filled +* properly. Typo: operations.
Oops, sorry. I'll correct it.
Landen
Quoted 2 lines
Other than that, this looks okay to me.
Re: [PATCH net-next 2/6] net: dsa: mt7530: Extend device data ready for adding a new hardware
In reply to Florian FainelliQuoted 27 lines · Florian Fainelli
Quoted 10 lines · Landen Chao
Add a structure holding required operations for each device such as device initialization, PHY port read or write, a checker whether PHY interface is supported on a certain port, MAC port setup for either bus pad or a specific PHY interface.
The patch is done for ready adding a new hardware MT7531.
Signed-off-by Landen Chao <[email protected]>Signed-off-by Sean Wang <[email protected]>---
[snip]
drivers/net/dsa/mt7530.c mt7530_fdb_write(struct mt7530_priv *priv, u16 vid, · line 428
Quoted 10 lines
drivers/net/dsa/mt7530.c +1
-1@@ -425,7 +425,7 @@ mt7530_fdb_write(struct mt7530_priv *priv, u16 vid, }static int -mt7530_pad_clk_setup (struct dsa_switch *ds,int mode) +mt7530_pad_clk_setup (struct dsa_switch *ds,phy_interface_t mode)Here you pass a
phy_interface_targument but not inmt7632_pad_clk_setup().
Quoted 16 lines
Quoted 4 lines
drivers/net/dsa/mt7530.c +4
-0+static int +mt7530_pad_setup (struct dsa_switch *ds,const struct phylink_link_state *state) +{ +struct mt7530_priv *priv = ds->priv;drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1441
Quoted 10 lines
drivers/net/dsa/mt7530.c +10
-0+ +/* Setup TX circuit incluing relevant PAD and driving */ +mt7530_pad_clk_setup (ds, state->interface); + +if (priv->id ==ID_MT7530 ) { +/* Setup RX circuit, relevant PAD and driving on the +* host which must be placed after the setup on the +* device side is all finished. +*/ +mt7623_pad_clk_setup (ds);Would not it make sense to pass it down here as well for consistency?
mt7623_pad_clk() contains the setting for PHY_INTERFACE_MODE_TRGMII. It is really better to pass phy_interface_t for error handling.
Quoted 17 lines
[snip]
drivers/net/dsa/mt7530.c mt7530_probe(struct mdio_device *mdiodev) · line 1776
Quoted 12 lines
drivers/net/dsa/mt7530.c +6
-2@@ -1660,8 +1768,19 @@ mt7530_probe(struct mdio_device *mdiodev)/* Get the hardware identifier from the devicetree node. * We will need it for some of the clock and regulator setup. */ - priv->id = (unsigned int )(unsigned long ) -of_device_get_match_data (&mdiodev->dev); + priv->info =of_device_get_match_data (&mdiodev->dev); +if (!priv->info) +return -EINVAL ; + +/* Sanity check if these required device operstaions are filled +* properly. Typo: operations.
Oops, sorry. I'll correct it.
Landen
Quoted 2 lines
Other than that, this looks okay to me.
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Andrew LunnQuoted 6 lines · Andrew Lunn
Quoted 2 lines
Do you also hint at using the same number of parameters for
mt7531_ind_c22_phy_read()andmt7531_ind_c45_phy_read()?That is up to you. It just seems like your MDIO bus can do both C22 and C45. And somebody might connect an external C45 PHY, so you might as well support it.
Yes, it is better to support external C45 PHY. Thanks for your advice.
Landen
Quoted 2 lines
Andrew
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
In reply to Florian FainelliQuoted 26 lines · Florian Fainelli
Quoted 12 lines · Landen Chao
Add new support for MT7531:
MT7531 is the next generation of MT7530. It is also a 7-ports switch with 5 giga embedded phys, 2 cpu ports, and the same MAC logic of MT7530. Cpu port 6 only supports HSGMII interface. Cpu port 5 supports either RGMII or HSGMII in different HW sku. Due to HSGMII interface support, pll, and pad setting are different from MT7530. This patch adds different initial setting of MT7531.
Signed-off-by Landen Chao <[email protected]>Signed-off-by Sean Wang <[email protected]>---
[snip]
Quoted 9 lines
drivers/net/dsa/mt7530.c +9
-0+/* Enable PHY power, since phy_device has not yet been created +* provided for phy_[read,write]_mmd_indirect is called, we provide +* our own mt7531_ind_mmd_phy_[read,write] to complete this +* function. +*/ + val =mt7531_ind_mmd_phy_read (priv,0 ,PHY_DEV1F , +MT7531_PHY_DEV1F_REG_403 ); + val |=MT7531_PHY_EN_BYPASS_MODE ; + val &= ~MT7531_PHY_POWER_OFF ;
Quoted 8 lines
drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1616
Quoted 2 lines
drivers/net/dsa/mt7530.c +2
-0+mt7531_ind_mmd_phy_write (priv,0 ,PHY_DEV1F , +MT7531_PHY_DEV1F_REG_403 , val);You are doing this for port 0 only, is that because this broadcasts to all internal PHYs as well, or is it enough to somehow do it just for port 0? It sounds like you might want to make this operation a bit more scoped, if you have an external PHY that also responds to broadcast MDIO writes this could possibly cause some unattended effects, no?
All internal PHY addresses can be used to access the same PHY_DEV1F group of registers.
I think the port "0" here must be changed to reference the "first internal phy address" to prevent the situation you mentioned.
Quoted 15 lines
[snip]
Quoted 12 lines
drivers/net/dsa/mt7530.c +12
-0+static int mt7531_rgmii_setup (struct mt7530_priv *priv,u32 port) +{ +u32 val; + +if (port !=5 ) { +dev_err (priv->dev,"RGMII mode is not available for port %d\n" , + port); +return -EINVAL ; + } + + val =mt7530_read (priv,MT7531_CLKGEN_CTRL ); + val |=GP_CLK_EN ;
Quoted 8 lines
drivers/net/dsa/mt7530.c mt7530_mac_setup(struct dsa_switch *ds, int port, unsigned int mode, · line 1924
Quoted 4 lines
drivers/net/dsa/mt7530.c +4
-0+ val &= ~GP_MODE_MASK ; + val |=GP_MODE (MT7531_GP_MODE_RGMII ); + val |=TXCLK_NO_REVERSE ; + val |=RXCLK_NO_DELAY ;You actually need to look at the port's
phy_interface_tvalue to determine whether the delays should be set/clear in either RX or TX directions.
Sure. Thanks for your advice.
Quoted 8 lines
[snip]
drivers/net/dsa/mt7530.c static void mt753x_phylink_mac_config(struct dsa_switch *ds, int port, · line 2106
Quoted 3 lines
drivers/net/dsa/mt7530.c +2
-1-if (phylink_autoneg_inband (mode)) { +if (phylink_autoneg_inband (mode) && + state->interface !=PHY_INTERFACE_MODE_SGMII ) {So you don't support in-band auto-negotiation for 1000BaseX either?
According to the user manual I have, it only provides the configure 10M +100M+1000M AN mode/1000M force mode/2500M force mode, so I mapping them to SGMII/1000BaseX/2500BaseX. The user friendly part of this IP wraps too much detail to map to the spec. I'll try to dig it out.
Quoted 20 lines
[snip]
Quoted 4 lines
drivers/net/dsa/mt7530.c +0
-0@@ -1590,9 +2197,20 @@ static void mt753x_phylink_validate(struct dsa_switch *ds, int port,phylink_set_port_modes (mask);phylink_set (mask, Autoneg);drivers/net/dsa/mt7530.c static void mt753x_phylink_validate(struct dsa_switch *ds, int port, · line 2207
Quoted 10 lines
drivers/net/dsa/mt7530.c +7
-2-if (state->interface ==PHY_INTERFACE_MODE_TRGMII ) { +switch (state->interface) { +case PHY_INTERFACE_MODE_TRGMII : phylink_set(mask, 1000baseT_Full); - }else { +break ; +case PHY_INTERFACE_MODE_1000BASEX : +case PHY_INTERFACE_MODE_2500BASEX : + phylink_set(mask, 1000baseX_Full); + phylink_set(mask, 2500baseX_Full);Did you intend this to be:
Quoted 8 lines
case PHY_INTERFACE_MODE_2500BASEX: phylink_set(mask, 2500baseX_Full); /* fall through */ case PHY_INTERFACE_MODE_1000BASEX: phylink_set(mask, 1000baseX_Full); break;?
As the user manual mentioned, it is more likely to be:
case PHY_INTERFACE_MODE_2500BASEX:
phylink_set(mask, 2500baseX_Full); break;
case PHY_INTERFACE_MODE_1000BASEX:
phylink_set(mask, 1000baseX_Full); break;
Quoted 18 lines
[snip]
drivers/net/dsa/mt7530.h enum mt7530_vlan_port_attr { · line 297
Quoted 13 lines
drivers/net/dsa/mt7530.h +13
-0+/* Register for PHY Indirect Access Control */ +#define MT7531_PHY_IAC 0x701C +#define PHY_ACS_ST BIT(31) +#define MDIO_REG_ADDR_MASK (0x1f << 25) +#define MDIO_PHY_ADDR_MASK (0x1f << 20) +#define MDIO_CMD_MASK (0x3 << 18) +#define MDIO_ST_MASK (0x3 << 16) +#define MDIO_RW_DATA_MASK (0xffff) +#define MDIO_REG_ADDR (x) (((x) & 0x1f) << 25) +#define MDIO_DEV_ADDR (x) (((x) & 0x1f) << 25) +#define MDIO_PHY_ADDR (x) (((x) & 0x1f) << 20) +#define MDIO_CMD (x) (((x) & 0x3) << 18) +#define MDIO_ST (x) (((x) & 0x3) << 16)I would suggest names that are more scoped because these could easily collide with existing of future definitions from
include/linux/mdio.h.
Sure, I'll add "MT7531_" as the prefix.
Quoted 19 lines
Quoted 19 lines
drivers/net/dsa/mt7530.h +18
-0+ +enum mt7531_phy_iac_cmd { +MT7531_MDIO_ADDR =0 , +MT7531_MDIO_WRITE =1 , +MT7531_MDIO_READ =2 , +MT7531_MDIO_READ_CL45 =3 , +}; + +/* MDIO_ST: MDIO start field */ +enum mt7531_mdio_st { +MT7531_MDIO_ST_CL45 =0 , +MT7531_MDIO_ST_CL22 =1 , +}; + +#define MDIO_CL22_READ (MDIO_ST(MT7531_MDIO_ST_CL22) | \ + MDIO_CMD(MT7531_MDIO_READ)) +#define MDIO_CL22_WRITE (MDIO_ST(MT7531_MDIO_ST_CL22) | \ + MDIO_CMD(MT7531_MDIO_WRITE))
Quoted 8 lines
drivers/net/dsa/mt7530.h enum mt7530_vlan_port_attr { · line 321
Quoted 6 lines
drivers/net/dsa/mt7530.h +6
-0+#define MDIO_CL45_ADDR (MDIO_ST(MT7531_MDIO_ST_CL45) | \ + MDIO_CMD(MT7531_MDIO_ADDR)) +#define MDIO_CL45_READ (MDIO_ST(MT7531_MDIO_ST_CL45) | \ + MDIO_CMD(MT7531_MDIO_READ)) +#define MDIO_CL45_WRITE (MDIO_ST(MT7531_MDIO_ST_CL45) | \ + MDIO_CMD(MT7531_MDIO_WRITE))Likewise.
I'll add "MT7531_" as the prefix.
Landen