Message ID | 20210216224804.3355044-4-olteanv@gmail.com |
---|---|
State | Superseded |
Delegated to: | Tom Rini |
Headers | show |
Series | Sandbox driver for DSA uclass | expand |
Hi Vladimir, On Wed, Feb 17, 2021 at 6:48 AM Vladimir Oltean <olteanv@gmail.com> wrote: > > From: Vladimir Oltean <vladimir.oltean@nxp.com> > > It would be desirable for top-level callers of PHYLIB to deal with as > little complexity as possible, and when they call dm_eth_phy_connect, > they get a struct phy_device that "just works". > > There is a phy_connect_fixed interception put in phy_connect, however > dm_eth_phy_connect will not reach there: if will search for a phy-handle > all by itself, and error out if there isn't one. So we can make callers > of dm_eth_phy_connect suffer by having them call: > > err = dm_eth_phy_connect(); > if (err) > err = dm_eth_phy_connect_fixed(); > > or we can just add the logic in dm_eth_phy_connect() that searches for a > fixed-link before searching for a phy-handle. This logic already exists since: commit bdf319273b4a752664c089fbffee5bb2024c8586 Author: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Date: Mon Oct 5 15:15:16 2020 +0200 mdio-uclass.c: support fixed-link subnodes > In fact we already have an in-tree driver that can make use of this > refactoring: the Freescale TSEC driver. I will drop the dm_eth_phy_connect() changes and only keep the TSEC changes in v2. > > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> > --- > drivers/net/tsec.c | 6 +----- > net/mdio-uclass.c | 12 ++++++++++-- > 2 files changed, 11 insertions(+), 7 deletions(-) > Regards, Bin
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index ec4868937257..f801d020fb65 100644 --- a/drivers/net/tsec.c +++ b/drivers/net/tsec.c @@ -707,11 +707,7 @@ static int init_phy(struct tsec_private *priv) tsec_configure_serdes(priv); #if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_MDIO) - if (ofnode_valid(ofnode_find_subnode(dev_ofnode(priv->dev), - "fixed-link"))) - phydev = phy_connect(NULL, 0, priv->dev, priv->interface); - else - phydev = dm_eth_phy_connect(priv->dev); + phydev = dm_eth_phy_connect(priv->dev); #else phydev = phy_connect(priv->bus, priv->phyaddr, priv->dev, priv->interface); diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c index 697e5f838d94..766d4711cc23 100644 --- a/net/mdio-uclass.c +++ b/net/mdio-uclass.c @@ -177,9 +177,10 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, /* Connect to a PHY linked in eth DT node */ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev) { - const char *if_str; + ofnode node = dev_ofnode(ethdev), subnode; phy_interface_t interface; struct phy_device *phy; + const char *if_str; int i; if (!dev_has_ofnode(ethdev)) { @@ -200,7 +201,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev) if (interface == PHY_INTERFACE_MODE_NONE) dev_dbg(ethdev, "can't find interface mode, default to NONE\n"); - phy = dm_eth_connect_phy_handle(ethdev, interface); + subnode = ofnode_find_subnode(node, "fixed-link"); + if (ofnode_valid(subnode)) { + phy = phy_connect(NULL, 0, ethdev, interface); + if (phy) + phy->node = subnode; + } else { + phy = dm_eth_connect_phy_handle(ethdev, interface); + } if (!phy) return NULL;