#include <linux/fs.h>
 #include <linux/platform_device.h>
 #include <linux/phy.h>
+#include <linux/of.h>
+#include <linux/of_mdio.h>
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 
        fep->oldlink = 0;
        fep->oldspeed = 0;
        fep->oldduplex = -1;
-       if(fep->fpi->bus_id)
-               phydev = phy_connect(dev, fep->fpi->bus_id, &fs_adjust_link, 0,
-                               PHY_INTERFACE_MODE_MII);
+       if(fep->fpi->phy_node)
+               phydev = of_phy_connect(dev, fep->fpi->phy_node,
+                                       &fs_adjust_link, 0,
+                                       PHY_INTERFACE_MODE_MII);
        else {
                printk("No phy bus ID specified in BSP code\n");
                return -EINVAL;
 
 /**************************************************************************************/
 
-static int __devinit find_phy(struct device_node *np,
-                              struct fs_platform_info *fpi)
-{
-       struct device_node *phynode, *mdionode;
-       int ret = 0, len, bus_id;
-       const u32 *data;
-
-       data  = of_get_property(np, "fixed-link", NULL);
-       if (data) {
-               snprintf(fpi->bus_id, 16, "%x:%02x", 0, *data);
-               return 0;
-       }
-
-       data = of_get_property(np, "phy-handle", &len);
-       if (!data || len != 4)
-               return -EINVAL;
-
-       phynode = of_find_node_by_phandle(*data);
-       if (!phynode)
-               return -EINVAL;
-
-       data = of_get_property(phynode, "reg", &len);
-       if (!data || len != 4) {
-               ret = -EINVAL;
-               goto out_put_phy;
-       }
-
-       mdionode = of_get_parent(phynode);
-       if (!mdionode) {
-               ret = -EINVAL;
-               goto out_put_phy;
-       }
-
-       bus_id = of_get_gpio(mdionode, 0);
-       if (bus_id < 0) {
-               struct resource res;
-               ret = of_address_to_resource(mdionode, 0, &res);
-               if (ret)
-                       goto out_put_mdio;
-               bus_id = res.start;
-       }
-
-       snprintf(fpi->bus_id, 16, "%x:%02x", bus_id, *data);
-
-out_put_mdio:
-       of_node_put(mdionode);
-out_put_phy:
-       of_node_put(phynode);
-       return ret;
-}
-
 #ifdef CONFIG_FS_ENET_HAS_FEC
 #define IS_FEC(match) ((match)->data == &fs_fec_ops)
 #else
        fpi->rx_copybreak = 240;
        fpi->use_napi = 1;
        fpi->napi_weight = 17;
-
-       ret = find_phy(ofdev->node, fpi);
-       if (ret)
+       fpi->phy_node = of_parse_phandle(ofdev->node, "phy-handle", 0);
+       if ((!fpi->phy_node) && (!of_get_property(ofdev->node, "fixed-link",
+                                                 NULL)))
                goto out_free_fpi;
 
        privsize = sizeof(*fep) +
 out_free_dev:
        free_netdev(ndev);
        dev_set_drvdata(&ofdev->dev, NULL);
+       of_node_put(fpi->phy_node);
 out_free_fpi:
        kfree(fpi);
        return ret;
        fep->ops->free_bd(ndev);
        fep->ops->cleanup_data(ndev);
        dev_set_drvdata(fep->dev, NULL);
-
+       of_node_put(fep->fpi->phy_node);
        free_netdev(ndev);
        return 0;
 }
 
 #include <linux/mii.h>
 #include <linux/platform_device.h>
 #include <linux/mdio-bitbang.h>
+#include <linux/of_mdio.h>
 #include <linux/of_platform.h>
 
 #include "fs_enet.h"
        return 0;
 }
 
-static void __devinit add_phy(struct mii_bus *bus, struct device_node *np)
-{
-       const u32 *data;
-       int len, id, irq;
-
-       data = of_get_property(np, "reg", &len);
-       if (!data || len != 4)
-               return;
-
-       id = *data;
-       bus->phy_mask &= ~(1 << id);
-
-       irq = of_irq_to_resource(np, 0, NULL);
-       if (irq != NO_IRQ)
-               bus->irq[id] = irq;
-}
-
 static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
                                         const struct of_device_id *match)
 {
-       struct device_node *np = NULL;
        struct mii_bus *new_bus;
        struct bb_info *bitbang;
        int ret = -ENOMEM;
-       int i;
 
        bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL);
        if (!bitbang)
        if (!new_bus->irq)
                goto out_unmap_regs;
 
-       for (i = 0; i < PHY_MAX_ADDR; i++)
-               new_bus->irq[i] = -1;
-
-       while ((np = of_get_next_child(ofdev->node, np)))
-               if (!strcmp(np->type, "ethernet-phy"))
-                       add_phy(new_bus, np);
-
        new_bus->parent = &ofdev->dev;
        dev_set_drvdata(&ofdev->dev, new_bus);
 
-       ret = mdiobus_register(new_bus);
+       ret = of_mdiobus_register(new_bus, ofdev->node);
        if (ret)
                goto out_free_irqs;
 
 
        return 0;
 }
 
-static void __devinit add_phy(struct mii_bus *bus, struct device_node *np)
-{
-       const u32 *data;
-       int len, id, irq;
-
-       data = of_get_property(np, "reg", &len);
-       if (!data || len != 4)
-               return;
-
-       id = *data;
-       bus->phy_mask &= ~(1 << id);
-
-       irq = of_irq_to_resource(np, 0, NULL);
-       if (irq != NO_IRQ)
-               bus->irq[id] = irq;
-}
-
 static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
                                         const struct of_device_id *match)
 {
        if (!new_bus->irq)
                goto out_unmap_regs;
 
-       for (i = 0; i < PHY_MAX_ADDR; i++)
-               new_bus->irq[i] = -1;
-
-       while ((np = of_get_next_child(ofdev->node, np)))
-               if (!strcmp(np->type, "ethernet-phy"))
-                       add_phy(new_bus, np);
-
        new_bus->parent = &ofdev->dev;
        dev_set_drvdata(&ofdev->dev, new_bus);
 
-       ret = mdiobus_register(new_bus);
+       ret = of_mdiobus_register(new_bus, ofdev->node);
        if (ret)
                goto out_free_irqs;