From: Andrew Lunn <andrew@lunn.ch>
To: mnhu@prevas.dk
Cc: netdev <netdev@vger.kernel.org>, Florian Fainelli <f.fainelli@gmail.com>
Subject: [net-next] dsa: slave: support phy devices on external MII bus
Date: Wed, 18 Oct 2017 18:21:38 +0200 [thread overview]
Message-ID: <20171018162138.GA15371@lunn.ch> (raw)
Hi Martin
Sorry for starting a new thread. I deleted the patchset from my mailbox.
Florian said:
> The logic goes like this:
>
> - try to connect to the PHY via phy-handle
> - if we have a PHY we are connecting via phy-handle but we need to
> divert MDIO reads/writes connect using its address on the diverted
> bus
> - connect using a fixed PHY
> - finally try using the DSA slave MII bus which would connect to the switch internal PHYs
This is not quite correct. Looking at the code:
phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
...
if (phy_dn) {
int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn);
/* If this PHY address is part of phys_mii_mask, which means
* that we need to divert reads and writes to/from it, then we
* want to bind this device using the slave MII bus created by
* DSA to make that happen.
*/
if (!phy_is_fixed && phy_id >= 0 &&
(ds->phys_mii_mask & (1 << phy_id))) {
ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
if (ret) {
netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
of_node_put(phy_dn);
return ret;
}
} else {
p->phy = of_phy_connect(slave_dev, phy_dn,
The first point really is:
- try to connect to the PHY via phy-handle, if the phy_id is not
valid, or if the phy_id does not map to a phy that the switch says
does not exist.
In your case, all these points are true, so it uses
dsa_slave_phy_connect(). But we actually want it to use
of_phy_connect(), which will use the correct bus.
For some Marvell chips, you cannot actually go on ds->phys_mii_mask.
These devices can have in built PHYs and SERDES interfaces which can
be assigned to ports. These SERDES interfaces could have external PHYs
connected to them, and be on the external MDIO bus. So
ds->phys_mii_mask indicates there is a PHY, but the phy-handle points
to a different phy.
So i think this code block needs to change. If we have a phy-handle,
use it. i.e. what Florian _thinks_ it should be doing. If not, then
use dsa_slave_phy_connect().
Andrew
next reply other threads:[~2017-10-18 16:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-18 16:21 Andrew Lunn [this message]
2017-10-18 16:51 ` [net-next] dsa: slave: support phy devices on external MII bus Florian Fainelli
2017-10-18 17:30 ` Martin Hundebøll
2017-10-18 18:54 ` Florian Fainelli
2017-10-18 19:09 ` Andrew Lunn
2017-10-18 19:18 ` Florian Fainelli
2017-10-18 19:31 ` Andrew Lunn
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=20171018162138.GA15371@lunn.ch \
--to=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=mnhu@prevas.dk \
--cc=netdev@vger.kernel.org \
/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).