[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f3283f70917b5c1c8d983d9f0e4ada290f9a7376.camel@mediatek.com>
Date: Mon, 20 May 2024 11:43:35 +0000
From: SkyLake Huang (黃啟澤)
<SkyLake.Huang@...iatek.com>
To: "andrew@...n.ch" <andrew@...n.ch>
CC: "linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "linux-mediatek@...ts.infradead.org"
<linux-mediatek@...ts.infradead.org>, "linux@...linux.org.uk"
<linux@...linux.org.uk>, "kuba@...nel.org" <kuba@...nel.org>,
"pabeni@...hat.com" <pabeni@...hat.com>, "edumazet@...gle.com"
<edumazet@...gle.com>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"dqfext@...il.com" <dqfext@...il.com>,
Steven Liu (劉人豪) <steven.liu@...iatek.com>,
"matthias.bgg@...il.com" <matthias.bgg@...il.com>, "davem@...emloft.net"
<davem@...emloft.net>, "hkallweit1@...il.com" <hkallweit1@...il.com>,
"daniel@...rotopia.org" <daniel@...rotopia.org>,
"angelogioacchino.delregno@...labora.com"
<angelogioacchino.delregno@...labora.com>
Subject: Re: [PATCH net-next v2 4/5] net: phy: mediatek: Extend 1G TX/RX link
pulse time
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
Powered by blists - more mailing lists