Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: bcmgenet: Register link_update callback for all MoCA PHYs

Commit 8d88c6ebb34c ("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: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Florian Fainelli and committed by
David S. Miller
6ac9de5f 7d5d3075

+23 -14
+23 -14
drivers/net/ethernet/broadcom/genet/bcmmii.c
··· 163 163 phy_print_status(phydev); 164 164 } 165 165 166 + static int bcmgenet_fixed_phy_link_update(struct net_device *dev, 167 + struct fixed_phy_status *status) 168 + { 169 + if (dev && dev->phydev && status) 170 + status->link = dev->phydev->link; 171 + 172 + return 0; 173 + } 174 + 166 175 void bcmgenet_phy_power_set(struct net_device *dev, bool enable) 167 176 { 168 177 struct bcmgenet_priv *priv = netdev_priv(dev); ··· 224 215 reg = bcmgenet_sys_readl(priv, SYS_PORT_CTRL); 225 216 reg |= LED_ACT_SOURCE_MAC; 226 217 bcmgenet_sys_writel(priv, reg, SYS_PORT_CTRL); 218 + 219 + if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET) 220 + fixed_phy_set_link_update(priv->phydev, 221 + bcmgenet_fixed_phy_link_update); 227 222 } 228 223 229 224 int bcmgenet_mii_config(struct net_device *dev) ··· 473 460 struct device_node *dn = priv->pdev->dev.of_node; 474 461 struct device *kdev = &priv->pdev->dev; 475 462 const char *phy_mode_str = NULL; 463 + struct phy_device *phydev = NULL; 476 464 char *compat; 477 465 int phy_mode; 478 466 int ret; ··· 529 515 priv->internal_phy = true; 530 516 } 531 517 532 - return 0; 533 - } 534 - 535 - static int bcmgenet_fixed_phy_link_update(struct net_device *dev, 536 - struct fixed_phy_status *status) 537 - { 538 - if (dev && dev->phydev && status) 539 - status->link = dev->phydev->link; 518 + /* Make sure we initialize MoCA PHYs with a link down */ 519 + if (phy_mode == PHY_INTERFACE_MODE_MOCA) { 520 + phydev = of_phy_find_device(dn); 521 + if (phydev) 522 + phydev->link = 0; 523 + } 540 524 541 525 return 0; 542 526 } ··· 591 579 return -ENODEV; 592 580 } 593 581 594 - if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET) { 595 - ret = fixed_phy_set_link_update( 596 - phydev, bcmgenet_fixed_phy_link_update); 597 - if (!ret) 598 - phydev->link = 0; 599 - } 582 + /* Make sure we initialize MoCA PHYs with a link down */ 583 + phydev->link = 0; 584 + 600 585 } 601 586 602 587 priv->phydev = phydev;