[PATCH 13/20] net: phy: fixed: Support the old DT binding

Ramon Fried rfried.dev at gmail.com
Tue Mar 2 18:49:46 CET 2021


On Tue, Mar 2, 2021 at 5:36 PM Bin Meng <bmeng.cn at gmail.com> wrote:
>
> Update fixedphy_probe() to support the old DT binding.
>
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
> ---
>
>  drivers/net/phy/fixed.c | 29 ++++++++++++++++++++++++++---
>  1 file changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
> index 8fc9c66684..6b720c7e4e 100644
> --- a/drivers/net/phy/fixed.c
> +++ b/drivers/net/phy/fixed.c
> @@ -19,11 +19,25 @@ static int fixedphy_probe(struct phy_device *phydev)
>  {
>         struct fixed_link *priv;
>         int ofnode = phydev->addr;
> +       bool old_binding = false;
>         u32 val;
> +       u32 old_val[5];
>
>         /* check for mandatory properties within fixed-link node */
>         val = fdt_getprop_u32_default_node(gd->fdt_blob,
>                                            ofnode, 0, "speed", 0);
> +
> +       if (!val) {
> +               /* try old binding */
> +               old_binding = true;
> +               if (fdtdec_get_int_array(gd->fdt_blob, ofnode, "fixed-link",
> +                                        old_val, ARRAY_SIZE(old_val))) {
> +                       printf("ERROR: no/invalid <fixed-link> property!\n");
> +                       return -ENOENT;
> +               }
> +               val = old_val[2];
> +       }
> +
>         if (val != SPEED_10 && val != SPEED_100 && val != SPEED_1000 &&
>             val != SPEED_2500 && val != SPEED_10000) {
>                 printf("ERROR: no/invalid speed given in fixed-link node!\n");
> @@ -38,9 +52,18 @@ static int fixedphy_probe(struct phy_device *phydev)
>         phydev->priv = priv;
>
>         priv->link_speed = val;
> -       priv->duplex = fdtdec_get_bool(gd->fdt_blob, ofnode, "full-duplex");
> -       priv->pause = fdtdec_get_bool(gd->fdt_blob, ofnode, "pause");
> -       priv->asym_pause = fdtdec_get_bool(gd->fdt_blob, ofnode, "asym-pause");
> +       if (!old_binding) {
> +               priv->duplex = fdtdec_get_bool(gd->fdt_blob, ofnode,
> +                                              "full-duplex");
> +               priv->pause = fdtdec_get_bool(gd->fdt_blob, ofnode,
> +                                             "pause");
> +               priv->asym_pause = fdtdec_get_bool(gd->fdt_blob, ofnode,
> +                                                  "asym-pause");
> +       } else {
> +               priv->duplex = old_val[1];
> +               priv->pause = old_val[3];
> +               priv->asym_pause = old_val[4];
> +       }
>
>         /* fixed-link phy must not be reset by core phy code */
>         phydev->flags |= PHY_FLAG_BROKEN_RESET;
> --
> 2.25.1
>
Reviewed-By: Ramon Fried <rfried.dev at gmail.com>


More information about the U-Boot mailing list