From: Vladimir Oltean <olteanv@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 3/4] net: mdio: teach dm_eth_phy_connect to connect to fixed PHY
Date: Wed, 17 Feb 2021 00:48:03 +0200 [thread overview]
Message-ID: <20210216224804.3355044-4-olteanv@gmail.com> (raw)
In-Reply-To: <20210216224804.3355044-1-olteanv@gmail.com>
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.
In fact we already have an in-tree driver that can make use of this
refactoring: the Freescale TSEC driver.
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(-)
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;
--
2.25.1
next prev parent reply other threads:[~2021-02-16 22:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-16 22:48 [PATCH 0/4] Sandbox driver for DSA uclass Vladimir Oltean
2021-02-16 22:48 ` [PATCH 1/4] net: phy: fixed: be compatible with live OF tree Vladimir Oltean
2021-03-12 6:34 ` Bin Meng
2021-03-12 7:53 ` Bin Meng
2021-02-16 22:48 ` [PATCH 2/4] net: phy: drop #ifdef CONFIG_DM_ETH around phy_connect_fixed Vladimir Oltean
2021-03-11 9:37 ` Bin Meng
2021-02-16 22:48 ` Vladimir Oltean [this message]
2021-03-12 3:29 ` [PATCH 3/4] net: mdio: teach dm_eth_phy_connect to connect to fixed PHY Bin Meng
2021-02-16 22:48 ` [PATCH 4/4] sandbox: add a DSA sandbox driver and unit test Vladimir Oltean
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=20210216224804.3355044-4-olteanv@gmail.com \
--to=olteanv@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox