Re: [PATCH net-next v2 4/5] net: phy: mediatek: Extend 1G TX/RX link pulse time
From: SkyLake Huang (黃啟澤)
Date: Mon May 20 2024 - 07:43:58 EST
On Sat, 2024-05-18 at 01:43 +0200, Andrew Lunn wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> > +int mtk_gphy_cl22_read_status(struct phy_device *phydev)
> > +{
> > +int err, old_link = phydev->link;
> > +int mii_ctrl;
> > +
> > +/* Update the link, but return if there was an error */
> > +err = genphy_update_link(phydev);
> > +if (err)
> > +return err;
> > +
> > +/* why bother the PHY if nothing can have changed */
> > +if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
> > +return 0;
> > +
> > +phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED;
> > +phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED;
> > +phydev->speed = SPEED_UNKNOWN;
> > +phydev->duplex = DUPLEX_UNKNOWN;
> > +phydev->pause = 0;
> > +phydev->asym_pause = 0;
> > +
> > +if (phydev->is_gigabit_capable) {
> > +err = genphy_read_master_slave(phydev);
> > +if (err < 0)
> > +return err;
> > +}
> > +
> > +err = genphy_read_lpa(phydev);
> > +if (err < 0)
> > +return err;
> > +
> > +if (phydev->autoneg == AUTONEG_ENABLE) {
> > +if (phydev->autoneg_complete) {
> > +phy_resolve_aneg_linkmode(phydev);
> > +} else {
> > +mii_ctrl = phy_read(phydev, MII_CTRL1000);
> > +if ((mii_ctrl & ADVERTISE_1000FULL) || (mii_ctrl &
> ADVERTISE_1000HALF))
> > +extend_an_new_lp_cnt_limit(phydev);
>
> This all looks very similar to genphy_read_status(), except these
> three.
>
> Would it be possible to call genphy_read_status() to do most of the
> work, and then do these couple of lines of code.
>
> Andrew
Refactor this in v3. This function still works well on my mt7988
platform. Thanks for this.
Sky