Merge tag 'dmaengine-4.3-rc1' of git://git.infradead.org/users/vkoul/slave-dma
[cascardo/linux.git] / drivers / of / of_mdio.c
index fdc60db..1350fa2 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/phy.h>
 #include <linux/phy_fixed.h>
 #include <linux/of.h>
+#include <linux/of_gpio.h>
 #include <linux/of_irq.h>
 #include <linux/of_mdio.h>
 #include <linux/module.h>
@@ -266,7 +267,8 @@ EXPORT_SYMBOL(of_phy_attach);
 bool of_phy_is_fixed_link(struct device_node *np)
 {
        struct device_node *dn;
-       int len;
+       int len, err;
+       const char *managed;
 
        /* New binding */
        dn = of_get_child_by_name(np, "fixed-link");
@@ -275,6 +277,10 @@ bool of_phy_is_fixed_link(struct device_node *np)
                return true;
        }
 
+       err = of_property_read_string(np, "managed", &managed);
+       if (err == 0 && strcmp(managed, "auto") != 0)
+               return true;
+
        /* Old binding */
        if (of_get_property(np, "fixed-link", &len) &&
            len == (5 * sizeof(__be32)))
@@ -289,8 +295,19 @@ int of_phy_register_fixed_link(struct device_node *np)
        struct fixed_phy_status status = {};
        struct device_node *fixed_link_node;
        const __be32 *fixed_link_prop;
-       int len;
+       int link_gpio;
+       int len, err;
        struct phy_device *phy;
+       const char *managed;
+
+       err = of_property_read_string(np, "managed", &managed);
+       if (err == 0) {
+               if (strcmp(managed, "in-band-status") == 0) {
+                       /* status is zeroed, namely its .link member */
+                       phy = fixed_phy_register(PHY_POLL, &status, -1, np);
+                       return IS_ERR(phy) ? PTR_ERR(phy) : 0;
+               }
+       }
 
        /* New binding */
        fixed_link_node = of_get_child_by_name(np, "fixed-link");
@@ -303,8 +320,13 @@ int of_phy_register_fixed_link(struct device_node *np)
                status.pause = of_property_read_bool(fixed_link_node, "pause");
                status.asym_pause = of_property_read_bool(fixed_link_node,
                                                          "asym-pause");
+               link_gpio = of_get_named_gpio_flags(fixed_link_node,
+                                                   "link-gpios", 0, NULL);
                of_node_put(fixed_link_node);
-               phy = fixed_phy_register(PHY_POLL, &status, np);
+               if (link_gpio == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
+
+               phy = fixed_phy_register(PHY_POLL, &status, link_gpio, np);
                return IS_ERR(phy) ? PTR_ERR(phy) : 0;
        }
 
@@ -316,7 +338,7 @@ int of_phy_register_fixed_link(struct device_node *np)
                status.speed = be32_to_cpu(fixed_link_prop[2]);
                status.pause = be32_to_cpu(fixed_link_prop[3]);
                status.asym_pause = be32_to_cpu(fixed_link_prop[4]);
-               phy = fixed_phy_register(PHY_POLL, &status, np);
+               phy = fixed_phy_register(PHY_POLL, &status, -1, np);
                return IS_ERR(phy) ? PTR_ERR(phy) : 0;
        }