Skip to contentSkip to conversation

net-next: dsa: add Mediatek MT7530 support

PATCH Superseded [email protected] 6 participants 24 messages Mar 21, 2017 – Mar 28, 2017

Subsystems (7)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 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

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                           | 1172 ++++++++++++++++++++
 drivers/net/dsa/mt7530.h                           |  382 +++++++
 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                                  |  117 ++
 13 files changed, 1794 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
#1 lore raw

PATCH v2 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
new file mode 100644
index 0000000..a9bc27b
@@ -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
#3 lore raw

PATCH v2 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  | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 127 insertions(+)
 create mode 100644 net/dsa/tag_mtk.c
include/net/dsa.h +1 -0
index 4e13e69..3276547 100644
@@ -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
index 9649238..d78789b 100644
@@ -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
index 31d3437..9b1d478 100644
@@ -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
index b6d4f6a..617f736 100644
@@ -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
index 0706a51..2a31399 100644
@@ -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 +117 -0

117 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 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 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
index 9e75768..c21ed99 100644
@@ -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
index 99b1c8e..996024d 100644
@@ -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
#7 lore raw

PATCH v2 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
index c21ed99..84b09a4 100644
@@ -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 · 1 line
1.9.1
#10 lore raw

PATCH v2 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 | 1172 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/dsa/mt7530.h |  382 +++++++++++++++
 4 files changed, 1563 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
index 0659846..5b322b4 100644
@@ -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
index a3c9416..8e629c1 100644
@@ -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 +1172 -0

1,172 lines not on this page · raw message

drivers/net/dsa/mt7530.h new file +382 -0

382 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer Reviewed-by on v2 3/5
#5 lore raw

Re: [PATCH net-next v2 3/5] net-next: ethernet: mediatek: add CDM able to recognize the tag for DSA

In reply to [email protected]
Quoted 9 lines · On Tue, Mar 21, 2017 at 05:35:08PM +0800…

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 working out for general untag packets as well.

Andrew

maintainer Reviewed-by on v2 4/5
#8 lore raw

Re: [PATCH net-next v2 4/5] net-next: ethernet: mediatek: add device_node of GMAC pointing into the netdev instance

In reply to [email protected]
Quoted 17 lines · On Tue, Mar 21, 2017 at 05:35:09PM +0800…

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 +0 -0
index c21ed99..84b09a4 100644

drivers/net/ethernet/mediatek/mtk_eth_soc.c static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) · line 2327

Quoted 5 lines
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;
+

Humm, O.K. This is not obvious, until you look at of_dev_node_match() in net-sysfs.c.

Most Ethernet drivers don't set netdev.dev.of_node. But they do call SET_NETDEV_DEV(), which sets netdev.dev.parent.

of_dev_node_match() first looks at netdev.dev.parent->of_node, and if that does not match, then looks at netdev.dev.of_node.

For the mtk Ethernet driver, the parent is not going to work, because of the sub devices. So netdev.dev.of_node does need to be set.

Andrew

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

Reviewed-by on v2 4/5
#9 lore raw

Re: [PATCH net-next v2 4/5] net-next: ethernet: mediatek: add device_node of GMAC pointing into the netdev instance

In reply to [email protected]
Quoted 8 lines · On 03/21/2017 02:35 AM, [email protected] wrote:

From: Sean Wang <[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.

Signature · 1 line
Florian
Reviewed-by on v2 3/5
#6 lore raw

Re: [PATCH net-next v2 3/5] net-next: ethernet: mediatek: add CDM able to recognize the tag for DSA

In reply to [email protected]
Quoted 9 lines · On 03/21/2017 02:35 AM, sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected] wrote:

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 working out for general untag packets as well.

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
maintainer
#11 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to [email protected]
Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+static int
+core_read_mmd_indirect(struct mt7530_priv *priv, int prtad, int devad)
+{
+	struct mii_bus *bus = priv->bus;
+	int value, ret;
+
+	/* Write the desired MMD Devad */
+	ret = bus->write(bus, 0, MII_MMD_CTRL, devad);
+	if (ret < 0)
+		goto err;

drivers/net/dsa/mt7530.c line 148

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+
+	/* Write the desired MMD register address */
+	ret = bus->write(bus, 0, MII_MMD_DATA, prtad);
+	if (ret < 0)
+		goto err;
+
+	/* Select the Function : DATA with no post increment */
+	ret = bus->write(bus, 0, MII_MMD_CTRL, (devad | MII_MMD_CTRL_NOINCR));
+	if (ret < 0)
+		goto err;

Hi Sean

This appear to be a copy of mmd_phy_indirect(). There are patches from Russell King which made this a public function. Once Russell patches make net-next, it would be nice to use mmd_phy_indirect(). But that might be as a follow up patch, rather than now, depending on the order of acceptance of the patches.

Andrew
--
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

#12 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to [email protected]
Quoted 15 lines · On 03/21/2017 02:35 AM, sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected] wrote:

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.

Quoted 6 lines

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.

Overall, this looks pretty nice and clean, a few comments below

Quoted 24 lines

---

drivers/net/dsa/mt7530.c new file +19 -0
+static void
+mt7530_fdb_read(struct mt7530_priv *priv, struct mt7530_fdb *fdb)
+{
+	u32 reg[3];
+	int i;
+
+	/* Read from ARL table into an array */
+	for (i = 0; i < 3; i++) {
+		reg[i] = mt7530_read(priv, MT7530_TSRA1 + (i * 4));
+
+		dev_dbg(priv->dev, "%s(%d) reg[%d]=0x%x\n",
+			__func__, __LINE__, i, reg[i]);
+	}
+
+	/* vid - 11:0 on reg[1] */
+	fdb->vid = (reg[1] >> 0) & 0xfff;
+	/* aging - 31:24 on reg[2] */
+	fdb->aging = (reg[2] >> 24) & 0xff;
+	/* portmask - 11:4 on reg[2] */

drivers/net/dsa/mt7530.c line 484

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+	fdb->port_mask = (reg[2] >> 4) & 0xff;
+	/* mac - 31:0 on reg[0] and 31:16 on reg[1] */
+	fdb->mac[0] = (reg[0] >> 24) & 0xff;
+	fdb->mac[1] = (reg[0] >> 16) & 0xff;
+	fdb->mac[2] = (reg[0] >>  8) & 0xff;
+	fdb->mac[3] = (reg[0] >>  0) & 0xff;
+	fdb->mac[4] = (reg[1] >> 24) & 0xff;
+	fdb->mac[5] = (reg[1] >> 16) & 0xff;
+	/* noarp - 3:2 on reg[2] */
+	fdb->noarp = ((reg[2] >> 2) & 0x3) == STATIC_ENT;

Could you add some definitions for the bits and masks that you are shifting here?

Quoted 22 lines
drivers/net/dsa/mt7530.c new file +22 -0
+}
+
+static void
+mt7530_fdb_write(struct mt7530_priv *priv, u16 vid,
+		 u8 port_mask, const u8 *mac,
+		 u8 aging, u8 type)
+{
+	u32 reg[3] = { 0 };
+	int i;
+
+	/* vid - 11:0 on reg[1] */
+	reg[1] |= (vid & 0xfff) << 0;
+	/* aging - 31:25 on reg[2] */
+	reg[2] |= (aging & 0xff) << 24;
+	/* portmask - 11:4 on reg[2] */
+	reg[2] |= (port_mask & 0xff) << 4;
+	/* type - 3 indicate that entry is static wouldn't
+	 * be aged out and 0 specified as erasing an entry
+	 */
+	reg[2] |= (type & 0x3) << 2;
+	/* mac - 31:0 on reg[0] and 31:16 on reg[1] */
+	reg[1] |= mac[5] << 16;

drivers/net/dsa/mt7530.c line 516

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+	reg[1] |= mac[4] << 24;
+	reg[0] |= mac[3] << 0;
+	reg[0] |= mac[2] << 8;
+	reg[0] |= mac[1] << 16;
+	reg[0] |= mac[0] << 24;
+
+	/* Wrirte array into the ARL table */
+	for (i = 0; i < 3; i++)
+		mt7530_write(priv, MT7530_ATA1 + (i * 4), reg[i]);
+}

