* [PATCH net-next 0/3] net: dsa: support PHY reads/writes diversion
@ 2015-03-10 23:57 Florian Fainelli
2015-03-10 23:57 ` [PATCH net-next 1/3] of: mdio: export of_mdio_parse_addr Florian Fainelli
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Florian Fainelli @ 2015-03-10 23:57 UTC (permalink / raw)
To: netdev; +Cc: davem, devicetree, Florian Fainelli
Hi all,
This patch series completes the PHY reads/writes diversion when we need to use
the slave MII bus provided by DSA and the underlying switch drivers to
implement the real PHY reads and writes. This is particularly useful when they
are conflicting MDIO bus addresses as in the case of multiple Broadcom switches
connected to each other (internal and external, or just external).
Florian Fainelli (3):
of: mdio: export of_mdio_parse_addr
net: dsa: move PHY setup on DSA MII bus to its own function
net: dsa: fully divert PHY reads/writes if requested
drivers/of/of_mdio.c | 3 ++-
include/linux/of_mdio.h | 6 ++++++
net/dsa/slave.c | 51 +++++++++++++++++++++++++++++++++++++------------
3 files changed, 47 insertions(+), 13 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/3] of: mdio: export of_mdio_parse_addr
2015-03-10 23:57 [PATCH net-next 0/3] net: dsa: support PHY reads/writes diversion Florian Fainelli
@ 2015-03-10 23:57 ` Florian Fainelli
2015-03-11 12:48 ` Rob Herring
[not found] ` <1426031833-5113-1-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2015-03-10 23:57 UTC (permalink / raw)
To: netdev; +Cc: davem, devicetree, Florian Fainelli
Export of_mdio_parse_addr() which allows parsing a given Ethernet PHY
node MDIO address, verify it is within the allowed range, and return
its value. This is going to be useful for the DSA code which needs to
deal with multiple layers of MDIO buses.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/of/of_mdio.c | 3 ++-
include/linux/of_mdio.h | 7 +++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 1bd43053b8c7..0c064485d1c2 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -88,7 +88,7 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi
return 0;
}
-static int of_mdio_parse_addr(struct device *dev, const struct device_node *np)
+int of_mdio_parse_addr(struct device *dev, const struct device_node *np)
{
u32 addr;
int ret;
@@ -108,6 +108,7 @@ static int of_mdio_parse_addr(struct device *dev, const struct device_node *np)
return addr;
}
+EXPORT_SYMBOL(of_mdio_parse_addr);
/**
* of_mdiobus_register - Register mii_bus and create PHYs from the device tree
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
index d449018d0726..8f2237eb3485 100644
--- a/include/linux/of_mdio.h
+++ b/include/linux/of_mdio.h
@@ -24,6 +24,7 @@ struct phy_device *of_phy_attach(struct net_device *dev,
phy_interface_t iface);
extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
+extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np);
#else /* CONFIG_OF */
static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
@@ -60,6 +61,12 @@ static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np)
{
return NULL;
}
+
+static inline int of_mdio_parse_addr(struct device *dev,
+ const struct device_node *np)
+{
+ return -ENOSYS;
+}
#endif /* CONFIG_OF */
#if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY)
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 2/3] net: dsa: move PHY setup on DSA MII bus to its own function
[not found] ` <1426031833-5113-1-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-03-10 23:57 ` Florian Fainelli
0 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2015-03-10 23:57 UTC (permalink / raw)
To: netdev-u79uwXL29TY76Z2rM5mHXA
Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, devicetree-u79uwXL29TY76Z2rM5mHXA,
Florian Fainelli
In preparation for dealing with indirect reads and writes towards
certain PHY devices, move the code which deals with binding the PHY
device to the slave MII bus created by DSA to its own function:
dsa_slave_phy_connect().
Signed-off-by: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
net/dsa/slave.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a47305c72fcc..19bc2b39c9d1 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -617,6 +617,23 @@ 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 dsa_switch *ds = p->parent;
+
+ p->phy = ds->slave_mii_bus->phy_map[p->port];
+ if (!p->phy)
+ return -ENODEV;
+
+ /* Use already configured phy mode */
+ p->phy_interface = p->phy->interface;
+ phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
+ p->phy_interface);
+
+ return 0;
+}
+
static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
struct net_device *slave_dev)
{
@@ -662,14 +679,9 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
* MDIO bus instead
*/
if (!p->phy) {
- p->phy = ds->slave_mii_bus->phy_map[p->port];
- if (!p->phy)
- return -ENODEV;
-
- /* Use already configured phy mode */
- p->phy_interface = p->phy->interface;
- phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
- p->phy_interface);
+ ret = dsa_slave_phy_connect(p, slave_dev);
+ if (ret)
+ return ret;
} else {
netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
p->phy->addr, p->phy->drv->name);
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 3/3] net: dsa: fully divert PHY reads/writes if requested
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
[not found] ` <1426031833-5113-1-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-03-10 23:57 ` Florian Fainelli
2015-03-11 21:56 ` [PATCH net-next 0/3] net: dsa: support PHY reads/writes diversion David Miller
3 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2015-03-10 23:57 UTC (permalink / raw)
To: netdev; +Cc: davem, devicetree, Florian Fainelli
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/3] of: mdio: export of_mdio_parse_addr
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
0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2015-03-11 12:48 UTC (permalink / raw)
To: Florian Fainelli; +Cc: netdev, David Miller, devicetree@vger.kernel.org
On Tue, Mar 10, 2015 at 6:57 PM, Florian Fainelli <f.fainelli@gmail.com> wrote:
> Export of_mdio_parse_addr() which allows parsing a given Ethernet PHY
> node MDIO address, verify it is within the allowed range, and return
> its value. This is going to be useful for the DSA code which needs to
> deal with multiple layers of MDIO buses.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
> ---
> drivers/of/of_mdio.c | 3 ++-
> include/linux/of_mdio.h | 7 +++++++
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
> index 1bd43053b8c7..0c064485d1c2 100644
> --- a/drivers/of/of_mdio.c
> +++ b/drivers/of/of_mdio.c
> @@ -88,7 +88,7 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi
> return 0;
> }
>
> -static int of_mdio_parse_addr(struct device *dev, const struct device_node *np)
> +int of_mdio_parse_addr(struct device *dev, const struct device_node *np)
> {
> u32 addr;
> int ret;
> @@ -108,6 +108,7 @@ static int of_mdio_parse_addr(struct device *dev, const struct device_node *np)
>
> return addr;
> }
> +EXPORT_SYMBOL(of_mdio_parse_addr);
>
> /**
> * of_mdiobus_register - Register mii_bus and create PHYs from the device tree
> diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
> index d449018d0726..8f2237eb3485 100644
> --- a/include/linux/of_mdio.h
> +++ b/include/linux/of_mdio.h
> @@ -24,6 +24,7 @@ struct phy_device *of_phy_attach(struct net_device *dev,
> phy_interface_t iface);
>
> extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
> +extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np);
>
> #else /* CONFIG_OF */
> static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
> @@ -60,6 +61,12 @@ static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np)
> {
> return NULL;
> }
> +
> +static inline int of_mdio_parse_addr(struct device *dev,
> + const struct device_node *np)
> +{
> + return -ENOSYS;
> +}
> #endif /* CONFIG_OF */
>
> #if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY)
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/3] net: dsa: support PHY reads/writes diversion
2015-03-10 23:57 [PATCH net-next 0/3] net: dsa: support PHY reads/writes diversion Florian Fainelli
` (2 preceding siblings ...)
2015-03-10 23:57 ` [PATCH net-next 3/3] net: dsa: fully divert PHY reads/writes if requested Florian Fainelli
@ 2015-03-11 21:56 ` David Miller
3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-03-11 21:56 UTC (permalink / raw)
To: f.fainelli; +Cc: netdev, devicetree
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 10 Mar 2015 16:57:10 -0700
> This patch series completes the PHY reads/writes diversion when we
> need to use the slave MII bus provided by DSA and the underlying
> switch drivers to implement the real PHY reads and writes. This is
> particularly useful when they are conflicting MDIO bus addresses as
> in the case of multiple Broadcom switches connected to each other
> (internal and external, or just external).
Series applied, thanks Florian.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-03-11 21:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH net-next 3/3] net: dsa: fully divert PHY reads/writes if requested Florian Fainelli
2015-03-11 21:56 ` [PATCH net-next 0/3] net: dsa: support PHY reads/writes diversion David Miller
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).