aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/xilinx/xilinx_emaclite.c
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2013-05-29 20:28:04 -0400
committerDavid S. Miller <davem@davemloft.net>2013-05-30 20:08:43 -0400
commite0a3bc65448c01289a74329ddf6c84d8c0594e59 (patch)
treea2e5a459acd9854d461e66c525aa06c25dc85793 /drivers/net/ethernet/xilinx/xilinx_emaclite.c
parentccfecdfe16a872ed3e8322ea48e34502568eb849 (diff)
net: emaclite: Support multiple phys connected to one MDIO bus
For system which contains at least two ethernet IP where one IP manage MDIO bus with several PHYs. Example dts node: ethernet_mac0: ethernet@81000000 { compatible = "xlnx,xps-ethernetlite-1.00.a"; device_type = "network"; interrupt-parent = <&xps_intc_0>; interrupts = < 1 0 >; local-mac-address = [ 00 0a 35 00 db bb ]; phy-handle = <&ethernet_mac0_phy0>; reg = < 0x81000000 0x10000 >; xlnx,duplex = <0x1>; xlnx,family = "spartan3e"; xlnx,include-internal-loopback = <0x0>; xlnx,include-mdio = <0x1>; xlnx,rx-ping-pong = <0x0>; xlnx,tx-ping-pong = <0x0>; ethernet_mac0_mdio { #address-cells = <1>; #size-cells = <0>; ethernet_mac0_phy0: phy@1 { reg = <0x1>; } ; ethernet_mac0_phy1: phy@3 { reg = <0x3>; } ; } ; } ; ethernet_mac2: ethernet@81040000 { compatible = "xlnx,xps-ethernetlite-1.00.a"; device_type = "network"; interrupt-parent = <&xps_intc_0>; interrupts = < 11 0 >; local-mac-address = [ 00 0a 35 00 db bb ]; phy-handle = <&ethernet_mac0_phy1>; reg = < 0x81040000 0x10000 >; xlnx,duplex = <0x1>; xlnx,family = "spartan3e"; xlnx,include-internal-loopback = <0x0>; xlnx,include-mdio = <0x0>; xlnx,rx-ping-pong = <0x0>; xlnx,tx-ping-pong = <0x0>; } ; Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/xilinx/xilinx_emaclite.c')
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_emaclite.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index a16dc3508998..fcd1e0b46103 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -848,6 +848,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
848 int rc; 848 int rc;
849 struct resource res; 849 struct resource res;
850 struct device_node *np = of_get_parent(lp->phy_node); 850 struct device_node *np = of_get_parent(lp->phy_node);
851 struct device_node *npp;
851 852
852 /* Don't register the MDIO bus if the phy_node or its parent node 853 /* Don't register the MDIO bus if the phy_node or its parent node
853 * can't be found. 854 * can't be found.
@@ -856,6 +857,17 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
856 dev_err(dev, "Failed to register mdio bus.\n"); 857 dev_err(dev, "Failed to register mdio bus.\n");
857 return -ENODEV; 858 return -ENODEV;
858 } 859 }
860 npp = of_get_parent(np);
861
862 of_address_to_resource(npp, 0, &res);
863 if (lp->ndev->mem_start != res.start) {
864 struct phy_device *phydev;
865 phydev = of_phy_find_device(lp->phy_node);
866 if (!phydev)
867 dev_info(dev,
868 "MDIO of the phy is not registered yet\n");
869 return 0;
870 }
859 871
860 /* Enable the MDIO bus by asserting the enable bit in MDIO Control 872 /* Enable the MDIO bus by asserting the enable bit in MDIO Control
861 * register. 873 * register.
@@ -869,7 +881,6 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
869 return -ENOMEM; 881 return -ENOMEM;
870 } 882 }
871 883
872 of_address_to_resource(np, 0, &res);
873 snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx", 884 snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
874 (unsigned long long)res.start); 885 (unsigned long long)res.start);
875 bus->priv = lp; 886 bus->priv = lp;