Lines Matching full:phydev

61 static int mv2222_tx_enable(struct phy_device *phydev)  in mv2222_tx_enable()  argument
63 return phy_clear_bits_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_TXDIS, in mv2222_tx_enable()
68 static int mv2222_tx_disable(struct phy_device *phydev) in mv2222_tx_disable() argument
70 return phy_set_bits_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_TXDIS, in mv2222_tx_disable()
74 static int mv2222_soft_reset(struct phy_device *phydev) in mv2222_soft_reset() argument
78 ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, MV_PORT_RST, in mv2222_soft_reset()
83 return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND2, MV_PORT_RST, in mv2222_soft_reset()
88 static int mv2222_disable_aneg(struct phy_device *phydev) in mv2222_disable_aneg() argument
90 int ret = phy_clear_bits_mmd(phydev, MDIO_MMD_PCS, MV_1GBX_CTRL, in mv2222_disable_aneg()
95 return mv2222_soft_reset(phydev); in mv2222_disable_aneg()
98 static int mv2222_enable_aneg(struct phy_device *phydev) in mv2222_enable_aneg() argument
100 int ret = phy_set_bits_mmd(phydev, MDIO_MMD_PCS, MV_1GBX_CTRL, in mv2222_enable_aneg()
105 return mv2222_soft_reset(phydev); in mv2222_enable_aneg()
108 static int mv2222_set_sgmii_speed(struct phy_device *phydev) in mv2222_set_sgmii_speed() argument
110 struct mv2222_data *priv = phydev->priv; in mv2222_set_sgmii_speed()
112 switch (phydev->speed) { in mv2222_set_sgmii_speed()
119 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in mv2222_set_sgmii_speed()
130 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in mv2222_set_sgmii_speed()
140 return phy_modify_mmd(phydev, MDIO_MMD_PCS, in mv2222_set_sgmii_speed()
149 static bool mv2222_is_10g_capable(struct phy_device *phydev) in mv2222_is_10g_capable() argument
151 struct mv2222_data *priv = phydev->priv; in mv2222_is_10g_capable()
167 static bool mv2222_is_1gbx_capable(struct phy_device *phydev) in mv2222_is_1gbx_capable() argument
169 struct mv2222_data *priv = phydev->priv; in mv2222_is_1gbx_capable()
175 static bool mv2222_is_sgmii_capable(struct phy_device *phydev) in mv2222_is_sgmii_capable() argument
177 struct mv2222_data *priv = phydev->priv; in mv2222_is_sgmii_capable()
193 static int mv2222_config_line(struct phy_device *phydev) in mv2222_config_line() argument
195 struct mv2222_data *priv = phydev->priv; in mv2222_config_line()
199 return phy_write_mmd(phydev, MDIO_MMD_VEND2, MV_PCS_CONFIG, in mv2222_config_line()
202 return phy_write_mmd(phydev, MDIO_MMD_VEND2, MV_PCS_CONFIG, in mv2222_config_line()
205 return phy_write_mmd(phydev, MDIO_MMD_VEND2, MV_PCS_CONFIG, in mv2222_config_line()
213 static int mv2222_swap_line_type(struct phy_device *phydev) in mv2222_swap_line_type() argument
215 struct mv2222_data *priv = phydev->priv; in mv2222_swap_line_type()
221 if (mv2222_is_1gbx_capable(phydev)) { in mv2222_swap_line_type()
226 if (mv2222_is_sgmii_capable(phydev)) { in mv2222_swap_line_type()
234 if (mv2222_is_10g_capable(phydev)) { in mv2222_swap_line_type()
245 ret = mv2222_config_line(phydev); in mv2222_swap_line_type()
253 static int mv2222_setup_forced(struct phy_device *phydev) in mv2222_setup_forced() argument
255 struct mv2222_data *priv = phydev->priv; in mv2222_setup_forced()
259 if (phydev->speed < SPEED_10000 && in mv2222_setup_forced()
260 phydev->speed != SPEED_UNKNOWN) { in mv2222_setup_forced()
261 ret = mv2222_swap_line_type(phydev); in mv2222_setup_forced()
268 ret = mv2222_set_sgmii_speed(phydev); in mv2222_setup_forced()
273 return mv2222_disable_aneg(phydev); in mv2222_setup_forced()
276 static int mv2222_config_aneg(struct phy_device *phydev) in mv2222_config_aneg() argument
278 struct mv2222_data *priv = phydev->priv; in mv2222_config_aneg()
285 if (phydev->autoneg == AUTONEG_DISABLE || in mv2222_config_aneg()
287 return mv2222_setup_forced(phydev); in mv2222_config_aneg()
292 ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, MV_1GBX_ADVERTISE, in mv2222_config_aneg()
299 return mv2222_enable_aneg(phydev); in mv2222_config_aneg()
302 static int mv2222_aneg_done(struct phy_device *phydev) in mv2222_aneg_done() argument
306 if (mv2222_is_10g_capable(phydev)) { in mv2222_aneg_done()
307 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_STAT1); in mv2222_aneg_done()
315 ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_1GBX_STAT); in mv2222_aneg_done()
323 static int mv2222_read_status_10g(struct phy_device *phydev) in mv2222_read_status_10g() argument
328 val = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_STAT1); in mv2222_read_status_10g()
336 phydev->autoneg = AUTONEG_DISABLE; in mv2222_read_status_10g()
337 phydev->speed = SPEED_10000; in mv2222_read_status_10g()
338 phydev->duplex = DUPLEX_FULL; in mv2222_read_status_10g()
340 if (phydev->autoneg == AUTONEG_ENABLE) { in mv2222_read_status_10g()
346 val = mv2222_swap_line_type(phydev); in mv2222_read_status_10g()
350 return mv2222_config_aneg(phydev); in mv2222_read_status_10g()
359 static int mv2222_read_status_1g(struct phy_device *phydev) in mv2222_read_status_1g() argument
364 val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_1GBX_STAT); in mv2222_read_status_1g()
368 if (phydev->autoneg == AUTONEG_ENABLE && in mv2222_read_status_1g()
375 val = mv2222_swap_line_type(phydev); in mv2222_read_status_1g()
379 return mv2222_config_aneg(phydev); in mv2222_read_status_1g()
390 val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_1GBX_PHY_STAT); in mv2222_read_status_1g()
396 phydev->duplex = DUPLEX_FULL; in mv2222_read_status_1g()
398 phydev->duplex = DUPLEX_HALF; in mv2222_read_status_1g()
401 phydev->speed = SPEED_1000; in mv2222_read_status_1g()
403 phydev->speed = SPEED_100; in mv2222_read_status_1g()
405 phydev->speed = SPEED_10; in mv2222_read_status_1g()
411 static bool mv2222_link_is_operational(struct phy_device *phydev) in mv2222_link_is_operational() argument
413 struct mv2222_data *priv = phydev->priv; in mv2222_link_is_operational()
416 val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_RX_SIGNAL_DETECT); in mv2222_link_is_operational()
420 if (phydev->sfp_bus && !priv->sfp_link) in mv2222_link_is_operational()
426 static int mv2222_read_status(struct phy_device *phydev) in mv2222_read_status() argument
428 struct mv2222_data *priv = phydev->priv; in mv2222_read_status()
431 phydev->link = 0; in mv2222_read_status()
432 phydev->speed = SPEED_UNKNOWN; in mv2222_read_status()
433 phydev->duplex = DUPLEX_UNKNOWN; in mv2222_read_status()
435 if (!mv2222_link_is_operational(phydev)) in mv2222_read_status()
439 link = mv2222_read_status_10g(phydev); in mv2222_read_status()
441 link = mv2222_read_status_1g(phydev); in mv2222_read_status()
446 phydev->link = link; in mv2222_read_status()
451 static int mv2222_resume(struct phy_device *phydev) in mv2222_resume() argument
453 return mv2222_tx_enable(phydev); in mv2222_resume()
456 static int mv2222_suspend(struct phy_device *phydev) in mv2222_suspend() argument
458 return mv2222_tx_disable(phydev); in mv2222_suspend()
461 static int mv2222_get_features(struct phy_device *phydev) in mv2222_get_features() argument
468 static int mv2222_config_init(struct phy_device *phydev) in mv2222_config_init() argument
470 if (phydev->interface != PHY_INTERFACE_MODE_XAUI) in mv2222_config_init()
479 struct phy_device *phydev = upstream; in mv2222_sfp_insert() local
487 priv = phydev->priv; in mv2222_sfp_insert()
488 dev = &phydev->mdio.dev; in mv2222_sfp_insert()
490 sfp_parse_support(phydev->sfp_bus, id, sfp_supported, interfaces); in mv2222_sfp_insert()
491 phydev->port = sfp_parse_port(phydev->sfp_bus, id, sfp_supported); in mv2222_sfp_insert()
492 sfp_interface = sfp_select_interface(phydev->sfp_bus, sfp_supported); in mv2222_sfp_insert()
505 linkmode_and(priv->supported, phydev->supported, sfp_supported); in mv2222_sfp_insert()
507 ret = mv2222_config_line(phydev); in mv2222_sfp_insert()
511 if (mutex_trylock(&phydev->lock)) { in mv2222_sfp_insert()
512 ret = mv2222_config_aneg(phydev); in mv2222_sfp_insert()
513 mutex_unlock(&phydev->lock); in mv2222_sfp_insert()
521 struct phy_device *phydev = upstream; in mv2222_sfp_remove() local
524 priv = phydev->priv; in mv2222_sfp_remove()
528 phydev->port = PORT_NONE; in mv2222_sfp_remove()
533 struct phy_device *phydev = upstream; in mv2222_sfp_link_up() local
536 priv = phydev->priv; in mv2222_sfp_link_up()
542 struct phy_device *phydev = upstream; in mv2222_sfp_link_down() local
545 priv = phydev->priv; in mv2222_sfp_link_down()
560 static int mv2222_probe(struct phy_device *phydev) in mv2222_probe() argument
562 struct device *dev = &phydev->mdio.dev; in mv2222_probe()
586 linkmode_copy(phydev->supported, supported); in mv2222_probe()
593 phydev->priv = priv; in mv2222_probe()
595 return phy_sfp_probe(phydev, &sfp_phy_ops); in mv2222_probe()