mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-09 11:30:02 +00:00
net: stmmac: check fwnode for phy device before scanning for phy
Some DT devices already have phy device configured in the DT/ACPI.
Current implementation scans for a phy unconditionally even though
there is a phy listed in the DT/ACPI and already attached.
We should check the fwnode if there is any phy device listed in
fwnode and decide whether to scan for a phy to attach to.
Fixes: fe2cfbc968 ("net: stmmac: check if MAC needs to attach to a PHY")
Reported-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/lkml/20230403212434.296975-1-martin.blumenstingl@googlemail.com/
Tested-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Shahab Vahedi <shahab@synopsys.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Suggested-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
Link: https://lore.kernel.org/r/20230406024541.3556305-1-michael.wei.hong.sit@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
24e3fce00c
commit
8fbc10b995
@@ -1134,22 +1134,26 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
|
|||||||
static int stmmac_init_phy(struct net_device *dev)
|
static int stmmac_init_phy(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct stmmac_priv *priv = netdev_priv(dev);
|
struct stmmac_priv *priv = netdev_priv(dev);
|
||||||
|
struct fwnode_handle *phy_fwnode;
|
||||||
struct fwnode_handle *fwnode;
|
struct fwnode_handle *fwnode;
|
||||||
bool phy_needed;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!phylink_expects_phy(priv->phylink))
|
||||||
|
return 0;
|
||||||
|
|
||||||
fwnode = of_fwnode_handle(priv->plat->phylink_node);
|
fwnode = of_fwnode_handle(priv->plat->phylink_node);
|
||||||
if (!fwnode)
|
if (!fwnode)
|
||||||
fwnode = dev_fwnode(priv->device);
|
fwnode = dev_fwnode(priv->device);
|
||||||
|
|
||||||
if (fwnode)
|
if (fwnode)
|
||||||
ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0);
|
phy_fwnode = fwnode_get_phy_node(fwnode);
|
||||||
|
else
|
||||||
|
phy_fwnode = NULL;
|
||||||
|
|
||||||
phy_needed = phylink_expects_phy(priv->phylink);
|
|
||||||
/* Some DT bindings do not set-up the PHY handle. Let's try to
|
/* Some DT bindings do not set-up the PHY handle. Let's try to
|
||||||
* manually parse it
|
* manually parse it
|
||||||
*/
|
*/
|
||||||
if (!fwnode || phy_needed || ret) {
|
if (!phy_fwnode || IS_ERR(phy_fwnode)) {
|
||||||
int addr = priv->plat->phy_addr;
|
int addr = priv->plat->phy_addr;
|
||||||
struct phy_device *phydev;
|
struct phy_device *phydev;
|
||||||
|
|
||||||
@@ -1165,6 +1169,9 @@ static int stmmac_init_phy(struct net_device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = phylink_connect_phy(priv->phylink, phydev);
|
ret = phylink_connect_phy(priv->phylink, phydev);
|
||||||
|
} else {
|
||||||
|
fwnode_handle_put(phy_fwnode);
|
||||||
|
ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!priv->plat->pmt) {
|
if (!priv->plat->pmt) {
|
||||||
|
|||||||
Reference in New Issue
Block a user