Skip to contentSkip to conversation

Add MV88E6xxx DSA driver and use on gwventana

PATCH Superseded Tim Harvey 3 participants 29 messages Sep 28, 2022 – Oct 4, 2022

Subsystems (4)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

v4 cover Add MV88E6xxx DSA driver and use on gwventana

This series adds a DSA driver for the MV88E6xxx based on drivers/net/phy/mv88e61xx and uses it in the gwventana_gw5904_defconfig.

The hope is that the other three boards that use the MV88E61xx driver can move to this as well eventually so that we can remove the non-dm driver and the 4 Kconfig options it requires.

The MV88E6xxx has an MDIO interface thus DM_MDIO must be used so support for a UCLASS_MDIO driver is added to the fec_mxc ethernet driver in a way that allows a fallback to the previous non DM_MDIO case as there are many boards out there using this driver that define DM_MDIO but do not have the required dt props for a DM_MDIO driver which would cause a regression.

Additionally some other patches are here suggested by Vladimir:
- ensure MDIO children are scanned on post-bind is needed
- sanity check DSA driver required ops are present
- allow DSA drivers to not require xmit/recv functions
- remove unecessary xmit/recv functions from ksz9477 driver

v4:
- use standard Linux internal MDIO dt structure
- use PHY_FIXED_ID define
- rename to mv88e6xxx
- sort includes alphabetically
- remove dsa term from function names
- reduce indentation level and remove unecessary code in of probe_mdio function
- rename pdev to mdev to represent mdio device

v3:
- fix mdios node in dt
- add Vladimir's rb tag's

v2:
- added Ramon's rb tag's to first two patches
- add patches for dsa-uclass to sanity check ops and make xmit/recv optional
- fec: fix fallback for non conforming DM_MDIO dts
- mv88e61xx:
- rebase on v2022.07-rc2 (use ofnode_get_phy_node)
- remove unused commented out fields from struct
- remove unused PORT_MASK macro
- remove phy from priv struct name
- refactor code from original drivers/net/phy/mv88e61xx with suggestions from review to consolidate some functions into mv88e61xx_dsa_port_enable
- remove unecessary skiping of disabling of CPU port
- remove unecessary dev_set_parent_priv
- remove unnecessary static init flag
- replace debug with a dev_warn if switch device-id unsupported
- remove unnecessary xmit/recv functions as we rely on the fact that only a single port is active instead of mangling packets

Tested on a Gateworks GW5904 which has a Marvell 88E6176 switch hanging off the IMX6 FEC.

Best Regards,

Tim

Tim Harvey (8):
net: mdio-uclass: scan for dm mdio children on post-bind
net: dsa: move cpu port probe to dsa_post_probe
net: dsa: ensure dsa driver has proper ops
net: dsa: allow rcv() and xmit() to be optional
net: ksz9477: remove unnecessary xmit and recv functions
net: fec: add support for DM_MDIO
net: add MV88E61xx DSA driver
board: gw_ventana: enable MV88E61XX DSA support

 arch/arm/dts/imx6qdl-gw5904.dtsi        |  31 +
 board/gateworks/gw_ventana/gw_ventana.c |  50 +-
 configs/gwventana_gw5904_defconfig      |   8 +-
 drivers/net/Kconfig                     |   7 +
 drivers/net/Makefile                    |   1 +
 drivers/net/fec_mxc.c                   |  90 ++-
 drivers/net/ksz9477.c                   |  23 -
 drivers/net/mv88e6xxx.c                 | 826 ++++++++++++++++++++++++
 net/dsa-uclass.c                        |  57 +-
 net/mdio-uclass.c                       |   4 +
 10 files changed, 1025 insertions(+), 72 deletions(-)
 create mode 100644 drivers/net/mv88e6xxx.c
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v4 1/8 net: mdio-uclass: scan for dm mdio children on post-bind

If a DM_MDIO driver is used we need to scan the subnodes as well.

---
v4:
- no changes
v3:
- no changes
v2:
- added Ramon's rb tag

---
 net/mdio-uclass.c | 4 ++++
 1 file changed, 4 insertions(+)
net/mdio-uclass.c +4 -0
index 4401492ca015..d80037d0ac71 100644
@@ -49,7 +49,11 @@ static int dm_mdio_post_bind(struct udevice *dev)
 		return -EINVAL;
 	}
 
+#if CONFIG_IS_ENABLED(OF_REAL)
+	return dm_scan_fdt_dev(dev);
+#else
 	return 0;
+#endif
 }
 
 int dm_mdio_read(struct udevice *mdio_dev, int addr, int devad, int reg)
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH v4 2/8 net: dsa: move cpu port probe to dsa_post_probe

In reply to Tim Harvey

In order to ensure that a DSA driver probe gets called before dsa_ops->port_probe move the port_probe of the cpu_port to a post-probe function.

---
v4:
- no changes
v3:
- added Vladimir's rb tag
v2:
- added Ramon's rb tag

---
 net/dsa-uclass.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