Same here.

Quoted 12 lines
drivers/net/dsa/mt7530.c new file +12 -0
+
+static int
+mt7530_pad_clk_setup(struct dsa_switch *ds, int mode)
+{
+	struct mt7530_priv *priv = ds->priv;
+	u32 ncpo1, ssc_delta, trgint, i;
+
+	switch (mode) {
+	case PHY_INTERFACE_MODE_RGMII:
+		trgint = 0;
+		ncpo1 = 0x0c80;
+		ssc_delta = 0x87;

drivers/net/dsa/mt7530.c line 538

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+		break;
+	case PHY_INTERFACE_MODE_TRGMII:
+		trgint = 1;
+		ncpo1 = 0x1400;
+		ssc_delta = 0x57;
+		break;
+	default:
+		pr_err("xMII mode %d not supported\n", mode);
+		return -EINVAL;
+	}

You may be able to move this to an adjust_link callback that the PHY library would call when the PHY gets setup and the port is finally used, as opposed to doing this upfront during driver initialization.

Quoted 4 lines
drivers/net/dsa/mt7530.c new file +4 -0
+mt7530_setup(struct dsa_switch *ds)
+{
+	struct mt7530_priv *priv = ds->priv;
+	int ret, i, phy_mode;

drivers/net/dsa/mt7530.c line 658

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+	u8  cpup_mask = 0;
+	u32 id, val;
+	struct regmap *regmap;
+	struct device_node *dn;
+
+	/* Make sure that cpu port specfied on the dt is appropriate */
+	if (!dsa_is_cpu_port(ds, MT7530_CPU_PORT)) {
+		dev_err(priv->dev, "port not matched with the CPU port\n");
+		return -EINVAL;
+	}

This is kind of a hard error, in that case, a sensible thing to do could be issue a warning to the user telling that the configuration does not permit the use of Mediatek tags. Your get_tag_protocol() function could then return DSA_TAG_PROTO_NONE here instead of DSA_TAG_PROTO_MTK. It would still allow an user to utilize the switch, and we would know what is wrong with the configuration/board setup though.

Quoted 11 lines
drivers/net/dsa/mt7530.c new file +11 -0
+
+	/* The parent node of master_netdev which holds the common system
+	 * controller also is the container for two GMACs nodes representing
+	 * as two netdev instances.
+	 */
+	dn = ds->master_netdev->dev.of_node->parent;
+	priv->ethernet = syscon_node_to_regmap(dn);
+	if (IS_ERR(priv->ethernet))
+		return PTR_ERR(priv->ethernet);
+
+	regmap = devm_regmap_init(ds->dev, NULL, priv,

drivers/net/dsa/mt7530.c line 679

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+				  &mt7530_regmap_config);
+	if (IS_ERR(regmap))
+		dev_warn(priv->dev, "phy regmap initialization failed");
+
+	phy_mode = of_get_phy_mode(ds->ports[ds->dst->cpu_port].dn);
+	if (phy_mode < 0) {
+		dev_err(priv->dev, "Can't find phy-mode for master device\n");
+		return phy_mode;
+	}
+	dev_info(priv->dev, "phy-mode for master device = %x\n", phy_mode);

An adjust_link() callback which has a proper PHY device structure would be more appropriate to look up the phy_mode rather than doing this here.

[snip]

drivers/net/dsa/mt7530.c line 748

Quoted 4 lines
drivers/net/dsa/mt7530.c new file +4 -0
+	mt7530_clear(priv, MT7530_MFC, UNU_FFP_MASK);
+
+	/* Fabric setup for the cpu port */
+	for (i = 0; i < MT7530_NUM_PORTS; i++)

Are not you missing an opening parenthesis here in the for() statement?

Quoted 24 lines
drivers/net/dsa/mt7530.c new file +24 -0
+		if (dsa_is_cpu_port(ds, i)) {
+			/* Enable Mediatek header mode on the cpu port */
+			mt7530_write(priv, MT7530_PVC_P(i),
+				     PORT_SPEC_TAG);
+
+			/* Setup the MAC by default for the cpu port */
+			mt7530_write(priv, MT7530_PMCR_P(i), PMCR_CPUP_LINK);
+
+			/* Disable auto learning on the cpu port */
+			mt7530_set(priv, MT7530_PSC_P(i), SA_DIS);
+
+			/* Unknown unicast frame fordwarding to the cpu port */
+			mt7530_set(priv, MT7530_MFC, UNU_FFP(BIT(i)));
+
+			/* CPU port gets connected to all user ports of
+			 * the switch
+			 */
+			mt7530_write(priv, MT7530_PCR_P(i),
+				     PCR_MATRIX(ds->enabled_port_mask));
+
+			cpup_mask |= BIT(i);
+		}
+
+	/* Fabric setup for the all user ports */

drivers/net/dsa/mt7530.c line 782

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+	for (i = 0; i < MT7530_NUM_PORTS; i++)
+		if (ds->enabled_port_mask & BIT(i)) {
+			/* Setup the MAC by default for all user ports */
+			mt7530_write(priv, MT7530_PMCR_P(i),
+				     PMCR_USERP_LINK);
+
+			/* The user port gets connected to the cpu port only */
+			mt7530_write(priv, MT7530_PCR_P(i),
+				     PCR_MATRIX(cpup_mask));
+		}

This should be moved to the port_enable() function.

[snip]

drivers/net/dsa/mt7530.h line 320

Quoted 13 lines
drivers/net/dsa/mt7530.h new file +13 -0
+#define wait_condition_timeout(condition, timeout)			\
+({									\
+	long __ret = 0;							\
+	unsigned long toj;						\
+	toj = jiffies + msecs_to_jiffies(timeout);			\
+									\
+	for ( ; !(condition) && !time_after_eq(jiffies, toj) ; )	\
+		cond_resched();						\
+									\
+	if (time_after_eq(jiffies, toj))				\
+		__ret = -ETIMEDOUT;					\
+	__ret;								\
+})

Can you use read*_poll_timeout() instead of this?

Quoted 9 lines

+/* struct mt7530_priv - This is the main datasructure for holding the state
+ * of the driver
+ * @dev: The device pointer
+ * @ds: The pointer to the dsa core structure
+ * @bus: The bus used for the device and built-in PHY
+ * @ethsys: The regmap used for enabling the necessary PLL
+ * @ethernet: The regmap used for access TRGMII-based registers
+ * @core_pwr: The power supplied into the core
+ * @io_pwr: The power supplied into the I/O

Quoted 8 lines

+ * @mcm: Flag for distinguishing if standalone IC or module
+ * coupling
+ * @reset: The descriptor for GPIO line tied to its reset pin
+ * @phy_mode: The xMII for cpu port used
+ * @ports: Holding the state amongs ports
+ * @reg_mutex: The lock for protecting among process accessing
+ * registers
+ */

Kudos for using kernel doc here.

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
maintainer
#14 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to [email protected]
Quoted 17 lines
drivers/net/dsa/mt7530.c new file +17 -0
+static int
+mt7623_trgmii_write(struct mt7530_priv *priv,  u32 reg, u32 val)
+{
+	int ret;
+
+	ret =  regmap_write(priv->ethernet, TRGMII_BASE(reg), val);
+	if (ret < 0)
+		dev_err(priv->dev,
+			"failed to priv write register\n");
+	return ret;
+}
+
+static u32
+mt7623_trgmii_read(struct mt7530_priv *priv, u32 reg)
+{
+	int ret;
+	u32 val;

drivers/net/dsa/mt7530.c line 103

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+
+	ret = regmap_read(priv->ethernet, TRGMII_BASE(reg), &val);
+	if (ret < 0) {
+		dev_err(priv->dev,
+			"failed to priv read register\n");
+		return ret;
+	}
+
+	return val;
+}

Hi Sean

These appear to be the only two accessors which use the regmap.

Quoted 18 lines
drivers/net/dsa/mt7530.c new file +18 -0
+static int
+mt7530_regmap_read(void *ctx, uint32_t reg, uint32_t *val)
+{
+	struct mt7530_priv *priv = (struct mt7530_priv *)ctx;
+
+	/* BIT(15) is used as indication for pseudo registers
+	 * which would be translated into the general MDIO
+	 * access to leverage the unique regmap sys interface.
+	 */
+	if (reg & BIT(15))
+		*val = mdiobus_read_nested(priv->bus,
+					   (reg & 0xf00) >> 8,
+					   (reg & 0xff) >> 2);
+	else
+		*val = mt7530_read(priv, reg);
+
+	return 0;
+}

.....

Quoted 25 lines
drivers/net/dsa/mt7530.c new file +25 -0
+static const struct regmap_range mt7530_readable_ranges[] = {
+	regmap_reg_range(0x0000, 0x00ac), /* Global control */
+	regmap_reg_range(0x2000, 0x202c), /* Port Control - P0 */
+	regmap_reg_range(0x2100, 0x212c), /* Port Control - P1 */
+	regmap_reg_range(0x2200, 0x222c), /* Port Control - P2 */
+	regmap_reg_range(0x2300, 0x232c), /* Port Control - P3 */
+	regmap_reg_range(0x2400, 0x242c), /* Port Control - P4 */
+	regmap_reg_range(0x2500, 0x252c), /* Port Control - P5 */
+	regmap_reg_range(0x2600, 0x262c), /* Port Control - P6 */
+	regmap_reg_range(0x30e0, 0x30f8), /* Port MAC - SYS */
+	regmap_reg_range(0x3000, 0x3014), /* Port MAC - P0 */
+	regmap_reg_range(0x3100, 0x3114), /* Port MAC - P1 */
+	regmap_reg_range(0x3200, 0x3214), /* Port MAC - P2*/
+	regmap_reg_range(0x3300, 0x3314), /* Port MAC - P3*/
+	regmap_reg_range(0x3400, 0x3414), /* Port MAC - P4 */
+	regmap_reg_range(0x3500, 0x3514), /* Port MAC - P5 */
+	regmap_reg_range(0x3600, 0x3614), /* Port MAC - P6 */
+	regmap_reg_range(0x4000, 0x40d4), /* MIB - P0 */
+	regmap_reg_range(0x4100, 0x41d4), /* MIB - P1 */
+	regmap_reg_range(0x4200, 0x42d4), /* MIB - P2 */
+	regmap_reg_range(0x4300, 0x43d4), /* MIB - P3 */
+	regmap_reg_range(0x4400, 0x44d4), /* MIB - P4 */
+	regmap_reg_range(0x4500, 0x45d4), /* MIB - P5 */
+	regmap_reg_range(0x4600, 0x46d4), /* MIB - P6 */
+	regmap_reg_range(0x4fe0, 0x4ff4), /* SYS */

drivers/net/dsa/mt7530.c line 408

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+	regmap_reg_range(0x7000, 0x700c), /* SYS 2 */
+	regmap_reg_range(0x7018, 0x7028), /* SYS 3 */
+	regmap_reg_range(0x7800, 0x7830), /* SYS 4 */
+	regmap_reg_range(0x7a00, 0x7a7c), /* TRGMII */
+	regmap_reg_range(0x8000, 0x8078), /* Psedo address for Phy - P0 */
+	regmap_reg_range(0x8100, 0x8178), /* Psedo address for Phy - P1 */
+	regmap_reg_range(0x8200, 0x8278), /* Psedo address for Phy - P2 */
+	regmap_reg_range(0x8300, 0x8378), /* Psedo address for Phy - P3 */
+	regmap_reg_range(0x8400, 0x8478), /* Psedo address for Phy - P4 */
+};

It looks like your regmap accessor are only used for 0x7a00 to 0x7a7c.

It is not clear why you even bother with a regmap. If you have it, why not use it for all registers within the regmap?

Andrew

author
#15 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

Hi Andrew,

The purpose for the regmap table registered is to

provide a way which helps us to look up a specific

register on the switch through regmap-debugfs.

And not all ranges of register is defined

so I only include the meaningful ones in a sparse way

for the table.

Sean

Quoted 95 lines · Andrew Lunn
Quoted 17 lines
drivers/net/dsa/mt7530.c new file +17 -0
+static int
+mt7623_trgmii_write(struct mt7530_priv *priv,  u32 reg, u32 val)
+{
+	int ret;
+
+	ret =  regmap_write(priv->ethernet, TRGMII_BASE(reg), val);
+	if (ret < 0)
+		dev_err(priv->dev,
+			"failed to priv write register\n");
+	return ret;
+}
+
+static u32
+mt7623_trgmii_read(struct mt7530_priv *priv, u32 reg)
+{
+	int ret;
+	u32 val;

drivers/net/dsa/mt7530.c line 103

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+
+	ret = regmap_read(priv->ethernet, TRGMII_BASE(reg), &val);
+	if (ret < 0) {
+		dev_err(priv->dev,
+			"failed to priv read register\n");
+		return ret;
+	}
+
+	return val;
+}

Hi Sean

These appear to be the only two accessors which use the regmap.

Quoted 18 lines
drivers/net/dsa/mt7530.c new file +18 -0
+static int
+mt7530_regmap_read(void *ctx, uint32_t reg, uint32_t *val)
+{
+	struct mt7530_priv *priv = (struct mt7530_priv *)ctx;
+
+	/* BIT(15) is used as indication for pseudo registers
+	 * which would be translated into the general MDIO
+	 * access to leverage the unique regmap sys interface.
+	 */
+	if (reg & BIT(15))
+		*val = mdiobus_read_nested(priv->bus,
+					   (reg & 0xf00) >> 8,
+					   (reg & 0xff) >> 2);
+	else
+		*val = mt7530_read(priv, reg);
+
+	return 0;
+}

.....

Quoted 25 lines
drivers/net/dsa/mt7530.c new file +25 -0
+static const struct regmap_range mt7530_readable_ranges[] = {
+	regmap_reg_range(0x0000, 0x00ac), /* Global control */
+	regmap_reg_range(0x2000, 0x202c), /* Port Control - P0 */
+	regmap_reg_range(0x2100, 0x212c), /* Port Control - P1 */
+	regmap_reg_range(0x2200, 0x222c), /* Port Control - P2 */
+	regmap_reg_range(0x2300, 0x232c), /* Port Control - P3 */
+	regmap_reg_range(0x2400, 0x242c), /* Port Control - P4 */
+	regmap_reg_range(0x2500, 0x252c), /* Port Control - P5 */
+	regmap_reg_range(0x2600, 0x262c), /* Port Control - P6 */
+	regmap_reg_range(0x30e0, 0x30f8), /* Port MAC - SYS */
+	regmap_reg_range(0x3000, 0x3014), /* Port MAC - P0 */
+	regmap_reg_range(0x3100, 0x3114), /* Port MAC - P1 */
+	regmap_reg_range(0x3200, 0x3214), /* Port MAC - P2*/
+	regmap_reg_range(0x3300, 0x3314), /* Port MAC - P3*/
+	regmap_reg_range(0x3400, 0x3414), /* Port MAC - P4 */
+	regmap_reg_range(0x3500, 0x3514), /* Port MAC - P5 */
+	regmap_reg_range(0x3600, 0x3614), /* Port MAC - P6 */
+	regmap_reg_range(0x4000, 0x40d4), /* MIB - P0 */
+	regmap_reg_range(0x4100, 0x41d4), /* MIB - P1 */
+	regmap_reg_range(0x4200, 0x42d4), /* MIB - P2 */
+	regmap_reg_range(0x4300, 0x43d4), /* MIB - P3 */
+	regmap_reg_range(0x4400, 0x44d4), /* MIB - P4 */
+	regmap_reg_range(0x4500, 0x45d4), /* MIB - P5 */
+	regmap_reg_range(0x4600, 0x46d4), /* MIB - P6 */
+	regmap_reg_range(0x4fe0, 0x4ff4), /* SYS */

drivers/net/dsa/mt7530.c line 408

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+	regmap_reg_range(0x7000, 0x700c), /* SYS 2 */
+	regmap_reg_range(0x7018, 0x7028), /* SYS 3 */
+	regmap_reg_range(0x7800, 0x7830), /* SYS 4 */
+	regmap_reg_range(0x7a00, 0x7a7c), /* TRGMII */
+	regmap_reg_range(0x8000, 0x8078), /* Psedo address for Phy - P0 */
+	regmap_reg_range(0x8100, 0x8178), /* Psedo address for Phy - P1 */
+	regmap_reg_range(0x8200, 0x8278), /* Psedo address for Phy - P2 */
+	regmap_reg_range(0x8300, 0x8378), /* Psedo address for Phy - P3 */
+	regmap_reg_range(0x8400, 0x8478), /* Psedo address for Phy - P4 */
+};

It looks like your regmap accessor are only used for 0x7a00 to 0x7a7c.

It is not clear why you even bother with a regmap. If you have it, why not use it for all registers within the regmap?

Andrew

maintainer
#16 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

Quoted 6 lines · Sean Wang

Hi Andrew,

The purpose for the regmap table registered is to

provide a way which helps us to look up a specific

Quoted 8 lines

register on the switch through regmap-debugfs.

And not all ranges of register is defined

so I only include the meaningful ones in a sparse way

for the table.

I think in that case it might be nice to make regmap support optional in order to avoid pulling in bloat on platforms that don't need it.

- Felix

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

#17 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

Quoted 12 lines · Felix Fietkau
Quoted 11 lines · Sean Wang

Hi Andrew,

The purpose for the regmap table registered is to

provide a way which helps us to look up a specific

register on the switch through regmap-debugfs.

And not all ranges of register is defined

Quoted 8 lines
Quoted 3 lines

so I only include the meaningful ones in a sparse way

for the table.

I think in that case it might be nice to make regmap support optional in order to avoid pulling in bloat on platforms that don't need it.

- Felix

The 2 relevant platforms are mips/ralink and arm/mediatek. both require regmap for the eth_sysctl syscon if they want to utilize the mtk_soc_eth driver which is a prereq for mt7530. so regmap cannot be optional here.

John

Quoted 5 lines

_______________________________________________
Linux-mediatek mailing list [email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

maintainer
#18 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

Quoted 18 lines · John Crispin
Quoted 15 lines · Felix Fietkau
Quoted 14 lines · Sean Wang

Hi Andrew,

The purpose for the regmap table registered is to

provide a way which helps us to look up a specific

register on the switch through regmap-debugfs.

And not all ranges of register is defined

so I only include the meaningful ones in a sparse way

for the table.

Quoted 8 lines
Quoted 5 lines

I think in that case it might be nice to make regmap support optional in order to avoid pulling in bloat on platforms that don't need it.

- Felix

The 2 relevant platforms are mips/ralink and arm/mediatek. both require regmap for the eth_sysctl syscon if they want to utilize the mtk_soc_eth driver which is a prereq for mt7530. so regmap cannot be optional here.

Makes sense, thanks.

- Felix

maintainer
#19 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to Sean Wang
Quoted 6 lines · Sean Wang

Hi Andrew,

The purpose for the regmap table registered is to

provide a way which helps us to look up a specific

Quoted 8 lines

register on the switch through regmap-debugfs.

And not all ranges of register is defined

so I only include the meaningful ones in a sparse way

for the table.

Many of there registers can be dumped using existing tools. You can dump the port registers using ethtool -r, if you implement get_regs/get_regs_len in your driver. mii-tool can dump the PHY registers.

What you cannot see are global registers, so i can understand the usage of regmap-debugfs. However, i have a hard time with you only actually using the regmap for get/set for one small subset of registers. Either you need to use regmap to get/set all registers, or you remove it from the mainline driver, and keep it as a private patch which you use for your development work. For the Marvell driver we have an out of tree patch which exports a log of information via debugfs.

Andrew

maintainer
#20 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to [email protected]

Hi Sean

drivers/net/dsa/mt7530.c line 673

Quoted 5 lines
drivers/net/dsa/mt7530.c new file +5 -0
+	regmap = devm_regmap_init(ds->dev, NULL, priv,
+				  &mt7530_regmap_config);
+	if (IS_ERR(regmap))
+		dev_warn(priv->dev, "phy regmap initialization failed");
+

Shouldn't this be a fatal error? If you keep going when there is an error, what happens when you actually try to use the regmap?

drivers/net/dsa/mt7530.c line 679

Quoted 6 lines
drivers/net/dsa/mt7530.c new file +6 -0
+	phy_mode = of_get_phy_mode(ds->ports[ds->dst->cpu_port].dn);
+	if (phy_mode < 0) {
+		dev_err(priv->dev, "Can't find phy-mode for master device\n");
+		return phy_mode;
+	}
+	dev_info(priv->dev, "phy-mode for master device = %x\n", phy_mode);

dev_dbg?

drivers/net/dsa/mt7530.c line 721

Quoted 5 lines
drivers/net/dsa/mt7530.c new file +5 -0
+
+	id = mt7530_read(priv, MT7530_CREV);
+	id >>= CHIP_NAME_SHIFT;
+	if (id != MT7530_ID)
+		return -ENODEV;

It might be helpful to say what ID has been found, if it is not the supported ID.

Andrew

maintainer
#22 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to [email protected]

On Tue, Mar 21, 2017 at 05:35:10PM +0800, sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected] wrote:

Hi Sean

drivers/net/dsa/mt7530.c line 544

Quoted 2 lines
drivers/net/dsa/mt7530.c new file +2 -0
+	/* Lower Tx Driving */
+	for (i = 0 ; i < 6 ; i++)

Could MT7530_CPU_PORT be used here?

Quoted 42 lines
drivers/net/dsa/mt7530.c new file +42 -0
+		mt7530_write(priv, MT7530_TRGMII_TD_ODT(i),
+			     TD_DM_DRVP(8) | TD_DM_DRVN(8));
+
+	/* Setup MT7530 core clock */
+	if (!trgint) {
+		/* Disable MT7530 core clock */
+		core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
+
+		/* Disable MT7530 PLL, since phy_device has not yet been
+		 * created when this function is called. So we provide
+		 * core_write_mmd_indirect to complete this function
+		 */
+		core_write_mmd_indirect(priv,
+					CORE_GSWPLL_GRP1,
+					MDIO_MMD_VEND2,
+					0);
+
+		/* Setup MT7530 core clock into 500Mhz */
+		core_write(priv, CORE_GSWPLL_GRP2,
+			   RG_GSWPLL_POSDIV_500M(1) |
+			   RG_GSWPLL_FBKDIV_500M(25));
+
+		/* Enable MT7530 PLL */
+		core_write(priv, CORE_GSWPLL_GRP1,
+			   RG_GSWPLL_EN_PRE |
+			   RG_GSWPLL_POSDIV_200M(2) |
+			   RG_GSWPLL_FBKDIV_200M(32));
+
+		/* Enable MT7530 core clock */
+		core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
+	}
+
+	/* Setup the MT7530 TRGMII Tx Clock */
+	core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
+	core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1));
+	core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0));
+	core_write(priv, CORE_PLL_GROUP10, RG_LCDDS_SSC_DELTA(ssc_delta));
+	core_write(priv, CORE_PLL_GROUP11, RG_LCDDS_SSC_DELTA1(ssc_delta));
+	core_write(priv, CORE_PLL_GROUP4,
+		   RG_SYSPLL_DDSFBK_EN | RG_SYSPLL_BIAS_EN |
+		   RG_SYSPLL_BIAS_LPF_EN);
+	core_write(priv, CORE_PLL_GROUP2,

drivers/net/dsa/mt7530.c line 596

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+		   RG_SYSPLL_EN_NORMAL | RG_SYSPLL_VODEN |
+		   RG_SYSPLL_POSDIV(1));
+	core_write(priv, CORE_PLL_GROUP7,
+		   RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C(3) |
+		   RG_LCDDS_PWDB | RG_LCDDS_ISO_EN);
+	core_set(priv, CORE_TRGMII_GSW_CLK_CG,
+		 REG_GSWCK_EN | REG_TRGMIICK_EN);
+
+	if (!trgint)
+		for (i = 0 ; i < 5 ; i++)

