All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/4]: net: dsa: mt7530: support MT7530 in the MT7621 So
@ 2019-01-14  7:03 gerg
  2019-01-14  7:03 ` [PATCHv2 1/4] net: ethernet: mediatek: support MT7621 SoC ethernet hardware gerg
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: gerg @ 2019-01-14  7:03 UTC (permalink / raw)
  To: sean.wang, bjorn, andrew, vivien.didelot, f.fainelli, netdev
  Cc: rene, john, neil


This is the second version of a patch series supporting the MT7530
switch as used in the MediaTek MT7621 SoC. Unlike the MediaTek MT7623
the MT7621 is built around a dual core MIPS CPU architecture. But
inside it uses basically the same 7530 switch.

These patches resolves all issues I had with version 1, and I can now
reliably use the driver on a 7621 SoC platform. These patches were
generated against linux-5.0-rc2.

The first 2 patches are new to the series and enable support for the
existing kernel mediatek ethernet driver on the MT7621 SoC. This support
is from Bjørn Mork, with an update and fix by me. Using this driver
fixed a number of problems I had (TX checksums, large RX packet drop)
over the staging driver (drivers/staging/mt7621-eth).

Patch 3 modifies the mt7530 DSA driver to support the 7530 switch as
implemented in the Mediatek MT7621 SoC. The last patch updates the
devicetree bindings to reflect the new support in the mt7530 driver.

Creating a new binding for the MT7621 seems like the only viable approach
to distinguish between a stand alone 7530 switch, the silicon module
in the MT7623 SoC and the silicon in the MT7621. Certainly the 7530 ID
register in the MT7623 and MT7621 returns the same value, "0x7530001".

Looking at the mt7530.c DSA driver it might make seom sense to convert
the existing "mediatek,mcm" binding to something like "mediatek,mt7623"
to be consistent with this new MT7621 support. As far as I can tell
this is the intention of this binding.

Any thoughts greatly appreciated...

 Documentation/devicetree/bindings/net/dsa/mt7530.txt |    3
 drivers/net/dsa/mt7530.c                             |   97 +++++++++++--------
 drivers/net/dsa/mt7530.h                             |    9 +
 drivers/net/ethernet/mediatek/Kconfig                |    2
 drivers/net/ethernet/mediatek/mtk_eth_soc.c          |   49 ++++++++-
 drivers/net/ethernet/mediatek/mtk_eth_soc.h          |    4
 6 files changed, 115 insertions(+), 49 deletions(-)

v1: initial patch series
v2: rebase to linux-5.0-rc2
    include mediatek ethernet driver changes
    change to use devicetree binding to idenify platform

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCHv2 1/4] net: ethernet: mediatek: support MT7621 SoC ethernet hardware
  2019-01-14  7:03 [PATCHv2 0/4]: net: dsa: mt7530: support MT7530 in the MT7621 So gerg
@ 2019-01-14  7:03 ` gerg
  2019-01-14  7:03 ` [PATCHv2 2/4] net: ethernet: mediatek: do not force autonegiation at init gerg
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: gerg @ 2019-01-14  7:03 UTC (permalink / raw)
  To: sean.wang, bjorn, andrew, vivien.didelot, f.fainelli, netdev
  Cc: rene, john, neil, Greg Ungerer

From: Bjørn Mork <bjorn@mork.no>

The Mediatek MT7621 SoC contains the same ethernet hardware module as
used on a number of other MediaTek SoC parts. There are some minor
differences to deal with but we can use the same driver to support
them all.

This patch is based on work by Bjørn Mork <bjorn@mork.no>, and his
original patch is at:

https://github.com/bmork/LEDE/commit/3293bc63f5461ca1eb0bbc4ed90145335e7e3404

There is an additional compatible devicetree type added, and the primary
change to the code required is to support a single interrupt (for both
RX and TX interrupts).

Signed-off-by: Bjørn Mork <bjorn@mork.no>
[gerg@kernel.org: rebase to mainline and irq handler fix]
Signed-off-by: Greg Ungerer <gerg@kernel.org>
---
 drivers/net/ethernet/mediatek/Kconfig       |  2 +-
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 48 ++++++++++++++++++---
 drivers/net/ethernet/mediatek/mtk_eth_soc.h |  4 ++
 3 files changed, 46 insertions(+), 8 deletions(-)

v2: first patch in this series for this change

diff --git a/drivers/net/ethernet/mediatek/Kconfig b/drivers/net/ethernet/mediatek/Kconfig
index f9149d2a4694..43656f961891 100644
--- a/drivers/net/ethernet/mediatek/Kconfig
+++ b/drivers/net/ethernet/mediatek/Kconfig
@@ -1,6 +1,6 @@
 config NET_VENDOR_MEDIATEK
 	bool "MediaTek ethernet driver"
-	depends on ARCH_MEDIATEK
+	depends on ARCH_MEDIATEK || SOC_MT7621
 	---help---
 	  If you have a Mediatek SoC with ethernet, say Y.
 
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index fe9653fa8aea..c7763a189619 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1761,6 +1761,22 @@ static irqreturn_t mtk_handle_irq_tx(int irq, void *_eth)
 	return IRQ_HANDLED;
 }
 
+static irqreturn_t mtk_handle_irq(int irq, void *_eth)
+{
+	struct mtk_eth *eth = _eth;
+
+	if (mtk_r32(eth, MTK_PDMA_INT_MASK) & MTK_RX_DONE_INT) {
+		if (mtk_r32(eth, MTK_PDMA_INT_STATUS) & MTK_RX_DONE_INT)
+			mtk_handle_irq_rx(irq, _eth);
+	}
+	if (mtk_r32(eth, MTK_QDMA_INT_MASK) & MTK_TX_DONE_INT) {
+		if (mtk_r32(eth, MTK_QMTK_INT_STATUS) & MTK_TX_DONE_INT)
+			mtk_handle_irq_tx(irq, _eth);
+	}
+
+	return IRQ_HANDLED;
+}
+
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static void mtk_poll_controller(struct net_device *dev)
 {
@@ -2501,7 +2517,10 @@ static int mtk_probe(struct platform_device *pdev)
 	}
 
 	for (i = 0; i < 3; i++) {
-		eth->irq[i] = platform_get_irq(pdev, i);
+		if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0)
+			eth->irq[i] = eth->irq[0];
+		else
+			eth->irq[i] = platform_get_irq(pdev, i);
 		if (eth->irq[i] < 0) {
 			dev_err(&pdev->dev, "no IRQ%d resource found\n", i);
 			return -ENXIO;
@@ -2544,13 +2563,21 @@ static int mtk_probe(struct platform_device *pdev)
 			goto err_deinit_hw;
 	}
 
-	err = devm_request_irq(eth->dev, eth->irq[1], mtk_handle_irq_tx, 0,
-			       dev_name(eth->dev), eth);
-	if (err)
-		goto err_free_dev;
+	if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) {
+		err = devm_request_irq(eth->dev, eth->irq[0],
+				       mtk_handle_irq, 0,
+				       dev_name(eth->dev), eth);
+	} else {
+		err = devm_request_irq(eth->dev, eth->irq[1],
+				       mtk_handle_irq_tx, 0,
+				       dev_name(eth->dev), eth);
+		if (err)
+			goto err_free_dev;
 
-	err = devm_request_irq(eth->dev, eth->irq[2], mtk_handle_irq_rx, 0,
-			       dev_name(eth->dev), eth);
+		err = devm_request_irq(eth->dev, eth->irq[2],
+				       mtk_handle_irq_rx, 0,
+				       dev_name(eth->dev), eth);
+	}
 	if (err)
 		goto err_free_dev;
 
@@ -2623,6 +2650,12 @@ static const struct mtk_soc_data mt2701_data = {
 	.required_pctl = true,
 };
 
+static const struct mtk_soc_data mt7621_data = {
+	.caps = MTK_SHARED_INT,
+	.required_clks = MT7621_CLKS_BITMAP,
+	.required_pctl = false,
+};
+
 static const struct mtk_soc_data mt7622_data = {
 	.caps = MTK_DUAL_GMAC_SHARED_SGMII | MTK_GMAC1_ESW | MTK_HWLRO,
 	.required_clks = MT7622_CLKS_BITMAP,
@@ -2637,6 +2670,7 @@ static const struct mtk_soc_data mt7623_data = {
 
 const struct of_device_id of_mtk_match[] = {
 	{ .compatible = "mediatek,mt2701-eth", .data = &mt2701_data},
+	{ .compatible = "mediatek,mt7621-eth", .data = &mt7621_data},
 	{ .compatible = "mediatek,mt7622-eth", .data = &mt7622_data},
 	{ .compatible = "mediatek,mt7623-eth", .data = &mt7623_data},
 	{},
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 46819297fc3e..f7501997cea0 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -363,6 +363,7 @@
 #define ETHSYS_CHIPID4_7	0x4
 #define MT7623_ETH		7623
 #define MT7622_ETH		7622
+#define MT7621_ETH		7621
 
 /* ethernet subsystem config register */
 #define ETHSYS_SYSCFG0		0x14
@@ -488,6 +489,8 @@ enum mtk_clks_map {
 				 BIT(MTK_CLK_SGMII_CDR_FB) | \
 				 BIT(MTK_CLK_SGMII_CK) | \
 				 BIT(MTK_CLK_ETH2PLL))
+#define MT7621_CLKS_BITMAP	(0)
+
 enum mtk_dev_state {
 	MTK_HW_INIT,
 	MTK_RESETTING
@@ -567,6 +570,7 @@ struct mtk_rx_ring {
 #define MTK_DUAL_GMAC_SHARED_SGMII	(BIT(11) | MTK_GMAC1_SGMII | \
 					 MTK_GMAC2_SGMII)
 #define MTK_HWLRO			BIT(12)
+#define MTK_SHARED_INT			BIT(13)
 #define MTK_HAS_CAPS(caps, _x)		(((caps) & (_x)) == (_x))
 
 /* struct mtk_eth_data -	This is the structure holding all differences
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCHv2 2/4] net: ethernet: mediatek: do not force autonegiation at init
  2019-01-14  7:03 [PATCHv2 0/4]: net: dsa: mt7530: support MT7530 in the MT7621 So gerg
  2019-01-14  7:03 ` [PATCHv2 1/4] net: ethernet: mediatek: support MT7621 SoC ethernet hardware gerg
