lkml.org 
[lkml]   [2019]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531 switch
From
Date
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

\
 
 \ /
  Last update: 2019-12-11 19:28    [W:0.070 / U:2.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site