netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next] dsa: slave: support phy devices on external MII bus
@ 2017-10-18 16:21 Andrew Lunn
  2017-10-18 16:51 ` Florian Fainelli
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2017-10-18 16:21 UTC (permalink / raw)
  To: mnhu; +Cc: netdev, Florian Fainelli

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-18 19:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-18 16:21 [net-next] dsa: slave: support phy devices on external MII bus Andrew Lunn
2017-10-18 16:51 ` 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

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).