aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/mdio-mux.c
diff options
context:
space:
mode:
authorPramod Kumar <pramod.kumar@broadcom.com>2016-06-10 11:03:45 +0530
committerDavid S. Miller <davem@davemloft.net>2016-06-10 23:24:53 -0700
commitf20e6657a8758fe8d074889a6f1883674f01c7f2 (patch)
treea55ed4fb2fd0a3087905a230ffaab7d4d40d52e6 /drivers/net/phy/mdio-mux.c
parentsctp: sctp should change socket state when shutdown is received (diff)
downloadlinux-dev-f20e6657a8758fe8d074889a6f1883674f01c7f2.tar.xz
linux-dev-f20e6657a8758fe8d074889a6f1883674f01c7f2.zip
mdio: mux: Enhanced MDIO mux framework for integrated multiplexers
An integrated multiplexer uses same address space for "muxed bus selection" and "generation of mdio transaction" hence its good to register parent bus from mux driver. Hence added a mechanism where mux driver could register a parent bus and pass it down to framework via mdio_mux_init api. Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/mdio-mux.c')
-rw-r--r--drivers/net/phy/mdio-mux.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
index 5c81d6faf304..dbd4ecc205dc 100644
--- a/drivers/net/phy/mdio-mux.c
+++ b/drivers/net/phy/mdio-mux.c
@@ -89,7 +89,8 @@ static int parent_count;
int mdio_mux_init(struct device *dev,
int (*switch_fn)(int cur, int desired, void *data),
void **mux_handle,
- void *data)
+ void *data,
+ struct mii_bus *mux_bus)
{
struct device_node *parent_bus_node;
struct device_node *child_bus_node;
@@ -101,10 +102,21 @@ int mdio_mux_init(struct device *dev,
if (!dev->of_node)
return -ENODEV;
- parent_bus_node = of_parse_phandle(dev->of_node, "mdio-parent-bus", 0);
+ if (!mux_bus) {
+ parent_bus_node = of_parse_phandle(dev->of_node,
+ "mdio-parent-bus", 0);
- if (!parent_bus_node)
- return -ENODEV;
+ if (!parent_bus_node)
+ return -ENODEV;
+
+ parent_bus = of_mdio_find_bus(parent_bus_node);
+ if (!parent_bus) {
+ ret_val = -EPROBE_DEFER;
+ goto err_parent_bus;
+ }
+ } else {
+ parent_bus = mux_bus;
+ }
pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL);
if (pb == NULL) {
@@ -112,11 +124,6 @@ int mdio_mux_init(struct device *dev,
goto err_parent_bus;
}
- parent_bus = of_mdio_find_bus(parent_bus_node);
- if (parent_bus == NULL) {
- ret_val = -EPROBE_DEFER;
- goto err_parent_bus;
- }
pb->switch_data = data;
pb->switch_fn = switch_fn;
@@ -177,7 +184,8 @@ int mdio_mux_init(struct device *dev,
put_device(&pb->mii_bus->dev);
err_parent_bus:
- of_node_put(parent_bus_node);
+ if (!mux_bus)
+ of_node_put(parent_bus_node);
return ret_val;
}
EXPORT_SYMBOL_GPL(mdio_mux_init);