Lines Matching refs:xpcs
147 static int xpcs_read(struct mdio_xpcs_args *xpcs, int dev, u32 reg) in xpcs_read() argument
151 return mdiobus_read(xpcs->bus, xpcs->addr, reg_addr); in xpcs_read()
154 static int xpcs_write(struct mdio_xpcs_args *xpcs, int dev, u32 reg, u16 val) in xpcs_write() argument
158 return mdiobus_write(xpcs->bus, xpcs->addr, reg_addr, val); in xpcs_write()
161 static int xpcs_read_vendor(struct mdio_xpcs_args *xpcs, int dev, u32 reg) in xpcs_read_vendor() argument
163 return xpcs_read(xpcs, dev, DW_VENDOR | reg); in xpcs_read_vendor()
166 static int xpcs_write_vendor(struct mdio_xpcs_args *xpcs, int dev, int reg, in xpcs_write_vendor() argument
169 return xpcs_write(xpcs, dev, DW_VENDOR | reg, val); in xpcs_write_vendor()
172 static int xpcs_read_vpcs(struct mdio_xpcs_args *xpcs, int reg) in xpcs_read_vpcs() argument
174 return xpcs_read_vendor(xpcs, MDIO_MMD_PCS, reg); in xpcs_read_vpcs()
177 static int xpcs_write_vpcs(struct mdio_xpcs_args *xpcs, int reg, u16 val) in xpcs_write_vpcs() argument
179 return xpcs_write_vendor(xpcs, MDIO_MMD_PCS, reg, val); in xpcs_write_vpcs()
182 static int xpcs_poll_reset(struct mdio_xpcs_args *xpcs, int dev) in xpcs_poll_reset() argument
190 ret = xpcs_read(xpcs, dev, MDIO_CTRL1); in xpcs_poll_reset()
198 static int xpcs_soft_reset(struct mdio_xpcs_args *xpcs, int dev) in xpcs_soft_reset() argument
202 ret = xpcs_write(xpcs, dev, MDIO_CTRL1, MDIO_CTRL1_RESET); in xpcs_soft_reset()
206 return xpcs_poll_reset(xpcs, dev); in xpcs_soft_reset()
215 static int xpcs_read_fault(struct mdio_xpcs_args *xpcs, in xpcs_read_fault() argument
220 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT1); in xpcs_read_fault()
225 xpcs_warn(xpcs, state, "Link fault condition detected!\n"); in xpcs_read_fault()
229 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT2); in xpcs_read_fault()
234 xpcs_warn(xpcs, state, "Receiver fault detected!\n"); in xpcs_read_fault()
236 xpcs_warn(xpcs, state, "Transmitter fault detected!\n"); in xpcs_read_fault()
238 ret = xpcs_read_vendor(xpcs, MDIO_MMD_PCS, DW_VR_XS_PCS_DIG_STS); in xpcs_read_fault()
243 xpcs_warn(xpcs, state, "FIFO fault condition detected!\n"); in xpcs_read_fault()
247 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_PCS_10GBRT_STAT1); in xpcs_read_fault()
252 xpcs_warn(xpcs, state, "Link is not locked!\n"); in xpcs_read_fault()
254 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_PCS_10GBRT_STAT2); in xpcs_read_fault()
259 xpcs_warn(xpcs, state, "Link has errors!\n"); in xpcs_read_fault()
266 static int xpcs_read_link(struct mdio_xpcs_args *xpcs, bool an) in xpcs_read_link() argument
271 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT1); in xpcs_read_link()
279 ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1); in xpcs_read_link()
306 static int xpcs_config_usxgmii(struct mdio_xpcs_args *xpcs, int speed) in xpcs_config_usxgmii() argument
334 ret = xpcs_read_vpcs(xpcs, MDIO_CTRL1); in xpcs_config_usxgmii()
338 ret = xpcs_write_vpcs(xpcs, MDIO_CTRL1, ret | DW_USXGMII_EN); in xpcs_config_usxgmii()
342 ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1); in xpcs_config_usxgmii()
349 ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1, ret); in xpcs_config_usxgmii()
353 ret = xpcs_read_vpcs(xpcs, MDIO_CTRL1); in xpcs_config_usxgmii()
357 return xpcs_write_vpcs(xpcs, MDIO_CTRL1, ret | DW_USXGMII_RST); in xpcs_config_usxgmii()
360 static int xpcs_config_aneg_c73(struct mdio_xpcs_args *xpcs) in xpcs_config_aneg_c73() argument
372 if (phylink_test(xpcs->supported, 2500baseX_Full)) in xpcs_config_aneg_c73()
377 ret = xpcs_write(xpcs, MDIO_MMD_AN, DW_SR_AN_ADV3, adv); in xpcs_config_aneg_c73()
383 if (phylink_test(xpcs->supported, 1000baseKX_Full)) in xpcs_config_aneg_c73()
385 if (phylink_test(xpcs->supported, 10000baseKX4_Full)) in xpcs_config_aneg_c73()
387 if (phylink_test(xpcs->supported, 10000baseKR_Full)) in xpcs_config_aneg_c73()
390 ret = xpcs_write(xpcs, MDIO_MMD_AN, DW_SR_AN_ADV2, adv); in xpcs_config_aneg_c73()
396 if (phylink_test(xpcs->supported, Pause)) in xpcs_config_aneg_c73()
398 if (phylink_test(xpcs->supported, Asym_Pause)) in xpcs_config_aneg_c73()
401 return xpcs_write(xpcs, MDIO_MMD_AN, DW_SR_AN_ADV1, adv); in xpcs_config_aneg_c73()
404 static int xpcs_config_aneg(struct mdio_xpcs_args *xpcs) in xpcs_config_aneg() argument
408 ret = xpcs_config_aneg_c73(xpcs); in xpcs_config_aneg()
412 ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_CTRL1); in xpcs_config_aneg()
418 return xpcs_write(xpcs, MDIO_MMD_AN, MDIO_CTRL1, ret); in xpcs_config_aneg()
421 static int xpcs_aneg_done(struct mdio_xpcs_args *xpcs, in xpcs_aneg_done() argument
426 ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1); in xpcs_aneg_done()
431 ret = xpcs_read(xpcs, MDIO_MMD_AN, DW_SR_AN_LP_ABL1); in xpcs_aneg_done()
437 xpcs_config_aneg(xpcs); in xpcs_aneg_done()
447 static int xpcs_read_lpa(struct mdio_xpcs_args *xpcs, in xpcs_read_lpa() argument
452 ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1); in xpcs_read_lpa()
464 ret = xpcs_read(xpcs, MDIO_MMD_AN, DW_SR_AN_LP_ABL3); in xpcs_read_lpa()
471 ret = xpcs_read(xpcs, MDIO_MMD_AN, DW_SR_AN_LP_ABL2); in xpcs_read_lpa()
482 ret = xpcs_read(xpcs, MDIO_MMD_AN, DW_SR_AN_LP_ABL1); in xpcs_read_lpa()
496 static void xpcs_resolve_lpa(struct mdio_xpcs_args *xpcs, in xpcs_resolve_lpa() argument
506 static int xpcs_get_max_xlgmii_speed(struct mdio_xpcs_args *xpcs, in xpcs_get_max_xlgmii_speed() argument
560 static void xpcs_resolve_pma(struct mdio_xpcs_args *xpcs, in xpcs_resolve_pma() argument
571 state->speed = xpcs_get_max_xlgmii_speed(xpcs, state); in xpcs_resolve_pma()
579 static int xpcs_validate(struct mdio_xpcs_args *xpcs, in xpcs_validate() argument
583 linkmode_and(supported, supported, xpcs->supported); in xpcs_validate()
584 linkmode_and(state->advertising, state->advertising, xpcs->supported); in xpcs_validate()
588 static int xpcs_config(struct mdio_xpcs_args *xpcs, in xpcs_config() argument
594 ret = xpcs_config_aneg(xpcs); in xpcs_config()
602 static int xpcs_get_state(struct mdio_xpcs_args *xpcs, in xpcs_get_state() argument
608 state->link = xpcs_read_link(xpcs, state->an_enabled) > 0 ? 1 : 0; in xpcs_get_state()
611 ret = xpcs_read_fault(xpcs, state); in xpcs_get_state()
613 ret = xpcs_soft_reset(xpcs, MDIO_MMD_PCS); in xpcs_get_state()
619 return xpcs_config(xpcs, state); in xpcs_get_state()
622 if (state->an_enabled && xpcs_aneg_done(xpcs, state)) { in xpcs_get_state()
624 xpcs_read_lpa(xpcs, state); in xpcs_get_state()
625 xpcs_resolve_lpa(xpcs, state); in xpcs_get_state()
629 xpcs_resolve_pma(xpcs, state); in xpcs_get_state()
635 static int xpcs_link_up(struct mdio_xpcs_args *xpcs, int speed, in xpcs_link_up() argument
639 return xpcs_config_usxgmii(xpcs, speed); in xpcs_link_up()
644 static u32 xpcs_get_id(struct mdio_xpcs_args *xpcs) in xpcs_get_id() argument
649 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MII_PHYSID1); in xpcs_get_id()
655 ret = xpcs_read(xpcs, MDIO_MMD_PCS, MII_PHYSID2); in xpcs_get_id()
662 static bool xpcs_check_features(struct mdio_xpcs_args *xpcs, in xpcs_check_features() argument
677 set_bit(match->supported[i], xpcs->supported); in xpcs_check_features()
682 static int xpcs_probe(struct mdio_xpcs_args *xpcs, phy_interface_t interface) in xpcs_probe() argument
684 u32 xpcs_id = xpcs_get_id(xpcs); in xpcs_probe()
694 if (xpcs_check_features(xpcs, match, interface)) in xpcs_probe()
695 return xpcs_soft_reset(xpcs, MDIO_MMD_PCS); in xpcs_probe()