Lines Matching +full:need +full:- +full:phy +full:- +full:for +full:- +full:wake

1 // SPDX-License-Identifier: GPL-2.0+
3 * drivers/net/phy/broadcom.c
13 #include "bcm-phy-lib.h"
16 #include <linux/phy.h>
25 ((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)
28 ((phydev)->drv->phy_id & ~((phydev)->drv->phy_id_mask))
30 MODULE_DESCRIPTION("Broadcom PHY driver");
43 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54xx_phy_can_wakeup()
45 return phy_interrupt_is_valid(phydev) || priv->wake_irq >= 0; in bcm54xx_phy_can_wakeup()
52 /* handling PHY's internal RX clock delay */ in bcm54xx_config_clock_delay()
55 if (phydev->interface == PHY_INTERFACE_MODE_RGMII || in bcm54xx_config_clock_delay()
56 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { in bcm54xx_config_clock_delay()
57 /* Disable RGMII RXC-RXD skew */ in bcm54xx_config_clock_delay()
60 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in bcm54xx_config_clock_delay()
61 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { in bcm54xx_config_clock_delay()
62 /* Enable RGMII RXC-RXD skew */ in bcm54xx_config_clock_delay()
70 /* handling PHY's internal TX clock delay */ in bcm54xx_config_clock_delay()
72 if (phydev->interface == PHY_INTERFACE_MODE_RGMII || in bcm54xx_config_clock_delay()
73 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { in bcm54xx_config_clock_delay()
77 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in bcm54xx_config_clock_delay()
78 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { in bcm54xx_config_clock_delay()
95 if (phydev->dev_flags & PHY_BRCM_EN_MASTER_MODE) { in bcm54210e_config_init()
111 if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) { in bcm54612e_config_init()
129 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in bcm54616s_config_init()
130 phydev->interface != PHY_INTERFACE_MODE_1000BASEX) in bcm54616s_config_init()
145 /* Select 1000BASE-X register set (primary SerDes) */ in bcm54616s_config_init()
161 val |= phydev->interface == PHY_INTERFACE_MODE_SGMII ? in bcm54616s_config_init()
229 /* Clear bit 9 to fix a phy interop issue. */ in bcm54xx_phydsp_config()
235 if (phydev->drv->phy_id == PHY_ID_BCM50610) { in bcm54xx_phydsp_config()
269 /* Abort if we are using an untested phy. */ in bcm54xx_adjust_rxrefclk()
293 if (phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED) { in bcm54xx_adjust_rxrefclk()
302 if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) in bcm54xx_adjust_rxrefclk()
307 if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) { in bcm54xx_adjust_rxrefclk()
325 if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) in bcm54xx_adjust_rxrefclk()
336 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54xx_ptp_stop()
338 if (priv->ptp) in bcm54xx_ptp_stop()
339 bcm_ptp_stop(priv->ptp); in bcm54xx_ptp_stop()
344 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54xx_ptp_config_init()
346 if (priv->ptp) in bcm54xx_ptp_config_init()
374 (phydev->dev_flags & PHY_BRCM_CLEAR_RGMII_MODE)) in bcm54xx_config_init()
394 /* For BCM54810, we need to disable BroadR-Reach function */ in bcm54xx_config_init()
408 /* For non-SFP setups, encode link speed into LED1 and LED3 pair in bcm54xx_config_init()
411 * them for MULTICOLOR and encoding link/activity into them. in bcm54xx_config_init()
412 * Don't do this for devices on an SFP module, since some of these in bcm54xx_config_init()
429 /* Acknowledge any left over interrupt and charge the device for in bcm54xx_config_init()
430 * wake-up. in bcm54xx_config_init()
437 pm_wakeup_event(&phydev->mdio.dev, 0); in bcm54xx_config_init()
446 if (!(phydev->dev_flags & PHY_BRCM_IDDQ_SUSPEND)) in bcm54xx_iddq_set()
465 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54xx_set_wakeup_irq()
471 if (priv->wake_irq_enabled != state) { in bcm54xx_set_wakeup_irq()
473 ret = enable_irq_wake(priv->wake_irq); in bcm54xx_set_wakeup_irq()
475 ret = disable_irq_wake(priv->wake_irq); in bcm54xx_set_wakeup_irq()
476 priv->wake_irq_enabled = state; in bcm54xx_set_wakeup_irq()
488 /* Acknowledge any Wake-on-LAN interrupt prior to suspend */ in bcm54xx_suspend()
493 if (phydev->wol_enabled) in bcm54xx_suspend()
496 /* We cannot use a read/modify/write here otherwise the PHY gets into in bcm54xx_suspend()
511 if (phydev->wol_enabled) { in bcm54xx_resume()
528 /* Upon exiting power down, the PHY remains in an internal reset state in bcm54xx_resume()
529 * for 40us in bcm54xx_resume()
536 if (phydev->dev_flags & PHY_BRCM_IDDQ_SUSPEND) { in bcm54xx_resume()
547 return -EOPNOTSUPP; in bcm54810_read_mmd()
553 return -EOPNOTSUPP; in bcm54810_write_mmd()
560 /* Disable BroadR-Reach function. */ in bcm54811_config_init()
571 if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) { in bcm54811_config_init()
584 struct device_node *np = phydev->mdio.dev.of_node; in bcm5481_config_aneg()
593 if (of_property_read_bool(np, "enet-phy-lane-swap")) { in bcm5481_config_aneg()
594 /* Lane Swap - Undocumented register...magic! */ in bcm5481_config_aneg()
613 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in bcm54616s_probe()
615 return -ENOMEM; in bcm54616s_probe()
617 phydev->priv = priv; in bcm54616s_probe()
623 /* The PHY is strapped in RGMII-fiber mode when INTERF_SEL[1:0] in bcm54616s_probe()
624 * is 01b, and the link between PHY and its link partner can be in bcm54616s_probe()
625 * either 1000Base-X or 100Base-FX. in bcm54616s_probe()
626 * RGMII-1000Base-X is properly supported, but RGMII-100Base-FX in bcm54616s_probe()
634 /* Bit 0 of the SerDes 100-FX Control register, when set in bcm54616s_probe()
635 * to 1, sets the MII/RGMII -> 100BASE-FX configuration. in bcm54616s_probe()
636 * When this bit is set to 0, it sets the GMII/RGMII -> in bcm54616s_probe()
637 * 1000BASE-X configuration. in bcm54616s_probe()
640 priv->mode_1000bx_en = true; in bcm54616s_probe()
642 phydev->port = PORT_FIBRE; in bcm54616s_probe()
650 struct bcm54616s_phy_priv *priv = phydev->priv; in bcm54616s_config_aneg()
654 if (priv->mode_1000bx_en) in bcm54616s_config_aneg()
667 struct bcm54616s_phy_priv *priv = phydev->priv; in bcm54616s_read_status()
670 if (priv->mode_1000bx_en) in bcm54616s_read_status()
682 /* Reset the PHY to bring it to a known state. */ in brcm_fet_config_init()
687 /* The datasheet indicates the PHY needs up to 1us to complete a reset, in brcm_fet_config_init()
692 /* The PHY requires 65 MDC clock cycles to complete a write operation in brcm_fet_config_init()
695 * We ignore -EIO here as the MDIO controller (e.g.: mdio-bcm-unimac) in brcm_fet_config_init()
696 * may flag the lack of turn-around as a read failure. This is in brcm_fet_config_init()
704 if (err < 0 && err != -EIO) in brcm_fet_config_init()
753 if (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE) { in brcm_fet_config_init()
788 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in brcm_fet_config_intr()
829 /* We cannot use a read/modify/write here otherwise the PHY continues in brcm_fet_suspend()
863 /* We cannot wake-up if we do not have a dedicated PHY interrupt line in bcm54xx_phy_get_wol()
864 * or an out of band GPIO descriptor for wake-up. Zeroing in bcm54xx_phy_get_wol()
865 * wol->supported allows the caller (MAC driver) to play through and in bcm54xx_phy_get_wol()
866 * offer its own Wake-on-LAN scheme if available. in bcm54xx_phy_get_wol()
869 wol->supported = 0; in bcm54xx_phy_get_wol()
881 /* We cannot wake-up if we do not have a dedicated PHY interrupt line in bcm54xx_phy_set_wol()
882 * or an out of band GPIO descriptor for wake-up. Returning -EOPNOTSUPP in bcm54xx_phy_set_wol()
884 * Wake-on-LAN scheme if available. in bcm54xx_phy_set_wol()
887 return -EOPNOTSUPP; in bcm54xx_phy_set_wol()
902 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in bcm54xx_phy_probe()
904 return -ENOMEM; in bcm54xx_phy_probe()
906 priv->wake_irq = -ENXIO; in bcm54xx_phy_probe()
908 phydev->priv = priv; in bcm54xx_phy_probe()
910 priv->stats = devm_kcalloc(&phydev->mdio.dev, in bcm54xx_phy_probe()
913 if (!priv->stats) in bcm54xx_phy_probe()
914 return -ENOMEM; in bcm54xx_phy_probe()
916 priv->ptp = bcm_ptp_probe(phydev); in bcm54xx_phy_probe()
917 if (IS_ERR(priv->ptp)) in bcm54xx_phy_probe()
918 return PTR_ERR(priv->ptp); in bcm54xx_phy_probe()
921 * whether the GPIO descriptor exists or not to advertise Wake-on-LAN in bcm54xx_phy_probe()
924 wakeup_gpio = devm_gpiod_get(&phydev->mdio.dev, "wakeup", GPIOD_IN); in bcm54xx_phy_probe()
925 if (PTR_ERR(wakeup_gpio) == -EPROBE_DEFER) in bcm54xx_phy_probe()
929 priv->wake_irq = gpiod_to_irq(wakeup_gpio); in bcm54xx_phy_probe()
932 * in order for the interrupt descriptor to be fully set-up. in bcm54xx_phy_probe()
934 ret = devm_request_irq(&phydev->mdio.dev, priv->wake_irq, in bcm54xx_phy_probe()
937 dev_name(&phydev->mdio.dev), phydev); in bcm54xx_phy_probe()
942 /* If we do not have a main interrupt or a side-band wake-up interrupt, in bcm54xx_phy_probe()
943 * then the device cannot be marked as wake-up capable. in bcm54xx_phy_probe()
948 return device_init_wakeup(&phydev->mdio.dev, true); in bcm54xx_phy_probe()
954 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54xx_get_stats()
956 bcm_phy_get_stats(phydev, priv->stats, stats, data); in bcm54xx_get_stats()
965 if (phydev->state != PHY_RUNNING) in bcm54xx_link_change_notify()
968 /* Don't change the DAC wake settings if auto power down in bcm54xx_link_change_notify()
971 if (!(phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) in bcm54xx_link_change_notify()
978 /* Enable/disable 10BaseT auto and forced early DAC wake depending in bcm54xx_link_change_notify()
980 * for 10Mbits/sec. in bcm54xx_link_change_notify()
982 if (phydev->speed == SPEED_10) in bcm54xx_link_change_notify()