mbox series

[v4,0/8] Add MV88E6xxx DSA driver and use on gwventana

Message ID 20220928193732.998665-1-tharvey@gateworks.com
Headers show
Series Add MV88E6xxx DSA driver and use on gwventana | expand

Message

Tim Harvey Sept. 28, 2022, 7:37 p.m. UTC
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

Comments

Fabio Estevam Oct. 3, 2022, 4:26 p.m. UTC | #1
Hi Tim,

On Wed, Sep 28, 2022 at 4:37 PM Tim Harvey <tharvey@gateworks.com> wrote:
>
> 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

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:

diff --git a/drivers/net/mv88e6xxx.c b/drivers/net/mv88e6xxx.c
index 6064bb7325..09ce6dd114 100644
--- a/drivers/net/mv88e6xxx.c
+++ b/drivers/net/mv88e6xxx.c
@@ -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
Fabio Estevam Oct. 3, 2022, 4:49 p.m. UTC | #2
On Mon, Oct 3, 2022 at 1:26 PM Fabio Estevam <festevam@gmail.com> wrote:

> 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.
Tim Harvey Oct. 3, 2022, 6:47 p.m. UTC | #3
On Mon, Oct 3, 2022 at 9:50 AM Fabio Estevam <festevam@gmail.com> wrote:
>
> On Mon, Oct 3, 2022 at 1:26 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> > 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.

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