#include <linux/delay.h>
 #include <linux/ethtool.h>
 #include <linux/kernel.h>
+#include <linux/mdio.h>
 #include <linux/mii.h>
 #include <linux/module.h>
 #include <linux/phy.h>
 #include <linux/hwmon.h>
 #include <linux/bitfield.h>
+#include <linux/of_mdio.h>
+#include <linux/of_irq.h>
 
 #define PHY_ID_MASK                    0xfffffff0
 #define PHY_ID_TJA1100                 0x0180dc40
 struct tja11xx_priv {
        char            *hwmon_name;
        struct device   *hwmon_dev;
+       struct phy_device *phydev;
+       struct work_struct phy_register_work;
 };
 
 struct tja11xx_phy_stats {
        .info           = tja11xx_hwmon_info,
 };
 
-static int tja11xx_probe(struct phy_device *phydev)
+static int tja11xx_hwmon_register(struct phy_device *phydev,
+                                 struct tja11xx_priv *priv)
 {
        struct device *dev = &phydev->mdio.dev;
-       struct tja11xx_priv *priv;
        int i;
 
-       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-       if (!priv)
-               return -ENOMEM;
-
        priv->hwmon_name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL);
        if (!priv->hwmon_name)
                return -ENOMEM;
        return PTR_ERR_OR_ZERO(priv->hwmon_dev);
 }
 
+static int tja11xx_probe(struct phy_device *phydev)
+{
+       struct device *dev = &phydev->mdio.dev;
+       struct tja11xx_priv *priv;
+
+       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       priv->phydev = phydev;
+
+       return tja11xx_hwmon_register(phydev, priv);
+}
+
+static void tja1102_p1_register(struct work_struct *work)
+{
+       struct tja11xx_priv *priv = container_of(work, struct tja11xx_priv,
+                                                phy_register_work);
+       struct phy_device *phydev_phy0 = priv->phydev;
+       struct mii_bus *bus = phydev_phy0->mdio.bus;
+       struct device *dev = &phydev_phy0->mdio.dev;
+       struct device_node *np = dev->of_node;
+       struct device_node *child;
+       int ret;
+
+       for_each_available_child_of_node(np, child) {
+               struct phy_device *phy;
+               int addr;
+
+               addr = of_mdio_parse_addr(dev, child);
+               if (addr < 0) {
+                       dev_err(dev, "Can't parse addr\n");
+                       continue;
+               } else if (addr != phydev_phy0->mdio.addr + 1) {
+                       /* Currently we care only about double PHY chip TJA1102.
+                        * If some day NXP will decide to bring chips with more
+                        * PHYs, this logic should be reworked.
+                        */
+                       dev_err(dev, "Unexpected address. Should be: %i\n",
+                               phydev_phy0->mdio.addr + 1);
+                       continue;
+               }
+
+               if (mdiobus_is_registered_device(bus, addr)) {
+                       dev_err(dev, "device is already registered\n");
+                       continue;
+               }
+
+               /* Real PHY ID of Port 1 is 0 */
+               phy = phy_device_create(bus, addr, PHY_ID_TJA1102, false, NULL);
+               if (IS_ERR(phy)) {
+                       dev_err(dev, "Can't create PHY device for Port 1: %i\n",
+                               addr);
+                       continue;
+               }
+
+               /* Overwrite parent device. phy_device_create() set parent to
+                * the mii_bus->dev, which is not correct in case.
+                */
+               phy->mdio.dev.parent = dev;
+
+               ret = of_mdiobus_phy_device_register(bus, phy, child, addr);
+               if (ret) {
+                       /* All resources needed for Port 1 should be already
+                        * available for Port 0. Both ports use the same
+                        * interrupt line, so -EPROBE_DEFER would make no sense
+                        * here.
+                        */
+                       dev_err(dev, "Can't register Port 1. Unexpected error: %i\n",
+                               ret);
+                       phy_device_free(phy);
+               }
+       }
+}
+
+static int tja1102_p0_probe(struct phy_device *phydev)
+{
+       struct device *dev = &phydev->mdio.dev;
+       struct tja11xx_priv *priv;
+       int ret;
+
+       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       priv->phydev = phydev;
+       INIT_WORK(&priv->phy_register_work, tja1102_p1_register);
+
+       ret = tja11xx_hwmon_register(phydev, priv);
+       if (ret)
+               return ret;
+
+       schedule_work(&priv->phy_register_work);
+
+       return 0;
+}
+
 static int tja1102_match_phy_device(struct phy_device *phydev, bool port0)
 {
        int ret;
        }, {
                .name           = "NXP TJA1102 Port 0",
                .features       = PHY_BASIC_T1_FEATURES,
-               .probe          = tja11xx_probe,
+               .probe          = tja1102_p0_probe,
                .soft_reset     = tja11xx_soft_reset,
                .config_init    = tja11xx_config_init,
                .read_status    = tja11xx_read_status,