Lines Matching full:phydev
110 static int yt8521_hw_strap_polling(struct phy_device *phydev);
111 #define YT8521_PHY_MODE_CURR yt8521_hw_strap_polling(phydev)
113 static int yt8511_read_page(struct phy_device *phydev) in yt8511_read_page() argument
115 return __phy_read(phydev, YT8511_PAGE_SELECT); in yt8511_read_page()
118 static int yt8511_write_page(struct phy_device *phydev, int page) in yt8511_write_page() argument
120 return __phy_write(phydev, YT8511_PAGE_SELECT, page); in yt8511_write_page()
123 static int yt8511_config_init(struct phy_device *phydev) in yt8511_config_init() argument
128 oldpage = phy_select_page(phydev, YT8511_EXT_CLK_GATE); in yt8511_config_init()
133 switch (phydev->interface) { in yt8511_config_init()
155 ret = __phy_modify(phydev, YT8511_PAGE, (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge); in yt8511_config_init()
160 ret = __phy_modify(phydev, YT8511_PAGE, 0, YT8511_CLK_125M); in yt8511_config_init()
165 ret = __phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_DELAY_DRIVE); in yt8511_config_init()
169 ret = __phy_modify(phydev, YT8511_PAGE, YT8511_DELAY_FE_TX_EN, fe); in yt8511_config_init()
174 ret = __phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_SLEEP_CTRL); in yt8511_config_init()
178 ret = __phy_modify(phydev, YT8511_PAGE, 0, YT8511_PLLON_SLP); in yt8511_config_init()
183 return phy_restore_page(phydev, oldpage, ret); in yt8511_config_init()
186 static u32 ytphy_read_ext(struct phy_device *phydev, u32 regnum) in ytphy_read_ext() argument
190 phy_lock_mdio_bus(phydev); in ytphy_read_ext()
191 ret = __phy_write(phydev, REG_DEBUG_ADDR_OFFSET, regnum); in ytphy_read_ext()
195 ret = __phy_read(phydev, REG_DEBUG_DATA); in ytphy_read_ext()
200 phy_unlock_mdio_bus(phydev); in ytphy_read_ext()
204 static int ytphy_write_ext(struct phy_device *phydev, u32 regnum, u16 val) in ytphy_write_ext() argument
208 phy_lock_mdio_bus(phydev); in ytphy_write_ext()
209 ret = __phy_write(phydev, REG_DEBUG_ADDR_OFFSET, regnum); in ytphy_write_ext()
213 ret = __phy_write(phydev, REG_DEBUG_DATA, val); in ytphy_write_ext()
218 phy_unlock_mdio_bus(phydev); in ytphy_write_ext()
222 static int ytphy_soft_reset(struct phy_device *phydev) in ytphy_soft_reset() argument
226 val = phy_read(phydev, MII_BMCR); in ytphy_soft_reset()
230 ret = phy_write(phydev, MII_BMCR, val | BMCR_RESET); in ytphy_soft_reset()
237 static int yt8512_clk_init(struct phy_device *phydev) in yt8512_clk_init() argument
239 struct device_node *node = phydev->mdio.dev.of_node; in yt8512_clk_init()
253 val = ytphy_read_ext(phydev, YT8512_EXTREG_AFE_PLL); in yt8512_clk_init()
259 ret = ytphy_write_ext(phydev, YT8512_EXTREG_AFE_PLL, val); in yt8512_clk_init()
263 val = ytphy_read_ext(phydev, YT8512_EXTREG_EXTEND_COMBO); in yt8512_clk_init()
269 ret = ytphy_write_ext(phydev, YT8512_EXTREG_EXTEND_COMBO, val); in yt8512_clk_init()
273 val = phy_read(phydev, MII_BMCR); in yt8512_clk_init()
278 ret = phy_write(phydev, MII_BMCR, val); in yt8512_clk_init()
283 static int yt8512_led_init(struct phy_device *phydev) in yt8512_led_init() argument
289 val = ytphy_read_ext(phydev, YT8512_EXTREG_LED0); in yt8512_led_init()
300 ret = ytphy_write_ext(phydev, YT8512_EXTREG_LED0, val); in yt8512_led_init()
304 val = ytphy_read_ext(phydev, YT8512_EXTREG_LED1); in yt8512_led_init()
313 ret = ytphy_write_ext(phydev, YT8512_LED1_BT_ON_EN, val); in yt8512_led_init()
318 static int yt8512_config_init(struct phy_device *phydev) in yt8512_config_init() argument
323 ret = yt8512_clk_init(phydev); in yt8512_config_init()
327 ret = yt8512_led_init(phydev); in yt8512_config_init()
332 val = ytphy_read_ext(phydev, YT8512_EXTREG_SLEEP_CONTROL1); in yt8512_config_init()
338 ret = ytphy_write_ext(phydev, YT8512_EXTREG_SLEEP_CONTROL1, val); in yt8512_config_init()
345 static int yt8512_read_status(struct phy_device *phydev) in yt8512_read_status() argument
351 ret = genphy_update_link(phydev); in yt8512_read_status()
355 val = phy_read(phydev, REG_PHY_SPEC_STATUS); in yt8512_read_status()
375 phydev->speed = speed; in yt8512_read_status()
376 phydev->duplex = duplex; in yt8512_read_status()
381 static int yt8521_soft_reset(struct phy_device *phydev) in yt8521_soft_reset() argument
386 ytphy_write_ext(phydev, 0xa000, 0); in yt8521_soft_reset()
387 ret = ytphy_soft_reset(phydev); in yt8521_soft_reset()
393 ytphy_write_ext(phydev, 0xa000, 2); in yt8521_soft_reset()
394 ret = ytphy_soft_reset(phydev); in yt8521_soft_reset()
398 ytphy_write_ext(phydev, 0xa000, 0); in yt8521_soft_reset()
402 val = ytphy_read_ext(phydev, 0xa001); in yt8521_soft_reset()
403 ytphy_write_ext(phydev, 0xa001, (val & ~0x8000)); in yt8521_soft_reset()
405 ytphy_write_ext(phydev, 0xa000, 0); in yt8521_soft_reset()
406 ret = ytphy_soft_reset(phydev); in yt8521_soft_reset()
414 static int yt8521_hw_strap_polling(struct phy_device *phydev) in yt8521_hw_strap_polling() argument
418 val = ytphy_read_ext(phydev, 0xa001) & 0x7; in yt8521_hw_strap_polling()
435 static int yt8521_config_init(struct phy_device *phydev) in yt8521_config_init() argument
446 ytphy_wol_feature_set(phydev, &wol); in yt8521_config_init()
449 phydev->irq = PHY_POLL; in yt8521_config_init()
451 hw_strap_mode = ytphy_read_ext(phydev, 0xa001) & 0x7; in yt8521_config_init()
453 ytphy_write_ext(phydev, 0xa000, 0); in yt8521_config_init()
456 val = ytphy_read_ext(phydev, YT8521_EXTREG_SLEEP_CONTROL1); in yt8521_config_init()
461 ret = ytphy_write_ext(phydev, YT8521_EXTREG_SLEEP_CONTROL1, val); in yt8521_config_init()
466 val = ytphy_read_ext(phydev, 0xc); in yt8521_config_init()
470 ret = ytphy_write_ext(phydev, 0xc, val); in yt8521_config_init()
474 netdev_info(phydev->attached_dev, "%s done, phy addr: %d, strap mode = %d, polling mode = %d\n", in yt8521_config_init()
475 __func__, phydev->mdio.addr, hw_strap_mode, yt8521_hw_strap_polling(phydev)); in yt8521_config_init()
483 static int yt8521_adjust_status(struct phy_device *phydev, int val, int is_utp) in yt8521_adjust_status() argument
511 phydev->speed = speed; in yt8521_adjust_status()
512 phydev->duplex = duplex; in yt8521_adjust_status()
521 static int yt8521_aneg_done(struct phy_device *phydev) in yt8521_aneg_done() argument
526 ytphy_write_ext(phydev, 0xa000, 2); in yt8521_aneg_done()
527 link_fiber = !!(phy_read(phydev, REG_PHY_SPEC_STATUS) & (BIT(YT8521_LINK_STATUS_BIT))); in yt8521_aneg_done()
530 ytphy_write_ext(phydev, 0xa000, 0); in yt8521_aneg_done()
532 link_utp = !!(phy_read(phydev, REG_PHY_SPEC_STATUS) & (BIT(YT8521_LINK_STATUS_BIT))); in yt8521_aneg_done()
534 netdev_info(phydev->attached_dev, "%s, phy addr: %d, link_fiber: %d, link_utp: %d\n", in yt8521_aneg_done()
535 __func__, phydev->mdio.addr, link_fiber, link_utp); in yt8521_aneg_done()
539 static int yt8521_read_status(struct phy_device *phydev) in yt8521_read_status() argument
549 ret = ytphy_write_ext(phydev, 0xa000, 0); in yt8521_read_status()
553 val = phy_read(phydev, REG_PHY_SPEC_STATUS); in yt8521_read_status()
560 yt8521_adjust_status(phydev, val, 1); in yt8521_read_status()
568 ret = ytphy_write_ext(phydev, 0xa000, 2); in yt8521_read_status()
572 val = phy_read(phydev, REG_PHY_SPEC_STATUS); in yt8521_read_status()
582 yt8521_fiber_latch_val = phy_read(phydev, MII_BMSR); in yt8521_read_status()
583 yt8521_fiber_curr_val = phy_read(phydev, MII_BMSR); in yt8521_read_status()
587 …netdev_info(phydev->attached_dev, "%s, phy addr: %d, fiber link down detect, latch = %04x, curr = … in yt8521_read_status()
588 __func__, phydev->mdio.addr, yt8521_fiber_latch_val, in yt8521_read_status()
594 yt8521_adjust_status(phydev, val, 0); in yt8521_read_status()
601 if (phydev->link == 0) in yt8521_read_status()
602 netdev_info(phydev->attached_dev, "%s, phy addr: %d, link up, media: %s, mii reg 0x11 = 0x%x\n", in yt8521_read_status()
603 __func__, phydev->mdio.addr, in yt8521_read_status()
606 phydev->link = 1; in yt8521_read_status()
608 if (phydev->link == 1) in yt8521_read_status()
609 netdev_info(phydev->attached_dev, "%s, phy addr: %d, link down\n", in yt8521_read_status()
610 __func__, phydev->mdio.addr); in yt8521_read_status()
611 phydev->link = 0; in yt8521_read_status()
617 ytphy_write_ext(phydev, 0xa000, 2); in yt8521_read_status()
619 ytphy_write_ext(phydev, 0xa000, 0); in yt8521_read_status()
625 static int yt8521_suspend(struct phy_device *phydev) in yt8521_suspend() argument
630 ytphy_write_ext(phydev, 0xa000, 0); in yt8521_suspend()
631 value = phy_read(phydev, MII_BMCR); in yt8521_suspend()
632 phy_write(phydev, MII_BMCR, value | BMCR_PDOWN); in yt8521_suspend()
634 ytphy_write_ext(phydev, 0xa000, 2); in yt8521_suspend()
635 value = phy_read(phydev, MII_BMCR); in yt8521_suspend()
636 phy_write(phydev, MII_BMCR, value | BMCR_PDOWN); in yt8521_suspend()
638 ytphy_write_ext(phydev, 0xa000, 0); in yt8521_suspend()
644 static int yt8521_resume(struct phy_device *phydev) in yt8521_resume() argument
649 value = ytphy_read_ext(phydev, YT8521_EXTREG_SLEEP_CONTROL1); in yt8521_resume()
655 ret = ytphy_write_ext(phydev, YT8521_EXTREG_SLEEP_CONTROL1, value); in yt8521_resume()
661 ytphy_write_ext(phydev, 0xa000, 0); in yt8521_resume()
662 value = phy_read(phydev, MII_BMCR); in yt8521_resume()
663 phy_write(phydev, MII_BMCR, value & ~BMCR_PDOWN); in yt8521_resume()
667 ytphy_write_ext(phydev, 0xa000, 2); in yt8521_resume()
668 value = phy_read(phydev, MII_BMCR); in yt8521_resume()
669 phy_write(phydev, MII_BMCR, value & ~BMCR_PDOWN); in yt8521_resume()
671 ytphy_write_ext(phydev, 0xa000, 0); in yt8521_resume()
678 static int yt8531_rxclk_duty_init(struct phy_device *phydev) in yt8531_rxclk_duty_init() argument
683 ret = ytphy_write_ext(phydev, 0xa040, 0xffff); in yt8531_rxclk_duty_init()
687 ret = ytphy_write_ext(phydev, 0xa041, 0xff); in yt8531_rxclk_duty_init()
691 ret = ytphy_write_ext(phydev, 0xa039, 0xbf00); in yt8531_rxclk_duty_init()
699 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || in yt8531_rxclk_duty_init()
700 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) in yt8531_rxclk_duty_init()
703 ret = ytphy_write_ext(phydev, 0xa03a, value); in yt8531_rxclk_duty_init()
706 ret = ytphy_write_ext(phydev, 0xa03b, value); in yt8531_rxclk_duty_init()
709 ret = ytphy_write_ext(phydev, 0xa03c, value); in yt8531_rxclk_duty_init()
712 ret = ytphy_write_ext(phydev, 0xa03d, value); in yt8531_rxclk_duty_init()
715 ret = ytphy_write_ext(phydev, 0xa03e, value); in yt8531_rxclk_duty_init()
718 ret = ytphy_write_ext(phydev, 0xa03f, value); in yt8531_rxclk_duty_init()
725 static int yt8531S_config_init(struct phy_device *phydev) in yt8531S_config_init() argument
730 ret = yt8531a_xtal_init(phydev); in yt8531S_config_init()
735 return yt8521_config_init(phydev); in yt8531S_config_init()
738 static int yt8531_config_init(struct phy_device *phydev) in yt8531_config_init() argument
743 ret = yt8531a_xtal_init(phydev); in yt8531_config_init()
749 ret = ytphy_write_ext(phydev, 0xa012, 0xd0); in yt8531_config_init()
753 ret = yt8531_rxclk_duty_init(phydev); in yt8531_config_init()
761 ret = ytphy_write_ext(phydev, 0xa010, 0xdbcf); in yt8531_config_init()
766 val = ytphy_read_ext(phydev, 0x57); in yt8531_config_init()
768 ret = ytphy_write_ext(phydev, 0x57, val); in yt8531_config_init()