Lines Matching full:phydev

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