Lines Matching full:phydev
63 static int mv3310_modify(struct phy_device *phydev, int devad, u16 reg, in mv3310_modify() argument
68 old = phy_read_mmd(phydev, devad, reg); in mv3310_modify()
76 ret = phy_write_mmd(phydev, devad, reg, val); in mv3310_modify()
96 struct phy_device *phydev = dev_get_drvdata(dev); in mv3310_hwmon_read() local
105 temp = phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP); in mv3310_hwmon_read()
153 static int mv3310_hwmon_config(struct phy_device *phydev, bool enable) in mv3310_hwmon_config() argument
158 ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP, in mv3310_hwmon_config()
164 ret = mv3310_modify(phydev, MDIO_MMD_VEND2, MV_V2_TEMP_CTRL, in mv3310_hwmon_config()
172 struct phy_device *phydev = data; in mv3310_hwmon_disable() local
174 mv3310_hwmon_config(phydev, false); in mv3310_hwmon_disable()
177 static int mv3310_hwmon_probe(struct phy_device *phydev) in mv3310_hwmon_probe() argument
179 struct device *dev = &phydev->mdio.dev; in mv3310_hwmon_probe()
180 struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); in mv3310_hwmon_probe()
196 ret = mv3310_hwmon_config(phydev, true); in mv3310_hwmon_probe()
200 ret = devm_add_action_or_reset(dev, mv3310_hwmon_disable, phydev); in mv3310_hwmon_probe()
205 priv->hwmon_name, phydev, in mv3310_hwmon_probe()
211 static inline int mv3310_hwmon_config(struct phy_device *phydev, bool enable) in mv3310_hwmon_config() argument
216 static int mv3310_hwmon_probe(struct phy_device *phydev) in mv3310_hwmon_probe() argument
222 static int mv3310_probe(struct phy_device *phydev) in mv3310_probe() argument
228 if (!phydev->is_c45 || in mv3310_probe()
229 (phydev->c45_ids.devices_in_package & mmd_mask) != mmd_mask) in mv3310_probe()
232 ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_BOOT); in mv3310_probe()
237 dev_warn(&phydev->mdio.dev, in mv3310_probe()
242 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in mv3310_probe()
246 dev_set_drvdata(&phydev->mdio.dev, priv); in mv3310_probe()
248 ret = mv3310_hwmon_probe(phydev); in mv3310_probe()
255 static int mv3310_suspend(struct phy_device *phydev) in mv3310_suspend() argument
260 static int mv3310_resume(struct phy_device *phydev) in mv3310_resume() argument
262 return mv3310_hwmon_config(phydev, true); in mv3310_resume()
265 static int mv3310_config_init(struct phy_device *phydev) in mv3310_config_init() argument
272 if (phydev->interface != PHY_INTERFACE_MODE_SGMII && in mv3310_config_init()
273 phydev->interface != PHY_INTERFACE_MODE_XAUI && in mv3310_config_init()
274 phydev->interface != PHY_INTERFACE_MODE_RXAUI && in mv3310_config_init()
275 phydev->interface != PHY_INTERFACE_MODE_10GKR) in mv3310_config_init()
281 if (phydev->c45_ids.devices_in_package & MDIO_DEVS_AN) { in mv3310_config_init()
282 val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1); in mv3310_config_init()
290 val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_STAT2); in mv3310_config_init()
308 val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_EXTABLE); in mv3310_config_init()
353 dev_warn(&phydev->mdio.dev, in mv3310_config_init()
357 phydev->supported &= mask; in mv3310_config_init()
358 phydev->advertising &= phydev->supported; in mv3310_config_init()
363 static int mv3310_config_aneg(struct phy_device *phydev) in mv3310_config_aneg() argument
370 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in mv3310_config_aneg()
372 if (phydev->autoneg == AUTONEG_DISABLE) { in mv3310_config_aneg()
373 ret = genphy_c45_pma_setup_forced(phydev); in mv3310_config_aneg()
377 return genphy_c45_an_disable_aneg(phydev); in mv3310_config_aneg()
380 phydev->advertising &= phydev->supported; in mv3310_config_aneg()
381 advertising = phydev->advertising; in mv3310_config_aneg()
383 ret = mv3310_modify(phydev, MDIO_MMD_AN, MDIO_AN_ADVERTISE, in mv3310_config_aneg()
392 ret = mv3310_modify(phydev, MDIO_MMD_AN, MV_AN_CTRL1000, in mv3310_config_aneg()
401 ret = mv3310_modify(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, in mv3310_config_aneg()
411 ret = genphy_c45_restart_aneg(phydev); in mv3310_config_aneg()
416 static int mv3310_aneg_done(struct phy_device *phydev) in mv3310_aneg_done() argument
420 val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_BASE_R + MDIO_STAT1); in mv3310_aneg_done()
427 return genphy_c45_aneg_done(phydev); in mv3310_aneg_done()
430 static void mv3310_update_interface(struct phy_device *phydev) in mv3310_update_interface() argument
432 if ((phydev->interface == PHY_INTERFACE_MODE_SGMII || in mv3310_update_interface()
433 phydev->interface == PHY_INTERFACE_MODE_10GKR) && phydev->link) { in mv3310_update_interface()
437 * phydev->interface to communicate this to the MAC. Only do in mv3310_update_interface()
440 if (phydev->speed == SPEED_10000) in mv3310_update_interface()
441 phydev->interface = PHY_INTERFACE_MODE_10GKR; in mv3310_update_interface()
442 else if (phydev->speed >= SPEED_10 && in mv3310_update_interface()
443 phydev->speed < SPEED_10000) in mv3310_update_interface()
444 phydev->interface = PHY_INTERFACE_MODE_SGMII; in mv3310_update_interface()
449 static int mv3310_read_10gbr_status(struct phy_device *phydev) in mv3310_read_10gbr_status() argument
451 phydev->link = 1; in mv3310_read_10gbr_status()
452 phydev->speed = SPEED_10000; in mv3310_read_10gbr_status()
453 phydev->duplex = DUPLEX_FULL; in mv3310_read_10gbr_status()
455 mv3310_update_interface(phydev); in mv3310_read_10gbr_status()
460 static int mv3310_read_status(struct phy_device *phydev) in mv3310_read_status() argument
462 u32 mmd_mask = phydev->c45_ids.devices_in_package; in mv3310_read_status()
472 phydev->speed = SPEED_UNKNOWN; in mv3310_read_status()
473 phydev->duplex = DUPLEX_UNKNOWN; in mv3310_read_status()
474 phydev->lp_advertising = 0; in mv3310_read_status()
475 phydev->link = 0; in mv3310_read_status()
476 phydev->pause = 0; in mv3310_read_status()
477 phydev->asym_pause = 0; in mv3310_read_status()
478 phydev->mdix = 0; in mv3310_read_status()
480 val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_BASE_R + MDIO_STAT1); in mv3310_read_status()
485 return mv3310_read_10gbr_status(phydev); in mv3310_read_status()
487 val = genphy_c45_read_link(phydev, mmd_mask); in mv3310_read_status()
491 phydev->link = val > 0 ? 1 : 0; in mv3310_read_status()
493 val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1); in mv3310_read_status()
498 val = genphy_c45_read_lpa(phydev); in mv3310_read_status()
503 val = phy_read_mmd(phydev, MDIO_MMD_AN, MV_AN_STAT1000); in mv3310_read_status()
507 phydev->lp_advertising |= mii_stat1000_to_ethtool_lpa_t(val); in mv3310_read_status()
509 if (phydev->autoneg == AUTONEG_ENABLE) in mv3310_read_status()
510 phy_resolve_aneg_linkmode(phydev); in mv3310_read_status()
513 if (phydev->autoneg != AUTONEG_ENABLE) { in mv3310_read_status()
514 val = genphy_c45_read_pma(phydev); in mv3310_read_status()
519 if (phydev->speed == SPEED_10000) { in mv3310_read_status()
520 val = genphy_c45_read_mdix(phydev); in mv3310_read_status()
524 val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_PAIRSWAP); in mv3310_read_status()
530 phydev->mdix = ETH_TP_MDI_X; in mv3310_read_status()
533 phydev->mdix = ETH_TP_MDI; in mv3310_read_status()
536 phydev->mdix = ETH_TP_MDI_INVALID; in mv3310_read_status()
541 mv3310_update_interface(phydev); in mv3310_read_status()