@ 2019-01-14  7:03 ` gerg
  2019-01-14 12:55   ` René van Dorst
  2019-01-14  7:03 ` [PATCHv2 3/4] net: dsa: mt7530: support the 7530 switch on the Mediatek MT7621 SoC gerg
  2019-01-14  7:03 ` [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621 gerg
  3 siblings, 1 reply; 13+ messages in thread
From: gerg @ 2019-01-14  7:03 UTC (permalink / raw)
  To: sean.wang, bjorn, andrew, vivien.didelot, f.fainelli, netdev
  Cc: rene, john, neil, Greg Ungerer

From: Greg Ungerer <gerg@kernel.org>

Do not attempt to force a port phy auto-ngeotiation during the driver
init phase. It is not necessary and results in a warning at system
boot up:

mtk_soc_eth 1e100000.ethernet: generated random MAC address be:e7:d4:9d:7d:b0
mtk_soc_eth 1e100000.ethernet: connected mac 0 to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]
------------[ cut here ]------------
WARNING: CPU: 1 PID: 1 at drivers/net/phy/phy.c:548 phy_start_aneg+0xf0/0x1c0
called from state READY
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc1-00005-ge3368ed2e336-dirty #11
Stack : 0000007a 00000000 00000000 807e0000 80710000 8006fb04 8072db28 0000000b
        00000000 00000000 8072d368 87c3db74 80770000 00000001 87c3db08 2892b90e
        00000000 00000000 80820000 00000000 00000000 2d363333 0000007b 00000000
        2d316372 00000000 00000000 00000000 80770000 00000000 80715e70 00000009
        00000224 80716e38 87d6a800 80660334 00000001 80340714 00000004 807e0004
        ...
