]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
net: ll_temac: Fix mdio initialization
authorMichal Simek <monstr@monstr.eu>
Tue, 4 Oct 2011 11:58:35 +0000 (13:58 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 27 Mar 2019 13:47:24 +0000 (14:47 +0100)
Current driver required to have phy-node directly in
the driver. After this fixed we can use standard structure.

DTS fragment:

phy-handle = <&phy0>;
mdio {
#address-cells = <1>;
#size-cells = <0>;
phy0: phy@7 {
compatible = "marvell,88e1111";
device_type = "ethernet-phy";
reg = <7>;
} ;
} ;

Signed-off-by: Michal Simek <monstr@monstr.eu>
CC: Anirudha Sarangi <anirudh@xilinx.com>
CC: John Linn <John.Linn@xilinx.com>
CC: Grant Likely <grant.likely@secretlab.ca>
CC: Rob Herring <rob.herring@calxeda.com>
CC: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/xilinx/ll_temac_main.c
drivers/net/ethernet/xilinx/ll_temac_mdio.c

index f73c83e84b7526ec9a035deaa6e09da76e63e101..3765c47097dd12ec4fa00edee73254453de15085 100644 (file)
@@ -1084,14 +1084,15 @@ static int temac_of_probe(struct platform_device *op)
        }
        temac_init_mac_address(ndev, addr);
 
-       rc = temac_mdio_setup(lp, op->dev.of_node);
-       if (rc)
-               dev_warn(&op->dev, "error registering MDIO bus\n");
-
        lp->phy_node = of_parse_phandle(op->dev.of_node, "phy-handle", 0);
-       if (lp->phy_node)
+       if (lp->phy_node) {
                dev_dbg(lp->dev, "using PHY node %pOF (%p)\n", np, np);
 
+               rc = temac_mdio_setup(lp, op->dev.of_node);
+               if (rc)
+                       dev_warn(&op->dev, "error registering MDIO bus\n");
+       }
+
        /* Add the device attributes */
        rc = sysfs_create_group(&lp->dev->kobj, &temac_attr_group);
        if (rc) {
index f5e83ac6f7e2fa6bb1bcde1f24e5a4e549c92522..068fb2904fe1b0df3a062144f0c56fdb28b254cb 100644 (file)
@@ -64,6 +64,7 @@ int temac_mdio_setup(struct temac_local *lp, struct device_node *np)
        int clk_div;
        int rc;
        struct resource res;
+       struct device_node *np1 = of_get_parent(lp->phy_node);
 
        /* Calculate a reasonable divisor for the clock rate */
        clk_div = 0x3f; /* worst-case default setting */
@@ -85,7 +86,7 @@ int temac_mdio_setup(struct temac_local *lp, struct device_node *np)
        if (!bus)
                return -ENOMEM;
 
-       of_address_to_resource(np, 0, &res);
+       of_address_to_resource(np1, 0, &res);
        snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
                 (unsigned long long)res.start);
        bus->priv = lp;
@@ -96,7 +97,7 @@ int temac_mdio_setup(struct temac_local *lp, struct device_node *np)
 
        lp->mii_bus = bus;
 
-       rc = of_mdiobus_register(bus, np);
+       rc = of_mdiobus_register(bus, np1);
        if (rc)
                goto err_register;