[PATCH] net: phy: Read physical phy IDs before phy is created

Michal Simek monstr at monstr.eu
Tue Jul 26 14:12:38 CEST 2022


po 25. 7. 2022 v 13:13 odesílatel Michal Simek <michal.simek at amd.com> napsal:
>
> ethernet-phy-id directly specify phy ID which is present on the board but
> there is no code which really checks that specified phy ID is actually
> present on the board. That's why read phy ID regs with get_phy_id() call
> and compare it with required ID. If they don't match don't use this driver.
>
> Code is intentionally below reset sequence which get's phy to the right
> state and correct address.
>
> Signed-off-by: Michal Simek <michal.simek at amd.com>
> ---
>
>  drivers/net/phy/ethernet_id.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/phy/ethernet_id.c b/drivers/net/phy/ethernet_id.c
> index 8864f99bb32f..7d56ad4aefa7 100644
> --- a/drivers/net/phy/ethernet_id.c
> +++ b/drivers/net/phy/ethernet_id.c
> @@ -18,7 +18,7 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev,
>         struct ofnode_phandle_args phandle_args;
>         struct gpio_desc gpio;
>         ofnode node;
> -       u32 id, assert, deassert;
> +       u32 id, assert, deassert, phy_id = 0xffffffff;
>         u16 vendor, device;
>         int ret;
>
> @@ -67,7 +67,21 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev,
>                 }
>         }
>
> -       id =  vendor << 16 | device;
> +       ret = get_phy_id(bus, phyaddr, phyaddr, &phy_id);
> +       if (ret) {
> +               dev_err(dev, "Physical phy is not detected\n");
> +               return NULL;
> +       }
> +
> +       id = vendor << 16 | device;
> +
> +       if (phy_id != id) {
> +               dev_err(dev,
> +                       "Required phyid %08x doesn't match with detected phyid %08x\n",
> +                       id, phy_id);
> +               return NULL;
> +       }
> +
>         phydev = phy_device_create(bus, phyaddr, id, false);
>         if (phydev)
>                 phydev->node = node;
> --
> 2.36.1
>

Please ignore this patch. It is not working properly on SOM boards.

Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs


More information about the U-Boot mailing list