[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1576088280.23763.73.camel@mtksdccf07>
Date: Thu, 12 Dec 2019 02:18:00 +0800
From: Landen Chao <landen.chao@...iatek.com>
To: Andrew Lunn <andrew@...n.ch>
CC: "f.fainelli@...il.com" <f.fainelli@...il.com>,
"vivien.didelot@...oirfairelinux.com"
<vivien.didelot@...oirfairelinux.com>,
"matthias.bgg@...il.com" <matthias.bgg@...il.com>,
"robh+dt@...nel.org" <robh+dt@...nel.org>,
"mark.rutland@....com" <mark.rutland@....com>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-mediatek@...ts.infradead.org"
<linux-mediatek@...ts.infradead.org>,
"davem@...emloft.net" <davem@...emloft.net>,
Sean Wang <Sean.Wang@...iatek.com>,
"opensource@...rst.com" <opensource@...rst.com>,
"frank-w@...lic-files.de" <frank-w@...lic-files.de>
Subject: Re: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of
MT7531 switch
On Wed, 2019-12-11 at 00:44 +0800, Andrew Lunn wrote:
> > +static int
> > +mt7531_ind_mmd_phy_read(struct mt7530_priv *priv, int port, int devad,
> > + int regnum)
> > +{
> > + struct mii_bus *bus = priv->bus;
> > + struct mt7530_dummy_poll p;
> > + u32 reg, val;
> > + int ret;
> > +
> > + INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
> > +
> > + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
> > +
> > + ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
> > + !(val & PHY_ACS_ST), 20, 100000);
> > + if (ret < 0) {
> > + dev_err(priv->dev, "poll timeout\n");
> > + goto out;
> > + }
> > +
> > + reg = MDIO_CL45_ADDR | MDIO_PHY_ADDR(port) | MDIO_DEV_ADDR(devad) |
> > + regnum;
>
> It might be better to call this mt7531_ind_c45_phy_read()
>
> > +static int
> > +mt7531_ind_phy_read(struct dsa_switch *ds, int port, int regnum)
> > +{
> > + struct mt7530_priv *priv = ds->priv;
> > + struct mii_bus *bus = priv->bus;
> > + struct mt7530_dummy_poll p;
> > + int ret;
> > + u32 val;
> > +
> > + INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
> > +
> > + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
> > +
> > + ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
> > + !(val & PHY_ACS_ST), 20, 100000);
> > + if (ret < 0) {
> > + dev_err(priv->dev, "poll timeout\n");
> > + goto out;
> > + }
> > +
> > + val = MDIO_CL22_READ | MDIO_PHY_ADDR(port) | MDIO_REG_ADDR(regnum);
>
> This is then mt7531_ind_c22_phy_read().
>
> And then you can add a wrapper around this to provide
>
> mt7531_phy_read() which can do both C22 and C45.
I'll update the code base on above suggestion.
>
> > + [ID_MT7531] = {
> > + .id = ID_MT7531,
> > + .setup = mt7531_setup,
> > + .phy_read = mt7531_ind_phy_read,
>
> and use it here.
Do you also hint at using the same number of parameters for
mt7531_ind_c22_phy_read() and mt7531_ind_c45_phy_read()?
Landen
>
> Andrew
Powered by blists - more mailing lists