[PATCHv3 03/15] net: tsec: convert to use DM_MDIO when DM_ETH enabled

Vladimir Oltean olteanv at gmail.com
Fri Jun 12 22:31:22 CEST 2020


On Fri, 12 Jun 2020 at 18:23, Zhiqiang Hou <Zhiqiang.Hou at nxp.com> wrote:
>
> From: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
>
> For the platforms on which the eTSEC driver uses DM_ETH, convert its
> MDIO controller code to also use DM_MDIO.
>
> Note that for handling the TBI PHY (the MAC PCS for SGMII), we still
> don't register a udevice for it, since we can drive it locally and there
> is no point in doing otherwise.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean at nxp.com>
> Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
> ---
> V3:
>  - Draw from the tsec.c part of the Vladimir's patch below and do some
>    slightly tweaking:
>    https://patchwork.ozlabs.org/project/uboot/patch/20200503185227.28731-4-olteanv@gmail.com/
>
>  drivers/net/tsec.c | 46 +++++++++++++---------------------------------
>  1 file changed, 13 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> index 3d75acb6b4..cb3e56d439 100644
> --- a/drivers/net/tsec.c
> +++ b/drivers/net/tsec.c
> @@ -18,6 +18,7 @@
>  #include <linux/bitops.h>
>  #include <linux/delay.h>
>  #include <linux/errno.h>
> +#include <miiphy.h>
>  #include <asm/processor.h>
>  #include <asm/io.h>
>
> @@ -681,8 +682,15 @@ static int init_phy(struct tsec_private *priv)
>         if (priv->interface == PHY_INTERFACE_MODE_SGMII)
>                 tsec_configure_serdes(priv);
>
> +#ifdef CONFIG_DM_ETH
> +       if (ofnode_valid(ofnode_find_subnode(priv->dev->node, "fixed-link")))
> +               phydev = phy_connect(NULL, 0, priv->dev, priv->interface);
> +       else
> +               phydev = dm_eth_phy_connect(priv->dev);
> +#else

You said it's better to split the fixed-link functionality into a
separate patch, but then you didn't :)

>         phydev = phy_connect(priv->bus, priv->phyaddr, priv->dev,
>                              priv->interface);
> +#endif
>         if (!phydev)
>                 return 0;
>
> @@ -787,14 +795,17 @@ int tsec_standard_init(bd_t *bis)
>         return tsec_eth_init(bis, tsec_info, ARRAY_SIZE(tsec_info));
>  }
>  #else /* CONFIG_DM_ETH */
> +
> +#ifndef CONFIG_DM_MDIO
> +#error "TSEC with DM_ETH also requires DM_MDIO"
> +#endif
> +
>  int tsec_probe(struct udevice *dev)
>  {
>         struct eth_pdata *pdata = dev_get_platdata(dev);
>         struct tsec_private *priv = dev_get_priv(dev);
> -       struct tsec_mii_mng __iomem *ext_phyregs_mii;
>         struct ofnode_phandle_args phandle_args;
>         u32 tbiaddr = CONFIG_SYS_TBIPA_VALUE;
> -       struct fsl_pq_mdio_info mdio_info;
>         const char *phy_mode;
>         fdt_addr_t reg;
>         ofnode parent;
> @@ -803,31 +814,6 @@ int tsec_probe(struct udevice *dev)
>         pdata->iobase = (phys_addr_t)dev_read_addr(dev);
>         priv->regs = dev_remap_addr(dev);
>
> -       if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
> -                                      &phandle_args)) {
> -               printf("phy-handle does not exist under tsec %s\n", dev->name);
> -               return -ENOENT;
> -       } else {
> -               int reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
> -
> -               priv->phyaddr = reg;
> -       }
> -
> -       parent = ofnode_get_parent(phandle_args.node);
> -       if (!ofnode_valid(parent)) {
> -               printf("No parent node for PHY?\n");
> -               return -ENOENT;
> -       }
> -
> -       reg = ofnode_get_addr_index(parent, 0);
> -       if (reg == FDT_ADDR_T_NONE) {
> -               printf("No 'reg' property of MII for external PHY\n");
> -               return -ENOENT;
> -       }
> -
> -       ext_phyregs_mii = map_physmem(reg + TSEC_MDIO_REGS_OFFSET, 0,
> -                                     MAP_NOCACHE);
> -
>         ret = dev_read_phandle_with_args(dev, "tbi-handle", NULL, 0, 0,
>                                          &phandle_args);
>         if (ret == 0) {
> @@ -865,12 +851,6 @@ int tsec_probe(struct udevice *dev)
>         if (priv->interface == PHY_INTERFACE_MODE_SGMII)
>                 priv->flags |= TSEC_SGMII;
>
> -       mdio_info.regs = ext_phyregs_mii;
> -       mdio_info.name = (char *)dev->name;
> -       ret = fsl_pq_mdio_init(NULL, &mdio_info);
> -       if (ret)
> -               return ret;
> -
>         /* Reset the MAC */
>         setbits_be32(&priv->regs->maccfg1, MACCFG1_SOFT_RESET);
>         udelay(2);  /* Soft Reset must be asserted for 3 TX clocks */
> --
> 2.25.1
>


More information about the U-Boot mailing list