All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Hershberger <joe.hershberger@ni.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/6] driver: net: fsl-mc: Modify the dpmac link detection method
Date: Wed, 25 Jul 2018 15:13:07 -0500	[thread overview]
Message-ID: <CANr=Z=Y_8yo1jK98Ahgotvc1By4WqjRskD-G2OjV8_hY7crDQg@mail.gmail.com> (raw)
In-Reply-To: <20180713144036.17606-5-pankaj.bansal@nxp.com>

On Fri, Jul 13, 2018 at 9:40 AM, Pankaj Bansal <pankaj.bansal@nxp.com> wrote:
> when there is no phy present for a dpmac, a dummy phy device is created.
> when we move to multiple phy method, we need to create as many dummy phy
> devices.
>
> Change this method so that we don't need to create dummy phy devices.
> We always report linkup if no phy is present.
>
> Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
> ---
>  drivers/net/ldpaa_eth/ldpaa_eth.c | 121 +++++++++++++---------------
>  1 file changed, 58 insertions(+), 63 deletions(-)
>
> diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
> index 8fcb948ee8..d2a6d90f18 100644
> --- a/drivers/net/ldpaa_eth/ldpaa_eth.c
> +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
> @@ -386,6 +386,60 @@ error:
>         return err;
>  }
>
> +static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv,
> +                                struct dpmac_link_state *state)
> +{
> +       struct phy_device *phydev = NULL;
> +       phy_interface_t enet_if;
> +       int err;
> +
> +       /* let's start off with maximum capabilities
> +        */
> +       enet_if = wriop_get_enet_if(priv->dpmac_id);
> +       switch (enet_if) {
> +       case PHY_INTERFACE_MODE_XGMII:
> +               state->rate = SPEED_10000;
> +               break;
> +       default:
> +               state->rate = SPEED_1000;
> +               break;
> +       }
> +       state->up = 1;
> +
> +#ifdef CONFIG_PHYLIB
> +       state->options |= DPMAC_LINK_OPT_AUTONEG;
> +
> +       phydev = wriop_get_phy_dev(priv->dpmac_id);
> +       if (phydev) {
> +               err = phy_startup(phydev);
> +               if (err) {
> +                       printf("%s: Could not initialize\n", phydev->dev->name);
> +                       state->up = 0;
> +               }
> +               if (phydev->link == 1) {

Just "phydev->link"

> +                       state->rate = state->rate < phydev->speed ?
> +                                     state->rate : phydev->speed;

MIN(state->rate, phydev->speed);

> +                       if (!phydev->duplex)
> +                               state->options |= DPMAC_LINK_OPT_HALF_DUPLEX;
> +                       if (!phydev->autoneg)
> +                               state->options &= ~DPMAC_LINK_OPT_AUTONEG;
> +               } else {
> +                       state->up = 0;
> +               }
> +       }
> +#endif
> +       if (!phydev)
> +               state->options &= ~DPMAC_LINK_OPT_AUTONEG;
> +
> +       if (state->up == 0) {
> +               state->rate = 0;
> +               state->options = 0;
> +               return -1;

return -ENODEV;

> +       }
> +
> +       return 0;
> +}
> +
>  static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)
>  {
>         struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
> @@ -394,10 +448,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)
>         struct dpni_link_state link_state;
>  #endif
>         int err = 0;
> -       struct mii_dev *bus;
> -       phy_interface_t enet_if;
>         struct dpni_queue d_queue;
> -       struct phy_device *phydev = NULL;
>
>         if (net_dev->state == ETH_STATE_ACTIVE)
>                 return 0;
> @@ -417,45 +468,9 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)
>         if (err < 0)
>                 goto err_dpmac_setup;
>
> -#ifdef CONFIG_PHYLIB
> -       phydev = wriop_get_phy_dev(priv->dpmac_id);
> -       if (phydev) {
> -               err = phy_startup(phydev);
> -               if (err) {
> -                       printf("%s: Could not initialize\n",
> -                              phydev->dev->name);
> -                       goto err_dpmac_bind;
> -               }
> -       }
> -#else
> -       phydev = (struct phy_device *)malloc(sizeof(struct phy_device));
> -       memset(phydev, 0, sizeof(struct phy_device));
> -       wriop_set_phy_dev(priv->dpmac_id, phydev);
> -
> -       phydev->speed = SPEED_1000;
> -       phydev->link = 1;
> -       phydev->duplex = DUPLEX_FULL;
> -#endif
> -
> -       bus = wriop_get_mdio(priv->dpmac_id);
> -       enet_if = wriop_get_enet_if(priv->dpmac_id);
> -       if ((bus == NULL) &&
> -           (enet_if == PHY_INTERFACE_MODE_XGMII)) {
> -               phydev = (struct phy_device *)
> -                               malloc(sizeof(struct phy_device));
> -               memset(phydev, 0, sizeof(struct phy_device));
> -               wriop_set_phy_dev(priv->dpmac_id, phydev);
> -
> -               phydev->speed = SPEED_10000;
> -               phydev->link = 1;
> -               phydev->duplex = DUPLEX_FULL;
> -       }
> -
> -       if (!phydev->link) {
> -               printf("%s: No link.\n", phydev->dev->name);
> -               err = -1;
> +       err = ldpaa_get_dpmac_state(priv, &dpmac_link_state);
> +       if (err < 0)
>                 goto err_dpmac_bind;
> -       }
>
>         /* DPMAC binding DPNI */
>         err = ldpaa_dpmac_bind(priv);
> @@ -489,18 +504,6 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)
>                 return err;
>         }
>
> -       dpmac_link_state.rate = phydev->speed;
> -
> -       if (phydev->autoneg == AUTONEG_DISABLE)
> -               dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG;
> -       else
> -               dpmac_link_state.options |= DPMAC_LINK_OPT_AUTONEG;
> -
> -       if (phydev->duplex == DUPLEX_HALF)
> -               dpmac_link_state.options |= DPMAC_LINK_OPT_HALF_DUPLEX;
> -
> -       dpmac_link_state.up = phydev->link;
> -
>         err = dpmac_set_link_state(dflt_mc_io, MC_CMD_NO_FLAGS,
>                                   priv->dpmac_handle, &dpmac_link_state);
>         if (err < 0) {
> @@ -543,7 +546,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)
>                 goto err_qdid;
>         }
>
> -       return phydev->link;
> +       return dpmac_link_state.up;
>
>  err_qdid:
>  err_get_queue:
> @@ -566,9 +569,6 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)
>  {
>         struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
>         int err = 0;
> -#ifdef CONFIG_PHYLIB
> -       struct mii_dev *bus = wriop_get_mdio(priv->dpmac_id);
> -#endif
>         struct phy_device *phydev = NULL;
>
>         if ((net_dev->state == ETH_STATE_PASSIVE) ||
> @@ -603,13 +603,8 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)
>
>  #ifdef CONFIG_PHYLIB
>         phydev = wriop_get_phy_dev(priv->dpmac_id);
> -       if (phydev && bus != NULL)
> +       if (phydev)
>                 phy_shutdown(phydev);
> -       else {
> -               free(phydev);
> -               phydev = NULL;
> -               wriop_set_phy_dev(priv->dpmac_id, phydev);
> -       }
>  #endif
>
>         /* Free DPBP handle and reset. */
> --
> 2.17.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

  reply	other threads:[~2018-07-25 20:13 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 14:40 [U-Boot] [PATCH 0/6] driver: net: fsl-mc: Add support of multiple phys for dpmac Pankaj Bansal
2018-07-13 14:40 ` [U-Boot] [PATCH 1/6] driver: net: fsl-mc: modify the label name Pankaj Bansal
2018-07-25 19:39   ` Joe Hershberger
2018-07-13 14:40 ` [U-Boot] [PATCH v3 2/6] driver: net: fsl-mc: remove unused strcture elements Pankaj Bansal
2018-07-25 20:03   ` Joe Hershberger
2018-07-13 14:40 ` [U-Boot] [PATCH 3/6] driver: net: fsl-mc: fix error handing in init_phy Pankaj Bansal
2018-07-25 20:04   ` Joe Hershberger
2018-07-13 14:40 ` [U-Boot] [PATCH 4/6] driver: net: fsl-mc: Modify the dpmac link detection method Pankaj Bansal
2018-07-25 20:13   ` Joe Hershberger [this message]
2018-07-13 14:40 ` [U-Boot] [PATCH 5/6] driver: net: fsl-mc: initialize dpmac irrespective of phy Pankaj Bansal
2018-07-25 20:14   ` Joe Hershberger
2018-07-13 14:40 ` [U-Boot] [PATCH 6/6] driver: net: fsl-mc: Add support of multiple phys for dpmac Pankaj Bansal
2018-07-25 20:52   ` Joe Hershberger
2018-07-19  3:35 ` [U-Boot] [PATCH 0/6] " Prabhakar Kushwaha
2018-07-25  3:03   ` Pankaj Bansal
2018-07-30 13:14 ` [U-Boot] [PATCH v2 " Pankaj Bansal
2018-07-30 13:15   ` [U-Boot] [PATCH v2 1/6] driver: net: fsl-mc: modify the label name Pankaj Bansal
2018-07-30 20:20     ` Joe Hershberger
2018-07-30 13:15   ` [U-Boot] [PATCH v2 2/6] driver: net: fsl-mc: remove unused strcture elements Pankaj Bansal
2018-07-30 20:19     ` Joe Hershberger
2018-07-30 13:15   ` [U-Boot] [PATCH v2 3/6] driver: net: fsl-mc: fix error handing in init_phy Pankaj Bansal
2018-07-30 20:26     ` Joe Hershberger
2018-07-30 13:15   ` [U-Boot] [PATCH v2 4/6] driver: net: fsl-mc: Modify the dpmac link detection method Pankaj Bansal
2018-07-30 20:35     ` Joe Hershberger
2018-07-30 13:15   ` [U-Boot] [PATCH v2 5/6] driver: net: fsl-mc: initialize dpmac irrespective of phy Pankaj Bansal
2018-07-30 20:36     ` Joe Hershberger
2018-07-30 13:15   ` [U-Boot] [PATCH v2 6/6] driver: net: fsl-mc: Add support of multiple phys for dpmac Pankaj Bansal
2018-07-30  8:05     ` Pankaj Bansal
2018-07-30 21:43     ` Joe Hershberger
2018-10-09 21:32     ` Joe Hershberger
2018-10-10  2:59       ` Pankaj Bansal
2018-10-10  8:27   ` [U-Boot] [PATCH v3 0/6] " Pankaj Bansal
2018-10-10  8:27     ` [U-Boot] [PATCH v3 1/6] driver: net: fsl-mc: modify the label name Pankaj Bansal
2018-10-10  8:27     ` [U-Boot] [PATCH v3 2/6] driver: net: fsl-mc: remove unused strcture elements Pankaj Bansal
2018-10-10  3:59       ` Joe Hershberger
2018-10-10  5:10         ` Pankaj Bansal
2018-10-10 18:35           ` Joe Hershberger
2018-10-10  8:28     ` [U-Boot] [PATCH v3 3/6] driver: net: fsl-mc: fix error handing in init_phy Pankaj Bansal
2018-10-10  8:28     ` [U-Boot] [PATCH v3 4/6] driver: net: fsl-mc: Modify the dpmac link detection method Pankaj Bansal
2018-10-10  8:28     ` [U-Boot] [PATCH v3 5/6] driver: net: fsl-mc: initialize dpmac irrespective of phy Pankaj Bansal
2018-10-10  8:28     ` [U-Boot] [PATCH v3 6/6] driver: net: fsl-mc: Add support of multiple phys for dpmac Pankaj Bansal
2018-10-10  8:38   ` [U-Boot] [PATCH v3 0/6] " Pankaj Bansal
2018-10-10  8:38     ` [U-Boot] [PATCH v3 1/6] driver: net: fsl-mc: modify the label name Pankaj Bansal
2018-10-22 19:28       ` [U-Boot] " Joe Hershberger
2018-10-10  8:38     ` [U-Boot] [PATCH v3 2/6] driver: net: fsl-mc: remove unused strcture elements Pankaj Bansal
2018-10-22 19:28       ` [U-Boot] " Joe Hershberger
2018-10-10  8:38     ` [U-Boot] [PATCH v3 3/6] driver: net: fsl-mc: fix error handing in init_phy Pankaj Bansal
2018-10-22 19:28       ` [U-Boot] " Joe Hershberger
2018-10-10  8:38     ` [U-Boot] [PATCH v3 4/6] driver: net: fsl-mc: Modify the dpmac link detection method Pankaj Bansal
2018-10-22 19:28       ` [U-Boot] " Joe Hershberger
2018-10-10  8:38     ` [U-Boot] [PATCH v3 5/6] driver: net: fsl-mc: initialize dpmac irrespective of phy Pankaj Bansal
2018-10-22 19:28       ` [U-Boot] " Joe Hershberger
2018-10-10  8:38     ` [U-Boot] [PATCH v3 6/6] driver: net: fsl-mc: Add support of multiple phys for dpmac Pankaj Bansal
2018-10-22 19:28       ` [U-Boot] " Joe Hershberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANr=Z=Y_8yo1jK98Ahgotvc1By4WqjRskD-G2OjV8_hY7crDQg@mail.gmail.com' \
    --to=joe.hershberger@ni.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.