History

net: usb: asix: suspend embedded PHY if external is used

In case external PHY is used, we need to take care of embedded PHY. Since there are no methods to disable this PHY from the MAC side and keeping RMII reference clock, we need to suspend it. This patch will reduce electrical noise (PHY is continuing to send FLPs) and power consumption by 0,22W.

Oleksij Rempel committed 4 years ago

Commit 4d17d431 parent d5f3c812 files · +20 −1Browse files

Unified · Split

2 files
  1. drivers/net/usb/asix.h +3 −0
  2. drivers/net/usb/asix_devices.c +17 −1
drivers/net/usb/asix.h+3−0
@@ -158,6 +158,8 @@ · 157 unmodified lines
158158 #define AX_EEPROM_MAGIC 0xdeadbeef
159159 #define AX_EEPROM_LEN 0x200
160160
161+#define AX_EMBD_PHY_ADDR 0x10
162+
161163 /* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
162164 struct asix_data {
163165 u8 multi_filter[AX_MCAST_FILTER_SIZE];
@@ -183,6 +185,7 @@ struct asix_common_private { · 19 unmodified lines
183185 struct asix_rx_fixup_info rx_fixup_info;
184186 struct mii_bus *mdio;
185187 struct phy_device *phydev;
188+ struct phy_device *phydev_int;
186189 u16 phy_addr;
187190 bool embd_phy;
188191 u8 chipcode;
drivers/net/usb/asix_devices.c+17−1
@@ -679,6 +679,22 @@ static int ax88772_init_phy(struct usbnet *dev) · 678 unmodified lines
679679
680680 phy_attached_info(priv->phydev);
681681
682+ if (priv->embd_phy)
683+ return 0;
684+
685+ /* In case main PHY is not the embedded PHY and MAC is RMII clock
686+ * provider, we need to suspend embedded PHY by keeping PLL enabled
687+ * (AX_SWRESET_IPPD == 0).
688+ */
689+ priv->phydev_int = mdiobus_get_phy(priv->mdio, AX_EMBD_PHY_ADDR);
690+ if (!priv->phydev_int) {
691+ netdev_err(dev->net, "Could not find internal PHY\n");
692+ return -ENODEV;
693+ }
694+
695+ priv->phydev_int->mac_managed_pm = 1;
696+ phy_suspend(priv->phydev_int);
697+
682698 return 0;
683699 }
684700
@@ -734,7 +750,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) · 49 unmodified lines
734750 return ret;
735751
736752 priv->phy_addr = ret;
737− priv->embd_phy = ((priv->phy_addr & 0x1f) == 0x10);
753+ priv->embd_phy = ((priv->phy_addr & 0x1f) == AX_EMBD_PHY_ADDR);
738754
739755 ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1,
740756 &priv->chipcode, 0);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t