Lines Matching +full:need +full:- +full:phy +full:- +full:for +full:- +full:wake
1 // SPDX-License-Identifier: GPL-2.0+
3 * drivers/net/phy/smsc.c
5 * Driver for SMSC PHYs
11 * Support added for SMSC LAN8187 and LAN8700 by steve.glendinning@shawell.net
21 #include <linux/phy.h>
27 /* Vendor-specific PHY Definitions */
70 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in smsc_phy_config_intr()
91 struct smsc_phy_priv *priv = phydev->priv; in smsc_phy_config_edpd()
93 if (priv->edpd_enable) in smsc_phy_config_edpd()
107 if (irq_status != -ENODEV) in smsc_phy_handle_interrupt()
124 struct smsc_phy_priv *priv = phydev->priv; in smsc_phy_config_init()
130 if (!priv->edpd_mode_set_by_user && phydev->irq != PHY_POLL) in smsc_phy_config_init()
131 priv->edpd_enable = false; in smsc_phy_config_init()
143 /* If the SMSC PHY is in power down mode, then set it in smsc_phy_reset()
152 /* reset the phy */ in smsc_phy_reset()
161 switch (phydev->mdix_ctrl) { in lan87xx_config_aneg()
186 phydev->mdix = phydev->mdix_ctrl; in lan87xx_config_aneg()
192 if (phydev->phy_id == 0x0007c0f0) { /* LAN9500A or LAN9505A */ in lan95xx_config_aneg_ext()
205 * The LAN87xx suffers from rare absence of the ENERGYON-bit when Ethernet cable
206 * plugs in while LAN87xx is in Energy Detect Power-Down mode. This leads to
208 * This workaround disables Energy Detect Power-Down mode and waiting for
210 * The Energy Detect Power-Down mode is enabled again in the end of procedure to
212 * The workaround is only applicable to poll mode. Energy Detect Power-Down may
217 struct smsc_phy_priv *priv = phydev->priv; in lan87xx_read_status()
224 if (!phydev->link && priv && priv->edpd_enable && in lan87xx_read_status()
225 priv->edpd_max_wait_ms) { in lan87xx_read_status()
226 unsigned int max_wait = priv->edpd_max_wait_ms * 1000; in lan87xx_read_status()
229 /* Disable EDPD to wake up PHY */ in lan87xx_read_status()
249 /* Re-enable EDPD */ in lan87xx_read_status()
269 /* Setup LED2/nINT/nPME pin to function as nPME. May need user option in lan874x_phy_config_init()
275 * MII_LAN874X_PHY_WOL_MPR, and MII_LAN874X_PHY_WOL_BCAST_FR need to in lan874x_phy_config_init()
276 * be cleared to de-assert PME signal after a WoL event happens, but in lan874x_phy_config_init()
297 struct smsc_phy_priv *priv = phydev->priv; in lan874x_get_wol()
300 wol->supported = (WAKE_UCAST | WAKE_BCAST | WAKE_MAGIC | in lan874x_get_wol()
302 wol->wolopts = 0; in lan874x_get_wol()
309 wol->wolopts |= WAKE_UCAST; in lan874x_get_wol()
312 wol->wolopts |= WAKE_BCAST; in lan874x_get_wol()
315 wol->wolopts |= WAKE_MAGIC; in lan874x_get_wol()
318 if (priv->wol_arp) in lan874x_get_wol()
319 wol->wolopts |= WAKE_ARP; in lan874x_get_wol()
321 wol->wolopts |= WAKE_MCAST; in lan874x_get_wol()
338 * are 8 registers to program the 16-bit masks, where each bit means in lan874x_chk_wol_pattern()
340 * CRC16 calculation for hardware comparison. This helper function in lan874x_chk_wol_pattern()
349 for (j = 0; j < 16; j++, i++, len--) { in lan874x_chk_wol_pattern()
393 reg--; in lan874x_set_wol_pattern()
395 masklen -= 16; in lan874x_set_wol_pattern()
401 reg--; in lan874x_set_wol_pattern()
409 struct net_device *ndev = phydev->attached_dev; in lan874x_set_wol()
410 struct smsc_phy_priv *priv = phydev->priv; in lan874x_set_wol()
417 if ((wol->wolopts & (WAKE_ARP | WAKE_MCAST)) == in lan874x_set_wol()
421 return -EOPNOTSUPP; in lan874x_set_wol()
430 if (wol->wolopts & WAKE_UCAST) in lan874x_set_wol()
435 if (wol->wolopts & WAKE_BCAST) in lan874x_set_wol()
440 if (wol->wolopts & WAKE_MAGIC) in lan874x_set_wol()
445 /* Need to use pattern matching */ in lan874x_set_wol()
446 if (wol->wolopts & (WAKE_ARP | WAKE_MCAST)) in lan874x_set_wol()
451 if (wol->wolopts & WAKE_ARP) { in lan874x_set_wol()
460 /* Need to match broadcast destination address and provided in lan874x_set_wol()
468 priv->wol_arp = true; in lan874x_set_wol()
471 if (wol->wolopts & WAKE_MCAST) { in lan874x_set_wol()
472 /* Need to match multicast destination address. */ in lan874x_set_wol()
477 priv->wol_arp = false; in lan874x_set_wol()
480 if (wol->wolopts & (WAKE_MAGIC | WAKE_UCAST)) { in lan874x_set_wol()
481 const u8 *mac = (const u8 *)ndev->dev_addr; in lan874x_set_wol()
485 for (i = 0; i < 6; i += 2, reg--) { in lan874x_set_wol()
510 for (i = 0; i < ARRAY_SIZE(smsc_hw_stats); i++) in smsc_get_strings()
534 for (i = 0; i < ARRAY_SIZE(smsc_hw_stats); i++) in smsc_get_stats()
540 struct smsc_phy_priv *priv = phydev->priv; in smsc_phy_get_edpd()
543 return -EOPNOTSUPP; in smsc_phy_get_edpd()
545 if (!priv->edpd_enable) in smsc_phy_get_edpd()
547 else if (!priv->edpd_max_wait_ms) in smsc_phy_get_edpd()
550 *edpd = PHY_STATE_MACH_MS + priv->edpd_max_wait_ms; in smsc_phy_get_edpd()
557 struct smsc_phy_priv *priv = phydev->priv; in smsc_phy_set_edpd()
560 return -EOPNOTSUPP; in smsc_phy_set_edpd()
564 priv->edpd_enable = false; in smsc_phy_set_edpd()
567 priv->edpd_enable = true; in smsc_phy_set_edpd()
568 priv->edpd_max_wait_ms = 0; in smsc_phy_set_edpd()
574 if (phydev->irq != PHY_POLL) in smsc_phy_set_edpd()
575 return -EOPNOTSUPP; in smsc_phy_set_edpd()
577 return -EINVAL; in smsc_phy_set_edpd()
578 priv->edpd_enable = true; in smsc_phy_set_edpd()
579 priv->edpd_max_wait_ms = edpd - PHY_STATE_MACH_MS; in smsc_phy_set_edpd()
582 priv->edpd_mode_set_by_user = true; in smsc_phy_set_edpd()
590 switch (tuna->id) { in smsc_phy_get_tunable()
594 return -EOPNOTSUPP; in smsc_phy_get_tunable()
602 switch (tuna->id) { in smsc_phy_set_tunable()
606 return -EOPNOTSUPP; in smsc_phy_set_tunable()
613 struct device *dev = &phydev->mdio.dev; in smsc_phy_probe()
619 return -ENOMEM; in smsc_phy_probe()
621 priv->edpd_enable = true; in smsc_phy_probe()
622 priv->edpd_max_wait_ms = EDPD_MAX_WAIT_DFLT_MS; in smsc_phy_probe()
624 if (device_property_present(dev, "smsc,disable-energy-detect")) in smsc_phy_probe()
625 priv->edpd_enable = false; in smsc_phy_probe()
627 phydev->priv = priv; in smsc_phy_probe()
684 /* This covers internal PHY (phy_id: 0x0007C0C3) for
718 .name = "SMSC LAN911x Internal PHY",
731 /* This covers internal PHY (phy_id: 0x0007C0F0) for
836 MODULE_DESCRIPTION("SMSC PHY driver");