Add MV88E61xx DSA driver and use on gwventana
Subsystems (4)
PATCH v2 1/8 net: mdio-uclass: scan for dm mdio children on post-bind
In reply to Tim HarveyIf a DM_MDIO driver is used we need to scan the subnodes as well.
---
v2:
- added Ramon's rb tag
--- net/mdio-uclass.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mdio-uclass.c +4 -0
@@ -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.17.1
PATCH v2 2/8 net: dsa: move cpu port probe to dsa_post_probe
In reply to Tim HarveyIn 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.
---
v2:
- added Ramon's rb tag
--- net/dsa-uclass.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
net/dsa-uclass.c +11 -3
@@ -466,8 +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; priv->cpu_port = pdata->cpu_port;
@@ -480,6 +478,15 @@ static int dsa_pre_probe(struct udevice *dev)uclass_find_device_by_ofnode (UCLASS_ETH , pdata->master_node, &priv->master_dev); +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,
@@ -489,13 +496,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.17.1
PATCH v2 5/8 net: ksz9477: remove unnecessary xmit and recv functions
In reply to Tim HarveyRemove the unnecessary xmit and recv functions.
---
v2: new patch
--- drivers/net/ksz9477.c | 23 ----------------------- 1 file changed, 23 deletions(-)
drivers/net/ksz9477.c +0 -23
@@ -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.17.1
v2 cover Add MV88E61xx DSA driver and use on gwventana
This series adds a DSA driver for the MV88E61xx based on drivers/net/phy/mv88e61xx and uses in on 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 MV88E61xx 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
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 | 35 + board/gateworks/gw_ventana/gw_ventana.c | 50 +- configs/gwventana_gw5904_defconfig | 7 +- drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/fec_mxc.c | 90 ++- drivers/net/ksz9477.c | 23 - drivers/net/mv88e61xx.c | 843 ++++++++++++++++++++++++ net/dsa-uclass.c | 58 +- net/mdio-uclass.c | 4 + 10 files changed, 1045 insertions(+), 73 deletions(-) create mode 100644 drivers/net/mv88e61xx.c
Signature · 1 line
2.17.1
PATCH v2 4/8 net: dsa: allow rcv() and xmit() to be optional
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.
---
v2: new patch
--- net/dsa-uclass.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
net/dsa-uclass.c +18 -9
@@ -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.17.1
PATCH v2 3/8 net: dsa: ensure dsa driver has proper ops
In reply to Tim HarveyAdd a function to sanity check a dsa driver having proper ops.
---
v2: new patch
--- net/dsa-uclass.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
net/dsa-uclass.c +17 -0
@@ -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.17.1
PATCH v2 6/8 net: fec: add support for DM_MDIO
In reply to Tim HarveyAdd 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.
---
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
@@ -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>
@@ -1025,6 +1027,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);
@@ -1088,7 +1165,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);
@@ -1096,7 +1173,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 ;
@@ -1227,6 +1307,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.17.1
PATCH v2 8/8 board: gw_ventana: enable MV88E61XX DSA support
In reply to Tim HarveyAdd 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
---
v2: no changes
--- arch/arm/dts/imx6qdl-gw5904.dtsi | 35 +++++++++++++++++ board/gateworks/gw_ventana/gw_ventana.c | 50 +++++++++---------------- configs/gwventana_gw5904_defconfig | 7 ++-- 3 files changed, 56 insertions(+), 36 deletions(-)
arch/arm/dts/imx6qdl-gw5904.dtsi +35 -0
@@ -219,6 +219,27 @@ compatible = "marvell,mv88e6085"; reg = <0>; + mdios { + #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>;
@@ -226,27 +247,41 @@ port@0 { reg = <0>; label = "lan4"; + phy-mode = "internal"; + phy-handle = <&sw_phy0>; }; port@1 { reg = <1>; label = "lan3"; + phy-mode = "internal"; + phy-handle = <&sw_phy1>; }; port@2 { reg = <2>; label = "lan2"; + phy-mode = "internal"; + phy-handle = <&sw_phy2>; }; port@3 { reg = <3>; label = "lan1"; + phy-mode = "internal"; + 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 +3 -4
@@ -103,12 +103,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
Signature · 1 line
2.17.1
PATCH v2 7/8 net: add MV88E61xx DSA driver
In reply to Tim HarveyAdd a DSA driver for the MV88E61xx compatible GbE Ethernet switches.
---
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/mv88e61xx.c | 843 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 851 insertions(+) create mode 100644 drivers/net/mv88e61xx.c
drivers/net/Kconfig +7 -0
@@ -433,6 +433,13 @@ config LPC32XX_ETH depends on ARCH_LPC32XX default y +config MV88E61XX + bool "Marvell MV88E61xx GbE switch DSA driver" + depends on DM_DSA && DM_MDIO + help + This driver implements a DSA switch driver for the MV88E61xx 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
@@ -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_MV88E61XX) += mv88e61xx.o obj-$(CONFIG_MVGBE) += mvgbe.o obj-$(CONFIG_MVMDIO) += mvmdio.o obj-$(CONFIG_MVNETA) += mvneta.o
drivers/net/mv88e61xx.c new file +843 -0
843 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 2/8] net: dsa: move cpu port probe to dsa_post_probe
In reply to Tim HarveyQuoted 7 lines · Tim Harvey
In order to ensure that a DSA driver probe gets called before
dsa_ops->port_probemove theport_probeof thecpu_portto a post-probe function.Signed-off-by Tim Harvey <[email protected]>Reviewed-by Ramon Fried <[email protected]>---
Re: [PATCH 5/8] net: ksz9477: remove unnecessary xmit and recv functions
In reply to Tim HarveyQuoted 4 lines · Tim Harvey
Remove the unnecessary xmit and recv functions.
Signed-off-by Tim Harvey <[email protected]>---
Re: [PATCH 4/8] net: dsa: allow rcv() and xmit() to be optional
In reply to Tim HarveyQuoted 7 lines · Tim Harvey
Allow
rcv()andxmit()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.Suggested-by Vladimir Oltean <[email protected]>Signed-off-by Tim Harvey <[email protected]>---
Re: [PATCH 3/8] net: dsa: ensure dsa driver has proper ops
In reply to Tim HarveyQuoted 5 lines · Tim Harvey
Add a function to sanity check a dsa driver having proper ops.
Suggested-by Vladimir Oltean <[email protected]>Signed-off-by Tim Harvey <[email protected]>---
Re: [PATCH 7/8] net: add MV88E61xx DSA driver
In reply to Tim HarveyQuoted 5 lines · Tim Harvey
Add a DSA driver for the MV88E61xx compatible GbE Ethernet switches.
Cc Marek BehĂșn <[email protected]>Cc Vladimir Oltean <[email protected]>Signed-off-by Tim Harvey <[email protected]>
Quoted 16 lines
---
v2:
- rebase on v2022.07-rc1 (useofnode_get_phy_node)
- remove unused commented out fields from struct
- remove unusedPORT_MASKmacro
- remove phy from priv struct name
- refactor code from originaldrivers/net/phy/mv88e61xxwith suggestions from review to consolidate some functions intomv88e61xx_dsa_port_enable
- remove unecessary skiping of disabling of CPU port
- remove unecessarydev_set_parent_priv
- remove unnecessary static init flag
- replace debug with adev_warnif 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
---
Some may prefer the driver be named mv88e6xxx, for more perceived similarity with Linux.
That can be done later anyway. Thanks for the submission, IMO it looks good enough and is certainly a great start.
Re: [PATCH 8/8] board: gw_ventana: enable MV88E61XX DSA support
In reply to Tim HarveyQuoted 21 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.
- update defconfig
- replacemv88e61xx_hw_resetweak override withboard_phy_configsupport for mv88e61xx configuration that is outside the scope of the DSA driverSigned-off-by Tim Harvey <[email protected]>---
v2: no changes--- arch/arm/dts/imx6qdl-gw5904.dtsi | 35 +++++++++++++++++ board/gateworks/gw_ventana/gw_ventana.c | 50 +++++++++---------------- configs/gwventana_gw5904_defconfig | 7 ++-- 3 files changed, 56 insertions(+), 36 deletions(-)arch/arm/dts/imx6qdl-gw5904.dtsi +0
-0
arch/arm/dts/imx6qdl-gw5904.dtsi line 222
Quoted 4 lines
arch/arm/dts/imx6qdl-gw5904.dtsi +1
-0@@ -219,6 +219,27 @@ compatible = "marvell,mv88e6085"; reg = <0>; + mdios {
I'm thinking either "mdios" is a container node for other "mdio" nodes, or you have the "mdio" node directly. Are you sure you want this structure? We might have problems if we pass this DT as-is up to Linux. Whereas the support for an "mdios" subnode could be upstreamed, I think. The current DT bindings document says:
- mdio : Container of PHY and devices on the switches MDIO
bus.
- mdio? : Container of PHYs and devices on the external MDIO
bus. The node must contains a compatible string of "marvell,mv88e6xxx-mdio-external"
You have an "mdios" which theoretically matches "mdio?" but only unintendedly so, since it is the internal MDIO bus and not the external one.
Easiest way out right now is to not introduce something which isn't parsed by the current Linux driver. So the internal MDIO bus would be named "mdio", and the external one would be named whatever, and would be identified by compatible string.
Quoted 23 lines
arch/arm/dts/imx6qdl-gw5904.dtsi +20
-0+ #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>;
Re: [PATCH 8/8] board: gw_ventana: enable MV88E61XX DSA support
Quoted 64 lines · Vladimir Oltean
Quoted 21 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.
- update defconfig
- replacemv88e61xx_hw_resetweak override withboard_phy_configsupport for mv88e61xx configuration that is outside the scope of the DSA driverSigned-off-by Tim Harvey <[email protected]>---
v2: no changes--- arch/arm/dts/imx6qdl-gw5904.dtsi | 35 +++++++++++++++++ board/gateworks/gw_ventana/gw_ventana.c | 50 +++++++++---------------- configs/gwventana_gw5904_defconfig | 7 ++-- 3 files changed, 56 insertions(+), 36 deletions(-)arch/arm/dts/imx6qdl-gw5904.dtsi +0
-0arch/arm/dts/imx6qdl-gw5904.dtsi line 222
Quoted 4 lines
arch/arm/dts/imx6qdl-gw5904.dtsi +1
-0@@ -219,6 +219,27 @@ compatible = "marvell,mv88e6085"; reg = <0>; + mdios {I'm thinking either "mdios" is a container node for other "mdio" nodes, or you have the "mdio" node directly. Are you sure you want this structure? We might have problems if we pass this DT as-is up to Linux. Whereas the support for an "mdios" subnode could be upstreamed, I think. The current DT bindings document says:
- mdio : Container of PHY and devices on the switches MDIO
bus.
- mdio? : Container of PHYs and devices on the external MDIO
bus. The node must contains a compatible string of "marvell,mv88e6xxx-mdio-external"You have an "mdios" which theoretically matches "mdio?" but only unintendedly so, since it is the internal MDIO bus and not the external one.
Easiest way out right now is to not introduce something which isn't parsed by the current Linux driver. So the internal MDIO bus would be named "mdio", and the external one would be named whatever, and would be identified by compatible string.
Quoted 15 lines
arch/arm/dts/imx6qdl-gw5904.dtsi +15
-0+ #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>; + }; +
Quoted 8 lines
arch/arm/dts/imx6qdl-gw5904.dtsi line 245
Quoted 8 lines
arch/arm/dts/imx6qdl-gw5904.dtsi +5
-0+ sw_phy3: ethernet-phy@3 { + reg = <0x3>; + }; + }; + ports { #address-cells = <1>; #size-cells = <0>;
Vladimir,
I'm not sure I follow your suggestion correctly. I agree this is not ideal and not at all what I wanted. The dt prior to this patch is what exists and works in Linux but U-Boot dsa (more correctly DM_MDIO dm_eth_phy_connect()) requires the phy-mode and phy-handle in the ports and I'm not clear how to define the mdio's for those to point to here.
Recall I did the same thing for gw7901 in commit 1cb87b929e1e ("arm:
dts: imx8mm-venice-gw7901.dts: fix dsa switch configuration") which I didn't feel was correct either as the previous dt there is what is in Linux and works.
Can you give me an example?
Best Regards,
Tim
Re: [PATCH 8/8] board: gw_ventana: enable MV88E61XX DSA support
Hi Tim,
Quoted 83 lines · Tim Harvey
Quoted 64 lines · Vladimir Oltean
Quoted 21 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.
- update defconfig
- replacemv88e61xx_hw_resetweak override withboard_phy_configsupport for mv88e61xx configuration that is outside the scope of the DSA driverSigned-off-by Tim Harvey <[email protected]>---
v2: no changes--- arch/arm/dts/imx6qdl-gw5904.dtsi | 35 +++++++++++++++++ board/gateworks/gw_ventana/gw_ventana.c | 50 +++++++++---------------- configs/gwventana_gw5904_defconfig | 7 ++-- 3 files changed, 56 insertions(+), 36 deletions(-)arch/arm/dts/imx6qdl-gw5904.dtsi +0
-0arch/arm/dts/imx6qdl-gw5904.dtsi line 222
Quoted 4 lines
arch/arm/dts/imx6qdl-gw5904.dtsi +1
-0@@ -219,6 +219,27 @@ compatible = "marvell,mv88e6085"; reg = <0>; + mdios {I'm thinking either "mdios" is a container node for other "mdio" nodes, or you have the "mdio" node directly. Are you sure you want this structure? We might have problems if we pass this DT as-is up to Linux. Whereas the support for an "mdios" subnode could be upstreamed, I think. The current DT bindings document says:
- mdio : Container of PHY and devices on the switches MDIO
bus.
- mdio? : Container of PHYs and devices on the external MDIO
bus. The node must contains a compatible string of "marvell,mv88e6xxx-mdio-external"You have an "mdios" which theoretically matches "mdio?" but only unintendedly so, since it is the internal MDIO bus and not the external one.
Easiest way out right now is to not introduce something which isn't parsed by the current Linux driver. So the internal MDIO bus would be named "mdio", and the external one would be named whatever, and would be identified by compatible string.
Quoted 15 lines
arch/arm/dts/imx6qdl-gw5904.dtsi +15
-0+ #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>; + }; +Quoted 8 lines
arch/arm/dts/imx6qdl-gw5904.dtsi line 245
Quoted 8 lines
arch/arm/dts/imx6qdl-gw5904.dtsi +5
-0+ sw_phy3: ethernet-phy@3 { + reg = <0x3>; + }; + }; + ports { #address-cells = <1>; #size-cells = <0>;Vladimir,
I'm not sure I follow your suggestion correctly. I agree this is not ideal and not at all what I wanted. The dt prior to this patch is what exists and works in Linux but U-Boot dsa (more correctly
DM_MDIOdm_eth_phy_connect()) requires the phy-mode and phy-handle in the ports and I'm not clear how to define the mdio's for those to point to here.
Quoted 6 lines
Recall I did the same thing for gw7901 in commit
1cb87b929e1e("arm:
dts:imx8mm-venice-gw7901.dts: fix dsa switch configuration") which I didn't feel was correct either as the previous dt there is what is in Linux and works.Can you give me an example?
My considerations are the following.
The Linux Documentation/devicetree/bindings/net/mdio.yaml file says that the following are valid node names for an MDIO controller:
properties:
$nodename:
pattern: "^mdio(@.*)?"
In simple terms, "mdio" or "mdio@something".
When you put an "mdio" controller on the same level as the "ports" node, you cannot use the "mdio@something" syntax, because the #address-cells and #size-cells must be 0 (otherwise said, if you say "mdio@something", you are also forced to say "ports@something").
This is not a problem if there is a single MDIO controller, because you can just use "mdio" and call it a day.
But when you have multiple MDIO controllers, naming the second one becomes problematic.
The Linux mv88e6xxx driver expects secondary (external) MDIO controllers to be named whatever (mdio1 for example) and just looks at their compatible strings. This is fine, but the "mdio1" name is neither "mdio" nor "mdio@something". So mdio.yaml won't really validate these nodes.
This is why some other drivers have an "mdios" container node on the same level as "ports", and make "mdios" have #address-cells of 1, so that children of "mdios" can be "mdio@something", and all children will be validated by mdio.yaml.
The mv88e6xxx driver does not support parsing an "mdios" container node, but code for that could be added, if we ever wanted to improve the bindings for this switch.
All that I'm saying is that your approach is the weird mix where you are neither benefitting from having a container node for MDIO controllers, nor complying to mdio.yaml, nor following what the Linux driver expects. You are free to make a choice whether to simply follow the non-compliant Linux way of having "mdio", "mdio1", etc, or to introduce a proper "mdios" container node here _and_ in Linux. But what you've proposed currently doesn't really make sense.