Lines Matching defs:phydev
73 struct phy_device *phydev;
93 static int tja11xx_check(struct phy_device *phydev, u8 reg, u16 mask, u16 set)
97 return phy_read_poll_timeout(phydev, reg, val, (val & mask) == set,
101 static int phy_modify_check(struct phy_device *phydev, u8 reg,
106 ret = phy_modify(phydev, reg, mask, set);
110 return tja11xx_check(phydev, reg, mask, set);
113 static int tja11xx_enable_reg_write(struct phy_device *phydev)
115 return phy_set_bits(phydev, MII_ECTRL, MII_ECTRL_CONFIG_EN);
118 static int tja11xx_enable_link_control(struct phy_device *phydev)
120 return phy_set_bits(phydev, MII_ECTRL, MII_ECTRL_LINK_CONTROL);
123 static int tja11xx_disable_link_control(struct phy_device *phydev)
125 return phy_clear_bits(phydev, MII_ECTRL, MII_ECTRL_LINK_CONTROL);
128 static int tja11xx_wakeup(struct phy_device *phydev)
132 ret = phy_read(phydev, MII_ECTRL);
140 ret = phy_set_bits(phydev, MII_ECTRL, MII_ECTRL_WAKE_REQUEST);
144 ret = phy_clear_bits(phydev, MII_ECTRL, MII_ECTRL_WAKE_REQUEST);
149 ret = phy_modify_check(phydev, MII_ECTRL,
155 ret = phy_modify(phydev, MII_ECTRL, MII_ECTRL_POWER_MODE_MASK,
160 ret = phy_modify_check(phydev, MII_GENSTAT,
166 return tja11xx_enable_link_control(phydev);
174 static int tja11xx_soft_reset(struct phy_device *phydev)
178 ret = tja11xx_enable_reg_write(phydev);
182 return genphy_soft_reset(phydev);
185 static int tja11xx_config_aneg_cable_test(struct phy_device *phydev)
190 if (phydev->link)
193 if (!phydev->drv->cable_test_start ||
194 !phydev->drv->cable_test_get_status)
197 ret = ethnl_cable_test_alloc(phydev, ETHTOOL_MSG_CABLE_TEST_NTF);
201 ret = phydev->drv->cable_test_start(phydev);
208 ret = phydev->drv->cable_test_get_status(phydev, &finished);
213 ethnl_cable_test_finished(phydev);
218 static int tja11xx_config_aneg(struct phy_device *phydev)
223 switch (phydev->master_slave_set) {
233 phydev_warn(phydev, "Unsupported Master/Slave mode\n");
237 changed = phy_modify_changed(phydev, MII_CFG1, MII_CFG1_MASTER_SLAVE, ctl);
242 ret = tja11xx_config_aneg_cable_test(phydev);
246 return __genphy_config_aneg(phydev, changed);
249 static int tja11xx_config_init(struct phy_device *phydev)
253 ret = tja11xx_enable_reg_write(phydev);
257 phydev->autoneg = AUTONEG_DISABLE;
258 phydev->speed = SPEED_100;
259 phydev->duplex = DUPLEX_FULL;
261 switch (phydev->phy_id & PHY_ID_MASK) {
263 ret = phy_modify(phydev, MII_CFG1,
273 ret = phy_set_bits(phydev, MII_COMMCFG, MII_COMMCFG_AUTO_OP);
281 ret = phy_clear_bits(phydev, MII_CFG1, MII_CFG1_SLEEP_CONFIRM);
285 ret = phy_modify(phydev, MII_CFG2, MII_CFG2_SLEEP_REQUEST_TO,
290 ret = tja11xx_wakeup(phydev);
295 ret = phy_read(phydev, MII_INTSRC);
302 static int tja11xx_read_status(struct phy_device *phydev)
306 phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN;
307 phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED;
309 ret = genphy_update_link(phydev);
313 ret = phy_read(phydev, MII_CFG1);
318 phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_FORCE;
320 phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_FORCE;
322 if (phydev->link) {
323 ret = phy_read(phydev, MII_COMMSTAT);
328 phydev->link = 0;
334 static int tja11xx_get_sqi(struct phy_device *phydev)
338 ret = phy_read(phydev, MII_COMMSTAT);
345 static int tja11xx_get_sqi_max(struct phy_device *phydev)
350 static int tja11xx_get_sset_count(struct phy_device *phydev)
355 static void tja11xx_get_strings(struct phy_device *phydev, u8 *data)
365 static void tja11xx_get_stats(struct phy_device *phydev,
371 ret = phy_read(phydev, tja11xx_hw_stats[i].reg);
385 struct phy_device *phydev = dev_get_drvdata(dev);
389 ret = phy_read(phydev, MII_INTSRC);
398 ret = phy_read(phydev, MII_INTSRC);
438 static int tja11xx_hwmon_register(struct phy_device *phydev,
441 struct device *dev = &phydev->mdio.dev;
454 phydev,
461 static int tja11xx_probe(struct phy_device *phydev)
463 struct device *dev = &phydev->mdio.dev;
470 priv->phydev = phydev;
472 return tja11xx_hwmon_register(phydev, priv);
479 struct phy_device *phydev_phy0 = priv->phydev;
536 static int tja1102_p0_probe(struct phy_device *phydev)
538 struct device *dev = &phydev->mdio.dev;
546 priv->phydev = phydev;
549 ret = tja11xx_hwmon_register(phydev, priv);
558 static int tja1102_match_phy_device(struct phy_device *phydev, bool port0)
562 if ((phydev->phy_id & PHY_ID_MASK) != PHY_ID_TJA1102)
565 ret = phy_read(phydev, MII_PHYSID2);
578 static int tja1102_p0_match_phy_device(struct phy_device *phydev)
580 return tja1102_match_phy_device(phydev, true);
583 static int tja1102_p1_match_phy_device(struct phy_device *phydev)
585 return tja1102_match_phy_device(phydev, false);
588 static int tja11xx_ack_interrupt(struct phy_device *phydev)
592 ret = phy_read(phydev, MII_INTSRC);
597 static int tja11xx_config_intr(struct phy_device *phydev)
601 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
604 return phy_write(phydev, MII_INTEN, value);
607 static int tja11xx_cable_test_start(struct phy_device *phydev)
611 ret = phy_clear_bits(phydev, MII_COMMCFG, MII_COMMCFG_AUTO_OP);
615 ret = tja11xx_wakeup(phydev);
619 ret = tja11xx_disable_link_control(phydev);
623 return phy_set_bits(phydev, MII_ECTRL, MII_ECTRL_CABLE_TEST);
656 static int tja11xx_cable_test_report(struct phy_device *phydev)
660 ret = phy_read(phydev, MII_EXTSTAT);
664 ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A,
670 static int tja11xx_cable_test_get_status(struct phy_device *phydev,
677 ret = phy_read(phydev, MII_ECTRL);
684 ret = phy_set_bits(phydev, MII_COMMCFG, MII_COMMCFG_AUTO_OP);
688 return tja11xx_cable_test_report(phydev);