Commit 6ac9de5f authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

net: bcmgenet: Register link_update callback for all MoCA PHYs

Commit 8d88c6eb ("net: bcmgenet: enable MoCA link state change
detection") added a fixed PHY link_update callback for MoCA PHYs when
registered using platform_data exclusively, this change is also
applicable to systems using Device Tree as their primary configuration
interface.

In order for this to work, move the link_update assignment into
bcmgenet_moca_phy_setup() where we know for sure that we are running on
a MoCA GENET instance, and do not override phydev->link since this is:

- properly taken care of by the PHY library by getting the link UP/DOWN
  interrupts
- this now runs everytime we call bcmgenet_open(), so we need to
  preserve whatever we detected before we went administratively DOWN and
  then UP
- we need to make sure that MoCA PHYs start with a link DOWN during
  probe in order to force a link transition to occur

To avoid a forward declaration, move bcmgenet_fixed_phy_link_update()
above its caller.
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7d5d3075
...@@ -163,6 +163,15 @@ void bcmgenet_mii_setup(struct net_device *dev) ...@@ -163,6 +163,15 @@ void bcmgenet_mii_setup(struct net_device *dev)
phy_print_status(phydev); phy_print_status(phydev);
} }
static int bcmgenet_fixed_phy_link_update(struct net_device *dev,
struct fixed_phy_status *status)
{
if (dev && dev->phydev && status)
status->link = dev->phydev->link;
return 0;
}
void bcmgenet_phy_power_set(struct net_device *dev, bool enable) void bcmgenet_phy_power_set(struct net_device *dev, bool enable)
{ {
struct bcmgenet_priv *priv = netdev_priv(dev); struct bcmgenet_priv *priv = netdev_priv(dev);
...@@ -215,6 +224,10 @@ static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv) ...@@ -215,6 +224,10 @@ static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)
reg = bcmgenet_sys_readl(priv, SYS_PORT_CTRL); reg = bcmgenet_sys_readl(priv, SYS_PORT_CTRL);
reg |= LED_ACT_SOURCE_MAC; reg |= LED_ACT_SOURCE_MAC;
bcmgenet_sys_writel(priv, reg, SYS_PORT_CTRL); bcmgenet_sys_writel(priv, reg, SYS_PORT_CTRL);
if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET)
fixed_phy_set_link_update(priv->phydev,
bcmgenet_fixed_phy_link_update);
} }
int bcmgenet_mii_config(struct net_device *dev) int bcmgenet_mii_config(struct net_device *dev)
...@@ -460,6 +473,7 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv) ...@@ -460,6 +473,7 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
struct device_node *dn = priv->pdev->dev.of_node; struct device_node *dn = priv->pdev->dev.of_node;
struct device *kdev = &priv->pdev->dev; struct device *kdev = &priv->pdev->dev;
const char *phy_mode_str = NULL; const char *phy_mode_str = NULL;
struct phy_device *phydev = NULL;
char *compat; char *compat;
int phy_mode; int phy_mode;
int ret; int ret;
...@@ -515,14 +529,12 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv) ...@@ -515,14 +529,12 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
priv->internal_phy = true; priv->internal_phy = true;
} }
return 0; /* Make sure we initialize MoCA PHYs with a link down */
} if (phy_mode == PHY_INTERFACE_MODE_MOCA) {
phydev = of_phy_find_device(dn);
static int bcmgenet_fixed_phy_link_update(struct net_device *dev, if (phydev)
struct fixed_phy_status *status) phydev->link = 0;
{ }
if (dev && dev->phydev && status)
status->link = dev->phydev->link;
return 0; return 0;
} }
...@@ -579,12 +591,9 @@ static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv) ...@@ -579,12 +591,9 @@ static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv)
return -ENODEV; return -ENODEV;
} }
if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET) { /* Make sure we initialize MoCA PHYs with a link down */
ret = fixed_phy_set_link_update( phydev->link = 0;
phydev, bcmgenet_fixed_phy_link_update);
if (!ret)
phydev->link = 0;
}
} }
priv->phydev = phydev; priv->phydev = phydev;
......
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