diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 5dab6be6fc38..9b22e7c1c4a1 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -23,6 +23,8 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
+#include <linux/of_irq.h>
+#include <linux/of_mdio.h>
 #include <linux/phy.h>
 #include <linux/phy_led_triggers.h>
 #include <linux/property.h>
@@ -3019,6 +3021,156 @@ void phy_drivers_unregister(struct phy_driver *drv, int n)
 }
 EXPORT_SYMBOL(phy_drivers_unregister);
 
+struct phy_device *
+of_phy_device_create(struct mii_bus *bus, struct device_node *child, int addr,
+		     u32 phy_id, bool is_c45)
+{
+	struct phy_c45_device_ids c45_ids;
+	struct phy_device *dev;
+	struct mdio_device *mdiodev;
+	int ret = 0;
+	int rc;
+
+	/* We allocate the device, and initialize the default values */
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return ERR_PTR(-ENOMEM);
+
+	mdiodev = &dev->mdio;
+	mdiodev->dev.parent = &bus->dev;
+	mdiodev->dev.bus = &mdio_bus_type;
+	mdiodev->dev.type = &mdio_bus_phy_type;
+	mdiodev->bus = bus;
+	mdiodev->bus_match = phy_bus_match;
+	mdiodev->addr = addr;
+	mdiodev->flags = MDIO_DEVICE_FLAG_PHY;
+	mdiodev->device_free = phy_mdio_device_free;
+	mdiodev->device_remove = phy_mdio_device_remove;
+
+	/* Associate the OF node with the device structure so it
+	 * can be looked up later
+	 */
+	of_node_get(child);
+	mdiodev->dev.of_node = child;
+	mdiodev->dev.fwnode = of_fwnode_handle(child);
+
+	rc = of_irq_get(child, 0);
+	if (rc == -EPROBE_DEFER)
+		return ERR_PTR(rc);
+
+	if (rc > 0) {
+		dev->irq = rc;
+		bus->irq[addr] = rc;
+	} else {
+		dev->irq = bus->irq[addr];
+	}
+
+	if (of_property_read_bool(child, "broken-turn-around"))
+		bus->phy_ignore_ta_mask |= 1 << addr;
+	of_property_read_u32(child, "reset-assert-us",
+			     &mdiodev->reset_assert_delay);
+	of_property_read_u32(child, "reset-deassert-us",
+			     &mdiodev->reset_deassert_delay);
+
+	dev->speed = SPEED_UNKNOWN;
+	dev->duplex = DUPLEX_UNKNOWN;
+	dev->pause = 0;
+	dev->asym_pause = 0;
+	dev->link = 0;
+	dev->interface = PHY_INTERFACE_MODE_GMII;
+	dev->autoneg = AUTONEG_ENABLE;
+	dev->is_c45 = is_c45;
+
+	dev_set_name(&mdiodev->dev, PHY_ID_FMT, bus->id, addr);
+	device_initialize(&mdiodev->dev);
+
+	dev->state = PHY_DOWN;
+
+	mutex_init(&dev->lock);
+	INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine);
+
+	ret = mdiobus_register_device(mdiodev);
+	if (ret)
+		return ERR_PTR(ret);
+
+	/* Deassert the reset signal */
+	phy_device_reset(dev, 0);
+
+	if (phy_id == U32_MAX) {
+		phy_id = 0;
+
+		c45_ids.devices_in_package = 0;
+		c45_ids.mmds_present = 0;
+		memset(c45_ids.device_ids, 0xff, sizeof(c45_ids.device_ids));
+
+		if (is_c45)
+			ret = get_phy_c45_ids(bus, addr, &c45_ids);
+		else
+			ret = get_phy_c22_id(bus, addr, &phy_id);
+
+		if (ret)
+			goto err_out;
+
+		dev->phy_id = phy_id;
+		dev->c45_ids = c45_ids;
+	} else {
+		dev->phy_id = phy_id;
+	}
+
+	/* Run all of the fixups for this PHY */
+	ret = phy_scan_fixups(dev);
+	if (ret) {
+		phydev_err(dev, "failed to initialize\n");
+		goto err_out;
+	}
+
+	/* Request the appropriate module unconditionally; don't
+	 * bother trying to do so only if it isn't already loaded,
+	 * because that gets complicated. A hotplug event would have
+	 * done an unconditional modprobe anyway.
+	 * We don't do normal hotplug because it won't work for MDIO
+	 * -- because it relies on the device staying around for long
+	 * enough for the driver to get loaded. With MDIO, the NIC
+	 * driver will get bored and give up as soon as it finds that
+	 * there's no driver _already_ loaded.
+	 */
+	if (is_c45) {
+		const int num_ids = ARRAY_SIZE(c45_ids.device_ids);
+		int i;
+
+		for (i = 1; i < num_ids; i++) {
+			if (c45_ids.device_ids[i] == 0xffffffff)
+				continue;
+
+			ret = phy_request_driver_module(dev,
+							c45_ids.device_ids[i]);
+			if (ret)
+				break;
+		}
+	} else {
+		ret = phy_request_driver_module(dev, phy_id);
+	}
+
+	if (ret)
+		goto err_out;
+
+	ret = device_add(&mdiodev->dev);
+	if (ret) {
+		phydev_err(dev, "failed to add\n");
+		goto err_out;
+	}
+
+	return dev;
+
+err_out:
+	/* Assert the reset signal */
+	phy_device_reset(dev, 1);
+
+	mdiobus_unregister_device(mdiodev);
+	put_device(&mdiodev->dev);
+	return  ERR_PTR(ret);
+}
+
 static struct phy_driver genphy_driver = {
 	.phy_id		= 0xffffffff,
 	.phy_id_mask	= 0xffffffff,
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 4daf94bb56a5..26783a9193da 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -10,6 +10,7 @@
 
 #include <linux/kernel.h>
 #include <linux/device.h>
+#include <linux/gpio/consumer.h>
 #include <linux/netdevice.h>
 #include <linux/err.h>
 #include <linux/phy.h>
@@ -105,7 +106,7 @@ int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
 EXPORT_SYMBOL(of_mdiobus_phy_device_register);
 
 static int of_mdiobus_register_phy(struct mii_bus *mdio,
-				    struct device_node *child, u32 addr)
+				   struct device_node *child, u32 addr)
 {
 	struct mii_timestamper *mii_ts;
 	struct phy_device *phy;
@@ -120,16 +121,42 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
 	is_c45 = of_device_is_compatible(child,
 					 "ethernet-phy-ieee802.3-c45");
 
-	if (!is_c45 && !of_get_phy_id(child, &phy_id))
-		phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
-	else
+	if (!is_c45 && !of_get_phy_id(child, &phy_id)) {
+		phy = of_phy_device_create(mdio, child, addr, phy_id, 0);
+	} else {
+		struct gpio_desc *reset_gpio;
+		unsigned int reset_assert_delay = DEFAULT_GPIO_RESET_DELAY;
+		unsigned int reset_deassert_delay = DEFAULT_GPIO_RESET_DELAY;
+
+		reset_gpio = gpiod_get_from_of_node(child, "reset-gpios", 0,
+						    GPIOD_OUT_LOW,  "PHY reset");
+		if (IS_ERR(reset_gpio)) {
+			if (PTR_ERR(reset_gpio) == -ENOENT)
+				reset_gpio = NULL;
+			else
+				return PTR_ERR(reset_gpio);
+		}
+
+		if (reset_gpio) {
+			gpiod_set_value_cansleep(reset_gpio, 1);
+			fsleep(reset_assert_delay);
+			gpiod_set_value_cansleep(reset_gpio, 0);
+			fsleep(reset_deassert_delay);
+			pr_err("========== reset PHY\n");
+		}
+// option 2
+//		phy = of_phy_device_create(mdio, child, addr, U32_MAX, is_c45);
 		phy = get_phy_device(mdio, addr, is_c45);
+
+		gpiod_put(reset_gpio);
+	}
 	if (IS_ERR(phy)) {
 		if (mii_ts)
 			unregister_mii_timestamper(mii_ts);
 		return PTR_ERR(phy);
 	}
 
+// option 2 - remove
 	rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
 	if (rc) {
 		if (mii_ts)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index eb3cb1a98b45..3e5efb120cad 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1753,4 +1753,7 @@ module_exit(phy_module_exit)
 bool phy_driver_is_genphy(struct phy_device *phydev);
 bool phy_driver_is_genphy_10g(struct phy_device *phydev);
 
+struct phy_device *of_phy_device_create(struct mii_bus *bus, struct device_node *child,
+					int addr, u32 phy_id, bool is_c45);
+
 #endif /* __PHY_H */
