netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Lamparter <chunkeey@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: "Marek Behún" <marek.behun@nic.cz>,
	netdev@vger.kernel.org, "Andrew Lunn" <andrew@lunn.ch>,
	"Michal Vokáč" <vokac.m@gmail.com>,
	"John Crispin" <john@phrozen.org>,
	"Wei Yongjun" <weiyongjun1@huawei.com>
Subject: Re: [PATCH net-next 1/1] net: dsa: qca8k: Fix internal PHY MDIO address
Date: Thu, 21 Mar 2019 20:56:51 +0100	[thread overview]
Message-ID: <1709445.Zob874UQW2@debian64> (raw)
In-Reply-To: <4f2160f2-28f1-bd61-86ee-3db77fd67ba4@gmail.com>

On Thursday, March 21, 2019 7:26:08 PM CET Florian Fainelli wrote:
> +Christian,
> 
> On 3/21/19 11:23 AM, Marek Behún wrote:
> > The MDIO addresses of the internal PHYs on this switch for ports 1-5
> > have addresses 0-4, not 1-5.
> > 
> 
> Can you provide a Fixes: tag for this? Your change will conflicts with
> Christian's patch series here:
> 
> http://patchwork.ozlabs.org/project/netdev/list/?series=98063
http://patchwork.ozlabs.org/patch/1058655/ (link to the patch)

So, Yes and no ;)

We both have the same idea:

+static int
+qca8k_port_to_phy(int port)
+{
+	if (port < 1 || port > QCA8K_MDIO_MASTER_MAX_PORTS)
+		return -EINVAL;
+
+	return port - 1;
+}

I plan to sent v4 tomorrow, since I need to test it on the device first.

> > Signed-off-by: Marek Behún <marek.behun@nic.cz>
> > Cc: Andrew Lunn <andrew@lunn.ch>
> > Cc: Florian Fainelli <f.fainelli@gmail.com>
> > Cc: Michal Vokáč <vokac.m@gmail.com>
> > Cc: John Crispin <john@phrozen.org>
> > Cc: Wei Yongjun <weiyongjun1@huawei.com>
> > ---
> >  drivers/net/dsa/qca8k.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> > index cdcde7f8e0b2..eb199193cc3b 100644
> > --- a/drivers/net/dsa/qca8k.c
> > +++ b/drivers/net/dsa/qca8k.c
> > @@ -625,7 +625,7 @@ qca8k_phy_read(struct dsa_switch *ds, int phy, int regnum)
> >  {
> >  	struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
> >  
> > -	return mdiobus_read(priv->bus, phy, regnum);
> > +	return mdiobus_read(priv->bus, phy - 1, regnum);
> >  }
> >  
> >  static int
> > @@ -633,7 +633,7 @@ qca8k_phy_write(struct dsa_switch *ds, int phy, int regnum, u16 val)
> >  {
> >  	struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
> >  
> > -	return mdiobus_write(priv->bus, phy, regnum, val);
> > +	return mdiobus_write(priv->bus, phy - 1, regnum, val);
> >  }

Word of Warning: The priv->bus is pointing to the external mdio-bus that
the QCA8337 is connected to, so in my case I noticed that the *same* PHYs
are registered twice. The first time on the external mdio, which is fine
since we need that for the phy-handle of the "ports" node and a s second
time by the slave-mdio that net/dsa/slave.c provides. In my case I found
Florian's explanation in
https://patchwork.ozlabs.org/patch/1036309/#2084184
very useful:

|I don't think you should have to do any of this translation, because you
|can do a couple of things with DSA/Device Tree:
|
|- you can not provide a phy-handle property at all, in which case, the
|core DSA layer assumes that the PHY is part of the switch's internal
|MDIO bus which is implictly created by dsa_slave_mii_bus_create()
|
|- you can specify a phy-handle property and then the PHY device tree
|node can be placed pretty much anywhere in Device Tree, including on a
|separate MDIO bus Device Tre node which is "external" to the switch
|
|In either case, the PHY device's MDIO bus parent and its address are
|taken care of by drivers/of/of_mdio.c. You can look at mx88e6xxx for how
|it deals with its internal vs. external MDIO bus controller and that
|driver is used on a wide variety of configuration.




      parent reply	other threads:[~2019-03-21 19:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 18:23 [PATCH net-next 1/1] net: dsa: qca8k: Fix internal PHY MDIO address Marek Behún
2019-03-21 18:26 ` Florian Fainelli
2019-03-21 19:55   ` Marek Behun
2019-03-21 22:24     ` Christian Lamparter
2019-03-21 23:01       ` Marek Behun
2019-03-22  0:05         ` Christian Lamparter
2019-03-25 17:51           ` Christian Lamparter
2019-03-25 19:34             ` Marek Behun
2019-03-21 19:56   ` Christian Lamparter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1709445.Zob874UQW2@debian64 \
    --to=chunkeey@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=john@phrozen.org \
    --cc=marek.behun@nic.cz \
    --cc=netdev@vger.kernel.org \
    --cc=vokac.m@gmail.com \
    --cc=weiyongjun1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).