[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191210164438.GD27714@lunn.ch>
Date: Tue, 10 Dec 2019 17:44:38 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Landen Chao <landen.chao@...iatek.com>
Cc: f.fainelli@...il.com, vivien.didelot@...oirfairelinux.com,
matthias.bgg@...il.com, robh+dt@...nel.org, mark.rutland@....com,
devicetree@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-mediatek@...ts.infradead.org,
davem@...emloft.net, sean.wang@...iatek.com, opensource@...rst.com,
frank-w@...lic-files.de
Subject: Re: [PATCH net-next 4/6] net: dsa: mt7530: Add the support of MT7531
switch
> +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.
> + [ID_MT7531] = {
> + .id = ID_MT7531,
> + .setup = mt7531_setup,
> + .phy_read = mt7531_ind_phy_read,
and use it here.
Andrew
Powered by blists - more mailing lists