On Wed, May 31, 2023 at 1:51 AM Marek Vasut
wrote:
>
> In case a new PHY is created and DM_ETH_PHY is enabled, bind a
> generic PHY driver from ETH_PHY uclass to the PHY to have a
> matching DM representation of that PHY.
>
> Signed-off-by: Marek Vasut
> ---
> Cc: Geert Uytterhoeven
> Cc: Joe Hershberger
> Cc: Michal Simek
> Cc: Nishanth Menon
> Cc: Ramon Fried
> ---
> drivers/net/phy/ethernet_id.c | 17 +
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/net/phy/ethernet_id.c b/drivers/net/phy/ethernet_id.c
> index a715e83db98..877a51c3d00 100644
> --- a/drivers/net/phy/ethernet_id.c
> +++ b/drivers/net/phy/ethernet_id.c
> @@ -7,6 +7,8 @@
>
> #include
> #include
> +#include
> +#include
> #include
> #include
> #include
> @@ -17,6 +19,8 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus,
> struct udevice *dev,
> struct phy_device *phydev;
> struct ofnode_phandle_args phandle_args;
> struct gpio_desc gpio;
> + const char *node_name;
> + struct udevice *pdev;
> ofnode node;
> u32 id, assert, deassert;
> u16 vendor, device;
> @@ -72,5 +76,18 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus,
> struct udevice *dev,
> if (phydev)
> phydev->node = node;
>
> + if (IS_ENABLED(CONFIG_DM_ETH_PHY) && ofnode_valid(node)) {
> + node_name = ofnode_get_name(node);
> + ret = device_bind_driver_to_node(dev, "eth_phy_generic_drv",
> +node_name, node,
> +);
> + if (ret)
> + return NULL;
> +
> + ret = device_probe(pdev);
> + if (ret)
> + return NULL;
> + }
> +
> return phydev;
> }
> --
> 2.39.2
>
Reviewed-by: Ramon Fried