Lines Matching refs:phydev

83 static int rtl821x_read_page(struct phy_device *phydev)  in rtl821x_read_page()  argument
85 return __phy_read(phydev, RTL821x_PAGE_SELECT); in rtl821x_read_page()
88 static int rtl821x_write_page(struct phy_device *phydev, int page) in rtl821x_write_page() argument
90 return __phy_write(phydev, RTL821x_PAGE_SELECT, page); in rtl821x_write_page()
93 static int rtl821x_probe(struct phy_device *phydev) in rtl821x_probe() argument
95 struct device *dev = &phydev->mdio.dev; in rtl821x_probe()
103 ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1); in rtl821x_probe()
111 ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR2); in rtl821x_probe()
119 phydev->priv = priv; in rtl821x_probe()
124 static int rtl8201_ack_interrupt(struct phy_device *phydev) in rtl8201_ack_interrupt() argument
128 err = phy_read(phydev, RTL8201F_ISR); in rtl8201_ack_interrupt()
133 static int rtl821x_ack_interrupt(struct phy_device *phydev) in rtl821x_ack_interrupt() argument
137 err = phy_read(phydev, RTL821x_INSR); in rtl821x_ack_interrupt()
142 static int rtl8211f_ack_interrupt(struct phy_device *phydev) in rtl8211f_ack_interrupt() argument
146 err = phy_read_paged(phydev, 0xa43, RTL8211F_INSR); in rtl8211f_ack_interrupt()
151 static int rtl8201_config_intr(struct phy_device *phydev) in rtl8201_config_intr() argument
156 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in rtl8201_config_intr()
157 err = rtl8201_ack_interrupt(phydev); in rtl8201_config_intr()
162 err = phy_write_paged(phydev, 0x7, RTL8201F_IER, val); in rtl8201_config_intr()
165 err = phy_write_paged(phydev, 0x7, RTL8201F_IER, val); in rtl8201_config_intr()
169 err = rtl8201_ack_interrupt(phydev); in rtl8201_config_intr()
175 static int rtl8211b_config_intr(struct phy_device *phydev) in rtl8211b_config_intr() argument
179 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in rtl8211b_config_intr()
180 err = rtl821x_ack_interrupt(phydev); in rtl8211b_config_intr()
184 err = phy_write(phydev, RTL821x_INER, in rtl8211b_config_intr()
187 err = phy_write(phydev, RTL821x_INER, 0); in rtl8211b_config_intr()
191 err = rtl821x_ack_interrupt(phydev); in rtl8211b_config_intr()
197 static int rtl8211e_config_intr(struct phy_device *phydev) in rtl8211e_config_intr() argument
201 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in rtl8211e_config_intr()
202 err = rtl821x_ack_interrupt(phydev); in rtl8211e_config_intr()
206 err = phy_write(phydev, RTL821x_INER, in rtl8211e_config_intr()
209 err = phy_write(phydev, RTL821x_INER, 0); in rtl8211e_config_intr()
213 err = rtl821x_ack_interrupt(phydev); in rtl8211e_config_intr()
219 static int rtl8211f_config_intr(struct phy_device *phydev) in rtl8211f_config_intr() argument
224 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in rtl8211f_config_intr()
225 err = rtl8211f_ack_interrupt(phydev); in rtl8211f_config_intr()
230 err = phy_write_paged(phydev, 0xa42, RTL821x_INER, val); in rtl8211f_config_intr()
233 err = phy_write_paged(phydev, 0xa42, RTL821x_INER, val); in rtl8211f_config_intr()
237 err = rtl8211f_ack_interrupt(phydev); in rtl8211f_config_intr()
243 static irqreturn_t rtl8201_handle_interrupt(struct phy_device *phydev) in rtl8201_handle_interrupt() argument
247 irq_status = phy_read(phydev, RTL8201F_ISR); in rtl8201_handle_interrupt()
249 phy_error(phydev); in rtl8201_handle_interrupt()
256 phy_trigger_machine(phydev); in rtl8201_handle_interrupt()
261 static irqreturn_t rtl821x_handle_interrupt(struct phy_device *phydev) in rtl821x_handle_interrupt() argument
265 irq_status = phy_read(phydev, RTL821x_INSR); in rtl821x_handle_interrupt()
267 phy_error(phydev); in rtl821x_handle_interrupt()
271 irq_enabled = phy_read(phydev, RTL821x_INER); in rtl821x_handle_interrupt()
273 phy_error(phydev); in rtl821x_handle_interrupt()
280 phy_trigger_machine(phydev); in rtl821x_handle_interrupt()
285 static irqreturn_t rtl8211f_handle_interrupt(struct phy_device *phydev) in rtl8211f_handle_interrupt() argument
289 irq_status = phy_read_paged(phydev, 0xa43, RTL8211F_INSR); in rtl8211f_handle_interrupt()
291 phy_error(phydev); in rtl8211f_handle_interrupt()
298 phy_trigger_machine(phydev); in rtl8211f_handle_interrupt()
303 static int rtl8211_config_aneg(struct phy_device *phydev) in rtl8211_config_aneg() argument
307 ret = genphy_config_aneg(phydev); in rtl8211_config_aneg()
314 if (phydev->speed == SPEED_100 && phydev->autoneg == AUTONEG_DISABLE) { in rtl8211_config_aneg()
315 phy_write(phydev, 0x17, 0x2138); in rtl8211_config_aneg()
316 phy_write(phydev, 0x0e, 0x0260); in rtl8211_config_aneg()
318 phy_write(phydev, 0x17, 0x2108); in rtl8211_config_aneg()
319 phy_write(phydev, 0x0e, 0x0000); in rtl8211_config_aneg()
325 static int rtl8211c_config_init(struct phy_device *phydev) in rtl8211c_config_init() argument
328 return phy_set_bits(phydev, MII_CTRL1000, in rtl8211c_config_init()
332 static int rtl8211f_config_init(struct phy_device *phydev) in rtl8211f_config_init() argument
334 struct rtl821x_priv *priv = phydev->priv; in rtl8211f_config_init()
335 struct device *dev = &phydev->mdio.dev; in rtl8211f_config_init()
339 ret = phy_modify_paged_changed(phydev, 0xa43, RTL8211F_PHYCR1, in rtl8211f_config_init()
348 switch (phydev->interface) { in rtl8211f_config_init()
373 ret = phy_modify_paged_changed(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, in rtl8211f_config_init()
388 ret = phy_modify_paged_changed(phydev, 0xd08, 0x15, RTL8211F_RX_DELAY, in rtl8211f_config_init()
403 ret = phy_modify_paged(phydev, 0xa43, RTL8211F_PHYCR2, in rtl8211f_config_init()
411 return genphy_soft_reset(phydev); in rtl8211f_config_init()
414 static int rtl821x_resume(struct phy_device *phydev) in rtl821x_resume() argument
418 ret = genphy_resume(phydev); in rtl821x_resume()
427 static int rtl8211e_config_init(struct phy_device *phydev) in rtl8211e_config_init() argument
433 switch (phydev->interface) { in rtl8211e_config_init()
459 oldpage = phy_select_page(phydev, 0x7); in rtl8211e_config_init()
463 ret = __phy_write(phydev, RTL821x_EXT_PAGE_SELECT, 0xa4); in rtl8211e_config_init()
467 ret = __phy_modify(phydev, 0x1c, RTL8211E_CTRL_DELAY in rtl8211e_config_init()
472 return phy_restore_page(phydev, oldpage, ret); in rtl8211e_config_init()
475 static int rtl8211b_suspend(struct phy_device *phydev) in rtl8211b_suspend() argument
477 phy_write(phydev, MII_MMD_DATA, BIT(9)); in rtl8211b_suspend()
479 return genphy_suspend(phydev); in rtl8211b_suspend()
482 static int rtl8211b_resume(struct phy_device *phydev) in rtl8211b_resume() argument
484 phy_write(phydev, MII_MMD_DATA, 0); in rtl8211b_resume()
486 return genphy_resume(phydev); in rtl8211b_resume()
489 static int rtl8366rb_config_init(struct phy_device *phydev) in rtl8366rb_config_init() argument
493 ret = phy_set_bits(phydev, RTL8366RB_POWER_SAVE, in rtl8366rb_config_init()
496 dev_err(&phydev->mdio.dev, in rtl8366rb_config_init()
504 static int rtlgen_get_speed(struct phy_device *phydev) in rtlgen_get_speed() argument
508 if (!phydev->link) in rtlgen_get_speed()
511 val = phy_read_paged(phydev, 0xa43, 0x12); in rtlgen_get_speed()
517 phydev->speed = SPEED_10; in rtlgen_get_speed()
520 phydev->speed = SPEED_100; in rtlgen_get_speed()
523 phydev->speed = SPEED_1000; in rtlgen_get_speed()
526 phydev->speed = SPEED_10000; in rtlgen_get_speed()
529 phydev->speed = SPEED_2500; in rtlgen_get_speed()
532 phydev->speed = SPEED_5000; in rtlgen_get_speed()
541 static int rtlgen_read_status(struct phy_device *phydev) in rtlgen_read_status() argument
545 ret = genphy_read_status(phydev); in rtlgen_read_status()
549 return rtlgen_get_speed(phydev); in rtlgen_read_status()
552 static int rtlgen_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) in rtlgen_read_mmd() argument
557 rtl821x_write_page(phydev, 0xa5c); in rtlgen_read_mmd()
558 ret = __phy_read(phydev, 0x12); in rtlgen_read_mmd()
559 rtl821x_write_page(phydev, 0); in rtlgen_read_mmd()
561 rtl821x_write_page(phydev, 0xa5d); in rtlgen_read_mmd()
562 ret = __phy_read(phydev, 0x10); in rtlgen_read_mmd()
563 rtl821x_write_page(phydev, 0); in rtlgen_read_mmd()
565 rtl821x_write_page(phydev, 0xa5d); in rtlgen_read_mmd()
566 ret = __phy_read(phydev, 0x11); in rtlgen_read_mmd()
567 rtl821x_write_page(phydev, 0); in rtlgen_read_mmd()
575 static int rtlgen_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, in rtlgen_write_mmd() argument
581 rtl821x_write_page(phydev, 0xa5d); in rtlgen_write_mmd()
582 ret = __phy_write(phydev, 0x10, val); in rtlgen_write_mmd()
583 rtl821x_write_page(phydev, 0); in rtlgen_write_mmd()
591 static int rtl822x_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) in rtl822x_read_mmd() argument
593 int ret = rtlgen_read_mmd(phydev, devnum, regnum); in rtl822x_read_mmd()
599 rtl821x_write_page(phydev, 0xa6e); in rtl822x_read_mmd()
600 ret = __phy_read(phydev, 0x16); in rtl822x_read_mmd()
601 rtl821x_write_page(phydev, 0); in rtl822x_read_mmd()
603 rtl821x_write_page(phydev, 0xa6d); in rtl822x_read_mmd()
604 ret = __phy_read(phydev, 0x12); in rtl822x_read_mmd()
605 rtl821x_write_page(phydev, 0); in rtl822x_read_mmd()
607 rtl821x_write_page(phydev, 0xa6d); in rtl822x_read_mmd()
608 ret = __phy_read(phydev, 0x10); in rtl822x_read_mmd()
609 rtl821x_write_page(phydev, 0); in rtl822x_read_mmd()
615 static int rtl822x_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, in rtl822x_write_mmd() argument
618 int ret = rtlgen_write_mmd(phydev, devnum, regnum, val); in rtl822x_write_mmd()
624 rtl821x_write_page(phydev, 0xa6d); in rtl822x_write_mmd()
625 ret = __phy_write(phydev, 0x12, val); in rtl822x_write_mmd()
626 rtl821x_write_page(phydev, 0); in rtl822x_write_mmd()
632 static int rtl822x_get_features(struct phy_device *phydev) in rtl822x_get_features() argument
636 val = phy_read_paged(phydev, 0xa61, 0x13); in rtl822x_get_features()
641 phydev->supported, val & RTL_SUPPORTS_2500FULL); in rtl822x_get_features()
643 phydev->supported, val & RTL_SUPPORTS_5000FULL); in rtl822x_get_features()
645 phydev->supported, val & RTL_SUPPORTS_10000FULL); in rtl822x_get_features()
647 return genphy_read_abilities(phydev); in rtl822x_get_features()
650 static int rtl822x_config_aneg(struct phy_device *phydev) in rtl822x_config_aneg() argument
654 if (phydev->autoneg == AUTONEG_ENABLE) { in rtl822x_config_aneg()
658 phydev->advertising)) in rtl822x_config_aneg()
661 ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12, in rtl822x_config_aneg()
667 return __genphy_config_aneg(phydev, ret); in rtl822x_config_aneg()
670 static int rtl822x_read_status(struct phy_device *phydev) in rtl822x_read_status() argument
674 if (phydev->autoneg == AUTONEG_ENABLE) { in rtl822x_read_status()
675 int lpadv = phy_read_paged(phydev, 0xa5d, 0x13); in rtl822x_read_status()
681 phydev->lp_advertising, lpadv & RTL_LPADV_10000FULL); in rtl822x_read_status()
683 phydev->lp_advertising, lpadv & RTL_LPADV_5000FULL); in rtl822x_read_status()
685 phydev->lp_advertising, lpadv & RTL_LPADV_2500FULL); in rtl822x_read_status()
688 ret = genphy_read_status(phydev); in rtl822x_read_status()
692 return rtlgen_get_speed(phydev); in rtl822x_read_status()
695 static bool rtlgen_supports_2_5gbps(struct phy_device *phydev) in rtlgen_supports_2_5gbps() argument
699 phy_write(phydev, RTL821x_PAGE_SELECT, 0xa61); in rtlgen_supports_2_5gbps()
700 val = phy_read(phydev, 0x13); in rtlgen_supports_2_5gbps()
701 phy_write(phydev, RTL821x_PAGE_SELECT, 0); in rtlgen_supports_2_5gbps()
706 static int rtlgen_match_phy_device(struct phy_device *phydev) in rtlgen_match_phy_device() argument
708 return phydev->phy_id == RTL_GENERIC_PHYID && in rtlgen_match_phy_device()
709 !rtlgen_supports_2_5gbps(phydev); in rtlgen_match_phy_device()
712 static int rtl8226_match_phy_device(struct phy_device *phydev) in rtl8226_match_phy_device() argument
714 return phydev->phy_id == RTL_GENERIC_PHYID && in rtl8226_match_phy_device()
715 rtlgen_supports_2_5gbps(phydev); in rtl8226_match_phy_device()
718 static int rtlgen_resume(struct phy_device *phydev) in rtlgen_resume() argument
720 int ret = genphy_resume(phydev); in rtlgen_resume()
728 static int rtl9000a_config_init(struct phy_device *phydev) in rtl9000a_config_init() argument
730 phydev->autoneg = AUTONEG_DISABLE; in rtl9000a_config_init()
731 phydev->speed = SPEED_100; in rtl9000a_config_init()
732 phydev->duplex = DUPLEX_FULL; in rtl9000a_config_init()
737 static int rtl9000a_config_aneg(struct phy_device *phydev) in rtl9000a_config_aneg() argument
742 switch (phydev->master_slave_set) { in rtl9000a_config_aneg()
752 phydev_warn(phydev, "Unsupported Master/Slave mode\n"); in rtl9000a_config_aneg()
756 ret = phy_modify_changed(phydev, MII_CTRL1000, CTL1000_AS_MASTER, ctl); in rtl9000a_config_aneg()
758 ret = genphy_soft_reset(phydev); in rtl9000a_config_aneg()
763 static int rtl9000a_read_status(struct phy_device *phydev) in rtl9000a_read_status() argument
767 phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; in rtl9000a_read_status()
768 phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; in rtl9000a_read_status()
770 ret = genphy_update_link(phydev); in rtl9000a_read_status()
774 ret = phy_read(phydev, MII_CTRL1000); in rtl9000a_read_status()
778 phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_FORCE; in rtl9000a_read_status()
780 phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_FORCE; in rtl9000a_read_status()
782 ret = phy_read(phydev, MII_STAT1000); in rtl9000a_read_status()
786 phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; in rtl9000a_read_status()
788 phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; in rtl9000a_read_status()
793 static int rtl9000a_ack_interrupt(struct phy_device *phydev) in rtl9000a_ack_interrupt() argument
797 err = phy_read(phydev, RTL8211F_INSR); in rtl9000a_ack_interrupt()
802 static int rtl9000a_config_intr(struct phy_device *phydev) in rtl9000a_config_intr() argument
807 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in rtl9000a_config_intr()
808 err = rtl9000a_ack_interrupt(phydev); in rtl9000a_config_intr()
813 err = phy_write_paged(phydev, 0xa42, RTL9000A_GINMR, val); in rtl9000a_config_intr()
816 err = phy_write_paged(phydev, 0xa42, RTL9000A_GINMR, val); in rtl9000a_config_intr()
820 err = rtl9000a_ack_interrupt(phydev); in rtl9000a_config_intr()
823 return phy_write_paged(phydev, 0xa42, RTL9000A_GINMR, val); in rtl9000a_config_intr()
826 static irqreturn_t rtl9000a_handle_interrupt(struct phy_device *phydev) in rtl9000a_handle_interrupt() argument
830 irq_status = phy_read(phydev, RTL8211F_INSR); in rtl9000a_handle_interrupt()
832 phy_error(phydev); in rtl9000a_handle_interrupt()
839 phy_trigger_machine(phydev); in rtl9000a_handle_interrupt()