Lines Matching refs:xpcs

124 	int (*pma_config)(struct dw_xpcs *xpcs);
149 int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface) in xpcs_get_an_mode() argument
153 compat = xpcs_find_compat(xpcs->id, interface); in xpcs_get_an_mode()
176 int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg) in xpcs_read() argument
179 struct mii_bus *bus = xpcs->mdiodev->bus; in xpcs_read()
180 int addr = xpcs->mdiodev->addr; in xpcs_read()
185 int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val) in xpcs_write() argument
188 struct mii_bus *bus = xpcs->mdiodev->bus; in xpcs_write()
189 int addr = xpcs->mdiodev->addr; in xpcs_write()
194 static int xpcs_read_vendor(struct dw_xpcs *xpcs, int dev, u32 reg) in xpcs_read_vendor() argument
196 return xpcs_read(xpcs, dev, DW_VENDOR | reg); in xpcs_read_vendor()
199 static int xpcs_write_vendor(struct dw_xpcs *xpcs, int dev, int reg, in xpcs_write_vendor() argument
202 return xpcs_write(xpcs, dev, DW_VENDOR | reg, val); in xpcs_write_vendor()
205 static int xpcs_read_vpcs(struct dw_xpcs *xpcs, int reg) in xpcs_read_vpcs() argument
207 return xpcs_read_vendor(xpcs, MDIO_MMD_PCS, reg); in xpcs_read_vpcs()
210 static int xpcs_write_vpcs(struct dw_xpcs *xpcs, int reg, u16 val) in xpcs_write_vpcs() argument
212 return xpcs_write_vendor(xpcs, MDIO_MMD_PCS, reg, val); in xpcs_write_vpcs()
215 static int xpcs_poll_reset(struct dw_xpcs *xpcs, int dev) in xpcs_poll_reset() argument
223 ret = xpcs_read(xpcs, dev, MDIO_CTRL1); in xpcs_poll_reset()
231 static int xpcs_soft_reset(struct dw_xpcs *xpcs, in xpcs_soft_reset() argument
248 ret = xpcs_write(xpcs, dev, MDIO_CTRL1, MDIO_CTRL1_RESET); in xpcs_soft_reset()
252 return xpcs_poll_reset(xpcs, dev); in xpcs_soft_reset()
261 static int xpcs_read_fault_c73(struct dw_xpcs *xpcs, in xpcs_read_fault_c73() argument
266 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT1); in xpcs_read_fault_c73()
271 xpcs_warn(xpcs, state, "Link fault condition detected!\n"); in xpcs_read_fault_c73()
275 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT2); in xpcs_read_fault_c73()
280 xpcs_warn(xpcs, state, "Receiver fault detected!\n"); in xpcs_read_fault_c73()
282 xpcs_warn(xpcs, state, "Transmitter fault detected!\n"); in xpcs_read_fault_c73()
284 ret = xpcs_read_vendor(xpcs, MDIO_MMD_PCS, DW_VR_XS_PCS_DIG_STS); in xpcs_read_fault_c73()
289 xpcs_warn(xpcs, state, "FIFO fault condition detected!\n"); in xpcs_read_fault_c73()
293 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_PCS_10GBRT_STAT1); in xpcs_read_fault_c73()
298 xpcs_warn(xpcs, state, "Link is not locked!\n"); in xpcs_read_fault_c73()
300 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_PCS_10GBRT_STAT2); in xpcs_read_fault_c73()
305 xpcs_warn(xpcs, state, "Link has errors!\n"); in xpcs_read_fault_c73()
312 static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an) in xpcs_read_link_c73() argument
317 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT1); in xpcs_read_link_c73()
325 ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1); in xpcs_read_link_c73()
352 static void xpcs_config_usxgmii(struct dw_xpcs *xpcs, int speed) in xpcs_config_usxgmii() argument
380 ret = xpcs_read_vpcs(xpcs, MDIO_CTRL1); in xpcs_config_usxgmii()
384 ret = xpcs_write_vpcs(xpcs, MDIO_CTRL1, ret | DW_USXGMII_EN); in xpcs_config_usxgmii()
388 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1); in xpcs_config_usxgmii()
395 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1, ret); in xpcs_config_usxgmii()
399 ret = xpcs_read_vpcs(xpcs, MDIO_CTRL1); in xpcs_config_usxgmii()
403 ret = xpcs_write_vpcs(xpcs, MDIO_CTRL1, ret | DW_USXGMII_RST); in xpcs_config_usxgmii()
413 static int _xpcs_config_aneg_c73(struct dw_xpcs *xpcs, in _xpcs_config_aneg_c73() argument
431 ret = xpcs_write(xpcs, MDIO_MMD_AN, DW_SR_AN_ADV3, adv); in _xpcs_config_aneg_c73()
444 ret = xpcs_write(xpcs, MDIO_MMD_AN, DW_SR_AN_ADV2, adv); in _xpcs_config_aneg_c73()
455 return xpcs_write(xpcs, MDIO_MMD_AN, DW_SR_AN_ADV1, adv); in _xpcs_config_aneg_c73()
458 static int xpcs_config_aneg_c73(struct dw_xpcs *xpcs, in xpcs_config_aneg_c73() argument
463 ret = _xpcs_config_aneg_c73(xpcs, compat); in xpcs_config_aneg_c73()
467 ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_CTRL1); in xpcs_config_aneg_c73()
473 return xpcs_write(xpcs, MDIO_MMD_AN, MDIO_CTRL1, ret); in xpcs_config_aneg_c73()
476 static int xpcs_aneg_done_c73(struct dw_xpcs *xpcs, in xpcs_aneg_done_c73() argument
482 ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1); in xpcs_aneg_done_c73()
487 ret = xpcs_read(xpcs, MDIO_MMD_AN, DW_SR_AN_LP_ABL1); in xpcs_aneg_done_c73()
493 xpcs_config_aneg_c73(xpcs, compat); in xpcs_aneg_done_c73()
503 static int xpcs_read_lpa_c73(struct dw_xpcs *xpcs, in xpcs_read_lpa_c73() argument
508 ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1); in xpcs_read_lpa_c73()
520 ret = xpcs_read(xpcs, MDIO_MMD_AN, DW_SR_AN_LP_ABL3); in xpcs_read_lpa_c73()
527 ret = xpcs_read(xpcs, MDIO_MMD_AN, DW_SR_AN_LP_ABL2); in xpcs_read_lpa_c73()
538 ret = xpcs_read(xpcs, MDIO_MMD_AN, DW_SR_AN_LP_ABL1); in xpcs_read_lpa_c73()
552 static void xpcs_resolve_lpa_c73(struct dw_xpcs *xpcs, in xpcs_resolve_lpa_c73() argument
562 static int xpcs_get_max_xlgmii_speed(struct dw_xpcs *xpcs, in xpcs_get_max_xlgmii_speed() argument
616 static void xpcs_resolve_pma(struct dw_xpcs *xpcs, in xpcs_resolve_pma() argument
627 state->speed = xpcs_get_max_xlgmii_speed(xpcs, state); in xpcs_resolve_pma()
635 void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported, in xpcs_validate() argument
651 compat = xpcs_find_compat(xpcs->id, state->interface); in xpcs_validate()
665 int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) in xpcs_config_eee() argument
669 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL0); in xpcs_config_eee()
686 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL0, ret); in xpcs_config_eee()
690 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL1); in xpcs_config_eee()
699 return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL1, ret); in xpcs_config_eee()
703 static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, unsigned int mode) in xpcs_config_aneg_c37_sgmii() argument
723 mdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL); in xpcs_config_aneg_c37_sgmii()
728 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, in xpcs_config_aneg_c37_sgmii()
734 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL); in xpcs_config_aneg_c37_sgmii()
745 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL, ret); in xpcs_config_aneg_c37_sgmii()
749 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1); in xpcs_config_aneg_c37_sgmii()
758 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, ret); in xpcs_config_aneg_c37_sgmii()
763 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, in xpcs_config_aneg_c37_sgmii()
769 static int xpcs_config_2500basex(struct dw_xpcs *xpcs) in xpcs_config_2500basex() argument
773 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1); in xpcs_config_2500basex()
778 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, ret); in xpcs_config_2500basex()
782 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL); in xpcs_config_2500basex()
788 return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, ret); in xpcs_config_2500basex()
791 int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, in xpcs_do_config() argument
797 compat = xpcs_find_compat(xpcs->id, interface); in xpcs_do_config()
804 ret = xpcs_config_aneg_c73(xpcs, compat); in xpcs_do_config()
810 ret = xpcs_config_aneg_c37_sgmii(xpcs, mode); in xpcs_do_config()
815 ret = xpcs_config_2500basex(xpcs); in xpcs_do_config()
824 ret = compat->pma_config(xpcs); in xpcs_do_config()
838 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_config() local
840 return xpcs_do_config(xpcs, interface, mode); in xpcs_config()
843 static int xpcs_get_state_c73(struct dw_xpcs *xpcs, in xpcs_get_state_c73() argument
850 state->link = xpcs_read_link_c73(xpcs, state->an_enabled) > 0 ? 1 : 0; in xpcs_get_state_c73()
853 ret = xpcs_read_fault_c73(xpcs, state); in xpcs_get_state_c73()
855 ret = xpcs_soft_reset(xpcs, compat); in xpcs_get_state_c73()
861 return xpcs_do_config(xpcs, state->interface, MLO_AN_INBAND); in xpcs_get_state_c73()
864 if (state->an_enabled && xpcs_aneg_done_c73(xpcs, state, compat)) { in xpcs_get_state_c73()
866 xpcs_read_lpa_c73(xpcs, state); in xpcs_get_state_c73()
867 xpcs_resolve_lpa_c73(xpcs, state); in xpcs_get_state_c73()
871 xpcs_resolve_pma(xpcs, state); in xpcs_get_state_c73()
877 static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, in xpcs_get_state_c37_sgmii() argument
891 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS); in xpcs_get_state_c37_sgmii()
921 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_get_state() local
925 compat = xpcs_find_compat(xpcs->id, state->interface); in xpcs_get_state()
931 ret = xpcs_get_state_c73(xpcs, state, compat); in xpcs_get_state()
939 ret = xpcs_get_state_c37_sgmii(xpcs, state); in xpcs_get_state()
950 static void xpcs_link_up_sgmii(struct dw_xpcs *xpcs, unsigned int mode, in xpcs_link_up_sgmii() argument
975 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1, val); in xpcs_link_up_sgmii()
983 struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); in xpcs_link_up() local
986 return xpcs_config_usxgmii(xpcs, speed); in xpcs_link_up()
988 return xpcs_link_up_sgmii(xpcs, mode, speed, duplex); in xpcs_link_up()
992 static u32 xpcs_get_id(struct dw_xpcs *xpcs) in xpcs_get_id() argument
998 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MII_PHYSID1); in xpcs_get_id()
1004 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MII_PHYSID2); in xpcs_get_id()
1015 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_PHYSID1); in xpcs_get_id()
1021 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_PHYSID2); in xpcs_get_id()
1117 struct dw_xpcs *xpcs; in xpcs_create() local
1121 xpcs = kzalloc(sizeof(*xpcs), GFP_KERNEL); in xpcs_create()
1122 if (!xpcs) in xpcs_create()
1125 xpcs->mdiodev = mdiodev; in xpcs_create()
1127 xpcs_id = xpcs_get_id(xpcs); in xpcs_create()
1136 xpcs->id = entry; in xpcs_create()
1144 xpcs->pcs.ops = &xpcs_phylink_ops; in xpcs_create()
1145 xpcs->pcs.poll = true; in xpcs_create()
1147 ret = xpcs_soft_reset(xpcs, compat); in xpcs_create()
1151 return xpcs; in xpcs_create()
1157 kfree(xpcs); in xpcs_create()
1163 void xpcs_destroy(struct dw_xpcs *xpcs) in xpcs_destroy() argument
1165 kfree(xpcs); in xpcs_destroy()