From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, devicetree@vger.kernel.org,
Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next 3/3] net: dsa: fully divert PHY reads/writes if requested
Date: Tue, 10 Mar 2015 16:57:13 -0700 [thread overview]
Message-ID: <1426031833-5113-4-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1426031833-5113-1-git-send-email-f.fainelli@gmail.com>
In case a PHY is found via Device Tree, and is also flagged by the
switch driver as needing indirect reads/writes using the switch driver
implemented MDIO bus, make sure that we bind this PHY to the slave MII
bus in order for this to happen.
Without this, we would succeed in having the PHY driver probe()'s
function to use slave MII bus read/write functions, because this is done
during dsa_slave_mii_init(), but past that point, the PHY driver would
not go through these diverted reads and writes.
Fixes: 0d8bcdd383b88 ("net: dsa: allow for more complex PHY setups")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
net/dsa/slave.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 19bc2b39c9d1..188b69773e70 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -618,11 +618,12 @@ static int dsa_slave_fixed_link_update(struct net_device *dev,
/* slave device setup *******************************************************/
static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
- struct net_device *slave_dev)
+ struct net_device *slave_dev,
+ int addr)
{
struct dsa_switch *ds = p->parent;
- p->phy = ds->slave_mii_bus->phy_map[p->port];
+ p->phy = ds->slave_mii_bus->phy_map[addr];
if (!p->phy)
return -ENODEV;
@@ -667,10 +668,24 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
if (ds->drv->get_phy_flags)
phy_flags = ds->drv->get_phy_flags(ds, p->port);
- if (phy_dn)
- p->phy = of_phy_connect(slave_dev, phy_dn,
- dsa_slave_adjust_link, phy_flags,
- p->phy_interface);
+ if (phy_dn) {
+ ret = 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 (ret >= 0 && (ds->phys_mii_mask & (1 << ret))) {
+ ret = dsa_slave_phy_connect(p, slave_dev, ret);
+ if (ret)
+ return ret;
+ } else {
+ p->phy = of_phy_connect(slave_dev, phy_dn,
+ dsa_slave_adjust_link,
+ phy_flags,
+ p->phy_interface);
+ }
+ }
if (p->phy && phy_is_fixed)
fixed_phy_set_link_update(p->phy, dsa_slave_fixed_link_update);
@@ -679,7 +694,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
* MDIO bus instead
*/
if (!p->phy) {
- ret = dsa_slave_phy_connect(p, slave_dev);
+ ret = dsa_slave_phy_connect(p, slave_dev, p->port);
if (ret)
return ret;
} else {
--
2.1.0
next prev parent reply other threads:[~2015-03-11 0:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-10 23:57 [PATCH net-next 0/3] net: dsa: support PHY reads/writes diversion Florian Fainelli
2015-03-10 23:57 ` [PATCH net-next 1/3] of: mdio: export of_mdio_parse_addr Florian Fainelli
2015-03-11 12:48 ` Rob Herring
[not found] ` <1426031833-5113-1-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-03-10 23:57 ` [PATCH net-next 2/3] net: dsa: move PHY setup on DSA MII bus to its own function Florian Fainelli
2015-03-10 23:57 ` Florian Fainelli [this message]
2015-03-11 21:56 ` [PATCH net-next 0/3] net: dsa: support PHY reads/writes diversion David Miller
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=1426031833-5113-4-git-send-email-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--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).