Skip to content

Commit 4a2c721

Browse files
oleremdavem330
authored andcommitted
net: usb: asix: ax88772: manage PHY PM from MAC
Take over PHY power management, otherwise PHY framework will try to access ASIX MDIO bus before MAC resume was completed. Fixes: e532a09 ("net: usb: asix: ax88772: add phylib support") Signed-off-by: Oleksij Rempel <[email protected]> Reported-by: Marek Szyprowski <[email protected]> Reported-by: Jon Hunter <[email protected]> Suggested-by: Heiner Kallweit <[email protected]> Tested-by: Jon Hunter <[email protected]> Tested-by: Marek Szyprowski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d41783b commit 4a2c721

File tree

1 file changed

+12
-31
lines changed

1 file changed

+12
-31
lines changed

drivers/net/usb/asix_devices.c

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -598,21 +598,16 @@ static void ax88772_suspend(struct usbnet *dev)
598598
struct asix_common_private *priv = dev->driver_priv;
599599
u16 medium;
600600

601+
if (netif_running(dev->net))
602+
phy_stop(priv->phydev);
603+
601604
/* Stop MAC operation */
602605
medium = asix_read_medium_status(dev, 1);
603606
medium &= ~AX_MEDIUM_RE;
604607
asix_write_medium_mode(dev, medium, 1);
605608

606609
netdev_dbg(dev->net, "ax88772_suspend: medium=0x%04x\n",
607610
asix_read_medium_status(dev, 1));
608-
609-
/* Preserve BMCR for restoring */
610-
priv->presvd_phy_bmcr =
611-
asix_mdio_read_nopm(dev->net, dev->mii.phy_id, MII_BMCR);
612-
613-
/* Preserve ANAR for restoring */
614-
priv->presvd_phy_advertise =
615-
asix_mdio_read_nopm(dev->net, dev->mii.phy_id, MII_ADVERTISE);
616611
}
617612

618613
static int asix_suspend(struct usb_interface *intf, pm_message_t message)
@@ -626,47 +621,31 @@ static int asix_suspend(struct usb_interface *intf, pm_message_t message)
626621
return usbnet_suspend(intf, message);
627622
}
628623

629-
static void ax88772_restore_phy(struct usbnet *dev)
630-
{
631-
struct asix_common_private *priv = dev->driver_priv;
632-
633-
if (priv->presvd_phy_advertise) {
634-
/* Restore Advertisement control reg */
635-
asix_mdio_write_nopm(dev->net, dev->mii.phy_id, MII_ADVERTISE,
636-
priv->presvd_phy_advertise);
637-
638-
/* Restore BMCR */
639-
if (priv->presvd_phy_bmcr & BMCR_ANENABLE)
640-
priv->presvd_phy_bmcr |= BMCR_ANRESTART;
641-
642-
asix_mdio_write_nopm(dev->net, dev->mii.phy_id, MII_BMCR,
643-
priv->presvd_phy_bmcr);
644-
645-
priv->presvd_phy_advertise = 0;
646-
priv->presvd_phy_bmcr = 0;
647-
}
648-
}
649-
650624
static void ax88772_resume(struct usbnet *dev)
651625
{
626+
struct asix_common_private *priv = dev->driver_priv;
652627
int i;
653628

654629
for (i = 0; i < 3; i++)
655630
if (!ax88772_hw_reset(dev, 1))
656631
break;
657-
ax88772_restore_phy(dev);
632+
633+
if (netif_running(dev->net))
634+
phy_start(priv->phydev);
658635
}
659636

660637
static void ax88772a_resume(struct usbnet *dev)
661638
{
639+
struct asix_common_private *priv = dev->driver_priv;
662640
int i;
663641

664642
for (i = 0; i < 3; i++) {
665643
if (!ax88772a_hw_reset(dev, 1))
666644
break;
667645
}
668646

669-
ax88772_restore_phy(dev);
647+
if (netif_running(dev->net))
648+
phy_start(priv->phydev);
670649
}
671650

672651
static int asix_resume(struct usb_interface *intf)
@@ -722,6 +701,8 @@ static int ax88772_init_phy(struct usbnet *dev)
722701
return ret;
723702
}
724703

704+
priv->phydev->mac_managed_pm = 1;
705+
725706
phy_attached_info(priv->phydev);
726707

727708
return 0;

0 commit comments

Comments
 (0)