Call Trace:
[<8000cfe0>] show_stack+0x94/0x12c
[<8060de6c>] dump_stack+0x8c/0xd0
[<80028430>] __warn+0x10c/0x120
[<80028488>] warn_slowpath_fmt+0x44/0x68
[<803adf78>] phy_start_aneg+0xf0/0x1c0
[<807aed8c>] mtk_init+0x434/0x4a4
[<8047310c>] register_netdevice+0x94/0x6d0
[<8047376c>] register_netdev+0x24/0x40
[<803bf4c0>] mtk_probe+0x2a0/0x930
[<80352d24>] platform_drv_probe+0x40/0x9c
[<80350e48>] really_probe+0x1f0/0x35c
[<803513e4>] __driver_attach+0x10c/0x114
[<8034ec88>] bus_for_each_dev+0x70/0xd0
[<8035023c>] bus_add_driver+0x1f0/0x25c
[<80351c70>] driver_register+0x80/0x144
[<800015f4>] do_one_initcall+0x50/0x1ac
[<80795e48>] kernel_init_freeable+0x184/0x26c
[<8062bbd4>] kernel_init+0x14/0x110
[<80007198>] ret_from_kernel_thread+0x14/0x1c
---[ end trace 6e884e9f12ed14c0 ]---
mtk_soc_eth 1e100000.ethernet eth0: mediatek frame engine at 0xbe100000, irq 22

Signed-off-by: Greg Ungerer <gerg@kernel.org>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 -
 1 file changed, 1 deletion(-)

v2: first patch in this series for this change

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index c7763a189619..e5a32d43a71c 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -356,7 +356,6 @@ static int mtk_phy_connect(struct net_device *dev)
 	linkmode_copy(dev->phydev->advertising, dev->phydev->supported);
 	linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
 			 dev->phydev->advertising);
-	phy_start_aneg(dev->phydev);
 
 	of_node_put(np);
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCHv2 3/4] net: dsa: mt7530: support the 7530 switch on the Mediatek MT7621 SoC
  2019-01-14  7:03 [PATCHv2 0/4]: net: dsa: mt7530: support MT7530 in the MT7621 So gerg
  2019-01-14  7:03 ` [PATCHv2 1/4] net: ethernet: mediatek: support MT7621 SoC ethernet hardware gerg
  2019-01-14  7:03 ` [PATCHv2 2/4] net: ethernet: mediatek: do not force autonegiation at init gerg
