[PATCH] net: dwc_eth_qos: Enable clock in probe

Ramon Fried rfried.dev at gmail.com
Thu Dec 2 06:04:11 CET 2021


On Tue, Nov 16, 2021 at 7:53 AM Ramon Fried <rfried.dev at gmail.com> wrote:
>
> On Sat, Nov 13, 2021 at 4:23 AM Marek Vasut <marex at denx.de> wrote:
> >
> > Enable DWC IP clock in driver probe, so the MII access is possible even
> > outside of active network transfers. This is particularly useful when
> > using 'mii' or 'mdio' commands to explore PHY state, neither of which
> > works with DWMAC currently due to the disabled clock.
> >
> > Signed-off-by: Marek Vasut <marex at denx.de>
> > Cc: Joe Hershberger <joe.hershberger at ni.com>
> > Cc: Patrice Chotard <patrice.chotard at foss.st.com>
> > Cc: Patrick Delaunay <patrick.delaunay at foss.st.com>
> > Cc: Ramon Fried <rfried.dev at gmail.com>
> > Cc: Stephen Warren <swarren at nvidia.com>
> > ---
> >  drivers/net/dwc_eth_qos.c | 22 +++++++++++-----------
> >  1 file changed, 11 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
> > index 585101804d3..22dad5b2030 100644
> > --- a/drivers/net/dwc_eth_qos.c
> > +++ b/drivers/net/dwc_eth_qos.c
> > @@ -1045,16 +1045,10 @@ static int eqos_start(struct udevice *dev)
> >         eqos->tx_desc_idx = 0;
> >         eqos->rx_desc_idx = 0;
> >
> > -       ret = eqos->config->ops->eqos_start_clks(dev);
> > -       if (ret < 0) {
> > -               pr_err("eqos_start_clks() failed: %d", ret);
> > -               goto err;
> > -       }
> > -
> >         ret = eqos->config->ops->eqos_start_resets(dev);
> >         if (ret < 0) {
> >                 pr_err("eqos_start_resets() failed: %d", ret);
> > -               goto err_stop_clks;
> > +               goto err;
> >         }
> >
> >         udelay(10);
> > @@ -1360,8 +1354,6 @@ err_shutdown_phy:
> >         phy_shutdown(eqos->phy);
> >  err_stop_resets:
> >         eqos->config->ops->eqos_stop_resets(dev);
> > -err_stop_clks:
> > -       eqos->config->ops->eqos_stop_clks(dev);
> >  err:
> >         pr_err("FAILED: %d", ret);
> >         return ret;
> > @@ -1416,7 +1408,6 @@ static void eqos_stop(struct udevice *dev)
> >                 phy_shutdown(eqos->phy);
> >         }
> >         eqos->config->ops->eqos_stop_resets(dev);
> > -       eqos->config->ops->eqos_stop_clks(dev);
> >
> >         debug("%s: OK\n", __func__);
> >  }
> > @@ -1862,6 +1853,12 @@ static int eqos_probe(struct udevice *dev)
> >                 goto err_remove_resources_core;
> >         }
> >
> > +       ret = eqos->config->ops->eqos_start_clks(dev);
> > +       if (ret < 0) {
> > +               pr_err("eqos_start_clks() failed: %d", ret);
> > +               goto err_remove_resources_tegra;
> > +       }
> > +
> >  #ifdef CONFIG_DM_ETH_PHY
> >         eqos->mii = eth_phy_get_mdio_bus(dev);
> >  #endif
> > @@ -1870,7 +1867,7 @@ static int eqos_probe(struct udevice *dev)
> >                 if (!eqos->mii) {
> >                         pr_err("mdio_alloc() failed");
> >                         ret = -ENOMEM;
> > -                       goto err_remove_resources_tegra;
> > +                       goto err_stop_clks;
> >                 }
> >                 eqos->mii->read = eqos_mdio_read;
> >                 eqos->mii->write = eqos_mdio_write;
> > @@ -1893,6 +1890,8 @@ static int eqos_probe(struct udevice *dev)
> >
> >  err_free_mdio:
> >         mdio_free(eqos->mii);
> > +err_stop_clks:
> > +       eqos->config->ops->eqos_stop_clks(dev);
> >  err_remove_resources_tegra:
> >         eqos->config->ops->eqos_remove_resources(dev);
> >  err_remove_resources_core:
> > @@ -1910,6 +1909,7 @@ static int eqos_remove(struct udevice *dev)
> >
> >         mdio_unregister(eqos->mii);
> >         mdio_free(eqos->mii);
> > +       eqos->config->ops->eqos_stop_clks(dev);
> >         eqos->config->ops->eqos_remove_resources(dev);
> >
> >         eqos_probe_resources_core(dev);
> > --
> > 2.33.0
> >
> Reviewed-by: Ramon Fried <rfried.dev at gmail.com>
Applied to u-boot-net/next,
Thanks.


More information about the U-Boot mailing list