Commit 279d8ff5 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 44d80732 6fc21a6e
......@@ -251,7 +251,6 @@ static void intel_speed_mode_2500(struct net_device *ndev, void *intel_data)
priv->plat->mdio_bus_data->xpcs_an_inband = false;
} else {
priv->plat->max_speed = 1000;
priv->plat->mdio_bus_data->xpcs_an_inband = true;
}
}
......
......@@ -1135,6 +1135,7 @@ static int stmmac_init_phy(struct net_device *dev)
{
struct stmmac_priv *priv = netdev_priv(dev);
struct fwnode_handle *fwnode;
bool phy_needed;
int ret;
fwnode = of_fwnode_handle(priv->plat->phylink_node);
......@@ -1144,10 +1145,11 @@ static int stmmac_init_phy(struct net_device *dev)
if (fwnode)
ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0);
phy_needed = phylink_expects_phy(priv->phylink);
/* Some DT bindings do not set-up the PHY handle. Let's try to
* manually parse it
*/
if (!fwnode || ret) {
if (!fwnode || phy_needed || ret) {
int addr = priv->plat->phy_addr;
struct phy_device *phydev;
......
......@@ -1586,6 +1586,25 @@ void phylink_destroy(struct phylink *pl)
}
EXPORT_SYMBOL_GPL(phylink_destroy);
/**
* phylink_expects_phy() - Determine if phylink expects a phy to be attached
* @pl: a pointer to a &struct phylink returned from phylink_create()
*
* When using fixed-link mode, or in-band mode with 1000base-X or 2500base-X,
* no PHY is needed.
*
* Returns true if phylink will be expecting a PHY.
*/
bool phylink_expects_phy(struct phylink *pl)
{
if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
(pl->cfg_link_an_mode == MLO_AN_INBAND &&
phy_interface_mode_is_8023z(pl->link_config.interface)))
return false;
return true;
}
EXPORT_SYMBOL_GPL(phylink_expects_phy);
static void phylink_phy_change(struct phy_device *phydev, bool up)
{
struct phylink *pl = phydev->phylink;
......
......@@ -574,6 +574,7 @@ struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *,
phy_interface_t iface,
const struct phylink_mac_ops *mac_ops);
void phylink_destroy(struct phylink *);
bool phylink_expects_phy(struct phylink *pl);
int phylink_connect_phy(struct phylink *, struct phy_device *);
int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment