summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAlex Marginean <alexandru.marginean@nxp.com>2019-11-25 17:15:13 +0200
committerJoe Hershberger <joe.hershberger@ni.com>2019-12-09 09:47:43 -0600
commit17bd7eae72fed240ff806c14b53fd6ff281ee311 (patch)
tree643ac0ba541439d3f03838613ad4fc74f8c550e0 /drivers
parent2f6245594e1f11db00efcaa5ac122918f019e0b4 (diff)
drivers: net: fsl_enetc: use the new MDIO DM helper functions
Uses the new dm_eth_phy_connect helper to connect to the PHY to simplify the code. Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/fsl_enetc.c53
-rw-r--r--drivers/net/fsl_enetc.h1
2 files changed, 10 insertions, 44 deletions
diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index a7740deb6f..c94ba240f8 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -205,57 +205,20 @@ static void enetc_start_pcs(struct udevice *dev)
}
/* Configure the actual/external ethernet PHY, if one is found */
-static void enetc_start_phy(struct udevice *dev)
+static void enetc_config_phy(struct udevice *dev)
{
struct enetc_priv *priv = dev_get_priv(dev);
- struct udevice *miidev;
- struct phy_device *phy;
- u32 phandle, phy_id;
- ofnode phy_node;
int supported;
- if (!ofnode_valid(dev->node)) {
- enetc_dbg(dev, "no enetc ofnode found, skipping PHY set-up\n");
- return;
- }
-
- if (ofnode_read_u32(dev->node, "phy-handle", &phandle)) {
- enetc_dbg(dev, "phy-handle not found, skipping PHY set-up\n");
- return;
- }
-
- phy_node = ofnode_get_by_phandle(phandle);
- if (!ofnode_valid(phy_node)) {
- enetc_dbg(dev, "invalid phy node, skipping PHY set-up\n");
- return;
- }
- enetc_dbg(dev, "phy node: %s\n", ofnode_get_name(phy_node));
+ priv->phy = dm_eth_phy_connect(dev);
- if (ofnode_read_u32(phy_node, "reg", &phy_id)) {
- enetc_dbg(dev,
- "missing reg in PHY node, skipping PHY set-up\n");
+ if (!priv->phy)
return;
- }
-
- if (uclass_get_device_by_ofnode(UCLASS_MDIO,
- ofnode_get_parent(phy_node),
- &miidev)) {
- enetc_dbg(dev, "can't find MDIO bus for node %s\n",
- ofnode_get_name(ofnode_get_parent(phy_node)));
- return;
- }
-
- phy = dm_mdio_phy_connect(miidev, phy_id, dev, priv->if_type);
- if (!phy) {
- enetc_dbg(dev, "dm_mdio_phy_connect returned null\n");
- return;
- }
supported = GENMASK(6, 0); /* speeds up to 1G & AN */
- phy->advertising = phy->supported & supported;
- phy->node = phy_node;
- phy_config(phy);
- phy_startup(phy);
+ priv->phy->advertising = priv->phy->supported & supported;
+
+ phy_config(priv->phy);
}
/*
@@ -470,7 +433,9 @@ static int enetc_start(struct udevice *dev)
enetc_setup_rx_bdr(dev);
enetc_start_pcs(dev);
- enetc_start_phy(dev);
+ enetc_config_phy(dev);
+ if (priv->phy)
+ phy_startup(priv->phy);
return 0;
}
diff --git a/drivers/net/fsl_enetc.h b/drivers/net/fsl_enetc.h
index 0bb4cdff47..9a36cdad80 100644
--- a/drivers/net/fsl_enetc.h
+++ b/drivers/net/fsl_enetc.h
@@ -154,6 +154,7 @@ struct enetc_priv {
int if_type;
struct mii_dev imdio;
+ struct phy_device *phy;
};
/* register accessors */