Why only 5 here? All other similar loops are to 6. Replacing 5 with a #define might help make this more readable.

Quoted 5 lines
drivers/net/dsa/mt7530.c new file +5 -0
+			mt7530_rmw(priv, MT7530_TRGMII_RD(i),
+				   RD_TAP_MASK, RD_TAP(16));
+	else
+		mt7623_trgmii_set(priv, GSW_INTF_MODE, INTF_MODE_TRGMII);
+

drivers/net/dsa/mt7530.c line 611

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+	return 0;
+}
+
+static int
+mt7623_pad_clk_setup(struct dsa_switch *ds)
+{
+	struct mt7530_priv *priv = ds->priv;
+	int i;
+
+	for (i = 0 ; i < 6; i++)

MT7530_CPU_PORT?

drivers/net/dsa/mt7530.h line 30

Quoted 2 lines
drivers/net/dsa/mt7530.h new file +2 -0
+
+/* Registers to mac forward conrol for unknown frames */

/conrol/control

drivers/net/dsa/mt7530.h line 102

Quoted 2 lines
drivers/net/dsa/mt7530.h new file +2 -0
+
+/* Registor for port control */

Register

Quoted 1 line

+/* Regiser for TOP signal control */

Register

Quoted 1 line

+/* struct mt7530_priv - This is the main datasructure for holding the state

data structure

Quoted 5 lines

+ * of the driver
+ * @dev: The device pointer
+ * @ds: The pointer to the dsa core structure
+ * @bus: The bus used for the device and built-in PHY
+ * @ethsys: The regmap used for enabling the necessary PLL

Quoted 8 lines

+ * @ethernet: The regmap used for access TRGMII-based registers
+ * @core_pwr: The power supplied into the core
+ * @io_pwr: The power supplied into the I/O
+ * @mcm: Flag for distinguishing if standalone IC or module
+ * coupling
+ * @reset: The descriptor for GPIO line tied to its reset pin
+ * @phy_mode: The xMII for cpu port used
+ * @ports: Holding the state amongs ports

among

Andrew
--
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

maintainer Acked-by on v2 1/5
#2 lore raw

Re: [PATCH net-next v2 1/5] dt-bindings: net: dsa: add Mediatek MT7530 binding

In reply to [email protected]
Quoted 10 lines · On Tue, Mar 21, 2017 at 05:35:06PM +0800…

From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[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
author
#13 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to Florian Fainelli

Hi Florian,

Thank for taking your time on reviewing. Add comment as inline.

Quoted 54 lines · Florian Fainelli
Quoted 15 lines · On 03/21/2017 02:35 AM, sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected] wrote:

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.

Quoted 6 lines

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.

Overall, this looks pretty nice and clean, a few comments below

Quoted 29 lines

---

drivers/net/dsa/mt7530.c new file +24 -0
+static void
+mt7530_fdb_read(struct mt7530_priv *priv, struct mt7530_fdb *fdb)
+{
+	u32 reg[3];
+	int i;
+
+	/* Read from ARL table into an array */
+	for (i = 0; i < 3; i++) {
+		reg[i] = mt7530_read(priv, MT7530_TSRA1 + (i * 4));
+
+		dev_dbg(priv->dev, "%s(%d) reg[%d]=0x%x\n",
+			__func__, __LINE__, i, reg[i]);
+	}
+
+	/* vid - 11:0 on reg[1] */
+	fdb->vid = (reg[1] >> 0) & 0xfff;
+	/* aging - 31:24 on reg[2] */
+	fdb->aging = (reg[2] >> 24) & 0xff;
+	/* portmask - 11:4 on reg[2] */
+	fdb->port_mask = (reg[2] >> 4) & 0xff;
+	/* mac - 31:0 on reg[0] and 31:16 on reg[1] */
+	fdb->mac[0] = (reg[0] >> 24) & 0xff;
+	fdb->mac[1] = (reg[0] >> 16) & 0xff;
+	fdb->mac[2] = (reg[0] >>  8) & 0xff;
Quoted 9 lines

drivers/net/dsa/mt7530.c line 484

Quoted 5 lines
drivers/net/dsa/mt7530.c new file +5 -0
+	fdb->mac[3] = (reg[0] >>  0) & 0xff;
+	fdb->mac[4] = (reg[1] >> 24) & 0xff;
+	fdb->mac[5] = (reg[1] >> 16) & 0xff;
+	/* noarp - 3:2 on reg[2] */
+	fdb->noarp = ((reg[2] >> 2) & 0x3) == STATIC_ENT;

Could you add some definitions for the bits and masks that you are shifting here?

Okay, I'll make into proper macro for readability

Quoted 26 lines
Quoted 26 lines
drivers/net/dsa/mt7530.c new file +26 -0
+}
+
+static void
+mt7530_fdb_write(struct mt7530_priv *priv, u16 vid,
+		 u8 port_mask, const u8 *mac,
+		 u8 aging, u8 type)
+{
+	u32 reg[3] = { 0 };
+	int i;
+
+	/* vid - 11:0 on reg[1] */
+	reg[1] |= (vid & 0xfff) << 0;
+	/* aging - 31:25 on reg[2] */
+	reg[2] |= (aging & 0xff) << 24;
+	/* portmask - 11:4 on reg[2] */
+	reg[2] |= (port_mask & 0xff) << 4;
+	/* type - 3 indicate that entry is static wouldn't
+	 * be aged out and 0 specified as erasing an entry
+	 */
+	reg[2] |= (type & 0x3) << 2;
+	/* mac - 31:0 on reg[0] and 31:16 on reg[1] */
+	reg[1] |= mac[5] << 16;
+	reg[1] |= mac[4] << 24;
+	reg[0] |= mac[3] << 0;
+	reg[0] |= mac[2] << 8;
+	reg[0] |= mac[1] << 16;
Quoted 9 lines

drivers/net/dsa/mt7530.c line 516

Quoted 6 lines
drivers/net/dsa/mt7530.c new file +6 -0
+	reg[0] |= mac[0] << 24;
+
+	/* Wrirte array into the ARL table */
+	for (i = 0; i < 3; i++)
+		mt7530_write(priv, MT7530_ATA1 + (i * 4), reg[i]);
+}

Same here.

As above. I will improve them.

Quoted 18 lines
Quoted 18 lines
drivers/net/dsa/mt7530.c new file +18 -0
+
+static int
+mt7530_pad_clk_setup(struct dsa_switch *ds, int mode)
+{
+	struct mt7530_priv *priv = ds->priv;
+	u32 ncpo1, ssc_delta, trgint, i;
+
+	switch (mode) {
+	case PHY_INTERFACE_MODE_RGMII:
+		trgint = 0;
+		ncpo1 = 0x0c80;
+		ssc_delta = 0x87;
+		break;
+	case PHY_INTERFACE_MODE_TRGMII:
+		trgint = 1;
+		ncpo1 = 0x1400;
+		ssc_delta = 0x57;
+		break;
Quoted 9 lines

drivers/net/dsa/mt7530.c line 538

Quoted 4 lines
drivers/net/dsa/mt7530.c new file +4 -0
+	default:
+		pr_err("xMII mode %d not supported\n", mode);
+		return -EINVAL;
+	}

You may be able to move this to an adjust_link callback that the PHY library would call when the PHY gets setup and the port is finally used, as opposed to doing this upfront during driver initialization.

Good point. i will follow up

Quoted 14 lines
Quoted 14 lines
drivers/net/dsa/mt7530.c new file +13 -0
+mt7530_setup(struct dsa_switch *ds)
+{
+	struct mt7530_priv *priv = ds->priv;
+	int ret, i, phy_mode;
+	u8  cpup_mask = 0;
+	u32 id, val;
+	struct regmap *regmap;
+	struct device_node *dn;
+
+	/* Make sure that cpu port specfied on the dt is appropriate */
+	if (!dsa_is_cpu_port(ds, MT7530_CPU_PORT)) {
+		dev_err(priv->dev, "port not matched with the CPU port\n");
+		return -EINVAL;
Quoted 9 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	}

This is kind of a hard error, in that case, a sensible thing to do could be issue a warning to the user telling that the configuration does not permit the use of Mediatek tags. Your get_tag_protocol() function could then return DSA_TAG_PROTO_NONE here instead of DSA_TAG_PROTO_MTK. It would still allow an user to utilize the switch, and we would know what is wrong with the configuration/board setup though.

I seems making a hard requirement.

I will improve it with showing warning message if the number of cpu port is not right.

It at least allows the other user ports can work in case cpu port doesn't work.

Quoted 16 lines
Quoted 16 lines
drivers/net/dsa/mt7530.c new file +16 -0
+
+	/* The parent node of master_netdev which holds the common system
+	 * controller also is the container for two GMACs nodes representing
+	 * as two netdev instances.
+	 */
+	dn = ds->master_netdev->dev.of_node->parent;
+	priv->ethernet = syscon_node_to_regmap(dn);
+	if (IS_ERR(priv->ethernet))
+		return PTR_ERR(priv->ethernet);
+
+	regmap = devm_regmap_init(ds->dev, NULL, priv,
+				  &mt7530_regmap_config);
+	if (IS_ERR(regmap))
+		dev_warn(priv->dev, "phy regmap initialization failed");
+
+	phy_mode = of_get_phy_mode(ds->ports[ds->dst->cpu_port].dn);
Quoted 9 lines

drivers/net/dsa/mt7530.c line 679

Quoted 5 lines
drivers/net/dsa/mt7530.c new file +5 -0
+	if (phy_mode < 0) {
+		dev_err(priv->dev, "Can't find phy-mode for master device\n");
+		return phy_mode;
+	}
+	dev_info(priv->dev, "phy-mode for master device = %x\n", phy_mode);

An adjust_link() callback which has a proper PHY device structure would be more appropriate to look up the phy_mode rather than doing this here.

As above. I will follow up

Quoted 9 lines

[snip]

drivers/net/dsa/mt7530.c line 748

Quoted 4 lines
drivers/net/dsa/mt7530.c new file +4 -0
+	mt7530_clear(priv, MT7530_MFC, UNU_FFP_MASK);
+
+	/* Fabric setup for the cpu port */
+	for (i = 0; i < MT7530_NUM_PORTS; i++)

Are not you missing an opening parenthesis here in the for() statement?

It is missing because the following is single statement.
I admits it is better to add the parenthesis for readability, so I will add it.

Quoted 28 lines
Quoted 28 lines
drivers/net/dsa/mt7530.c new file +28 -0
+		if (dsa_is_cpu_port(ds, i)) {
+			/* Enable Mediatek header mode on the cpu port */
+			mt7530_write(priv, MT7530_PVC_P(i),
+				     PORT_SPEC_TAG);
+
+			/* Setup the MAC by default for the cpu port */
+			mt7530_write(priv, MT7530_PMCR_P(i), PMCR_CPUP_LINK);
+
+			/* Disable auto learning on the cpu port */
+			mt7530_set(priv, MT7530_PSC_P(i), SA_DIS);
+
+			/* Unknown unicast frame fordwarding to the cpu port */
+			mt7530_set(priv, MT7530_MFC, UNU_FFP(BIT(i)));
+
+			/* CPU port gets connected to all user ports of
+			 * the switch
+			 */
+			mt7530_write(priv, MT7530_PCR_P(i),
+				     PCR_MATRIX(ds->enabled_port_mask));
+
+			cpup_mask |= BIT(i);
+		}
+
+	/* Fabric setup for the all user ports */
+	for (i = 0; i < MT7530_NUM_PORTS; i++)
+		if (ds->enabled_port_mask & BIT(i)) {
+			/* Setup the MAC by default for all user ports */
+			mt7530_write(priv, MT7530_PMCR_P(i),
Quoted 9 lines

drivers/net/dsa/mt7530.c line 782

Quoted 6 lines
drivers/net/dsa/mt7530.c new file +6 -0
+				     PMCR_USERP_LINK);
+
+			/* The user port gets connected to the cpu port only */
+			mt7530_write(priv, MT7530_PCR_P(i),
+				     PCR_MATRIX(cpup_mask));
+		}

This should be moved to the port_enable() function.

okay. i will follow up.

Quoted 1 line

[snip]

*_poll_timeout

Quoted 7 lines
Quoted 7 lines
drivers/net/dsa/mt7530.h new file +7 -0
+#define wait_condition_timeout(condition, timeout)			\
+({									\
+	long __ret = 0;							\
+	unsigned long toj;						\
+	toj = jiffies + msecs_to_jiffies(timeout);			\
+									\
+	for ( ; !(condition) && !time_after_eq(jiffies, toj) ; )	\
Quoted 9 lines

drivers/net/dsa/mt7530.h line 320

Quoted 6 lines
drivers/net/dsa/mt7530.h new file +6 -0
+		cond_resched();						\
+									\
+	if (time_after_eq(jiffies, toj))				\
+		__ret = -ETIMEDOUT;					\
+	__ret;								\
+})

Can you use read*_poll_timeout() instead of this?

I will try to reuse them

the function pointer for op in *_poll_timeout seems only accepting only single argument for address. which implies I need creating another function for mt7530_readX() used by *_poll_timeout and keeping another static pointer to mt7530 internal for mt7530_readX() to work.

Quoted 19 lines
Quoted 9 lines

+/* struct mt7530_priv - This is the main datasructure for holding the state
+ * of the driver
+ * @dev: The device pointer
+ * @ds: The pointer to the dsa core structure
+ * @bus: The bus used for the device and built-in PHY
+ * @ethsys: The regmap used for enabling the necessary PLL
+ * @ethernet: The regmap used for access TRGMII-based registers
+ * @core_pwr: The power supplied into the core
+ * @io_pwr: The power supplied into the I/O

Quoted 8 lines

+ * @mcm: Flag for distinguishing if standalone IC or module
+ * coupling
+ * @reset: The descriptor for GPIO line tied to its reset pin
+ * @phy_mode: The xMII for cpu port used
+ * @ports: Holding the state amongs ports
+ * @reg_mutex: The lock for protecting among process accessing
+ * registers
+ */

Kudos for using kernel doc here.

author
#21 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to Andrew Lunn

Hi Andrew,

Add comment as below inline

Quoted 11 lines · Andrew Lunn

Hi Sean

drivers/net/dsa/mt7530.c line 673

Quoted 5 lines
drivers/net/dsa/mt7530.c new file +5 -0
+	regmap = devm_regmap_init(ds->dev, NULL, priv,
+				  &mt7530_regmap_config);
+	if (IS_ERR(regmap))
+		dev_warn(priv->dev, "phy regmap initialization failed");
+

Shouldn't this be a fatal error? If you keep going when there is an error, what happens when you actually try to use the regmap?

Initial thought is that it is just for debugging purpose so if it fails, it should break any functionality of switch and only have implication as a warning message.

Anyway, i will remove it in the next one since it seems better being kept in private place as you suggested in the previous mail.

Quoted 9 lines

drivers/net/dsa/mt7530.c line 679

Quoted 6 lines
drivers/net/dsa/mt7530.c new file +6 -0
+	phy_mode = of_get_phy_mode(ds->ports[ds->dst->cpu_port].dn);
+	if (phy_mode < 0) {
+		dev_err(priv->dev, "Can't find phy-mode for master device\n");
+		return phy_mode;
+	}
+	dev_info(priv->dev, "phy-mode for master device = %x\n", phy_mode);

dev_dbg?

Sorry. i forgot turned it into dev_dbg

Quoted 8 lines

drivers/net/dsa/mt7530.c line 721

Quoted 5 lines
drivers/net/dsa/mt7530.c new file +5 -0
+
+	id = mt7530_read(priv, MT7530_CREV);
+	id >>= CHIP_NAME_SHIFT;
+	if (id != MT7530_ID)
+		return -ENODEV;

It might be helpful to say what ID has been found, if it is not the supported ID.

I will fix it up to make users know what was going on

thanks for taking your time on those reviewing again!

Quoted 1 line

Andrew

author
#23 lore raw

Re: [PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to Andrew Lunn

Hi Andrew

Quoted 9 lines · Andrew Lunn

On Tue, Mar 21, 2017 at 05:35:10PM +0800, sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected] wrote:

Hi Sean

drivers/net/dsa/mt7530.c line 544

Quoted 2 lines
drivers/net/dsa/mt7530.c new file +2 -0
+	/* Lower Tx Driving */
+	for (i = 0 ; i < 6 ; i++)

Could MT7530_CPU_PORT be used here?

I should create meaningful definition instead of avoiding hard coding

where 6 should be corrected into 5 which is meant for the number for

control register to configure TRGMII path

Quoted 47 lines
Quoted 47 lines
drivers/net/dsa/mt7530.c new file +47 -0
+		mt7530_write(priv, MT7530_TRGMII_TD_ODT(i),
+			     TD_DM_DRVP(8) | TD_DM_DRVN(8));
+
+	/* Setup MT7530 core clock */
+	if (!trgint) {
+		/* Disable MT7530 core clock */
+		core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
+
+		/* Disable MT7530 PLL, since phy_device has not yet been
+		 * created when this function is called. So we provide
+		 * core_write_mmd_indirect to complete this function
+		 */
+		core_write_mmd_indirect(priv,
+					CORE_GSWPLL_GRP1,
+					MDIO_MMD_VEND2,
+					0);
+
+		/* Setup MT7530 core clock into 500Mhz */
+		core_write(priv, CORE_GSWPLL_GRP2,
+			   RG_GSWPLL_POSDIV_500M(1) |
+			   RG_GSWPLL_FBKDIV_500M(25));
+
+		/* Enable MT7530 PLL */
+		core_write(priv, CORE_GSWPLL_GRP1,
+			   RG_GSWPLL_EN_PRE |
+			   RG_GSWPLL_POSDIV_200M(2) |
+			   RG_GSWPLL_FBKDIV_200M(32));
+
+		/* Enable MT7530 core clock */
+		core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
+	}
+
+	/* Setup the MT7530 TRGMII Tx Clock */
+	core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
+	core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1));
+	core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0));
+	core_write(priv, CORE_PLL_GROUP10, RG_LCDDS_SSC_DELTA(ssc_delta));
+	core_write(priv, CORE_PLL_GROUP11, RG_LCDDS_SSC_DELTA1(ssc_delta));
+	core_write(priv, CORE_PLL_GROUP4,
+		   RG_SYSPLL_DDSFBK_EN | RG_SYSPLL_BIAS_EN |
+		   RG_SYSPLL_BIAS_LPF_EN);
+	core_write(priv, CORE_PLL_GROUP2,
+		   RG_SYSPLL_EN_NORMAL | RG_SYSPLL_VODEN |
+		   RG_SYSPLL_POSDIV(1));
+	core_write(priv, CORE_PLL_GROUP7,
+		   RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C(3) |
+		   RG_LCDDS_PWDB | RG_LCDDS_ISO_EN);
Quoted 8 lines