net/dsa-uclass.c +11 -2
index 3bf4351c847d..286718818517 100644
@@ -466,7 +466,6 @@ static int dsa_pre_probe(struct udevice *dev)
 {
 	struct dsa_pdata *pdata = dev_get_uclass_plat(dev);
 	struct dsa_priv *priv = dev_get_uclass_priv(dev);
-	struct dsa_ops *ops = dsa_get_ops(dev);
 	int err;
 
 	priv->num_ports = pdata->num_ports;
@@ -482,6 +481,15 @@ static int dsa_pre_probe(struct udevice *dev)
 	if (err)
 		return err;
 
+	return 0;
+}
+
+static int dsa_post_probe(struct udevice *dev)
+{
+	struct dsa_priv *priv = dev_get_uclass_priv(dev);
+	struct dsa_ops *ops = dsa_get_ops(dev);
+	int err;
+
 	/* Simulate a probing event for the CPU port */
 	if (ops->port_probe) {
 		err = ops->port_probe(dev, priv->cpu_port,
@@ -491,13 +499,14 @@ static int dsa_pre_probe(struct udevice *dev)
 	}
 
 	return 0;
-}
+};
 
 UCLASS_DRIVER(dsa) = {
 	.id = UCLASS_DSA,
 	.name = "dsa",
 	.post_bind = dsa_post_bind,
 	.pre_probe = dsa_pre_probe,
+	.post_probe = dsa_post_probe,
 	.per_device_auto = sizeof(struct dsa_priv),
 	.per_device_plat_auto = sizeof(struct dsa_pdata),
 	.per_child_plat_auto = sizeof(struct dsa_port_pdata),
Signature · 1 line
2.25.1
author
#3 lore raw

PATCH v4 3/8 net: dsa: ensure dsa driver has proper ops

In reply to Tim Harvey

Add a function to sanity check a dsa driver having proper ops.

---
v4:
- no changes
v3:
- added Vladimir's rb tag
v2: new patch

---
 net/dsa-uclass.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
net/dsa-uclass.c +17 -0
index 286718818517..cb21de17432b 100644
@@ -342,6 +342,19 @@ U_BOOT_DRIVER(dsa_port) = {
 	.plat_auto = sizeof(struct eth_pdata),
 };
 
+static int dsa_sanitize_ops(struct udevice *dev)
+{
+	struct dsa_ops *ops = dsa_get_ops(dev);
+
+	if ((!ops->xmit || !ops->rcv) &&
+	    (!ops->port_enable && !ops->port_disable)) {
+		dev_err(dev, "Packets cannot be steered to ports\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  * This function mostly deals with pulling information out of the device tree
  * into the pdata structure.
@@ -358,6 +371,10 @@ static int dsa_post_bind(struct udevice *dev)
 	if (!ofnode_valid(node))
 		return -ENODEV;
 
+	err = dsa_sanitize_ops(dev);
+	if (err)
+		return err;
+
 	pdata->master_node = ofnode_null();
 
 	node = ofnode_find_subnode(node, "ports");
Signature · 1 line
2.25.1
author
#4 lore raw

PATCH v4 4/8 net: dsa: allow rcv() and xmit() to be optional

In reply to Tim Harvey

Allow rcv() and xmit() dsa driver ops to be optional in case a driver does not care to mangle a packet as in U-Boot only one network port is enabled at a time and thus no packet mangling is necessary.

---
v4:
- no changes
v3:
- added Vladimir's rb tag
v2: new patch

---
 net/dsa-uclass.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
net/dsa-uclass.c +18 -9
index cb21de17432b..9d63cde6b154 100644
@@ -131,16 +131,14 @@ static void dsa_port_stop(struct udevice *pdev)
  * We copy the frame to a stack buffer where we have reserved headroom and
  * tailroom space.  Headroom and tailroom are set to 0.
  */
-static int dsa_port_send(struct udevice *pdev, void *packet, int length)
+static int dsa_port_mangle_packet(struct udevice *pdev, void *packet, int length)
 {
+	struct dsa_port_pdata *port_pdata = dev_get_parent_plat(pdev);
 	struct udevice *dev = dev_get_parent(pdev);
 	struct dsa_priv *priv = dev_get_uclass_priv(dev);
 	int head = priv->headroom, tail = priv->tailroom;
-	struct udevice *master = dsa_get_master(dev);
 	struct dsa_ops *ops = dsa_get_ops(dev);
 	uchar dsa_packet_tmp[PKTSIZE_ALIGN];
-	struct dsa_port_pdata *port_pdata;
-	int err;
 
 	if (length + head + tail > PKTSIZE_ALIGN)
 		return -EINVAL;
@@ -152,10 +150,21 @@ static int dsa_port_send(struct udevice *pdev, void *packet, int length)
 	/* copy back to preserve original buffer alignment */
 	memcpy(packet, dsa_packet_tmp, length);
 
-	port_pdata = dev_get_parent_plat(pdev);
-	err = ops->xmit(dev, port_pdata->index, packet, length);
-	if (err)
-		return err;
+	return ops->xmit(dev, port_pdata->index, packet, length);
+}
+
+static int dsa_port_send(struct udevice *pdev, void *packet, int length)
+{
+	struct udevice *dev = dev_get_parent(pdev);
+	struct udevice *master = dsa_get_master(dev);
+	struct dsa_ops *ops = dsa_get_ops(dev);
+	int err;
+
+	if (ops->xmit) {
+		err = dsa_port_mangle_packet(pdev, packet, length);
+		if (err)
+			return err;
+	}
 
 	return eth_get_ops(master)->send(master, packet, length);
 }
@@ -172,7 +181,7 @@ static int dsa_port_recv(struct udevice *pdev, int flags, uchar **packetp)
 	int length, port_index, err;
 
 	length = eth_get_ops(master)->recv(master, flags, packetp);
-	if (length <= 0)
+	if (length <= 0 || !ops->rcv)
 		return length;
 
 	/*
Signature · 1 line
2.25.1
author
#5 lore raw

PATCH v4 5/8 net: ksz9477: remove unnecessary xmit and recv functions

In reply to Tim Harvey

Remove the unnecessary xmit and recv functions.

---
v4:
- no changes
v3:
- added Vladimir's rb tag
v2: new patch

---
 drivers/net/ksz9477.c | 23 -----------------------
 1 file changed, 23 deletions(-)
drivers/net/ksz9477.c +0 -23
index ed8f1895cb12..fb5c76c600be 100644
@@ -62,7 +62,6 @@
 
 struct ksz_dsa_priv {
 	struct udevice *dev;
-	int active_port;
 };
 
 static inline int ksz_read8(struct udevice *dev, u32 reg, u8 *val)
@@ -382,9 +381,6 @@ static int ksz_port_enable(struct udevice *dev, int port, struct phy_device *phy
 	data8 |= SW_START;
 	ksz_write8(priv->dev, REG_SW_OPERATION, data8);
 
-	/* keep track of current enabled non-cpu port */
-	priv->active_port = port;
-
 	return 0;
 }
 
@@ -413,28 +409,9 @@ static void ksz_port_disable(struct udevice *dev, int port, struct phy_device *p
 	 */
 }
 
-static int ksz_xmit(struct udevice *dev, int port, void *packet, int length)
-{
-	dev_dbg(dev, "%s P%d %d\n", __func__, port + 1, length);
-
-	return 0;
-}
-
-static int ksz_recv(struct udevice *dev, int *port, void *packet, int length)
-{
-	struct ksz_dsa_priv *priv = dev_get_priv(dev);
-
-	dev_dbg(dev, "%s P%d %d\n", __func__, priv->active_port + 1, length);
-	*port = priv->active_port;
-
-	return 0;
-};
-
 static const struct dsa_ops ksz_dsa_ops = {
 	.port_enable = ksz_port_enable,
 	.port_disable = ksz_port_disable,
-	.xmit = ksz_xmit,
-	.rcv = ksz_recv,
 };
 
 static int ksz_probe_mdio(struct udevice *dev)
Signature · 1 line
2.25.1
author
#6 lore raw

PATCH v4 6/8 net: fec: add support for DM_MDIO

In reply to Tim Harvey

Add support for DM_MDIO by registering a UCLASS_MDIO driver and attempting to use it. This is necessary if wanting to use a DSA driver for example hanging off of the FEC MAC.

Care is taken to fallback to non DM_MDIO mii bus as several boards define DM_MDIO without having the proper device-tree configuration necessary such as an mdio subnode, a phy-mode prop, and either a valid phy-handle prop or fixed-phy subnode which will cause dm_eth_phy_connect() to fail.

---
v4:
- no changes
v3:
- no changes
v2:
- fix fallback mechanism for legacy dt's that do not have phy-handle and mdio subnode

---
 drivers/net/fec_mxc.c | 90 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 88 insertions(+), 2 deletions(-)
drivers/net/fec_mxc.c +88 -2
index 8bc2b46d403f..03be4b4ec282 100644
@@ -30,6 +30,8 @@
 #include <asm/arch/imx-regs.h>
 #include <asm/mach-imx/sys_proto.h>
 #include <asm-generic/gpio.h>
+#include <dm/device_compat.h>
+#include <dm/lists.h>
 
 #include "fec_mxc.h"
 #include <eth_phy.h>
@@ -1026,6 +1028,81 @@ struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id)
 	return bus;
 }
 
+#ifdef CONFIG_DM_MDIO
+struct dm_fec_mdio_priv {
+	struct ethernet_regs *regs;
+};
+
+static int dm_fec_mdio_read(struct udevice *dev, int addr, int devad, int reg)
+{
+	struct dm_fec_mdio_priv *priv = dev_get_priv(dev);
+
+	return fec_mdio_read(priv->regs, addr, reg);
+}
+
+static int dm_fec_mdio_write(struct udevice *dev, int addr, int devad, int reg, u16 data)
+{
+	struct dm_fec_mdio_priv *priv = dev_get_priv(dev);
+
+	return fec_mdio_write(priv->regs, addr, reg, data);
+}
+
+static const struct mdio_ops dm_fec_mdio_ops = {
+	.read = dm_fec_mdio_read,
+	.write = dm_fec_mdio_write,
+};
+
+static int dm_fec_mdio_probe(struct udevice *dev)
+{
+	struct dm_fec_mdio_priv *priv = dev_get_priv(dev);
+
+	priv->regs = (struct ethernet_regs *)ofnode_get_addr(dev_ofnode(dev->parent));
+
+	return 0;
+}
+
+U_BOOT_DRIVER(fec_mdio) = {
+	.name		= "fec_mdio",
+	.id		= UCLASS_MDIO,
+	.probe		= dm_fec_mdio_probe,
+	.ops		= &dm_fec_mdio_ops,
+	.priv_auto	= sizeof(struct dm_fec_mdio_priv),
+};
+
+static int dm_fec_bind_mdio(struct udevice *dev)
+{
+	struct udevice *mdiodev;
+	const char *name;
+	ofnode mdio;
+	int ret = -ENODEV;
+
+	/* for a UCLASS_MDIO driver we need to bind and probe manually
+	 * for an internal MDIO bus that has no dt compatible of its own
+	 */
+	ofnode_for_each_subnode(mdio, dev_ofnode(dev)) {
+		name = ofnode_get_name(mdio);
+
+		if (strcmp(name, "mdio"))
+			continue;
+
+		ret = device_bind_driver_to_node(dev, "fec_mdio",
+						 name, mdio, &mdiodev);
+		if (ret) {
+			printf("%s bind %s failed: %d\n", __func__, name, ret);
+			break;
+		}
+
+		/* need to probe it as there is no compatible to do so */
+		ret = uclass_get_device_by_ofnode(UCLASS_MDIO, mdio, &mdiodev);
+		if (!ret)
+			return 0;
+		printf("%s probe %s failed: %d\n", __func__, name, ret);
+	}
+
+	return ret;
+}
+#endif
+
 static int fecmxc_read_rom_hwaddr(struct udevice *dev)
 {
 	struct fec_priv *priv = dev_get_priv(dev);
@@ -1089,7 +1166,7 @@ static int device_get_phy_addr(struct fec_priv *priv, struct udevice *dev)
 
 static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
 {
-	struct phy_device *phydev;
+	struct phy_device *phydev = NULL;
 	int addr;
 
 	addr = device_get_phy_addr(priv, dev);
@@ -1097,7 +1174,10 @@ static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
 	addr = CONFIG_FEC_MXC_PHYADDR;
 #endif
 
-	phydev = phy_connect(priv->bus, addr, dev, priv->interface);
+	if (IS_ENABLED(CONFIG_DM_MDIO))
+		phydev = dm_eth_phy_connect(dev);
+	if (!phydev)
+		phydev = phy_connect(priv->bus, addr, dev, priv->interface);
 	if (!phydev)
 		return -ENODEV;
 
@@ -1228,6 +1308,12 @@ static int fecmxc_probe(struct udevice *dev)
 
 	priv->dev_id = dev_seq(dev);
 
+	if (IS_ENABLED(CONFIG_DM_MDIO)) {
+		ret = dm_fec_bind_mdio(dev);
+		if (ret && ret != -ENODEV)
+			return ret;
+	}
+
 #ifdef CONFIG_DM_ETH_PHY
 	bus = eth_phy_get_mdio_bus(dev);
 #endif
Signature · 1 line
2.25.1
author
#7 lore raw

PATCH v4 7/8 net: add MV88E61xx DSA driver

In reply to Tim Harvey

Add a DSA driver for the MV88E61xx compatible GbE Ethernet switches.

---
v4:
- rename to mv88e6xxx
- sort includes alphabetically
- remove dsa term from function names
- reduce indentation level and remove unecessary code in of probe_mdio function
- rename pdev to mdev to represent mdio device
v3:
- Added Vladimir's rb tag
v2:
- rebase on v2022.07-rc1 (use ofnode_get_phy_node)
- remove unused commented out fields from struct
- remove unused PORT_MASK macro
- remove phy from priv struct name
- refactor code from original drivers/net/phy/mv88e61xx with suggestions from review to consolidate some functions
into mv88e61xx_dsa_port_enable
- remove unecessary skiping of disabling of CPU port
- remove unecessary dev_set_parent_priv
- remove unnecessary static init flag
- replace debug with a dev_warn if switch device-id unsupported
- remove unnecessary xmit/recv functions as we rely on the fact that only a single port is active instead of mangling packets

---
 drivers/net/Kconfig     |   7 +
 drivers/net/Makefile    |   1 +
 drivers/net/mv88e6xxx.c | 831 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 839 insertions(+)
 create mode 100644 drivers/net/mv88e6xxx.c
drivers/net/Kconfig +7 -0
index 6bbbadc5eef3..5508dacbcc49 100644
@@ -438,6 +438,13 @@ config KSZ9477
 	  This driver implements a DSA switch driver for the KSZ9477 family
 	  of GbE switches using the I2C interface.
 
+config MV88E6XXX
+	bool "Marvell MV88E6xxx GbE switch DSA driver"
+	depends on DM_DSA && DM_MDIO
+	help
+	  This driver implements a DSA switch driver for the MV88E6xxx family
+	  of GbE switches using the MDIO interface
+
 config MVGBE
 	bool "Marvell Orion5x/Kirkwood network interface support"
 	depends on ARCH_KIRKWOOD || ARCH_ORION5X
drivers/net/Makefile +1 -0
index 96b7678e9882..f05fd58e3fa7 100644
@@ -59,6 +59,7 @@ obj-$(CONFIG_MEDIATEK_ETH) += mtk_eth.o
 obj-$(CONFIG_MPC8XX_FEC) += mpc8xx_fec.o
 obj-$(CONFIG_MT7620_ETH) += mt7620-eth.o
 obj-$(CONFIG_MT7628_ETH) += mt7628-eth.o
+obj-$(CONFIG_MV88E6XXX) += mv88e6xxx.o
 obj-$(CONFIG_MVGBE) += mvgbe.o
 obj-$(CONFIG_MVMDIO) += mvmdio.o
 obj-$(CONFIG_MVNETA) += mvneta.o
drivers/net/mv88e6xxx.c new file +831 -0

831 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#8 lore raw

PATCH v4 8/8 board: gw_ventana: enable MV88E61XX DSA support

In reply to Tim Harvey

Add MV88E61XX DSA support:
- update dt: U-Boot dsa driver requires different device-tree syntax than the linux driver in order to link the dsa ports to the mdio bus.
- update defconfig
- replace mv88e61xx_hw_reset weak override with board_phy_config support for mv88e61xx configuration that is outside the scope of the DSA driver

---
v4:
- use standard Linux internal MDIO dt structure
- use PHY_FIXED_ID define
v3:
- move mdio's mdio@0 subnode
v2: no changes

---
 arch/arm/dts/imx6qdl-gw5904.dtsi        | 31 +++++++++++++++
 board/gateworks/gw_ventana/gw_ventana.c | 50 +++++++++----------------
 configs/gwventana_gw5904_defconfig      |  8 ++--
 drivers/net/mv88e6xxx.c                 | 29 ++++++--------
 4 files changed, 65 insertions(+), 53 deletions(-)
arch/arm/dts/imx6qdl-gw5904.dtsi +31 -0
index 612b6e068e28..487dd7648274 100644
@@ -212,6 +212,27 @@
 			compatible = "marvell,mv88e6085";
 			reg = <0>;
 
+			mdio {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				sw_phy0: ethernet-phy@0 {
+					reg = <0x0>;
+				};
+
+				sw_phy1: ethernet-phy@1 {
+					reg = <0x1>;
+				};
+
+				sw_phy2: ethernet-phy@2 {
+					reg = <0x2>;
+				};
+
+				sw_phy3: ethernet-phy@3 {
+					reg = <0x3>;
+				};
+			};
+
 			ports {
 				#address-cells = <1>;
 				#size-cells = <0>;
@@ -219,27 +240,37 @@
 				port@0 {
 					reg = <0>;
 					label = "lan4";
+					phy-handle = <&sw_phy0>;
 				};
 
 				port@1 {
 					reg = <1>;
 					label = "lan3";
+					phy-handle = <&sw_phy1>;
 				};
 
 				port@2 {
 					reg = <2>;
 					label = "lan2";
+					phy-handle = <&sw_phy2>;
 				};
 
 				port@3 {
 					reg = <3>;
 					label = "lan1";
+					phy-handle = <&sw_phy3>;
 				};
 
 				port@5 {
 					reg = <5>;
 					label = "cpu";
 					ethernet = <&fec>;
+					phy-mode = "rgmii-id";
+
+					fixed-link {
+						speed = <1000>;
+						full-duplex;
+					};
 				};
 			};
 		};
board/gateworks/gw_ventana/gw_ventana.c +18 -32

62 lines not on this page · raw message

configs/gwventana_gw5904_defconfig +4 -4
index 8c6baf0ae5e2..33b57c5a1c5d 100644
@@ -111,11 +111,11 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD=y
 CONFIG_PHYLIB=y
-CONFIG_MV88E61XX_SWITCH=y
-CONFIG_MV88E61XX_CPU_PORT=5
-CONFIG_MV88E61XX_PHY_PORTS=0xf
-CONFIG_MV88E61XX_FIXED_PORTS=0x0
+CONFIG_MV88E61XX=y
+CONFIG_PHY_FIXED=y
+CONFIG_DM_ETH=y
 CONFIG_DM_MDIO=y
+CONFIG_DM_DSA=y
 CONFIG_E1000=y
 CONFIG_FEC_MXC=y
 CONFIG_MII=y
drivers/net/mv88e6xxx.c +12 -17
index a3a3f6cf4acc..6064bb73257b 100644
@@ -727,31 +727,26 @@ static const struct dsa_ops mv88e6xxx_dsa_ops = {
 static int mv88e6xxx_probe_mdio(struct udevice *dev)
 {
 	struct udevice *mdev;
-	ofnode node, mdios;
 	const char *name;
+	ofnode node;
 	int ret;
 
-	/* bind phy ports of mdios child node to mv88e6xxx_mdio device */
-	mdios = dev_read_subnode(dev, "mdios");
-	if (!ofnode_valid(mdios))
+	/* bind phy ports of mdio child node to mv88e6xxx_mdio device */
+	node = dev_read_subnode(dev, "mdio");
+	if (!ofnode_valid(node))
 		return 0;
 
-	ofnode_for_each_subnode(node, mdios) {
-		name = ofnode_get_name(node);
-		ret = device_bind_driver_to_node(dev,
-						 "mv88e6xxx_mdio",
-						 name, node, NULL);
-		if (ret) {
-			dev_err(dev, "failed to bind %s: %d\n", name, ret);
-			continue;
-		}
-
+	name = ofnode_get_name(node);
+	ret = device_bind_driver_to_node(dev,
+					 "mv88e6xxx_mdio",
+					 name, node, NULL);
+	if (ret) {
+		dev_err(dev, "failed to bind %s: %d\n", name, ret);
+	} else {
 		/* need to probe it as there is no compatible to do so */
 		ret = uclass_get_device_by_ofnode(UCLASS_MDIO, node, &mdev);
-		if (ret) {
+		if (ret)
 			dev_err(dev, "failed to probe %s: %d\n", name, ret);
-			continue;
-		}
 	}
 
 	return ret;
Signature · 1 line
2.25.1
reviewer
#9 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Hi Tim,

Quoted 4 lines · Tim Harvey

Add MV88E61XX DSA support:
- update dt: U-Boot dsa driver requires different device-tree syntax than the linux driver in order to link the dsa ports to the mdio bus.

Shouldn't the U-Boot dts version (imx6qdl-gw5904-u-boot.dtsi) be updated instead?

Otherwise, this will cause problems when syncing imx6qdl-gw5904.dtsi with Linux.

author
#10 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Quoted 9 lines · Fabio Estevam

Hi Tim,

Quoted 4 lines · Tim Harvey

Add MV88E61XX DSA support:
- update dt: U-Boot dsa driver requires different device-tree syntax than the linux driver in order to link the dsa ports to the mdio bus.

Quoted 5 lines

Shouldn't the U-Boot dts version (imx6qdl-gw5904-u-boot.dtsi) be updated instead?

Otherwise, this will cause problems when syncing imx6qdl-gw5904.dtsi with Linux.

Fabio,

That is one route to go but I'm hoping to update the Linux dt as well to match so I'm not worried about it at this time.

Best Regards,

Tim

reviewer
#11 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

In reply to Tim Harvey

Hi Tim,

configs/gwventana_gw5904_defconfig CONFIG_SUPPORT_EMMC_BOOT=y · line 114

Quoted 13 lines · Tim Harvey
configs/gwventana_gw5904_defconfig +1 -4
index 8c6baf0ae5e2..33b57c5a1c5d 100644
@@ -111,11 +111,11 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD=y
 CONFIG_PHYLIB=y
-CONFIG_MV88E61XX_SWITCH=y
-CONFIG_MV88E61XX_CPU_PORT=5
-CONFIG_MV88E61XX_PHY_PORTS=0xf
-CONFIG_MV88E61XX_FIXED_PORTS=0x0
+CONFIG_MV88E61XX=y

There is a typo here:

This one should be CONFIG_MV88E6XXX instead.

After fixing this and passing CONFIG_NET_RANDOM_ETHADDR=y to my custom board defconfig:

 ethernet      0  [ + ]   fecmxc                |   |   `-- ethernet@30be0000
 bootdev       2  [   ]   eth_bootdev           |   |       |--
[email protected]
 mdio          0  [ + ]   fec_mdio              |   |       `-- mdio
 dsa           0  [   ]   mv88e6xxx             |   |           `-- switch@0
 ethernet      1  [   ]   dsa-port              |   |               |-- lan4
 bootdev       3  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      2  [   ]   dsa-port              |   |               |-- lan3
 bootdev       4  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      3  [   ]   dsa-port              |   |               |-- lan2
 bootdev       5  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      4  [   ]   dsa-port              |   |               |-- lan1
 bootdev       6  [   ]   eth_bootdev           |   |               |

`-- switch@[email protected]
mdio 1 [ + ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-0
mdio 2 [ ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-1
mdio 3 [ ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-2
mdio 4 [ ] mv88e6xxx_mdio | |
`-- mv88e6xxx-mdio-3

but still not able to get a DHCP address:

u-boot=> dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4

Thanks

author
#12 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Quoted 21 lines · Fabio Estevam

Hi Tim,

configs/gwventana_gw5904_defconfig CONFIG_SUPPORT_EMMC_BOOT=y · line 114

Quoted 13 lines · Tim Harvey
configs/gwventana_gw5904_defconfig +1 -4
index 8c6baf0ae5e2..33b57c5a1c5d 100644
@@ -111,11 +111,11 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD=y
 CONFIG_PHYLIB=y
-CONFIG_MV88E61XX_SWITCH=y
-CONFIG_MV88E61XX_CPU_PORT=5
-CONFIG_MV88E61XX_PHY_PORTS=0xf
-CONFIG_MV88E61XX_FIXED_PORTS=0x0
+CONFIG_MV88E61XX=y

There is a typo here:

Quoted 1 line

This one should be CONFIG_MV88E6XXX instead.

Ooops - thanks for pointing that out. I have another patch on top to merge two defconfigs that fixed that typo introduced with the v4 series that changed MV88E61XX to MV88E6XXX.

Quoted 30 lines

After fixing this and passing CONFIG_NET_RANDOM_ETHADDR=y to my custom board defconfig:

 ethernet      0  [ + ]   fecmxc                |   |   `-- ethernet@30be0000
 bootdev       2  [   ]   eth_bootdev           |   |       |--
[email protected]
 mdio          0  [ + ]   fec_mdio              |   |       `-- mdio
 dsa           0  [   ]   mv88e6xxx             |   |           `-- switch@0
 ethernet      1  [   ]   dsa-port              |   |               |-- lan4
 bootdev       3  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      2  [   ]   dsa-port              |   |               |-- lan3
 bootdev       4  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      3  [   ]   dsa-port              |   |               |-- lan2
 bootdev       5  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      4  [   ]   dsa-port              |   |               |-- lan1
 bootdev       6  [   ]   eth_bootdev           |   |               |

`-- switch@[email protected]
mdio 1 [ + ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-0
mdio 2 [ ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-1
mdio 3 [ ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-2
mdio 4 [ ] mv88e6xxx_mdio | |
`-- mv88e6xxx-mdio-3

Quoted 7 lines

but still not able to get a DHCP address:

u-boot=> dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4

With CONFIG_CMD_NET=y what does 'net list' show?

I have the following (with network attached to lan4 port)
Net: MV88E61XX eth0: ethernet@2188000, eth1: lan4, eth2: lan3, eth3: lan2, eth
4: lan1
Hit any key to stop autoboot: 0
Ventana > print ethaddr ethaddr=00:d0:12:f3:f2:f5
Ventana > dm tree
...

 ethernet      0  [ + ]   fecmxc                |   |   |-- ethernet@2188000
 bootdev       0  [   ]   eth_bootdev           |   |   |   |--
[email protected]
 mdio          0  [ + ]   fec_mdio              |   |   |   `-- mdio
 dsa           0  [ + ]   mv88e6xxx             |   |   |       `-- switch@0
 ethernet      1  [ + ]   dsa-port              |   |   |           |-- lan4
 bootdev       2  [   ]   eth_bootdev           |   |   |           |
 `-- switch@[email protected]
 ethernet      2  [ + ]   dsa-port              |   |   |           |-- lan3
 bootdev       3  [   ]   eth_bootdev           |   |   |           |
 `-- switch@[email protected]
 ethernet      3  [ + ]   dsa-port              |   |   |           |-- lan2
 bootdev       4  [   ]   eth_bootdev           |   |   |           |
 `-- switch@[email protected]
 ethernet      4  [ + ]   dsa-port              |   |   |           |-- lan1
 bootdev       5  [   ]   eth_bootdev           |   |   |           |

`-- switch@[email protected]
mdio 1 [ + ] mv88e6xxx_mdio | | |
`-- mv88e6xxx-mdio-0
...
Ventana > net list
eth0 : ethernet@2188000 00:d0:12:f3:f2:f5 active eth1 : lan4 00:d0:12:f3:f2:f5
eth2 : lan3 00:d0:12:f3:f2:f5
eth3 : lan2 00:d0:12:f3:f2:f5
eth4 : lan1 00:d0:12:f3:f2:f5
Ventana > setenv ethact lan4
Ventana > dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
DHCP client bound to address 172.24.33.142 (1076 ms)

I do not use CONFIG_NET_RANDOM_ETHADDR and have a single MAC address allocated to the board.

What board are you using and what does its fec/mdio dt look like?

Best Regards,

Tim

reviewer
#13 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Hi Tim,

Quoted 43 lines · Tim Harvey

With CONFIG_CMD_NET=y what does 'net list' show?

I have the following (with network attached to lan4 port)
Net: MV88E61XX eth0: ethernet@2188000, eth1: lan4, eth2: lan3, eth3: lan2, eth
4: lan1
Hit any key to stop autoboot: 0
Ventana > print ethaddr ethaddr=00:d0:12:f3:f2:f5
Ventana > dm tree
...

 ethernet      0  [ + ]   fecmxc                |   |   |-- ethernet@2188000
 bootdev       0  [   ]   eth_bootdev           |   |   |   |--
[email protected]
 mdio          0  [ + ]   fec_mdio              |   |   |   `-- mdio
 dsa           0  [ + ]   mv88e6xxx             |   |   |       `-- switch@0
 ethernet      1  [ + ]   dsa-port              |   |   |           |-- lan4
 bootdev       2  [   ]   eth_bootdev           |   |   |           |
 `-- switch@[email protected]
 ethernet      2  [ + ]   dsa-port              |   |   |           |-- lan3
 bootdev       3  [   ]   eth_bootdev           |   |   |           |
 `-- switch@[email protected]
 ethernet      3  [ + ]   dsa-port              |   |   |           |-- lan2
 bootdev       4  [   ]   eth_bootdev           |   |   |           |
 `-- switch@[email protected]
 ethernet      4  [ + ]   dsa-port              |   |   |           |-- lan1
 bootdev       5  [   ]   eth_bootdev           |   |   |           |

`-- switch@[email protected]
mdio 1 [ + ] mv88e6xxx_mdio | | |
`-- mv88e6xxx-mdio-0
...
Ventana > net list
eth0 : ethernet@2188000 00:d0:12:f3:f2:f5 active eth1 : lan4 00:d0:12:f3:f2:f5
eth2 : lan3 00:d0:12:f3:f2:f5
eth3 : lan2 00:d0:12:f3:f2:f5
eth4 : lan1 00:d0:12:f3:f2:f5
Ventana > setenv ethact lan4
Ventana > dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
DHCP client bound to address 172.24.33.142 (1076 ms)

Quoted 2 lines

I do not use CONFIG_NET_RANDOM_ETHADDR and have a single MAC address allocated to the board.

Below are the logs:

Net:   MV88E61XX
Warning: ethernet@30be0000 (eth0) using random MAC address - a6:a6:56:1c:28:0a
eth0: ethernet@30be0000
Hit any key to stop autoboot:  0

Your log also shows eth1-eth4. Mine does not.

Unlike your log, dsa-port is not getting probed here:

 ethernet      0  [ + ]   fecmxc                |   |   `-- ethernet@30be0000
 bootdev       2  [   ]   eth_bootdev           |   |       |--
[email protected]
 mdio          0  [ + ]   fec_mdio              |   |       `-- mdio
 dsa           0  [   ]   mv88e6xxx             |   |           `-- switch@0
 ethernet      1  [   ]   dsa-port              |   |               |-- lan4
 bootdev       3  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      2  [   ]   dsa-port              |   |               |-- lan3
 bootdev       4  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      3  [   ]   dsa-port              |   |               |-- lan2
 bootdev       5  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      4  [   ]   dsa-port              |   |               |-- lan1
 bootdev       6  [   ]   eth_bootdev           |   |               |

`-- switch@[email protected]
mdio 1 [ + ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-0
mdio 2 [ ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-1
mdio 3 [ ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-2
mdio 4 [ ] mv88e6xxx_mdio | |
`-- mv88e6xxx-mdio-3

 simple_bus    7  [   ]   simple_bus            |   `-- bus@32c00000
 usb           0  [   ]   ehci_mx6              |       `-- usb@32e40000
 phy           0  [   ]   nop_phy               |-- usbphynop1
 regulator     0  [   ]   regulator_fixed       |-- regulator-usdhc2
 sysreset      1  [   ]   wdt_reboot            |-- wdt-reboot
 bootstd       0  [   ]   bootstd_drv           `-- bootstd
 bootmeth      0  [   ]   bootmeth_distro           |-- distro
 bootmeth      1  [   ]   bootmeth_efi              |-- efi
 bootmeth      2  [   ]   bootmeth_pxe              |-- pxe
 bootmeth      3  [   ]   vbe_simple                `-- vbe_simple

u-boot=> net list
eth0 : ethernet@30be0000 a6:a6:56:1c:28:0a active
eth1 : lan4 00:00:00:00:00:00
eth2 : lan3 00:00:00:00:00:00
eth3 : lan2 00:00:00:00:00:00
eth4 : lan1 00:00:00:00:00:00
u-boot=> setenv ethact lan4
u-boot=> dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
BOOTP broadcast 7
BOOTP broadcast 8
(IP is never retrieved)

Quoted 1 line

What board are you using and what does its fec/mdio dt look like?

I am using a custom imx8mn board.

The FEC/MDIO nodes are like this:
https://pastebin.com/raw/0SvLLzxj

Thanks,

Fabio Estevam

author
#14 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Quoted 87 lines · Fabio Estevam

Hi Tim,

Quoted 43 lines · Tim Harvey

With CONFIG_CMD_NET=y what does 'net list' show?

I have the following (with network attached to lan4 port)
Net: MV88E61XX eth0: ethernet@2188000, eth1: lan4, eth2: lan3, eth3: lan2, eth
4: lan1
Hit any key to stop autoboot: 0
Ventana > print ethaddr ethaddr=00:d0:12:f3:f2:f5
Ventana > dm tree
...

 ethernet      0  [ + ]   fecmxc                |   |   |-- ethernet@2188000
 bootdev       0  [   ]   eth_bootdev           |   |   |   |--
[email protected]
 mdio          0  [ + ]   fec_mdio              |   |   |   `-- mdio
 dsa           0  [ + ]   mv88e6xxx             |   |   |       `-- switch@0
 ethernet      1  [ + ]   dsa-port              |   |   |           |-- lan4
 bootdev       2  [   ]   eth_bootdev           |   |   |           |
 `-- switch@[email protected]
 ethernet      2  [ + ]   dsa-port              |   |   |           |-- lan3
 bootdev       3  [   ]   eth_bootdev           |   |   |           |
 `-- switch@[email protected]
 ethernet      3  [ + ]   dsa-port              |   |   |           |-- lan2
 bootdev       4  [   ]   eth_bootdev           |   |   |           |
 `-- switch@[email protected]
 ethernet      4  [ + ]   dsa-port              |   |   |           |-- lan1
 bootdev       5  [   ]   eth_bootdev           |   |   |           |

`-- switch@[email protected]
mdio 1 [ + ] mv88e6xxx_mdio | | |
`-- mv88e6xxx-mdio-0
...
Ventana > net list
eth0 : ethernet@2188000 00:d0:12:f3:f2:f5 active eth1 : lan4 00:d0:12:f3:f2:f5
eth2 : lan3 00:d0:12:f3:f2:f5
eth3 : lan2 00:d0:12:f3:f2:f5
eth4 : lan1 00:d0:12:f3:f2:f5
Ventana > setenv ethact lan4
Ventana > dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
DHCP client bound to address 172.24.33.142 (1076 ms)

Quoted 2 lines

I do not use CONFIG_NET_RANDOM_ETHADDR and have a single MAC address allocated to the board.

Below are the logs:

Net:   MV88E61XX
Warning: ethernet@30be0000 (eth0) using random MAC address - a6:a6:56:1c:28:0a
eth0: ethernet@30be0000
Hit any key to stop autoboot:  0

Your log also shows eth1-eth4. Mine does not.

Unlike your log, dsa-port is not getting probed here:

 ethernet      0  [ + ]   fecmxc                |   |   `-- ethernet@30be0000
 bootdev       2  [   ]   eth_bootdev           |   |       |--
[email protected]
 mdio          0  [ + ]   fec_mdio              |   |       `-- mdio
 dsa           0  [   ]   mv88e6xxx             |   |           `-- switch@0
 ethernet      1  [   ]   dsa-port              |   |               |-- lan4
 bootdev       3  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      2  [   ]   dsa-port              |   |               |-- lan3
 bootdev       4  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      3  [   ]   dsa-port              |   |               |-- lan2
 bootdev       5  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      4  [   ]   dsa-port              |   |               |-- lan1
 bootdev       6  [   ]   eth_bootdev           |   |               |

`-- switch@[email protected]
mdio 1 [ + ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-0
mdio 2 [ ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-1
mdio 3 [ ] mv88e6xxx_mdio | |
|-- mv88e6xxx-mdio-2
mdio 4 [ ] mv88e6xxx_mdio | |
`-- mv88e6xxx-mdio-3

Quoted 11 lines
 simple_bus    7  [   ]   simple_bus            |   `-- bus@32c00000
 usb           0  [   ]   ehci_mx6              |       `-- usb@32e40000
 phy           0  [   ]   nop_phy               |-- usbphynop1
 regulator     0  [   ]   regulator_fixed       |-- regulator-usdhc2
 sysreset      1  [   ]   wdt_reboot            |-- wdt-reboot
 bootstd       0  [   ]   bootstd_drv           `-- bootstd
 bootmeth      0  [   ]   bootmeth_distro           |-- distro
 bootmeth      1  [   ]   bootmeth_efi              |-- efi
 bootmeth      2  [   ]   bootmeth_pxe              |-- pxe
 bootmeth      3  [   ]   vbe_simple                `-- vbe_simple

Right - so it looks like the 'net: fec: add support for DM_MDIO' patch is not doing its job to probe the mdio bus and ports.

Is CONFIG_DM_MDIO enabled and is dm_fec_bind_mdio returning successfully?

Is CONFIG_DM_ETH_PHY enabled? I don't use that and if I recall that code never seemed right to me.

Tim

Quoted 28 lines

u-boot=> net list
eth0 : ethernet@30be0000 a6:a6:56:1c:28:0a active
eth1 : lan4 00:00:00:00:00:00
eth2 : lan3 00:00:00:00:00:00
eth3 : lan2 00:00:00:00:00:00
eth4 : lan1 00:00:00:00:00:00
u-boot=> setenv ethact lan4
u-boot=> dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
BOOTP broadcast 7
BOOTP broadcast 8
(IP is never retrieved)

Quoted 1 line

What board are you using and what does its fec/mdio dt look like?

I am using a custom imx8mn board.

The FEC/MDIO nodes are like this:
https://pastebin.com/raw/0SvLLzxj

Thanks,

Fabio Estevam

#15 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Quoted 4 lines · Tim Harvey

Right - so it looks like the 'net: fec: add support for DM_MDIO' patch is not doing its job to probe the mdio bus and ports.

Is CONFIG_DM_MDIO enabled and is dm_fec_bind_mdio returning successfully?

Yes, for both.

Quoted 2 lines

Is CONFIG_DM_ETH_PHY enabled? I don't use that and if I recall that code never seemed right to me.

CONFIG_DM_ETH_PHY is not enabled.

Regards,

Fabio Estevam

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-60 Fax: (+49)-8142-66989-80 Email: [email protected]
author
#16 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Quoted 9 lines · Fabio Estevam
Quoted 5 lines · Tim Harvey

Right - so it looks like the 'net: fec: add support for DM_MDIO' patch is not doing its job to probe the mdio bus and ports.

Is CONFIG_DM_MDIO enabled and is dm_fec_bind_mdio returning successfully?

Quoted 8 lines

Yes, for both.

Quoted 2 lines

Is CONFIG_DM_ETH_PHY enabled? I don't use that and if I recall that code never seemed right to me.

CONFIG_DM_ETH_PHY is not enabled.

Fabio,

I'm not sure why your configuration is behaving differently and think you'll have to instrument code to help understand it.

Here is the chain of events I see on my imx6q fec <-> mv88e6085 configuration:
fecmxc_probe() calls dm_fec_bind_mdio() which finds the mdio node in dt and binds the 'fec_mdio' driver to it then probes that driver. When it binds via device_bind_driver_to_node() it should end up calling dsa_post_bind() to bind to the dsa_port driver. Can you verify that you have DM_DSA enabled and that dsa_post_bind() gets called?

You can enable debug for dsa-uclass.c and perhaps that will explain more. In dsa_post_bind() there is a loop over pdata->num_ports which calls device_bind_driver_to_node() to bind the node to DSA_PORT_CHILD_DRV_NAME - I imagine that isn't happening due to one of the checks prior to this failing silently.

Tim

reviewer
#17 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Hi Tim,

Quoted 6 lines · Tim Harvey

Fabio,

I'm not sure why your configuration is behaving differently and think you'll have to instrument code to help understand it.

Here is the chain of events I see on my imx6q fec <-> mv88e6085 configuration:

The switch I am using is a mv88e6320.

I instrumented the code a bit and I notice that I am not able to read the switch ID.

mv88e6xxx_get_switch_id() fails because mv88e6xxx_port_read() returns 0xffff.

I am investigating this failure.

Thanks

reviewer
#18 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Quoted 6 lines · Fabio Estevam

The switch I am using is a mv88e6320.

I instrumented the code a bit and I notice that I am not able to read the switch ID.

mv88e6xxx_get_switch_id() fails because mv88e6xxx_port_read() returns 0xffff.

This was caused by the wrong description of the Ethernet switch reset.

With this fixed, dm tree looks a bit better:

 ethernet      0  [ + ]   fecmxc                |   |   `-- ethernet@30be0000
 bootdev       2  [   ]   eth_bootdev           |   |       |--
[email protected]
 mdio          0  [ + ]   fec_mdio              |   |       `-- mdio
 dsa           0  [ + ]   mv88e6xxx             |   |           `-- switch@0
 ethernet      1  [   ]   dsa-port              |   |               |-- lan0
 bootdev       3  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      2  [   ]   dsa-port              |   |               |-- lan1
 bootdev       4  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      3  [ + ]   dsa-port              |   |               |-- lan3
 bootdev       5  [   ]   eth_bootdev           |   |               |

`-- switch@[email protected]
mdio 1 [ + ] mv88e6xxx_mdio | |
`-- mv88e6xxx-mdio-0

Boot log:
Net: MV88E61XX
Warning: ethernet@30be0000 (eth0) using random MAC address - 36:6f:7f:0c:61:14
eth0: ethernet@30be0000Could not get PHY for mv88e6xxx-mdio-0: addr 0 Could not get PHY for mv88e6xxx-mdio-0: addr 1
, eth3: lan3

u-boot=> net list
eth0 : ethernet@30be0000 36:6f:7f:0c:61:14 active
eth1 : lan0 00:00:00:00:00:00
eth2 : lan1 00:00:00:00:00:00
eth3 : lan3 36:6f:7f:0c:61:14

but still not able to get DHCP IP.

author
#19 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Quoted 11 lines · Fabio Estevam
Quoted 6 lines · Fabio Estevam

The switch I am using is a mv88e6320.

I instrumented the code a bit and I notice that I am not able to read the switch ID.

mv88e6xxx_get_switch_id() fails because mv88e6xxx_port_read() returns 0xffff.

This was caused by the wrong description of the Ethernet switch reset.

Seems like something that needs an error print? Which driver this?

Quoted 20 lines

With this fixed, dm tree looks a bit better:

 ethernet      0  [ + ]   fecmxc                |   |   `-- ethernet@30be0000
 bootdev       2  [   ]   eth_bootdev           |   |       |--
[email protected]
 mdio          0  [ + ]   fec_mdio              |   |       `-- mdio
 dsa           0  [ + ]   mv88e6xxx             |   |           `-- switch@0
 ethernet      1  [   ]   dsa-port              |   |               |-- lan0
 bootdev       3  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      2  [   ]   dsa-port              |   |               |-- lan1
 bootdev       4  [   ]   eth_bootdev           |   |               |
 `-- switch@[email protected]
 ethernet      3  [ + ]   dsa-port              |   |               |-- lan3
 bootdev       5  [   ]   eth_bootdev           |   |               |

`-- switch@[email protected]
mdio 1 [ + ] mv88e6xxx_mdio | |
`-- mv88e6xxx-mdio-0

Quoted 6 lines

Boot log:
Net: MV88E61XX
Warning: ethernet@30be0000 (eth0) using random MAC address - 36:6f:7f:0c:61:14
eth0: ethernet@30be0000Could not get PHY for mv88e6xxx-mdio-0: addr 0 Could not get PHY for mv88e6xxx-mdio-0: addr 1
, eth3: lan3

This doesn't look correct - why could it not get the phy for lan1 and lan2 yet lan3 was fine? I would assume a DT port/reg mismatch.

Quoted 8 lines

u-boot=> net list
eth0 : ethernet@30be0000 36:6f:7f:0c:61:14 active
eth1 : lan0 00:00:00:00:00:00
eth2 : lan1 00:00:00:00:00:00
eth3 : lan3 36:6f:7f:0c:61:14

but still not able to get DHCP IP.

Where are you setting your active port? By default eth0 is active and thats the cpu uplink. If you have a network connection on lan3 port you would need to 'setenv ethact lan3'.

Tim

reviewer Reviewed-by
#20 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Hi Tim,

Quoted 3 lines · Tim Harvey

Where are you setting your active port? By default eth0 is active and thats the cpu uplink. If you have a network connection on lan3 port you would need to 'setenv ethact lan3'.

It works now: both 'dhcp' and 'tftp' commands are functional.

Thanks a lot for your work on this and for your help!

If you send a v5 with the CONFIG_MV88E6XXX=y typo fixed, feel free to add for the whole series:

author
#21 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Quoted 9 lines · Fabio Estevam

Hi Tim,

Quoted 3 lines · Tim Harvey

Where are you setting your active port? By default eth0 is active and thats the cpu uplink. If you have a network connection on lan3 port you would need to 'setenv ethact lan3'.

Quoted 8 lines

It works now: both 'dhcp' and 'tftp' commands are functional.

Thanks a lot for your work on this and for your help!

If you send a v5 with the CONFIG_MV88E6XXX=y typo fixed, feel free to add for the whole series:

Fabio,

Thanks for testing this. I'll submit a v5 shortly with your rb tag and support for 6320:

drivers/net/mv88e6xxx.c +2 -0
@@ -176,6 +176,7 @@
 #define PORT_SWITCH_ID_6220            0x2200
 #define PORT_SWITCH_ID_6240            0x2400
 #define PORT_SWITCH_ID_6250            0x2500
+#define PORT_SWITCH_ID_6320            0x1150
 #define PORT_SWITCH_ID_6352            0x3520
 
 struct mv88e6xxx_priv {
@@ -792,6 +793,7 @@ static int mv88e6xxx_probe(struct udevice *dev)
        case PORT_SWITCH_ID_6071:
        case PORT_SWITCH_ID_6220:
        case PORT_SWITCH_ID_6250:
+       case PORT_SWITCH_ID_6320:
                priv->port_count = 7;
                priv->phy_ctrl1_en_det_shift = 14;
                priv->phy_ctrl1_en_det_width = 1;

Was there an error path you found in drivers/net/mv88e6xxx.c that should print an error to explain a failed probe for better future troubleshooting or was that failure somewhere else? It sounds like your switch was held in reset such that register reads were failing.

Best Regards,

Tim

reviewer
#22 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Hi Tim,

Quoted 4 lines · Tim Harvey

Fabio,

Thanks for testing this. I'll submit a v5 shortly with your rb tag and support for 6320:

Thanks for including the 6320 model!

Quoted 4 lines

Was there an error path you found in drivers/net/mv88e6xxx.c that should print an error to explain a failed probe for better future troubleshooting or was that failure somewhere else? It sounds like your switch was held in reset such that register reads were failing.

Yes, that was the reason for the register read failure.

Initially, I had described the reset GPIO inside using reset-gpios inside the switch node, just like described in the Linux binding document:
Documentation/devicetree/bindings/net/dsa/marvell.txt

It did not work, so I moved it to phy-reset-gpios inside the fec node.

I don't think this is a blocker for your v5 series. We can improve it later so that
the binding from Linux could also work in U-Boot.

Thanks

reviewer
#23 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Hi Tim,

Quoted 15 lines · Fabio Estevam

Hi Tim,

Quoted 4 lines · Tim Harvey

Fabio,

Thanks for testing this. I'll submit a v5 shortly with your rb tag and support for 6320:

Thanks for including the 6320 model!

Quoted 3 lines

Was there an error path you found in drivers/net/mv88e6xxx.c that should print an error to explain a failed probe for better future troubleshooting or was that failure somewhere else? It sounds like

I forgot to reply to this one. Yes, it would help if we print an error like this:

drivers/net/mv88e6xxx.c +3 -1
@@ -410,8 +410,10 @@ static int mv88e6xxx_get_switch_id(struct udevice *dev)
        int res;
 
        res = mv88e6xxx_port_read(dev, 0, PORT_REG_SWITCH_ID);
-       if (res < 0)
+       if (res < 0) {
+               dev_err(dev, "Failed to read switch ID: %d\n", res);
                return res;
+       }
        return res & 0xfff0;
 }
 

Thanks

author
#24 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Quoted 37 lines · Fabio Estevam

Hi Tim,

Quoted 15 lines · Fabio Estevam

Hi Tim,

Quoted 4 lines · Tim Harvey

Fabio,

Thanks for testing this. I'll submit a v5 shortly with your rb tag and support for 6320:

Thanks for including the 6320 model!

Quoted 3 lines

Was there an error path you found in drivers/net/mv88e6xxx.c that should print an error to explain a failed probe for better future troubleshooting or was that failure somewhere else? It sounds like

I forgot to reply to this one. Yes, it would help if we print an error like this:

drivers/net/mv88e6xxx.c +3 -1
@@ -410,8 +410,10 @@ static int mv88e6xxx_get_switch_id(struct udevice *dev)
        int res;
 
        res = mv88e6xxx_port_read(dev, 0, PORT_REG_SWITCH_ID);
-       if (res < 0)
+       if (res < 0) {
+               dev_err(dev, "Failed to read switch ID: %d\n", res);
                return res;
+       }
        return res & 0xfff0;
 }
 
Quoted 1 line

Thanks

Fabio,

I just sent a v5 before seeing this. I think all we are waiting for on this series is for Vladimir to ok the dt changes as I believe I have finally done the right thing there now.

If I need to do a v6 I'll add this in, otherwise I'll send it after it gets accepted and merged.

Best Regards,

Tim

#25 lore raw

Re: [PATCH v4 8/8] board: gw_ventana: enable MV88E61XX DSA support

Hi Tim,

Quoted 8 lines · Tim Harvey

Fabio,

I just sent a v5 before seeing this. I think all we are waiting for on this series is for Vladimir to ok the dt changes as I believe I have finally done the right thing there now.

If I need to do a v6 I'll add this in, otherwise I'll send it after it gets accepted and merged.

That's totally fine. Thanks!

reviewer
#26 lore raw
In reply to Tim Harvey

Hi Tim,

Quoted 15 lines · Tim Harvey

This series adds a DSA driver for the MV88E6xxx based on drivers/net/phy/mv88e61xx and uses it in the gwventana_gw5904_defconfig.

The hope is that the other three boards that use the MV88E61xx driver can move to this as well eventually so that we can remove the non-dm driver and the 4 Kconfig options it requires.

The MV88E6xxx has an MDIO interface thus DM_MDIO must be used so support for a UCLASS_MDIO driver is added to the fec_mxc ethernet driver in a way that allows a fallback to the previous non DM_MDIO case as there are many boards out there using this driver that define DM_MDIO but do not have the required dt props for a DM_MDIO driver which would cause a regression.

Quoted 5 lines

Additionally some other patches are here suggested by Vladimir:
- ensure MDIO children are scanned on post-bind is needed
- sanity check DSA driver required ops are present
- allow DSA drivers to not require xmit/recv functions
- remove unecessary xmit/recv functions from ksz9477 driver

I am trying to test your series on a custom imx8mn-based board with a Marvell 88E6320 switch.

I applied your series against U-Boot master, and added the change below to support 88E6320:

drivers/net/mv88e6xxx.c +2 -0
index 6064bb7325..09ce6dd114 100644
@@ -176,6 +176,7 @@
 #define PORT_SWITCH_ID_6220            0x2200
 #define PORT_SWITCH_ID_6240            0x2400
 #define PORT_SWITCH_ID_6250            0x2500
+#define PORT_SWITCH_ID_6320            0x1150
 #define PORT_SWITCH_ID_6352            0x3520
 
 struct mv88e6xxx_priv {
@@ -792,6 +793,7 @@ static int mv88e6xxx_probe(struct udevice *dev)
        case PORT_SWITCH_ID_6071:
        case PORT_SWITCH_ID_6220:
        case PORT_SWITCH_ID_6250:
+       case PORT_SWITCH_ID_6320:
                priv->port_count = 7;
                priv->phy_ctrl1_en_det_shift = 14;
                priv->phy_ctrl1_en_det_width = 1;

When booting I get:

Error: ethernet@30be0000 address not set.
No ethernet found.

And 'dm tree' shows that the Ethernet drivers have not been probed:

=> dm tree

ethernet 0 [ ] fecmxc | | `-- ethernet@30be0000
...
mdio 0 [ ] fec_mdio | | `-- mdio

If you have any suggestions, please let me know.

Thanks

reviewer
#27 lore raw
Quoted 7 lines · Fabio Estevam

And 'dm tree' shows that the Ethernet drivers have not been probed:

=> dm tree

ethernet 0 [ ] fecmxc | | `-- ethernet@30be0000
...
mdio 0 [ ] fec_mdio | | `-- mdio

This was an issue in Kconfig. Now with the new mv88e6xxx driver properly selected I get:

SEC0: RNG instantiated
Net:
Error: ethernet@30be0000 address not set.
Error: ethernet@30be0000 address not set.
Error: ethernet@30be0000 address not set.
Error: ethernet@30be0000 address not set.
Error: ethernet@30be0000 address not
...

and not able to access console as these errors keep coming in loop.

author
#28 lore raw
Quoted 23 lines · Fabio Estevam
Quoted 7 lines · Fabio Estevam

And 'dm tree' shows that the Ethernet drivers have not been probed:

=> dm tree

ethernet 0 [ ] fecmxc | | `-- ethernet@30be0000
...
mdio 0 [ ] fec_mdio | | `-- mdio

This was an issue in Kconfig. Now with the new mv88e6xxx driver properly selected I get:

SEC0: RNG instantiated
Net:
Error: ethernet@30be0000 address not set.
Error: ethernet@30be0000 address not set.
Error: ethernet@30be0000 address not set.
Error: ethernet@30be0000 address not set.
Error: ethernet@30be0000 address not
...

Quoted 1 line

and not able to access console as these errors keep coming in loop.

Fabio,

Looks like this is coming from net/eth-uclass.c with CONFIG_NET_RANDOM_ETHADDR not defined and would be because there is no ethaddr env to set the MAC addr?

If I undefine ethaddr on my board and define CONFIG_NET_RANDOM_ETHADDR=y I get an random MAC that is the same for all ports and DHCP/networking works but if I then disable CONFIG_NET_RANDOM_ETHADDR I see the same behavior as you - so it looks like the lack of a valid MAC addr causes eth_post_probe() to fail by design?

Tim