PHYs attached to DSAs may provide IRQs from GPIOs or other
interrupt controllers in the device tree. For these cases,
we need to go and grab the IRQ before registering the slave
so the PHY core can grab and enable this IRQ.

Cc: Antti Seppälä <a.sepp...@gmail.com>
Cc: Roman Yeryomin <ro...@advem.lv>
Cc: Colin Leitner <colin.leit...@googlemail.com>
Cc: Gabor Juhos <juh...@openwrt.org>
Cc: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Linus Walleij <linus.wall...@linaro.org>
---
 net/dsa/slave.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 2afa99506f8b..9909d7fe80b1 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -15,6 +15,7 @@
 #include <linux/phy_fixed.h>
 #include <linux/of_net.h>
 #include <linux/of_mdio.h>
+#include <linux/of_irq.h>
 #include <linux/mdio.h>
 #include <linux/list.h>
 #include <net/rtnetlink.h>
@@ -1119,6 +1120,13 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv 
*p,
                return -ENODEV;
        }
 
+       /*
+        * If the PHY has a link IRQ associated with it in the device tree,
+        * then assign it so it can be claimed by the core.
+        */
+       if (of_irq_count(p->dp->dn))
+               p->phy->irq = irq_of_parse_and_map(p->dp->dn, 0);
+
        /* Use already configured phy mode */
        if (p->phy_interface == PHY_INTERFACE_MODE_NA)
                p->phy_interface = p->phy->interface;
-- 
2.13.6

Reply via email to