drivers/net/dsa/mt7530.c line 596

Quoted 5 lines
drivers/net/dsa/mt7530.c new file +5 -0
+	core_set(priv, CORE_TRGMII_GSW_CLK_CG,
+		 REG_GSWCK_EN | REG_TRGMIICK_EN);
+
+	if (!trgint)
+		for (i = 0 ; i < 5 ; i++)

Why only 5 here? All other similar loops are to 6. Replacing 5 with a #define might help make this more readable.

the same as above, it should be corrected

Quoted 9 lines
Quoted 9 lines
drivers/net/dsa/mt7530.c new file +9 -0
+			mt7530_rmw(priv, MT7530_TRGMII_RD(i),
+				   RD_TAP_MASK, RD_TAP(16));
+	else
+		mt7623_trgmii_set(priv, GSW_INTF_MODE, INTF_MODE_TRGMII);
+
+	return 0;
+}
+
+static int
Quoted 8 lines

drivers/net/dsa/mt7530.c line 611

Quoted 6 lines
drivers/net/dsa/mt7530.c new file +6 -0
+mt7623_pad_clk_setup(struct dsa_switch *ds)
+{
+	struct mt7530_priv *priv = ds->priv;
+	int i;
+
+	for (i = 0 ; i < 6; i++)

MT7530_CPU_PORT?

the same as above , it should be corrected

Quoted 5 lines

drivers/net/dsa/mt7530.h line 30

Quoted 2 lines
drivers/net/dsa/mt7530.h new file +2 -0
+
+/* Registers to mac forward conrol for unknown frames */

/conrol/control

will fix it up

Quoted 5 lines

drivers/net/dsa/mt7530.h line 102

Quoted 2 lines
drivers/net/dsa/mt7530.h new file +2 -0
+
+/* Registor for port control */

Register

will fix it up

Quoted 4 lines
Quoted 1 line

+/* Regiser for TOP signal control */

Register

will fix it up

Quoted 18 lines
Quoted 1 line

+/* struct mt7530_priv - This is the main datasructure for holding the state

data structure

Quoted 5 lines

+ * of the driver
+ * @dev: The device pointer
+ * @ds: The pointer to the dsa core structure
+ * @bus: The bus used for the device and built-in PHY
+ * @ethsys: The regmap used for enabling the necessary PLL

Quoted 8 lines

+ * @ethernet: The regmap used for access TRGMII-based registers
+ * @core_pwr: The power supplied into the core
+ * @io_pwr: The power supplied into the I/O
+ * @mcm: Flag for distinguishing if standalone IC or module
+ * coupling
+ * @reset: The descriptor for GPIO line tied to its reset pin
+ * @phy_mode: The xMII for cpu port used
+ * @ports: Holding the state amongs ports

Quoted 1 line

among

will fix it up

thank for your careful reviewing again!!

Quoted 1 line

Andrew

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