Lines Matching full:phydev

26 #define BRCM_PHY_MODEL(phydev) \  argument
27 ((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)
29 #define BRCM_PHY_REV(phydev) \ argument
30 ((phydev)->drv->phy_id & ~((phydev)->drv->phy_id_mask))
66 static bool bcm54xx_phy_can_wakeup(struct phy_device *phydev) in bcm54xx_phy_can_wakeup() argument
68 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54xx_phy_can_wakeup()
70 return phy_interrupt_is_valid(phydev) || priv->wake_irq >= 0; in bcm54xx_phy_can_wakeup()
73 static int bcm54xx_config_clock_delay(struct phy_device *phydev) in bcm54xx_config_clock_delay() argument
78 val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC); in bcm54xx_config_clock_delay()
80 if (phydev->interface == PHY_INTERFACE_MODE_RGMII || in bcm54xx_config_clock_delay()
81 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { in bcm54xx_config_clock_delay()
85 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in bcm54xx_config_clock_delay()
86 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { in bcm54xx_config_clock_delay()
90 rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC, in bcm54xx_config_clock_delay()
96 val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL); in bcm54xx_config_clock_delay()
97 if (phydev->interface == PHY_INTERFACE_MODE_RGMII || in bcm54xx_config_clock_delay()
98 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { in bcm54xx_config_clock_delay()
102 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in bcm54xx_config_clock_delay()
103 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { in bcm54xx_config_clock_delay()
107 rc = bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val); in bcm54xx_config_clock_delay()
114 static int bcm54210e_config_init(struct phy_device *phydev) in bcm54210e_config_init() argument
118 bcm54xx_config_clock_delay(phydev); in bcm54210e_config_init()
120 if (phydev->dev_flags & PHY_BRCM_EN_MASTER_MODE) { in bcm54210e_config_init()
121 val = phy_read(phydev, MII_CTRL1000); in bcm54210e_config_init()
123 phy_write(phydev, MII_CTRL1000, val); in bcm54210e_config_init()
129 static int bcm54612e_config_init(struct phy_device *phydev) in bcm54612e_config_init() argument
133 bcm54xx_config_clock_delay(phydev); in bcm54612e_config_init()
136 if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) { in bcm54612e_config_init()
139 reg = bcm_phy_read_exp(phydev, BCM54612E_EXP_SPARE0); in bcm54612e_config_init()
140 err = bcm_phy_write_exp(phydev, BCM54612E_EXP_SPARE0, in bcm54612e_config_init()
150 static int bcm54616s_config_init(struct phy_device *phydev) in bcm54616s_config_init() argument
154 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in bcm54616s_config_init()
155 phydev->interface != PHY_INTERFACE_MODE_1000BASEX) in bcm54616s_config_init()
160 val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC); in bcm54616s_config_init()
165 rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC, in bcm54616s_config_init()
171 val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_MODE); in bcm54616s_config_init()
175 rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val); in bcm54616s_config_init()
180 rc = phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN); in bcm54616s_config_init()
186 val |= phydev->interface == PHY_INTERFACE_MODE_SGMII ? in bcm54616s_config_init()
189 rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val); in bcm54616s_config_init()
194 rc = phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN); in bcm54616s_config_init()
200 rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val); in bcm54616s_config_init()
205 return phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN); in bcm54616s_config_init()
209 static int bcm50610_a0_workaround(struct phy_device *phydev) in bcm50610_a0_workaround() argument
213 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH0, in bcm50610_a0_workaround()
219 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH3, in bcm50610_a0_workaround()
224 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75, in bcm50610_a0_workaround()
229 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP96, in bcm50610_a0_workaround()
234 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP97, in bcm50610_a0_workaround()
240 static int bcm54xx_phydsp_config(struct phy_device *phydev) in bcm54xx_phydsp_config() argument
245 err = bcm54xx_auxctl_write(phydev, in bcm54xx_phydsp_config()
252 if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 || in bcm54xx_phydsp_config()
253 BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) { in bcm54xx_phydsp_config()
255 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08, in bcm54xx_phydsp_config()
260 if (phydev->drv->phy_id == PHY_ID_BCM50610) { in bcm54xx_phydsp_config()
261 err = bcm50610_a0_workaround(phydev); in bcm54xx_phydsp_config()
267 if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM57780) { in bcm54xx_phydsp_config()
270 val = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP75); in bcm54xx_phydsp_config()
275 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75, val); in bcm54xx_phydsp_config()
280 err2 = bcm54xx_auxctl_write(phydev, in bcm54xx_phydsp_config()
288 static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev) in bcm54xx_adjust_rxrefclk() argument
295 if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM57780 && in bcm54xx_adjust_rxrefclk()
296 BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610 && in bcm54xx_adjust_rxrefclk()
297 BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610M && in bcm54xx_adjust_rxrefclk()
298 BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54210E && in bcm54xx_adjust_rxrefclk()
299 BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54810 && in bcm54xx_adjust_rxrefclk()
300 BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811) in bcm54xx_adjust_rxrefclk()
303 val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_SCR3); in bcm54xx_adjust_rxrefclk()
309 if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 || in bcm54xx_adjust_rxrefclk()
310 BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) && in bcm54xx_adjust_rxrefclk()
311 BRCM_PHY_REV(phydev) >= 0x3) { in bcm54xx_adjust_rxrefclk()
318 if (phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED) { in bcm54xx_adjust_rxrefclk()
319 if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811) { in bcm54xx_adjust_rxrefclk()
327 if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) in bcm54xx_adjust_rxrefclk()
332 if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) { in bcm54xx_adjust_rxrefclk()
333 if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E || in bcm54xx_adjust_rxrefclk()
334 BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 || in bcm54xx_adjust_rxrefclk()
335 BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811) in bcm54xx_adjust_rxrefclk()
342 bcm_phy_write_shadow(phydev, BCM54XX_SHD_SCR3, val); in bcm54xx_adjust_rxrefclk()
344 val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_APD); in bcm54xx_adjust_rxrefclk()
350 if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) in bcm54xx_adjust_rxrefclk()
356 bcm_phy_write_shadow(phydev, BCM54XX_SHD_APD, val); in bcm54xx_adjust_rxrefclk()
359 static void bcm54xx_ptp_stop(struct phy_device *phydev) in bcm54xx_ptp_stop() argument
361 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54xx_ptp_stop()
367 static void bcm54xx_ptp_config_init(struct phy_device *phydev) in bcm54xx_ptp_config_init() argument
369 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54xx_ptp_config_init()
372 bcm_ptp_config_init(phydev); in bcm54xx_ptp_config_init()
375 static int bcm5481x_set_brrmode(struct phy_device *phydev, bool on) in bcm5481x_set_brrmode() argument
381 reg = bcm_phy_read_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL); in bcm5481x_set_brrmode()
391 err = bcm_phy_write_exp(phydev, in bcm5481x_set_brrmode()
403 return bcm_phy_write_exp(phydev, in bcm5481x_set_brrmode()
407 static int bcm54811_config_init(struct phy_device *phydev) in bcm54811_config_init() argument
409 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54811_config_init()
413 if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) { in bcm54811_config_init()
414 reg = bcm_phy_read_exp(phydev, BCM54612E_EXP_SPARE0); in bcm54811_config_init()
417 err = bcm_phy_write_exp(phydev, BCM54612E_EXP_SPARE0, in bcm54811_config_init()
425 phydev->autoneg = 0; in bcm54811_config_init()
427 return bcm5481x_set_brrmode(phydev, priv->brr_mode); in bcm54811_config_init()
430 static int bcm54xx_config_init(struct phy_device *phydev) in bcm54xx_config_init() argument
434 reg = phy_read(phydev, MII_BCM54XX_ECR); in bcm54xx_config_init()
440 err = phy_write(phydev, MII_BCM54XX_ECR, reg); in bcm54xx_config_init()
448 err = phy_write(phydev, MII_BCM54XX_IMR, reg); in bcm54xx_config_init()
452 if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 || in bcm54xx_config_init()
453 BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) && in bcm54xx_config_init()
454 (phydev->dev_flags & PHY_BRCM_CLEAR_RGMII_MODE)) in bcm54xx_config_init()
455 bcm_phy_write_shadow(phydev, BCM54XX_SHD_RGMII_MODE, 0); in bcm54xx_config_init()
457 bcm54xx_adjust_rxrefclk(phydev); in bcm54xx_config_init()
459 switch (BRCM_PHY_MODEL(phydev)) { in bcm54xx_config_init()
462 err = bcm54xx_config_clock_delay(phydev); in bcm54xx_config_init()
465 err = bcm54210e_config_init(phydev); in bcm54xx_config_init()
468 err = bcm54612e_config_init(phydev); in bcm54xx_config_init()
471 err = bcm54616s_config_init(phydev); in bcm54xx_config_init()
475 val = bcm_phy_read_exp(phydev, in bcm54xx_config_init()
478 err = bcm_phy_write_exp(phydev, in bcm54xx_config_init()
483 err = bcm54811_config_init(phydev); in bcm54xx_config_init()
489 bcm54xx_phydsp_config(phydev); in bcm54xx_config_init()
499 if (!phy_on_sfp(phydev)) { in bcm54xx_config_init()
502 bcm_phy_write_shadow(phydev, BCM54XX_SHD_LEDS1, val); in bcm54xx_config_init()
507 bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val); in bcm54xx_config_init()
510 bcm54xx_ptp_config_init(phydev); in bcm54xx_config_init()
515 err = bcm_phy_read_exp(phydev, BCM54XX_WOL_INT_STATUS); in bcm54xx_config_init()
520 pm_wakeup_event(&phydev->mdio.dev, 0); in bcm54xx_config_init()
525 static int bcm54xx_iddq_set(struct phy_device *phydev, bool enable) in bcm54xx_iddq_set() argument
529 if (!(phydev->dev_flags & PHY_BRCM_IDDQ_SUSPEND)) in bcm54xx_iddq_set()
532 ret = bcm_phy_read_exp(phydev, BCM54XX_TOP_MISC_IDDQ_CTRL); in bcm54xx_iddq_set()
541 ret = bcm_phy_write_exp(phydev, BCM54XX_TOP_MISC_IDDQ_CTRL, ret); in bcm54xx_iddq_set()
546 static int bcm54xx_set_wakeup_irq(struct phy_device *phydev, bool state) in bcm54xx_set_wakeup_irq() argument
548 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54xx_set_wakeup_irq()
551 if (!bcm54xx_phy_can_wakeup(phydev)) in bcm54xx_set_wakeup_irq()
565 static int bcm54xx_suspend(struct phy_device *phydev) in bcm54xx_suspend() argument
569 bcm54xx_ptp_stop(phydev); in bcm54xx_suspend()
572 ret = bcm_phy_read_exp(phydev, BCM54XX_WOL_INT_STATUS); in bcm54xx_suspend()
576 if (phydev->wol_enabled) in bcm54xx_suspend()
577 return bcm54xx_set_wakeup_irq(phydev, true); in bcm54xx_suspend()
583 ret = phy_write(phydev, MII_BMCR, BMCR_PDOWN); in bcm54xx_suspend()
587 return bcm54xx_iddq_set(phydev, true); in bcm54xx_suspend()
590 static int bcm54xx_resume(struct phy_device *phydev) in bcm54xx_resume() argument
594 if (phydev->wol_enabled) { in bcm54xx_resume()
595 ret = bcm54xx_set_wakeup_irq(phydev, false); in bcm54xx_resume()
600 ret = bcm54xx_iddq_set(phydev, false); in bcm54xx_resume()
607 ret = genphy_resume(phydev); in bcm54xx_resume()
619 if (phydev->dev_flags & PHY_BRCM_IDDQ_SUSPEND) { in bcm54xx_resume()
620 ret = genphy_soft_reset(phydev); in bcm54xx_resume()
625 return bcm54xx_config_init(phydev); in bcm54xx_resume()
628 static int bcm54810_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) in bcm54810_read_mmd() argument
633 static int bcm54810_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, in bcm54810_write_mmd() argument
643 * @phydev: target phy_device struct
645 * Description: Reads the PHY's abilities and populates phydev->supported
654 static int bcm5481x_read_abilities(struct phy_device *phydev) in bcm5481x_read_abilities() argument
656 struct device_node *np = phydev->mdio.dev.of_node; in bcm5481x_read_abilities()
657 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm5481x_read_abilities()
661 linkmode_clear_bit(bcm54811_linkmodes[i], phydev->supported); in bcm5481x_read_abilities()
666 err = bcm5481x_set_brrmode(phydev, priv->brr_mode); in bcm5481x_read_abilities()
673 phydev->supported); in bcm5481x_read_abilities()
675 val = phy_read(phydev, MII_BCM54XX_LRESR); in bcm5481x_read_abilities()
680 phydev->supported, in bcm5481x_read_abilities()
683 phydev->supported, in bcm5481x_read_abilities()
686 phydev->supported, in bcm5481x_read_abilities()
691 return genphy_read_abilities(phydev); in bcm5481x_read_abilities()
694 static int bcm5481x_config_delay_swap(struct phy_device *phydev) in bcm5481x_config_delay_swap() argument
696 struct device_node *np = phydev->mdio.dev.of_node; in bcm5481x_config_delay_swap()
699 bcm54xx_config_clock_delay(phydev); in bcm5481x_config_delay_swap()
703 int ret = bcm_phy_write_exp(phydev, in bcm5481x_config_delay_swap()
713 static int bcm5481_config_aneg(struct phy_device *phydev) in bcm5481_config_aneg() argument
715 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm5481_config_aneg()
720 ret = bcm_config_lre_aneg(phydev, false); in bcm5481_config_aneg()
722 ret = genphy_config_aneg(phydev); in bcm5481_config_aneg()
728 return bcm5481x_config_delay_swap(phydev); in bcm5481_config_aneg()
731 static int bcm54811_config_aneg(struct phy_device *phydev) in bcm54811_config_aneg() argument
733 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54811_config_aneg()
739 phydev->autoneg = 0; in bcm54811_config_aneg()
740 ret = bcm_config_lre_aneg(phydev, false); in bcm54811_config_aneg()
742 ret = genphy_config_aneg(phydev); in bcm54811_config_aneg()
749 return bcm5481x_config_delay_swap(phydev); in bcm54811_config_aneg()
756 static int bcm54616s_probe(struct phy_device *phydev) in bcm54616s_probe() argument
761 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in bcm54616s_probe()
765 phydev->priv = priv; in bcm54616s_probe()
767 val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_MODE); in bcm54616s_probe()
778 val = bcm_phy_read_shadow(phydev, BCM54616S_SHD_100FX_CTRL); in bcm54616s_probe()
790 phydev->port = PORT_FIBRE; in bcm54616s_probe()
796 static int bcm54616s_config_aneg(struct phy_device *phydev) in bcm54616s_config_aneg() argument
798 struct bcm54616s_phy_priv *priv = phydev->priv; in bcm54616s_config_aneg()
803 ret = genphy_c37_config_aneg(phydev); in bcm54616s_config_aneg()
805 ret = genphy_config_aneg(phydev); in bcm54616s_config_aneg()
808 bcm54xx_config_clock_delay(phydev); in bcm54616s_config_aneg()
813 static int bcm54616s_read_status(struct phy_device *phydev) in bcm54616s_read_status() argument
815 struct bcm54616s_phy_priv *priv = phydev->priv; in bcm54616s_read_status()
820 err = genphy_c37_read_status(phydev, &changed); in bcm54616s_read_status()
822 err = genphy_read_status(phydev); in bcm54616s_read_status()
827 static int brcm_fet_config_init(struct phy_device *phydev) in brcm_fet_config_init() argument
832 err = phy_write(phydev, MII_BMCR, BMCR_RESET); in brcm_fet_config_init()
852 err = phy_read(phydev, MII_BMCR); in brcm_fet_config_init()
857 reg = phy_read(phydev, MII_BRCM_FET_INTREG); in brcm_fet_config_init()
862 if (phydev->phy_id == PHY_ID_BCM5221) in brcm_fet_config_init()
872 err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); in brcm_fet_config_init()
877 brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST); in brcm_fet_config_init()
883 phy_lock_mdio_bus(phydev); in brcm_fet_config_init()
885 err = __phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg); in brcm_fet_config_init()
887 phy_unlock_mdio_bus(phydev); in brcm_fet_config_init()
891 if (phydev->phy_id != PHY_ID_BCM5221) { in brcm_fet_config_init()
893 reg = __phy_read(phydev, MII_BRCM_FET_SHDW_AUXMODE4); in brcm_fet_config_init()
899 err = __phy_modify(phydev, MII_BRCM_FET_SHDW_AUXMODE4, in brcm_fet_config_init()
906 err = __phy_set_bits(phydev, MII_BRCM_FET_SHDW_MISCCTRL, in brcm_fet_config_init()
912 if (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE) { in brcm_fet_config_init()
914 err = __phy_set_bits(phydev, MII_BRCM_FET_SHDW_AUXSTAT2, in brcm_fet_config_init()
920 err2 = __phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest); in brcm_fet_config_init()
924 phy_unlock_mdio_bus(phydev); in brcm_fet_config_init()
929 static int brcm_fet_ack_interrupt(struct phy_device *phydev) in brcm_fet_ack_interrupt() argument
934 reg = phy_read(phydev, MII_BRCM_FET_INTREG); in brcm_fet_ack_interrupt()
941 static int brcm_fet_config_intr(struct phy_device *phydev) in brcm_fet_config_intr() argument
945 reg = phy_read(phydev, MII_BRCM_FET_INTREG); in brcm_fet_config_intr()
949 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in brcm_fet_config_intr()
950 err = brcm_fet_ack_interrupt(phydev); in brcm_fet_config_intr()
955 err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); in brcm_fet_config_intr()
958 err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); in brcm_fet_config_intr()
962 err = brcm_fet_ack_interrupt(phydev); in brcm_fet_config_intr()
968 static irqreturn_t brcm_fet_handle_interrupt(struct phy_device *phydev) in brcm_fet_handle_interrupt() argument
972 irq_status = phy_read(phydev, MII_BRCM_FET_INTREG); in brcm_fet_handle_interrupt()
974 phy_error(phydev); in brcm_fet_handle_interrupt()
981 phy_trigger_machine(phydev); in brcm_fet_handle_interrupt()
986 static int brcm_fet_suspend(struct phy_device *phydev) in brcm_fet_suspend() argument
993 err = phy_write(phydev, MII_BMCR, BMCR_PDOWN); in brcm_fet_suspend()
998 brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST); in brcm_fet_suspend()
1004 phy_lock_mdio_bus(phydev); in brcm_fet_suspend()
1006 err = __phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg); in brcm_fet_suspend()
1008 phy_unlock_mdio_bus(phydev); in brcm_fet_suspend()
1012 if (phydev->phy_id == PHY_ID_BCM5221) in brcm_fet_suspend()
1019 err = __phy_set_bits(phydev, MII_BRCM_FET_SHDW_AUXMODE4, reg); in brcm_fet_suspend()
1022 err2 = __phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest); in brcm_fet_suspend()
1026 phy_unlock_mdio_bus(phydev); in brcm_fet_suspend()
1031 static int bcm5221_config_aneg(struct phy_device *phydev) in bcm5221_config_aneg() argument
1035 ret = genphy_config_aneg(phydev); in bcm5221_config_aneg()
1039 switch (phydev->mdix_ctrl) { in bcm5221_config_aneg()
1053 return phy_modify(phydev, BCM5221_AEGSR, BCM5221_AEGSR_MDIX_MAN_SWAP | in bcm5221_config_aneg()
1058 static int bcm5221_read_status(struct phy_device *phydev) in bcm5221_read_status() argument
1063 ret = phy_read(phydev, BCM5221_AEGSR); in bcm5221_read_status()
1069 phydev->mdix_ctrl = ETH_TP_MDI_X; in bcm5221_read_status()
1071 phydev->mdix_ctrl = ETH_TP_MDI; in bcm5221_read_status()
1073 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in bcm5221_read_status()
1077 phydev->mdix = ETH_TP_MDI_X; in bcm5221_read_status()
1079 phydev->mdix = ETH_TP_MDI; in bcm5221_read_status()
1081 return genphy_read_status(phydev); in bcm5221_read_status()
1084 static void bcm54xx_phy_get_wol(struct phy_device *phydev, in bcm54xx_phy_get_wol() argument
1092 if (!bcm54xx_phy_can_wakeup(phydev)) { in bcm54xx_phy_get_wol()
1097 bcm_phy_get_wol(phydev, wol); in bcm54xx_phy_get_wol()
1100 static int bcm54xx_phy_set_wol(struct phy_device *phydev, in bcm54xx_phy_set_wol() argument
1110 if (!bcm54xx_phy_can_wakeup(phydev)) in bcm54xx_phy_set_wol()
1113 ret = bcm_phy_set_wol(phydev, wol); in bcm54xx_phy_set_wol()
1120 static int bcm54xx_phy_probe(struct phy_device *phydev) in bcm54xx_phy_probe() argument
1126 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in bcm54xx_phy_probe()
1132 phydev->priv = priv; in bcm54xx_phy_probe()
1134 priv->stats = devm_kcalloc(&phydev->mdio.dev, in bcm54xx_phy_probe()
1135 bcm_phy_get_sset_count(phydev), sizeof(u64), in bcm54xx_phy_probe()
1140 priv->ptp = bcm_ptp_probe(phydev); in bcm54xx_phy_probe()
1148 wakeup_gpio = devm_gpiod_get(&phydev->mdio.dev, "wakeup", GPIOD_IN); in bcm54xx_phy_probe()
1158 ret = devm_request_irq(&phydev->mdio.dev, priv->wake_irq, in bcm54xx_phy_probe()
1161 dev_name(&phydev->mdio.dev), phydev); in bcm54xx_phy_probe()
1169 if (!bcm54xx_phy_can_wakeup(phydev)) in bcm54xx_phy_probe()
1172 return device_init_wakeup(&phydev->mdio.dev, true); in bcm54xx_phy_probe()
1175 static void bcm54xx_get_stats(struct phy_device *phydev, in bcm54xx_get_stats() argument
1178 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54xx_get_stats()
1180 bcm_phy_get_stats(phydev, priv->stats, stats, data); in bcm54xx_get_stats()
1183 static void bcm54xx_link_change_notify(struct phy_device *phydev) in bcm54xx_link_change_notify() argument
1189 if (phydev->state != PHY_RUNNING) in bcm54xx_link_change_notify()
1195 if (!(phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) in bcm54xx_link_change_notify()
1198 ret = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP08); in bcm54xx_link_change_notify()
1206 if (phydev->speed == SPEED_10) in bcm54xx_link_change_notify()
1210 bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08, ret); in bcm54xx_link_change_notify()
1213 static int lre_read_master_slave(struct phy_device *phydev) in lre_read_master_slave() argument
1221 phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; in lre_read_master_slave()
1222 phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; in lre_read_master_slave()
1224 val = phy_read(phydev, MII_BCM54XX_LRECR); in lre_read_master_slave()
1235 val = phy_read(phydev, MII_BCM54XX_LRELDSE); in lre_read_master_slave()
1244 phydev->master_slave_get = cfg; in lre_read_master_slave()
1245 phydev->master_slave_state = state; in lre_read_master_slave()
1251 static int lre_read_lpa(struct phy_device *phydev) in lre_read_lpa() argument
1255 if (phydev->autoneg != AUTONEG_ENABLE) { in lre_read_lpa()
1256 if (!phydev->autoneg_complete) { in lre_read_lpa()
1260 phydev->lp_advertising); in lre_read_lpa()
1266 lrelpa = phy_read(phydev, MII_BCM54XX_LRELPA); in lre_read_lpa()
1271 phydev->lp_advertising, in lre_read_lpa()
1274 phydev->lp_advertising, in lre_read_lpa()
1277 phydev->lp_advertising, in lre_read_lpa()
1280 phydev->lp_advertising, in lre_read_lpa()
1283 linkmode_zero(phydev->lp_advertising); in lre_read_lpa()
1289 static int lre_read_status_fixed(struct phy_device *phydev) in lre_read_status_fixed() argument
1291 int lrecr = phy_read(phydev, MII_BCM54XX_LRECR); in lre_read_status_fixed()
1296 phydev->duplex = DUPLEX_FULL; in lre_read_status_fixed()
1299 phydev->speed = SPEED_100; in lre_read_status_fixed()
1301 phydev->speed = SPEED_10; in lre_read_status_fixed()
1307 * lre_update_link - update link status in @phydev
1308 * @phydev: target phy_device struct
1311 * Description: Update the value in phydev->link to reflect the
1317 static int lre_update_link(struct phy_device *phydev) in lre_update_link() argument
1321 lrecr = phy_read(phydev, MII_BCM54XX_LRECR); in lre_update_link()
1336 if (!phy_polling_mode(phydev) || !phydev->link) { in lre_update_link()
1337 status = phy_read(phydev, MII_BCM54XX_LRESR); in lre_update_link()
1345 status = phy_read(phydev, MII_BCM54XX_LRESR); in lre_update_link()
1349 phydev->link = status & LRESR_LSTATUS ? 1 : 0; in lre_update_link()
1350 phydev->autoneg_complete = status & LRESR_LDSCOMPLETE ? 1 : 0; in lre_update_link()
1355 if (phydev->autoneg == AUTONEG_ENABLE && !phydev->autoneg_complete) in lre_update_link()
1356 phydev->link = 0; in lre_update_link()
1364 static int bcm54811_lre_read_status(struct phy_device *phydev) in bcm54811_lre_read_status() argument
1366 int err, old_link = phydev->link; in bcm54811_lre_read_status()
1369 err = lre_update_link(phydev); in bcm54811_lre_read_status()
1374 if (phydev->autoneg == in bcm54811_lre_read_status()
1375 AUTONEG_ENABLE && old_link && phydev->link) in bcm54811_lre_read_status()
1378 phydev->speed = SPEED_UNKNOWN; in bcm54811_lre_read_status()
1379 phydev->duplex = DUPLEX_UNKNOWN; in bcm54811_lre_read_status()
1380 phydev->pause = 0; in bcm54811_lre_read_status()
1381 phydev->asym_pause = 0; in bcm54811_lre_read_status()
1383 err = lre_read_master_slave(phydev); in bcm54811_lre_read_status()
1388 err = lre_read_lpa(phydev); in bcm54811_lre_read_status()
1392 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) in bcm54811_lre_read_status()
1393 phy_resolve_aneg_linkmode(phydev); in bcm54811_lre_read_status()
1394 else if (phydev->autoneg == AUTONEG_DISABLE) in bcm54811_lre_read_status()
1395 err = lre_read_status_fixed(phydev); in bcm54811_lre_read_status()
1400 static int bcm54811_read_status(struct phy_device *phydev) in bcm54811_read_status() argument
1402 struct bcm54xx_phy_priv *priv = phydev->priv; in bcm54811_read_status()
1405 return bcm54811_lre_read_status(phydev); in bcm54811_read_status()
1407 return genphy_read_status(phydev); in bcm54811_read_status()