Skip to content

Commit 279d8ff

Browse files
committed
Merge branch 'phy-handle-fixes'
Michael Sit Wei Hong says: ==================== Fix PHY handle no longer parsing After the fixed link support was introduced, it is observed that PHY no longer attach to the MAC properly. So we introduce a helper function to determine if the MAC should expect to connect to a PHY and proceed accordingly. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 44d8073 + 6fc21a6 commit 279d8ff

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ static void intel_speed_mode_2500(struct net_device *ndev, void *intel_data)
251251
priv->plat->mdio_bus_data->xpcs_an_inband = false;
252252
} else {
253253
priv->plat->max_speed = 1000;
254-
priv->plat->mdio_bus_data->xpcs_an_inband = true;
255254
}
256255
}
257256

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ static int stmmac_init_phy(struct net_device *dev)
11351135
{
11361136
struct stmmac_priv *priv = netdev_priv(dev);
11371137
struct fwnode_handle *fwnode;
1138+
bool phy_needed;
11381139
int ret;
11391140

11401141
fwnode = of_fwnode_handle(priv->plat->phylink_node);
@@ -1144,10 +1145,11 @@ static int stmmac_init_phy(struct net_device *dev)
11441145
if (fwnode)
11451146
ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0);
11461147

1148+
phy_needed = phylink_expects_phy(priv->phylink);
11471149
/* Some DT bindings do not set-up the PHY handle. Let's try to
11481150
* manually parse it
11491151
*/
1150-
if (!fwnode || ret) {
1152+
if (!fwnode || phy_needed || ret) {
11511153
int addr = priv->plat->phy_addr;
11521154
struct phy_device *phydev;
11531155

drivers/net/phy/phylink.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,25 @@ void phylink_destroy(struct phylink *pl)
15861586
}
15871587
EXPORT_SYMBOL_GPL(phylink_destroy);
15881588

1589+
/**
1590+
* phylink_expects_phy() - Determine if phylink expects a phy to be attached
1591+
* @pl: a pointer to a &struct phylink returned from phylink_create()
1592+
*
1593+
* When using fixed-link mode, or in-band mode with 1000base-X or 2500base-X,
1594+
* no PHY is needed.
1595+
*
1596+
* Returns true if phylink will be expecting a PHY.
1597+
*/
1598+
bool phylink_expects_phy(struct phylink *pl)
1599+
{
1600+
if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
1601+
(pl->cfg_link_an_mode == MLO_AN_INBAND &&
1602+
phy_interface_mode_is_8023z(pl->link_config.interface)))
1603+
return false;
1604+
return true;
1605+
}
1606+
EXPORT_SYMBOL_GPL(phylink_expects_phy);
1607+
15891608
static void phylink_phy_change(struct phy_device *phydev, bool up)
15901609
{
15911610
struct phylink *pl = phydev->phylink;

include/linux/phylink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *,
574574
phy_interface_t iface,
575575
const struct phylink_mac_ops *mac_ops);
576576
void phylink_destroy(struct phylink *);
577+
bool phylink_expects_phy(struct phylink *pl);
577578

578579
int phylink_connect_phy(struct phylink *, struct phy_device *);
579580
int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);

0 commit comments

Comments
 (0)