@ 2019-01-14  7:03 ` gerg
  2019-01-14  7:03 ` [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621 gerg
  3 siblings, 0 replies; 13+ messages in thread
From: gerg @ 2019-01-14  7:03 UTC (permalink / raw)
  To: sean.wang, bjorn, andrew, vivien.didelot, f.fainelli, netdev
  Cc: rene, john, neil, Greg Ungerer

From: Greg Ungerer <gerg@kernel.org>

The MediaTek MT7621 SoC device contains a 7530 switch, and the existing
linux kernel 7530 DSA switch driver can be used with it.

The bulk of the changes required stem from the 7621 having different
regulator and pad setup. The existing setup of these in the 7530
driver appears to be very specific to its implemtation in the Mediatek
7623 SoC. (Not entirely surprising given the 7623 is a quad core ARM
based SoC, and the 7621 is a dual core, dual thread MIPS based SoC).

Create a new devicetree type, "mediatek,mt7621", to support the 7530
switch in the 7621 SoC. There appears to be no usable ID register to
distinguish it from a 7530 in other hardware at runtime. This is used
to carry out the appropriate configuration and setup.

Signed-off-by: Greg Ungerer <gerg@kernel.org>
---
 drivers/net/dsa/mt7530.c | 97 ++++++++++++++++++++++++----------------
 drivers/net/dsa/mt7530.h |  9 ++++
 2 files changed, 67 insertions(+), 39 deletions(-)

v1: initial patch
v2: changed to use separate devicetree binding

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 74547f43b938..c396665e576c 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -622,17 +622,19 @@ static void mt7530_adjust_link(struct dsa_switch *ds, int port,
 	struct mt7530_priv *priv = ds->priv;
 
 	if (phy_is_pseudo_fixed_link(phydev)) {
-		dev_dbg(priv->dev, "phy-mode for master device = %x\n",
-			phydev->interface);
-
-		/* Setup TX circuit incluing relevant PAD and driving */
-		mt7530_pad_clk_setup(ds, phydev->interface);
-
-		/* 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 (priv->id == ID_MT7530) {
+			dev_dbg(priv->dev, "phy-mode for master device = %x\n",
+				phydev->interface);
+
+			/* Setup TX circuit incluing relevant PAD and driving */
+			mt7530_pad_clk_setup(ds, phydev->interface);
+
+			/* 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);
+		}
 	} else {
 		u16 lcl_adv = 0, rmt_adv = 0;
 		u8 flowctrl;
@@ -688,6 +690,10 @@ mt7530_cpu_port_enable(struct mt7530_priv *priv,
 	/* Unknown unicast frame fordwarding to the cpu port */
 	mt7530_set(priv, MT7530_MFC, UNU_FFP(BIT(port)));
 
+	/* Set CPU port number */
+	if (priv->id == ID_MT7621)
+		mt7530_rmw(priv, MT7530_MFC, CPU_MASK, CPU_EN | CPU_PORT(port));
+
 	/* CPU port gets connected to all user ports of
 	 * the switch
 	 */
@@ -1220,24 +1226,27 @@ mt7530_setup(struct dsa_switch *ds)
 	 * as two netdev instances.
 	 */
 	dn = ds->ports[MT7530_CPU_PORT].master->dev.of_node->parent;
-	priv->ethernet = syscon_node_to_regmap(dn);
-	if (IS_ERR(priv->ethernet))
-		return PTR_ERR(priv->ethernet);
 
-	regulator_set_voltage(priv->core_pwr, 1000000, 1000000);
-	ret = regulator_enable(priv->core_pwr);
-	if (ret < 0) {
-		dev_err(priv->dev,
-			"Failed to enable core power: %d\n", ret);
-		return ret;
-	}
+	if (priv->id == ID_MT7530) {
+		priv->ethernet = syscon_node_to_regmap(dn);
+		if (IS_ERR(priv->ethernet))
+			return PTR_ERR(priv->ethernet);
+
+		regulator_set_voltage(priv->core_pwr, 1000000, 1000000);
+		ret = regulator_enable(priv->core_pwr);
+		if (ret < 0) {
+			dev_err(priv->dev,
+				"Failed to enable core power: %d\n", ret);
+			return ret;
+		}
 
-	regulator_set_voltage(priv->io_pwr, 3300000, 3300000);
-	ret = regulator_enable(priv->io_pwr);
-	if (ret < 0) {
-		dev_err(priv->dev, "Failed to enable io pwr: %d\n",
-			ret);
-		return ret;
+		regulator_set_voltage(priv->io_pwr, 3300000, 3300000);
+		ret = regulator_enable(priv->io_pwr);
+		if (ret < 0) {
+			dev_err(priv->dev, "Failed to enable io pwr: %d\n",
+				ret);
+			return ret;
+		}
 	}
 
 	/* Reset whole chip through gpio pin or memory-mapped registers for
@@ -1327,9 +1336,17 @@ static const struct dsa_switch_ops mt7530_switch_ops = {
 	.port_vlan_del		= mt7530_port_vlan_del,
 };
 
+static const struct of_device_id mt7530_of_match[] = {
+	{ .compatible = "mediatek,mt7621", .data = (void *)ID_MT7621, },
+	{ .compatible = "mediatek,mt7530", .data = (void *)ID_MT7530, },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, mt7530_of_match);
+
 static int
 mt7530_probe(struct mdio_device *mdiodev)
 {
+	const struct of_device_id *of_id;
 	struct mt7530_priv *priv;
 	struct device_node *dn;
 
@@ -1357,13 +1374,21 @@ mt7530_probe(struct mdio_device *mdiodev)
 		}
 	}
 
-	priv->core_pwr = devm_regulator_get(&mdiodev->dev, "core");
-	if (IS_ERR(priv->core_pwr))
-		return PTR_ERR(priv->core_pwr);
+	/* Get the hardware identifier from the devicetree node.
+	 * We will need it for some of the clock and regulator setup.
+	 */
+	of_id = of_match_node(mt7530_of_match, dn);
+	priv->id = (unsigned int)of_id->data;
 
-	priv->io_pwr = devm_regulator_get(&mdiodev->dev, "io");
-	if (IS_ERR(priv->io_pwr))
-		return PTR_ERR(priv->io_pwr);
+	if (priv->id == ID_MT7530) {
+		priv->core_pwr = devm_regulator_get(&mdiodev->dev, "core");
+		if (IS_ERR(priv->core_pwr))
+			return PTR_ERR(priv->core_pwr);
+
+		priv->io_pwr = devm_regulator_get(&mdiodev->dev, "io");
+		if (IS_ERR(priv->io_pwr))
+			return PTR_ERR(priv->io_pwr);
+	}
 
 	/* Not MCM that indicates switch works as the remote standalone
 	 * integrated circuit so the GPIO pin would be used to complete
@@ -1409,12 +1434,6 @@ mt7530_remove(struct mdio_device *mdiodev)
 	mutex_destroy(&priv->reg_mutex);
 }
 
-static const struct of_device_id mt7530_of_match[] = {
-	{ .compatible = "mediatek,mt7530" },
-	{ /* sentinel */ },
-};
-MODULE_DEVICE_TABLE(of, mt7530_of_match);
-
 static struct mdio_driver mt7530_mdio_driver = {
 	.probe  = mt7530_probe,
 	.remove = mt7530_remove,
diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h
index d9b407a22a58..a95ed958df5b 100644
--- a/drivers/net/dsa/mt7530.h
+++ b/drivers/net/dsa/mt7530.h
@@ -19,6 +19,11 @@
 #define MT7530_NUM_FDB_RECORDS		2048
 #define MT7530_ALL_MEMBERS		0xff
 
+enum {
+	ID_MT7530 = 0,
+	ID_MT7621 = 1,
+};
+
 #define	NUM_TRGMII_CTRL			5
 
 #define TRGMII_BASE(x)			(0x10000 + (x))
@@ -36,6 +41,9 @@
 #define  UNM_FFP(x)			(((x) & 0xff) << 16)
 #define  UNU_FFP(x)			(((x) & 0xff) << 8)
 #define  UNU_FFP_MASK			UNU_FFP(~0)
+#define  CPU_EN				BIT(7)
+#define  CPU_PORT(x)			((x) << 4)
+#define  CPU_MASK			(0xf << 4)
 
 /* Registers for address table access */
 #define MT7530_ATA1			0x74
@@ -430,6 +438,7 @@ struct mt7530_priv {
 	struct regulator	*core_pwr;
 	struct regulator	*io_pwr;
 	struct gpio_desc	*reset;
+	unsigned int		id;
 	bool			mcm;
 
 	struct mt7530_port	ports[MT7530_NUM_PORTS];
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621
  2019-01-14  7:03 [PATCHv2 0/4]: net: dsa: mt7530: support MT7530 in the MT7621 So gerg
                   ` (2 preceding siblings ...)
  2019-01-14  7:03 ` [PATCHv2 3/4] net: dsa: mt7530: support the 7530 switch on the Mediatek MT7621 SoC gerg
@ 2019-01-14  7:03 ` gerg
  2019-01-14 14:07   ` Andrew Lunn
  3 siblings, 1 reply; 13+ messages in thread
From: gerg @ 2019-01-14  7:03 UTC (permalink / raw)
  To: sean.wang, bjorn, andrew, vivien.didelot, f.fainelli, netdev
  Cc: rene, john, neil, Greg Ungerer

From: Greg Ungerer <gerg@kernel.org>

Add devicetree binding to support the compatible mt7530 switch as used
in the MediaTek MT7621 SoC.

Signed-off-by: Greg Ungerer <gerg@kernel.org>
---
 Documentation/devicetree/bindings/net/dsa/mt7530.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

v1: initial patch
v2: changed to use separate devicetree binding

diff --git a/Documentation/devicetree/bindings/net/dsa/mt7530.txt b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
index aa3527f71fdc..b4e2af30776f 100644
--- a/Documentation/devicetree/bindings/net/dsa/mt7530.txt
+++ b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
@@ -3,7 +3,8 @@ Mediatek MT7530 Ethernet switch
 
 Required properties:
 
-- compatible: Must be compatible = "mediatek,mt7530";
+- compatible: may be compatible = "mediatek,mt7530"
+	or compatible = "mediatek,mt7621"
 - #address-cells: Must be 1.
 - #size-cells: Must be 0.
 - mediatek,mcm: Boolean; if defined, indicates that either MT7530 is the part
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCHv2 2/4] net: ethernet: mediatek: do not force autonegiation at init
  2019-01-14  7:03 ` [PATCHv2 2/4] net: ethernet: mediatek: do not force autonegiation at init gerg
@ 2019-01-14 12:55   ` René van Dorst
  2019-01-15  4:51     ` Greg Ungerer
  0 siblings, 1 reply; 13+ messages in thread
From: René van Dorst @ 2019-01-14 12:55 UTC (permalink / raw)
  To: gerg
  Cc: sean.wang, bjorn, andrew, vivien.didelot, f.fainelli, netdev, john, neil

Quoting gerg@kernel.org:

> From: Greg Ungerer <gerg@kernel.org>
>
> Do not attempt to force a port phy auto-ngeotiation during the driver
> init phase. It is not necessary and results in a warning at system
> boot up:
>
> mtk_soc_eth 1e100000.ethernet: generated random MAC address be:e7:d4:9d:7d:b0
> mtk_soc_eth 1e100000.ethernet: connected mac 0 to PHY at fixed-0:00  
> [uid=00000000, driver=Generic PHY]
> ------------[ cut here ]------------
> WARNING: CPU: 1 PID: 1 at drivers/net/phy/phy.c:548 phy_start_aneg+0xf0/0x1c0
> called from state READY
> Modules linked in:
> CPU: 1 PID: 1 Comm: swapper/0 Not tainted  
> 5.0.0-rc1-00005-ge3368ed2e336-dirty #11
> Stack : 0000007a 00000000 00000000 807e0000 80710000 8006fb04  
> 8072db28 0000000b
>         00000000 00000000 8072d368 87c3db74 80770000 00000001  
> 87c3db08 2892b90e
>         00000000 00000000 80820000 00000000 00000000 2d363333  
> 0000007b 00000000
>         2d316372 00000000 00000000 00000000 80770000 00000000  
> 80715e70 00000009
>         00000224 80716e38 87d6a800 80660334 00000001 80340714  
> 00000004 807e0004
>         ...
> Call Trace:
> [<8000cfe0>] show_stack+0x94/0x12c
> [<8060de6c>] dump_stack+0x8c/0xd0
> [<80028430>] __warn+0x10c/0x120
> [<80028488>] warn_slowpath_fmt+0x44/0x68
> [<803adf78>] phy_start_aneg+0xf0/0x1c0
> [<807aed8c>] mtk_init+0x434/0x4a4
> [<8047310c>] register_netdevice+0x94/0x6d0
> [<8047376c>] register_netdev+0x24/0x40
> [<803bf4c0>] mtk_probe+0x2a0/0x930
> [<80352d24>] platform_drv_probe+0x40/0x9c
> [<80350e48>] really_probe+0x1f0/0x35c
> [<803513e4>] __driver_attach+0x10c/0x114
> [<8034ec88>] bus_for_each_dev+0x70/0xd0
> [<8035023c>] bus_add_driver+0x1f0/0x25c
> [<80351c70>] driver_register+0x80/0x144
> [<800015f4>] do_one_initcall+0x50/0x1ac
> [<80795e48>] kernel_init_freeable+0x184/0x26c
> [<8062bbd4>] kernel_init+0x14/0x110
> [<80007198>] ret_from_kernel_thread+0x14/0x1c
> ---[ end trace 6e884e9f12ed14c0 ]---
> mtk_soc_eth 1e100000.ethernet eth0: mediatek frame engine at  
> 0xbe100000, irq 22
>
> Signed-off-by: Greg Ungerer <gerg@kernel.org>
> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 -
>  1 file changed, 1 deletion(-)
>
> v2: first patch in this series for this change
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c  
> b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index c7763a189619..e5a32d43a71c 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -356,7 +356,6 @@ static int mtk_phy_connect(struct net_device *dev)
>  	linkmode_copy(dev->phydev->advertising, dev->phydev->supported);
>  	linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
>  			 dev->phydev->advertising);
> -	phy_start_aneg(dev->phydev);
>
>  	of_node_put(np);
>
> --
> 2.17.1

Hi Greg,

I think this is recently fix and applied, see  
https://patchwork.kernel.org/patch/10753537/

Greats,

René

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621
  2019-01-14  7:03 ` [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621 gerg
@ 2019-01-14 14:07   ` Andrew Lunn
  2019-01-15  5:07     ` Greg Ungerer
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2019-01-14 14:07 UTC (permalink / raw)
  To: gerg
  Cc: sean.wang, bjorn, vivien.didelot, f.fainelli, netdev, rene, john, neil

On Mon, Jan 14, 2019 at 05:03:34PM +1000, gerg@kernel.org wrote:
> From: Greg Ungerer <gerg@kernel.org>
> 
> Add devicetree binding to support the compatible mt7530 switch as used
> in the MediaTek MT7621 SoC.

Hi Gerg

It gets messy, but could you try to indicate that core-supply and
io-supply are not required for your new device. Currently the binding
indicates they are required for all devices.

Thanks
	Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCHv2 2/4] net: ethernet: mediatek: do not force autonegiation at init
  2019-01-14 12:55   ` René van Dorst
@ 2019-01-15  4:51     ` Greg Ungerer
  0 siblings, 0 replies; 13+ messages in thread
From: Greg Ungerer @ 2019-01-15  4:51 UTC (permalink / raw)
  To: René van Dorst
  Cc: sean.wang, bjorn, andrew, vivien.didelot, f.fainelli, netdev, john, neil

Hi René,

On 14/1/19 10:55 pm, René van Dorst wrote:
> Quoting gerg@kernel.org:
> 
>> From: Greg Ungerer <gerg@kernel.org>
>>
>> Do not attempt to force a port phy auto-ngeotiation during the driver
>> init phase. It is not necessary and results in a warning at system
>> boot up:
>>
>> mtk_soc_eth 1e100000.ethernet: generated random MAC address be:e7:d4:9d:7d:b0
>> mtk_soc_eth 1e100000.ethernet: connected mac 0 to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]
>> ------------[ cut here ]------------
>> WARNING: CPU: 1 PID: 1 at drivers/net/phy/phy.c:548 phy_start_aneg+0xf0/0x1c0
>> called from state READY
>> Modules linked in:
>> CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc1-00005-ge3368ed2e336-dirty #11
>> Stack : 0000007a 00000000 00000000 807e0000 80710000 8006fb04 8072db28 0000000b
>>         00000000 00000000 8072d368 87c3db74 80770000 00000001 87c3db08 2892b90e
>>         00000000 00000000 80820000 00000000 00000000 2d363333 0000007b 00000000
>>         2d316372 00000000 00000000 00000000 80770000 00000000 80715e70 00000009
>>         00000224 80716e38 87d6a800 80660334 00000001 80340714 00000004 807e0004
>>         ...
>> Call Trace:
>> [<8000cfe0>] show_stack+0x94/0x12c
>> [<8060de6c>] dump_stack+0x8c/0xd0
>> [<80028430>] __warn+0x10c/0x120
>> [<80028488>] warn_slowpath_fmt+0x44/0x68
>> [<803adf78>] phy_start_aneg+0xf0/0x1c0
>> [<807aed8c>] mtk_init+0x434/0x4a4
>> [<8047310c>] register_netdevice+0x94/0x6d0
>> [<8047376c>] register_netdev+0x24/0x40
>> [<803bf4c0>] mtk_probe+0x2a0/0x930
>> [<80352d24>] platform_drv_probe+0x40/0x9c
>> [<80350e48>] really_probe+0x1f0/0x35c
>> [<803513e4>] __driver_attach+0x10c/0x114
>> [<8034ec88>] bus_for_each_dev+0x70/0xd0
>> [<8035023c>] bus_add_driver+0x1f0/0x25c
>> [<80351c70>] driver_register+0x80/0x144
>> [<800015f4>] do_one_initcall+0x50/0x1ac
>> [<80795e48>] kernel_init_freeable+0x184/0x26c
>> [<8062bbd4>] kernel_init+0x14/0x110
>> [<80007198>] ret_from_kernel_thread+0x14/0x1c
>> ---[ end trace 6e884e9f12ed14c0 ]---
>> mtk_soc_eth 1e100000.ethernet eth0: mediatek frame engine at 0xbe100000, irq 22
>>
>> Signed-off-by: Greg Ungerer <gerg@kernel.org>
>> ---
>>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> v2: first patch in this series for this change
>>
>> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
>> index c7763a189619..e5a32d43a71c 100644
>> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
>> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
>> @@ -356,7 +356,6 @@ static int mtk_phy_connect(struct net_device *dev)
>>      linkmode_copy(dev->phydev->advertising, dev->phydev->supported);
>>      linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
>>               dev->phydev->advertising);
>> -    phy_start_aneg(dev->phydev);
>>
>>      of_node_put(np);
>>
>> -- 
>> 2.17.1
> 
> Hi Greg,
> 
> I think this is recently fix and applied, see https://patchwork.kernel.org/patch/10753537/

Yep, looks like that will do it. I will drop this one.

Regards
Greg

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621
  2019-01-14 14:07   ` Andrew Lunn
@ 2019-01-15  5:07     ` Greg Ungerer
  2019-01-15 13:18       ` Andrew Lunn
  0 siblings, 1 reply; 13+ messages in thread
From: Greg Ungerer @ 2019-01-15  5:07 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: sean.wang, bjorn, vivien.didelot, f.fainelli, netdev, rene, john, neil

Hi Andrew,

On 15/1/19 12:07 am, Andrew Lunn wrote:
> On Mon, Jan 14, 2019 at 05:03:34PM +1000, gerg@kernel.org wrote:
>> From: Greg Ungerer <gerg@kernel.org>
>>
>> Add devicetree binding to support the compatible mt7530 switch as used
>> in the MediaTek MT7621 SoC.
> 
> Hi Gerg
> 
> It gets messy, but could you try to indicate that core-supply and
> io-supply are not required for your new device. Currently the binding
> indicates they are required for all devices.

Yep, good point. Are you thinking something like this?

--- a/Documentation/devicetree/bindings/net/dsa/mt7530.txt
+++ b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
@@ -3,16 +3,19 @@ Mediatek MT7530 Ethernet switch

  Required properties:

-- compatible: Must be compatible = "mediatek,mt7530";
+- compatible: may be compatible = "mediatek,mt7530"
+       or compatible = "mediatek,mt7621"
  - #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.
+       (not required on mediatek,mt7621)
  - 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.
+       (not required on mediatek,mt7621)

  If the property mediatek,mcm isn't defined, following property is required


Regards
Greg

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621
  2019-01-15  5:07     ` Greg Ungerer
@ 2019-01-15 13:18       ` Andrew Lunn
  2019-01-16 13:14         ` Greg Ungerer
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2019-01-15 13:18 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: sean.wang, bjorn, vivien.didelot, f.fainelli, netdev, rene, john, neil

On Tue, Jan 15, 2019 at 03:07:33PM +1000, Greg Ungerer wrote:
> Hi Andrew,
> 
> On 15/1/19 12:07 am, Andrew Lunn wrote:
> >On Mon, Jan 14, 2019 at 05:03:34PM +1000, gerg@kernel.org wrote:
> >>From: Greg Ungerer <gerg@kernel.org>
> >>
> >>Add devicetree binding to support the compatible mt7530 switch as used
> >>in the MediaTek MT7621 SoC.
> >
> >Hi Gerg
> >
> >It gets messy, but could you try to indicate that core-supply and
> >io-supply are not required for your new device. Currently the binding
> >indicates they are required for all devices.
> 
> Yep, good point. Are you thinking something like this?
> 
> --- a/Documentation/devicetree/bindings/net/dsa/mt7530.txt
> +++ b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
> @@ -3,16 +3,19 @@ Mediatek MT7530 Ethernet switch
> 
>  Required properties:
> 
> -- compatible: Must be compatible = "mediatek,mt7530";
> +- compatible: may be compatible = "mediatek,mt7530"
> +       or compatible = "mediatek,mt7621"
>  - #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.
> +       (not required on mediatek,mt7621)
>  - 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.
> +       (not required on mediatek,mt7621)
> 
>  If the property mediatek,mcm isn't defined, following property is required

Hi Greg

As i said, it is a bit messy. I would probably have a section:

Required properties

which lists all common required properties. And then a section

Required properties mediatek,mt7530

With those which are required by that device.

     Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621
  2019-01-15 13:18       ` Andrew Lunn
@ 2019-01-16 13:14         ` Greg Ungerer
  2019-01-16 16:12           ` Andrew Lunn
  0 siblings, 1 reply; 13+ messages in thread
From: Greg Ungerer @ 2019-01-16 13:14 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: sean.wang, bjorn, vivien.didelot, f.fainelli, netdev, rene, john, neil

Hi Andrew,

On 15/1/19 11:18 pm, Andrew Lunn wrote:
[snip]
> As i said, it is a bit messy. I would probably have a section:
> 
> Required properties
> 
> which lists all common required properties. And then a section
> 
> Required properties mediatek,mt7530
> 
> With those which are required by that device.


Ok, I see what you mean.
The simplest approach is something like this:

diff --git a/Documentation/devicetree/bindings/net/dsa/mt7530.txt b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
index aa3527f71fdc..47aa205ee0bd 100644
--- a/Documentation/devicetree/bindings/net/dsa/mt7530.txt
+++ b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
@@ -3,12 +3,16 @@ Mediatek MT7530 Ethernet switch
  
  Required properties:
  
-- compatible: Must be compatible = "mediatek,mt7530";
+- compatible: may be compatible = "mediatek,mt7530"
+	or compatible = "mediatek,mt7621"
  - #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.
+
+If compatible mediatek,mt7530 is set then the following properties are required
+
  - 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


That leaves the existing if/else with other bindings in place after this.

Maybe I am mis-reading the mt7530.c code but I am not entirely sure that
"reset-gpios" is actually required for the mediatek,mcm not defined case -
it is optional. (And I actually don't define it for my mt7621 case where
mediatek,mcm is not defined).

Regards
Greg

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621
  2019-01-16 13:14         ` Greg Ungerer
@ 2019-01-16 16:12           ` Andrew Lunn
  2019-01-17  5:17             ` Greg Ungerer
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2019-01-16 16:12 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: sean.wang, bjorn, vivien.didelot, f.fainelli, netdev, rene, john, neil

On Wed, Jan 16, 2019 at 11:14:30PM +1000, Greg Ungerer wrote:
> Hi Andrew,
> 
> On 15/1/19 11:18 pm, Andrew Lunn wrote:
> [snip]
> >As i said, it is a bit messy. I would probably have a section:
> >
> >Required properties
> >
> >which lists all common required properties. And then a section
> >
> >Required properties mediatek,mt7530
> >
> >With those which are required by that device.
> 
> 
> Ok, I see what you mean.
> The simplest approach is something like this:
> 
> diff --git a/Documentation/devicetree/bindings/net/dsa/mt7530.txt b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
> index aa3527f71fdc..47aa205ee0bd 100644
> --- a/Documentation/devicetree/bindings/net/dsa/mt7530.txt
> +++ b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
> @@ -3,12 +3,16 @@ Mediatek MT7530 Ethernet switch
>  Required properties:
> -- compatible: Must be compatible = "mediatek,mt7530";
> +- compatible: may be compatible = "mediatek,mt7530"
> +	or compatible = "mediatek,mt7621"
>  - #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.
> +
> +If compatible mediatek,mt7530 is set then the following properties are required
> +
>  - 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

Yes, that looks good.

> 
> 
> That leaves the existing if/else with other bindings in place after this.
> 
> Maybe I am mis-reading the mt7530.c code but I am not entirely sure that
> "reset-gpios" is actually required for the mediatek,mcm not defined case -
> it is optional. (And I actually don't define it for my mt7621 case where
> mediatek,mcm is not defined).

The gpio seems to be optional in general, any only used for
device other than mediatek,mcm.

The reset controller is required for mediatek,mcm, but not others.

So it looks like the binding document needs a few fixes :-(

   Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621
  2019-01-16 16:12           ` Andrew Lunn
@ 2019-01-17  5:17             ` Greg Ungerer
  0 siblings, 0 replies; 13+ messages in thread
From: Greg Ungerer @ 2019-01-17  5:17 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: sean.wang, bjorn, vivien.didelot, f.fainelli, netdev, rene, john, neil

Hi Andrew,

On 17/1/19 2:12 am, Andrew Lunn wrote:
> On Wed, Jan 16, 2019 at 11:14:30PM +1000, Greg Ungerer wrote:
>> Hi Andrew,
>>
>> On 15/1/19 11:18 pm, Andrew Lunn wrote:
>> [snip]
>>> As i said, it is a bit messy. I would probably have a section:
>>>
>>> Required properties
>>>
>>> which lists all common required properties. And then a section
>>>
>>> Required properties mediatek,mt7530
>>>
>>> With those which are required by that device.
>>
>>
>> Ok, I see what you mean.
>> The simplest approach is something like this:
>>
>> diff --git a/Documentation/devicetree/bindings/net/dsa/mt7530.txt b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
>> index aa3527f71fdc..47aa205ee0bd 100644
>> --- a/Documentation/devicetree/bindings/net/dsa/mt7530.txt
>> +++ b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
>> @@ -3,12 +3,16 @@ Mediatek MT7530 Ethernet switch
>>   Required properties:
>> -- compatible: Must be compatible = "mediatek,mt7530";
>> +- compatible: may be compatible = "mediatek,mt7530"
>> +	or compatible = "mediatek,mt7621"
>>   - #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.
>> +
>> +If compatible mediatek,mt7530 is set then the following properties are required
>> +
>>   - 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
> 
> Yes, that looks good.
> 
>>
>>
>> That leaves the existing if/else with other bindings in place after this.
>>
>> Maybe I am mis-reading the mt7530.c code but I am not entirely sure that
>> "reset-gpios" is actually required for the mediatek,mcm not defined case -
>> it is optional. (And I actually don't define it for my mt7621 case where
>> mediatek,mcm is not defined).
> 
> The gpio seems to be optional in general, any only used for
> device other than mediatek,mcm.
> 
> The reset controller is required for mediatek,mcm, but not others.
> 
> So it looks like the binding document needs a few fixes :-(

Yep.. Thanks for the feedback though. I'll roll a v3.

Regards
Greg





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-01-17  5:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-14  7:03 [PATCHv2 0/4]: net: dsa: mt7530: support MT7530 in the MT7621 So gerg
2019-01-14  7:03 ` [PATCHv2 1/4] net: ethernet: mediatek: support MT7621 SoC ethernet hardware gerg
2019-01-14  7:03 ` [PATCHv2 2/4] net: ethernet: mediatek: do not force autonegiation at init gerg
2019-01-14 12:55   ` René van Dorst
2019-01-15  4:51     ` Greg Ungerer
2019-01-14  7:03 ` [PATCHv2 3/4] net: dsa: mt7530: support the 7530 switch on the Mediatek MT7621 SoC gerg
2019-01-14  7:03 ` [PATCHv2 4/4] dt-bindings: net: dsa: add new MT7530 binding to support MT7621 gerg
2019-01-14 14:07   ` Andrew Lunn
2019-01-15  5:07     ` Greg Ungerer
2019-01-15 13:18       ` Andrew Lunn
2019-01-16 13:14         ` Greg Ungerer
2019-01-16 16:12           ` Andrew Lunn
2019-01-17  5:17             ` Greg Ungerer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.